/* Ganada — Learn Korean · design system */

:root {
  --bg: #f7f3ec;
  --surface: #ffffff;
  --surface-2: #fbf8f2;
  --ink: #221c15;
  --muted: #6f675c;
  --line: #e7dfd1;
  --accent: #c8402f;
  --accent-deep: #a8321f;
  --accent-soft: #fdeeea;
  --gold: #b98a2f;
  --navy: #2f4a6e;
  --ok: #2e7d4f;
  --ok-soft: #e9f5ee;
  --bad: #b3372b;
  --bad-soft: #fbeeec;
  --ko: 'Noto Sans KR', -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --ko-serif: 'Noto Serif KR', 'Noto Sans KR', serif;
  --shadow: 0 1px 2px rgba(34, 28, 21, 0.05), 0 10px 28px rgba(34, 28, 21, 0.06);
  --radius: 18px;
}
html[data-theme='dark'] {
  --bg: #171412;
  --surface: #211d1a;
  --surface-2: #282320;
  --ink: #f0e9df;
  --muted: #a49a8c;
  --line: #373029;
  --accent: #e0563f;
  --accent-deep: #c8402f;
  --accent-soft: #3a221d;
  --gold: #d3a54a;
  --navy: #8fb0dd;
  --ok: #5cbb82;
  --ok-soft: #1d2f25;
  --bad: #e0705f;
  --bad-soft: #37211d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.25);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #171412; --surface: #211d1a; --surface-2: #282320; --ink: #f0e9df; --muted: #a49a8c;
    --line: #373029; --accent: #e0563f; --accent-deep: #c8402f; --accent-soft: #3a221d; --gold: #d3a54a;
    --navy: #8fb0dd; --ok: #5cbb82; --ok-soft: #1d2f25; --bad: #e0705f; --bad-soft: #37211d;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--ko);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
img { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #c8402f;
  outline: 3px solid color-mix(in srgb, var(--accent) 75%, white);
  outline-offset: 3px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 12px; top: 8px; z-index: 200; padding: 9px 14px;
  border-radius: 10px; background: var(--ink); color: var(--bg); transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.view { max-width: 1060px; margin: 0 auto; padding: 22px 18px 70px; }

/* ── Top bar ─────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px;
  background: var(--accent); color: #fff; font-family: var(--ko-serif); font-weight: 900;
  font-size: 22px; border-radius: 12px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-ko { font-weight: 900; font-size: 17px; }
.brand-en { font-size: 11px; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }
.mainnav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.mainnav a {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; font-size: 14.5px;
  white-space: nowrap;
}
.nav-icon { font-size: 15px; line-height: 1; }
.nav-label { line-height: 1.2; }
.mainnav a:hover { background: var(--surface-2); color: var(--ink); }
.mainnav a.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 700; }
html[data-theme='dark'] .mainnav a.active { color: #f1a08f; }
.topchips { display: flex; gap: 8px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
}
.chip.hot { background: var(--accent-soft); border-color: transparent; color: var(--accent-deep); }
html[data-theme='dark'] .chip.hot { color: #f1a08f; }

/* ── Cards & layout ──────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px;
}
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 6px; font-size: 21px; }
.card h3 { margin: 18px 0 8px; font-size: 16px; }
.card p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.section-title { margin: 30px 0 12px; font-size: 24px; font-weight: 900; }
.section-sub { margin: -6px 0 14px; color: var(--muted); font-size: 14.5px; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent-deep);
}
html[data-theme='dark'] .badge { color: #f1a08f; }
.badge.blue { background: #e8eef7; color: #2f4a6e; }
html[data-theme='dark'] .badge.blue { background: #232c3a; color: #a9c3e8; }
.badge.gold { background: #f6eeda; color: #8a6417; }
html[data-theme='dark'] .badge.gold { background: #33290f; color: #d3a54a; }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.ko-display { font-family: var(--ko-serif); font-weight: 900; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 13px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: transform 0.05s ease, background 0.15s ease;
}
.btn:hover { background: var(--accent-deep); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.big { padding: 15px 28px; font-size: 17px; }
.btn.small { padding: 7px 14px; font-size: 13.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.speak-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-deep); border: none;
  font-size: 17px; cursor: pointer; flex: 0 0 auto;
}
html[data-theme='dark'] .speak-btn { color: #f1a08f; }
.speak-btn:hover { filter: brightness(0.96); }
.speak-btn.speaking { animation: pulse 1s ease infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* Progress bars */
.pbar { height: 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.pbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #e0703c); border-radius: 999px; transition: width 0.4s ease; }
.pbar.ok > i { background: linear-gradient(90deg, var(--ok), #55b37e); }

/* ── Home ────────────────────────────────── */
.hero { display: flex; gap: 22px; align-items: center; padding: 26px 26px 22px; position: relative; overflow: hidden; }
.hero::after {
  content: '한국어'; position: absolute; right: -10px; bottom: -26px;
  font-family: var(--ko-serif); font-weight: 900; font-size: 110px; opacity: 0.06;
  pointer-events: none;
}
.hero-ko { font-size: clamp(24px, 4vw, 34px); font-weight: 900; margin: 0; font-family: var(--ko-serif); }
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.today-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px dashed var(--line);
}
.today-item:first-of-type { border-top: none; padding-top: 4px; }
.today-num {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px;
  background: var(--surface-2); border: 1px solid var(--line); font-weight: 800; font-size: 18px; flex: 0 0 auto;
}
.today-body { flex: 1; min-width: 180px; }
.today-body b { font-size: 16px; }
.tip-card { border-left: 4px solid var(--gold); }
.phase-row { display: flex; align-items: center; gap: 14px; padding: 11px 0; border-top: 1px dashed var(--line); }
.phase-row:first-child { border-top: none; }
.phase-row .pbar { flex: 1; min-width: 120px; }
.phase-row .pname { width: 210px; font-weight: 600; font-size: 14.5px; }
.phase-row .pval { width: 64px; text-align: right; color: var(--muted); font-size: 13px; }

/* ── Course view ─────────────────────────── */
.phase-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 30px 0 10px; }
.phase-head h2 { margin: 0; font-size: 22px; }
.phase-blurb { color: var(--muted); font-size: 14px; margin: 0 0 14px; max-width: 720px; }
.unit-card { margin-bottom: 18px; }
.unit-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.unit-ko { font-family: var(--ko-serif); font-weight: 900; font-size: 19px; }
.lesson-row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 11px 12px; border-radius: 13px; border: 1px solid transparent;
  background: transparent; text-align: left; cursor: pointer; color: var(--ink); font-size: 15px;
}
.lesson-row:hover { background: var(--surface-2); border-color: var(--line); }
.lesson-row.locked { opacity: 0.5; cursor: not-allowed; }
.lesson-row .lnum {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--line); font-weight: 800; font-size: 13.5px; flex: 0 0 auto;
}
.lesson-row.done .lnum { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.lesson-row .lmain { flex: 1; min-width: 140px; }
.lesson-row .lko { color: var(--muted); font-size: 13px; }
.lesson-row .lmeta { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 12px; }

/* ── Roadmap ─────────────────────────────── */
.tl { position: relative; margin-left: 8px; padding-left: 28px; }
.tl::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); border-radius: 2px; }
.tl-item { position: relative; padding: 4px 0 26px; }
.tl-item::before {
  content: ''; position: absolute; left: -27.5px; top: 8px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--surface); border: 3px solid var(--line);
}
.tl-item.done::before { background: var(--ok); border-color: var(--ok-soft); }
.tl-item h3 { margin: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.check-list { list-style: none; margin: 8px 0 0; padding: 0; }
.check-list li { padding: 3px 0; display: flex; gap: 9px; align-items: baseline; font-size: 14.5px; }
.check-list li::before { content: '☐'; color: var(--muted); }
.check-list li.ok { color: var(--ok); font-weight: 600; }
.check-list li.ok::before { content: '☑'; }

/* ── Lesson player ───────────────────────── */
.lesson-shell { max-width: 760px; margin: 0 auto; }
.lesson-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.lesson-top .pbar { flex: 1; }
.lesson-top .exit {
  border: none; background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 15px;
}
.lesson-card { min-height: 300px; display: flex; flex-direction: column; }
.lesson-body { flex: 1; }
.lesson-foot { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.step-tag { font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-deep); }
html[data-theme='dark'] .step-tag { color: #f1a08f; }

.flash-ko { font-size: clamp(34px, 8vw, 56px); font-weight: 900; text-align: center; margin: 18px 0 4px; font-family: var(--ko-serif); }
.flash-ro { text-align: center; color: var(--muted); font-size: 16px; }
.flash-en { text-align: center; font-size: 19px; margin-top: 10px; }
.flip-hint { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 16px; }
.flashcard {
  display: block; width: 100%; padding: 0; border: 0; background: transparent;
  color: inherit; text-align: inherit; cursor: pointer;
}

.jumbo-char { font-size: clamp(90px, 20vw, 150px); font-weight: 900; text-align: center; margin: 6px 0; font-family: var(--ko-serif); line-height: 1.1; }
.char-sound { text-align: center; font-size: 22px; font-weight: 700; }
.char-tip { text-align: center; color: var(--muted); margin-top: 8px; }

.gram-point { font-size: 19px; font-weight: 800; margin: 2px 0 8px; }
.gram-ex { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px dashed var(--line); }
.gram-ex:first-of-type { border-top: none; }
.gram-ex .gk { font-weight: 700; font-size: 16.5px; }

/* Dialogue */
.dlg-line { display: flex; gap: 12px; padding: 10px 0; border-top: 1px dashed var(--line); align-items: flex-start; }
.dlg-line:first-child { border-top: none; }
.dlg-speaker {
  flex: 0 0 auto; width: 54px; text-align: center; padding: 3px 0; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; font-weight: 700;
}
.dlg-speaker.a { background: var(--accent-soft); border-color: transparent; color: var(--accent-deep); }
html[data-theme='dark'] .dlg-speaker.a { color: #f1a08f; }
.dlg-main {
  flex: 1; min-width: 0; padding: 0; border: 0; background: transparent;
  color: inherit; text-align: left; cursor: pointer;
}
.dlg-ko { font-weight: 600; font-size: 17px; }
.dlg-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.dlg-line.playing .dlg-ko { color: var(--accent-deep); }
html[data-theme='dark'] .dlg-line.playing .dlg-ko { color: #f1a08f; }

/* Drills */
.drill-q { font-size: 19px; font-weight: 700; margin: 6px 0 16px; }
.opts { display: grid; gap: 10px; }
.opt {
  padding: 13px 16px; border-radius: 13px; border: 1.5px solid var(--line);
  background: var(--surface); font-size: 16.5px; cursor: pointer; text-align: left;
  color: var(--ink); display: flex; align-items: center; gap: 10px; transition: border-color 0.12s;
}
.opt:hover { border-color: var(--accent); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); font-weight: 700; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt .okmark { margin-left: auto; font-weight: 800; }
.feedback { margin-top: 14px; padding: 12px 16px; border-radius: 12px; font-weight: 600; display: none; }
.feedback.show { display: block; }
.feedback.good { background: var(--ok-soft); color: var(--ok); }
.feedback.badf { background: var(--bad-soft); color: var(--bad); }
.feedback .fb-why { display: block; font-weight: 400; margin-top: 4px; color: var(--ink); font-size: 14px; }
.listen-prompt { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 10px 0 18px; }
.listen-prompt .speak-btn { width: 74px; height: 74px; font-size: 30px; }

/* arrange / word bank */
.bank { display: flex; flex-wrap: wrap; gap: 9px; margin: 8px 0 14px; min-height: 46px; padding: 8px; border: 1.5px dashed var(--line); border-radius: 12px; }
.bank.target { border-style: solid; background: var(--surface-2); min-height: 56px; }
.token {
  padding: 7px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  font-size: 16.5px; font-weight: 600; cursor: pointer;
}
.token:hover { border-color: var(--accent); }
.bank.target .token { background: var(--accent-soft); border-color: transparent; color: var(--accent-deep); }
html[data-theme='dark'] .bank.target .token { color: #f1a08f; }

/* typed answers */
.type-input {
  width: 100%; font-size: 22px; padding: 13px 16px; border-radius: 13px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font-family: var(--ko); font-weight: 600;
}
.type-input:focus { outline: none; border-color: var(--accent); }
.type-hint { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.ime-pad { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; }
.ime-row { display: flex; gap: 7px; justify-content: center; }
.ime-key {
  min-width: 40px; height: 42px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-size: 17px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.ime-key:hover { border-color: var(--accent); }
.ime-key.on { background: var(--accent-soft); border-color: var(--accent); }
.ime-wide { min-width: 52px; color: var(--muted); }
.ime-space { min-width: 120px; color: var(--muted); }

/* completion */
.done-face { font-size: 54px; text-align: center; margin: 8px 0; }
.done-stats { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.done-stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 18px; text-align: center; min-width: 100px; }
.done-stat b { display: block; font-size: 20px; }
.done-stat span { color: var(--muted); font-size: 12.5px; }

/* ── Review ──────────────────────────────── */
.review-shell { max-width: 720px; margin: 0 auto; }

/* ── Library ─────────────────────────────── */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-weight: 600; cursor: pointer; font-size: 14px;
}
.tab.active { background: var(--accent-soft); border-color: transparent; color: var(--accent-deep); }
html[data-theme='dark'] .tab.active { color: #f1a08f; }
.phrase-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px dashed var(--line); }
.phrase-row:first-child { border-top: none; }
.phrase-ko { font-weight: 700; font-size: 16.5px; min-width: 150px; }
.phrase-en { flex: 1; color: var(--muted); font-size: 14px; }
.phrase-ro { color: var(--muted); font-size: 12.5px; font-style: italic; }
.jamo-grid { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; }
.jamo-cell {
  width: 64px; height: 74px; border-radius: 13px; border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; background: var(--surface);
}
.jamo-cell b { font-size: 25px; font-family: var(--ko-serif); }
.jamo-cell span { font-size: 11px; color: var(--muted); }
.jamo-cell:hover { border-color: var(--accent); }

/* ── Handwriting practice ────────────────── */
.writing-slot { margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--line); }
.writing-pad {
  padding: 14px; border: 1px solid var(--line); border-radius: 17px;
  background: var(--surface-2);
}
.writing-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 11px; }
.writing-copy b { display: block; font-size: 15.5px; }
.writing-copy span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.writing-tools { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.writing-tool, .writing-quick-btn {
  min-height: 36px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.writing-tool[aria-pressed='true'] { color: var(--accent-deep); border-color: var(--accent); background: var(--accent-soft); }
html[data-theme='dark'] .writing-tool[aria-pressed='true'] { color: #f1a08f; }
.writing-tool:disabled { opacity: 0.4; cursor: default; }
.writing-stage {
  position: relative; width: 100%; min-height: 190px; overflow: hidden;
  border: 1.5px solid var(--line); border-radius: 15px; background: var(--surface);
  background-image: radial-gradient(circle at center, color-mix(in srgb, var(--accent-soft) 45%, transparent), transparent 62%);
}
.writing-canvas {
  position: absolute; inset: 0; z-index: 2; display: block; width: 100%; height: 100%;
  cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none;
}
.writing-target {
  position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden;
  color: color-mix(in srgb, var(--accent) 16%, transparent); font-family: var(--ko-serif);
  font-size: clamp(70px, 24vw, 138px); font-weight: 900; white-space: nowrap; pointer-events: none;
}
.writing-target[hidden] { display: none; }
.writing-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 9px; color: var(--muted); font-size: 12px; }
.writing-status { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.writing-studio { padding: 22px; }
.writing-studio-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 0.75fr); gap: 20px; align-items: end; }
.writing-studio-head h2 { margin-bottom: 2px; }
.writing-target-input label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.writing-target-input .row { flex-wrap: nowrap; }
.writing-target-input .type-input { min-width: 0; padding: 9px 12px; font-size: 17px; }
.writing-quick { display: flex; flex-wrap: wrap; gap: 7px; margin: 16px 0 12px; }
.writing-quick-btn { min-width: 43px; font-family: var(--ko); font-size: 15px; }
.writing-quick-btn:hover, .writing-tool:hover { border-color: var(--accent); }

/* ── Settings ────────────────────────────── */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.set-row:first-of-type { border-top: none; }
.set-label b { display: block; font-size: 15.5px; }
.set-label span { color: var(--muted); font-size: 13px; }
select, input[type='range'] { accent-color: var(--accent); }
select {
  padding: 9px 12px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 14px; max-width: 320px;
}
output { min-width: 42px; color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.switch { position: relative; width: 48px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 2; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background 0.15s;
}
.switch i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: left 0.15s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { left: 23px; }

/* ── Toast ───────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 22px; border-radius: 13px;
  font-size: 14.5px; font-weight: 600; z-index: 100; max-width: min(560px, 90vw);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); text-align: center;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 860px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .phase-row .pname { width: 100%; }
  .phase-row { flex-wrap: wrap; }
}
@media (max-width: 720px) {
  .topbar {
    gap: 10px; padding: 10px 12px; background: var(--surface);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .mainnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px;
    width: 100%; margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -8px 28px rgba(34, 28, 21, 0.08);
  }
  .mainnav a {
    position: relative; flex-direction: column; justify-content: center; gap: 3px;
    min-width: 0; min-height: 51px; padding: 5px 2px; border-radius: 12px;
    text-align: center;
  }
  .mainnav a.active::before {
    content: ''; position: absolute; top: -6px; left: 28%; right: 28%; height: 3px;
    border-radius: 0 0 3px 3px; background: var(--accent);
  }
  .nav-icon { font-size: 20px; }
  .nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 10.5px; font-weight: 700; }
  .topchips { margin-left: auto; }
  .view { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
  .hero { padding: 20px; }
  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }
  .lesson-card > .lesson-foot {
    position: sticky; bottom: calc(69px + env(safe-area-inset-bottom)); z-index: 8;
    margin: 20px -16px 0; padding: 12px 16px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
    backdrop-filter: blur(12px); box-shadow: 0 -10px 22px rgba(34, 28, 21, 0.06);
  }
  .writing-studio-head { grid-template-columns: 1fr; gap: 12px; }
  .ime-row { gap: 4px; width: 100%; }
  .ime-key { flex: 1 1 0; min-width: 0; height: 40px; padding: 0; }
  .ime-wide { flex-grow: 1.3; }
  .ime-space { flex-grow: 3; min-width: 0; }
}
@media (max-width: 540px) {
  .card { padding: 18px 16px; }
  .today-item { flex-wrap: wrap; align-items: flex-start; }
  .today-body { min-width: 0; flex-basis: calc(100% - 56px); }
  .today-item > .btn { flex: 1 1 auto; margin-left: 56px; }
  .phrase-row { align-items: flex-start; flex-wrap: wrap; }
  .phrase-ko { min-width: 0; flex: 1; }
  .phrase-en { flex-basis: calc(100% - 52px); margin-left: 52px; }
  .phrase-row > .badge { margin-left: 52px; }
  .lesson-foot .btn.big { flex: 1 1 180px; }
  .writing-head { flex-direction: column; }
  .writing-tools { width: 100%; justify-content: stretch; }
  .writing-tool { flex: 1; min-height: 42px; }
  .writing-pad { padding: 11px; }
  .writing-meta { align-items: flex-start; }
  .writing-target-input .btn { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
