/* Shared semantic colours. Component fallbacks preserve the original light palette. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --theme-canvas: #18191c;
  --theme-surface: #242528;
  --theme-surface-muted: #2b2d31;
  --theme-surface-glass: #24262aee;
  --theme-hover: #34373c;
  --theme-selected: #363b40;
  --theme-line: #3a3d43;
  --theme-text: #e8eaed;
  --theme-muted: #c1c5cc;
  --theme-accent: #c0cec7;
  --theme-accent-border: #84928b;
  --theme-on-accent: #212823;
  --theme-green-text: #b8cdbf;
  --theme-green-soft: #303a34;
  --theme-blue-text: #b9c8dc;
  --theme-blue-soft: #303844;
  --theme-blue-solid: #b9c6d8;
  --theme-purple-text: #cbc0da;
  --theme-purple-soft: #39333f;
  --theme-purple-solid: #c2b5d0;
  --theme-amber-text: #d8c8a8;
  --theme-amber-soft: #3e392f;
  --theme-amber-solid: #d2c3a6;
  --theme-red-text: #dcbab1;
  --theme-red-soft: #433532;
  --theme-red-solid: #d6b3a9;
  --theme-shadow: #00000030;
  --theme-scrim: #000000a8;
  --green: var(--theme-accent);
  --green-dark: #d3dcd7;
  --muted: var(--theme-muted);
  --line: var(--theme-line);
  --bg: var(--theme-canvas);
  --mint: var(--theme-green-soft);
  scrollbar-color: #5b6068 #202226;
}
:root[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] :is(.sidebar,.mobile-rail,.fm-sidebar) { background: #1e2023; }
html[data-theme="dark"] .topbar { background: #1b1d20ed; border-bottom-color: var(--line); }
html[data-theme="dark"] .welcome-banner { background: linear-gradient(115deg,#303337,#282b2f); }
html[data-theme="dark"] .welcome-copy h2 { color: var(--theme-text); }
html[data-theme="dark"] .holiday-banner { background: linear-gradient(115deg,#33322f,#292a2b); }
html[data-theme="dark"] .brand.school-brand .brand-tagline { color: #dddcd1; }
html[data-theme="dark"] .chat-workspace .conversation { background: #1d1f22; }
html[data-theme="dark"] .chat-message { background: #2b2e33; }
html[data-theme="dark"] .chat-message.self { background: #363c40; border-color: #485157; }
html[data-theme="dark"] .chat-text { color: var(--theme-text); }
html[data-theme="dark"] .chat-message-meta { color: var(--theme-muted); }
html[data-theme="dark"] .chat-sender { color: #cddbd2; }
html[data-theme="dark"] .chat-workspace .thread.selected { box-shadow: inset 3px 0 #c0cec7; }
html[data-theme="dark"] :is(.chat-compose-input textarea,.form-stack input:not([type=checkbox]):not([type=file]),.form-stack textarea,.form-stack select,.diary-select select) { background: #1d1f22; }
html[data-theme="dark"] .homework-editor textarea { background: #1d1f22!important; color: var(--theme-text)!important; }
html[data-theme="dark"] :is(input,textarea)::placeholder { color: #b4b9c2; opacity: 1; }
html[data-theme="dark"] :is(input,textarea,select) { caret-color: #ccd9d1; }
html[data-theme="dark"] :is(input[type=checkbox],input[type=radio],progress) { accent-color: #c0cec7; }
html[data-theme="dark"] :is(input,textarea,select):disabled { color: #a6b5ab; opacity: .7; }
html[data-theme="dark"] .group-member-search input { background: #1d1f22!important; }
html[data-theme="dark"] .group-type-picker input:checked+span,
html[data-theme="dark"] .homework-format-grid input:checked+span { background: #383f3c; }
html[data-theme="dark"] :is(.button.primary,.chat-send,.demo-role-switch button[aria-pressed=true]) { color: var(--theme-on-accent); }
html[data-theme="dark"] .calendar-day.today { color: var(--theme-on-accent); background: var(--theme-accent); }
html[data-theme="dark"] #toast { background: #373f3a; border: 1px solid #75877a; color: #e0e5e1; }
html[data-theme="dark"] :is(#toast>.icon,.undo-button) { color: var(--theme-accent); }
html[data-theme="dark"] :focus-visible { outline-color: #bacfc1; }
html[data-theme="dark"] ::selection { background: #4c5a52; color: #fff; }

/* Shared theme control with a visible current state in both palettes. */
.topbar { position: sticky; top: 0; z-index: 20; backdrop-filter: blur(16px); }
.theme-toggle { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; height: 44px; padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: var(--theme-surface-muted,#f2f5f1); color: var(--muted); }
.theme-toggle-label { font-size: 11px; font-weight: 550; padding: 0 7px; }
.theme-toggle-light,.theme-toggle-dark { display: grid; place-items: center; width: 31px; height: 34px; border-radius: 9px; transition: background .18s,color .18s,box-shadow .18s; }
.theme-toggle .icon { width: 18px; height: 18px; }
.theme-toggle:hover { border-color: var(--theme-accent-border,#98b59e); }
html:not([data-theme="dark"]) .theme-toggle-light { color: #286546; background: #fff; box-shadow: 0 1px 5px #18342316; }
html[data-theme="dark"] .theme-toggle-dark { color: #dce4de; background: #4b5750; box-shadow: 0 1px 5px #0003; }
.login-theme { position: absolute; top: 22px; right: 26px; }
@media(max-width:1100px) { .topbar .theme-toggle-label { display: none; } }
@media(max-width:760px) { .theme-toggle { border-radius: 11px; height: 44px; padding: 3px; gap: 1px; } .theme-toggle-light,.theme-toggle-dark { width: 27px; height: 34px; } .login-layout { padding-top: 88px; } .login-theme { top: 18px; right: 20px; } }
@media(prefers-reduced-motion:reduce) { .theme-toggle-light,.theme-toggle-dark { transition: none; } }
