/* Structure and components. Colors, fonts, radii and shadows come from the
   tokens each look defines in looks.css. */

:root {
  --tabbar-h: 0px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-pattern, none);
  background-attachment: fixed;
  color: var(--text);
  font: 17px/1.55 var(--font-body);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--link, var(--accent)); }
h1, h2, h3 { font-family: var(--font-display); font-weight: var(--display-weight, 700); letter-spacing: var(--display-tracking, 0); }
h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); line-height: 1.15; margin: 0.35em 0; }
h2 { font-size: 1.3rem; margin: 1.6em 0 0.6em; }
h3 { font-size: 1.05rem; margin: 0 0 0.4em; }
.muted { color: var(--muted); }
.small, small { font-size: 0.86rem; }
.center { text-align: center; }
kbd { font: inherit; font-size: 0.8em; border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; background: var(--surface); }
mark { background: color-mix(in srgb, var(--accent) 25%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.skip { position: absolute; left: -999px; top: 8px; }
.skip:focus { left: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Category color: any element with data-cat gets --cat / --cat-soft. */
[data-cat="plosive"] { --cat: var(--cat-plosive); }
[data-cat="fricative"] { --cat: var(--cat-fricative); }
[data-cat="affricate"] { --cat: var(--cat-affricate); }
[data-cat="nasal"] { --cat: var(--cat-nasal); }
[data-cat="liquid"] { --cat: var(--cat-liquid); }
[data-cat="vowel"] { --cat: var(--cat-vowel); }
[data-cat="rvowel"] { --cat: var(--cat-rvowel); }
[data-cat="spelling"] { --cat: var(--cat-spelling); }
[data-cat] { --cat-soft: color-mix(in srgb, var(--cat) 16%, var(--surface)); --cat-ink: color-mix(in srgb, var(--cat) 70%, var(--text)); }

/* ── top bar & tab bar ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: var(--topbar-bg, var(--surface)); border-bottom: var(--border-w) solid var(--border);
  backdrop-filter: saturate(1.4) blur(10px);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: var(--display-weight, 700); font-size: 1.15rem; text-decoration: none; color: var(--text); white-space: nowrap; }
.logo { width: 32px; height: 32px; border-radius: 10px; background: url("../icon.svg") center / cover; flex: none; }
.top-search { flex: 1; max-width: 340px; margin-left: auto; }
.top-search input, .search-box input {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: var(--border-w) solid var(--border); border-radius: 999px; padding: 7px 14px;
}
.nav { display: flex; gap: 2px; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: var(--radius-sm); font-weight: 600; }
.nav a:hover, .nav a.active { background: var(--accent-soft); color: var(--accent-strong, var(--accent)); }
.mobile-only { display: none; }
.nav a.install-link { color: var(--accent-strong, var(--accent)); border: var(--border-w) solid color-mix(in srgb, var(--accent) 45%, var(--border)); border-radius: 999px; }
.nav a.install-link[hidden] { display: none; }
.tabbar { display: none; }
@media (max-width: 720px) {
  :root { --tabbar-h: calc(62px + env(safe-area-inset-bottom)); }
  .top-search { display: none; }
  .nav { margin-left: auto; }
  .nav a:not(.icon-link) { display: none; }
  .mobile-only { display: inline-block; }
  .nav a.install-link { font-size: 0.85rem; padding: 4px 10px; white-space: nowrap; }
}
@media (max-width: 440px) {
  .brand-name { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: var(--tabbar-h);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--topbar-bg, var(--surface)); border-top: var(--border-w) solid var(--border);
    backdrop-filter: saturate(1.4) blur(10px);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    text-decoration: none; color: var(--muted); font-size: 0.72rem; font-weight: 700;
  }
  .tabbar a span { font-size: 1.3rem; line-height: 1.2; transition: transform 0.15s; }
  .tabbar a.active { color: var(--accent-strong, var(--accent)); }
  .tabbar a.active span { transform: translateY(-2px) scale(1.12); }
  .foot { padding-bottom: calc(var(--tabbar-h) + 12px); }
}
main { max-width: 1000px; margin: 0 auto; padding: 8px 16px 40px; }
.foot { text-align: center; padding: 18px 16px; }
.crumbs { font-size: 0.88rem; color: var(--muted); margin-top: 8px; }
.crumbs a { color: var(--muted); }

/* ── buttons ── */
.btn, .say, .chip, .choice, .spelling, .seg button, .tabs button {
  font: inherit; cursor: pointer; color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: var(--border-w) solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); padding: 8px 14px;
  box-shadow: var(--btn-shadow, none);
  transition: transform 0.08s, background 0.15s, box-shadow 0.08s;
}
.btn:active, .say:active, .chip:active, .choice:active, .spelling:active { transform: translateY(var(--press-y, 1px)); box-shadow: var(--btn-shadow-pressed, none); }
.btn:hover, .say:hover, .chip:hover, .spelling:hover, .choice:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-border, var(--accent)); font-weight: 700; }
.btn.primary:hover { background: var(--accent-hover, var(--accent)); }
.btn.danger { color: var(--bad); }
.say { padding: 4px 11px; margin: 3px; font-size: 0.95rem; }
.say span { font-size: 0.85em; }
.playing { background: var(--accent-soft) !important; border-color: var(--accent) !important; }
.playing span { animation: wiggle 0.5s ease-in-out infinite alternate; display: inline-block; }
@keyframes wiggle { to { transform: scale(1.25); } }
.chip { padding: 5px 13px; border-radius: 999px; font-size: 0.95rem; white-space: nowrap; }
.chip.on { background: var(--cat, var(--accent)); color: var(--on-cat, #fff); border-color: var(--cat, var(--accent)); }
.chip[data-cat]:not(.on) { border-color: color-mix(in srgb, var(--cat) 50%, var(--border)); }

/* ── home ── */
.hero { display: grid; gap: 14px; padding: 10px 0 6px; }
.hero h1 { margin: 0; }
.hero p { margin: 4px 0 0; color: var(--muted); }
.wave { display: inline-block; animation: wave 1.8s ease-in-out 1; transform-origin: 70% 70%; }
@keyframes wave { 20%, 60% { transform: rotate(16deg); } 40%, 80% { transform: rotate(-8deg); } }
.search-box { position: relative; display: block; }
.search-box span { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search-box input { padding: 13px 18px 13px 46px; font-size: 1.02rem; background: var(--surface); box-shadow: var(--card-shadow); }
.search-box.big input { font-size: 1.1rem; }
.continue {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
  background: var(--cat-soft); border: var(--border-w) solid color-mix(in srgb, var(--cat) 40%, var(--border));
  border-radius: var(--radius); padding: 10px 14px;
}
.continue small { display: block; color: var(--muted); }
.continue > span:last-child { margin-left: auto; font-size: 1.3rem; color: var(--cat-ink); }
.mini-glyph { white-space: nowrap; flex: none; min-width: 46px; height: 46px; padding: 0 8px; border-radius: var(--radius-sm); background: var(--cat); color: var(--on-cat, #fff); display: grid; place-items: center; font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.1rem; }
.backend { display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); display: inline-block; }
.dot.ok { background: var(--good); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0; }
@media (max-width: 720px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px; padding: 16px; min-height: 120px;
  border-radius: var(--radius); background: var(--tile-bg, var(--cat-soft)); color: var(--text);
  border: var(--border-w) solid var(--tile-border, color-mix(in srgb, var(--cat) 30%, var(--border)));
  text-decoration: none; box-shadow: var(--card-shadow); transition: transform 0.15s;
}
.tile:hover { transform: translateY(-2px); }
.tile b { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.12rem; margin-top: auto; }
.tile small { color: var(--muted); }
.tile-icon {
  width: 52px; height: 52px; border-radius: var(--radius-sm); display: grid; place-items: center;
  background: var(--cat); color: var(--on-cat, #fff); font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.5rem;
}
.small-tiles .tile { min-height: 0; flex-direction: row; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); }
.small-tiles .tile b { margin: 0; font-size: 1rem; }
.small-tiles .tile span { font-size: 1.3rem; }
.callout { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 16px; border: var(--border-w) solid color-mix(in srgb, var(--accent) 25%, transparent); }
.deck-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.deck {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; padding: 12px 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: var(--border-w) solid var(--border); text-decoration: none; color: var(--text); box-shadow: var(--card-shadow);
}
.deck .emoji { grid-row: span 2; width: 42px; height: 42px; border-radius: var(--radius-sm); background: var(--cat-soft); display: grid; place-items: center; font-size: 1.3rem; }
.deck small { color: var(--muted); }
.bar { position: absolute; left: 0; bottom: 0; height: 5px; width: 100%; background: var(--cat-soft); }
.bar::after { content: ""; position: absolute; inset: 0; width: var(--p); background: var(--cat); border-radius: 0 3px 3px 0; }

/* ── deck grid ── */
.deck-head { padding: 4px 0 6px; }
.deck-head h1 { display: flex; align-items: center; gap: 10px; }
.card-grid, .card-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin: 14px 0; }
.mini-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px 8px 12px; border-radius: var(--radius);
  background: var(--surface); border: var(--border-w) solid var(--border); text-decoration: none; color: var(--text); text-align: center;
  box-shadow: var(--card-shadow); transition: transform 0.15s;
}
.mini-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--cat); border-radius: var(--radius) var(--radius) 0 0; }
.mini-card:hover { transform: translateY(-2px) rotate(var(--hover-tilt, 0deg)); }
.mini-card b { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.35rem; line-height: 1.2; }
.mini-card .emoji { font-size: 1.4rem; }
.mini-card small { color: var(--muted); }
.stars { color: var(--star, #f5a524); letter-spacing: 1px; font-size: 0.9rem; }
.stars .off { color: var(--border); }
.ipa { font-family: "Charis SIL", "Doulos SIL", "Gentium", "Noto Serif", Georgia, serif; color: var(--muted); }

/* ── flip card ── */
.card-wrap { max-width: 640px; margin: 10px auto 0; }
.card-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 4px; border: var(--border-w) solid var(--border); }
.seg button { border: none; background: transparent; box-shadow: none; border-radius: 999px; padding: 7px 16px; font-weight: 700; color: var(--muted); }
.seg button[aria-selected="true"], .seg button.on { background: var(--seg-on, var(--surface)); color: var(--text); box-shadow: var(--seg-shadow, 0 1px 4px rgb(0 0 0 / 0.12)); }
.side-switch button[aria-selected="true"] { background: var(--cat); color: var(--on-cat, #fff); }
.flip-scene { perspective: 1800px; }
.flip-scene.enter-right { animation: in-right 0.28s ease-out; }
.flip-scene.enter-left { animation: in-left 0.28s ease-out; }
@keyframes in-right { from { opacity: 0; transform: translateX(40px); } }
@keyframes in-left { from { opacity: 0; transform: translateX(-40px); } }
.flip { display: grid; transition: transform 0.55s cubic-bezier(.3,.7,.25,1.15); transform-style: preserve-3d; }
.flip.flipped { transform: rotateY(180deg); }
@media (prefers-reduced-motion: reduce) { .flip, .flip-scene { transition: none; animation: none !important; } }
.face {
  grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; min-width: 0;
  background: var(--face-bg, var(--surface)); border: var(--card-border-w, var(--border-w)) solid var(--card-border, var(--border));
  border-radius: var(--radius-lg); box-shadow: var(--card-shadow-lg, var(--card-shadow));
  padding: 16px 18px 20px; min-height: 470px; display: flex; flex-direction: column; gap: 12px;
  position: relative; overflow: hidden;
}
.face::before { content: ""; position: absolute; inset: 0 0 auto 0; height: var(--face-band, 8px); background: var(--cat); }
.face.back { transform: rotateY(180deg); }
.flip:not(.flipped) .back, .flip.flipped .front { pointer-events: none; visibility: hidden; transition: visibility 0s 0.28s; }
.flip.flipped .back, .flip:not(.flipped) .front { visibility: visible; transition: visibility 0s 0.28s; }
.face-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }
.cat-pill { font-size: 0.78rem; font-weight: 800; text-transform: var(--pill-case, uppercase); letter-spacing: 0.06em; color: var(--cat-ink); background: var(--cat-soft); padding: 3px 10px; border-radius: 999px; }
.big-label { font-weight: 700; }
.glyph { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; margin-top: 2px; }
.glyph b { font-family: var(--font-glyph, var(--font-display)); font-weight: var(--display-weight); font-size: clamp(3rem, 14vw, 4.8rem); line-height: 1; color: var(--glyph-color, var(--text)); }
.glyph .emoji { font-size: 2.8rem; }
.glyph .ipa { font-size: 1.6rem; }
.say-this { text-align: center; margin: 0; color: var(--muted); }
.say-this span { display: block; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.word-text { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 2rem; color: var(--text); display: block; line-height: 1.2; }
.word-text.huge { font-size: 2.6rem; text-align: center; margin: 0; }
.sentence-text { font-size: 1.15rem; color: var(--text); display: block; }
.targets {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; scroll-snap-type: x proximity; scrollbar-width: thin;
  mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 24px), transparent);
}
.targets .chip { scroll-snap-align: start; }
.rec-row { display: flex; justify-content: center; padding: 4px 0; }
.rec {
  --level: 0;
  width: 96px; height: 96px; border-radius: 50%; border: var(--rec-border, none); font-size: 2.5rem; cursor: pointer;
  background: var(--rec); color: #fff;
  box-shadow: 0 0 0 calc(var(--level) * 24px) color-mix(in srgb, var(--rec) 28%, transparent), var(--rec-shadow, var(--card-shadow));
  transition: box-shadow 0.08s, transform 0.12s; display: block; margin: 6px auto;
}
.rec:hover { transform: scale(1.04); }
.rec:active { transform: scale(0.94); }
.rec.recording { animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { filter: brightness(1.15); } }
.status { text-align: center; color: var(--muted); min-height: 1.5em; }
.actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.feedback { border-radius: var(--radius); padding: 10px 14px; animation: pop-in 0.25s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96); } }
.feedback p { margin: 0.3em 0; }
.feedback.good { background: var(--good-soft); border: var(--border-w) solid color-mix(in srgb, var(--good) 30%, transparent); }
.feedback.warn { background: var(--warn-soft); border: var(--border-w) solid color-mix(in srgb, var(--warn) 30%, transparent); }
.tip { background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px 12px; }
.sentence-check .ok { color: var(--good); font-weight: 600; }
.sentence-check .missed { color: var(--bad); text-decoration: line-through; }
.sentence-check .changed { color: var(--warn); font-weight: 600; text-decoration: underline wavy; }
.listen { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.big-say { font-size: 1.15rem; padding: 10px 20px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: var(--border-w) solid var(--border); padding-bottom: 0; margin-top: 4px; }
.tabs button { border: none; background: none; box-shadow: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; padding: 8px 12px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: calc(-1 * var(--border-w)); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--cat); }
.tab-panel { animation: pop-in 0.2s ease-out; }
.tab-panel h3 { margin-top: 12px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 0; }
.tag { font-size: 0.8rem; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); text-decoration: none; }
a.tag:hover { color: var(--accent); }
.spellings { display: flex; flex-wrap: wrap; gap: 6px; }
.spelling { flex-direction: column; gap: 0; padding: 4px 12px; line-height: 1.2; }
.spelling b { font-size: 1.1rem; font-family: var(--font-display); font-weight: var(--display-weight); }
.spelling small { color: var(--muted); }
.pos { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 4px 0; }
.pos small { color: var(--muted); width: 54px; }
.pairs { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.pair { display: inline-flex; align-items: center; white-space: nowrap; }
.vs { color: var(--muted); font-size: 0.8rem; }
.notes dt { font-weight: 700; margin-top: 8px; }
.notes dd { margin: 0; }
.sound-row { display: flex; align-items: center; gap: 8px; }
@media (hover: none) { .keys { display: none; } }

/* The flip is the core of the method, so it is the biggest, brightest button, pinned to the
   bottom of the screen with prev / record-or-listen / next. On practice screens it takes the
   place of the phone tab bar. */
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; gap: 8px; justify-content: center; align-items: stretch;
  padding: 10px max(16px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
  background: var(--topbar-bg, var(--surface)); backdrop-filter: blur(8px);
  border-top: var(--border-w) solid var(--border);
}
body:has(.bottom-bar) { padding-bottom: 90px; }
body:has(.bottom-bar) .tabbar { display: none; }
body:has(.bottom-bar) .foot { padding-bottom: 18px; }
.bottom-bar .bar-nav { flex: none; padding: 0 18px; font-size: 1.2rem; }
.bottom-bar .bar-act { font-size: 1.4rem; }
.bottom-bar .bar-act.recording { animation: pulse 1.2s infinite; background: var(--rec); }
.flip-btn {
  display: flex; flex: 1; max-width: 560px;
  font-size: 1.15rem; font-weight: 800; padding: 14px 18px; border-radius: var(--radius);
  background: var(--cat, var(--accent)); color: var(--on-cat, var(--accent-ink)); border-color: var(--accent-border, var(--cat, var(--accent)));
}
.flip-btn:hover { background: var(--cat, var(--accent)); filter: brightness(1.08); }
.flip-btn.nudge { animation: nudge 1.4s ease-in-out 3; }
@keyframes nudge { 50% { transform: scale(1.03); box-shadow: 0 0 0 8px color-mix(in srgb, var(--cat, var(--accent)) 28%, transparent); } }

/* what you've already done */
.history { text-align: center; margin: 0; color: var(--muted); font-size: 0.9rem; }
.chip.won { border-color: var(--good); }
.chip.tried { border-style: dashed; }
.chip .mk { font-size: 0.8em; }
.chip:not(.on).won .mk { color: var(--good); }
.deck-progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 10px 0 2px; }
.deck-progress > div { height: 100%; background: var(--good); transition: width 0.4s; }
.actions.start { justify-content: flex-start; margin: 8px 0; }
.mini-card.mastered { border-color: var(--good); background: var(--good-soft); }
.mini-card.tried { border-style: dashed; }
.mini-card .badge { font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.mini-card.mastered .badge { color: var(--good); }

/* celebration glow (confetti below) */
.win { animation: win-glow 0.9s ease-out; }
@keyframes win-glow { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); } 100% { box-shadow: 0 0 0 30px transparent; } }
@media (prefers-reduced-motion: reduce) { .win, .flip-btn.nudge { animation: none; } }
@media (max-width: 720px) { .face { min-height: 0; padding: 14px 14px 18px; } .card-wrap { margin-top: 4px; } }

/* confetti */
.confetti { position: fixed; z-index: 60; pointer-events: none; width: 0; height: 0; }
.confetti i {
  position: absolute; width: 9px; height: 14px; border-radius: 2px; background: var(--c);
  animation: burst 1.1s cubic-bezier(.15,.7,.3,1) forwards;
}
@keyframes burst {
  to { transform: translate(var(--x), calc(var(--y) + 80px)) rotate(var(--r)); opacity: 0; }
}

/* ── search ── */
.word-results { display: grid; gap: 8px; }
.word-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--radius); padding: 8px 10px; box-shadow: var(--card-shadow); }
.word-row .say { font-weight: 700; font-size: 1.05rem; }
.on-cards { display: flex; flex-wrap: wrap; gap: 6px; }
.practice-any { display: block; margin: 14px 0; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); font-weight: 700; text-decoration: none; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty .chip { margin: 3px; text-decoration: none; }

/* ── lessons ── */
.lesson-list { display: grid; gap: 10px; }
.lesson {
  display: flex; gap: 14px; align-items: center; padding: 12px 16px; border-radius: var(--radius); background: var(--surface);
  border: var(--border-w) solid var(--border); text-decoration: none; color: var(--text); box-shadow: var(--card-shadow);
}
.lesson .emoji { font-size: 1.6rem; width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--accent-soft); }
.lesson p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.lesson-body { max-width: 720px; margin: 0 auto; }
.lesson-body section { background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--radius); padding: 4px 20px 16px; margin: 14px 0; box-shadow: var(--card-shadow); }
.lead { font-size: 1.1rem; color: var(--muted); }
.pairs-table, .chart { border-collapse: collapse; width: 100%; }
.pairs-table th, .pairs-table td, .chart th, .chart td { border-bottom: 1px solid var(--border); padding: 7px 9px; text-align: left; vertical-align: top; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); border: var(--border-w) solid var(--border); box-shadow: var(--card-shadow); }
.chart tr[data-cat] td:first-child { border-left: 5px solid var(--cat); }
.chart td.spellings .spelling { margin: 2px; }
.chart .ok { color: var(--good); }
.chart .missed { color: var(--bad); }

/* ── games ── */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }
.controls select, .settings select, .settings input:not([type="checkbox"]):not([type="range"]):not([type="radio"]) {
  font: inherit; padding: 8px 10px; border-radius: var(--radius-sm); border: var(--border-w) solid var(--border); background: var(--surface); color: var(--text); max-width: 100%;
}
.game { background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--radius-lg); padding: 20px; text-align: center; box-shadow: var(--card-shadow-lg, var(--card-shadow)); }
.prompt { font-size: 1.15rem; }
.big-btn { font-size: 1.2rem; padding: 12px 24px; }
.choices { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 18px 0; }
.choice { font-size: 1.6rem; padding: 14px 30px; font-family: var(--font-display); font-weight: var(--display-weight); }
.choice.right { background: var(--good-soft); border-color: var(--good); }
.choice.wrong { background: var(--warn-soft); border-color: var(--bad); }
.homophone-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.hgroup { background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.hgroup .say { align-self: flex-start; }
.hgroup small { color: var(--muted); }
.het { font-size: 1.2rem; }

/* ── progress & settings ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.stats div { background: var(--cat-soft); border: var(--border-w) solid color-mix(in srgb, var(--cat) 30%, var(--border)); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; }
.stats b { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.8rem; }
.stats small { color: var(--muted); }
.settings fieldset { border: var(--border-w) solid var(--border); border-radius: var(--radius); background: var(--surface); margin: 0 0 14px; padding: 12px 16px; display: grid; gap: 12px; }
.settings legend { font-weight: 800; padding: 0 6px; font-family: var(--font-display); }
.settings label { display: grid; gap: 4px; }
.settings label.check { display: flex; gap: 8px; align-items: center; }
.settings .row { display: flex; gap: 8px; flex-wrap: wrap; }
.settings .row input { flex: 1 1 160px; }
.look-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.look-option { display: flex !important; gap: 12px; align-items: center; padding: 10px; border: 2px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.look-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.look-option input { position: absolute; opacity: 0; }
.look-option small { display: block; color: var(--muted); }
.look-swatch { position: relative; width: 64px; height: 52px; flex: none; border-radius: 10px; overflow: hidden; display: grid; grid-template-columns: repeat(3, 1fr); }
.look-swatch b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.3rem; }
[data-preview="playroom"] .look-swatch { background: #fff6e8; } [data-preview="playroom"] .look-swatch i:nth-child(1) { background: #ff7a59; } [data-preview="playroom"] .look-swatch i:nth-child(2) { background: #2ec4b6; } [data-preview="playroom"] .look-swatch i:nth-child(3) { background: #ffc93c; } [data-preview="playroom"] b { font-family: Fredoka, sans-serif; color: #fff; text-shadow: 0 2px 0 rgb(0 0 0 / 0.25); }
[data-preview="studio"] .look-swatch { background: #f4f1ea; border: 1px solid #d9d3c7; } [data-preview="studio"] .look-swatch i { margin-top: 38px; } [data-preview="studio"] .look-swatch i:nth-child(1) { background: #c2410c; } [data-preview="studio"] .look-swatch i:nth-child(2) { background: #3f6e5a; } [data-preview="studio"] .look-swatch i:nth-child(3) { background: #1f2a44; } [data-preview="studio"] b { font-family: Fraunces, Georgia, serif; font-weight: 600; color: #1f2a44; }
[data-preview="pop"] .look-swatch { background: #efedf4; border: 2px solid #2b2836; box-shadow: 3px 3px 0 #2b2836; } [data-preview="pop"] .look-swatch i:nth-child(1) { background: #f2a2b9; } [data-preview="pop"] .look-swatch i:nth-child(2) { background: #f4de95; } [data-preview="pop"] .look-swatch i:nth-child(3) { background: #94d2b8; } [data-preview="pop"] b { font-family: "Archivo Black", sans-serif; color: #2b2836; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px); transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: var(--radius-sm); z-index: 50; max-width: calc(100% - 32px); animation: pop-in 0.2s;
}

/* ── checkup ── */
.welcome {
  display: flex; gap: 18px; align-items: center; margin: 12px 0 4px; padding: 20px;
  background: var(--cat-soft); border: var(--border-w) solid color-mix(in srgb, var(--cat) 45%, var(--border));
  border-radius: var(--radius-lg); box-shadow: var(--card-shadow);
}
.welcome h1 { margin: 0 0 6px; font-size: clamp(1.4rem, 4.5vw, 1.9rem); }
.welcome p { margin: 0; }
.welcome-art { font-size: 2.6rem; flex: none; }
@media (max-width: 560px) { .welcome { flex-direction: column; align-items: flex-start; } }
.checkup-link { display: block; text-decoration: none; font-weight: 700; padding: 10px 14px; border-radius: var(--radius); background: var(--surface); border: var(--border-w) dashed var(--border); }
.plan { background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--card-shadow); display: grid; gap: 8px; }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.plan-cards { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-cards .chip { text-decoration: none; }
.plan-cards .mk { font-size: 0.75em; font-weight: 800; color: var(--good); }
.l1-plan p { margin: 0; }
.l1-badge { display: block; font-style: normal; font-size: 0.78rem; font-weight: 800; color: var(--cat-ink, var(--accent)); }
.checkup { max-width: 640px; margin: 0 auto; display: grid; gap: 12px; }
.checkup h1, .checkup h2 { margin: 0.2em 0 0; }
.checkup-tips { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
.lang-pick { display: grid; gap: 4px; }
.lang-pick select { font: inherit; padding: 8px 10px; border-radius: var(--radius-sm); border: var(--border-w) solid var(--border); background: var(--surface); color: var(--text); max-width: 320px; }
.ck-progress { display: flex; gap: 6px; }
.ck-progress span { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.ck-progress .done { background: var(--good); border-color: var(--good); }
.ck-progress .now { background: var(--accent); border-color: var(--accent); }
.ck-sentence {
  font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(1.5rem, 5.5vw, 2.1rem); line-height: 1.3;
  text-align: center; margin: 10px 0 0; background: var(--surface); border: var(--border-w) solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 18px; box-shadow: var(--card-shadow-lg, var(--card-shadow)); text-wrap: balance;
}
.ck-sentence .ok { color: var(--good); }
.ck-sentence .changed { color: var(--warn); text-decoration: underline wavy; text-underline-offset: 5px; }
.ck-sentence .missed { color: var(--muted); text-decoration: line-through; }
.checkup .rec { margin: 8px auto 0; }
.ck-results { display: grid; gap: 8px; }
.ck-result {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
  background: var(--cat-soft, var(--surface)); border: var(--border-w) solid color-mix(in srgb, var(--cat, var(--border)) 40%, var(--border));
  border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--card-shadow);
}
.ck-result small { display: block; color: var(--muted); }
.ck-result > span:last-child { margin-left: auto; font-size: 1.2rem; }
.ck-result:not([data-cat]) .mini-glyph { background: var(--accent-soft); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ── install page ── */
.install { max-width: 560px; margin: 0 auto; display: grid; gap: 14px; }
.install-hero { display: flex; gap: 16px; align-items: flex-start; }
.install-hero img { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--card-shadow); flex: none; }
.install-hero h1 { margin: 0; }
.install .big-btn { justify-self: start; }
.install ol { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.install-steps { background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--card-shadow); }
.install-steps h2 { margin: 0 0 8px; font-size: 1.1rem; }

/* ── kid mode ── */
body.kid { font-size: 20px; }
body.kid .rec { width: 124px; height: 124px; font-size: 3.2rem; }
body.kid .keys { display: none; }
