/* Keyflow — dark theme.
 * One surface ramp, one accent, finger colours as the only other hues.
 * Everything else is spacing and weight. */

:root {
  --bg:      #0a0c10;
  --bg-1:    #10141b;
  --bg-2:    #161c26;
  --bg-3:    #1d2431;
  --line:    #232b3a;
  --line-2:  #2e3849;

  --text:    #e7ebf2;
  --text-2:  #a5b0c2;
  --dim:     #99a6bb;

  --accent:  #5eead4;
  --accent-2:#2dd4bf;
  --accent-d:#0f766e;
  --ok:      #4ade80;
  --bad:     #f87171;
  --warn:    #fbbf24;

  --f-lp: #f472b6;  --f-lr: #c084fc;  --f-lm: #60a5fa;  --f-li: #34d399;
  --f-ri: #fbbf24;  --f-rm: #fb923c;  --f-rr: #f87171;  --f-rp: #22d3ee;
  --f-th: #94a3b8;

  --r:    12px;
  --r-sm: 8px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --shadow: 0 10px 30px -12px rgba(0,0,0,.8);
}

* { box-sizing: border-box; }

/* Any `display` rule beats the hidden attribute, and an invisible flex
 * overlay still eats clicks. Make hidden mean hidden, everywhere. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  /* Two soft pools of light so a near-black page doesn't read as flat. */
  background-image:
    radial-gradient(900px 520px at 15% -10%, rgba(94,234,212,.07), transparent 60%),
    radial-gradient(760px 480px at 92% 0%, rgba(129,140,248,.06), transparent 62%);
  background-attachment: fixed;
  min-height: 100vh;
}

h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
small { font-size: .58em; font-weight: 600; opacity: .65; letter-spacing: 0; }

/* ── top bar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 28px;
  padding: 14px 28px;
  background: rgba(10,12,16,.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(140deg, var(--accent), var(--accent-d));
  box-shadow: 0 0 0 1px rgba(94,234,212,.25), 0 6px 18px -8px var(--accent);
  position: relative;
}
.brand-mark::after {
  content: ''; position: absolute; inset: 7px 5px auto 5px; height: 3px;
  border-radius: 2px; background: rgba(3,10,12,.75);
}
.brand-name { font-size: 16px; }

.nav { display: flex; gap: 4px; margin-right: auto; }
.nav a {
  padding: 7px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 550; color: var(--text-2);
  transition: background .15s, color .15s;
}
.nav a:hover { color: var(--text); background: var(--bg-2); }
.nav a.active { color: var(--bg); background: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.streak {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line);
  font-size: 13px; font-weight: 650; color: var(--dim);
}
.streak.on { color: var(--warn); border-color: rgba(251,191,36,.3); background: rgba(251,191,36,.08); }
.streak-flame { font-size: 10px; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--text-2); font-size: 14px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }

/* ── views ───────────────────────────────────────────────── */
#app { max-width: 1080px; margin: 0 auto; padding: 32px 28px 80px; }
.view { display: none; }
.view.on { display: block; animation: fade .25s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-title { font-size: 30px; margin-bottom: 6px; }
.view-sub { color: var(--dim); font-size: 15px; margin-bottom: 28px; }

/* ── hero ────────────────────────────────────────────────── */
.hero {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 36px; align-items: center;
  padding: 34px; margin-bottom: 44px;
  background: linear-gradient(160deg, var(--bg-1), rgba(16,20,27,.4));
  border: 1px solid var(--line); border-radius: 18px;
}
.hero h1 { font-size: 34px; line-height: 1.15; margin-bottom: 12px; }
.hero p { color: var(--text-2); font-size: 15px; line-height: 1.6; max-width: 46ch; }
.hero-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.stat {
  display: flex; flex-direction: column; gap: 3px;
  padding: 14px 16px; border-radius: var(--r);
  background: var(--bg-2); border: 1px solid var(--line);
}
.stat-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-lab { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .07em; }

/* ── buttons ─────────────────────────────────────────────── */
.btn {
  padding: 10px 18px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: var(--bg-3); border-color: #3a465b; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #04140f;
  box-shadow: 0 8px 24px -12px var(--accent);
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-danger { border-color: rgba(248,113,113,.35); color: var(--bad); background: rgba(248,113,113,.07); }
.btn-danger:hover { background: rgba(248,113,113,.14); border-color: rgba(248,113,113,.5); }

/* ── unit + lesson grid ──────────────────────────────────── */
.unit { margin-bottom: 40px; }
.unit-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; margin-bottom: 16px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.unit-head h2 { font-size: 20px; }
.unit-head p { color: var(--dim); font-size: 13.5px; margin-top: 4px; }
.unit-count {
  font-size: 12.5px; font-weight: 650; color: var(--dim);
  padding: 4px 10px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line);
  white-space: nowrap;
}

.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }

.lesson {
  position: relative; display: grid; gap: 6px;
  padding: 16px 16px 14px; border-radius: var(--r);
  background: var(--bg-1); border: 1px solid var(--line);
  transition: border-color .16s, background .16s, transform .12s;
}
.lesson:hover { border-color: var(--line-2); background: var(--bg-2); transform: translateY(-2px); }
.lesson-num {
  font-size: 11px; font-weight: 700; color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.lesson-title { font-size: 15px; font-weight: 650; }
.lesson-keys {
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  letter-spacing: .06em;
}
.lesson-stars { font-size: 13px; letter-spacing: 2px; margin-top: 2px; }
.star { color: var(--line-2); }
.star.on { color: var(--warn); text-shadow: 0 0 12px rgba(251,191,36,.5); }
.lesson-best { font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.lesson.done { border-color: rgba(94,234,212,.22); background: rgba(94,234,212,.04); }
.lesson.next { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(94,234,212,.25), 0 12px 30px -18px var(--accent); }
.lesson.next::after {
  content: 'next'; position: absolute; top: 12px; right: 12px;
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--bg); background: var(--accent); padding: 2px 7px; border-radius: 999px;
}

/* ── typing screen ───────────────────────────────────────── */
.type-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.type-title { flex: 1; text-align: center; }
.type-unit {
  display: block; font-size: 11.5px; font-weight: 650; letter-spacing: .1em;
  text-transform: uppercase; color: var(--dim); margin-bottom: 3px;
}
.type-title h2 { font-size: 19px; }

.metrics {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--r) var(--r) 0 0; overflow: hidden;
}
.metric {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 14px 8px; background: var(--bg-1);
}
.metric-val { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.metric-lab { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }

.progressbar { height: 3px; background: var(--bg-3); border-radius: 0 0 3px 3px; overflow: hidden; }
.progressbar-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent-d), var(--accent));
  transition: width .12s linear;
}

.typearea {
  position: relative; margin: 26px 0 22px; padding: 30px 34px;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 16px;
  outline: none;
}
.typearea:focus-within, .typearea:focus { border-color: rgba(94,234,212,.35); }
.typearea.shake { animation: shake .16s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  30% { transform: translateX(-3px); }
  70% { transform: translateX(3px); }
}

.typeviewport { height: 150px; overflow: hidden; }
.typescroll { transition: transform .18s cubic-bezier(.4,0,.2,1); }

.tline {
  font-family: var(--mono); font-size: 22px; line-height: 50px; height: 50px;
  white-space: pre; letter-spacing: .5px;
  opacity: .8; transition: opacity .2s;
}
.tline.active { opacity: 1; }

.ch { color: var(--dim); border-radius: 3px; }
.ch.ok { color: var(--text); }
.ch.bad { color: #fff; background: rgba(248,113,113,.55); }
.ch.sp.bad { background: rgba(248,113,113,.4); }
.ch.cur {
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
  animation: caret 1s steps(1) infinite;
  background: rgba(94,234,212,.09);
}
@keyframes caret { 50% { box-shadow: inset 2px 0 0 transparent; } }

.type-hint {
  position: absolute; left: 0; right: 0; bottom: -26px; text-align: center;
  font-size: 12.5px; color: var(--dim);
}

/* ── keyboard ────────────────────────────────────────────── */
.board-wrap { margin-top: 34px; }
.board-wrap.hide-keyboard .keyboard { display: none; }

.keyboard {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px; border-radius: 14px;
  background: var(--bg-1); border: 1px solid var(--line);
  user-select: none;
}
.kb-row { display: flex; gap: 6px; }

.key {
  position: relative; min-width: 0; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  background: var(--bg-2); border: 1px solid var(--line);
  border-bottom-width: 2px;
  font-family: var(--mono); font-size: 13px; color: var(--text-2);
  overflow: hidden;   /* long legends like Backspace must never spill */
  transition: background .12s, color .12s, border-color .12s, opacity .2s, transform .06s;
}
.key-label { display: flex; flex-direction: column; align-items: center; line-height: 1.1; pointer-events: none; }
.key-label .up { font-size: 10px; opacity: .55; }
.key-mod { font-size: 10.5px; letter-spacing: .04em; color: var(--dim); }
.key-space { font-size: 0; }

/* the little colour chip that says which finger owns this key */
.key-dot {
  position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  width: 12px; height: 2px; border-radius: 2px; opacity: .5;
}
.f-lp .key-dot { background: var(--f-lp); }
.f-lr .key-dot { background: var(--f-lr); }
.f-lm .key-dot { background: var(--f-lm); }
.f-li .key-dot { background: var(--f-li); }
.f-ri .key-dot { background: var(--f-ri); }
.f-rm .key-dot { background: var(--f-rm); }
.f-rr .key-dot { background: var(--f-rr); }
.f-rp .key-dot { background: var(--f-rp); }
.f-th .key-dot { background: var(--f-th); width: 40px; }

/* the raised nubs on f and j, so the eye finds home position */
.key-anchor::after {
  content: ''; position: absolute; bottom: 9px; left: 50%; transform: translateX(-50%);
  width: 12px; height: 2px; border-radius: 2px; background: var(--dim);
}

.key.out-of-scope { opacity: .28; }

.key.next {
  color: #04140f; background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94,234,212,.18), 0 8px 22px -10px var(--accent);
  transform: translateY(-1px);
  opacity: 1;
}
.key.next .key-dot { opacity: 0; }
.key.next-shift {
  color: var(--accent); border-color: rgba(94,234,212,.55);
  background: rgba(94,234,212,.12); opacity: 1;
}
.key.hit { background: rgba(94,234,212,.3); border-color: var(--accent); }
.key.miss { background: rgba(248,113,113,.4); border-color: var(--bad); color: #fff; }

/* finger guide under the board */
.hands {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 14px; min-height: 26px;
  font-size: 13.5px; color: var(--text-2);
}
.finger-dot { width: 9px; height: 9px; border-radius: 50%; }
.finger-dot.f-lp { background: var(--f-lp); }  .finger-dot.f-lr { background: var(--f-lr); }
.finger-dot.f-lm { background: var(--f-lm); }  .finger-dot.f-li { background: var(--f-li); }
.finger-dot.f-ri { background: var(--f-ri); }  .finger-dot.f-rm { background: var(--f-rm); }
.finger-dot.f-rr { background: var(--f-rr); }  .finger-dot.f-rp { background: var(--f-rp); }
.finger-dot.f-th { background: var(--f-th); }
.finger-text em { color: var(--accent); font-style: normal; font-weight: 650; }
.finger-key {
  font-family: var(--mono); font-size: 12px; padding: 2px 9px; border-radius: 6px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--accent);
}

/* ── result overlay ──────────────────────────────────────── */
.result {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(6,8,11,.78); backdrop-filter: blur(6px);
  animation: fade .2s ease both;
}
.result-card {
  width: min(520px, 100%); padding: 30px; text-align: center;
  background: var(--bg-1); border: 1px solid var(--line-2);
  border-radius: 18px; box-shadow: var(--shadow);
}
.result-stars { font-size: 30px; letter-spacing: 6px; margin-bottom: 10px; }
.result-card h3 { font-size: 24px; margin-bottom: 20px; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.result-grid div { display: flex; flex-direction: column; gap: 2px; padding: 12px 6px; background: var(--bg-2); border-radius: 10px; }
.result-grid span { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-grid em { font-size: 10.5px; font-style: normal; color: var(--dim); text-transform: uppercase; letter-spacing: .07em; }
.result-note { font-size: 14px; line-height: 1.6; color: var(--text-2); margin-bottom: 16px; }
.result-keys {
  display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; align-items: center;
  margin-bottom: 22px; font-size: 12px;
}
.rk-lab { color: var(--dim); }
.rk {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 7px;
  background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.28); color: var(--bad);
  font-family: var(--mono);
}
.rk b { color: var(--text); }
.result-actions { display: flex; gap: 10px; justify-content: center; }

/* ── practice ────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  display: grid; gap: 8px; align-content: start; text-align: left;
  padding: 20px; border-radius: 14px;
  background: var(--bg-1); border: 1px solid var(--line);
  color: inherit; font: inherit; cursor: pointer;
  transition: border-color .16s, background .16s, transform .12s;
}
.card:hover { border-color: var(--accent); background: var(--bg-2); transform: translateY(-2px); }
.card-tag {
  justify-self: start; font-size: 10px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--accent);
  padding: 3px 8px; border-radius: 999px; background: rgba(94,234,212,.1);
}
.card h3 { font-size: 17px; }
.card p { font-size: 13.5px; line-height: 1.55; color: var(--dim); }
.card-keys { display: flex; flex-wrap: wrap; gap: 5px; font-size: 12px; color: var(--dim); }
.wk {
  font-family: var(--mono); padding: 2px 7px; border-radius: 6px;
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--warn);
}

.custom-box { margin-top: 20px; display: grid; gap: 12px; }
.custom-box textarea {
  width: 100%; padding: 16px; border-radius: 12px; resize: vertical;
  background: var(--bg-1); border: 1px solid var(--line); color: var(--text);
  font-family: var(--mono); font-size: 14px; line-height: 1.6;
}
.custom-box textarea:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── progress ────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 28px; }

.panel {
  padding: 22px; margin-bottom: 18px;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 16px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-head h3 { font-size: 16px; }
.panel-note { font-size: 12px; color: var(--dim); }

.chart { position: relative; }
.chart-svg { width: 100%; height: 180px; display: block; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--dim); margin-top: 4px; }
.empty { color: var(--dim); font-size: 13.5px; }

.heatboard { background: transparent; border: none; padding: 0; }
.heatboard .key { color: var(--dim); }
.heatboard .key.has-heat {
  /* hue 0 (red) through 145 (green), driven by the accuracy ratio */
  background: hsl(calc(var(--heat) * 145) 62% 42% / .55);
  border-color: hsl(calc(var(--heat) * 145) 62% 52% / .7);
  color: var(--text);
}
.heatboard .key.has-heat::before {
  content: attr(data-acc);
  position: absolute; top: 3px; right: 4px;
  font-size: 8px; opacity: .8;
}
.heatboard .key-dot { opacity: .3; }

.weaklist { display: grid; gap: 8px; margin-bottom: 18px; }
.weakrow { display: grid; grid-template-columns: 34px 1fr 48px 68px; align-items: center; gap: 12px; }
.weakkey {
  display: flex; align-items: center; justify-content: center; height: 28px;
  font-family: var(--mono); font-size: 13px;
  background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 7px;
}
.weakbar { height: 7px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.weakbar i {
  display: block; height: 100%; border-radius: 4px;
  /* Colour tracks the score itself, so a short bar is never a green one. */
  background: hsl(calc(var(--heat) * 145) 68% 52%);
}
.weakpct { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.weakn { font-size: 11.5px; color: var(--dim); }

/* ── settings drawer ─────────────────────────────────────── */
.drawer {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(6,8,11,.7); backdrop-filter: blur(4px);
  display: flex; justify-content: flex-end;
  animation: fade .18s ease both;
}
.drawer-panel {
  width: min(400px, 100%); height: 100%; overflow-y: auto;
  padding: 24px; background: var(--bg-1); border-left: 1px solid var(--line);
  display: grid; gap: 8px; align-content: start;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.toggle {
  display: grid; grid-template-columns: 40px 1fr; gap: 14px; align-items: start;
  padding: 14px; border-radius: 12px; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line);
}
.toggle:hover { border-color: var(--line-2); }
.toggle { position: relative; }
.toggle input {
  position: absolute; width: 1px; height: 1px; margin: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.toggle:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.toggle span {
  grid-column: 1; width: 38px; height: 22px; border-radius: 999px;
  background: var(--bg-3); border: 1px solid var(--line-2); position: relative;
  transition: background .16s, border-color .16s;
}
.toggle span::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--dim);
  transition: transform .16s, background .16s;
}
.toggle input:checked + span { background: rgba(94,234,212,.2); border-color: var(--accent); }
.toggle input:checked + span::after { transform: translateX(16px); background: var(--accent); }
.toggle strong { display: block; font-size: 14px; font-weight: 650; }
.toggle em { display: block; font-style: normal; font-size: 12.5px; color: var(--dim); margin-top: 3px; line-height: 1.45; }

/* ── responsive ──────────────────────────────────────────── */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero h1 { font-size: 27px; }
  .tline { font-size: 19px; }
}

@media (max-width: 620px) {
  #app { padding: 22px 16px 60px; }
  .topbar { padding: 12px 16px; gap: 14px; }
  .brand-name { display: none; }
  .nav a { padding: 6px 11px; font-size: 13px; }
  .metric-val { font-size: 20px; }
  .typearea { padding: 20px 16px; }
  .tline { font-size: 16px; line-height: 42px; height: 42px; }
  .typeviewport { height: 126px; }
  .key { height: 30px; font-size: 10px; }
  .key-mod { font-size: 7.5px; letter-spacing: 0; }
  .keyboard { padding: 7px; gap: 4px; }
  .kb-row { gap: 4px; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .weakrow { grid-template-columns: 30px 1fr 42px; }
  .weakn { display: none; }
}

/* Respect a reduced-motion preference: keep the caret, drop the rest. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .ch.cur { animation: none; }
}

/* Career tracks and the daily mission keep the original Keyflow palette. */
.eyebrow {
  display: block; margin-bottom: 10px; color: var(--accent);
  font-size: 10px; font-weight: 750; line-height: 1.5;
  text-transform: uppercase; letter-spacing: .14em;
}
.hero { margin-bottom: 20px; }
.hero h1 { font-size: clamp(30px, 4vw, 42px); max-width: 11ch; }
.hero p { max-width: 48ch; }
.section-intro { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin: 42px 0 20px; }
.section-intro h2 { font-size: 24px; }
.section-intro p { max-width: 30ch; color: var(--text-2); font-size: 13px; line-height: 1.6; }
.track-picker { display: flex; flex-wrap: wrap; gap: 9px; }
.track-option {
  --track-color: var(--accent); display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-2); background: var(--bg-1); color: var(--text-2);
  border-radius: 10px; padding: 12px 16px; font: inherit; font-size: 13px; font-weight: 650;
  cursor: pointer; transition: border-color .16s, background .16s;
}
.track-legal { --track-color: #c4b5fd; }
.track-admin { --track-color: #93c5fd; }
.track-commercial { --track-color: #fbbf24; }
.track-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--track-color); }
.track-option:hover { background: var(--bg-2); border-color: var(--track-color); }
.track-option[aria-pressed="true"] { color: var(--text); border-color: var(--track-color); background: var(--bg-3); }
.track-note { margin: 13px 0 28px; color: var(--text-2); font-size: 13px; line-height: 1.6; min-height: 21px; }
.unit-legal .unit-head h2 { color: #c4b5fd; }
.unit-admin .unit-head h2 { color: #93c5fd; }
.unit-commercial .unit-head h2 { color: #fbbf24; }
.mission-banner {
  display: flex; align-items: center; gap: 22px; padding: 25px 28px; margin-bottom: 28px;
  border: 1px solid rgba(196,181,253,.3); border-radius: 16px;
  background: radial-gradient(ellipse at top left, rgba(129,140,248,.12), transparent 75%), var(--bg-1);
}
.mission-symbol {
  display: grid; place-items: center; flex-shrink: 0; width: 58px; height: 66px;
  border: 1px solid rgba(196,181,253,.3); border-radius: 12px 12px 24px 24px;
  color: #c4b5fd; background: rgba(129,140,248,.1); font-size: 30px;
}
.mission-copy { flex: 1; }
.mission-copy .eyebrow { color: #c4b5fd; margin-bottom: 5px; }
.mission-copy h3 { font-size: 20px; margin-bottom: 6px; }
.mission-copy p { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.mission-status { display: block; font-size: 11px; color: #c4b5fd; margin-top: 8px; }
.mission-banner .btn { flex-shrink: 0; }
.card-link { color: var(--accent); font-size: 12px; margin-top: 10px; font-weight: 600; }
.run-feedback { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin: 14px 0 -10px; font-size: 12px; color: var(--text-2); }
#runCombo { color: var(--dim); }
#runCombo.flowing { color: var(--accent); }
:where(button, a, textarea):focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

@media (max-width: 620px) {
  .hero { padding: 24px; gap: 24px; }
  .hero h1 { max-width: 14ch; }
  .section-intro { display: block; }
  .section-intro p { margin-top: 10px; max-width: none; }
  .track-picker { display: grid; grid-template-columns: 1fr 1fr; }
  .track-option { justify-content: center; padding: 12px 8px; font-size: 12px; }
  .mission-banner { padding: 20px; gap: 15px; flex-wrap: wrap; }
  .mission-symbol { width: 42px; height: 52px; font-size: 24px; }
  .mission-copy { min-width: 170px; }
  .mission-copy h3 { font-size: 18px; }
  .mission-banner .btn { width: 100%; }
}


/* Readable guidance, keyboard access and layouts down to 320 CSS pixels. */
html { color-scheme: dark; scroll-padding-top: 130px; }
body { line-height: 1.5; }
.skip-link {
  position: fixed; top: 8px; left: 12px; z-index: 100;
  padding: 10px 16px; background: var(--accent); color: #04140f;
  border-radius: 8px; font-weight: 650; transform: translateY(-150%);
}
.skip-link:focus { transform: none; }
#app:focus { outline: none; }
.icon-btn { width: 40px; height: 40px; flex-shrink: 0; }
.nav a { display: inline-flex; align-items: center; min-height: 44px; }
.btn, .track-option { min-height: 44px; }
.type-title { min-width: 0; }
.type-title h2, .mission-copy h3 { overflow-wrap: anywhere; }
.typing-input {
  position: absolute; left: 10px; top: 10px; width: 1px; height: 1px;
  opacity: .01; padding: 0; border: 0; resize: none; font-size: 16px;
}
.typearea:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.type-hint { line-height: 1.5; }
.custom-box label { font-size: 14px; font-weight: 650; }
.form-help { color: var(--text-2); font-size: 13px; }
.custom-box textarea { font-size: 16px; }
.result { overflow-y: auto; }
.result-card { max-height: calc(100dvh - 48px); overflow-y: auto; }
.panel-head { flex-wrap: wrap; row-gap: 6px; }
.hands { flex-wrap: wrap; }
.noscript-note { padding: 24px; max-width: 50ch; margin: 24px auto; }
@media (max-width: 480px) {
  .topbar { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; padding: 10px 16px; }
  .brand-name { display: inline; }
  .topbar-right { justify-self: end; }
  .nav { grid-row: 2; grid-column: 1 / -1; margin: 0; width: 100%; }
  .nav a { flex: 1; justify-content: center; }
  .type-head { gap: 8px; flex-wrap: wrap; }
  .type-title { order: -1; flex-basis: 100%; margin-bottom: 4px; }
  #restartBtn { margin-left: auto; }
  .lesson-grid, .cards { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: 20px; }
  .hero-stats { gap: 8px; }
  .stat { padding: 12px; }
  .mission-copy { min-width: 0; flex-basis: calc(100% - 60px); }
  .type-hint { position: static; margin: 10px 0 -4px; }
  .board-wrap { margin-top: 18px; }
  .result { padding: 16px; }
  .result-card { padding: 22px; max-height: calc(100dvh - 32px); }
}
