/* Korean Nerd · TOPIK Ⅱ 3–4급 — design system
   Palette: learning indigo + progress green. Type: Noto Sans KR (UI, Cyrillic + Hangul), Noto Serif KR (exam passages). */

:root {
  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --surface-2: #EEF0F8;
  --text: #17153B;
  --muted: #565B75;
  --border: #DFE2EE;
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --on-primary: #FFFFFF;
  --primary-soft: #ECEBFE;
  --accent: #15803D;
  --accent-soft: #E3F5E9;
  --danger: #B91C1C;
  --danger-soft: #FDECEC;
  --warn: #A16207;
  --warn-soft: #FDF4DC;
  --ring: #4F46E5;
  --shadow: 0 1px 2px rgba(23, 21, 59, .06), 0 4px 16px rgba(23, 21, 59, .05);
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Noto Sans KR', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Noto Serif KR', 'Noto Serif', Georgia, serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sidebar: 280px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0F26; --surface: #121936; --surface-2: #1A2246; --text: #EEF0FF; --muted: #A3AACB; --border: #232C55;
    --primary: #8B7CFF; --primary-hover: #A396FF; --on-primary: #0A0F26; --primary-soft: #262A63;
    --accent: #4ADE80; --accent-soft: #15301F; --danger: #F87171; --danger-soft: #3A1717; --warn: #FBBF24; --warn-soft: #362A0E;
    --ring: #A39EFF; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
/* Size scale: desktop values here; tablets / phones override the variables at the end of the file. */
:root {
  --fs-body: 16px; --fs-small: 14px; --lh-body: 1.6;
  --fs-h1: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); --fs-h2: 1.35rem; --fs-h3: 1.1rem;
  --page-x: 16px; --card-pad: 22px; --gap: 16px; --topbar-h: 64px; --btn-h: 44px; --btn-fs: 15px; --ko-fs: 17px;
}
:root[data-theme="dark"] {
  --bg: #0A0F26; --surface: #121936; --surface-2: #1A2246; --text: #EEF0FF; --muted: #A3AACB; --border: #232C55;
  --primary: #8B7CFF; --primary-hover: #A396FF; --on-primary: #0A0F26; --primary-soft: #262A63;
  --accent: #4ADE80; --accent-soft: #15301F; --danger: #F87171; --danger-soft: #3A1717; --warn: #FBBF24; --warn-soft: #362A0E;
  --ring: #A39EFF; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--fs-body)/var(--lh-body) var(--font); word-break: keep-all; overflow-wrap: break-word;
}
img, svg, iframe { display: block; max-width: 100%; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: var(--fs-h1); font-weight: 800; }
h2 { font-size: var(--fs-h2); font-weight: 700; }
h3 { font-size: var(--fs-h3); font-weight: 700; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.25em; }
li { margin: .25em 0; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
[lang="ko"], .ko { font-family: var(--font); }
.serif { font-family: var(--font-serif); }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 40;
  transform: translateX(-100%); transition: transform .25s var(--ease);
}
.sidebar.open { transform: none; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; text-decoration: none; color: var(--text); }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none; }
.brand-name { font-weight: 800; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { padding: 6px 10px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 10px; border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 500; font-size: 15px;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav a svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav a[aria-current="page"] svg { color: var(--primary); }
.nav .nav-meta { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 500; }
.sidebar-foot { padding: 12px 18px 18px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.sidebar-foot a { color: var(--muted); }
.scrim { position: fixed; inset: 0; background: rgba(10, 10, 30, .45); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.show { opacity: 1; pointer-events: auto; }

.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px;
  height: 60px; padding: 0 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border);
}
.topbar .title { font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; border: 1px solid transparent;
  background: transparent; color: var(--text); cursor: pointer; transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

.main { padding: 24px var(--page-x) 64px; max-width: 1080px; margin: 0 auto; }

@media (min-width: 1024px) {
  .sidebar { transform: none; }
  .scrim { display: none !important; }
  .content { margin-left: var(--sidebar); transition: margin-left .25s var(--ease); }
  /* ☰ hides the left panel; the content then takes the full width */
  .sb-collapsed .sidebar { transform: translateX(-100%); }
  .sb-collapsed .content { margin-left: 0; }
  .main { padding: 36px 40px 80px; }
}

/* ---------- Page header ---------- */
.page-head { margin-bottom: 28px; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 4px 10px; border-radius: 999px; margin-bottom: 12px; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 70ch; }

/* ---------- Cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-title svg { width: 22px; height: 22px; color: var(--primary); flex: none; }
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.stack > * + * { margin-top: var(--gap); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-small); }
.section { margin-top: 36px; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }

.tile {
  display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--text);
  transition: transform .18s var(--ease), border-color .18s var(--ease);
}
a.tile:hover { transform: translateY(-2px); border-color: var(--primary); color: var(--text); }
.tile-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.tile-icon svg { width: 22px; height: 22px; }
.tile h3 { margin: 0; }
.tile p { margin: 0; color: var(--muted); font-size: 14px; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 1.7rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid transparent; font: 600 var(--btn-fs)/1.2 var(--font); cursor: pointer; text-decoration: none;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-success { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn-success { color: #0E0F1C; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }

/* ---------- Chips / tabs ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--accent-soft); color: var(--accent); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.pri { background: var(--primary-soft); color: var(--primary); }
.stars { color: var(--warn); letter-spacing: 1px; font-size: 13px; white-space: nowrap; }

.tabs { display: flex; gap: 6px; padding: 4px; background: var(--surface-2); border-radius: 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; min-height: 40px; padding: 8px 14px; border-radius: 9px; border: 0; background: transparent; color: var(--muted);
  font: 600 14px/1.2 var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

.seg { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.seg button {
  min-height: 52px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 700 15px/1.2 var(--font); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: border-color .15s, background .15s;
}
.seg button small { font-weight: 500; font-size: 11px; color: var(--muted); }
.seg button:hover { border-color: var(--primary); }
.seg button[aria-current="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.seg button[aria-current="true"] small { color: var(--on-primary); opacity: .85; }
.seg button.done:not([aria-current="true"]) { border-color: var(--accent); }
.seg button.done:not([aria-current="true"]) small { color: var(--accent); }

/* ---------- Progress ---------- */
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .5s var(--ease); }
.bar.pri > i { background: var(--primary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Callouts ---------- */
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--text); }
.callout svg { width: 20px; height: 20px; flex: none; color: var(--primary); margin-top: 2px; }
.callout.warn { background: var(--warn-soft); }
.callout.warn svg { color: var(--warn); }
.callout.ok { background: var(--accent-soft); }
.callout.ok svg { color: var(--accent); }
.callout.bad { background: var(--danger-soft); }
.callout.bad svg { color: var(--danger); }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }

pre.cheat {
  margin: 0; padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px dashed var(--border);
  font: 500 14px/1.7 var(--mono); white-space: pre-wrap; overflow-x: auto;
}

/* ---------- Steps ---------- */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { counter-increment: s; position: relative; padding: 12px 14px 12px 52px; background: var(--surface-2); border-radius: var(--radius-sm); margin: 0; }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 12px; width: 26px; height: 26px; border-radius: 8px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.steps b { display: block; }
.steps span { color: var(--muted); font-size: 15px; }

/* ---------- Video (lazy facade) ---------- */
.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; }
.video button { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; padding: 0; cursor: pointer; background: #000 center/cover no-repeat; }
.video button::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, .55)); }
.video .play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 68px; height: 68px; border-radius: 50%; background: rgba(255, 255, 255, .95); display: grid; place-items: center; z-index: 1; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); transition: transform .15s var(--ease); }
.video button:hover .play { transform: translate(-50%, -50%) scale(1.06); }
.video .play svg { width: 28px; height: 28px; color: #4F46E5; margin-left: 4px; }
.video .vlabel { position: absolute; left: 14px; bottom: 12px; z-index: 1; color: #fff; font-weight: 600; font-size: 14px; text-align: left; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video.empty { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); text-align: center; padding: 20px; }

/* ---------- Exam passage / dialog ---------- */
.passage { font-family: var(--font-serif); font-size: 17px; line-height: 1.9; background: var(--surface-2); border-radius: var(--radius-sm); padding: 16px 18px; white-space: pre-line; }
.passage u, .ctx u { text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: var(--primary); }
.dialog { display: grid; gap: 10px; }
.line { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: start; }
.who { font-size: 13px; font-weight: 700; padding: 3px 0; border-radius: 8px; text-align: center; background: var(--surface-2); color: var(--muted); }
.who.f { background: #FCE7F3; color: #9D174D; }
.who.m { background: #DBEAFE; color: #1E40AF; }
:root[data-theme="dark"] .who.f { background: #3B1530; color: #F9A8D4; }
:root[data-theme="dark"] .who.m { background: #172554; color: #93C5FD; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .who.f { background: #3B1530; color: #F9A8D4; }
  :root:not([data-theme="light"]) .who.m { background: #172554; color: #93C5FD; }
}
.line .ko { font-family: var(--font-serif); font-size: 17px; line-height: 1.75; }
.line .ru, .tr { color: var(--muted); font-size: 14px; margin-top: 2px; }
.script.hidden .ko, .script.hidden .ru { filter: blur(7px); user-select: none; }
.script.hidden .dialog { pointer-events: none; }
.parts { display: grid; gap: 8px; }
.parts div { display: grid; grid-template-columns: 40px 1fr; gap: 8px; font-family: var(--font-serif); font-size: 17px; line-height: 1.7; }
.parts b { font-family: var(--font); color: var(--primary); }

/* ---------- Audio player (TTS) ---------- */
.player { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.player .now { font-size: 14px; color: var(--muted); flex: 1; min-width: 140px; }
.player select { min-height: 36px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 0 8px; font: 500 14px var(--font); }

/* ---------- Quiz ---------- */
.q { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 18px; }
.q-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.q-num { flex: none; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 10px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.q-prompt { font-weight: 600; }
.opts { display: grid; gap: 8px; }
.opt {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: start; text-align: left; width: 100%;
  min-height: 52px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font: 500 16px/1.5 var(--font); cursor: pointer; transition: border-color .15s, background .15s;
}
.opt:hover:not([disabled]) { border-color: var(--primary); background: var(--primary-soft); }
.opt .mark { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--border); display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--muted); }
.opt .t-ko { font-family: var(--font-serif); font-size: 17px; }
.opt .t-ru { display: block; color: var(--muted); font-size: 14px; }
.opt .why { display: none; font-size: 14px; margin-top: 4px; }
.opt .res { width: 22px; height: 22px; }
.opt[disabled] { cursor: default; }
.opt.correct { border-color: var(--accent); background: var(--accent-soft); }
.opt.correct .mark { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.opt.wrong .mark { background: var(--danger); border-color: var(--danger); color: #fff; }
/* after answering: reasons and option translations open with «Подробнее» (.show-why) */
.opt .t-ko + .t-ru { display: none; }
.opts.show-why .why, .opts.show-why .opt .t-ko + .t-ru { display: block; }
.opts.revealed .opt:not(.correct):not(.wrong) { opacity: .75; }
.feedback { margin-top: 12px; }
.input-row { display: flex; gap: 8px; flex-wrap: wrap; }
.input, textarea, select.input {
  min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font: 400 16px/1.5 var(--font); width: 100%;
}
.input:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
label.field { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.ctx { display: grid; gap: 4px; font-family: var(--font-serif); font-size: 17px; line-height: 1.75; margin-bottom: 12px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm); }

.score-card { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.ring { --p: 0; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0); flex: none; }
.ring b { width: 66px; height: 66px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Flashcards ---------- */
.flash-wrap { perspective: 1200px; }
.flash {
  position: relative; min-height: 280px; border-radius: 20px; cursor: pointer; transform-style: preserve-3d;
  transition: transform .45s var(--ease); border: 0; padding: 0; width: 100%; background: none; color: inherit; font: inherit;
}
.flash.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: 20px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center;
}
.face.back { transform: rotateY(180deg); }
.face .word { font-size: clamp(2rem, 1.4rem + 3vw, 3rem); font-weight: 800; font-family: var(--font); }
.face .meaning { font-size: 1.35rem; font-weight: 700; }
.face .colloc { font-family: var(--font-serif); font-size: 1.05rem; color: var(--muted); }
.face .hint { position: absolute; bottom: 14px; font-size: 13px; color: var(--muted); }
.face .lvl { position: absolute; top: 14px; left: 14px; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate button { min-height: 56px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: 700 15px/1.2 var(--font); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.rate button small { font-weight: 500; color: var(--muted); font-size: 12px; }
.rate .again { border-color: var(--danger); color: var(--danger); }
.rate .hard { border-color: var(--warn); color: var(--warn); }
.rate .good { border-color: var(--accent); color: var(--accent); }
.rate .easy { border-color: var(--primary); color: var(--primary); }
.rate button:hover { background: var(--surface-2); }

/* ---------- Writing: wongoji ---------- */
.wongoji { --cols: 25; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); background: var(--surface); overflow: hidden; border-radius: 6px; }
.wongoji span { aspect-ratio: 1; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: grid; place-items: center; font-family: var(--font-serif); font-size: clamp(9px, 1.6vw, 15px); line-height: 1; }
.wongoji span.mark50 { box-shadow: inset 0 -2px 0 var(--primary); }
.wongoji span.over { background: var(--danger-soft); }
.counter { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.counter b { color: var(--text); font-variant-numeric: tabular-nums; }
.timer { font: 800 1.6rem/1 var(--mono); font-variant-numeric: tabular-nums; }
textarea { min-height: 180px; resize: vertical; font-family: var(--font-serif); font-size: 17px; line-height: 1.8; }
.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.check-list li { display: flex; gap: 10px; align-items: flex-start; margin: 0; }
.check-list svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.check-list .ok svg { color: var(--accent); }
.check-list .bad svg { color: var(--danger); }
.check-list .neutral svg { color: var(--muted); }
.version { border-left: 4px solid var(--border); }
.version.bad { border-left-color: var(--danger); }
.version.mid { border-left-color: var(--warn); }
.version.good { border-left-color: var(--accent); }

details.acc { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
details.acc + details.acc { margin-top: 8px; }
details.acc summary { cursor: pointer; list-style: none; padding: 14px 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; min-height: 48px; }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::after { content: ''; margin-left: auto; width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
details.acc[open] summary::after { transform: rotate(-135deg); }
details.acc .acc-body { padding: 0 16px 16px; }

/* ---------- Library ---------- */
.res { display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--text); padding: 14px 16px; }
.res:hover { border-color: var(--primary); color: var(--text); }
.res .tile-icon { flex: none; }
.res b { display: block; line-height: 1.3; }
.res span { font-size: 14px; color: var(--muted); }
.res .ext { margin-left: auto; width: 18px; height: 18px; color: var(--muted); flex: none; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease); z-index: 60; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.footer { margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

@media (max-width: 560px) {
  .card { padding: 16px; }
  .line { grid-template-columns: 1fr; gap: 4px; }
  .who { justify-self: start; padding: 2px 10px; }
  .rate { grid-template-columns: repeat(2, 1fr); }
  th, td { padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .sidebar, .topbar, .player, .btn, .footer { display: none !important; }
  .content { margin: 0 !important; }
}

/* inline icon sizing */
.eyebrow svg, .chip svg { width: 15px; height: 15px; flex: none; }
.card-title h3 { flex: 1; }
[hidden] { display: none !important; }
.grid > .card + .card, .grid > * + .card { margin-top: 0; }

/* =========================================================
   v2 — dashboard redesign + site-wide restyle
   ========================================================= */
:root {
  --fire: #DC2626; --fire-soft: #FDECEC;
  --sky: #2563EB; --sky-soft: #E6EEFE;
  --leaf: #15803D; --leaf-soft: #E3F5E9;
  --amber: #B45309; --amber-soft: #FDF1DC;
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fire: #F87171; --fire-soft: rgba(239, 68, 68, .16); --sky: #60A5FA; --sky-soft: rgba(59, 130, 246, .16);
    --leaf: #4ADE80; --leaf-soft: rgba(34, 197, 94, .16); --amber: #FBBF24; --amber-soft: rgba(245, 158, 11, .16);
  }
}
:root[data-theme="dark"] {
  --fire: #F87171; --fire-soft: rgba(239, 68, 68, .16); --sky: #60A5FA; --sky-soft: rgba(59, 130, 246, .16);
  --leaf: #4ADE80; --leaf-soft: rgba(34, 197, 94, .16); --amber: #FBBF24; --amber-soft: rgba(245, 158, 11, .16);
}

/* Sidebar: larger, calmer */
.brand { padding: 22px 22px 18px; gap: 14px; }
.brand-mark { width: 46px; height: 46px; border-radius: 13px; font-size: 18px; background: linear-gradient(135deg, var(--primary), #7C3AED); color: #fff; }
.brand-name { font-size: 1.2rem; }
.brand-sub { font-size: 13px; }
.nav { padding: 6px 14px; }
.nav-label { padding: 18px 12px 8px; font-size: 12px; }
.nav a { min-height: 50px; padding: 10px 14px; font-size: 16px; gap: 14px; border-radius: 12px; }
.nav a svg { width: 22px; height: 22px; }
.nav a[aria-current="page"] { background: linear-gradient(90deg, var(--primary-soft), color-mix(in srgb, var(--primary-soft) 40%, transparent)); }
.nav .nav-meta { font-size: 13px; }
.sidebar-foot { padding: 16px 22px 22px; font-size: 14px; line-height: 1.8; }
.sidebar-foot a { color: var(--primary); }
.topbar { height: var(--topbar-h); padding: 0 20px; }
.topbar .title { font-size: 1.1rem; }

/* Cards: softer, rounder */
.card { border-radius: var(--radius); padding: var(--card-pad); }
.round-btn { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text); transition: background .15s, transform .15s var(--ease); }
.round-btn svg { width: 18px; height: 18px; }
a:hover .round-btn { background: var(--primary-soft); color: var(--primary); transform: translateX(2px); }
.tile-icon.ok { background: var(--leaf-soft); color: var(--leaf); }
.tone-fire { background: var(--fire-soft); color: var(--fire); }
.tone-blue { background: var(--sky-soft); color: var(--sky); }
.tone-green { background: var(--leaf-soft); color: var(--leaf); }
.tone-amber { background: var(--amber-soft); color: var(--amber); }

/* Hero row */
.home-top { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 1180px) { .home-top { grid-template-columns: minmax(0, 2.25fr) minmax(280px, 1fr); } }
.hero {
  position: relative; overflow: hidden; isolation: isolate; border-radius: 22px; min-height: 270px; padding: 30px 32px;
  color: #fff; display: flex; align-items: center;
  background: radial-gradient(120% 140% at 100% 0%, #8B5CF6 0%, transparent 55%), linear-gradient(115deg, #3F37C9 0%, #5B4CF0 45%, #7C5CF5 100%);
  box-shadow: 0 18px 40px -18px rgba(79, 70, 229, .65);
}
.hero-body { position: relative; max-width: 560px; }
.hero-kicker { font-weight: 700; font-size: 15px; opacity: .9; }
.hero h1 { color: #fff; font-size: clamp(2.1rem, 1.4rem + 2.6vw, 3.3rem); font-weight: 800; margin: .15em 0 .3em; letter-spacing: -.02em; }
.hero p { font-size: 1.08rem; opacity: .94; max-width: 46ch; margin-bottom: 1.3em; }
.btn-hero { background: #EEEBFF; color: #3B2FD0; min-height: 50px; padding: 12px 22px; font-size: 16px; }
.btn-hero:hover { background: #fff; color: #3B2FD0; }
.btn-hero-ghost { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .45); color: #fff; min-height: 50px; padding: 12px 20px; font-size: 16px; }
.btn-hero-ghost:hover { background: rgba(255, 255, 255, .18); color: #fff; }
@media (max-width: 700px) {
  .hero { padding: 24px 20px; min-height: 0; }
}

.exam-card { display: flex; flex-direction: column; gap: 12px; text-decoration: none; color: var(--text); justify-content: space-between; }
.exam-card:hover { border-color: var(--primary); color: var(--text); }
.exam-days { display: flex; align-items: baseline; gap: 12px; }
.exam-days b { font-size: 3.4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.exam-days span { font-size: 1.9rem; font-weight: 700; }

/* Overall progress */
.progress-card { display: grid; gap: 24px; grid-template-columns: 1fr; align-items: center; }
@media (min-width: 960px) { .progress-card { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } .progress-rows { border-left: 1px solid var(--border); padding-left: 32px; } }
.progress-main { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.big-ring { --p: 0; width: 148px; height: 148px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-2) 0); }
.big-ring b { width: 122px; height: 122px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; grid-auto-flow: column; align-content: center; }
.big-ring small { font-size: 1.3rem; margin-left: 2px; }
.accent-text { color: var(--primary); font-weight: 600; margin: 14px 0 0; }
.progress-rows { display: grid; gap: 4px; }
.prow { display: grid; grid-template-columns: 24px minmax(110px, 160px) 1fr 46px; gap: 14px; align-items: center; min-height: 38px; color: var(--text); text-decoration: none; border-radius: 10px; }
.prow:hover { color: var(--primary); }
.prow-ic svg { width: 22px; height: 22px; color: var(--muted); }
.prow-label { font-size: 15px; }
.prow-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 15px; }
@media (max-width: 480px) { .prow { grid-template-columns: 22px 1fr 44px; } .prow .bar { grid-column: 2 / 4; grid-row: 2; } }

/* Stat tiles */
.stats4 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.stat-tile { display: flex; align-items: center; gap: 16px; text-decoration: none; color: var(--text); }
.stat-tile:hover { border-color: var(--primary); color: var(--text); }
.stat-tile .tile-icon { width: 54px; height: 54px; border-radius: 15px; flex: none; }
.stat-tile .tile-icon svg { width: 26px; height: 26px; }
.stat-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stat-body b { font-size: 1.6rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-body b small { font-size: 1.05rem; font-weight: 600; color: var(--muted); }
.stat-body > span { font-size: 15px; }
.stat-body > small { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Course path */
.steps-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.steps-grid.collapsed .step-extra { display: none; }
.step { display: flex; flex-direction: column; gap: 16px; text-decoration: none; color: var(--text); transition: transform .18s var(--ease), border-color .18s; }
.step:hover { transform: translateY(-2px); border-color: var(--primary); color: var(--text); }
.step-n { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.step-main { display: flex; align-items: center; gap: 14px; }
.step-main b { display: block; font-size: 1.05rem; }
.step-main small { display: block; color: var(--muted); font-size: 13.5px; line-height: 1.4; margin-top: 2px; }
.step .chev svg { width: 20px; height: 20px; color: var(--muted); }
.step-now { border: 2px solid var(--primary); background: linear-gradient(160deg, var(--primary-soft), var(--surface) 70%); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent), var(--shadow); }
.step-now .tile-icon { background: var(--primary); color: var(--on-primary); }
.step-chip-done { background: var(--leaf-soft); color: var(--leaf); }
.step-chip-now { background: var(--primary); color: var(--on-primary); }
.step-chip-wip { background: var(--amber-soft); color: var(--amber); }
.step-done .bar > i, .step-done .bar.pri > i { background: var(--leaf); }

/* Done card */
.done-card { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.main.home { max-width: 1360px; }
@media (min-width: 1024px) { .main { max-width: 1240px; } .main.home { max-width: 1360px; } }
.big-ring b { display: flex; align-items: baseline; justify-content: center; }
.exam-card > .row:first-child { flex-wrap: nowrap; }
.exam-card > .row:first-child b { white-space: nowrap; }
.progress-main > div:last-child { flex: 1; min-width: 200px; }
.stat-tile { container-type: inline-size; padding: 18px; gap: 14px; }
.stat-body > span { overflow-wrap: normal; word-break: normal; }
@container (max-width: 270px) {
  .stat-tile .round-btn { display: none; }
  .stat-tile .tile-icon { width: 46px; height: 46px; }
}
.stat-tile { display: block; }
.stat-inner { display: flex; align-items: center; gap: 14px; }

/* 기출문제 */
.past-status { position: sticky; top: 72px; z-index: 6; padding: 12px 16px; }
.past-instr { font-weight: 700; font-family: var(--font-serif); padding: 4px 2px; margin-top: 8px; }
.past-img { width: 100%; max-width: 760px; border-radius: 12px; border: 1px solid var(--border); background: #fff; margin-bottom: 8px; }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.qcell { min-height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font: 700 14px var(--font); cursor: pointer; font-variant-numeric: tabular-nums; }
.qcell.ok { background: var(--leaf-soft); color: var(--leaf); border-color: var(--leaf); }
.qcell.bad { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

/* Grammar reference */
.g-filters { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .g-filters { grid-template-columns: 2fr 1.2fr 1fr; } }
.g-unit-head { margin-bottom: 10px; }
.g-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.g-item { display: flex; align-items: center; gap: 12px; text-align: left; min-height: 56px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; transition: border-color .15s, transform .15s var(--ease); }
.g-item:hover { border-color: var(--primary); transform: translateY(-1px); }
.g-num { min-width: 34px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.g-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.g-main b { font-size: 17px; }
.g-main span { font-size: 13.5px; color: var(--muted); }
.g-item .chev svg { width: 18px; height: 18px; color: var(--muted); }
.sheet { position: fixed; inset: 0; z-index: 70; display: flex; justify-content: center; align-items: flex-end; }
@media (min-width: 760px) { .sheet { align-items: center; padding: 24px; } }
.sheet-scrim { position: absolute; inset: 0; background: rgba(8, 10, 30, .55); }
.sheet-panel { position: relative; width: 100%; max-width: 780px; max-height: 100%; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 20px 20px 0 0; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
@media (min-width: 760px) { .sheet-panel { border-radius: 20px; max-height: calc(100vh - 48px); } }
@media (max-width: 759px) { .sheet-panel { height: 100%; border-radius: 0; } }
.sheet-head { display: flex; gap: 12px; align-items: flex-start; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.sheet-body { overflow-y: auto; padding: 8px 20px 20px; }
.sheet-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.g-block { padding-top: 16px; }
.g-block h3 { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.g-block h3 small { font-size: 13px; font-weight: 600; color: var(--muted); }
.g-block .q { border-top: 0; margin-top: 0; padding-top: 0; }
/* Grammar card form tables: wrap headers and tighten on phones so all columns fit */
.g-block table th { white-space: normal; overflow-wrap: normal; word-break: normal; hyphens: auto; }
@media (max-width: 560px) {
  .g-block table { font-size: 13.5px; }
  .g-block th, .g-block td { padding: 7px 8px; }
  .g-block td { overflow-wrap: break-word; hyphens: auto; }
}

/* ---------- Home: compact layout + proverb hero ---------- */
.main.home { max-width: 1180px; }
.main.home .home-top { gap: 16px; }
@media (min-width: 1100px) { .main.home .home-top { grid-template-columns: minmax(0, 2.4fr) minmax(250px, 1fr); } }
.main.home .hero { min-height: 0; padding: 22px 26px; border-radius: 18px; }
.main.home .hero-kicker { font-size: 13px; letter-spacing: .02em; }
.main.home .hero h1 { font-size: clamp(1.45rem, 1.1rem + 1.3vw, 2.05rem); margin: .3em 0 .25em; letter-spacing: -.01em; line-height: 1.25; }
.hero-lit { font-style: italic; opacity: .85; font-size: .98rem; margin: 0 0 .35em; }
.main.home .hero .hero-mean { font-size: 1rem; opacity: .96; margin: 0 0 1em; max-width: 52ch; }
.main.home .btn-hero, .main.home .btn-hero-ghost { min-height: 42px; padding: 9px 16px; font-size: 15px; }
.main.home .card { padding: 18px; }
.main.home .exam-card { gap: 8px; }
.main.home .exam-days b { font-size: 2.5rem; }
.main.home .exam-days span { font-size: 1.4rem; }
.main.home .progress-card { gap: 18px; }
.main.home .progress-main { gap: 20px; }
.main.home .big-ring { width: 112px; height: 112px; }
.main.home .big-ring b { width: 92px; height: 92px; font-size: 2rem; }
.main.home .big-ring small { font-size: 1rem; }
.main.home .prow { min-height: 32px; gap: 12px; }
.main.home .prow-label, .main.home .prow-val { font-size: 14px; }
.main.home .stats4 { gap: 12px; }
.main.home .stat-tile { padding: 14px; }
.main.home .stat-tile .tile-icon { width: 44px; height: 44px; border-radius: 12px; }
.main.home .stat-tile .tile-icon svg { width: 22px; height: 22px; }
.main.home .stat-body b { font-size: 1.3rem; }
.main.home .stat-body > span { font-size: 14px; }
.main.home .steps-grid { gap: 12px; }
.main.home .step { gap: 12px; }
.main.home .step-main b { font-size: 1rem; }
.main.home .section { margin-top: 20px; }

/* ---------- Section tabs: clearly visible on every page ---------- */
.tabs { background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent); padding: 5px; gap: 6px; border-radius: 14px; }
.tab {
  color: var(--primary); font-weight: 700; background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent); min-height: 42px;
}
.tab:hover { color: var(--primary); border-color: var(--primary); }
.tab[aria-selected="true"] {
  background: var(--primary); color: var(--on-primary); border-color: var(--primary);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--primary) 70%, transparent);
}
.tab:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }

/* ---------- Study plan ---------- */
.plan-summary { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.plan-day { scroll-margin-top: 84px; }
.plan-day-head { margin-bottom: 10px; }
.plan-day-head h2 { margin: 0; font-size: 1.15rem; }
.plan-day.is-next { border: 2px solid var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent), var(--shadow); }
.plan-day.is-done { opacity: .72; }
.plan-tasks { display: grid; gap: 6px; margin-bottom: 10px; }
.plan-task { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; background: var(--surface-2); color: var(--text); text-decoration: none; min-height: 48px; border: 1px solid transparent; }
.plan-task:hover { border-color: var(--primary); color: var(--text); }
.plan-task-ic { width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.plan-task-ic svg { width: 18px; height: 18px; }
.plan-task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 15px; }
.plan-task-main small { color: var(--muted); font-size: 13px; }
.plan-task.is-done .plan-task-ic { background: var(--leaf-soft); color: var(--leaf); }
.plan-task.is-done .plan-task-main > span { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text) 40%, transparent); }
.plan-task .chev svg { width: 18px; height: 18px; color: var(--muted); }
.plan-home .row { margin-bottom: 12px; }
.plan-home .plan-tasks { margin-bottom: 0; }

/* ---------- Tap targets ≥ 44 × 44 px and wrapping tabs ---------- */
.tabs { flex-wrap: wrap; overflow: visible; }
.tab { flex: 1 1 auto; min-height: 44px; }
.btn, .btn-sm, .main.home .btn-hero, .main.home .btn-hero-ghost { min-height: var(--btn-h); }
.icon-btn { min-width: 44px; min-height: 44px; flex: none; }
.prow, .main.home .prow { min-height: 44px; }
a.chip { min-height: 44px; padding: 8px 12px; }
.skip { min-height: 44px; display: inline-flex; align-items: center; }

/* ---------- Navigation buttons (between sections / lessons only) ---------- */
:root { --nav-accent: #0369A1; --nav-accent-text: #075985; --nav-soft: #E0F2FE; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --nav-accent: #38BDF8; --nav-accent-text: #7DD3FC; --nav-soft: #0C2A3D; }
}
:root[data-theme="dark"] { --nav-accent: #38BDF8; --nav-accent-text: #7DD3FC; --nav-soft: #0C2A3D; }
.btn.btn-nav, .btn-nav {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 12px;
  background: var(--nav-soft); color: var(--nav-accent-text); border: 1.5px solid color-mix(in srgb, var(--nav-accent) 55%, transparent);
  font: 700 15.5px/1.2 var(--font); text-decoration: none; cursor: pointer;
}
.btn-nav:hover, .btn.btn-nav:hover { background: var(--nav-soft); color: var(--nav-accent-text); border-color: var(--nav-accent); box-shadow: 0 4px 14px -6px color-mix(in srgb, var(--nav-accent) 70%, transparent); }
.btn-nav svg { width: 18px; height: 18px; flex: none; }
.main.home .hero .btn-nav { min-height: 48px; padding: 10px 18px; font-size: 15.5px; }
.tile .btn-nav { align-self: flex-start; margin-top: 4px; }

/* ---------- Brand logo (한 pictogram) — follows the theme ---------- */
:root { --logo-glass: #3B6EF5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --logo-glass: #7FA2FF; } }
:root[data-theme="dark"] { --logo-glass: #7FA2FF; }
.brand-mark, .sidebar .brand-mark { width: 46px; height: 46px; padding: 3px; border-radius: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: none; display: grid; place-items: center; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-mark .logo-face { fill: var(--surface); }
.brand-mark .logo-glass { stroke: var(--logo-glass); }

/* ---------- 기출 exam runner (full-screen, like the TOPIK CBT apps) ---------- */
body.xr-open { overflow: hidden; }
.xr { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: flex; flex-direction: column; }
.xr-head { flex: none; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px 10px; box-shadow: var(--shadow); }
.xr-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; max-width: 980px; margin: 0 auto; }
.xr-title { text-align: center; line-height: 1.25; min-width: 0; }
.xr-title b { display: block; font-size: 1.15rem; }
.xr-title span { font-size: 13px; color: var(--muted); }
.xr-exit { min-height: 44px; }
.xr-submit { min-height: 44px; white-space: nowrap; }
.xr-timer { display: flex; align-items: center; gap: 10px; max-width: 980px; margin: 8px auto 0; }
.xr-time { font-variant-numeric: tabular-nums; font-size: 1.05rem; min-width: 52px; }
.xr-total { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.xr-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.xr-bar > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .9s linear; }
.xr-low .xr-bar > i { background: var(--danger); }
.xr-low .xr-time { color: var(--danger); }
.xr-ic { flex: none; }
.xr-head-idle .xr-timer, .xr-head-idle .xr-submit { visibility: hidden; }
.xr-head-done .xr-bar, .xr-head-done .xr-total { display: none; }
.xr-paused .xr-body { filter: blur(6px); pointer-events: none; user-select: none; }
.xr-paused .xr-head::after { content: 'Пауза — нажмите ▶, чтобы продолжить'; display: block; text-align: center; margin-top: 8px; font-weight: 700; color: var(--primary); }
.xr-body { flex: 1; overflow-y: auto; padding: 18px 16px 80px; -webkit-overflow-scrolling: touch; }
.xr-body > * { max-width: 860px; margin-left: auto; margin-right: auto; }
.xr-grid { position: absolute; top: 112px; right: 12px; left: 12px; max-width: 520px; margin-left: auto; z-index: 3; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .35); max-height: 70vh; overflow-y: auto; }
.qcell.xr-done { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.xr-group { font-size: 1.02rem; line-height: 1.55; font-weight: 700; margin: 26px 0 10px; font-family: var(--font-serif); }
.xr-block { margin-bottom: 8px; }
.xr-q { padding: 10px 0 14px; scroll-margin-top: 12px; }
.xr-qhead { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; font-size: 1rem; line-height: 1.6; }
.xr-num { font-weight: 800; min-width: 30px; }
.xr-img { display: block; width: 100%; max-width: 760px; border-radius: 10px; border: 1px solid var(--border); background: #fff; margin: 6px 0 10px; }
.xr-passage { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 12px 14px; line-height: 1.85; margin: 6px 0 10px; white-space: pre-line; font-family: var(--font-serif); }
.xr-given { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; margin: 6px 0 10px; font-family: var(--font-serif); }
.xr-opts { display: grid; gap: 6px; padding-left: 36px; }
.xr-opts-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.xr-opts-pic { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 480px) { .xr-opts { padding-left: 0; } .xr-opts-2 { grid-template-columns: 1fr 1fr; } }
.xr-opt { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; text-align: left; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 500 15.5px/1.45 var(--font); cursor: pointer; }
.xr-opts-pic .xr-opt { justify-content: center; }
.xr-opt:hover { border-color: var(--primary); }
.xr-opt[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.xr-opt[aria-pressed="true"] .xr-circ { background: var(--primary); color: var(--on-primary); }
.xr-circ { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; border: 1.5px solid currentColor; }
.xr-opt.is-key { border-color: var(--accent); background: var(--accent-soft); }
.xr-opt.is-key .xr-circ { background: var(--accent); color: #fff; border-color: var(--accent); }
.xr-opt.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.chip.bad-chip { background: var(--danger-soft); color: var(--danger); }
.xr-short { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.xr-short .input { flex: 1; min-height: 48px; font-size: 16px; }
.xr-mark { font-size: 1.2rem; font-weight: 700; width: 28px; text-align: center; }
.xr-essay { width: 100%; font: 16px/1.8 var(--font); resize: vertical; }
.xr-count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; font-weight: 600; }
.xr-count.ok { color: var(--accent); }
.xr-count.over { color: var(--danger); }
.xr-end { text-align: center; padding: 24px 0; }
.xr-start { margin-top: 24px !important; display: grid; gap: 12px; justify-items: start; }
.xr-start ul { margin: 0; padding-left: 20px; line-height: 1.7; }
.xr-score { text-align: center; }
.xr-score .row { justify-content: center; }
.xr-points b { font-size: 3rem; font-weight: 800; color: var(--primary); }
.xr-points span { font-size: 1.2rem; color: var(--muted); }
.xr-review { margin-top: 12px; }
.xr-result { padding-top: 6px; }
@media (max-width: 560px) {
  .xr-head { padding: 6px 10px 8px; }
  .xr-exit span { display: none; }
  .xr-exit { padding: 8px 10px; }
  .xr-submit { padding: 8px 12px; font-size: 14px; }
  .xr-title b { font-size: 1rem; }
  .xr-title span { font-size: 12px; }
  .xr-timer { gap: 6px; }
  .xr-total { display: none; }
  .xr-grid { top: 104px; }
}

/* ---------- Про Топик ---------- */
.about-toc { gap: 8px; margin-bottom: 8px; }
.about-toc .chip { text-decoration: none; min-height: 44px; padding-inline: 14px; }
.about-block { scroll-margin-top: 80px; }
.about-block > .section-title { gap: 12px; }
.about-facts { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (min-width: 1200px) { .about-facts { grid-template-columns: repeat(4, 1fr); } }
.about-fact { display: flex; flex-direction: column; gap: 6px; }
.about-facts > .card, .about-block .grid > .card { margin-top: 0; }
@media (max-width: 560px) { .about-facts { grid-template-columns: 1fr 1fr; gap: 10px; } .about-fact { padding: 14px; } .about-fact .tile-icon { width: 36px; height: 36px; } }
.about-list { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.about-grade { display: flex; flex-direction: column; gap: 8px; }
.about-grade.is-target { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.about-grade-n { font-size: 1.4rem; }
.about-pts { font-weight: 700; color: var(--primary); }
tr.hl td { background: var(--accent-soft); font-weight: 600; }
.about-sched td, .about-sched th { white-space: nowrap; }

/* exam review: audio player for «▶ С этого места» */
.xr-review-audio { display: block; width: 100%; margin-top: 8px; }
/* listening trainer: picture options (img) — the text description is the fallback */
.opt-img { display: block; width: 100%; max-width: 280px; border-radius: 10px; margin: 2px 0 6px; }
.opt.has-img .t-ru { display: none; }
/* about.html: links get a 44px tap area without changing the layout; wide tables show they scroll */
.about-link { display: inline-block; padding: 12px 4px; margin: -12px -4px; }
.table-wrap.can-scroll:not(.at-end) { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.scroll-hint { margin: 6px 0 0; text-align: right; }
.about-block .table-wrap td:first-child { white-space: nowrap; }
/* «Тренировка 연습» hub + back link on 듣기 / 읽기 / 쓰기 */
.back-link { margin-bottom: 16px; }
.practice-card { display: flex; flex-direction: column; gap: 12px; text-decoration: none; color: var(--text); }
.practice-card .btn { align-self: flex-start; margin-top: auto; }

/* =========================================================
   Phones & tablets — compact scale. Desktop (≥ 1024 px) is untouched.
   Tablet 641–1023 px: drawer menu, medium scale. Phone ≤ 640 px: main target.
   ========================================================= */
/* Lexicon dictionary: one word = one line, never split by syllable */
.dict-word { white-space: nowrap; word-break: keep-all; overflow-wrap: normal; }
.dict-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.dict-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "spk word pos" ". tr st" ". ex ex";
  align-items: center; column-gap: 6px; row-gap: 0; margin: 0; padding: 5px 10px 6px 6px; border-bottom: 1px solid var(--border);
}
.dict-row:last-child { border-bottom: 0; }
/* 🔊: small icon, 40 × 40 tap area; negative margins keep the row low */
.dict-row .icon-btn { grid-area: spk; width: 40px; height: 40px; min-width: 40px; min-height: 40px; margin: -9px -6px -9px -4px; border-radius: 10px; }
.dict-row .icon-btn svg { width: 18px; height: 18px; color: var(--muted); }
.dict-row .dict-word { grid-area: word; font-size: 16.5px; font-weight: 700; line-height: 1.3; min-width: 0; }
.dict-pos { grid-area: pos; justify-self: end; font-size: 11.5px; line-height: 1.3; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.dict-tr { grid-area: tr; font-size: 14px; line-height: 1.3; }
.dict-row .chip { grid-area: st; justify-self: end; align-self: start; font-size: 11px; padding: 1px 7px; gap: 4px; margin-top: 1px; }
.dict-ex { grid-area: ex; font-size: 12.5px; line-height: 1.3; color: var(--muted); }

@media (max-width: 1023px) {
  :root { --page-x: 20px; --card-pad: 18px; --gap: 14px; --topbar-h: 56px; --fs-h1: 1.6rem; --fs-h2: 1.25rem; --fs-h3: 1.05rem; --radius: 16px; }
  .topbar { padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
  .main { padding-left: max(var(--page-x), env(safe-area-inset-left)); padding-right: max(var(--page-x), env(safe-area-inset-right)); }
  /* drawer */
  .sidebar { width: min(80vw, 300px); padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) env(safe-area-inset-left); }
  .sidebar .brand { padding: 16px 16px 12px; gap: 12px; }
  .sidebar .brand-mark { width: 40px; height: 40px; }
  .brand-name { font-size: 1.05rem; }
  .nav { padding: 4px 10px; }
  .nav-label { font-size: 11px; padding: 12px 12px 6px; }
  .nav a { min-height: 44px; padding: 8px 12px; font-size: 15px; gap: 12px; border-radius: 10px; }
  .nav a svg { width: 20px; height: 20px; }
  .sidebar-foot { padding: 12px 16px 14px; font-size: 13px; line-height: 1.7; }
  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .player select { font-size: 16px; } /* iOS: no zoom on focus */
  .main.home .hero { padding: 20px 22px; }
  .main.home .exam-days b { font-size: 2.2rem; }
  .sheet-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .xr-head { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .xr-body { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (max-width: 640px) {
  :root {
    --fs-body: 15px; --fs-small: 13px; --lh-body: 1.4;
    --fs-h1: clamp(20px, 5.6vw, 22px); --fs-h2: 18px; --fs-h3: 16px;
    --page-x: clamp(12px, 3.6vw, 14px); --card-pad: clamp(12px, 3.6vw, 14px); --gap: clamp(10px, 3vw, 12px);
    --radius: 14px; --topbar-h: 48px; --btn-h: 42px; --btn-fs: 14px; --ko-fs: 16px;
  }
  /* shell */
  .topbar { gap: 4px; padding: 0 max(4px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left)); }
  .topbar .title { font-size: 16px; }
  .topbar .icon-btn { width: 40px; height: 40px; min-width: 40px; min-height: 40px; border-radius: 10px; }
  .topbar .icon-btn svg { width: 20px; height: 20px; }
  .main { padding-top: 14px; padding-bottom: 40px; }
  .footer { margin-top: 28px; padding-top: 14px; font-size: 13px; gap: 6px 12px; }
  .page-head { margin-bottom: 16px; }
  .page-head h1 { margin-bottom: .35em; }
  .eyebrow { font-size: 12px; padding: 3px 9px; margin-bottom: 8px; }
  .lead { font-size: 15px; line-height: 1.45; }
  .back-link { margin-bottom: 12px; }
  .section { margin-top: 22px; }
  .section-title { margin-bottom: 10px; }
  .row { gap: 8px; }
  .card + .card { margin-top: 12px; }
  .card-title { margin-bottom: 10px; gap: 8px; }
  .card-title svg { width: 20px; height: 20px; }
  .tile { gap: 8px; }
  .tile-icon { width: 38px; height: 38px; border-radius: 10px; }
  .tile-icon svg { width: 19px; height: 19px; }
  .tile p { font-size: 13.5px; }
  .stat b { font-size: 1.4rem; }
  .callout { padding: 10px 12px; gap: 10px; font-size: 14px; }
  .callout svg { width: 18px; height: 18px; }
  ul, ol { padding-left: 1.15em; }
  /* buttons, chips, tabs */
  .btn { padding: 8px 14px; border-radius: 11px; }
  .btn svg { width: 17px; height: 17px; }
  .btn-sm, .btn.btn-sm { min-height: 40px; padding: 6px 10px; font-size: 13.5px; }
  .btn.btn-nav, .btn-nav, .main.home .hero .btn-nav { min-height: 42px; padding: 8px 14px; font-size: 14.5px; }
  .chip { font-size: 12px; padding: 2px 8px; }
  a.chip { min-height: 40px; padding: 6px 12px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding: 4px; gap: 4px; border-radius: 12px; }
  .tab { flex: 1 0 auto; min-height: 40px; padding: 8px 12px; font-size: 13.5px; border-radius: 9px; }
  .about-toc { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: calc(-1 * var(--page-x)); margin-right: calc(-1 * var(--page-x)); padding: 2px var(--page-x); }
  .about-toc::-webkit-scrollbar { display: none; }
  .about-toc .chip { min-height: 40px; flex: none; }
  .seg { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
  .seg button { min-height: 46px; font-size: 14px; border-radius: 10px; }
  .bar { height: 6px; }
  .input, select.input { min-height: 42px; padding: 8px 12px; border-radius: 11px; } /* text stays 16px: no iOS zoom */
  /* tables */
  table { font-size: 14px; }
  th, td { padding: 8px 10px; }
  th { font-size: 12px; }
  details.acc summary { padding: 10px 12px; min-height: 44px; }
  details.acc .acc-body { padding: 0 12px 12px; }
  .steps li { padding: 10px 12px 10px 46px; }
  .steps li::before { left: 12px; top: 10px; width: 24px; height: 24px; font-size: 13px; }
  .steps span { font-size: 14px; }
  .video .play { width: 56px; height: 56px; }
  .video .play svg { width: 24px; height: 24px; }
  .res { padding: 12px; gap: 12px; }
  .res span { font-size: 13px; }

  /* Home */
  .main.home .home-top { gap: var(--gap); }
  .main.home .hero { padding: 16px; border-radius: var(--radius); box-shadow: 0 10px 24px -16px rgba(79, 70, 229, .6); }
  .main.home .hero-kicker { font-size: 12px; }
  .main.home .hero h1 { font-size: clamp(24px, 6.6vw, 26px); margin: .2em 0 .15em; line-height: 1.25; }
  .main.home .hero .hero-lit { font-size: 15px; line-height: 1.4; margin: 0 0 .3em; }
  .main.home .hero .hero-mean { font-size: 14px; line-height: 1.4; margin: 0 0 12px; }
  .main.home .hero .btn-nav { min-height: 40px; padding: 7px 14px; font-size: 14px; }
  .main.home .card { padding: var(--card-pad); }
  .main.home .exam-card { gap: 6px; }
  .main.home .exam-card .tile-icon { width: 32px; height: 32px; border-radius: 9px; }
  .main.home .exam-card .tile-icon svg { width: 18px; height: 18px; }
  .main.home .exam-days { gap: 8px; }
  .main.home .exam-days b { font-size: 34px; }
  .main.home .exam-days span { font-size: 18px; }
  .main.home .exam-card .round-btn { width: 32px; height: 32px; }
  .main.home .section { margin-top: 14px; }
  .plan-home .row { margin-bottom: 8px; }
  .plan-tasks { gap: 4px; }
  .plan-task { min-height: 44px; padding: 6px 10px; gap: 10px; border-radius: 10px; }
  .plan-task-ic { width: 28px; height: 28px; border-radius: 8px; }
  .plan-task-ic svg { width: 16px; height: 16px; }
  .plan-task-main { font-size: 14px; line-height: 1.35; }
  .plan-task-main small { font-size: 12.5px; }
  .main.home .progress-card { gap: 12px; }
  .main.home .progress-main { gap: 14px; }
  .main.home .big-ring { width: 92px; height: 92px; }
  .main.home .big-ring b { width: 76px; height: 76px; font-size: 1.6rem; }
  .accent-text { margin-top: 6px; font-size: 14px; }
  .main.home .prow-label, .main.home .prow-val { font-size: 13.5px; }
  .main.home .stats4 { gap: 10px; }
  .main.home .stat-tile { padding: 12px; }
  .main.home .stat-tile .tile-icon { width: 38px; height: 38px; border-radius: 10px; }
  .main.home .stat-tile .tile-icon svg { width: 19px; height: 19px; }
  .main.home .stat-body b { font-size: 1.15rem; }
  .main.home .stat-body > span { font-size: 13.5px; }
  .stat-body > small { font-size: 12px; margin-top: 2px; }
  .main.home .steps-grid { gap: 10px; }
  .main.home .step { gap: 10px; }
  .step-main { gap: 10px; }
  .main.home .step-main b { font-size: 15px; }
  .step-main small { font-size: 12.5px; }

  /* Plan / about */
  .plan-day { scroll-margin-top: 60px; }
  .plan-day-head h2 { font-size: 16px; }
  .about-block { scroll-margin-top: 60px; }
  .about-facts { gap: 8px; }
  .about-fact { padding: 12px; }

  /* Lexicon */
  .dict-filters { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dict-count { margin: 0; }
  .dict-filters > input { grid-column: 1 / -1; }
  .flash { min-height: 230px; }
  .face { padding: 18px; gap: 8px; }
  .face .meaning { font-size: 1.15rem; }
  .face .colloc { font-size: 1rem; }
  .rate { gap: 6px; }
  .rate button { min-height: 48px; font-size: 14px; }

  /* Tests: 듣기 / 읽기 / grammar */
  .q { padding-top: 14px; margin-top: 14px; }
  .q-head { gap: 8px; margin-bottom: 10px; }
  .q-num { min-width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }
  .q-prompt { font-size: 15.5px; line-height: 1.45; }
  .opts { gap: 6px; }
  .opt { grid-template-columns: 26px 1fr auto; gap: 8px; min-height: 44px; padding: 9px 10px; border-radius: 11px; font-size: 15px; line-height: 1.4; }
  .opt .mark { width: 24px; height: 24px; font-size: 13px; }
  .opt .t-ko { font-size: var(--ko-fs); }
  .opt .t-ru, .opt .why { font-size: 13px; }
  .passage { font-size: var(--ko-fs); line-height: 1.75; padding: 12px; }
  .ctx { font-size: var(--ko-fs); line-height: 1.7; padding: 10px 12px; }
  .line .ko, .parts div { font-size: var(--ko-fs); line-height: 1.65; }
  .line .ru, .tr { font-size: 13px; }
  .player { padding: 8px; gap: 8px; }
  .player .btn { flex: 1 1 0; }
  .player select { min-height: 40px; }
  .player .now { flex-basis: 100%; min-width: 0; font-size: 13px; }
  .score-card { gap: 12px; }
  .ring { width: 72px; height: 72px; }
  .ring b { width: 58px; height: 58px; font-size: 1rem; }

  /* Writing */
  textarea { min-height: 40vh; font-size: 16px; line-height: 1.7; }
  .counter { gap: 4px 10px; font-size: 12.5px; }
  .timer { font-size: 1.3rem; }
  .btn-row { flex-wrap: nowrap; gap: 6px; }
  .btn-row > .btn { flex: 1 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; white-space: nowrap; }
  .btn-row > .btn svg { display: none; }
  .lbl-x { display: none; }

  /* Grammar reference */
  .g-filters { gap: 8px; }
  .g-list { gap: 6px; }
  .g-item { min-height: 50px; padding: 8px 12px; gap: 10px; border-radius: 12px; }
  .g-num { min-width: 28px; font-size: 12px; }
  .g-main b { font-size: 16px; }
  .g-main span { font-size: 13px; }
  .sheet-head { padding: 12px 14px; gap: 10px; }
  .sheet-body { padding: 4px 14px 16px; }
  .sheet-foot { padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
  .g-block { padding-top: 12px; }

  /* 기출 exam screen: compact header (it stays pinned: timer, ⏸ and the question grid are always visible) */
  .xr-head { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
  .xr-top { gap: 6px; }
  .xr-exit, .xr-submit { min-height: 40px; }
  .xr-submit { padding: 6px 10px; font-size: 13.5px; }
  .xr-title b { font-size: 15px; }
  .xr-title span { font-size: 11px; }
  .xr-timer { margin-top: 4px; gap: 4px; }
  .xr-time { font-size: 15px; min-width: 46px; }
  .xr-bar { height: 6px; }
  .xr-ic { width: 40px; height: 40px; min-width: 40px; min-height: 40px; }
  .xr-body { padding: 12px 12px calc(72px + env(safe-area-inset-bottom)); }
  .xr-group { margin: 16px 0 8px; font-size: 15px; }
  .xr-q { padding: 6px 0 10px; }
  .xr-qhead { font-size: 15.5px; margin-bottom: 6px; }
  .xr-opts { gap: 6px; }
  .xr-opt { min-height: 44px; padding: 7px 10px; font-size: 15px; }
  .xr-circ { width: 24px; height: 24px; font-size: 14px; }
  .xr-passage, .xr-given { padding: 10px 12px; font-size: 15.5px; line-height: 1.75; }
  .xr-points b { font-size: 2.4rem; }
}

/* Landscape phones: low screen — slim bars, exam header in one row */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 1023px) {
  :root { --topbar-h: 48px; }
  .xr-head { display: flex; align-items: center; gap: 12px; padding-top: 4px; padding-bottom: 4px; }
  .xr-top { flex: 1 1 55%; min-width: 0; }
  .xr-timer { flex: 1 1 45%; margin: 0; }
  .xr-title span { display: none; }
  .xr-exit, .xr-submit { min-height: 40px; }
  .flash { min-height: 200px; }
}

/* ---------- Minimal text: «Подробнее» toggles, proverb «?» ---------- */
details.more > summary { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; cursor: pointer; list-style: none; color: var(--primary); font-weight: 600; font-size: 14px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: ''; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .2s; }
details.more[open] > summary::after { transform: rotate(-135deg) translate(-2px, 0); }
details.more > .callout { margin-top: 8px; }
.hero-litrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 1em; }
.main.home .hero .hero-litrow .hero-lit { margin: 0; }
.hero-q { position: relative; flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .7); background: rgba(255, 255, 255, .12); color: #fff; font: 700 15px/1 var(--font); cursor: pointer; display: grid; place-items: center; padding: 0; }
.hero-q::before { content: ''; position: absolute; inset: -8px; } /* 44 px tap area */
.hero-q[aria-expanded="true"] { background: #fff; color: #3B2FD0; }
.main.home .hero .hero-mean { margin-top: -.4em; }
.about-block > .about-more, .about-block > .callout, .about-block > .table-wrap + * { margin-top: 12px; }
@media (max-width: 640px) {
  .hero-litrow { margin-bottom: 12px; gap: 8px; }
  .main.home .hero .hero-mean { margin-top: -4px; }
}

/* Home: exam countdown in one line — «28 д 05:12:34» */
.main.home .exam-days .exam-count { font-size: 1.75rem; white-space: nowrap; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
@media (max-width: 1023px) { .main.home .exam-days .exam-count { font-size: 2rem; } }
@media (max-width: 640px) { .main.home .exam-days .exam-count { font-size: 30px; } }
