/* Layout: one centered reading column; question cards are the main object; deep teal brand with a warm amber accent */
[hidden] { display: none !important; }
:root {
  --bg: #f6f7f5; --surface: #ffffff; --ink: #17231f; --muted: #56655f; --line: #dbe2de;
  --accent: #0f6b62; --accent-soft: #e2f1ee; --amber: #c27a00; --good: #1f7a45; --good-soft: #e3f3ea;
  --bad: #b3261e; --bad-soft: #fbe9e7;
  --f-body: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
  --f-mono: ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1614; --surface: #17211e; --ink: #e6eeeb; --muted: #9db0a9; --line: #2a3a35;
    --accent: #5ccfbf; --accent-soft: #163330; --amber: #f0b44c; --good: #5fcf8d; --good-soft: #163325;
    --bad: #ff8a80; --bad-soft: #3a1d1b; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { word-break: keep-all; overflow-wrap: anywhere; margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 17px; line-height: 1.6; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 760px; margin: 0 auto; padding-inline: 16px; }
header.top { background: var(--surface); border-bottom: 1px solid var(--line); }
header.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px color-mix(in srgb, var(--amber) 25%, transparent); }
nav.main { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 15px; }
nav.main a { text-decoration: none; color: var(--muted); }
nav.main a:hover { color: var(--ink); }
main { padding-block: 28px 56px; display: grid; gap: 28px; }
h1, h2, h3 { line-height: 1.3; text-wrap: balance; margin: 0; word-break: keep-all; }
h1 { font-size: clamp(26px, 5vw, 34px); }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0; }
.lede { color: var(--muted); font-size: 18px; }
.stack { display: grid; gap: 12px; }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.pill { display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.btns { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.subs { display: grid; gap: 10px; }
.sub { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); }
.sub:hover { border-color: var(--accent); }
.sub .code { font-weight: 700; color: var(--amber); white-space: nowrap; font-size: 15px; }
.sub .meta { font-size: 14px; color: var(--muted); white-space: nowrap; }
.qlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.qlist a { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.qlist .id { font-family: var(--f-mono); color: var(--muted); font-size: 14px; padding-top: 2px; }
.question { font-size: 20px; font-weight: 700; }
.options { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.opt { width: 100%; text-align: left; display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt .letter { font-weight: 700; color: var(--muted); }
.opt.correct { border-color: var(--good); background: var(--good-soft); }
.opt.correct .letter { color: var(--good); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .letter { color: var(--bad); }
.opt:disabled { cursor: default; }
.explain { border-left: 3px solid var(--amber); padding: 4px 0 4px 14px; display: grid; gap: 8px; }
.explain .tip { color: var(--muted); font-size: 15px; }
.figure img { max-width: 100%; height: auto; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.refs { font-size: 14px; color: var(--muted); }
.pager { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ad-slot { min-height: 100px; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.score { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pass { color: var(--good); } .fail { color: var(--bad); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.checks label { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 15px; cursor: pointer; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.fact b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.fact span { font-size: 14px; color: var(--muted); }
footer { border-top: 1px solid var(--line); padding-block: 20px 40px; font-size: 14px; color: var(--muted); }
footer .wrap { display: grid; gap: 8px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.opt.chosen { border-color: var(--accent); background: var(--accent-soft); }
.confirm { color: var(--bad); font-size: 15px; }
.skip { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; }
.empty { color: var(--good); }
.checks small { font-size: 13px; }
.ready .score { font-size: 52px; }
.weak { margin: 0; padding-left: 20px; }
.flash .ans { font-size: 19px; font-weight: 700; color: var(--good); }
.flash .tip { color: var(--muted); font-size: 15px; }
select { font: inherit; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
/* Focus mode: one question per screen on phones, actions pinned to the bottom edge */
body.focus nav.main, body.focus footer, body.focus .ad-slot, body.focus .q .crumbs, body.focus .flash .crumbs, body.focus .explain .refs, body.focus .opt.faded { display: none; }
body.focus header.top .wrap { padding-block: 8px; }
body.focus main { padding-block: 8px 0; gap: 8px; }
body.focus .run { min-height: calc(100dvh - 58px); display: flex; flex-direction: column; gap: 8px; }
body.focus .run .card { padding: 14px; gap: 8px; }
body.focus .question { font-size: 17px; line-height: 1.4; }
body.focus .options { gap: 6px; }
body.focus .opt { padding: 8px 12px; font-size: 15.5px; line-height: 1.4; }
body.focus .explain { font-size: 15px; line-height: 1.45; gap: 4px; }
body.focus .explain .tip { font-size: 14px; }
body.focus .figure img { max-height: 32dvh; width: auto; }
body.focus .run > .btns { position: sticky; bottom: 0; margin-top: auto; padding-block: 8px; background: var(--bg); }
body.focus .run > .btns .btn { flex: 1; }
nav.exams { display: flex; gap: 6px; padding-bottom: 10px; font-size: 14px; }
nav.exams a { padding: 3px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--muted); }
nav.exams a[aria-current] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
body.focus .exams-row { display: none; }
header.top .exams-row { padding-block: 0; }
/* Phone fit: grid tracks may shrink below their content so nothing pushes the page sideways */
main { grid-template-columns: minmax(0, 1fr); }
.sub { grid-template-columns: 52px minmax(0, 1fr) auto; }
.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.links a { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--accent); font-weight: 700; text-decoration: none; }
.links a::after { content: "›"; font-size: 22px; line-height: 1; }
.links a:hover { border-color: var(--accent); }
@media (max-width: 560px) {
  .sub { grid-template-columns: 52px minmax(0, 1fr); row-gap: 2px; }
  .sub .meta { grid-column: 2; white-space: normal; }
  .btns .btn { flex: 1 1 100%; }
  body.focus .run > .btns .btn { flex: 1; }
}
/* iPhone: older Safari lacks dvh, the home bar covers the screen bottom, and fields under 16px zoom the page */
@supports not (height: 100dvh) { body.focus .run { min-height: calc(100vh - 58px); } }
body.focus .run > .btns { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
select, input, textarea { font-size: 16px; }
/* Gear guide: disclosure line, numbered steps, affiliate buttons */
.disclosure { font-size: 15px; color: var(--muted); padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.gear { scroll-margin-top: 16px; }
.gear-step { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--amber); }
.gear-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.gear .note { border-left: 3px solid var(--amber); padding: 4px 0 4px 14px; }
.gear-btns .btn { text-align: center; line-height: 1.3; padding-block: 8px; }

/* Ad slots take no room while empty; AdSense marks unfilled slots after review. */
.ad-slot { min-height: 0; }
.ad-slot:has(ins[data-ad-status="unfilled"]) { display: none; }
/* Phones: keep the main menu on one swipeable line instead of wrapping. */
@media (max-width: 640px) {
  nav.main { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  nav.main::-webkit-scrollbar { display: none; }
}
/* Home hero: a soft tinted panel so the main actions stand out. */
main > .hero { background: linear-gradient(160deg, var(--accent-soft), var(--surface) 75%); border: 1px solid var(--line); border-radius: 18px; padding: 22px 18px; margin-top: 16px; }
@media (min-width: 700px) { main > .hero { padding: 32px 32px; } }
main > .hero > .pill { justify-self: start; width: fit-content; }
/* Study plan card (src/habit.js) */
.habit { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.habit .habit-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.habit h2 { margin: 0; }
.habit .streak { font-size: 14px; font-weight: 700; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; }
.habit .streak.on { color: #b45309; background: #fff4e0; border-color: #f5c77e; }
.habit .week { display: flex; gap: 6px; }
.habit .week i { width: 26px; height: 8px; border-radius: 4px; background: var(--line); }
.habit .week i.on { background: var(--accent); }
.habit .week i.today { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 2px; }
.habit .today { margin: 0; font-weight: 600; }
.habit .exam-date { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 6px; font-size: 15px; }
.habit .exam-date label { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); }
.habit .exam-date input { font: inherit; font-size: 16px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.habit .exam-date p { margin: 0; }
.habit .dday { color: var(--accent); font-size: 18px; margin-right: 4px; }
@media (prefers-color-scheme: dark) { .habit .streak.on { color: #fbbf24; background: #3a2a10; border-color: #6b4a14; } }

/* Guide tables scroll sideways inside their box on narrow phones instead of widening the page. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 15px; }
.table-wrap th, .table-wrap td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.table-wrap th { background: var(--bg); }

/* Korean exam layout: 제시문 box, numbered choices on list pages, answer reveal */
.box { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 12px 14px; display: grid; gap: 4px; font-size: 16px; }
.choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.choices li { display: grid; grid-template-columns: 26px 1fr; gap: 6px; }
.choices .num { color: var(--muted); }
.qitem .question { font-size: 18px; }
.qitem .question a { color: var(--ink); text-decoration: none; }
.qitem .question a:hover { color: var(--accent); }
details summary { cursor: pointer; color: var(--accent); font-weight: 700; min-height: 32px; }
details[open] { display: grid; gap: 8px; border-left: 3px solid var(--amber); padding-left: 12px; }
.opt .letter { font-size: 18px; }
.topics { margin: 0; padding-left: 20px; }
.radios label { align-items: flex-start; }
/* Exam answer sheet */
.omr-wrap summary { font-size: 15px; }
.omr { margin-top: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 4px; max-height: 132px; overflow-y: auto; }
.omr button { min-height: 32px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; padding: 0; }
.omr button.done { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.omr button.here { outline: 2px solid var(--amber); outline-offset: 1px; }
/* Per-area accuracy bars */
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(0, 9em) 1fr auto; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-size: 15px; }
.bar .track { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.bar .track i { display: block; height: 100%; background: var(--good); }
.bar .track i.low { background: var(--bad); }
@media (max-width: 560px) { .bar { grid-template-columns: 1fr auto; } .bar .track { grid-column: 1 / -1; grid-row: 2; } }
/* Pass calculator */
.field { display: grid; gap: 6px; }
.field input { font: inherit; font-size: 18px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); max-width: 180px; }
.review li { word-break: keep-all; }
.btn.check { width: 100%; margin-top: 4px; }
.btn.check:disabled { opacity: .45; cursor: default; }
