/* Mandarin Trainer. Same family as the lesson pages: jade band, vermilion accent,
   amber for tricky sounds, Outfit headings, Noto Sans body. Phone first. */

@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(fonts/noto-sans-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2215, U+FEFF, U+FFFD; }
/* the pinyin letters: ā ǎ ē ě ī ǐ ō ǒ ū ǔ ǖ ǘ ǚ ǜ */
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(fonts/noto-sans-pinyin.woff2) format("woff2");
  unicode-range: U+0100-017F, U+01CD-01DC, U+01F8-01F9, U+1E3F; }
@font-face { font-family: Outfit; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(fonts/outfit-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: light;
  --bg: #FFFFFF; --card: #FFFFFF; --soft: #F1F6F4; --ink: #15201C; --muted: #56635E; --line: #DCE5E1; --line2: #C3D0CB;
  --jade: #0F5E4E; --on-jade: #FFFFFF; --band: #0F5E4E; --on-band: #FFFFFF;
  --red: #C8372D; --accent: #C8372D; --amber: #B86A00; --blue: #2563C9;
  --good: #DDF2E8; --good-ink: #0F6B50; --bad: #FBE3E0; --bad-ink: #9A2A22;
  --mark: #FCE7C3; --mark-ink: #7A4305;
  --display: Outfit, "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --text: "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111614; --card: #1A211F; --soft: #212A27; --ink: #E8EEEB; --muted: #A3B0AB; --line: #2E3A36; --line2: #44534E;
    --jade: #4CC3A6; --on-jade: #0B1512; --band: #0C3A31;
    --red: #FF7A6B; --amber: #FFB44D; --blue: #86B4FF;
    --good: #173A2C; --good-ink: #8EE0BF; --bad: #43201D; --bad-ink: #FFB1A9;
    --mark: #4A3416; --mark-ink: #FFD49E;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--text); -webkit-font-smoothing: antialiased; overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.12; letter-spacing: -.01em; margin: 0; }
p, ul { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }
a { color: var(--jade); }
svg { display: block; flex: none; }
mark { background: var(--mark); color: var(--mark-ink); border-radius: .18em; padding: 0 .05em; }
:focus-visible { outline: 3px solid var(--jade); outline-offset: 2px; }
.band :focus-visible { outline-color: #fff; }

.wrap { width: 100%; max-width: 760px; margin-inline: auto; padding-left: max(16px, var(--safe-l)); padding-right: max(16px, var(--safe-r)); }
.page { display: flex; flex-direction: column; gap: 18px; padding-top: 16px; padding-bottom: calc(100px + var(--safe-b)); }
.fine { font-size: .82rem; line-height: 1.4; color: var(--muted); }
.hint { color: var(--muted); font-size: .95rem; }
.hint.left { text-align: left; }
.pad-top { padding-top: 14px; }
.warn { background: var(--bad); color: var(--bad-ink); border-radius: 14px; padding: 10px 14px; font-size: .92rem; }

/* ---- the jade band ---- */
.band { background: var(--band); color: var(--on-band); padding-top: var(--safe-t); }
.hero { padding-bottom: 18px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; }
.hero h1 { font-size: 1.75rem; font-weight: 800; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.stat { background: rgba(255, 255, 255, .12); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font: 800 1.75rem/1.05 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat b small { font-size: .95rem; font-weight: 600; opacity: .78; }
.stat span { font-size: .8rem; opacity: .9; }
.bar { position: sticky; top: 0; z-index: 20; }
.bar-in { display: flex; align-items: center; gap: 6px; min-height: 56px; padding-top: 4px; padding-bottom: 4px; padding-left: max(6px, var(--safe-l)); }
.bar-titles { flex: 1; min-width: 0; }
.bar-titles h1 { font-size: 1.2rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-titles p { font-size: .78rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- buttons ---- */
.icon-btn { all: unset; box-sizing: border-box; cursor: pointer; width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; color: inherit; }
.icon-btn.small { width: 44px; height: 44px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.icon-btn:focus-visible { outline: 3px solid var(--jade); outline-offset: 2px; }
.band .icon-btn:focus-visible { outline-color: #fff; }
.icon-btn:disabled { opacity: .35; cursor: default; }
@media (hover: hover) { .icon-btn.on-band:hover { background: rgba(255, 255, 255, .14); } .icon-btn:not(.on-band):not(:disabled):hover { background: var(--soft); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 48px; padding: .5rem 1.15rem;
  border-radius: 999px; border: 1.5px solid var(--jade); background: transparent; color: var(--jade);
  font-weight: 600; font-size: 1rem; line-height: 1.2; text-align: center; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.btn svg { width: 1.15em; height: 1.15em; }
.btn.solid { background: var(--jade); color: var(--on-jade); }
.btn.big { min-height: 60px; font: 700 1.15rem/1.2 var(--display); }
.btn.wide { width: 100%; }
.btn.small { min-height: 44px; padding: .3rem .95rem; font-size: .92rem; }
.btn.ghost { border-color: var(--line2); color: var(--ink); }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger.fill { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .4; cursor: default; }
.btn:active:not(:disabled), .cat:active, .g:active { transform: scale(.985); }
.btn.two { flex-direction: column; gap: 2px; padding-block: .6rem; min-height: 68px; }
.btn-main { font: 700 1.25rem/1.15 var(--display); }
.btn-sub { font: 500 .88rem/1.2 var(--text); opacity: .92; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.link-btn { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--jade); font-weight: 600; align-self: flex-start; }
.link-btn svg { width: 18px; height: 18px; }
.link-btn:focus-visible { outline: 3px solid var(--jade); outline-offset: 2px; border-radius: 8px; }

.fab {
  position: fixed; right: max(18px, var(--safe-r)); bottom: calc(18px + var(--safe-b)); z-index: 30;
  width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.96); }

/* ---- Home ---- */
.nudges { display: flex; flex-direction: column; gap: 8px; }
.nudge { display: flex; align-items: center; gap: 6px; background: var(--good); color: var(--good-ink); border-radius: 16px; padding: 6px 4px 6px 14px; }
.nudge-text { flex: 1; min-width: 0; font-size: .95rem; line-height: 1.25; }
.nudge .btn.solid { background: var(--good-ink); border-color: var(--good-ink); color: var(--good); }
.tier-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tier h2 { font-size: 1.4rem; font-weight: 800; }
.legend { font-size: .74rem; color: var(--muted); white-space: nowrap; }
.tier-sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.cat {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-height: 116px;
  padding: 12px; border: 1.5px solid var(--line); border-radius: 16px; background: var(--card);
}
.cat:focus-visible { outline: 3px solid var(--jade); outline-offset: 2px; }
@media (hover: hover) { .cat:hover { border-color: var(--jade); } }
.cat-name { font: 700 1rem/1.15 var(--display); }
.cat-note { font-size: .78rem; line-height: 1.25; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cat-grow { flex: 1; }
.pb { display: flex; height: 7px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.pb.tall { height: 10px; }
.pb i { display: block; height: 100%; }
.pb .k { background: var(--jade); }
.pb .l { background: var(--amber); }
.pb .u { background: var(--line2); }
.cat-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 6px; min-height: 22px; }
.nums { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill { font-size: .72rem; font-weight: 700; line-height: 1.5; border-radius: 99px; padding: .05rem .5rem; white-space: nowrap; }
.pill.due { background: var(--bad); color: var(--bad-ink); }
.pill.ready, .pill.in { background: var(--good); color: var(--good-ink); }
.credits { font-size: .78rem; line-height: 1.5; color: var(--muted); text-align: center; }
.credits a { color: inherit; }
.boot-error { align-items: flex-start; padding-top: calc(40px + var(--safe-t)); }

/* ---- category page ---- */
.summary { display: flex; flex-direction: column; gap: 8px; }
.summary-note { color: var(--muted); }
.summary-nums { font-size: .9rem; color: var(--muted); }
.summary-nums b { color: var(--ink); font-variant-numeric: tabular-nums; }
.unlock { display: flex; flex-direction: column; gap: 10px; border: 1.5px dashed var(--jade); border-radius: 16px; padding: 14px; background: color-mix(in srgb, var(--jade) 5%, var(--card)); }
.unlock h2 { font-size: 1.05rem; }
.unlock-list { list-style: none; padding: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; align-items: baseline; }
.unlock-list li { display: contents; }
.u-py { font-weight: 700; }
.u-en { color: var(--muted); font-size: .92rem; line-height: 1.3; }
.all-open { color: var(--muted); font-size: .95rem; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; margin-top: 4px; }
.list-head h2 { font-size: 1.2rem; font-weight: 800; }
.list-head h2 span { color: var(--muted); font: 600 .85rem var(--text); margin-left: 4px; }
.list-sub { font: 700 .76rem var(--display); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-top: 2px; }
.rows { list-style: none; padding: 0; border: 1.5px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--card); }
.rows.next { border-color: var(--jade); box-shadow: inset 4px 0 0 var(--jade); background: color-mix(in srgb, var(--jade) 5%, var(--card)); }
.rows.later { background: var(--soft); border-color: transparent; }
.rows.later .row-en { color: var(--muted); font-weight: 500; }
.rows.later .row { border-bottom-color: var(--bg); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(84px, 40%) 44px; align-items: center; gap: 4px; min-height: 60px; padding: 6px 6px 6px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-en { display: block; font-weight: 600; line-height: 1.25; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 2px; font-size: .7rem; font-weight: 700; line-height: 1.5; border-radius: 99px; padding: .03rem .5rem; }
.chip svg { width: 11px; height: 11px; stroke-width: 3.2; }
.chip.known, .chip.learned { background: var(--good); color: var(--good-ink); }
.chip.learning { background: var(--mark); color: var(--mark-ink); }
.chip.new { background: var(--soft); color: var(--muted); }
.chip-btn { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 3px; font-size: .72rem; font-weight: 700; color: var(--jade); border: 1.5px solid var(--line2); border-radius: 99px; padding: .2rem .6rem; min-height: 28px; position: relative; }
.chip-btn::after { content: ""; position: absolute; inset: -9px -6px; } /* bigger tap target */
.chip-btn svg { width: 12px; height: 12px; }
.chip-btn:focus-visible { outline: 3px solid var(--jade); outline-offset: 2px; }
.py-toggle { all: unset; box-sizing: border-box; cursor: pointer; min-height: 44px; display: flex; align-items: center; justify-content: flex-end; text-align: right; padding: 4px 6px; border-radius: 10px; }
.py-toggle:focus-visible { outline: 3px solid var(--jade); outline-offset: -2px; }
.py-dots { font-size: .8rem; font-weight: 600; color: var(--muted); border: 1.5px dashed var(--line2); border-radius: 99px; padding: .28rem .85rem; }
.py-text { font-weight: 700; font-size: 1.02rem; line-height: 1.2; overflow-wrap: anywhere; }
.icon-btn.play { color: var(--jade); background: var(--soft); border-radius: 50%; }
.rows.later .icon-btn.play { background: var(--bg); }
.icon-btn.play svg { width: 18px; height: 18px; }

/* ---- study ---- */
body[data-screen="study"] { overflow: hidden; }
.study { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.study .bar { position: static; flex: none; }
.counts { display: flex; gap: 12px; padding-right: 4px; font-size: .68rem; line-height: 1.1; text-align: center; }
.counts span { display: flex; flex-direction: column; align-items: center; opacity: .95; }
.counts b { font: 700 1.1rem/1.1 var(--display); font-variant-numeric: tabular-nums; }
.c-new b { color: #A9CBFF; }
.c-learn b { color: #FFD49E; }
.study-main { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding-top: 14px; padding-bottom: 14px; overscroll-behavior: contain; }
.fc { flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 14px; background: var(--card); border: 2px solid var(--jade); border-radius: 22px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tag { font: 700 .72rem/1.5 var(--display); text-transform: uppercase; letter-spacing: .06em; padding: .15rem .65rem; border-radius: 99px; background: var(--soft); color: var(--muted); }
.tag.new { background: color-mix(in srgb, var(--blue) 16%, transparent); color: var(--blue); }
.tag.mine { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--red); }
.fc-body { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding-block: 8px; }
.en { font: 800 clamp(1.6rem, 7vw, 2.3rem)/1.15 var(--display); text-wrap: balance; overflow-wrap: anywhere; }
.py { font-size: clamp(2.2rem, 11.4vw, 3rem); font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.py.long { font-size: clamp(1.7rem, 8.2vw, 2.4rem); }
.fc-body .py + .en, .fc-body .en + .py { margin-top: 2px; }
.fc-body .py ~ .en { font-size: clamp(1.3rem, 5.6vw, 1.8rem); font-weight: 700; }
.big-play { all: unset; box-sizing: border-box; cursor: pointer; width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; background: var(--jade); color: var(--on-jade); }
.big-play svg { width: 52px; height: 52px; }
.big-play:focus-visible { outline: 3px solid var(--jade); outline-offset: 4px; }
.audio-row { display: flex; gap: 8px; justify-content: center; width: 100%; }
.btn.pill { flex: 1 1 0; min-width: 0; max-width: 150px; padding-inline: .6rem; white-space: nowrap; }
.btn.mic.on { background: var(--mark); color: var(--mark-ink); border-color: var(--mark-ink); }
.heard { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 1.5px dashed var(--line2); border-radius: 14px; padding: 10px 12px; font-size: .95rem; line-height: 1.35; }
.heard.live { flex-direction: row; justify-content: center; gap: 10px; color: var(--mark-ink); background: var(--mark); border-color: transparent; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: currentColor; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.55); opacity: .5; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.syl { display: inline-flex; align-items: center; justify-content: center; min-width: 2.4rem; min-height: 1.9rem; padding: .05rem .6rem; border-radius: 9px; font-weight: 700; }
.syl.ok { background: var(--good); color: var(--good-ink); }
.syl.miss { background: var(--mark); color: var(--mark-ink); box-shadow: inset 0 -3px 0 var(--amber); }
.study-foot { flex: none; background: var(--bg); border-top: 1px solid var(--line); padding-top: 10px; padding-bottom: max(10px, var(--safe-b)); }
.grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.g { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 62px; border-radius: 14px; border: 1.5px solid var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); text-align: center; }
.g:focus-visible { outline: 3px solid var(--c); outline-offset: 2px; }
.g b { font: 700 1.02rem var(--display); color: var(--c); }
.g span { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.g1 { --c: var(--red); } .g2 { --c: var(--amber); } .g3 { --c: var(--jade); } .g4 { --c: var(--blue); }
.done { display: flex; flex-direction: column; gap: 12px; background: var(--soft); border-radius: 20px; padding: 20px 16px; }
.done > h2 { font-size: 1.6rem; font-weight: 800; }
.done .unlock { background: var(--card); }

/* ---- sheets ---- */
html.sheet-open, html.sheet-open body { overflow: hidden; }
.sheet-wrap { position: fixed; left: 0; right: 0; top: 0; height: 100%; z-index: 50; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 20, 16, .5); opacity: 0; transition: opacity .2s; }
.sheet { position: relative; width: 100%; max-width: 640px; margin-inline: auto; max-height: 94%; display: flex; flex-direction: column; background: var(--bg); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .22); transform: translateY(100%); transition: transform .24s cubic-bezier(.2, .8, .2, 1); }
.sheet.tall { height: 94%; }
.sheet-wrap.in .sheet { transform: none; }
.sheet-wrap.in .sheet-backdrop { opacity: 1; }
.sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 8px max(18px, var(--safe-l)); border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 1.3rem; font-weight: 800; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 14px; padding: 14px max(16px, var(--safe-r)) calc(20px + var(--safe-b)) max(16px, var(--safe-l)); }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-backdrop, #toast { transition: none; } .pulse { animation: none; } }

.search-box { flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1.5px solid var(--line2); border-radius: 14px; background: var(--card); color: var(--muted); }
.search-box:focus-within { border-color: var(--jade); }
.search-box input { flex: 1; min-width: 0; min-height: 52px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 1.05rem; -webkit-appearance: none; appearance: none; }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; }
.results { display: flex; flex-direction: column; gap: 10px; }
.results .result { margin-block: -5px; }
.result { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 1px; align-items: center; min-height: 58px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.result:focus-visible { outline: 3px solid var(--jade); outline-offset: -2px; border-radius: 8px; }
.r-py { grid-column: 1; font-weight: 700; font-size: 1.08rem; line-height: 1.25; }
.r-en { grid-column: 1; color: var(--muted); font-size: .9rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.r-side { grid-column: 2; grid-row: 1 / span 2; }
.zipf { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.zipf i { width: 4px; border-radius: 1px; background: var(--line2); }
.zipf i:nth-child(1) { height: 4px; } .zipf i:nth-child(2) { height: 6px; } .zipf i:nth-child(3) { height: 9px; } .zipf i:nth-child(4) { height: 11px; } .zipf i:nth-child(5) { height: 14px; }
.zipf i.on { background: var(--jade); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: .82rem; font-weight: 700; color: var(--muted); }
.field input, .field select { width: 100%; min-height: 50px; padding: 0 12px; border: 1.5px solid var(--line2); border-radius: 12px; background: var(--card); color: var(--ink); font-size: 1.05rem; -webkit-appearance: none; appearance: none; }
.field select { padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8a84' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
.field input:focus, .field select:focus { outline: 0; border-color: var(--jade); }
.field.bad input, .field.bad select { border-color: var(--red); }
.err { font-size: .84rem; font-weight: 600; color: var(--red); }
.found { text-align: center; padding-block: 6px; }
.found-py { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.found-en { color: var(--muted); }
.notice { display: flex; flex-direction: column; gap: 10px; background: var(--mark); color: var(--mark-ink); border-radius: 14px; padding: 12px 14px; }
.notice-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.notice .btn { border-color: var(--mark-ink); color: var(--mark-ink); }
.notice .btn.solid { background: var(--mark-ink); color: var(--mark); }
.audio-match { display: flex; flex-direction: column; gap: 8px; }
.audio-on { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.results.tight .result { min-height: 50px; }

.set { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.set h3 { font-size: 1.05rem; font-weight: 700; }
.set.split { flex-direction: row; align-items: center; justify-content: space-between; gap: 14px; }
.set.split > div { display: flex; flex-direction: column; gap: 4px; }
.stepper { align-self: flex-start; display: inline-flex; align-items: center; border: 1.5px solid var(--line2); border-radius: 14px; overflow: hidden; }
.stepper button { all: unset; box-sizing: border-box; cursor: pointer; width: 58px; height: 50px; display: grid; place-items: center; font-size: 1.6rem; line-height: 1; color: var(--jade); }
.stepper button:disabled { opacity: .3; cursor: default; }
.stepper button:focus-visible { outline: 3px solid var(--jade); outline-offset: -3px; border-radius: 12px; }
.stepper output { min-width: 66px; text-align: center; font: 700 1.35rem var(--display); font-variant-numeric: tabular-nums; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 9px 12px; border: 1.5px solid var(--line2); border-radius: 14px; }
.choice:focus-visible { outline: 3px solid var(--jade); outline-offset: 2px; }
.choice.on { border-color: var(--jade); background: color-mix(in srgb, var(--jade) 8%, transparent); }
.choice .dot { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line2); }
.choice.on .dot { border-color: var(--jade); background: radial-gradient(circle, var(--jade) 0 42%, transparent 46%); }
.choice b { display: block; font-weight: 600; line-height: 1.25; }
.choice small { display: block; font-size: .84rem; line-height: 1.3; color: var(--muted); }
.switch { all: unset; box-sizing: border-box; cursor: pointer; flex: none; width: 60px; height: 44px; display: flex; align-items: center; }
.switch i { position: relative; display: block; width: 56px; height: 32px; border-radius: 99px; background: var(--line2); transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch.on i { background: var(--jade); }
.switch.on i::after { transform: translateX(24px); }
.switch:focus-visible { outline: 3px solid var(--jade); outline-offset: 2px; border-radius: 99px; }

/* ---- toast and confirm ---- */
#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); z-index: 80; max-width: min(92vw, 420px); padding: 10px 18px; border-radius: 99px; background: var(--ink); color: var(--bg); font-size: .92rem; font-weight: 600; text-align: center; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
/* while studying, keep it clear of the buttons at the bottom */
body[data-screen="study"] #toast { bottom: auto; top: calc(var(--safe-t) + 6px); }
.modal-wrap { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(8, 20, 16, .55); }
.modal { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; padding: 20px; border-radius: 20px; background: var(--bg); box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.modal h2 { font-size: 1.3rem; font-weight: 800; }
.modal-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px; }

@media (min-width: 700px) {
  .hero h1 { font-size: 2.2rem; }
  .sheet-wrap { justify-content: center; }
  .sheet { border-radius: 20px; max-height: 86%; }
  .sheet.tall { height: 86%; }
  .fc { flex: 0 1 auto; min-height: 420px; }
}
