:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --text: #1d1d1b;
  --muted: #6b6860;
  --line: #e2ddd2;
  --accent: #c8102e;
  --accent-soft: #fbe9ec;
  --ok: #1a7f37;
  --ok-soft: #e6f4ea;
  --bad: #c8102e;
  --bad-soft: #fbe9ec;
  --warn-bg: #fff6e0;
  --warn-line: #e8c46a;
  --tip-bg: #eaf3fb;
  --tip-line: #9cc3e6;
  --t-ngang: #57606a;
  --t-huyen: #1f6feb;
  --t-sac: #d1242f;
  --t-hoi: #1a7f37;
  --t-nga: #8250df;
  --t-nang: #9a6700;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px rgba(0, 0, 0, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614;
    --surface: #211f1c;
    --surface-2: #2a2824;
    --text: #ecebe6;
    --muted: #a19d93;
    --line: #38352f;
    --accent: #ff6b7d;
    --accent-soft: #3a2026;
    --ok: #3fb950;
    --ok-soft: #1c3322;
    --bad: #ff7b72;
    --bad-soft: #3a2026;
    --warn-bg: #2e2716;
    --warn-line: #6b5520;
    --tip-bg: #18263a;
    --tip-line: #2d4d73;
    --t-ngang: #a3aab3;
    --t-huyen: #58a6ff;
    --t-sac: #ff7b72;
    --t-hoi: #56d364;
    --t-nga: #c297ff;
    --t-nang: #e3b341;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- 상단 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { text-decoration: none; display: flex; align-items: baseline; gap: 10px; }
.brand-vi { font-weight: 800; font-size: 1.15rem; color: var(--accent); letter-spacing: -.01em; }
.brand-ko { font-size: .85rem; color: var(--muted); }
.nav-link { text-decoration: none; font-size: .9rem; color: var(--muted); padding: 6px 10px; border-radius: 8px; }
.nav-link:hover { background: var(--surface-2); }
.lang-btn { flex: none; margin-left: 8px; text-decoration: none; font-size: .82rem; font-weight: 700; color: var(--accent); border: 1.5px solid var(--accent); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.lang-btn:hover { background: var(--accent-soft); }

#app { max-width: 780px; margin: 0 auto; padding: 20px 16px 80px; }

h1 { font-size: 1.6rem; line-height: 1.3; margin: .2em 0 .1em; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.muted { color: var(--muted); }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.warn-btn { background: var(--warn-bg); border-color: var(--warn-line); }

/* ---------- 홈 ---------- */
.hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); margin-bottom: 24px;
}
.hero h1 { font-size: 1.9rem; }
.hero .bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 14px 0 6px; }
.hero .bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.hero .actions { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }

.level { margin-bottom: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.level-head { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.level-num {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; background: var(--accent-soft); color: var(--accent);
}
.level.locked .level-num { background: var(--surface-2); color: var(--muted); }
.level-title { font-weight: 700; }
.level-sub { font-size: .85rem; color: var(--muted); }
.level-tag { margin-left: auto; font-size: .75rem; color: var(--muted); white-space: nowrap; }
.lesson-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.lesson-list a {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.lesson-list li:last-child a { border-bottom: 0; }
.lesson-list a:hover { background: var(--surface-2); }
.lesson-id { font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--muted); width: 2.4em; }
.lesson-name { flex: 1; }
.lesson-name small { display: block; color: var(--muted); font-size: .8rem; }
.check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: .75rem; }
.check.done { background: var(--ok); border-color: var(--ok); color: #fff; }

.guide-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); margin-bottom: 28px; }
.guide-tile {
  display: flex; flex-direction: column; gap: 2px; padding: 16px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.guide-tile:hover { border-color: var(--accent); }
.guide-tile small { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.guide-tile.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.guide-icon { font-size: 1.6rem; line-height: 1.2; }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 8px; }
.steps > li {
  counter-increment: step; position: relative; padding: 12px 14px 12px 52px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.steps > li ul { margin: .3em 0; padding-left: 1.2em; }
.steps > li::before {
  content: counter(step); position: absolute; left: 14px; top: 12px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: #fff; font-size: .8rem; font-weight: 700;
}
.steps li > div { margin-top: 2px; color: var(--text); }
.steps li p { margin: .3em 0; }
.places { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.place { display: flex; flex-direction: column; gap: 6px; }
.place p { margin: 0; }
.place .btn { align-self: flex-start; margin-top: auto; }
.place-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.place-head > b { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.place-meta .chip { flex: 0 1 auto; max-width: 100%; }
.place-addr { font-size: .85rem; color: var(--muted); }
.place-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .78rem; }
.fresh { font-size: .74rem; font-weight: 700; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.fresh-new { color: var(--ok); background: var(--ok-soft); }
.fresh-mid { color: var(--muted); background: var(--line); }
.fresh-old { color: var(--bad); background: var(--bad-soft); }
.rating { font-weight: 700; }
.rating-mich { color: var(--bad); background: var(--bad-soft); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.place .review { font-size: .88rem; background: var(--accent-soft); border-radius: 8px; padding: 6px 8px; }
.place-old { border-color: var(--bad); border-style: dashed; }
.state-line { font-size: .86rem; border-radius: 8px; padding: 6px 8px; margin: 4px 0; }
.state-line.st-live { color: var(--bad); background: var(--bad-soft); }
.state-line.st-warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.state-line.st-gone, .state-line.st-unknown { color: var(--muted, #666); background: var(--line, #eee); }
.delivery { font-size: .85rem; }
.incident { font-size: .86rem; color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 6px 8px; }
.incident a { color: inherit; }
.list-row { gap: 4px; }
.list-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.fresh-legend { font-size: .8rem; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { flex: none; font-size: .72rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 8px; }
.related { display: flex; flex-wrap: wrap; gap: 8px; }
.sources { margin-top: 32px; font-size: .88rem; }
.sources summary { cursor: pointer; color: var(--muted); }
.sources a { color: var(--t-huyen); }
.safety-cat { scroll-margin-top: 70px; }
.safety-cat h3 { font-size: 1rem; margin: 0; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checklist li {
  position: relative; padding: 12px 14px 12px 40px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px;
}
.checklist li::before { content: "✔"; position: absolute; left: 14px; top: 12px; color: var(--ok); font-weight: 700; }

/* ---------- 성조 ---------- */
.t-ngang { color: var(--t-ngang); }
.t-huyen { color: var(--t-huyen); }
.t-sac { color: var(--t-sac); }
.t-hoi { color: var(--t-hoi); }
.t-nga { color: var(--t-nga); }
.t-nang { color: var(--t-nang); }
body.no-colors [class^="t-"] { color: inherit; }

.tone-strip { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 24px; }
.tone-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: .85rem;
}
.tone-chip b { font-size: 1rem; }
.tone-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.tone-table td, .tone-table th { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.tone-table tr:last-child td { border-bottom: 0; }
.tone-table th { font-size: .8rem; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.tone-table .ex { font-size: 1.4rem; font-weight: 700; }
.tone-table .shape { font-size: 1.2rem; font-weight: 700; }
.table-wrap { overflow-x: auto; }

/* ---------- 레슨 ---------- */
.crumb { font-size: .85rem; color: var(--muted); text-decoration: none; }
.crumb:hover { color: var(--text); }
.vi-title { font-size: 1.05rem; color: var(--muted); margin: 0; }
.goal { margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: .95rem; }
.goal b { color: var(--accent); }

.sec { margin: 32px 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.sec-head h2 { margin: 0; }
.sec-head .tools { display: flex; gap: 6px; }
.prose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.prose p { margin: .5em 0; }
.prose ul { margin: .5em 0; padding-left: 1.2em; }
.prose li { margin: .3em 0; }
.sec-tip .prose { background: var(--tip-bg); border-color: var(--tip-line); }
.sec-warn .prose { background: var(--warn-bg); border-color: var(--warn-line); }
.sec-warn h2::before { content: "⚠️ "; }
.sec-tip h2::before { content: "💡 "; }
.scene { color: var(--muted); font-size: .92rem; margin: -4px 0 14px; }

.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); }
.grid .vi { font-size: 1.3rem; }
.list { display: grid; gap: 10px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s;
}
.card.playing { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card.your-turn { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.card.your-turn::after { content: "🗣 따라 말해보세요"; display: block; margin-top: 8px; font-size: .85rem; font-weight: 700; color: var(--ok); }

.vi-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.vi { font-size: 1.45rem; font-weight: 700; line-height: 1.35; letter-spacing: -.01em; }
.list .vi { font-size: 1.3rem; }
.meta { margin: 8px 0 0; display: grid; gap: 2px; }
.meta > div { display: flex; gap: 8px; align-items: baseline; }
.meta dt {
  flex: none; width: 2.6em; text-align: center; font-size: .7rem; font-weight: 700;
  color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 2px; line-height: 1.6;
}
.meta dd { margin: 0; }
.pr-text { color: var(--accent); font-weight: 600; }
.en-line { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.en-pr { display: block; color: var(--t-huyen); font-size: .9rem; }
.hint { display: none; }
.masked { cursor: pointer; }
.masked .real { display: none; }
.masked .hint { display: inline-block; color: var(--muted); font-size: .8rem; font-weight: 400; background: var(--surface-2); border-radius: 6px; padding: 0 8px; }
.note { margin: 8px 0 0; font-size: .85rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; }

.play-btns { display: flex; gap: 4px; flex: none; align-items: center; }
.btn-play, .btn-slow {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px;
  height: 34px; display: inline-flex; align-items: center; justify-content: center;
}
.btn-play { width: 34px; padding: 0; }
.btn-play svg { width: 18px; height: 18px; }
.btn-slow { padding: 0 10px; font-size: .75rem; font-weight: 600; }
.btn-play.small { width: 26px; height: 26px; }
.btn-play.small svg { width: 14px; height: 14px; }
.btn-slow.small { height: 26px; padding: 0 8px; font-size: .7rem; }
.btn-play:hover, .btn-slow:hover { border-color: var(--accent); color: var(--accent); }
.badge-south { font-size: .65rem; font-weight: 700; color: var(--ok); border: 1px solid var(--ok); border-radius: 6px; padding: 0 4px; }
.noaudio { font-size: .7rem; color: var(--muted); white-space: nowrap; }

/* 대화 */
.dialogue { display: grid; gap: 10px; }
.dialogue .card { max-width: 88%; }
.dialogue .card.right { justify-self: end; background: var(--surface-2); }
.speaker { font-size: .75rem; font-weight: 700; color: var(--muted); margin-bottom: 2px; }

.lesson-end {
  margin-top: 40px; padding: 24px; text-align: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.lesson-end .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

/* ---------- 퀴즈 ---------- */
.quiz-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.quiz-progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 24px; }
.quiz-progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 20px; text-align: center; }
.q-prompt { color: var(--muted); font-size: .95rem; }
.q-big-play {
  width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  display: inline-grid; place-items: center; margin: 16px 0 8px;
}
.q-big-play svg { width: 38px; height: 38px; }
.q-reveal { min-height: 3.2em; margin: 8px 0; }
.q-reveal .vi { font-size: 1.8rem; }
.options { display: grid; gap: 8px; margin-top: 18px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.options.tone-opts { grid-template-columns: repeat(3, 1fr); }
.opt {
  padding: 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface);
  font-weight: 600; text-align: center;
}
.opt:hover:not(:disabled) { border-color: var(--muted); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.opt .shape { display: block; font-size: 1.4rem; }
.opt small { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); }
.q-next { margin-top: 18px; }
.result { text-align: center; padding: 32px 20px; }
.result .score { font-size: 3rem; font-weight: 800; }

/* ---------- 설정 ---------- */
.setting { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 14px; }
.setting h2 { font-size: 1rem; margin-bottom: 4px; }
.setting p { margin: 0 0 10px; font-size: .88rem; color: var(--muted); }
.setting label { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.setting label small { color: var(--muted); display: block; }

/* ---------- 즐겨찾기 ---------- */
.card-btns { display: flex; gap: 4px; align-items: center; flex: none; }
.btn-fav {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  width: 34px; height: 34px; padding: 0; font-size: 1.05rem; line-height: 1; color: var(--muted); flex: none;
}
.btn-fav:hover { border-color: #e3a400; color: #e3a400; }
.btn-fav.on { color: #e3a400; border-color: #e3a400; background: color-mix(in srgb, #e3a400 12%, var(--surface)); }
.place-tags { display: flex; gap: 6px; align-items: center; flex: none; }
.checklist li .btn-fav, .steps > li .btn-fav { float: right; margin: -4px -4px 4px 8px; width: 30px; height: 30px; font-size: .95rem; }
.fav-wrap { display: grid; gap: 4px; }
.src-link { font-size: .8rem; color: var(--muted); text-decoration: none; padding-left: 4px; }
.checklist .src-link { display: block; margin-top: 4px; padding-left: 0; }
.src-link:hover { color: var(--accent); }
.chip-on { background: var(--text); color: var(--bg); border-color: var(--text); }
a.tone-chip { text-decoration: none; }
.empty p { margin: .4em 0; }

/* ---------- 오프라인 저장 ---------- */
.howto { margin: .4em 0; padding-left: 1.3em; }
.howto li { margin: .35em 0; }
.howto code, .setting code { background: var(--surface-2); border-radius: 6px; padding: 1px 6px; font-size: .88em; word-break: break-all; }
.offline-status { font-weight: 600; }
.offline-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0 12px; }
.offline-bar > i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .2s; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px);
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-size: .9rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}

.disclaimer { font-size: .8rem; margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- 복습 ---------- */
.review-today { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.big-num { font-size: 2.6rem; font-weight: 800; line-height: 1; color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.35rem; }
.stat span { font-size: .8rem; color: var(--muted); line-height: 1.3; display: block; }
.week-chart { display: flex; gap: 6px; height: 130px; align-items: flex-end; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.day-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.day-col i { display: block; width: 70%; max-width: 34px; min-height: 2px; background: var(--line); border-radius: 6px 6px 2px 2px; }
.day-col.today i { background: var(--accent); }
.day-n { font-size: .72rem; color: var(--muted); }
.day-label { font-size: .75rem; color: var(--muted); }
.day-col.today .day-label { color: var(--accent); font-weight: 700; }
.lv-rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 16px; }
.lv-row { display: grid; grid-template-columns: minmax(0, 11em) 1fr 3em; align-items: center; gap: 10px; padding: 8px 0; font-size: .9rem; }
.lv-row small { display: block; }
.lv-row .bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.lv-row .bar > i { display: block; height: 100%; background: var(--ok); }
.lv-row b { text-align: right; }
.btn.wide { min-width: 60%; justify-content: center; }
.flash { position: relative; }
.flash > .chip { position: absolute; top: 12px; left: 12px; }
.flash-ko { font-size: 1.5rem; font-weight: 700; margin: 18px 0 6px; }
.flash-back { text-align: left; margin: 12px 0 6px; }
.flash .src-link { display: block; text-align: left; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 16px; }
.grade { padding: 12px 4px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; }
.grade small { display: block; font-weight: 400; font-size: .75rem; color: var(--muted); margin-top: 2px; }
.grade-again { border-color: var(--bad); color: var(--bad); }
.grade-hard { border-color: #d4a017; }
.grade-good { border-color: var(--ok); color: var(--ok); }
.grade-easy { border-color: var(--t-huyen); color: var(--t-huyen); }
.tone-strip.center { justify-content: center; }
.dict-form { margin-top: 14px; }
.dict-input {
  width: 100%; font: inherit; font-size: 1.25rem; padding: 12px 14px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--surface); color: var(--text); text-align: center;
}
.dict-input:focus { outline: none; border-color: var(--accent); }
.dict-btns { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.dict-btns .btn { flex: 1; max-width: 12em; justify-content: center; }
.dict-verdict { margin-top: 16px; font-weight: 700; }
.dict-verdict.ok { color: var(--ok); }
.dict-verdict.tone { color: #b7791f; }
.dict-verdict.miss { color: var(--bad); }
.dict-answer { font-size: 1.5rem; margin: 8px 0 2px; }
.num-input { display: flex; align-items: center; gap: 6px; max-width: 16em; margin: 0 auto; }
.num-input .dict-input { flex: 1; min-width: 0; font-size: 1.5rem; }
.num-input span { font-size: 1.25rem; }
.num-best { font-size: .75rem; color: var(--ok); margin-left: 4px; }
.num-opts .opt { font-size: 1.1rem; }
.w-ok { color: var(--ok); }
.w-tone { color: #b7791f; text-decoration: underline wavy; text-underline-offset: 4px; }
.w-miss { color: var(--bad); text-decoration: line-through; }
.dict-legend { font-size: .78rem; display: flex; gap: 12px; justify-content: center; }
.dict-legend .w-miss { text-decoration: none; }

/* ---------- 아래 탭 바 (모바일) ---------- */
.tabbar { display: none; }

@media (max-width: 720px) {
  .topnav { display: none; }
  #app { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(6, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
    text-decoration: none; font-size: .72rem; color: var(--muted); border-radius: 10px;
  }
  .tabbar a.active { color: var(--accent); font-weight: 700; }
  .tab-icon { font-size: 1.25rem; line-height: 1; }
  .topbar { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  h1 { font-size: 1.4rem; }
  .sec { margin: 26px 0; }
  .prose { padding: 14px 16px; }
}

/* 손가락으로 누르기 쉽게: 터치 화면에서는 버튼을 키운다 */
@media (pointer: coarse) {
  .btn-play, .btn-fav { width: 42px; height: 42px; }
  .btn-slow { height: 42px; padding: 0 12px; }
  .btn-play.small { width: 34px; height: 34px; }
  .btn-slow.small { height: 34px; }
  .btn.small { padding: 9px 14px; }
  .checklist li .btn-fav, .steps > li .btn-fav { width: 38px; height: 38px; }
  .btn-play svg { width: 20px; height: 20px; }
}

@media (max-width: 480px) {
  #app { padding-left: 12px; padding-right: 12px; }
  .brand-ko { display: none; }
  .vi-row { flex-wrap: wrap; }
  .card-btns { margin-left: auto; }
  .card { padding: 12px 14px; }
  .sec-head .tools { width: 100%; }
  .sec-head .tools .btn { flex: 1; }
  .lesson-list a { padding: 12px 14px; }
  .guide-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .guide-tile { padding: 12px; }
  .guide-tile small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .level-head { padding: 12px 14px; }
  .hero { padding: 18px; }
  .dialogue .card { max-width: 100%; }
  .options.tone-opts { grid-template-columns: repeat(2, 1fr); }
  .vi { font-size: 1.3rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grades { grid-template-columns: repeat(2, 1fr); }
  .lv-row { grid-template-columns: minmax(0, 8em) 1fr 2.6em; }
}
.filter-label { font-size: .85rem; margin: 14px 0 0; color: var(--muted); }
.filter-label + .tone-strip { margin-top: 6px; margin-bottom: 4px; }

/* ---------- 식당: 메뉴·가격·이용자 후기 ---------- */
.eat-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.menu-chips { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; }
.menu-chips > .tone-chip { align-self: flex-start; }
.menu-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.menu-row-title { font-size: .78rem; font-weight: 700; color: var(--muted); min-width: 5.6em; }
.tone-chip small { color: var(--muted); font-size: .75rem; }
.chip-on small { color: inherit; opacity: .75; }
.small-note { font-size: .78rem; margin: -10px 0 0; }
.price { font-size: .74rem; white-space: nowrap; }
.comm { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: .84rem; }
.comm-link { margin-left: auto; font-weight: 700; color: var(--accent); text-decoration: none; white-space: nowrap; }
.comm-warn { color: #9a6700; background: var(--warn-bg); border-radius: 8px; padding: 2px 8px; font-size: .8rem; }
.comm-closed { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 2px 8px; font-size: .8rem; font-weight: 700; }
.comm-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.comm-form { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.comm-form form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.comm-form summary { cursor: pointer; }
.comm-form input, .comm-form textarea, .comm-form select {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text);
}
.comm-form .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stars { display: flex; gap: 2px; }
.star { font-size: 2rem; line-height: 1; background: none; border: 0; padding: 2px 4px; cursor: pointer; color: var(--line); }
.star.on { color: #e3a008; }
.stars-view { color: #e3a008; letter-spacing: 1px; }
.review-item { display: flex; flex-direction: column; gap: 4px; }
.review-item p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.review-item .btn { align-self: flex-start; }
.review-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.review-head small { margin-left: auto; }
.link-btn { align-self: flex-start; background: none; border: 0; padding: 0; font: inherit; font-size: .8rem; color: var(--muted); cursor: pointer; text-decoration: underline; }

/* ---------- 오늘 뭐 먹지 ---------- */
.pick-settings { margin: 0 0 16px; }
.pick-settings summary { cursor: pointer; font-size: .92rem; }
.pick-settings .tone-strip { margin: 10px 0 0; }
.roulette { font-size: 4.2rem; line-height: 1.1; min-height: 1.6em; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.roulette small { font-size: 1rem; font-weight: 700; }
.pick-big { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 0 6px; }
.pick-big b { font-size: 1.6rem; }
.pick-emo { font-size: 3.6rem; line-height: 1.1; display: block; }
.pick-others { justify-content: center; margin: 8px 0 4px; }
.pick-result h3 { margin: 22px 0 10px; font-size: 1.02rem; }
.pick-again, .pick-result > .actions { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.cup { display: flex; align-items: stretch; gap: 10px; margin-top: 18px; }
.cup-opt { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px; font-weight: 700; }
.cup-vs { align-self: center; font-weight: 800; color: var(--accent); }
.pick-log { padding-left: 1.2em; font-size: .9rem; }
.pick-game .q-card h2 { margin: 6px 0 0; }

/* 내 위치에서 가까운 순 · 영업시간 */
.dist { font-size: 0.8rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.chip-near { font-weight: 700; }
.hours { font-size: 0.85rem; margin: 2px 0; }
.hours.is-open b { color: var(--ok); }
.hours.is-closed { color: var(--muted); }
.hours-week { font-size: 0.85rem; margin: 2px 0 6px; }
.hours-week summary { cursor: pointer; color: var(--muted); }
.hours-week div { display: flex; gap: 8px; padding: 1px 0; }
.hours-week b { min-width: 1.5em; }
.eat-search { width: 100%; box-sizing: border-box; margin: 10px 0 2px; padding: 10px 12px; font-size: 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.bk-btn { margin-left: 6px; padding: 2px 8px; }

/* 생활 가이드: 대분류 → 가이드 → 알아두기·장소·문장 */
.quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0 6px; }
.quick > span { font-size: .82rem; margin-right: 2px; }
.cat-nav { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 6px 0; margin: 4px 0 8px; }
.cat { margin: 18px 0 8px; scroll-margin-top: 56px; }
.cat-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 8px; }
.cat-head h2 { margin: 0; font-size: 1.15rem; }
.cat-head small { font-size: .82rem; }
.cat-icon { font-size: 1.3rem; }
.guide-grid.compact { grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 8px; margin-bottom: 8px; }
.guide-grid.compact .guide-tile { padding: 12px; }
.guide-grid.compact .guide-tile small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.guide-grid.compact .guide-icon { font-size: 1.3rem; }
.guide-tile.tile-main { border-color: var(--accent); background: var(--accent-soft); }
.cat-more { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .85rem; }
.cat-more .tone-chip { text-decoration: none; }
.hits { display: grid; gap: 6px; }
.hit { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.hit small { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.toc { display: grid; gap: 4px; margin: 10px 0; }
.toc-row { display: flex; flex-direction: column; gap: 2px; }
.toc-label { font-size: .78rem; font-weight: 700; color: var(--muted); }
.toc-row .tone-strip { margin: 0; }
.guide-actions { margin: 6px 0 4px; }
.sec { scroll-margin-top: 12px; }
.sec.flash { animation: flash 1.6s ease-out; border-radius: 10px; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }

/* 가게 화면: 영업 상태·폐업 신고 */
.status-box { border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; font-size: .88rem; line-height: 1.5; border: 1px solid var(--line); }
.status-box.ok { background: var(--ok-soft); border-color: transparent; }
.status-box.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.status-box.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.comm-help { font-size: .85rem; color: var(--muted); margin: 0 0 8px; }
.comm-links { margin-left: auto; display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }
.comm-links .comm-link { margin-left: 0; }
.comm-link-sub { color: var(--muted); font-weight: 600; }
.closure-steps { font-size: .82rem; color: var(--muted); margin: 0; }
#closure-box { scroll-margin-top: 20px; }
[data-guide-home] > .small-note { margin: 16px 0 0; }

/* ---------- 상황별 플랜 ---------- */
.plans { display: grid; gap: 12px; }
.plan-steps { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.plan-steps li { display: grid; grid-template-columns: 3.6em 1fr; gap: 8px; align-items: start; border-left: 3px solid var(--accent-soft); padding-left: 8px; }
.plan-time { font-weight: 700; color: var(--accent); font-size: .85rem; padding-top: 2px; }
.plan-tips { margin: 6px 0 0; padding-left: 1.2em; font-size: .86rem; color: var(--muted); }
.plan .plan-like { align-self: flex-start; margin-top: 8px; }
.popular-plans { margin: 12px 0; }
.popular-plans .small-note { display: inline-block; margin-top: 6px; }
.plan-teaser { margin: 12px 0; background: var(--accent-soft); }

/* 🧰 도구: 환율 계산기 · 번역기 */
.tool-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); margin: 12px 0 24px; }
.tool-card {
  display: flex; flex-direction: column; gap: 4px; padding: 18px; text-decoration: none;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow);
}
.tool-card b { font-size: 1.15rem; }
.tool-card small { color: var(--muted); font-size: .85rem; line-height: 1.45; }
.tool-icon { font-size: 2rem; line-height: 1.1; }
.rate-status { margin: 0 0 8px; font-size: .86rem; }
.rate-ins { display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 10px 0 6px; }
.rate-in { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.rate-in input, .rate-manual input, .tr-input {
  width: 100%; box-sizing: border-box; padding: 10px; font-size: 1.05rem; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text);
}
.rate-in input:focus, .tr-input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.rate-quick { margin: 4px 0 10px; }
.rate-result { padding: 16px; display: grid; gap: 6px; }
.rate-big { font-size: 1.35rem; line-height: 1.4; overflow-wrap: anywhere; }
.rate-big b { color: var(--accent); }
.rate-read { font-size: .92rem; overflow-wrap: anywhere; }
.vi-read { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--text); }
.rate-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.rate-table th, .rate-table td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.rate-table th { font-weight: 600; color: var(--muted); }
.rate-result .small-note, .sec .small-note, .tr-google-box .small-note, .tr-form .small-note { margin: 6px 0 0; }
.rate-manual { display: grid; gap: 8px; margin-top: 10px; }
.rate-manual label { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.rate-manual input { width: 9em; padding: 8px; font-size: 1rem; }
.rate-manual .actions, .tr-btns, .tr-own .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tr-form { margin: 10px 0 14px; display: grid; gap: 8px; }
.tr-input { resize: vertical; min-height: 3.2em; line-height: 1.45; }
.tr-own { padding: 14px 16px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.tr-own > b { display: block; font-size: 1.3rem; margin-bottom: 8px; overflow-wrap: anywhere; }
.tr-google-box { padding: 14px 16px; margin-bottom: 18px; background: var(--tip-bg); border: 1px solid var(--tip-line); border-radius: var(--radius); }
.tr-google { display: inline-block; margin-top: 8px; text-decoration: none; }
.tr-card-act { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.tr-big {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 18px; padding: 24px; background: var(--surface); text-align: center; cursor: pointer;
}
.tr-big-text { font-size: clamp(2rem, 9vw, 4.2rem); font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.tr-big-sub { font-size: 1.1rem; color: var(--muted); }
.tr-big-close { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); font-size: .85rem; color: var(--muted); }
@media (max-width: 720px) {
  .tabbar a { font-size: .68rem; }
  .rate-ins { grid-template-columns: 1fr 1fr; }
  .rate-ins label:first-child { grid-column: 1 / -1; }
}

/* 🧰 도구 2단계: 더치페이 · 메뉴판 · 대화판 */
.split-row { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; }
.split-n { min-width: 3em; text-align: center; font-size: 1.15rem; }
.split-each { font-size: 1.1rem; margin-top: 4px; }
.split-own { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); margin: 8px 0; }
.split-own .small-note { grid-column: 1 / -1; margin: 0; }
.split-table td, .split-table th { white-space: nowrap; }
.warn-text { color: var(--bad); }
.tip-list { margin: 0; padding-left: 1.1em; display: grid; gap: 8px; font-size: .92rem; }
.menu-parse { padding: 14px; display: grid; gap: 10px; margin-top: 8px; }
.menu-line { font-size: 1.05rem; line-height: 1.6; overflow-wrap: anywhere; }
.mw-parts, .mw-list { display: flex; flex-wrap: wrap; gap: 8px; }
.mw-part { display: flex; flex-direction: column; gap: 2px; max-width: 100%; }
.mw {
  display: inline-grid; grid-template-columns: 1fr auto; column-gap: 8px; align-items: center; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; max-width: 100%; box-sizing: border-box;
}
.mw > :not(.btn-play) { grid-column: 1; }
.mw .btn-play { grid-column: 2; grid-row: 1 / span 4; }
.mw.unknown { border-style: dashed; }
.mw-vi { font-size: 1.05rem; overflow-wrap: anywhere; }
.mw-pr { color: var(--accent); font-size: .78rem; }
.mw-ko { font-size: .9rem; }
.mw.playing { border-color: var(--accent); }
.menu-ex { margin-top: 10px; }
.talk-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.talk { display: grid; gap: 12px; }
.talk-them { padding: 14px; border: 2px solid var(--accent); border-radius: var(--radius); background: var(--accent-soft); display: grid; gap: 10px; }
.talk-them.flip { transform: rotate(180deg); }
.talk-intro { font-size: .95rem; line-height: 1.5; }
.talk-me-said { font-size: clamp(1.4rem, 6vw, 2.2rem); font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.talk-answers { display: flex; flex-wrap: wrap; gap: 8px; }
.talk-answers.common { padding-top: 8px; border-top: 1px dashed var(--line); }
.talk-ans, .talk-q {
  padding: 10px 12px; font-size: 1rem; font-family: inherit; color: var(--text); text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; max-width: 100%;
}
.talk-ans.on, .talk-q.on { border-color: var(--accent); outline: 2px solid var(--accent); }
.talk-me { display: grid; gap: 10px; }
.talk-said { display: grid; gap: 4px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.talk-said b { overflow-wrap: anywhere; }
.talk-ko { font-size: 1.35rem; font-weight: 700; overflow-wrap: anywhere; }
.talk-wait { margin: 0; }
.talk-h { font-size: 1rem; margin: 6px 0 0; }
.talk-mine { display: flex; flex-wrap: wrap; gap: 8px; }
.talk-pad { display: grid; gap: 10px; }
.talk-pad-show { text-align: center; font-size: 1rem; }
.talk-pad-show b { font-size: 1.8rem; }
.talk-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.talk-keys .btn { font-size: 1.3rem; padding: 12px 0; }
.talk-pad .actions { display: flex; gap: 8px; justify-content: center; }
.talk-more { justify-self: center; padding: 8px 16px; font-size: .95rem; font-family: inherit; color: var(--accent); background: transparent; border: 1px dashed var(--accent); border-radius: 999px; cursor: pointer; }
.talk-more small { color: var(--muted); }
/* 첫 화면 '자주 쓰는 도구' 한 줄 */
.home-tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 14px 0 4px; }
.home-tools a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 2px; text-decoration: none; font-size: .78rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); white-space: nowrap;
}
.home-tools a span { font-size: 1.4rem; line-height: 1.1; }
.home-tools a:hover { border-color: var(--accent); }
/* 성조표: 영어판 설명이 길어 좁은 휴대폰에서 이름 칸이 눌리지 않게 */
.tone-table td:nth-child(3) { min-width: 8.5em; }
/* 영어판: 'Meaning'·'Pron.' 이름표가 길어서 폭을 글자에 맞춘다 (한국어판 '발음'·'한'은 그대로) */
html[lang="en"] .meta dt { width: auto; min-width: 2.6em; padding: 0 5px; }
/* 첫 화면 '내 동네' — 고르기 전에는 칸, 고른 뒤에는 한 줄 */
.home-area { margin: 14px 0 4px; }
.home-area h2 { margin: 0 0 4px; font-size: 1.05rem; }
.home-area p { margin: 0 0 8px; font-size: .88rem; }
.home-area-line { margin: 12px 0 0; font-size: .88rem; color: var(--muted); }
.home-area-line b { color: var(--text); }
/* 🏠 새 주소로 옮기기 (예전 주소에서만) */
.move-banner { margin: 0 0 14px; border: 2px solid var(--accent); }
.move-banner h2 { margin: 0 0 6px; font-size: 1.05rem; }
.move-banner p { margin: 0 0 8px; font-size: .9rem; }
/* 📋 고친 내역 */
.changes-day h2 { margin: 0 0 6px; font-size: 1rem; }
.changes-day ul { margin: 0; padding-left: 20px; }
.changes-day li { margin-bottom: 4px; }
/* 📮 제보·의견 */
.fb-kinds { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.fb-link { margin: 18px 0 0; font-size: .85rem; text-align: center; }
