/* MPEI brandbook, pp. 11–12: official colours and accessible screen roles.
   Scientific colour maps and source illustrations retain their original colours. */
:root {
  --mpei-blue:#004077; --mpei-red:#c10630; --mpei-black:#000001;
  --mpei-blue-70:#718db1; --mpei-blue-40:#b7c4d6; --mpei-blue-20:#d6dde6;
  --mpei-red-70:#d68587; --mpei-red-40:#eac1c3; --mpei-red-20:#f0dada;
  --mpei-gray-70:#343437; --mpei-gray-40:#83838c; --mpei-gray-20:#c6c6c6;
  color-scheme:light;
  --theme-page:#fff; --theme-surface:#f4f6f9; --theme-raised:#fff;
  --theme-text:var(--mpei-gray-70); --theme-muted:#54545c;
  --theme-heading:var(--mpei-blue); --theme-link:var(--mpei-blue); --theme-visited:var(--mpei-red);
  --theme-line:var(--mpei-blue-20); --theme-control:#64748a;
  --theme-active:var(--mpei-blue-20); --theme-accent:var(--mpei-red);
  --theme-notice:#faf1f1; --theme-notice-text:#7f1532;
  --theme-primary:var(--mpei-blue); --theme-on-primary:#fff;
  --theme-focus:var(--mpei-red); --theme-code-keyword:var(--mpei-blue);
  --theme-code-literal:#922541; --theme-selection:var(--mpei-blue-20);
  --theme-selection-text:var(--mpei-black);
  --theme-header:var(--mpei-blue); --theme-header-active:#002e56;
  --theme-header-line:var(--mpei-red-70);
}
:root[data-theme=dark] {
  color-scheme:dark;
  --theme-page:#1b1b1e; --theme-surface:#27272b; --theme-raised:var(--mpei-gray-70);
  --theme-text:var(--mpei-blue-20); --theme-muted:var(--mpei-blue-40);
  --theme-heading:#f2f4f8; --theme-link:var(--mpei-blue-40); --theme-visited:var(--mpei-red-40);
  --theme-line:#48484f; --theme-control:var(--mpei-gray-40);
  --theme-active:var(--mpei-gray-70); --theme-accent:var(--mpei-red-70);
  --theme-notice:#33282c; --theme-notice-text:var(--mpei-red-40);
  --theme-primary:var(--mpei-blue-40); --theme-on-primary:var(--mpei-blue);
  --theme-focus:var(--mpei-red-40); --theme-code-keyword:var(--mpei-blue-40);
  --theme-code-literal:var(--mpei-red-40); --theme-selection:var(--mpei-blue-40);
  --theme-selection-text:var(--mpei-black);
}
@media(prefers-color-scheme:dark) {
  :root:not([data-theme=light]) {
    color-scheme:dark;
    --theme-page:#1b1b1e; --theme-surface:#27272b; --theme-raised:var(--mpei-gray-70);
    --theme-text:var(--mpei-blue-20); --theme-muted:var(--mpei-blue-40);
    --theme-heading:#f2f4f8; --theme-link:var(--mpei-blue-40); --theme-visited:var(--mpei-red-40);
    --theme-line:#48484f; --theme-control:var(--mpei-gray-40);
    --theme-active:var(--mpei-gray-70); --theme-accent:var(--mpei-red-70);
    --theme-notice:#33282c; --theme-notice-text:var(--mpei-red-40);
    --theme-primary:var(--mpei-blue-40); --theme-on-primary:var(--mpei-blue);
    --theme-focus:var(--mpei-red-40); --theme-code-keyword:var(--mpei-blue-40);
    --theme-code-literal:var(--mpei-red-40); --theme-selection:var(--mpei-blue-40);
    --theme-selection-text:var(--mpei-black);
  }
}
/* Bridge the existing page families to one set of screen roles. */
:root {
  --blue:var(--theme-link); --red:var(--theme-accent); --ink:var(--theme-text);
  --muted:var(--theme-muted); --line:var(--theme-line); --wash:var(--theme-surface);
  --soft:var(--theme-surface); --surface:var(--theme-surface); --accent:var(--theme-accent);
  --table-ink:var(--theme-text); --table-head:var(--theme-surface); --table-stripe:var(--theme-surface);
  --lp-blue:var(--theme-link); --lp-gold:var(--theme-accent);
  --lp-border:var(--theme-line); --lp-soft:var(--theme-surface);
}
html, body[data-platform], body[data-platform] main#main {
  background:var(--theme-page); color:var(--theme-text);
}
body[data-platform] main#main :is(h1,h2,h3,h4,h5,h6) {color:var(--theme-heading)}
body[data-platform] a {color:var(--theme-link)}
body[data-platform] main#main a:visited {color:var(--theme-visited)}
body[data-platform] a:hover {text-decoration-thickness:2px;text-underline-offset:3px}
body[data-platform] :is(a,button,input,select,textarea,summary,[tabindex]):focus-visible {
  outline:3px solid var(--theme-focus);outline-offset:3px;
}
body[data-platform] ::selection {background:var(--theme-selection);color:var(--theme-selection-text)}
body[data-platform] :is(button,input,select,textarea) {
  border-color:var(--theme-control);background:var(--theme-raised);color:var(--theme-text);accent-color:var(--theme-accent);
}
body[data-platform] :is(input,select,textarea) {color-scheme:inherit}
body[data-platform] input::placeholder, body[data-platform] textarea::placeholder {color:var(--theme-muted);opacity:1}
body[data-platform] button:hover {background:var(--theme-active)}
body[data-platform] button[aria-pressed=true] {background:var(--theme-primary);color:var(--theme-on-primary)}
body[data-platform] :is(button,input,select,textarea):disabled {opacity:.65;cursor:not-allowed}
/* The blue brand masthead remains recognisable in both themes. */
body[data-platform] .lp-header {background:var(--theme-header);color:#fff;border-bottom-color:var(--theme-header-line);gap:12px}
body[data-platform] .lp-header a {color:#fff}
body[data-platform] .lp-header a:hover,body[data-platform] .lp-header a[aria-current] {background:var(--theme-header-active)}
body[data-platform] .lp-header :focus-visible {outline-color:#fff}
.lp-theme-control {display:flex;align-items:center;gap:8px;font:14px var(--lp-sans);white-space:nowrap}
body[data-platform] .lp-theme-control select {min-height:44px;width:138px;border:1px solid var(--mpei-blue-40);border-radius:4px;padding:6px 8px;background:var(--theme-header);color:#fff;color-scheme:dark;font:14px var(--lp-sans)}
body[data-platform] .lp-theme-control select option {background:var(--theme-header);color:#fff}
body[data-platform] :is(.lp-page-controls,.lp-mobile,.lp-dialog-head,.lp-part) {background:var(--theme-page);color:var(--theme-text)}
body[data-platform] :is(.lp-part>summary,.lp-inline-toc summary) {background:var(--theme-surface)}
body[data-platform] .lp-part li {border-color:var(--theme-line)}
body[data-platform] .lp-part a[aria-current] {background:var(--theme-active);color:var(--theme-link);border-left-color:var(--theme-accent)}
body[data-platform] :is(.lp-outline a,.lp-muted,.lp-type,.lp-route-label,.lp-legacy,.lp-files small,.lp-filters p) {color:var(--theme-muted)}
body[data-platform] .lp-outline a[aria-current] {color:var(--theme-link);border-left-color:var(--theme-accent)}
body[data-platform] .lp-mobile :is(a,button) {color:var(--theme-link);background:var(--theme-page)}
body[data-platform] .lp-hub .lp-primary,body[data-platform] .lp-pagination a[aria-current] {background:var(--theme-primary);color:var(--theme-on-primary)}
body[data-platform] :is(.lp-quick,.lp-sequence) a {background:var(--theme-surface);color:var(--theme-link)}
body[data-platform] dialog {background:var(--theme-page);color:var(--theme-text);border-color:var(--theme-control);box-shadow:0 16px 64px #0006}
body[data-platform] dialog::backdrop {background:#0009}
body[data-platform] :is(.lp-noscript,#lp-navigation-warning) {background:var(--theme-notice);color:var(--theme-notice-text)}
body[data-platform] #lp-navigation-warning:empty {background:none}
/* Reading, captions, reference cards and laboratory controls. */
body[data-platform] main#main :is(.lead,.learning-panel,.engineering-panel,.widget,.mini-lab,.optimization-widget,.optimization-application,.native-series,.course-utility article,.reference-item,.femm-reference-card,.micro-module-card,.micro-chapter,.example-card,.package-card,.book-module,.field-lab-catalog article,.field-lab-preview) {
  color:var(--theme-text);background:var(--theme-page);border-color:var(--theme-line);
}
body[data-platform] main#main :is(.note,.manual-math-context,.manual-figure-key,.field-theory-links,.block,.notation-guide,.engineering-output,.widget-stat,.engineering-stat,.opt-stats>div,.lab-sweep-controls,.micro-signature,.micro-finder,.reference-toolbar,.lesson-selfcheck,.learning-summary,.learning-feedback,.learning-hints p) {
  background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-line);
}
body[data-platform] main#main :is(.note,.manual-math-context,.field-theory-links,.block) {border-left-color:var(--theme-link)}
body[data-platform] main#main :is(.result,.applicability,.engineering-notice,.opt-notice,.lab-live-feedback,.block.warn,.annotation-note,.learning-storage-warning) {
  background:var(--theme-notice);color:var(--theme-text);border-left-color:var(--theme-accent);
}
body[data-platform] main#main :is(.source-note,.reading-location,.reading-details,.references,.manual-figure-source,.manual-caption-note,.manual-table-notes,.math-scroll-hint,.table-scroll-status,.field-math-axes,.lab-hint,.lab-range,.selfcheck-optional,.selfcheck-intro,.learning-source,.plot-caption,.copy-status,.opt-stats dt,figcaption) {color:var(--theme-muted)}
body[data-platform] main#main :is(.eyebrow,.data-error) {color:var(--theme-accent)}
body[data-platform] main#main :is(.course-breadcrumb,.model-portrait-title) {color:var(--theme-muted)}
body[data-platform] main#main .femm-reference-picture {background:var(--theme-page)}
body[data-platform] main#main .reference-meta {color:var(--theme-muted)}
body[data-platform] main#main :is(.lab-main-chart,.lab-response-chart) {background:var(--theme-page)}
body[data-platform] main#main :is(.femm-reference-search,.femm-reference-volume,.micro-function-index) {background:var(--theme-surface);color:var(--theme-text)}
body[data-platform] main#main :is(.femm-reference-result,.micro-api-entry) {background:var(--theme-page);color:var(--theme-text);border-color:var(--theme-line)}
body[data-platform] main#main :is(.femm-reference-tag,.femm-reference-volume span) {color:var(--theme-muted)}
body[data-platform] main#main :is(.elcut-summary p,.elcut-page-nav,.elcut-filters,.subject-navigation,.part-number) {background:var(--theme-surface);color:var(--theme-text)}
body[data-platform] main#main :is(.elcut-card,.curriculum-card,.practice-field-figure) {background:var(--theme-page);color:var(--theme-text);border-color:var(--theme-line)}
body[data-platform] main#main :is(.elcut-files small,.curriculum-card>span:last-child,.part-heading p) {color:var(--theme-muted)}
body[data-platform] main#main :is(.subject-navigation a,.elcut-summary strong,.model-portrait-more summary,.model-portrait-list-title) {color:var(--theme-link)}
body[data-platform] main#main :is(.lab-kicker,.widget-stat strong,.engineering-stat strong,.opt-control output,.widget-controls legend,.lab-transfer summary,.field-theory-text details.solution summary) {color:var(--theme-link)}
body[data-platform] main#main :is(.data-badge,.pilot-label,.opt-best,.opt-live) {background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-control)}
body[data-platform] main#main :is(button,input,select,textarea) {color:var(--theme-text);background:var(--theme-raised);border-color:var(--theme-control)}
body[data-platform] main#main button:hover {background:var(--theme-active)}
body[data-platform] main#main button[aria-pressed=true] {background:var(--theme-primary);color:var(--theme-on-primary)}
body[data-platform] main#main :is(.table-wrap,.engineering-table,table) {background:var(--theme-page);color:var(--theme-text)}
body[data-platform] main#main table :is(th,td) {background:var(--theme-page);color:var(--theme-text);border-color:var(--theme-line)}
body[data-platform] main#main table thead th {background:var(--theme-surface);color:var(--theme-heading)}
body[data-platform] main#main table tbody tr:nth-child(even)>:is(th,td) {background:var(--theme-page)}
body[data-platform] main#main table.table-striped tbody tr:nth-child(even)>:is(th,td) {background:var(--theme-surface)}
body[data-platform] main#main table tbody tr:hover>:is(th,td),body[data-platform] main#main table tr.selected>:is(th,td) {background:var(--theme-active)}
body[data-platform] main#main :is(.unit-cell,.table-unit) {color:var(--theme-muted)}
body[data-platform] main#main :is(.formula,.formula-number,.math,.katex) {color:var(--theme-text)}
body[data-platform] main#main .formula {background:transparent}
body[data-platform] main#main :is(.formula,.author-bibliography li,.bibliography-list>li):target {background:var(--theme-notice);outline:2px solid var(--theme-accent);outline-offset:3px;animation:none}
body[data-platform] main#main mark {background:var(--theme-selection);color:var(--theme-selection-text)}
body[data-platform] main#main :is(pre,code,kbd,samp,.code-toolbar,.code-block pre,.python-code) {background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-line)}
body[data-platform] main#main .code-toolbar {background:var(--theme-active)}
body[data-platform] main#main pre code {background:transparent}
body[data-platform] main#main .python-code span {color:var(--theme-text)!important;background:transparent}
body[data-platform] main#main .python-code :is(.c,.c1,.ch,.cm,.cp,.cpf,.cs,.go) {color:var(--theme-muted)!important}
body[data-platform] main#main .python-code :is(.k,.kc,.kd,.kn,.kp,.kr,.kt,.nb,.nf,.nc,.nn,.bp,.fm) {color:var(--theme-code-keyword)!important;font-weight:600}
body[data-platform] main#main .python-code :is(.s,.s1,.s2,.sa,.sb,.sc,.sd,.se,.sh,.si,.sr,.ss,.sx,.m,.mi,.mf,.mh,.mo,.mb,.il,.err) {color:var(--theme-code-literal)!important}
/* Theme-aware field laboratories use the same UI tokens. Physical colour maps stay semantic. */
body[data-platform] main#main .field-theory {
  --paper:var(--theme-page);--paper-2:var(--theme-surface);--paper-3:var(--theme-active);
  --ink:var(--theme-text);--ink-2:var(--theme-text);--muted:var(--theme-muted);--rule:var(--theme-control);
  --accent:var(--theme-link);--accent-ink:var(--theme-on-primary);--focus:var(--theme-focus);
  --def-bg:var(--theme-surface);--def-border:var(--theme-link);--theorem-bg:var(--theme-surface);
  --example-bg:var(--theme-surface);--warn-bg:var(--theme-notice);--note-bg:var(--theme-surface);
  color:var(--theme-text);
}
/* Native screenshots, plots and scanned figures are light documents, never inverted. */
body[data-platform] main#main :is(img,canvas,.native-series svg,.opt-chart,.engineering-plot,.lab-schematic,.lab-main-chart svg,.lab-response-chart svg) {color-scheme:only light;background:#fff}
body[data-platform] main#main .field-theory canvas {background:var(--theme-page);color-scheme:inherit}
body[data-platform] main#main .field-theory .lab-stage .overlay {background:var(--theme-surface);color:var(--theme-text)}
/* DOM labels projected over a canvas need an opaque reading surface. */
body[data-platform] main#main .field-theory .stage-canvas-wrap>div>div {background:var(--theme-page)!important;color:var(--theme-text)!important;border:1px solid var(--theme-control)}
body[data-platform] .figure-viewer-scroll {background:var(--theme-surface)}
body[data-platform] .figure-viewer-tools :is(button,a) {background:var(--theme-raised);color:var(--theme-link);border-color:var(--theme-control)}
@media(max-width:1100px) {.lp-theme-control>span{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}.lp-header nav{gap:0}.lp-header a{padding-inline:7px}}
@media(max-width:900px) {body[data-platform] .lp-header{gap:8px}body[data-platform] .lp-header>[data-open-search]{margin-left:auto}.lp-theme-control select{max-width:120px}.lp-theme-control{gap:0}}
@media(prefers-reduced-motion:reduce) {html{scroll-behavior:auto!important}body[data-platform] *,body[data-platform] *::before,body[data-platform] *::after{animation:none!important;transition:none!important}}
@media(prefers-contrast:more) {:root{--theme-control:var(--theme-text);--theme-line:var(--theme-muted)}body[data-platform] a{text-decoration:underline}}
@media(forced-colors:active) {
  body[data-platform] :is(a,button,input,select,textarea,summary,[tabindex]):focus-visible {outline:3px solid Highlight}
  body[data-platform] :is(button,input,select,textarea){border:1px solid ButtonText}
  body[data-platform] :is(a[aria-current],button[aria-pressed=true]) {outline:2px solid Highlight;text-decoration:underline}
}

/* The laboratory scene can still be adjusted independently of the page. */
body[data-platform] main#main .field-theory[data-theme=light] {
  --mpei-blue:#004077; --mpei-red:#c10630; --mpei-black:#000001;
  --mpei-blue-70:#718db1; --mpei-blue-40:#b7c4d6; --mpei-blue-20:#d6dde6;
  --mpei-red-70:#d68587; --mpei-red-40:#eac1c3; --mpei-red-20:#f0dada;
  --mpei-gray-70:#343437; --mpei-gray-40:#83838c; --mpei-gray-20:#c6c6c6;
  color-scheme:light;
  --theme-page:#fff; --theme-surface:#f4f6f9; --theme-raised:#fff;
  --theme-text:var(--mpei-gray-70); --theme-muted:#54545c;
  --theme-heading:var(--mpei-blue); --theme-link:var(--mpei-blue); --theme-visited:var(--mpei-red);
  --theme-line:var(--mpei-blue-20); --theme-control:#64748a;
  --theme-active:var(--mpei-blue-20); --theme-accent:var(--mpei-red);
  --theme-notice:#faf1f1; --theme-notice-text:#7f1532;
  --theme-primary:var(--mpei-blue); --theme-on-primary:#fff;
  --theme-focus:var(--mpei-red); --theme-code-keyword:var(--mpei-blue);
  --theme-code-literal:#922541; --theme-selection:var(--mpei-blue-20);
  --theme-selection-text:var(--mpei-black);
  --theme-header:var(--mpei-blue); --theme-header-active:#002e56;
  --theme-header-line:var(--mpei-red-70);
}
body[data-platform] main#main .field-theory[data-theme=dark] {
  color-scheme:dark;
  --theme-page:#1b1b1e; --theme-surface:#27272b; --theme-raised:var(--mpei-gray-70);
  --theme-text:var(--mpei-blue-20); --theme-muted:var(--mpei-blue-40);
  --theme-heading:#f2f4f8; --theme-link:var(--mpei-blue-40); --theme-visited:var(--mpei-red-40);
  --theme-line:#48484f; --theme-control:var(--mpei-gray-40);
  --theme-active:var(--mpei-gray-70); --theme-accent:var(--mpei-red-70);
  --theme-notice:#33282c; --theme-notice-text:var(--mpei-red-40);
  --theme-primary:var(--mpei-blue-40); --theme-on-primary:var(--mpei-blue);
  --theme-focus:var(--mpei-red-40); --theme-code-keyword:var(--mpei-blue-40);
  --theme-code-literal:var(--mpei-red-40); --theme-selection:var(--mpei-blue-40);
  --theme-selection-text:var(--mpei-black);
}
@media print {
  :root,:root[data-theme],body[data-platform] main#main .field-theory[data-theme] {color-scheme:light;--theme-page:#fff;--theme-text:#000;--theme-heading:#000;--theme-link:#004077;--theme-muted:#343437;--theme-line:#83838c;--theme-surface:#fff;--theme-active:#fff;--theme-notice:#fff;--theme-accent:#c10630;--theme-code-keyword:#004077;--theme-code-literal:#922541}
  .lp-theme-control{display:none!important}
  body[data-platform] main#main a:visited{color:#004077}
}
