:root {
  --bg: #f4f8fc; --surface: #ffffff; --surface-2: #eef4fa; --ink: #11263c; --muted: #5b6f84;
  --line: #d9e3ee; --brand: #0b5394; --brand-2: #1a7fd6; --accent: #00a7a0;
  --good: #1f9d55; --warn: #d98a00; --bad: #d64545; --chart-1: #1a7fd6; --chart-2: #00a7a0;
  --chart-3: #e07b39; --chart-4: #8a5cd6; --chart-5: #d64592; --radius: 12px;
  --shadow: 0 1px 2px rgba(17,38,60,.06), 0 4px 16px rgba(17,38,60,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1622; --surface: #132233; --surface-2: #1a2d42; --ink: #e5eef7; --muted: #93a7bb;
    --line: #253b52; --brand: #5aa9ff; --brand-2: #79bbff; --accent: #2fd1c8; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1622; --surface: #132233; --surface-2: #1a2d42; --ink: #e5eef7; --muted: #93a7bb;
  --line: #253b52; --brand: #5aa9ff; --brand-2: #79bbff; --accent: #2fd1c8; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
h3 { font-size: 15px; } h4 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--brand-2); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .err { color: var(--bad); }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.mono { font-variant-numeric: tabular-nums; }

.shell { display: flex; min-height: calc(100vh / var(--z, 1)); }
.sidebar { width: 240px; flex: 0 0 240px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: calc(100vh / var(--z, 1)); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px; font-weight: 700; font-size: 18px; color: var(--brand); }
#nav { padding: 0 8px 16px; flex: 1; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 13.5px; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item .ic { width: 18px; text-align: center; }
.sidebar-foot { padding: 12px 16px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h2 { margin: 0; font-size: 18px; flex: 1; }
.topbar-right { display: flex; gap: 10px; flex-wrap: wrap; }
.sel { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
#menu-btn { display: none; }
.view { padding: 20px; max-width: 1400px; width: 100%; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .spanall { grid-column: 1 / -1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card > h3:first-child { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.good { background: rgba(31,157,85,.14); color: var(--good); }
.pill.warn { background: rgba(217,138,0,.16); color: var(--warn); }
.pill.bad { background: rgba(214,69,69,.14); color: var(--bad); }
.pill.brand { background: rgba(26,127,214,.14); color: var(--brand-2); }
.banner { padding: 10px 14px; border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--brand-2); font-size: 13px; }
.banner.warn { border-color: var(--warn); } .banner.bad { border-color: var(--bad); } .banner.good { border-color: var(--good); }

.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 7px 14px; border-radius: 8px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.icon-btn { border: 0; background: transparent; color: var(--ink); font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; max-width: 100%; }
textarea { width: 100%; min-height: 70px; resize: vertical; }
input[type=range] { padding: 0; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-items: end; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 8px 14px; border: 0; background: none; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; font: inherit; white-space: nowrap; }
.tab.active { color: var(--brand); border-color: var(--brand); font-weight: 600; }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.hl td { background: rgba(26,127,214,.08); }

.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand-2); border-radius: 99px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .grid-l { stroke: var(--line); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.gauge { display: flex; flex-direction: column; align-items: center; }
.gauge .big { font-size: 34px; font-weight: 800; }
.set-block { border: 1px solid var(--line); border-left: 4px solid var(--brand-2); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.set-block.warmup { border-left-color: var(--chart-2); } .set-block.drill { border-left-color: var(--chart-4); }
.set-block.kick { border-left-color: var(--chart-5); } .set-block.main { border-left-color: var(--chart-3); }
.set-block.recovery, .set-block.cooldown { border-left-color: var(--good); } .set-block.preset { border-left-color: var(--brand-2); }
.set-block .hd { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.feed-item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px; border-radius: 10px; background: var(--surface-2); text-align: center; font-size: 12px; }
.badge .em { font-size: 26px; } .badge.locked { opacity: .4; filter: grayscale(1); }

.video-stage { position: relative; background: #000; border-radius: 10px; overflow: hidden; }
.video-stage video { width: 100%; display: block; max-height: calc(60vh / var(--z, 1)); }
.video-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 24px; text-align: center; color: var(--muted); }
.route svg { width: 100%; height: 320px; background: var(--surface-2); border-radius: 10px; }

.lock { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 50; }
.lock-card { background: var(--surface); padding: 28px; border-radius: 16px; border: 1px solid var(--line); width: min(360px, calc(92vw / var(--z, 1))); display: flex; flex-direction: column; gap: 12px; text-align: center; align-items: center; }
.lock-card input { width: 100%; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; transition: transform .25s; z-index: 60; max-width: calc(90vw / var(--z, 1)); }
.toast.show { transform: translateX(-50%) translateY(0); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 40; padding: 16px; }
/* Popups (Memory master, standard 1): drag the top bar to move, drag the bottom-right corner to resize, the arrows button fills the screen. */
.modal-card { background: var(--surface); border-radius: 14px; width: min(760px, 100%); max-height: calc(88vh / var(--z, 1)); overflow: hidden; position: relative; display: flex; flex-direction: column; }
.modal-card.max { width: calc(calc(100vw / var(--z, 1)) - 32px); height: calc(calc(100vh / var(--z, 1)) - 32px); max-height: none; }
.modal-bar { flex: none; display: flex; justify-content: flex-end; align-items: center; gap: 2px; padding: 6px 8px 0; cursor: move; touch-action: none; user-select: none; -webkit-user-select: none; }
.modal-card.max .modal-bar { cursor: default; }
.modal-max { font-size: 16px; }
#modal-body { flex: 1; min-height: 0; overflow: auto; padding: 0 20px 20px; }
.modal-grip { position: absolute; right: 3px; bottom: 3px; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none; opacity: .5; border-radius: 0 0 10px 0;
  background: linear-gradient(135deg, transparent 0 46%, var(--ink) 46% 54%, transparent 54% 68%, var(--ink) 68% 76%, transparent 76%); }
.modal-grip:hover { opacity: 1; }
.modal-card.max .modal-grip { display: none; }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .view { padding: 0; } .card { box-shadow: none; break-inside: avoid; }
}
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .sidebar { position: fixed; left: -260px; z-index: 30; transition: left .2s; box-shadow: var(--shadow); }
  .sidebar.open { left: 0; }
  #menu-btn { display: inline-block; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .span2, .span3 { grid-column: auto; }
  .view { padding: 16px; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .topbar-right { width: 100%; }
}

/* Memory master Standard 13 (2026-12-04): Classic mode. The app opens in Classic: black on white, plain tables with a
   dark line under the headings, grey buttons, one bright highlight for the page you are on. The switch in the top bar
   and on the lock screen changes to the Current look above (which still follows the Theme setting) and back. Classic is
   this one block: every rule starts with html[data-mode="classic"], and it mostly re-points the colour tokens. */
.modesw{display:inline-flex;align-items:center;gap:2px;padding:2px;border:1px solid var(--line);border-radius:9px;background:var(--surface-2);flex:none;align-self:center}
.modesw button{all:unset;cursor:pointer;font-size:12px;font-weight:600;line-height:1.5;padding:3px 10px;border-radius:7px;color:var(--muted)}
.modesw button:hover{color:var(--ink)} .modesw button:focus-visible{outline:2px solid var(--brand-2);outline-offset:1px}
.modesw button.on{background:var(--brand);color:#fff}
html[data-mode="classic"]:root:root{ --bg:#ffffff; --surface:#ffffff; --surface-2:#f4f4f0; --ink:#111111; --muted:#70706a; --line:#e6e6e0;
  --brand:#111111; --brand-2:#111111; --accent:#00a7a0; --good:#1a7f55; --warn:#a86400; --bad:#c62f3f; --radius:10px;
  --shadow:none; color-scheme:light; }
html[data-mode="classic"] body{background:#fff}
html[data-mode="classic"] ::selection{background:#dcf85a;color:#111}
html[data-mode="classic"] a{color:#111}
html[data-mode="classic"] .brand{color:#111}
html[data-mode="classic"] .nav-item{border-radius:4px;color:#2b2b28}
html[data-mode="classic"] .nav-item:hover{background:#f4f4f0;color:#111}
html[data-mode="classic"] .nav-item.active{background:#dcf85a;color:#111;font-weight:600}
html[data-mode="classic"] .topbar h2{font-weight:500;font-size:24px;letter-spacing:-.03em}
html[data-mode="classic"] .card{box-shadow:none}
html[data-mode="classic"] .stat .v,html[data-mode="classic"] .gauge .big,html[data-mode="classic"] .score-big{font-weight:500;letter-spacing:-.02em}
html[data-mode="classic"] .pill{display:inline-flex;align-items:center;gap:5px;padding:3px 10px;background:#f1f1ec;color:#2b2b28}
html[data-mode="classic"] .pill.good,html[data-mode="classic"] .pill.warn,html[data-mode="classic"] .pill.bad,html[data-mode="classic"] .pill.brand{background:#f1f1ec;color:#2b2b28}
html[data-mode="classic"] .pill.good::before,html[data-mode="classic"] .pill.warn::before,html[data-mode="classic"] .pill.bad::before{content:"";width:7px;height:7px;border-radius:50%;flex:none;background:#1a9a6c}
html[data-mode="classic"] .pill.warn::before{background:#f08c1a}
html[data-mode="classic"] .pill.bad::before{background:#e5484d}
html[data-mode="classic"] .banner{background:#f8f8f5;border-left-color:#111;border-radius:8px}
html[data-mode="classic"] .banner.warn{border-left-color:#f08c1a} html[data-mode="classic"] .banner.bad{border-left-color:#e5484d} html[data-mode="classic"] .banner.good{border-left-color:#1a9a6c}
html[data-mode="classic"] .btn{border-color:transparent;background:#ecece6;color:#111;border-radius:6px}
html[data-mode="classic"] .btn:hover{background:#e0e0d8;border-color:transparent}
html[data-mode="classic"] .btn.primary,html[data-mode="classic"] .btn.on{background:#111;border-color:#111;color:#fff}
html[data-mode="classic"] .btn.primary:hover,html[data-mode="classic"] .btn.on:hover{background:#2b2b2b}
html[data-mode="classic"] .btn.danger{color:#c62f3f}
html[data-mode="classic"] .pad .btn.four{border-color:var(--chart-2);color:var(--chart-2);background:#fff} html[data-mode="classic"] .pad .btn.six{border-color:var(--chart-4);color:var(--chart-4);background:#fff}
html[data-mode="classic"] .pad .btn.wkt{background:var(--bad);border-color:var(--bad);color:#fff}
html[data-mode="classic"] input,html[data-mode="classic"] select,html[data-mode="classic"] textarea{border-color:#dcdcd5;border-radius:6px}
html[data-mode="classic"] input:focus,html[data-mode="classic"] select:focus,html[data-mode="classic"] textarea:focus{outline:none;border-color:#111;box-shadow:0 0 0 3px rgba(17,17,17,.08)}
html[data-mode="classic"] input[type=checkbox],html[data-mode="classic"] input[type=radio],html[data-mode="classic"] input[type=range]{accent-color:#111;box-shadow:none}
html[data-mode="classic"] .tab.active{color:#111;border-color:#111}
html[data-mode="classic"] th{font-weight:500;color:#8a8a83;border-bottom:1.5px solid #cfcfc7;padding:10px 8px}
html[data-mode="classic"] td{padding:11px 8px;border-bottom-color:#ecece6}
html[data-mode="classic"] tr.hl td{background:#f6fbd9}
html[data-mode="classic"] .bar{background:#ecece6}
html[data-mode="classic"] .bar > span{background:#111}
html[data-mode="classic"] .badge{background:#f4f4f0}
html[data-mode="classic"] .choice:hover{border-color:#111}
html[data-mode="classic"] .choice.on{border-color:#111;background:#f6fbd9}
html[data-mode="classic"] .steps span.now{border-color:#111}
html[data-mode="classic"] label.consent{border-color:#111;background:#f8f8f5}
html[data-mode="classic"] label.consent .tag{background:#ecece6;color:#111}
html[data-mode="classic"] label.consent.optional{border-color:#c79a1e;background:rgba(199,154,30,.09)} html[data-mode="classic"] label.consent.optional .tag{background:rgba(199,154,30,.2);color:#9a7410}
html[data-mode="classic"] label.consent.ticked{border-color:var(--good);background:#ecf7f1}
html[data-mode="classic"] .lock-card{border-radius:14px}
html[data-mode="classic"] .toast{background:#111;color:#fff;border-radius:8px}
html[data-mode="classic"] .modal{background:rgba(17,17,17,.42)}
html[data-mode="classic"] .modal-card{border-radius:14px;box-shadow:0 24px 64px rgba(17,17,17,.28)}
html[data-mode="classic"] .modesw{border-color:#dcdcd5;background:#f4f4f0;border-radius:6px}
html[data-mode="classic"] .modesw button{border-radius:4px;color:#70706a}
html[data-mode="classic"] .modesw button.on{background:#111;color:#fff}

/* Memory master Standard 12 (2026-11-23): on large monitors the whole page scales up to fill the screen.
   Laptops and phones are unchanged. Zoom also scales vh/vw, so those divide by --z. */
html { zoom: var(--z, 1); }
@media (min-width: 1900px) { :root { --z: 1.1; } }
@media (min-width: 2150px) { :root { --z: 1.25; } }
@media (min-width: 2450px) { :root { --z: 1.4; } }
@media (min-width: 2800px) { :root { --z: 1.6; } }
@media (min-width: 3300px) { :root { --z: 1.85; } }
@media (min-width: 3900px) { :root { --z: 2.2; } }
