/* =========================================================================
   해기사 기출 문제 — Design system
   Light mode · Toss-inspired warmth + Microsoft Fluent 2 depth/motion
   ========================================================================= */

:root {
  --legacy-banner-height: 32px;
  /* ---- palette ---- */
  --blue-50:  #EAF2FE;
  --blue-100: #C9DEFB;
  --blue-300: #6BA4F8;
  --blue-500: #3182F6;   /* primary (Toss blue) */
  --blue-600: #2272EB;
  --blue-700: #1B64D6;

  --green-50:  #E7F9F1;
  --green-500: #00C471;
  --green-600: #00A864;
  --green-700: #048a55;

  --red-50:  #FDECEE;
  --red-500: #F04452;
  --red-600: #E02D3C;

  --amber-500: #FF9500;

  --grey-0:  #FFFFFF;
  --grey-50: #F9FAFB;
  --grey-100:#F2F4F6;
  --grey-150:#EBEEF1;
  --grey-200:#E5E8EB;
  --grey-300:#D1D6DB;
  --grey-400:#B0B8C1;
  --grey-500:#8B95A1;
  --grey-600:#6B7684;
  --grey-700:#4E5968;
  --grey-800:#333D4B;
  --grey-900:#191F28;

  --bg: var(--grey-100);
  --surface: var(--grey-0);
  --text: var(--grey-900);
  --text-2: var(--grey-700);
  --text-3: var(--grey-500);
  --line: var(--grey-200);

  /* ---- radius ---- */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* ---- shadow (Fluent depth, Toss softness) ---- */
  --sh-1: 0 1px 2px rgba(23,31,40,.06), 0 1px 3px rgba(23,31,40,.04);
  --sh-2: 0 2px 6px rgba(23,31,40,.06), 0 8px 20px rgba(23,31,40,.06);
  --sh-3: 0 6px 16px rgba(23,31,40,.08), 0 18px 44px rgba(23,31,40,.10);
  --sh-blue: 0 6px 18px rgba(49,130,246,.30);
  --sh-blue-sm: 0 2px 8px rgba(49,130,246,.24);

  /* ---- motion (Fluent 2 curves) ---- */
  --e-out: cubic-bezier(.33, 1, .68, 1);
  --e-inout: cubic-bezier(.65, 0, .35, 1);
  --e-spring: cubic-bezier(.34, 1.56, .64, 1);

  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR",
    system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "tnum";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
:focus-visible { outline: 3px solid var(--blue-100); outline-offset: 2px; }

/* ===================== layout ===================== */
#app { min-height: 100dvh; }

.legacy-banner {
  position: sticky; top: 0; z-index: 50;
  height: var(--legacy-banner-height); padding: 0 12px;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  white-space: nowrap; overflow: hidden;
  background: rgba(242, 244, 246, .94); border-bottom: 1px solid var(--grey-200);
  backdrop-filter: saturate(160%) blur(12px);
  color: var(--grey-600); font-size: 11.5px; font-weight: 600;
  letter-spacing: -.01em;
}
.legacy-banner a {
  color: var(--blue-600); font-weight: 700; text-decoration: none;
}
.legacy-banner a:hover { color: var(--blue-700); text-decoration: underline; }
.legacy-banner a:focus-visible { outline: 2px solid var(--blue-300); outline-offset: 2px; }

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 18px calc(40px + env(safe-area-inset-bottom));
}

/* sticky app header */
.appbar {
  position: sticky; top: var(--legacy-banner-height); z-index: 30;
  backdrop-filter: saturate(180%) blur(14px);
  background: rgba(249, 250, 251, .82);
  border-bottom: 1px solid var(--line);
}
.appbar-inner {
  max-width: 760px; margin: 0 auto;
  height: 56px; padding: 0 14px;
  display: flex; align-items: center; gap: 10px;
}
.appbar .brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 16px; letter-spacing: -.02em;
  cursor: pointer; user-select: none;
  padding: 6px 10px; margin: 0 -8px; border-radius: var(--r-pill);
  transition: background .16s var(--e-out), transform .1s var(--e-out);
}
.appbar .brand:hover { background: var(--grey-150); }
.appbar .brand:active { transform: scale(.97); }
.appbar .brand:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; }
.brand .logo {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  box-shadow: var(--sh-blue-sm);
  display: grid; place-items: center; color: #fff; font-size: 14px;
}
.appbar .spacer { flex: 1; }

/* 홈 하단 제작자 크레딧 (홈 전용, 기능 영향 없음) */
.home-footer {
  margin-top: 28px; padding: 18px 4px 32px;
  border-top: 1px solid var(--line);
  text-align: center; color: var(--text-3);
  font-size: 12.5px; letter-spacing: -.01em;
}
.home-footer a { color: inherit; text-decoration: none; }
.home-footer a:hover { color: var(--text-2); text-decoration: underline; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 38px; min-width: 38px; padding: 0 12px;
  border-radius: var(--r-pill);
  color: var(--text-2); font-weight: 600; font-size: 14px;
  transition: background .16s var(--e-out), color .16s var(--e-out), transform .1s var(--e-out);
}
.iconbtn:hover { background: var(--grey-150); color: var(--text); }
.iconbtn:active { transform: scale(.95); }
.iconbtn.active { color: var(--blue-600); background: var(--blue-50); }

/* ===================== headings ===================== */
.page-head { padding: 26px 2px 16px; }
.page-head h1 {
  margin: 0; font-size: 26px; line-height: 1.25; letter-spacing: -.03em;
  font-weight: 800;
}
.page-head p { margin: 8px 0 0; color: var(--text-3); font-size: 14.5px; font-weight: 500; }

.section { margin-top: 22px; }
.section > .label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--text-3);
  letter-spacing: .01em; margin: 0 2px 10px; text-transform: none;
}
.section > .label .hint { color: var(--grey-400); font-weight: 500; }

/* ===================== card ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
}

/* ===================== exam cards ===================== */
.exam-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.exam-card {
  position: relative; text-align: left;
  padding: 18px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1.5px solid var(--line);
  box-shadow: var(--sh-1);
  transition: border-color .18s var(--e-out), box-shadow .18s var(--e-out), transform .12s var(--e-out);
}
.exam-card:hover:not(.disabled) { transform: translateY(-2px); box-shadow: var(--sh-2); }
.exam-card.selected { border-color: var(--blue-500); box-shadow: var(--sh-blue-sm); }
.exam-card .ec-badge {
  display: inline-flex; font-size: 11.5px; font-weight: 700; color: var(--blue-700);
  background: var(--blue-50); padding: 3px 9px; border-radius: var(--r-pill); margin-bottom: 10px;
}
.exam-card .ec-title { font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.exam-card .ec-sub { margin-top: 4px; font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.exam-card.disabled { opacity: .55; cursor: not-allowed; }
.exam-card .ec-check {
  position: absolute; top: 14px; right: 14px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--blue-500); color: #fff; display: none;
  place-items: center; font-size: 13px; box-shadow: var(--sh-blue-sm);
}
.exam-card.selected .ec-check { display: grid; }

/* ===================== chips ===================== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 38px; padding: 0 15px; border-radius: var(--r-pill);
  background: var(--surface); border: 1.5px solid var(--grey-200);
  color: var(--text-2); font-size: 14px; font-weight: 600; letter-spacing: -.01em;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s var(--e-out);
}
.chip:hover { border-color: var(--grey-300); background: var(--grey-50); }
.chip:active { transform: scale(.96); }
.chip.on {
  background: var(--blue-500); border-color: var(--blue-500); color: #fff;
  box-shadow: var(--sh-blue-sm);
}
.chip.on:hover { background: var(--blue-600); }
.chip.all.on { background: var(--grey-900); border-color: var(--grey-900); box-shadow: none; }

/* ===================== segmented ===================== */
.segmented {
  display: inline-flex; padding: 4px; gap: 4px;
  background: var(--grey-150); border-radius: var(--r-pill);
}
.segmented button {
  height: 36px; padding: 0 18px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 600; color: var(--text-2);
  transition: all .18s var(--e-out);
}
.segmented button.on {
  background: var(--surface); color: var(--blue-600);
  box-shadow: var(--sh-1);
}

/* ===================== mode cards ===================== */
.mode-grid { display: grid; gap: 12px; }
.mode-card {
  display: flex; align-items: center; gap: 15px; text-align: left;
  padding: 17px 18px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-1);
  transition: transform .14s var(--e-out), box-shadow .18s var(--e-out), border-color .18s var(--e-out);
}
.mode-card:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--grey-200); }
.mode-card:active { transform: translateY(0) scale(.99); }
.mode-card .mc-ic {
  flex: none; width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; font-size: 22px;
}
.mode-card .mc-ic.flash { background: linear-gradient(135deg,#FFF1D6,#FFE0A6); }
.mode-card .mc-ic.practice { background: linear-gradient(135deg,var(--blue-50),#CFE2FD); }
.mode-card .mc-ic.exam { background: linear-gradient(135deg,#E7F9F1,#C7F0DC); }
.mode-card .mc-body { flex: 1; min-width: 0; }
.mode-card .mc-title { font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.mode-card .mc-desc { margin-top: 3px; font-size: 13px; color: var(--text-3); font-weight: 500; line-height: 1.4; }
.mode-card .mc-arrow { color: var(--grey-400); font-size: 20px; }

/* summary bar (inline, above the mode cards) */
.summary {
  margin-top: 22px;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--sh-1);
}
.summary .s-count { font-weight: 800; font-size: 15px; }
.summary .s-count b { color: var(--blue-600); }
.summary .s-meta { font-size: 12.5px; color: var(--text-3); font-weight: 500; }

/* ===================== buttons ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 22px; border-radius: var(--r-sm);
  font-size: 16px; font-weight: 700; letter-spacing: -.01em;
  background: var(--grey-100); color: var(--text);
  transition: transform .1s var(--e-out), background .16s var(--e-out), box-shadow .16s var(--e-out), opacity .16s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--blue-500); color: #fff; box-shadow: var(--sh-blue-sm); }
.btn.primary:hover { background: var(--blue-600); }
.btn.ghost { background: var(--surface); border: 1.5px solid var(--grey-200); color: var(--text-2); }
.btn.ghost:hover { background: var(--grey-50); border-color: var(--grey-300); }
.btn.danger { background: var(--red-500); color: #fff; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn.sm { height: 42px; font-size: 14.5px; border-radius: var(--r-xs); padding: 0 16px; }

/* ===================== session ===================== */
.session { padding-top: 10px; }
.s-top { display: flex; align-items: center; gap: 10px; padding: 14px 2px 8px; }
.s-top .s-mode {
  font-size: 12px; font-weight: 700; color: var(--blue-700);
  background: var(--blue-50); padding: 5px 11px; border-radius: var(--r-pill);
}
.s-top .s-mode.flash { color: #9a6a00; background: #FFF3D9; }
.s-top .s-mode.exam { color: var(--green-700); background: var(--green-50); }
.s-top .s-prog { font-size: 13.5px; color: var(--text-3); font-weight: 600; }
.s-top .spacer { flex: 1; }

.pbar { height: 6px; background: var(--grey-150); border-radius: var(--r-pill); overflow: hidden; margin: 4px 2px 0; }
.pbar > i {
  display: block; height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--blue-400, var(--blue-500)), var(--blue-500));
  background: linear-gradient(90deg, #5AA0FF, var(--blue-500));
  transition: width .35s var(--e-out);
}

/* question card */
.qcard {
  margin-top: 16px; padding: 22px 20px 20px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-2);
}
.q-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tag {
  font-size: 11.5px; font-weight: 700; color: var(--text-2);
  background: var(--grey-100); padding: 4px 10px; border-radius: var(--r-pill);
}
.tag.subj { color: var(--blue-700); background: var(--blue-50); }
.q-meta .spacer { flex: 1; }
.bm-btn { font-size: 21px; color: var(--grey-300); transition: transform .18s var(--e-spring), color .15s; }
.bm-btn:hover { color: var(--amber-500); }
.bm-btn.on { color: var(--amber-500); transform: scale(1.06); }

.q-text {
  font-size: 19px; line-height: 1.55; font-weight: 600; letter-spacing: -.02em;
  color: var(--text); word-break: keep-all;
}
.q-img {
  display: block; margin: 14px auto 4px; max-width: 100%;
  border-radius: var(--r-sm); background: #fff; padding: 2px;
  /* very light frame so box/table images (which carry their own border)
     don't show a heavy double border */
  box-shadow: 0 0 0 1px var(--grey-150);
}
.q-img.full { max-width: 100%; }
.q-img.stem { margin: 2px auto 6px; max-width: 100%; }
.q-imgnote { text-align: center; font-size: 12px; color: var(--text-3); margin-top: 2px; }
/* image choices (formula / 해도도식 / 기호) */
.choice-img { display: block; max-width: 100%; max-height: 84px; height: auto; }
.choice.has-img .ctext { padding-top: 0; display: flex; align-items: center; }

/* inline math reconstructed as real text (분수·윗줄·지수) — selectable & scales
   with font size, so 문제/선지 수식이 더 이상 작은 이미지로 찌그러지지 않는다 */
.frac {
  display: inline-flex; flex-direction: column; vertical-align: middle;
  text-align: center; margin: 0 .12em; line-height: 1.05;
}
.frac > .fn { padding: 0 .35em; border-bottom: 1px solid currentColor; }
.frac > .fd { padding: 0 .35em; }
.ovl { text-decoration: overline; }
/* √ radical: the tall √ joins the vinculum (.rad border-top), and the radicand
   keeps its own 윗줄 below it — so √G̅M̄ shows two bars, like the original. */
.rad { border-top: 1px solid currentColor; padding: .16em .14em 0 .06em; }
.sq { display: inline-block; transform: scaleY(1.3); transform-origin: bottom; margin-right: -.02em; }
.ctext sup, .ctext sub, .q-text sup, .q-text sub { font-size: .72em; }

/* choices */
.choices { display: grid; gap: 10px; margin-top: 20px; }
.choice {
  display: flex; align-items: flex-start; gap: 13px; text-align: left;
  padding: 15px 16px; border-radius: var(--r-sm);
  background: var(--surface); border: 1.5px solid var(--grey-200);
  font-size: 15.5px; line-height: 1.5; font-weight: 500; color: var(--text);
  transition: border-color .15s var(--e-out), background .15s var(--e-out),
              box-shadow .15s var(--e-out), transform .08s var(--e-out);
}
.choice:hover:not(.locked) { border-color: var(--blue-300); background: var(--blue-50); }
.choice:active:not(.locked) { transform: scale(.99); }
.choice .mark {
  flex: none; width: 27px; height: 27px; border-radius: 9px;
  background: var(--grey-100); color: var(--text-2);
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
  transition: all .15s var(--e-out);
}
.choice .ctext { flex: 1; padding-top: 2px; word-break: keep-all; }
.choice.locked { cursor: default; }

.choice.correct {
  border-color: var(--green-500); background: var(--green-50);
  box-shadow: 0 0 0 1px var(--green-500) inset;
}
.choice.correct .mark { background: var(--green-500); color: #fff; }
.choice.wrong {
  border-color: var(--red-500); background: var(--red-50);
  box-shadow: 0 0 0 1px var(--red-500) inset;
  animation: shake .4s var(--e-out);
}
.choice.wrong .mark { background: var(--red-500); color: #fff; }
.choice.selected { border-color: var(--blue-500); background: var(--blue-50); box-shadow: 0 0 0 1px var(--blue-500) inset; }
.choice.selected .mark { background: var(--blue-500); color: #fff; }
.choice.dimmed { opacity: .5; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

/* verdict line under choices (practice/flash) */
.verdict { margin-top: 16px; display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 14.5px; }
.verdict.ok { color: var(--green-700); }
.verdict.no { color: var(--red-600); }
.verdict .v-ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; }
.verdict.ok .v-ic { background: var(--green-500); }
.verdict.no .v-ic { background: var(--red-500); }

/* fixed nav footer — always pinned to the bottom of the viewport so the
   이전/다음 buttons never move regardless of question length */
.s-nav-fixed {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(242,244,246,0), var(--bg) 42%);
  pointer-events: none;
}
.s-nav-inner {
  max-width: 760px; margin: 0 auto;
  display: flex; gap: 10px; pointer-events: auto;
}
.s-nav-inner .btn { flex: 1; box-shadow: var(--sh-1); }
.s-nav-inner .btn.primary { box-shadow: var(--sh-blue-sm); }
.s-nav-inner .btn.narrow { flex: 0 0 auto; min-width: 58px; padding: 0 14px; }
/* leave room so content isn't hidden behind the fixed bar */
.session { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }

/* question card enter animation */
.qcard.enter { animation: qin .32s var(--e-out); }
@keyframes qin { from { opacity: 0; transform: translateY(10px) scale(.995); } to { opacity: 1; transform: none; } }
.qcard.enter-rev { animation: qinrev .32s var(--e-out); }
@keyframes qinrev { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ===================== results ===================== */
.result-hero {
  margin-top: 18px; padding: 30px 22px; text-align: center;
  background: linear-gradient(160deg, var(--blue-600), var(--blue-500));
  border-radius: var(--r-lg); color: #fff; box-shadow: var(--sh-blue);
}
.result-hero .rh-label { font-size: 14px; font-weight: 600; opacity: .9; }
.result-hero .rh-score { font-size: 54px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; margin: 6px 0 2px; }
.result-hero .rh-score small { font-size: 22px; font-weight: 700; opacity: .8; }
.result-hero .rh-sub { font-size: 14.5px; font-weight: 600; opacity: .95; }

.ring-wrap { display: flex; justify-content: center; gap: 26px; margin-top: 18px; }
.subj-bars { margin-top: 20px; display: grid; gap: 12px; }
.subj-row { display: grid; grid-template-columns: 64px 1fr 52px; align-items: center; gap: 12px; }
.subj-row .sr-name { font-size: 13.5px; font-weight: 700; color: var(--text-2); }
.subj-row .sr-track { height: 9px; background: var(--grey-150); border-radius: var(--r-pill); overflow: hidden; }
.subj-row .sr-fill { height: 100%; border-radius: var(--r-pill); background: var(--blue-500); transition: width .6s var(--e-out); }
.subj-row .sr-val { font-size: 13px; font-weight: 700; color: var(--text-3); text-align: right; }

.review-list { margin-top: 14px; display: grid; gap: 8px; }
.rev-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  text-align: left; transition: background .14s, box-shadow .14s;
}
.rev-item:hover { box-shadow: var(--sh-1); }
.rev-item .ri-ic { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; }
.rev-item .ri-ic.ok { background: var(--green-500); }
.rev-item .ri-ic.no { background: var(--red-500); }
.rev-item .ri-num { font-size: 13px; font-weight: 700; color: var(--text-3); flex: none; }
.rev-item .ri-q { flex: 1; min-width: 0; font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

/* ===================== empty / loading ===================== */
.empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty .em-ic { font-size: 40px; margin-bottom: 12px; }
.empty .em-title { font-size: 16px; font-weight: 700; color: var(--text-2); }
.empty .em-sub { margin-top: 6px; font-size: 13.5px; }

/* ===================== toast ===================== */
#toast-host {
  position: fixed; left: 0; right: 0; bottom: 22px; z-index: 80;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 16px;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  max-width: 440px; width: max-content;
  padding: 12px 14px 12px 16px; border-radius: var(--r-sm);
  background: var(--grey-900); color: #fff; box-shadow: var(--sh-3);
  font-size: 14px; font-weight: 600;
  animation: toastin .3s var(--e-spring);
}
.toast.out { animation: toastout .25s var(--e-out) forwards; }
.toast .t-act {
  color: #8FC0FF; font-weight: 700; padding: 6px 10px; margin: -4px -2px -4px 4px;
  border-radius: var(--r-xs); white-space: nowrap;
}
.toast .t-act:hover { background: rgba(255,255,255,.1); }
@keyframes toastin { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateY(10px); } }

/* ===================== dialog ===================== */
.scrim {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(23,31,40,.42); backdrop-filter: blur(2px);
  display: grid; place-items: end center;
  animation: fade .2s var(--e-out);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 760px;
  background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  box-shadow: var(--sh-3); animation: sheetin .28s var(--e-out);
}
@keyframes sheetin { from { transform: translateY(100%); } to { transform: none; } }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--grey-200); margin: 6px auto 14px; }
.sheet h3 { margin: 0 0 6px; font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.sheet .sheet-body { margin: 0 0 18px; color: var(--text-3); font-size: 14px; line-height: 1.5; max-height: 60vh; overflow: auto; }
.sheet .sheet-body:empty { display: none; }
.sheet .sheet-actions { display: flex; gap: 10px; }
.sheet .sheet-actions .btn { flex: 1; }

/* ===================== dashboard ===================== */
.dash { padding: 16px; }
.dash-stats { display: grid; grid-template-columns: repeat(3, 1fr); }
.dash-stats .ds { text-align: center; padding: 4px 0; position: relative; }
.dash-stats .ds + .ds::before {
  content: ""; position: absolute; left: 0; top: 14%; height: 72%; width: 1px; background: var(--line);
}
.ds-v { font-size: 26px; font-weight: 800; letter-spacing: -.03em; color: var(--text); }
.ds-v small { font-size: 15px; font-weight: 700; color: var(--text-3); }
.ds-l { margin-top: 3px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.quick-chips { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.qchip {
  height: 36px; padding: 0 13px; border-radius: var(--r-pill);
  background: var(--grey-100); color: var(--text-2); font-size: 13.5px; font-weight: 700;
  transition: all .15s var(--e-out);
}
.qchip:hover:not([disabled]) { background: var(--grey-150); }
.qchip:active { transform: scale(.96); }
.qchip.on { background: var(--blue-50); color: var(--blue-700); box-shadow: 0 0 0 1.5px var(--blue-100) inset; }
.qchip[disabled] { opacity: .4; cursor: default; }
.empty-dash { display: flex; align-items: center; gap: 14px; padding: 18px 16px; }
.empty-dash .ed-ic { font-size: 28px; }
.empty-dash .ed-t { font-size: 15px; font-weight: 700; }
.empty-dash .ed-s { margin-top: 3px; font-size: 12.5px; color: var(--text-3); font-weight: 500; }

/* scope card */
.scope-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }

/* resume banner */
.resume {
  display: flex; align-items: center; gap: 12px; margin: 4px 0 2px;
  padding: 14px 14px 14px 16px; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  color: #fff; box-shadow: var(--sh-blue-sm);
}
.resume .rs-ic { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 14px; }
.resume .rs-body { flex: 1; min-width: 0; }
.resume .rs-t { font-size: 15px; font-weight: 800; letter-spacing: -.02em; }
.resume .rs-s { font-size: 12.5px; opacity: .92; font-weight: 600; margin-top: 1px; }
.resume .btn.primary { background: #fff; color: var(--blue-700); box-shadow: none; }
.resume .iconbtn { color: rgba(255,255,255,.85); }
.resume .iconbtn:hover { background: rgba(255,255,255,.15); color: #fff; }

/* toggle row + switch */
.toggle-row { display: flex; align-items: center; gap: 14px; padding: 4px 2px; }
.toggle-row > div:first-child { flex: 1; }
.tr-t { font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.tr-s { font-size: 12.5px; color: var(--text-3); font-weight: 500; margin-top: 2px; }
.switch {
  width: 50px; height: 30px; border-radius: var(--r-pill); background: var(--grey-300);
  position: relative; transition: background .2s var(--e-out); flex: none;
}
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: transform .2s var(--e-spring); }
.switch.on { background: var(--blue-500); }
.switch.on i { transform: translateX(20px); }

/* session timer */
.s-timer {
  font-size: 13px; font-weight: 800; color: var(--blue-700); background: var(--blue-50);
  padding: 4px 10px; border-radius: var(--r-pill); font-variant-numeric: tabular-nums;
}

/* exam question grid */
.qgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.qg-cell {
  aspect-ratio: 1; border-radius: var(--r-xs); background: var(--grey-100);
  color: var(--text-2); font-size: 14px; font-weight: 700;
  display: grid; place-items: center; transition: all .14s var(--e-out);
}
.qg-cell:hover { background: var(--grey-150); }
.qg-cell.done { background: var(--blue-500); color: #fff; }
.qg-cell.cur { box-shadow: 0 0 0 2.5px var(--blue-500) inset; color: var(--blue-700); background: var(--blue-50); }
.qg-cell.cur.done { color: #fff; background: var(--blue-600); }

/* ===================== AI 풀이 (문제 카드와 분리된 별도 카드) ===================== */
.ai-card { margin-top: 14px; }
.ai-card.ai-open {
  padding: 16px 18px 14px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-1);
  animation: qin .28s var(--e-out);
}
.ai-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; border-radius: var(--r-sm);
  background: linear-gradient(135deg, #F0F6FF, #E6EEFF);
  border: 1.5px solid var(--blue-100); color: var(--blue-700);
  font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  transition: transform .1s var(--e-out), box-shadow .16s var(--e-out), background .16s;
}
.ai-btn:hover { box-shadow: var(--sh-blue-sm); background: linear-gradient(135deg, #EAF2FF, #DCE8FF); }
.ai-btn:active { transform: scale(.99); }
.ai-btn .ai-hint { color: var(--blue-300); font-weight: 600; font-size: 13px; }

.ai-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; row-gap: 9px; font-size: 15px; font-weight: 800; letter-spacing: -.02em; color: var(--grey-900); margin-bottom: 12px; }
.ai-badge { font-size: 11px; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--blue-500), var(--blue-700)); padding: 2px 8px; border-radius: var(--r-pill); letter-spacing: .02em; }
.ai-title { margin-right: 2px; }

/* 모델 선택 세그먼트 (Toss/Fluent2 톤: 둥근 트랙 + 선택 시 흰 칩이 살짝 떠오름) */
.ai-model-seg {
  margin-left: auto; display: inline-flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: var(--r-pill);
  background: var(--grey-100); border: 1px solid var(--line);
}
.ai-model-pill {
  appearance: none; border: 0; cursor: pointer; white-space: nowrap;
  padding: 5px 11px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 700; letter-spacing: -.01em;
  color: var(--text-3); background: transparent;
  transition: color .15s var(--e-out), background .18s var(--e-out), box-shadow .18s var(--e-out), transform .1s var(--e-out);
}
.ai-model-pill:hover { color: var(--text-2); }
.ai-model-pill:active { transform: scale(.96); }
.ai-model-pill.on { color: var(--blue-700); background: var(--surface); box-shadow: var(--sh-1); }
.ai-model-pill:focus-visible { outline: 2px solid var(--blue-300); outline-offset: 1px; }

@media (max-width: 420px) {
  .ai-model-seg { margin-left: 0; width: 100%; justify-content: space-between; }
  .ai-model-pill { flex: 1; padding: 6px 6px; font-size: 11.5px; text-align: center; }
}
.ai-panel { min-height: 80px; }
.ai-loading { display: flex; align-items: center; gap: 14px; padding: 26px 6px; color: var(--text-2); font-weight: 600; }
.ai-loading small { color: var(--text-3); font-weight: 500; }
.spinner {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 3px solid var(--blue-100); border-top-color: var(--blue-500);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ai-content { color: var(--text); font-size: 15px; line-height: 1.68; word-break: keep-all; }
.ai-content h4 {
  margin: 18px 0 8px; font-size: 15.5px; font-weight: 800; letter-spacing: -.02em; color: var(--grey-900);
}
.ai-content h4:first-child { margin-top: 2px; }
.ai-content p { margin: 8px 0; color: var(--text-2); }
.ai-content ul { margin: 6px 0; padding-left: 4px; list-style: none; }
.ai-content li { position: relative; padding-left: 16px; margin: 5px 0; color: var(--text-2); }
.ai-content li::before { content: "·"; position: absolute; left: 4px; color: var(--blue-500); font-weight: 800; }
.ai-content strong { color: var(--grey-900); font-weight: 700; }
.ai-content code { background: var(--grey-100); padding: 1px 6px; border-radius: 6px; font-size: 13px; font-family: ui-monospace, monospace; }

.ai-foot { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.ai-by { font-size: 12px; color: var(--grey-400); font-weight: 500; }
.ai-model-tag { display: inline-block; padding: 1px 7px; border-radius: var(--r-pill); background: #EAF2FF; color: var(--blue-700); font-size: 11.5px; font-weight: 700; }
.ai-err { padding: 18px; background: var(--red-50); color: var(--red-600); border-radius: var(--r-sm); font-weight: 600; font-size: 14px; line-height: 1.5; }
.ai-moved {
  display: flex; align-items: flex-start; gap: 13px; padding: 18px;
  border: 1px solid var(--blue-100); border-radius: var(--r-md);
  background: linear-gradient(145deg, #F7FAFF, #EEF5FF);
}
.ai-moved-mark {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 11px; color: #fff; background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  box-shadow: var(--sh-blue-sm); font-size: 11px; font-weight: 900; letter-spacing: .03em;
}
.ai-moved-copy { min-width: 0; }
.ai-moved-copy strong { display: block; color: var(--grey-900); font-size: 15px; line-height: 1.45; letter-spacing: -.02em; }
.ai-moved-copy p { margin: 6px 0 14px; color: var(--text-2); font-size: 13.5px; line-height: 1.55; word-break: keep-all; }
.ai-moved-action { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; }
.ai-new-link { text-decoration: none; }

@media (max-width: 480px) {
  .ai-moved { padding: 16px; }
  .ai-moved-action { width: 100%; justify-content: center; }
}

/* utility */
.muted { color: var(--text-3); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.hide { display: none !important; }

@media (max-width: 480px) {
  .page-head h1 { font-size: 23px; }
  .exam-grid { grid-template-columns: 1fr; }
  .q-text { font-size: 18px; }
  .qgrid { grid-template-columns: repeat(5, 1fr); }
  .ds-v { font-size: 23px; }
  .segmented button { padding: 0 14px; }
}
