:root {
  /* Brand fonts from the live site (Plus Jakarta Sans + Noto Sans Myanmar),
     with the already-bundled OFL TTF files as an offline fallback. */
  --font-ui: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --font-my: "Noto Sans Myanmar", "Pyidaungsu", "Myanmar Text", "Padauk", "Myanmar Sangam MN", "Plus Jakarta Sans", sans-serif;
  --radius-card: 12px; /* Tailwind rounded-xl */
  --radius-btn: 12px;
  --radius-pill: 999px;
  --side-w: 232px;
  --side-rail: 72px;
  --space: 16px;
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  /* Pedagogical finger hues (not marketing-site tokens). Kept distinct for teaching. */
  --finger-lp: #C77D9E; --finger-lr: #CF8F61; --finger-lm: #C4A646;
  --finger-li: #6FA97A; --finger-ri: #4E9E96; --finger-rm: #6787B8;
  --finger-rr: #8C7DB8; --finger-rp: #C47076; --finger-th: #7F8E98;
}

/* Light is the live site default (bg-gray-50, white header, blue-600 primary). */
[data-theme="light"] {
  --bg: #f9fafb;              /* gray-50 page */
  --card: #ffffff;
  --card-border: #e5e7eb;     /* gray-200 */
  --text: #111827;            /* gray-900 */
  --muted: #4b5563;           /* gray-600 */
  --side: #ffffff;
  --side-hover: #f3f4f6;      /* gray-100 */
  --side-on: #2563eb;         /* blue-600 */
  --side-text: #374151;       /* gray-700 */
  --side-muted: #6b7280;      /* gray-500 */
  --side-on-text: #ffffff;
  --side-border: #e5e7eb;
  --hero: #0f172a;            /* slate-900, site hero / camp / footer */
  --hero-text: #ffffff;
  --hero-muted: #d1d5db;      /* gray-300 */
  --primary: #2563eb;         /* blue-600 */
  --primary-hover: #1d4ed8;   /* blue-700 */
  --on-primary: #ffffff;
  --accent: #0284c7;          /* sky-600, "Online courses" CTA tone */
  --accent-hover: #0369a1;    /* sky-700 */
  --on-accent: #ffffff;
  --good: #059669;            /* emerald-600 */
  --bad: #dc2626;             /* red-600 */
  --error-bg: #dc2626;
  --error-fg: #ffffff;
  --current: #f59e0b;         /* amber-500, high-contrast caret chip */
  --current-ink: #0f172a;
  --caret: #2563eb;
  --gold: #facc15;            /* yellow-400, site badge / camp CTA */
  --warn: #b45309;            /* amber-700, readable on amber-50 */
  --warn-soft: #fffbeb;       /* amber-50 */
  --nav-on: #2563eb;
  --nav-hover: #f3f4f6;
  --secondary: #f3f4f6;       /* gray-100 */
  --secondary-hover: #e5e7eb;
  --blue-soft: #dbeafe;       /* blue-100 */
  --ghost: #d1d5db;
  --seg-on: #2563eb;
  --focus: #2563eb;
  --wordmark-from: #2563eb;   /* from-blue-600 */
  --wordmark-to: #06b6d4;     /* to-cyan-500 */
  --logo-glow-from: #2563eb;
  --logo-glow-to: #0891b2;    /* to-cyan-600 */
  --finger-bg-lp: #F3E4EB; --finger-bg-lr: #F5E8DC; --finger-bg-lm: #F3EED6;
  --finger-bg-li: #DEEDDF; --finger-bg-ri: #D5EBE8; --finger-bg-rm: #DCE4F0;
  --finger-bg-rr: #E6E3F0; --finger-bg-rp: #F2E0E2; --finger-bg-th: #E3E6E8;
  --hand-fill: #e5e7eb; --hand-edge: #4b5563; --hand-nail: #f9fafb;
}

/* Dark follows the live site `dark:` tokens (prefers-color-scheme). */
[data-theme="dark"] {
  --bg: #111827;              /* gray-900 */
  --card: #1f2937;            /* gray-800 */
  --card-border: #374151;     /* gray-700 */
  --text: #f9fafb;            /* gray-50 */
  --muted: #9ca3af;           /* gray-400 */
  --side: #111827;
  --side-hover: #1f2937;
  --side-on: #2563eb;
  --side-text: #d1d5db;       /* gray-300 */
  --side-muted: #9ca3af;
  --side-on-text: #ffffff;
  --side-border: #1f2937;     /* gray-800, site header dark border */
  --hero: #0f172a;
  --hero-text: #ffffff;
  --hero-muted: #9ca3af;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --on-primary: #ffffff;
  --accent: #38bdf8;          /* sky-400, readable on dark keys / next-glyph */
  --accent-hover: #0ea5e9;
  --on-accent: #0f172a;
  --good: #34d399;            /* emerald-400 */
  --bad: #f87171;             /* red-400 */
  --error-bg: #dc2626;
  --error-fg: #ffffff;
  --current: #fbbf24;         /* amber-400 */
  --current-ink: #0f172a;
  --caret: #67e8f9;           /* cyan-300 */
  --gold: #facc15;
  --warn: #fcd34d;            /* amber-300 */
  --warn-soft: #422006;       /* dark amber wash */
  --nav-on: #2563eb;
  --nav-hover: #1f2937;
  --secondary: #1f2937;
  --secondary-hover: #374151;
  --blue-soft: #1e3a8a;       /* blue-900-ish soft chip */
  --ghost: #4b5563;
  --seg-on: #2563eb;
  --focus: #60a5fa;           /* blue-400 */
  --wordmark-from: #60a5fa;   /* dark:from-blue-400 */
  --wordmark-to: #67e8f9;     /* dark:to-cyan-300 */
  --logo-glow-from: #2563eb;
  --logo-glow-to: #0891b2;
  --finger-bg-lp: #2A2230; --finger-bg-lr: #2C2620; --finger-bg-lm: #2B291E;
  --finger-bg-li: #1F2A24; --finger-bg-ri: #1C292A; --finger-bg-rm: #1E2430;
  --finger-bg-rr: #242230; --finger-bg-rp: #2A2124; --finger-bg-th: #22262A;
  --hand-fill: #1f2937; --hand-edge: #9ca3af; --hand-nail: #374151;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { overflow-x: hidden; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: calc(15px * var(--font-scale, 1));
  font-weight: 500;
  line-height: 1.45;
  overflow-x: hidden;
}
body.lang-my, body.lang-my button, body.lang-my input, .my,
body.lang-my .lesson-num, body.lang-my .stage-tile, body.lang-my .val,
body.lang-my .hero, body.lang-my .facts, body.lang-my .main {
  font-family: var(--font-my);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.app {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: 100%;
  min-width: 0;
  max-width: 100%;
}
.app.rail { grid-template-columns: var(--side-rail) 1fr; }
.app.onboard-mode { grid-template-columns: 1fr; }
.app.onboard-mode .sidebar { display: none; }
.app.rail .side-foot, .app.rail .full-label { display: none; }
.app.rail .rail-label { display: inline; font-size: 10px; font-weight: 700; }
.rail-label { display: none; }

.sidebar {
  background: var(--side);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 12px;
  min-height: 100vh;
  min-width: 0;
  position: sticky;
  top: 0;
  border-right: 1px solid var(--side-border);
  box-shadow: var(--shadow-lg);
  z-index: 20;
}
@media (min-width: 901px) {
  .sidebar {
    height: 100vh;
    max-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .side-spacer { min-height: 0; }
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; min-width: 0; }
.brand-logo {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}
.brand-glow {
  position: absolute;
  inset: -4px;
  border-radius: var(--radius-pill);
  background: linear-gradient(to right, var(--logo-glow-from), var(--logo-glow-to));
  filter: blur(8px);
  opacity: 0.25;
  pointer-events: none;
}
.brand-mark-img {
  position: relative;
  z-index: 1;
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: #ffffff;
  border-radius: var(--radius-pill);
  padding: 4px;
  display: block;
}
.brand-text { min-width: 0; }
.brand-name {
  font-weight: 800;
  font-size: 16px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  background-image: linear-gradient(to right, var(--wordmark-from), var(--wordmark-to));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-center {
  font-size: 10px;
  font-weight: 700;
  color: var(--side-muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  line-height: 1.2;
}
.brand-product { font-size: 12px; font-weight: 700; color: var(--side-text); margin-top: 2px; }
.brand-free { font-size: 11px; color: var(--primary); font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0; color: var(--side-text);
  text-align: left; padding: 8px 10px; border-radius: 10px; width: 100%;
  font-weight: 700;
}
.nav-btn:hover { background: var(--side-hover); color: var(--primary); }
.nav-btn.is-on { background: var(--side-on); color: var(--side-on-text); font-weight: 800; }
.nav-btn.is-on:hover { background: var(--primary-hover); color: #fff; }
.nav-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.app.rail .brand-text, .app.rail .nav-label, .app.rail .side-foot-text, .app.rail .toggles span { display: none; }
.app.rail .brand, .app.rail .toggles { justify-content: center; padding-left: 0; padding-right: 0; }
.app.rail .nav-btn { justify-content: center; padding: 10px 0; }
.app.rail .brand-logo, .app.rail .brand-mark-img { width: 40px; height: 40px; }
.app.rail .brand { padding-bottom: 12px; }
.side-spacer { flex: 1; }
.side-foot { padding: 8px; border-radius: 12px; background: var(--secondary); margin-bottom: 8px; }
.side-foot .who { font-weight: 700; font-size: 13px; }
.side-foot .role { font-size: 11px; color: var(--side-muted); }
.toggles { display: flex; gap: 6px; align-items: center; padding: 4px 4px 0; flex-wrap: wrap; }
.icon-btn {
  background: var(--secondary); color: var(--side-text); border: 0; border-radius: 8px;
  padding: 6px 8px; font-size: 12px; font-weight: 700;
}
.icon-btn.is-on { background: var(--primary); color: var(--on-primary); }
.ver { font-size: 11px; color: var(--side-muted); padding: 6px 8px 0; }
.app.rail .ver { display: none; }

.main { padding: 20px 28px 32px; min-width: 0; }
h1 { font-size: 1.7rem; margin: 0 0 4px; font-weight: 800; letter-spacing: -0.02em; }
.sub { color: var(--muted); margin: 0 0 16px; }

.btn {
  border: 0; border-radius: var(--radius-btn); padding: 8px 16px;
  background: var(--primary); color: var(--on-primary); font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--primary-hover); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-ghost {
  background: var(--secondary); color: var(--text); box-shadow: none;
}
.btn-ghost:hover { background: var(--secondary-hover); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-lg {
  font-size: 1.25rem; padding: 14px 36px; border-radius: 12px;
  min-width: 280px; min-height: 3.25rem;
}

.card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-card); padding: 16px;
  box-shadow: var(--shadow-lg);
}
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.seg { display: inline-flex; background: var(--secondary); border-radius: 10px; overflow: hidden; border: 1px solid var(--card-border); }
.seg button {
  background: transparent; border: 0; color: var(--text); padding: 6px 16px; font-weight: 700;
}
.seg button.is-on { background: var(--seg-on); color: var(--on-primary); }

/* Home */
.home { display: flex; flex-direction: column; min-height: calc(100vh - 40px); }
.home-head h1 { margin-bottom: 8px; }
.hero {
  flex: 1; background: var(--hero); border-radius: 18px;
  display: grid; place-items: center; text-align: center; padding: 28px 24px; min-height: 420px;
  box-shadow: var(--shadow-lg);
}
.hero .kicker { color: var(--hero-muted); margin: 16px 0 4px; }
.hero h2 { color: var(--hero-text); font-size: 1.45rem; margin: 0 0 20px; font-weight: 700; }
.hero .hint { color: var(--hero-muted); margin-top: 16px; max-width: 36rem; }
.facts { color: var(--muted); margin: 14px 0 0; }
.footer-free { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* Lessons */
.lesson-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px 16px;
  align-items: center; margin-bottom: 10px;
  min-width: 0;
}
.lesson-num {
  min-width: 2.6em; min-height: 2.6em; width: max-content;
  box-sizing: border-box;
  padding: 0.2em 0.5em;
  border-radius: 999px;
  display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center;
  align-self: start;
  font-weight: 700; font-size: 1.05rem; line-height: 1;
  overflow: visible;
  background: var(--blue-soft); color: var(--text);
  flex-shrink: 0;
}
body.lang-my .lesson-num {
  font-family: "Pyidaungsu", "Padauk", "Noto Sans Myanmar", var(--font-my);
  min-height: 3.15em;
  padding: 0.25em 0.55em 0.2em;
}
body.lang-my .lesson-num .mn-digit {
  font-family: "Pyidaungsu", "Padauk", "Noto Sans Myanmar", var(--font-my);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.15;
}
body.lang-my .lesson-num .ar-digit {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1;
  opacity: 0.72;
}
.lesson-title { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.lesson-keys { color: var(--muted); font-size: 0.95rem; overflow-wrap: anywhere; }
.stages { display: flex; gap: 8px; }
.stage-tile {
  min-width: 88px; text-align: center; border: 1px solid var(--card-border);
  background: var(--card); border-radius: 12px; padding: 10px 12px;
  color: var(--text);
}
.stage-tile.is-next { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.stage-tile.is-locked { opacity: 0.55; cursor: not-allowed; }
.stars { letter-spacing: 1px; color: #ca8a04; } /* yellow-600 for contrast on white */
[data-theme="dark"] .stars { color: var(--gold); }

/* Typing */
.typing-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.typing-title { font-size: 1.25rem; font-weight: 700; margin: 0; }
.typing-tip { color: var(--muted); margin: 2px 0 0; font-size: 0.92rem; }
.stats {
  display: grid; grid-template-columns: auto auto auto 1fr auto;
  gap: 8px 18px; align-items: center;
  padding: 8px 14px; margin-bottom: 8px;
}
.stat { display: flex; align-items: baseline; gap: 8px; }
.stat .lbl { color: var(--muted); font-size: 0.85rem; }
.stat .val { font-weight: 700; font-size: 1.1rem; }
.stat .unit { color: var(--muted); font-size: 0.85rem; }
.bar { height: 10px; background: var(--secondary); border-radius: 5px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); width: 0%; }
.prog-pct { color: var(--muted); font-weight: 700; font-size: 0.85rem; }

.mid { display: grid; grid-template-columns: 1fr 150px; gap: 10px; padding: 8px; margin-bottom: 6px; align-items: stretch; }
.typed-area {
  font-size: calc(30px * var(--type-scale, 1));
  line-height: 1.55;
  padding: 12px 16px;
  max-height: calc(1.55em * 3 + 24px);
  overflow: hidden;
  font-family: var(--font-ui);
  word-break: break-word;
  font-weight: 600;
}
body.lang-my .typed-area, .typed-area.is-my { font-family: var(--font-my); }
.ch-ok { color: var(--good); }
.ch-cur {
  background: var(--current); color: var(--current-ink);
  border-radius: 3px; position: relative;
}
.ch-cur.is-caret::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--caret);
}
.ch-err { background: var(--error-bg); color: var(--error-fg); border-radius: 3px; }
.ch-todo { color: var(--text); }
.ch-space { display: inline-block; min-width: 0.35em; }
.next-box {
  background: var(--bg); border-radius: 12px; padding: 10px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.next-box .lbl { color: var(--muted); font-size: 0.8rem; margin-bottom: 4px; }
.next-box .glyph { font-size: 2.4rem; font-weight: 700; color: var(--accent); min-height: 1.2em; font-family: var(--font-my); }
.next-box .keyname { font-weight: 700; font-size: 0.9rem; color: var(--muted); }
.msg { color: var(--muted); margin: 4px 0 8px; min-height: 1.3em; }
.msg.is-err { color: var(--bad); }
.msg.is-good { color: var(--good); }

.kb-wrap {
  display: grid;
  grid-template-columns: minmax(160px, 0.22fr) minmax(0, 1fr) minmax(160px, 0.22fr);
  gap: 0 12px;
  align-items: stretch;
}
.hand-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden; /* crop the unused half of the two-hand SVG */
}
.hand-col svg.hands-svg,
.hand-col svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
}
.keyboard { display: flex; flex-direction: column; gap: 4px; user-select: none; min-width: 0; }
.kb-row { display: flex; gap: 4px; }
.kb-gap { display: block; }
.kb-key {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 6px;
  min-height: 38px;
  padding: 2px 2px 6px;
  font-size: 13px;
  line-height: 1;
}
.kb-key[data-finger="lp"] { background: var(--finger-bg-lp); }
.kb-key[data-finger="lr"] { background: var(--finger-bg-lr); }
.kb-key[data-finger="lm"] { background: var(--finger-bg-lm); }
.kb-key[data-finger="li"] { background: var(--finger-bg-li); }
.kb-key[data-finger="ri"] { background: var(--finger-bg-ri); }
.kb-key[data-finger="rm"] { background: var(--finger-bg-rm); }
.kb-key[data-finger="rr"] { background: var(--finger-bg-rr); }
.kb-key[data-finger="rp"] { background: var(--finger-bg-rp); }
.kb-key[data-finger="th"] { background: var(--finger-bg-th); }
.kb-main { display: block; text-align: center; margin-top: 8px; font-weight: 600; }
.kb-shift { position: absolute; top: 2px; right: 4px; font-size: 9px; color: var(--muted); }
.kb-us { position: absolute; top: 2px; left: 4px; font-size: 8px; color: var(--muted); }
.kb-special { font-size: 10px; color: var(--muted); }
.kb-bump {
  position: absolute; left: 50%; bottom: 4px; width: 10px; height: 2px;
  background: currentColor; transform: translateX(-50%); opacity: 0.7;
}
.kb-key.is-hint, .kb-key[data-key="space"].is-hint {
  background: var(--primary) !important; color: var(--on-primary); border-color: var(--text); font-weight: 700;
}
.kb-key.is-hint .kb-shift, .kb-key.is-hint .kb-us, .kb-key.is-hint .kb-special { color: var(--on-primary); }
.kb-key.is-backspace-hint { background: var(--error-bg) !important; color: #fff; }
.kb-key.is-pressed { filter: brightness(1.15); transform: translateY(1px); }
.kb-key[data-key="space"] { min-height: 36px; background: var(--card); }
.kb-key[data-key="space"] .kb-special { font-size: 11px; color: var(--muted); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

.result-stage { display: grid; place-items: center; min-height: 360px; }
.result-card { text-align: center; padding: 28px 32px; border: 2px solid var(--primary); max-width: 420px; }
.result-card h2 { margin: 0 0 8px; }
.star-row { font-size: 2rem; color: var(--gold); margin: 8px 0; }
.big-stats { display: flex; gap: 24px; justify-content: center; margin: 16px 0; }
.big-stats div { display: flex; flex-direction: column; }
.big-stats .v { font-size: 1.6rem; font-weight: 700; }
.big-stats .l { color: var(--muted); font-size: 0.85rem; }

/* Settings / forms */
.field { margin: 12px 0; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; }
.field .help { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.field input[type="text"], .field input[type="number"] {
  width: min(320px, 100%); padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--ghost); background: var(--card); color: var(--text);
}
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.more-tile { display: flex; gap: 12px; cursor: pointer; }
.more-tile:hover { background: var(--secondary-hover); }
.tile-icon { width: 28px; flex-shrink: 0; color: var(--primary); }
.tile-icon svg { width: 24px; height: 24px; }

/* Progress */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.tile .lbl { color: var(--muted); font-size: 0.85rem; }
.tile .val { font-size: 1.3rem; font-weight: 700; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chart { height: 180px; }
.history-line { color: var(--muted); margin: 4px 0; }
.weak { display: inline-block; background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 4px 8px; margin: 4px 4px 0 0; font-weight: 700; }

.onboard { max-width: 640px; margin: 10vh auto; }
.onboard h1 { margin-bottom: 8px; }
.error { color: var(--bad); min-height: 1.2em; }

.phone-note {
  display: none;
  background: var(--warn-soft); color: var(--warn);
  padding: 10px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-top: max(10px, env(safe-area-inset-top));
  text-align: center; font-size: 13px; font-weight: 600;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 30;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .app, .app.rail { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 25; min-height: 0;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px;
    padding: 10px 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    border-right: 0;
    border-bottom: 1px solid var(--side-border);
    width: 100%;
    max-width: 100%;
  }
  .brand { padding: 0 8px 0 0; }
  .nav {
    flex-direction: row; flex: 1 1 100%;
    flex-wrap: wrap;
    overflow: visible;
    min-width: 0; max-width: 100%;
    gap: 4px;
  }
  .nav-btn { width: auto; padding: 6px 8px; flex: 0 0 auto; }
  .side-spacer { display: none; }
  .side-foot { margin: 0; }
  .ver { display: none; }
  .kb-wrap { grid-template-columns: minmax(120px, 0.2fr) minmax(0, 1fr) minmax(120px, 0.2fr); }
  .tiles, .charts { grid-template-columns: 1fr 1fr; }
  .mid { grid-template-columns: 1fr 110px; }
  .typed-area { font-size: calc(24px * var(--type-scale, 1)); }
  .main {
    padding: 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .hero { min-height: 280px; padding: 20px 16px; }
  .btn-lg { min-width: 0; width: min(100%, 320px); }
}
@media (max-width: 720px) {
  .phone-note { display: block; }
  .kb-wrap, .next-box, .hand-col { display: none; }
  .mid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  body.is-typing .phone-note { display: block; font-weight: 700; }
  .lesson-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin: 0 0 12px;
    padding: 14px;
    overflow: visible;
  }
  .lesson-card .stages { justify-content: flex-start; flex-wrap: wrap; }
  .lesson-title, .lesson-keys, h1, .sub { overflow-wrap: anywhere; min-width: 0; }
  .sidebar .brand-center, .sidebar .brand-free, .sidebar .brand-sub, .sidebar .ver, .side-foot { display: none; }
  .brand-product { margin-top: 0; }
  .brand-logo, .brand-mark-img { width: 40px; height: 40px; }
  .nav-btn { flex: 0 0 auto; }
  .toggles { margin-left: auto; padding: 0; }
}
@media (pointer: coarse) and (max-width: 900px) {
  .phone-note { display: block; }
}

@media (max-height: 700px) {
  .main { padding-top: 12px; padding-bottom: 12px; }
  .typing-head { margin-bottom: 4px; }
  .typing-tip { display: none; }
  .stats { padding: 6px 12px; margin-bottom: 6px; }
  .mid { padding: 6px; margin-bottom: 4px; }
  .typed-area { font-size: calc(24px * var(--type-scale, 1)); padding: 8px 12px; max-height: calc(1.55em * 2 + 16px); }
  .msg { margin: 2px 0 4px; }
  .legend { margin-top: 4px; }
}
@media (max-width: 1100px) and (min-width: 721px) {
  .kb-wrap { grid-template-columns: minmax(140px, 0.2fr) minmax(0, 1fr) minmax(140px, 0.2fr); gap: 0 8px; }
}
