/* =========================================================
   KeyStart Academy — dark-mode.css
   "Night Campus" theme. Applied when <html> has the .dark class
   (set before first paint by the inline script in <head>).
   Screen only: printed receipts and certificates stay light.
   ========================================================= */
@media screen {
  html.dark {
    color-scheme: dark;
    --bg: #0A1426;
    --bg-grid: rgba(148, 163, 184, 0.05);
    --surface: #111E36;
    --surface-2: #0E1A30;
    --surface-3: #1A2946;
    --cream: #13213B;
    --line: #22355A;
    --line-strong: #31476F;
    --key-top: #16264A;
    --key-hover: #1B2D55;
    --key-edge: rgba(0, 0, 0, 0.4);
    --key-border: #2B4068;
    --ink: #F3F6FC;
    --ink-2: #CBD5E6;
    --muted: #9FAECA;
    --faint: #8E9DBA;
    --navy: #06101F;
    --navy-2: #0D1C36;
    --brand: #FFC233;
    --brand-hover: #FFD166;
    --brand-ink: #0A1426;
    --brand-soft: rgba(255, 194, 51, 0.14);
    --accent: #8FB0FF;
    --accent-hover: #B0C8FF;
    --accent-edge: #3F64D8;
    --accent-ink: #0A1426;
    --accent-soft: rgba(143, 176, 255, 0.13);
    --accent-soft-2: rgba(143, 176, 255, 0.28);
    --ok: #4ADE80;   --ok-soft: rgba(74, 222, 128, 0.12);
    --few: #FBBF24;  --few-soft: rgba(251, 191, 36, 0.12);
    --bad: #F87171;  --bad-soft: rgba(248, 113, 113, 0.13);
    --closed: #A3AEC2; --closed-soft: rgba(163, 174, 194, 0.12);
    --t-typing: #8FB0FF; --t-office: #4ADE80; --t-basics: #FBBF24; --t-advanced: #C4A1FF;
    --overlay: rgba(2, 6, 14, 0.72);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 18px 40px -16px rgba(0, 0, 0, 0.8);
    --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, 0.9);
    --lit: #FFC233;
    --lit-ink: #0A1426;
  }

  /* Base */
  html.dark body { background: var(--bg); }
  html.dark img:not(.cert-doc img):not(.deco) { filter: brightness(0.9); }

  /* Buttons */
  html.dark .keycap { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
  html.dark .keycap:hover { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
  html.dark .keycap-accent { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
  html.dark .keycap-accent:hover { background: #fff; border-color: #fff; color: #0A1426; }
  html.dark .keycap-dark { background: #0A1426; border-color: #0A1426; color: #fff; }
  html.dark .keycap-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.5); }
  html.dark .keycap-ghost { background: transparent; }
  html.dark .keycap[aria-pressed="true"], html.dark .tab-key[aria-selected="true"], html.dark .keycap-radio input:checked + .keycap, html.dark .chip.is-on, html.dark .chip[aria-pressed="true"], html.dark .chip-check input:checked + span {
    background: var(--brand); border-color: var(--brand); color: var(--brand-ink);
  }
  html.dark .btn-arrow { background: #0A1426; color: var(--brand); }
  html.dark .icon-key:hover { color: var(--brand-ink); }
  html.dark .icon-key[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
  html.dark .st-ico, html.dark .kt-ico { color: #0A1426; }
  html.dark .kc-mini { color: var(--brand); }
  html.dark .track-key .kc-mini { color: #0A1426; }
  html.dark .cc-level, html.dark .cell-link { color: var(--brand); }

  /* Header + top bar */
  html.dark .top-strip { background: #050C19; border-bottom: 1px solid var(--line); }
  html.dark .site-header { background: color-mix(in srgb, var(--surface) 96%, transparent); }
  html.dark .logo-key-top { background: #0A1426; }
  html.dark .dd-menu, html.dark .mobile-panel, html.dark .filter-panel { background: var(--surface); }
  html.dark .mp-foot { background: var(--surface-2); }

  /* Keyboard: glowing lit keys */
  html.dark .okb { background: #0B1528; }
  html.dark .key { background: var(--surface-3); border-color: #31476F; color: #CBD5E6; box-shadow: 0 2px 0 #050C19; }
  html.dark .key.home { background: #1E3263; }
  html.dark .key.bump::after { background: #CBD5E6; }
  html.dark .key.lit { background: var(--lit); color: var(--lit-ink); box-shadow: 0 0 16px 2px rgba(255, 194, 51, 0.55); border-color: #FFD166; }
  html.dark .key.next { box-shadow: 0 2px 0 #050C19, inset 0 0 0 2px var(--accent), 0 0 10px rgba(143, 176, 255, 0.35); }
  html.dark .okb.show-fingers .key { filter: saturate(0.75) brightness(0.85); color: #111827; }
  html.dark .key[data-heat="1"] { background: #3A2830; } html.dark .key[data-heat="2"] { background: #5A2E36; }
  html.dark .key[data-heat="3"] { background: #8E3540; color: #fff; } html.dark .key[data-heat="4"] { background: #C2414B; color: #fff; box-shadow: 0 0 10px rgba(248, 113, 113, 0.5); }
  html.dark .heat-sw[data-heat="1"] { background: #3A2830; } html.dark .heat-sw[data-heat="2"] { background: #5A2E36; } html.dark .heat-sw[data-heat="3"] { background: #8E3540; } html.dark .heat-sw[data-heat="4"] { background: #C2414B; }

  /* Tables */
  html.dark .sheet-table .col-names th, html.dark .mini-sheet th, html.dark .timetable thead th { background: #06101F; }
  html.dark .formula-bar::before { background: var(--brand); color: #0A1426; }
  html.dark .tt-block { background: color-mix(in srgb, var(--tc) 14%, var(--surface)); }
  html.dark .tt-kc { color: #0A1426; }

  /* Typing box */
  html.dark .tt-text { background: #0B1528; }
  html.dark .ch.bad { background: rgba(248, 113, 113, 0.16); }
  html.dark .tt-badge { color: #0A1426; }

  /* Hero, banners, footer */
  html.dark .ed-hero, html.dark .stats-banner, html.dark .page-hero, html.dark .site-footer { background: #050C19; }
  html.dark .ed-hero-bg::after { background: linear-gradient(100deg, rgba(5, 12, 25, 0.98) 30%, rgba(5, 12, 25, 0.75)); }
  html.dark .ph-bg { background: linear-gradient(110deg, rgba(5, 12, 25, 0.97) 35%, rgba(5, 12, 25, 0.82)), url("../images/lab-1.webp") center / cover no-repeat; }
  html.dark .news-band { color: #0A1426; }
  html.dark .news-band .h3, html.dark .news-band .f-label { color: #0A1426; }
  html.dark .news-band .input { background: #fff; color: #0A1426; }
  html.dark .feature-card, html.dark .ac-counter, html.dark .happy-box { background: var(--surface); }
  html.dark .feature-card:hover .fc-ico, html.dark .mini-card .fc-ico { color: #0A1426; }
  html.dark .logo-tile:hover { background: var(--brand); color: #0A1426; }
  html.dark .path-row.is-lit .path-step .keycap { background: var(--brand); color: #0A1426; border-color: var(--brand); }
  html.dark .path-row.is-lit .path-step .kc-hint { background: #0A1426; color: var(--brand); }
  html.dark .path-row.is-lit .path-step .kc-sub { color: rgba(10, 20, 38, 0.75); }

  /* Popups, toasts, tray */
  html.dark .pop { background: var(--surface); border-color: var(--line-strong); }
  html.dark .pop-head { background: var(--surface-2); }
  html.dark .toast { background: var(--surface-3); border-color: var(--line-strong); }
  html.dark .chart-tip { background: #F3F6FC; color: #0A1426; }
  html.dark .compare-tray { background: var(--surface-2); }
  html.dark .success-key { color: #0A1426; }
  html.dark .avatar { background: var(--brand); color: #0A1426; }
  html.dark .bell-count { border-color: var(--surface); color: #0A1426; }
  html.dark .cert-zoom { color: #0A1426; }

  /* Documents stay "paper" for realism */
  html.dark .cert-doc { box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.9); filter: brightness(0.94); }
  html.dark .receipt-doc { filter: brightness(0.95); }

  /* Forms */
  html.dark .input { background-color: #0B1528; }
  html.dark select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%239FAECA' stroke-width='1.6'/%3E%3C/svg%3E"); }
  html.dark .switch { background: #31476F; }
  html.dark .switch:checked { background: var(--brand); }
  html.dark .demo-note { border-color: rgba(251, 191, 36, 0.5); }

  /* Workbook (Home 2) */
  html.dark .workbook { background: #08111F; }
  html.dark .wb-tabs { background: #08111F; }
  html.dark .wb-tab.is-active { background: var(--surface); }
  html.dark .rank-1 { background: #B88A12; color: #0A1426; } html.dark .rank-2 { background: #9CA3AF; color: #0A1426; } html.dark .rank-3 { background: #B07A57; color: #0A1426; }

  /* Dashboard */
  html.dark .dash-side { background: #050C19; border-color: var(--line); }
  html.dark .dash-top { background: color-mix(in srgb, var(--surface) 94%, transparent); }
  html.dark .dash-tabbar { background: #050C19; }
  html.dark .ds-link.is-active { color: #0A1426; }
  html.dark .ds-link.is-active .ds-key { background: #0A1426; }
  html.dark .countdown-cell { background: #050C19; }
  html.dark .cal-day { background: var(--surface-2); }
  html.dark .cal-day.is-present { background: rgba(74, 222, 128, 0.1); }
  html.dark .cal-day.is-absent { background: rgba(248, 113, 113, 0.12); }
  html.dark .avatar-lg { background: #050C19; }

  /* Misc */
  html.dark .key-missing { background: transparent; border-color: var(--brand); color: var(--brand); }
  html.dark .noscript-note { background: #2B2410; }
  html.dark .map-pin circle { stroke: #0A1426; }
}
