/* Approved Swiss Red identity. Legacy aliases stay outside .emh-ui: shadcn
   uses --muted for a surface; the retained controllers use it for text. */
@import url('/assets/fonts/inter/fonts.css');
@import url('/assets/fonts/jetbrains-mono/fonts.css');

:root, :root[data-theme='light'] {
  --emh-ink:#111111; --emh-muted:#626262; --emh-paper:#ffffff;
  --emh-surface:#ffffff; --emh-soft:#f5f5f5; --emh-line:#d4d4d4;
  --emh-primary:#db0000; --emh-primary-label:#ffffff;
  --emh-primary-text:#b50000; --emh-selected:#fff0f0; --emh-danger:#b50000;
  --emh-input:#111111; --emh-shadow:0 8px 28px rgb(0 0 0 / .08);
  --emh-font-sans:Inter,system-ui,sans-serif;
  --emh-font-mono:'JetBrains Mono',monospace;
  --emh-success:#177245; --emh-success-soft:#eaf7ef;
  --emh-warning:#875600; --emh-warning-soft:#fff5d6;
  --emh-danger-soft:#fff0f0;
  --emh-brand-surface:var(--emh-primary); --emh-brand-label:var(--emh-primary-label);
  --emh-nav-selected:var(--emh-primary); --emh-nav-selected-label:var(--emh-primary-label);
  color-scheme:light;
}
:root[data-theme='dark'] {
  --emh-ink:#f5f2f2; --emh-muted:#bdb2b2; --emh-paper:#141212;
  --emh-surface:#1c1919; --emh-soft:#282323; --emh-line:#4a4141;
  --emh-primary:#ae454c; --emh-primary-label:#ffffff;
  --emh-primary-text:#e59a9e; --emh-selected:#2f1c1c; --emh-danger:#ff9494;
  --emh-input:#827575; --emh-shadow:0 8px 28px rgb(0 0 0 / .25);
  --emh-success:#6bdca7; --emh-success-soft:#153b2b;
  --emh-warning:#ffd477; --emh-warning-soft:#3d3016;
  --emh-danger-soft:#351d1d;
  --emh-brand-surface:var(--emh-selected); --emh-brand-label:var(--emh-ink);
  --emh-nav-selected:var(--emh-selected); --emh-nav-selected-label:var(--emh-primary-text);
  color-scheme:dark;
}
:root, :root[data-theme], :root[data-theme] body.tutor-workspace {
  --ink:var(--emh-ink); --muted:var(--emh-muted); --paper:var(--emh-paper);
  --surface:var(--emh-surface); --surface-raised:var(--emh-surface);
  --surface-soft:var(--emh-soft); --line:var(--emh-line);
  --lav:var(--emh-selected); --lavender:var(--emh-selected);
  --violet:var(--emh-primary-text); --violet-strong:var(--emh-primary-text);
  --lilac:var(--emh-primary-text); --orange:var(--emh-primary); --coral:var(--emh-primary);
  --user-bubble:var(--emh-selected); --user-ink:var(--emh-ink); --shadow:transparent;
  --app-accent:var(--emh-primary-text); --app-soft:var(--emh-soft);
  --app-sidebar:var(--emh-surface); --app-selected:var(--emh-selected); --app-shadow:var(--emh-shadow);
  --calculator-ink:var(--emh-ink); --calculator-muted:var(--emh-muted);
  --calculator-accent:var(--emh-primary-text); --calculator-paper:var(--emh-soft);
  --calculator-panel:var(--emh-surface); --calculator-line:var(--emh-line);
  --calculator-soft:var(--emh-selected); --calculator-graph:var(--emh-paper);
  --calculator-grid:var(--emh-soft); --calculator-axis:var(--emh-input);
  --viewer-ink:var(--emh-ink); --viewer-muted:var(--emh-muted); --viewer-line:var(--emh-line);
  --viewer-bg:var(--emh-paper); --viewer-panel:var(--emh-surface); --viewer-accent:var(--emh-primary-text);
}
:root[data-theme] body, :root[data-theme] body.tutor-workspace {
  margin:0; background:var(--emh-paper); color:var(--emh-ink);
  font-family:var(--emh-font-sans); -webkit-font-smoothing:antialiased;
}
:root[data-theme] body :is(h1,h2,h3,h4,h5,h6,button,input,select,textarea,summary,.brand),
:root body.tutor-workspace :is(h1,h2,h3,h4,h5,h6,button,input,select,textarea,summary) {
  font-family:var(--emh-font-sans);
}
:root[data-theme] body :is(h1,h2,h3) { letter-spacing:-.035em; }
:root[data-theme] body :is(pre,code,kbd,.expression,.result,#range-label) { font-family:var(--emh-font-mono); }
:root[data-theme] body :is(a,button,input,textarea,select,summary,[tabindex]):focus-visible {
  outline:2px solid var(--emh-primary-text); outline-offset:4px;
}
:root[data-theme] body :is(input,select,textarea) { accent-color:var(--emh-primary); }
:root[data-theme] body :is(input:not([type='range']):not([type='checkbox']):not([type='radio']),select,textarea) {
  color:var(--emh-ink); background-color:var(--emh-surface); border-color:var(--emh-input);
}
:root[data-theme] body :is(.button,.auth-gate-action,.calculator-key.calculate),
:root[data-theme] body.tutor-workspace :is(.composer-toolbar .send,.call-action--primary,.code-workspace-button-primary,#confirm-tutor-speed,#read-user-textbook,#save-user-textbook) {
  background:var(--emh-primary); color:var(--emh-primary-label); border-color:var(--emh-primary);
  border-radius:10px; box-shadow:none; min-height:44px; font-weight:600;
}
:root[data-theme] body :is(.button,.auth-gate-action,.calculator-key.calculate):hover,
:root[data-theme] body.tutor-workspace :is(.composer-toolbar .send,.call-action--primary,.code-workspace-button-primary):hover {
  background:var(--emh-primary); color:var(--emh-primary-label); border-color:var(--emh-primary); filter:none; text-decoration:underline; transform:none;
}
:root[data-theme] body :is(.button-secondary,.button.button-secondary) {
  color:var(--emh-ink); background:var(--emh-surface); border:1px solid var(--emh-input);
}
:root[data-theme] body :is(.button-secondary,.button.button-secondary):hover { color:var(--emh-ink); background:var(--emh-soft); border-color:var(--emh-input); }
:root[data-theme] body :is(.library-chat-row,.tool-card,.course-dialog,.research-panel,.library-empty-state) {
  background:var(--emh-surface); color:var(--emh-ink); border-color:var(--emh-line); box-shadow:none; border-radius:10px;
}
:root[data-theme] body .learning-library {
  --library-accent:var(--emh-primary); --library-accent-text:var(--emh-primary-text);
  --library-surface:var(--emh-surface); --library-soft:var(--emh-selected);
}
:root[data-theme] body .library-context { border-radius:10px; border-left:4px solid var(--emh-primary); }
:root[data-theme] body .library-heading h1 { margin:0; }
:root[data-theme] body :is(.library-load-status,.auth-status):empty { display:none; }
:root[data-theme] body .library-chat-row:hover { transform:none; border-color:var(--emh-primary-text); }
:root[data-theme] body .library-load-status a { color:var(--emh-primary-text); }
:root[data-theme] body .course-dialog::backdrop { background:rgb(0 0 0 / .55); backdrop-filter:none; }
:root[data-theme] body .course-dialog :is(input,select,textarea) { background:var(--emh-paper); }
:root[data-theme] body .research-view-switch [aria-pressed='true'],
:root[data-theme] body .library-tabs [aria-selected='true'] { color:var(--emh-primary-text); border-color:var(--emh-primary); background:var(--emh-selected); }
:root[data-theme] body .research-phase { background:var(--emh-selected); color:var(--emh-primary-text); }
:root[data-theme] body .research-panel-heading, :root[data-theme] body .research-document { background:var(--emh-surface); }
:root[data-theme] body .research-heading h1 { font-size:clamp(1.8rem,3vw,2.5rem); }
:root[data-theme] body .calculator-workspace { border-radius:10px; }
:root[data-theme] body .calculator-mode-switch a[aria-current] { color:var(--emh-nav-selected-label); background:var(--emh-nav-selected); }
:root[data-theme] body .calculator-page-heading h1 { margin:0; }
:root[data-theme] body .result.is-error { color:var(--emh-danger); }
:root[data-theme] body .expression { border-radius:0; }
:root[data-theme] body.tutor-workspace .code-workspace { --code-accent-strong:var(--emh-primary); --code-panel-strong:var(--emh-soft); }
:root[data-theme] body.tutor-workspace .tutor-primary-actions { border-bottom:2px solid var(--emh-primary); }
:root[data-theme] body.tutor-workspace :is(.homework-auth-gate,.composer,.homework-message,.chat-textbook-dialog,.tutor-speed-dialog) { border-radius:10px; }
:root[data-theme] body footer { color:var(--emh-muted); }

/* Actual shadcn token vocabulary is scoped to its single-owner islands. */
.emh-ui {
  --background:var(--emh-paper); --foreground:var(--emh-ink);
  --card:var(--emh-surface); --card-foreground:var(--emh-ink);
  --popover:var(--emh-surface); --popover-foreground:var(--emh-ink);
  --primary:var(--emh-primary); --primary-foreground:var(--emh-primary-label);
  --secondary:var(--emh-soft); --secondary-foreground:var(--emh-ink);
  --muted:var(--emh-soft); --muted-foreground:var(--emh-muted);
  --accent:var(--emh-selected); --accent-foreground:var(--emh-primary-text);
  --destructive:var(--emh-danger); --border:var(--emh-line);
  --input:var(--emh-input); --ring:var(--emh-primary-text);
  --sidebar:var(--emh-surface); --radius:.625rem;
}
.emh-ui :where(a) { color:inherit; }

.emh-state-mount:empty { display:none; }
@media(max-width:760px) {
  :root[data-theme] body .learning-library { width:calc(100% - 32px); padding-top:24px; }
}
@media(prefers-reduced-motion:reduce) { :root[data-theme] body *,:root[data-theme] body *::before,:root[data-theme] body *::after { animation-duration:.01ms !important; transition-duration:.01ms !important; } }
