:root {
  --ink: #203a34;
  --ink-soft: #52635f;
  --jade: #2d7566;
  --jade-pale: #e5f0ec;
  --red: #b33a32;
  --red-pale: #f8e9e7;
  --gold: #b78322;
  --gold-pale: #fbf1d8;
  --blue: #356c87;
  --paper: #f7f8f5;
  --white: #ffffff;
  --line: #d7dfda;
  --muted: #6c7975;
  --shadow: 0 10px 28px rgba(25, 55, 47, 0.12);
  --safe-top: max(env(safe-area-inset-top), var(--android-inset-top, 0px));
  --safe-right: max(env(safe-area-inset-right), var(--android-inset-right, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom), var(--android-inset-bottom, 0px));
  --safe-left: max(env(safe-area-inset-left), var(--android-inset-left, 0px));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; }
html { background: var(--paper); color: var(--ink); font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", sans-serif; }
body { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
button, select { color: inherit; font: inherit; letter-spacing: 0; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid #78a99d; outline-offset: 3px; }
svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#app { min-height: 100vh; min-height: 100dvh; }

.intro-screen {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
  color: #fff;
  background: var(--ink);
  text-align: center;
  transition: opacity 240ms ease;
}
.intro-screen.leaving { opacity: 0; pointer-events: none; }
.intro-seal, .brand-seal {
  display: grid;
  place-items: center;
  border: 3px solid currentColor;
  color: #fff;
  background: var(--red);
  font-family: "Noto Serif CJK KR", Batang, serif;
  font-weight: 800;
}
.intro-seal { width: 112px; height: 112px; margin-bottom: 16px; font-size: 68px; box-shadow: 8px 8px 0 #c89a39; }
.intro-screen h1 { margin: 0; font-family: "Noto Serif CJK KR", Batang, serif; font-size: 42px; letter-spacing: 0; }
.intro-screen p { margin: 0; color: #dfeae6; font-size: 18px; }
.intro-action { margin-top: 28px; border-bottom: 1px solid #9dbab2; padding: 8px 0; font-weight: 700; }
.intro-screen small { position: absolute; bottom: calc(22px + var(--safe-bottom)); color: #b9cbc5; }

.onboard-screen {
  position: fixed;
  z-index: 900;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(20px + var(--safe-top)) calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left));
  background: rgba(25, 43, 38, 0.76);
}
.onboard-sheet { width: min(520px, 100%); max-height: 100%; overflow-y: auto; padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); box-shadow: var(--shadow); }
.onboard-mark { width: 58px; height: 58px; display: grid; place-items: center; background: var(--red); color: #fff; font: 800 34px/1 Batang, serif; }
.onboard-sheet h2 { margin: 18px 0 8px; font-size: 25px; }
.onboard-sheet > p { margin: 0; color: var(--ink-soft); line-height: 1.65; }
.onboard-steps { margin: 22px 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.onboard-steps li { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.onboard-steps span { color: var(--muted); line-height: 1.45; }

.main-menu {
  width: min(1080px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
}
.menu-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 22px; border-bottom: 2px solid var(--ink); }
.menu-brand { display: flex; align-items: center; gap: 16px; }
.brand-seal { width: 68px; height: 68px; flex: 0 0 68px; font-size: 42px; box-shadow: 5px 5px 0 var(--gold); }
.byline { margin: 0 0 3px; color: var(--red); font-size: 12px; font-weight: 800; }
.menu-header h1 { margin: 0; font: 800 32px/1.2 "Noto Serif CJK KR", Batang, serif; letter-spacing: 0; }
.menu-tagline { margin: 5px 0 0; color: var(--ink-soft); }
.network-state { flex: 0 0 auto; padding: 8px 10px; border: 1px solid #bad0c9; border-radius: 4px; color: var(--jade); background: var(--jade-pale); font-size: 12px; font-weight: 700; }
.network-state.offline { border-color: #e3c98f; color: #77530f; background: var(--gold-pale); }

.reward-strip { display: flex; align-items: center; gap: 8px; min-height: 44px; margin: 18px 0 10px; overflow-x: auto; scrollbar-width: none; }
.reward-strip::-webkit-scrollbar { display: none; }
.rb-level, .rb-stat { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--white); font-size: 13px; }
.rb-level { color: #fff; border-color: var(--jade); background: var(--jade); }
.rb-level b { margin-left: 4px; }
.quick-controls { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 20px; }
.icon-control { min-height: 40px; display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: #fff; cursor: pointer; font-size: 13px; font-weight: 700; }
.icon-control.off, .icon-control[aria-pressed="false"] { color: #8c9793; background: #eef1ef; }

.mode-group { margin-top: 24px; }
.group-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.group-heading > span { display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: var(--ink); font: 700 20px/1 Batang, serif; }
.group-heading h2, .group-heading p { margin: 0; }
.group-heading h2 { font-size: 18px; }
.group-heading p { margin-top: 2px; color: var(--muted); font-size: 12px; }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-card {
  min-width: 0;
  min-height: 92px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  box-shadow: 0 2px 0 rgba(32, 58, 52, 0.07);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}
.mode-card:hover { transform: translateY(-2px); border-color: #8eaaa2; box-shadow: 0 7px 16px rgba(32, 58, 52, 0.1); }
.mode-card:active { transform: translateY(0); }
.mode-glyph { display: grid; place-items: center; width: 60px; height: 60px; color: #fff; background: var(--jade); font: 800 36px/1 Batang, serif; }
.mode-glyph.red { background: var(--red); }
.mode-glyph.gold { color: var(--ink); background: #d5aa4c; }
.mode-glyph.small { width: 48px; height: 48px; font-size: 28px; }
.mode-copy { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.mode-copy b { overflow-wrap: anywhere; font-size: 16px; }
.mode-copy small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.mode-arrow { color: var(--jade); font-size: 28px; }
.mode-card.compact { min-height: 74px; grid-template-columns: 48px minmax(0, 1fr); }

.menu-secondary { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.secondary-link { min-width: 0; min-height: 64px; display: flex; align-items: center; gap: 11px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 6px; background: #edf2ef; text-align: left; cursor: pointer; }
.secondary-link > svg, .secondary-icon { flex: 0 0 28px; width: 28px; height: 28px; color: var(--jade); }
.secondary-icon { display: grid; place-items: center; border: 1px solid var(--red); color: var(--red); font: 700 19px/1 Batang, serif; }
.secondary-link > span:nth-child(2) { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.secondary-link b { font-size: 14px; }
.secondary-link small { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.review-link { border-color: #d9bd82; background: var(--gold-pale); }
.menu-footer { margin-top: 28px; color: #87928e; font-size: 11px; text-align: center; }

.mode-ui { display: none; width: min(1120px, 100%); min-height: 100vh; min-height: 100dvh; margin: 0 auto; padding: calc(16px + var(--safe-top)) calc(20px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(20px + var(--safe-left)); }
.mode-ui.active { display: block; }
.mode-topbar { min-height: 64px; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.mode-topbar h1, .mode-topbar p { margin: 0; }
.mode-topbar h1 { font-size: 22px; }
.mode-topbar p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.mode-live { min-width: 70px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink-soft); font-size: 12px; font-weight: 800; text-align: center; }
.mode-live:empty { visibility: hidden; }

.icon-button, .command {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  font-weight: 800;
  cursor: pointer;
}
.icon-button { width: 44px; display: inline-grid; place-items: center; padding: 0; }
.command { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; }
.command.primary { border-color: var(--jade); color: #fff; background: var(--jade); }
.command.danger { border-color: #e5bcb8; color: #8f2e28; background: var(--red-pale); }
.command.selected { border-color: var(--gold); background: var(--gold-pale); }
.icon-button:hover, .command:hover { border-color: #8ba69f; }
.icon-button.ready { color: #fff; border-color: var(--red); background: var(--red); animation: ready-pulse 1.4s ease-in-out infinite; }
@keyframes ready-pulse { 50% { box-shadow: 0 0 0 5px rgba(179, 58, 50, 0.13); } }

.filter-row { display: flex; gap: 7px; margin: 14px 0; overflow-x: auto; padding: 2px 1px 6px; scrollbar-width: thin; }
.filter-chip { flex: 0 0 auto; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 18px; color: var(--ink-soft); background: #fff; font-size: 12px; font-weight: 800; cursor: pointer; }
.filter-chip.active { color: #fff; border-color: var(--ink); background: var(--ink); }

.practice-layout { display: grid; grid-template-columns: minmax(220px, 310px) minmax(380px, 1fr); gap: 24px; align-items: start; }
.practice-info { min-height: 430px; display: flex; flex-direction: column; align-items: flex-start; padding: 28px 24px; border-left: 6px solid var(--red); background: #eaf0ed; }
.practice-emoji { font-size: 31px; }
.practice-glyph { margin: 18px 0 8px; color: var(--ink); font: 800 88px/1 Batang, "Noto Serif CJK KR", serif; }
.practice-reading { margin: 0; color: var(--red); font: 800 25px/1.3 Batang, serif; }
.practice-example { margin: 12px 0 4px; font-size: 17px; font-weight: 800; }
.practice-role { margin: 10px 0 18px; color: var(--ink-soft); line-height: 1.6; }
.listen-button { margin-top: auto; }
.writing-tool { min-width: 0; display: flex; flex-direction: column; align-items: center; }
.writer-caption { width: min(420px, 100%); display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.writer-caption strong { font-size: 15px; }
.writer-caption span { color: var(--muted); font-size: 12px; }
.writer-board { position: relative; width: min(420px, 100%); aspect-ratio: 1; overflow: hidden; border: 2px solid var(--ink); background: #fff; box-shadow: 7px 7px 0 #dbe5e0; }
.writer-board::before, .writer-board::after { content: ""; position: absolute; z-index: 0; pointer-events: none; opacity: 0.45; }
.writer-board::before { top: 50%; left: 0; width: 100%; border-top: 1px dashed #a9b9b3; }
.writer-board::after { top: 0; left: 50%; height: 100%; border-left: 1px dashed #a9b9b3; }
.writer-host { position: relative; z-index: 1; width: 100%; height: 100%; touch-action: none; }
.writer-host > svg { display: block; width: 100% !important; height: 100% !important; }
.writer-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: #ccd6d1; font: 800 150px/1 Batang, serif; }
.practice-feedback { width: min(540px, 100%); min-height: 48px; display: grid; place-items: center; margin-top: 14px; padding: 8px 12px; border-left: 4px solid #92aaa3; color: var(--ink-soft); background: #edf2ef; font-size: 14px; font-weight: 700; text-align: center; }
.practice-feedback.correct, .quiz-feedback.correct, .match-instruction.correct { border-color: var(--jade); color: #185a4d; background: var(--jade-pale); }
.practice-feedback.retry, .quiz-feedback.retry { border-color: var(--gold); color: #72500f; background: var(--gold-pale); }
.practice-feedback.complete, .match-instruction.complete { border-color: var(--red); color: #8b2d27; background: var(--red-pale); }
.practice-progress { width: min(540px, 100%); height: 6px; margin-top: 10px; overflow: hidden; background: #dce3df; }
.practice-progress span { display: block; width: 0; height: 100%; background: var(--jade); transition: width 300ms ease; }
.practice-actions { width: min(590px, 100%); display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 13px; }

.word-heading { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 13px; margin: 10px auto 16px; padding: 12px 16px; border-left: 5px solid var(--gold); background: var(--gold-pale); }
.word-emoji { font-size: 30px; }
.word-heading h2, .word-heading p { margin: 0; }
.word-title { font: 800 23px/1.3 Batang, serif; }
.word-meaning { margin-top: 3px !important; color: var(--ink-soft); font-size: 13px; }
.word-tool { display: flex; flex-direction: column; align-items: center; }
.word-writers { width: min(780px, 100%); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.word-cell { min-width: 0; opacity: 0.64; transition: opacity 160ms ease, transform 160ms ease; }
.word-cell.active, .word-cell.done { opacity: 1; }
.word-cell.active { transform: translateY(-3px); }
.word-cell.active .writer-board { border-color: var(--red); box-shadow: 7px 7px 0 #edcfca; }
.word-cell.done .writer-board { border-color: var(--jade); box-shadow: 7px 7px 0 #cfe1db; }
.word-cell-label { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.word-cell-label b { color: var(--ink); }

.card-stage { min-height: 600px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.learning-card { width: min(430px, 100%); min-height: 510px; display: flex; flex-direction: column; align-items: center; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.card-topline { width: 100%; display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 800; }
.card-state { padding: 4px 7px; color: #fff; background: var(--red); }
.card-state.known { background: var(--jade); }
.card-writer { width: min(300px, 78vw); aspect-ratio: 1; margin: 12px 0 4px; }
.card-answer { width: 100%; min-height: 95px; text-align: center; }
.card-answer h2, .card-answer p { margin: 0; }
.card-emoji { font-size: 25px; }
.card-reading { color: var(--red); font: 800 25px/1.35 Batang, serif; }
.card-example { margin-top: 6px !important; color: var(--ink-soft); }
.card-prompt { margin: auto 0 0; color: var(--muted); font-size: 13px; }
.card-actions { display: flex; justify-content: center; gap: 8px; width: min(650px, 100%); margin-top: 16px; }

.segmented { display: flex; align-items: stretch; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #e8eeeb; }
.segmented button { min-height: 38px; flex: 1; border: 0; border-radius: 4px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 800; cursor: pointer; }
.segmented button.active { color: #fff; background: var(--ink); }
#quiz-mode > .segmented { width: min(600px, 100%); margin: 16px auto 10px; }
.quiz-stats, .match-status { display: flex; justify-content: center; gap: 24px; margin: 11px auto; color: var(--muted); font-size: 13px; }
.quiz-stats b, .match-status b { color: var(--ink); }
.quiz-board { width: min(720px, 100%); min-height: 520px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; padding: 25px; border-top: 4px solid var(--red); background: #fff; box-shadow: var(--shadow); }
.quiz-instruction { margin: 0; color: var(--ink-soft); font-weight: 800; }
.quiz-prompt { min-height: 145px; display: grid; place-items: center; padding: 16px; color: var(--ink); font: 800 80px/1.25 Batang, "Noto Serif CJK KR", serif; text-align: center; overflow-wrap: anywhere; }
.quiz-context { min-height: 24px; margin: 0 0 15px; color: var(--red); font-size: 18px; font-weight: 800; }
.quiz-choices { width: min(580px, 100%); display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quiz-choices button { min-height: 58px; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: #f5f7f5; font-size: 20px; font-weight: 800; cursor: pointer; overflow-wrap: anywhere; }
.quiz-choices button.correct { color: #fff; border-color: var(--jade); background: var(--jade); }
.quiz-choices button.wrong { color: #fff; border-color: var(--red); background: var(--red); }
.quiz-feedback { width: min(580px, 100%); min-height: 44px; display: grid; place-items: center; margin-top: 14px; border-left: 4px solid var(--line); color: var(--muted); background: #f1f4f2; font-size: 13px; font-weight: 800; text-align: center; }

.match-status { margin-top: 18px; }
.match-instruction { width: min(720px, 100%); min-height: 44px; display: grid; place-items: center; margin: 10px auto 14px; border-left: 4px solid var(--gold); background: var(--gold-pale); color: #745111; font-size: 13px; font-weight: 800; text-align: center; }
.match-board { width: min(760px, 100%); display: grid; grid-template-columns: 1fr 1px 1fr; gap: 20px; margin: 0 auto; padding: 20px; background: #fff; box-shadow: var(--shadow); }
.match-column { display: grid; grid-template-rows: repeat(6, minmax(56px, auto)); gap: 9px; }
.match-divider { background: var(--line); }
.match-tile { min-width: 0; min-height: 56px; padding: 8px; border: 2px solid var(--line); border-radius: 5px; background: #f6f8f6; font-weight: 800; cursor: pointer; overflow-wrap: anywhere; }
.match-tile.character { font: 800 30px/1 Batang, serif; }
.match-tile.selected { border-color: var(--gold); background: var(--gold-pale); box-shadow: 0 0 0 2px #e3c475; }
.match-tile.matched { color: #fff; border-color: var(--jade); background: var(--jade); opacity: 0.68; }
.match-actions { display: flex; justify-content: center; margin-top: 16px; }

.progress-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px; margin: 18px 0; padding: 20px; color: #fff; background: var(--ink); }
.level-seal { width: 66px; height: 66px; display: grid; place-items: center; border: 2px solid #fff; background: var(--red); font: 800 31px/1 Batang, serif; }
.progress-hero p, .progress-hero h2, .progress-hero span { margin: 0; }
.progress-hero p { color: #bcd0c9; font-size: 12px; }
.progress-hero h2 { margin: 4px 0; font-size: 22px; }
.progress-hero span { color: #dce8e4; font-size: 12px; }
.daily-ring { width: 72px; height: 72px; display: flex; align-items: baseline; justify-content: center; border: 5px solid #d1a94f; border-radius: 50%; background: #fff; color: var(--ink); }
.daily-ring strong { font-size: 23px; }
.daily-ring span { color: var(--muted); }
.progress-section, .settings-section { margin-top: 16px; padding: 20px; border: 1px solid var(--line); background: #fff; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.section-title h2, .section-title p { margin: 0; }
.section-title h2 { font-size: 17px; }
.section-title p { color: var(--muted); font-size: 11px; }
.progress-list { display: grid; gap: 14px; }
.progress-row { display: grid; grid-template-columns: 125px minmax(100px, 1fr) 45px; align-items: center; gap: 12px; }
.progress-row > div:first-child { display: flex; justify-content: space-between; gap: 8px; }
.progress-row b, .progress-row span, .progress-row strong { font-size: 12px; }
.progress-row > div:first-child span { color: var(--muted); }
.progress-row > strong { text-align: right; }
.bar { height: 9px; overflow: hidden; background: #e4e9e6; }
.bar span { display: block; height: 100%; background: var(--jade); }
.bar.red span { background: var(--red); }
.bar.gold span { background: var(--gold); }
.bar.ink span { background: var(--ink); }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.week-day { min-width: 0; min-height: 83px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--line); background: #f5f7f5; }
.week-day span { color: var(--muted); font-size: 10px; }
.week-day b { margin: 4px 0; }
.week-day i { width: 23px; height: 23px; display: grid; place-items: center; border: 1px solid #bfc9c5; color: #a9b4b0; font: normal 13px/1 Batang, serif; }
.week-day.active i { border-color: var(--red); color: #fff; background: var(--red); }
.sticker-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.sticker { min-width: 0; min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1px dashed #c9d1cd; color: #9ca6a2; background: #f4f6f4; }
.sticker.earned { border: 1px solid #d9bb77; color: var(--ink); background: var(--gold-pale); }
.sticker span { font-size: 24px; }
.sticker b { max-width: 100%; font-size: 10px; text-align: center; overflow-wrap: anywhere; }
.progress-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }

.settings-section { width: min(760px, 100%); margin-right: auto; margin-left: auto; }
.setting-row { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid #e4e9e6; }
.setting-row > div, .setting-row label { display: flex; flex-direction: column; gap: 4px; }
.setting-row b, .setting-stack b { font-size: 14px; }
.setting-row span, .setting-stack span { color: var(--muted); font-size: 11px; }
.switch { position: relative; width: 50px; height: 28px; flex: 0 0 50px; border: 1px solid #bbc6c2; border-radius: 15px; background: #dce2df; cursor: pointer; }
.switch span { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24); transition: left 150ms ease; }
.switch.on { border-color: var(--jade); background: var(--jade); }
.switch.on span { left: 25px; }
.setting-stack { padding: 13px 0; border-top: 1px solid #e4e9e6; }
.setting-stack > div:first-child { display: flex; flex-direction: column; gap: 3px; margin-bottom: 9px; }
.settings-section .segmented { width: 100%; }
.voice-row select { min-width: 180px; max-width: 50%; min-height: 40px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.preview-voice { margin-top: 12px; }
.about-section dl, .about-section dl div { margin: 0; }
.about-section dl div { display: flex; justify-content: space-between; gap: 15px; padding: 9px 0; border-top: 1px solid #e4e9e6; }
.about-section dt { color: var(--muted); font-size: 12px; }
.about-section dd { font-size: 12px; font-weight: 800; text-align: right; }

.trace-reward-toast { position: fixed; z-index: 1200; top: calc(16px + var(--safe-top)); left: 50%; max-width: calc(100% - 32px); transform: translate(-50%, -24px); padding: 11px 16px; border: 1px solid #d0a64d; border-radius: 5px; color: var(--ink); background: var(--gold-pale); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity 170ms ease, transform 170ms ease; font-weight: 800; white-space: nowrap; }
.trace-reward-toast.show { opacity: 1; transform: translate(-50%, 0); }
.trt-points { margin-left: 8px; color: var(--red); }

@media (max-width: 760px) {
  .main-menu { padding: calc(15px + var(--safe-top)) calc(14px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(14px + var(--safe-left)); }
  .menu-header { align-items: center; }
  .brand-seal { width: 54px; height: 54px; flex-basis: 54px; font-size: 33px; box-shadow: 4px 4px 0 var(--gold); }
  .menu-header h1 { font-size: 25px; }
  .menu-tagline { font-size: 12px; }
  .network-state { display: none; }
  .mode-grid, .mode-grid-primary { grid-template-columns: 1fr; }
  .mode-card { min-height: 74px; grid-template-columns: 52px minmax(0, 1fr) 18px; }
  .mode-glyph { width: 50px; height: 50px; font-size: 30px; }
  .mode-grid:not(.mode-grid-primary) { grid-template-columns: repeat(3, 1fr); }
  .mode-card.compact { min-height: 112px; grid-template-columns: 1fr; grid-template-rows: 48px 1fr; justify-items: center; text-align: center; gap: 7px; padding: 10px 5px; }
  .mode-card.compact .mode-copy { align-items: center; }
  .menu-secondary { grid-template-columns: 1fr 1fr; }
  .review-link { grid-column: 1 / -1; }
  .quick-controls { justify-content: flex-start; overflow-x: auto; }

  .mode-ui { padding: calc(10px + var(--safe-top)) calc(12px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(12px + var(--safe-left)); }
  .mode-topbar { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .mode-topbar h1 { font-size: 18px; }
  .mode-topbar p { font-size: 10px; }
  .mode-live { min-width: 58px; padding: 6px; font-size: 10px; }
  .practice-layout { display: block; }
  .practice-info { min-height: 0; display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 8px 11px; padding: 10px 12px; border-left-width: 4px; }
  .practice-emoji { grid-row: 1 / 3; font-size: 27px; }
  .practice-glyph { grid-row: 1 / 3; margin: 0; font-size: 50px; }
  .practice-reading { margin: 0; font-size: 20px; }
  .practice-example { margin: 0; font-size: 13px; }
  .practice-role { grid-column: 1 / -1; margin: 2px 0; font-size: 11px; line-height: 1.4; }
  .practice-info .listen-button { grid-column: 4; grid-row: 1 / 3; width: 44px; padding: 0; font-size: 0; }
  .practice-info .listen-button svg { font-size: 17px; }
  .writing-tool { margin-top: 12px; }
  .writer-board { width: min(340px, 83vw); }
  .practice-feedback { margin-top: 11px; font-size: 12px; }
  .practice-actions { flex-wrap: wrap; gap: 6px; }
  .practice-actions .command { padding: 8px 10px; font-size: 11px; }

  .word-heading { grid-template-columns: auto minmax(0, 1fr) 44px; padding: 9px 10px; }
  .word-heading .listen-button { width: 44px; padding: 0; font-size: 0; }
  .word-heading .listen-button svg { font-size: 17px; }
  .word-title { font-size: 19px; }
  .word-writers { gap: 9px; }
  .word-writers .writer-board { width: 100%; }
  .word-cell-label { flex-direction: column; gap: 2px; }

  .card-stage { min-height: 0; padding-top: 4px; }
  .learning-card { min-height: 460px; padding: 14px; }
  .card-writer { width: min(270px, 72vw); }
  .card-actions { flex-wrap: wrap; }
  .card-actions .command { padding: 8px 10px; font-size: 11px; }

  .quiz-stats, .match-status { gap: 12px; font-size: 11px; }
  .quiz-board { min-height: 470px; padding: 17px 12px; }
  .quiz-prompt { min-height: 128px; font-size: 62px; }
  .quiz-choices button { min-height: 55px; font-size: 17px; }
  .match-board { gap: 9px; padding: 11px; }
  .match-tile { padding: 6px 3px; font-size: 12px; }
  .match-tile.character { font-size: 27px; }

  .progress-hero { gap: 10px; padding: 13px; }
  .level-seal { width: 50px; height: 50px; font-size: 25px; }
  .daily-ring { width: 58px; height: 58px; border-width: 4px; }
  .daily-ring strong { font-size: 19px; }
  .progress-section, .settings-section { padding: 14px 12px; }
  .section-title { align-items: flex-start; flex-direction: column; gap: 3px; }
  .progress-row { grid-template-columns: 95px minmax(75px, 1fr) 35px; gap: 7px; }
  .progress-row > div:first-child { flex-direction: column; gap: 2px; }
  .week-strip { gap: 3px; }
  .week-day { min-height: 70px; }
  .sticker-grid { grid-template-columns: repeat(3, 1fr); }
  .progress-actions { flex-direction: column; }
  .voice-row select { min-width: 130px; }
}

@media (max-width: 390px) {
  .sound-label { display: none; }
  .icon-control { width: 42px; justify-content: center; padding: 6px; }
  .practice-info { grid-template-columns: auto auto minmax(0, 1fr) 44px; }
  .practice-emoji { display: none; }
  .writer-board { width: min(300px, 80vw); }
  .quiz-choices { gap: 7px; }
  .quiz-choices button { font-size: 15px; }
  .segmented button { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
