/* ============================================================
   모찌CBT — 흑백 미니멀 UI
   ============================================================ */

:root {
  --bg:        #ffffff;
  --bg-soft:   #f7f7f7;
  --bg-sunken: #f0f0f0;
  --fg:        #111111;
  --fg-mid:    #5a5a5a;
  --fg-dim:    #8a8a8a;
  --line:      #e3e3e3;
  --line-hard: #c9c9c9;
  --accent:    #111111;
  --accent-fg: #ffffff;
  --ok:        #10794a;
  --ok-bg:     #e9f6ef;
  --no:        #b3261e;
  --no-bg:     #fdecea;
  --shadow:    0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);

  --r:   12px;
  --r-s: 8px;
  --pad: 16px;
  --topbar-h: 52px;

  --font: -apple-system, BlinkMacSystemFont, "Pretendard Variable", Pretendard,
          system-ui, "Segoe UI", Roboto, "Malgun Gothic", "Apple SD Gothic Neo",
          "Noto Sans KR", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "D2Coding", "Nanum Gothic Coding", monospace;
}

html[data-theme="dark"] {
  --bg:        #0a0a0a;
  --bg-soft:   #151515;
  --bg-sunken: #1c1c1c;
  --fg:        #f2f2f2;
  --fg-mid:    #a8a8a8;
  --fg-dim:    #777777;
  --line:      #272727;
  --line-hard: #3d3d3d;
  --accent:    #f2f2f2;
  --accent-fg: #0a0a0a;
  --ok:        #58d59a;
  --ok-bg:     #10241b;
  --no:        #ff8a80;
  --no-bg:     #2a1615;
  --shadow:    0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body { min-height: 100dvh; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------------- topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; gap: 4px;
  padding-left: 8px; padding-right: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-title {
  flex: 1; min-width: 0;
  font-size: 15px; font-weight: 650; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-left: 6px;
}
/* 홈 — 제목 자리에 로고와 한 줄 소개를 같이 둔다 */
.topbar-title.brand {
  display: flex; align-items: center; gap: 9px;
  padding-left: 2px; overflow: visible;
}
.topbar-logo {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 10px; object-fit: cover; background: var(--bg-soft);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-name { font-size: 15.5px; font-weight: 750; }
.brand-tag {
  font-size: 11.5px; font-weight: 500; color: var(--fg-mid); letter-spacing: 0;
  overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; gap: 2px; }

.icon-btn {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 10px; color: var(--fg);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--bg-soft); }
.icon-btn:active { background: var(--bg-sunken); }
.icon-btn svg {
  width: 20px; height: 20px; fill: none;
  stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.ico-moon { display: none; }
html[data-theme="dark"] .ico-sun  { display: none; }
html[data-theme="dark"] .ico-moon { display: block; }

.quiz-progress {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--line);
}
.quiz-progress > span {
  display: block; height: 100%; width: 0%;
  background: var(--accent); transition: width .25s ease;
}

/* ---------------- layout ---------------- */
.app {
  max-width: 760px; margin: 0 auto;
  padding: 20px var(--pad) calc(96px + env(safe-area-inset-bottom));
}
.stack   { display: flex; flex-direction: column; gap: 12px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.row     { display: flex; align-items: center; gap: 8px; }
.grow    { flex: 1; min-width: 0; }

.section-title {
  font-size: 12px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--fg-dim);
  margin: 24px 0 8px;
}
.section-title:first-child { margin-top: 4px; }

.hero { margin-bottom: 4px; }
.hero h1 { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin: 0 0 2px; }
.hero p  { margin: 0; color: var(--fg-mid); font-size: 14px; }
/* 홈 인사 — 로고와 소개는 상단 바로 올라갔으므로 여기서는 인사만 크게 */
.hero p.hero-greet {
  font-size: 19px; font-weight: 700; letter-spacing: -.015em;
  color: var(--fg); margin-bottom: 2px;
}

/* ---------------- cards & buttons ---------------- */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
}
.card-soft { background: var(--bg-soft); border-color: transparent; }

.tile {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r); padding: 15px 16px;
  transition: transform .06s ease, border-color .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.tile:hover  { border-color: var(--line-hard); }
.tile:active { transform: scale(.985); }
.tile-main   { flex: 1; min-width: 0; }
.tile-title  { font-weight: 650; font-size: 15.5px; letter-spacing: -.01em; }
.tile-sub    { font-size: 13px; color: var(--fg-mid); margin-top: 2px; }
.tile-num    { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--fg-dim); }
.tile-chev   { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: var(--fg-dim); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-hard); background: var(--bg); color: var(--fg);
  border-radius: 10px; padding: 12px 18px;
  font-weight: 650; font-size: 15px; letter-spacing: -.01em;
  min-height: 46px;
  transition: transform .06s ease, opacity .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-ghost   { border-color: transparent; background: var(--bg-soft); }
.btn-quiet   { border-color: transparent; background: none; color: var(--fg-mid); font-weight: 550; }
.btn-danger  { color: var(--no); border-color: color-mix(in srgb, var(--no) 40%, transparent); }
.btn-block   { width: 100%; }
.btn-sm      { padding: 8px 12px; min-height: 36px; font-size: 13.5px; border-radius: 8px; }
/* 이모지 하나짜리 버튼 (신고) — 글자 폭에 기대지 않고 정사각으로 잡는다 */
.btn-icon    { padding: 0; width: 46px; flex: 0 0 46px; font-size: 19px; }
.btn:disabled { opacity: .4; pointer-events: none; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--bg);
  border-radius: 999px; padding: 7px 13px; font-size: 13.5px; font-weight: 550;
  color: var(--fg-mid); min-height: 34px;
  -webkit-tap-highlight-color: transparent;
}
.chip[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
}
.chip small { opacity: .6; margin-left: 4px; font-variant-numeric: tabular-nums; }
.chip:disabled { opacity: .55; cursor: default; }

.empty {
  text-align: center; padding: 48px 16px; color: var(--fg-dim);
}
.empty strong { display: block; color: var(--fg-mid); font-size: 15px; margin-bottom: 6px; }

/* ---------------- 최근에 본 시험 ---------------- */
.exam-card {
  display: block; width: 100%; text-align: left;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; transition: border-color .12s ease, transform .06s ease;
  -webkit-tap-highlight-color: transparent;
}
.exam-card:hover  { border-color: var(--line-hard); }
.exam-card:active { transform: scale(.99); }
.exam-card.current { border-color: var(--accent); }

.exam-card-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 3px; }
.exam-card-title { font-size: 16px; font-weight: 700; letter-spacing: -.015em; flex: 1; min-width: 0; }
.exam-card-pct {
  font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums;
  letter-spacing: -.03em; line-height: 1;
}
.exam-card-sub { font-size: 12.5px; color: var(--fg-dim); margin-bottom: 11px; }

.pbar {
  position: relative; height: 10px; border-radius: 999px;
  background: var(--bg-sunken); overflow: hidden;
}
.pbar > i {
  position: absolute; inset: 0 auto 0 0; display: block;
  border-radius: 999px; background: var(--accent);
  width: 0; transition: width .6s cubic-bezier(.2,.8,.3,1);
}
/* 아주 조금 풀었을 때도 막대가 보이도록 */
.pbar > i[style*="%"]:not([style*="width: 0%"]) { min-width: 6px; }
.pbar > i.ok {
  background: var(--ok); z-index: 1;
}
.pbar-legend {
  display: flex; gap: 14px; margin-top: 8px;
  font-size: 12px; color: var(--fg-dim);
}
.pbar-legend b { font-weight: 650; color: var(--fg-mid); font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.dot.a { background: var(--ok); }
.dot.b { background: var(--accent); }
.dot.c { background: var(--bg-sunken); border: 1px solid var(--line-hard); }

/* ---------------- 계정 ---------------- */
.acct {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; row-gap: 10px;
  background: var(--bg-soft); border-radius: var(--r); padding: 13px 15px;
}
/* 좁아지면 버튼을 아랫줄로 내린다 (글자가 짓눌리는 것보다 낫다) */
.acct .grow { min-width: 140px; }
.acct .btn { white-space: nowrap; margin-left: auto; }
.acct-avatar {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: var(--accent-fg);
  display: grid; place-items: center; font-weight: 750; font-size: 15px;
}
.acct-name { font-weight: 650; font-size: 14.5px; }
.acct-sub  { font-size: 12.5px; color: var(--fg-dim); }

/* 한글은 기본값으로 두면 '비회원으로 푸 / 는 중' 처럼 낱말 한가운데가 잘린다.
   keep-all 로 낱말을 지키되, 한 낱말이 정말 안 들어가면 그때만 쪼갠다. */
.acct-name, .acct-sub,
.tile-title, .tile-sub,
.exam-card-title, .exam-card-sub,
.sheet-body p, .form-hint, .set-row .grow strong, .set-row .grow small {
  word-break: keep-all;
  overflow-wrap: break-word;
}

.sheet form { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 12.5px; font-weight: 650; color: var(--fg-mid); }
.form-err {
  font-size: 13px; color: var(--no);
  background: var(--no-bg); border-radius: var(--r-s); padding: 9px 12px;
}
.form-hint { font-size: 12px; color: var(--fg-dim); line-height: 1.6; }
.form-warning { font-size: 12px; color: var(--no); line-height: 1.6; }
.report-card { border: 1px solid var(--line); border-radius: var(--r-s); padding: 12px; overflow-wrap: anywhere; }
.report-card p { white-space: pre-wrap; }

/* "또는" 구분선 */
.or-line {
  display: flex; align-items: center; gap: 12px;
  font-size: 12px; color: var(--fg-dim); margin: 2px 0;
}
.or-line::before, .or-line::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

/* ---------------- stats ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  background: var(--bg-soft); border-radius: var(--r); padding: 14px 12px; text-align: center;
}
.stat b {
  display: block; font-size: 22px; font-weight: 720;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.stat span { font-size: 12px; color: var(--fg-dim); }
/* 눌러서 그 목록으로 가는 숫자 칸 */
.stat-link {
  display: block; width: 100%; border: 1px solid transparent;
  font: inherit; color: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.stat-link:hover { border-color: var(--line); }
.stat-link:active { transform: scale(.98); }
.stat-link span { text-decoration: underline; text-underline-offset: 2px; }

/* 검색 상자 */
.search-box { margin-bottom: 12px; }
.search-box .ans-input { width: 100%; }

.bar-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.bar-label { width: 108px; flex: 0 0 108px; font-size: 13px; color: var(--fg-mid);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 7px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; }
.bar-fill  { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.bar-val   { width: 62px; flex: 0 0 62px; text-align: right; font-size: 12px;
  color: var(--fg-dim); font-variant-numeric: tabular-nums; }

/* ---------------- 관리자 ---------------- */
.q-badge.admin {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0;
}
.q-badge.warn {
  background: var(--no-bg); color: var(--no); border-color: transparent; font-weight: 650;
}

.edit-row { margin-top: 12px; }
.edit-label {
  display: block; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  color: var(--fg-dim); text-transform: uppercase; margin-bottom: 5px;
}
.edit-hint { font-size: 12px; color: var(--fg-dim); margin-top: 5px; line-height: 1.5; }
.edit-choice { display: flex; align-items: flex-start; gap: 8px; margin-top: 7px; }
.edit-choice .ans-input { flex: 1; min-width: 0; }
/* 정답 고르는 번호 단추 — 눌린 것이 정답이다 */
.edit-ans {
  width: 40px; height: 44px; flex: 0 0 40px;
  border: 1px solid var(--line-hard); border-radius: 8px; background: var(--bg);
  color: var(--fg-dim); font-weight: 700; font-variant-numeric: tabular-nums;
}
.edit-ans[aria-pressed="true"] {
  background: var(--ok); border-color: var(--ok); color: #fff;
}

/* ---------------- 모의고사 ---------------- */
/* 시험 구성 안내 */
.mock-info-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.mock-info-top b { font-size: 20px; letter-spacing: -.02em; }
.mock-info-top span { font-size: 13px; color: var(--fg-mid); }
.mock-info-topics {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--fg-mid);
}
.mock-info-topics b { color: var(--fg); font-weight: 650; margin-left: 5px; }

/* 답안지 — 어느 문항을 비워 뒀는지 한눈에 */
.omr { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.omr-cell {
  aspect-ratio: 1; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  font-size: 13px; font-variant-numeric: tabular-nums; color: var(--fg-dim);
}
.omr-cell.done { background: var(--bg-sunken); color: var(--fg); font-weight: 650; border-color: transparent; }
.omr-cell.here { border-color: var(--accent); border-width: 2px; color: var(--fg); }

/* 성적표 머리 */
.mock-head {
  text-align: center; padding: 26px 18px 22px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-soft);
}
.mock-head.pass { background: var(--ok-bg); border-color: transparent; }
.mock-head.fail { background: var(--no-bg); border-color: transparent; }
.mock-score { display: flex; align-items: baseline; justify-content: center; gap: 4px; }
.mock-score b { font-size: 52px; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.mock-score span { font-size: 17px; color: var(--fg-mid); }
.mock-head.pass .mock-score b { color: var(--ok); }
.mock-head.fail .mock-score b { color: var(--no); }
.mock-verdict { margin-top: 10px; font-size: 18px; font-weight: 750; letter-spacing: -.02em; }
.mock-reason { margin-top: 3px; font-size: 13.5px; color: var(--fg-mid); }
.mock-when { margin-top: 10px; font-size: 12px; color: var(--fg-dim); }

.mock-cheer {
  margin-top: 14px; padding: 15px 16px;
  background: var(--bg-soft); border-radius: var(--r);
}
.mock-cheer strong { display: block; font-size: 15.5px; letter-spacing: -.01em; }
.mock-cheer p { margin: 5px 0 0; font-size: 13.5px; color: var(--fg-mid); line-height: 1.6; }

/* 과락선 — 막대 안에 세로선 하나 */
.bar-track { position: relative; }
.bar-floor {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: var(--fg-dim); border-radius: 1px; opacity: .75;
}
.bar-item.is-fail .bar-fill { background: var(--no); }
.bar-item.is-fail .bar-val  { color: var(--no); font-weight: 700; }

/* 문항별 결과 */
.mock-review { display: flex; flex-direction: column; gap: 4px; }
.mock-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); font-size: 13.5px;
}
.mock-row:hover { border-color: var(--line-hard); }
.mock-no {
  width: 26px; flex: 0 0 26px; text-align: right;
  color: var(--fg-dim); font-variant-numeric: tabular-nums; font-size: 12px;
}
.mock-q { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mock-mine {
  flex: 0 0 auto; max-width: 34%; font-size: 12px; color: var(--fg-mid);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mock-mark { width: 18px; flex: 0 0 18px; text-align: center; font-weight: 700; }
.mock-row.ok   .mock-mark { color: var(--ok); }
.mock-row.no   .mock-mark { color: var(--no); }
.mock-row.no   { background: var(--no-bg); border-color: transparent; }
.mock-row.self .mock-mark { color: var(--fg-dim); }

/* 지난 성적표 */
.mock-hist {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg);
}
.mock-hist:hover { border-color: var(--line-hard); }
.mock-hist-when { font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; }
.mock-hist-score { text-align: right; flex: 0 0 auto; }
.mock-hist-score b { display: block; font-size: 21px; font-weight: 750; letter-spacing: -.02em; }
.mock-hist-score span { font-size: 11.5px; color: var(--fg-dim); }
.mock-hist.pass .mock-hist-score b { color: var(--ok); }
.mock-hist.fail .mock-hist-score b { color: var(--no); }

/* 종이꽃 — 합격했을 때만 잠깐 */
canvas.confetti {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 90;
}

/* ---------------- question ---------------- */
.q-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: 12px; color: var(--fg-dim); margin-bottom: 12px;
}
.q-badge {
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px;
  font-weight: 600; font-size: 11.5px; letter-spacing: .01em;
}
.q-badge.solid { background: var(--bg-sunken); border-color: transparent; }
.q-count { margin-left: auto; font-variant-numeric: tabular-nums; }

.q-text {
  font-size: 16.5px; line-height: 1.75; letter-spacing: -.01em;
  white-space: pre-wrap; word-break: break-word;
}
.q-text b { font-weight: 700; }
/* 원본 시험지의 밑줄 — '밑줄 친 부분' 을 묻는 문항에서 어디를 가리키는지 보여준다 */
.q-text u { text-decoration-thickness: 2px; text-underline-offset: 3px; }

.q-block { margin-top: 14px; }

/* 문제 그림 — 원본 시험지의 회로도·파형·모르스 부호.
   어두운 화면에서도 흰 배경 그림이 눈에 잘 들어오도록 판을 깔아 준다. */
.q-figure { margin: 0; }
.q-figure img {
  display: block; max-width: 100%; height: auto; margin: 0 auto;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 8px;
}

pre.code {
  margin: 0; padding: 14px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--r-s);
  font-family: var(--mono); font-size: 13px; line-height: 1.62;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  tab-size: 4;
}
pre.code .lang {
  display: block; font-family: var(--font); font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--fg-dim);
  margin-bottom: 8px;
}
pre.code code { font: inherit; }

/* 코드 색 — 편집기(VS Code) 기본 배색을 따라간다. 눈에 익은 색이라 따로 배울
   것이 없다. 나머지 화면이 흑백이므로 여기서만 색을 쓴다. */
pre.code .c-cmt  { color: #008000; font-style: italic; }
pre.code .c-str  { color: #a31515; }
pre.code .c-num  { color: #098658; }
pre.code .c-kw   { color: #0000ff; }
pre.code .c-fn   { color: #795e26; }
pre.code .c-type { color: #267f99; }
pre.code .c-meta { color: #af00db; }

html[data-theme="dark"] pre.code .c-cmt  { color: #6a9955; }
html[data-theme="dark"] pre.code .c-str  { color: #ce9178; }
html[data-theme="dark"] pre.code .c-num  { color: #b5cea8; }
html[data-theme="dark"] pre.code .c-kw   { color: #569cd6; }
html[data-theme="dark"] pre.code .c-fn   { color: #dcdcaa; }
html[data-theme="dark"] pre.code .c-type { color: #4ec9b0; }
html[data-theme="dark"] pre.code .c-meta { color: #c586c0; }

.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-s); }
table.tbl {
  border-collapse: collapse; width: 100%; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: var(--r-s);
}
table.tbl th, table.tbl td {
  border: 1px solid var(--line); padding: 8px 11px; text-align: left; white-space: nowrap;
}
table.tbl th { background: var(--bg-soft); font-weight: 650; }
.tbl-cap { font-size: 13px; font-weight: 650; margin: 12px 0 6px; }

.choices {
  background: var(--bg-soft); border-radius: var(--r-s); padding: 12px 14px;
  font-size: 14px; line-height: 1.9;
}
.choices .choices-h {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--fg-dim); margin-bottom: 4px;
}
.choices span { display: inline-block; margin-right: 14px; }

.q-note {
  font-size: 13px; color: var(--fg-mid);
  background: var(--bg-soft); border-left: 3px solid var(--line-hard);
  padding: 9px 12px; border-radius: 0 var(--r-s) var(--r-s) 0;
}

/* ---------------- 4지선다 ---------------- */
.opts { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%; text-align: left;
  background: var(--bg); border: 1.5px solid var(--line); border-radius: var(--r);
  padding: 13px 14px; font-size: 15px; line-height: 1.6;
  transition: border-color .12s ease, background .12s ease, transform .06s ease;
  -webkit-tap-highlight-color: transparent;
}
.opt:hover { border-color: var(--line-hard); }
.opt:active { transform: scale(.99); }
.opt-no {
  flex: 0 0 24px; width: 24px; height: 24px; margin-top: 1px;
  display: grid; place-items: center;
  border: 1.5px solid var(--line-hard); border-radius: 50%;
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--fg-mid);
}
.opt-txt { flex: 1; min-width: 0; word-break: break-word; }
.opt[aria-checked="true"] { border-color: var(--accent); background: var(--bg-soft); }
.opt[aria-checked="true"] .opt-no { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.opt.is-ok { border-color: var(--ok); background: var(--ok-bg); }
.opt.is-ok .opt-no { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.is-no { border-color: var(--no); background: var(--no-bg); }
.opt.is-no .opt-no { background: var(--no); border-color: var(--no); color: #fff; }
.opt.dim { opacity: .5; }
.opts.locked .opt { pointer-events: none; }

/* ---------------- answer inputs ---------------- */
.ans-list { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.ans-row { display: flex; align-items: center; gap: 10px; }
.ans-label {
  flex: 0 0 auto; min-width: 30px; text-align: center;
  font-size: 13.5px; font-weight: 700; color: var(--fg-mid);
  padding: 0 6px;
}
/* 라벨이 긴 문제는 좁은 화면에서 라벨을 위로 올린다 */
@media (max-width: 560px) {
  .ans-row.wide { flex-wrap: wrap; row-gap: 4px; }
  .ans-row.wide .ans-label { flex-basis: 100%; text-align: left; padding: 0 2px; }
  .ans-row.wide .ans-input { flex-basis: 0; }
}

.ans-input {
  flex: 1; min-width: 0;
  background: var(--bg); border: 1.5px solid var(--line-hard);
  border-radius: 10px; padding: 12px 14px;
  font-size: 16px; /* iOS 자동 확대 방지 */
  transition: border-color .12s ease;
}
.ans-input::placeholder { color: var(--fg-dim); }
.ans-input:focus { outline: none; border-color: var(--accent); }
.ans-input[readonly] { background: var(--bg-soft); }
.ans-input.is-ok { border-color: var(--ok); background: var(--ok-bg); }
.ans-input.is-no { border-color: var(--no); background: var(--no-bg); }
textarea.ans-input { resize: vertical; min-height: 96px; line-height: 1.6; font-family: var(--mono); font-size: 14px; }
.ans-mark { flex: 0 0 22px; width: 22px; text-align: center; font-size: 17px; font-weight: 700; }
.ans-mark.is-ok { color: var(--ok); }
.ans-mark.is-no { color: var(--no); }

/* ---------------- result ---------------- */
.result { margin-top: 18px; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
.result-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; font-weight: 700; font-size: 15px;
}
.result.ok .result-head { background: var(--ok-bg); color: var(--ok); }
.result.no .result-head { background: var(--no-bg); color: var(--no); }
.result.self .result-head { background: var(--bg-soft); color: var(--fg-mid); }
.result-body { padding: 14px 16px; border-top: 1px solid var(--line); }

.ans-key { display: flex; flex-direction: column; gap: 6px; }
.ans-key-row { display: flex; gap: 10px; font-size: 14.5px; align-items: baseline; }
.ans-key-row .k { flex: 0 0 auto; font-weight: 700; color: var(--fg-mid); min-width: 26px; }
.ans-key-row .v { font-weight: 650; }
.ans-alt { font-size: 12.5px; color: var(--fg-dim); margin-top: 1px; }

.exp {
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line);
  font-size: 14px; line-height: 1.78; color: var(--fg-mid);
  white-space: pre-wrap; word-break: break-word;
}
.exp-h {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--fg-dim); margin-bottom: 6px;
}

.notebook-prompt {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--r-s);
  background: var(--bg-soft); font-size: 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.notebook-prompt .grow { font-weight: 550; }

/* ---------------- action bar ---------------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.actionbar-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 8px; align-items: center; }
.kbd-hint {
  font-size: 11.5px; color: var(--fg-dim); text-align: center;
  max-width: 760px; margin: 6px auto 0;
}
.kbd {
  display: inline-block; border: 1px solid var(--line-hard); border-radius: 4px;
  padding: 0 5px; font-family: var(--mono); font-size: 10.5px; line-height: 16px;
}
@media (hover: none) { .kbd-hint { display: none; } }

/* ---------------- notebook list ---------------- */
.nb-item {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: var(--r); padding: 13px 14px;
}
.nb-main { flex: 1; min-width: 0; }
.nb-q {
  font-size: 14.5px; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.nb-meta { font-size: 12px; color: var(--fg-dim); margin-top: 5px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- sheet (modal) ---------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.42);
  animation: fade .18s ease;
}
.sheet {
  position: fixed; z-index: 100; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  background: var(--bg); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 8px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  max-height: 86dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: slideup .22s cubic-bezier(.2,.8,.3,1);
}
.sheet-handle {
  width: 38px; height: 4px; border-radius: 999px; background: var(--line-hard);
  margin: 4px auto 12px;
}
.sheet-title { font-size: 17px; font-weight: 700; margin: 0 0 14px; letter-spacing: -.01em; }
.sheet-body { display: flex; flex-direction: column; gap: 10px; }
.sheet-body p { margin: 0; font-size: 14px; color: var(--fg-mid); line-height: 1.7; }

@keyframes fade    { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideup { from { transform: translateY(14px); opacity: .4 } to { transform: none; opacity: 1 } }

/* settings rows */
.set-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: 0; }
.set-row .grow strong { display: block; font-size: 14.5px; font-weight: 650; }
.set-row .grow small { display: block; font-size: 12.5px; color: var(--fg-dim); margin-top: 1px; line-height: 1.5; }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; z-index: 200;
  left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--fg); color: var(--bg);
  padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow);
  animation: slideup .18s ease; max-width: calc(100vw - 32px); text-align: center;
}

/* ---------------- responsive ---------------- */
@media (min-width: 720px) {
  :root { --pad: 24px; }
  .app { padding-top: 28px; }
  .hero h1 { font-size: 30px; }
  .hero p.hero-greet { font-size: 22px; }
}
@media (max-width: 400px) {
  .stat b { font-size: 19px; }
  .bar-label { width: 84px; flex-basis: 84px; }
  /* 아주 좁은 화면에서는 로고를 조금 줄여 소개 문구 자리를 지킨다 */
  .topbar-logo { width: 32px; height: 32px; flex-basis: 32px; }
  .brand-tag { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .topbar, .actionbar, .kbd-hint { display: none !important; }
}

/* Imported diagrams and formulas can occur within a sentence or a choice. */
.q-inline-image {
  display: inline-block;
  max-width: 100%;
  height: auto;
  vertical-align: middle;
  background: #fff;
  border-radius: 3px;
  margin: 4px 2px;
}
.opt-txt { min-width: 0; }
.q-stem-image {
  display: block;
  margin: 12px 0;
}

.exam-search { display:block; width:100%; }
.exam-pages { display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:20px; margin:16px 0; }
