/* 매터픽과 같은 폰트 파일을 그대로 참조한다(같은 오리진의 /fonts에서 서빙됨) —
   한글은 KoPubWorld Dotum, 영문·숫자는 D2Coding. */
@font-face {
  font-family: "KoPubWorld Dotum";
  src: url("/fonts/kopub-world-dotum/KoPubWorld-Dotum-Medium.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  /* 매터픽 원본 범위(U+00A0-10FFFF)는 화살표/도형/이모지 블록까지 이 폰트에
     떠넘겨서, 정작 그 글자들이 파일 안에 없어 깨지는 원인이 됐다(unicode-range가
     맞으면 그 폰트로 확정되고, 없으면 다음 폰트로 안 넘어가고 tofu가 뜬다).
     한글에 실제로 쓰는 범위로 좁혀서 나머지는 뒤 폰트(D2Coding/시스템 모노스페이스)로
     자연스럽게 넘어가게 한다. */
  unicode-range: U+0020-002F, U+003A-0040, U+005B-0060, U+007B-007E, U+00A0-00FF,
    U+2000-206F, U+3000-303F, U+3130-318F, U+AC00-D7A3;
}

@font-face {
  font-family: "D2Coding Latin";
  src: url("/fonts/D2Coding-Regular.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0030-0039, U+0041-005A, U+0061-007A;
}

@font-face {
  font-family: "D2Coding";
  src: url("/fonts/D2Coding-Regular.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* 매터픽처럼 어두운 배경 + 절제된 모노톤을 기본으로 한다. 초록은 포인트 컬러
   하나로만 제한해서 쓴다(accent = done, 둘을 같은 색으로 묶어 예외 색을 하나로
   줄인다). OS가 밝은 테마를 쓰면 예전에 정한 흰색/무채색 라이트 테마로 돌아간다
   — "라이트는 무채색이 낫다"던 피드백은 라이트 테마 자체에는 여전히 유효하다. */
:root {
  color-scheme: dark light;
  /* sticky 요소가 여럿(header/exam-bar)일 때 서로 겹치지 않도록 헤더 높이를
     변수로 고정해서 exam-bar의 top 계산에 그대로 재사용한다. */
  --header-h: 49px;
  --bg: #0c0d0f;
  --surface: #131417;
  --text: #e6e7e9;
  /* 제목/라벨은 --text(밝음)로, 길게 읽는 본문은 --text-dim으로 한 단계 낮춰서
     눈이 덜 피로하고 위계가 보이게 한다. --muted는 그보다 더 작은 메타 정보용. */
  --text-dim: #b7bac0;
  --muted: #8b8f96;
  --border: #303339;
  /* 매터픽이 실제 쓰는 초록(그 앱의 --fg)을 그대로 가져온다 — 쨍한 비비드 그린
     대신 절제된 세이지 톤. accent(상호작용)와 done(완료)은 의미가 달라서
     같은 계열이지만 톤을 살짝 구분한다(매터픽의 --fg vs --fg-bright) —
     "색을 억지로 하나로 통일하지 않는다". error는 둘과 확실히 다른 색으로 둔다. */
  --accent: #7ea87e;
  --accent-text: #0b120b;
  --done: #a3c9a3;
  --error: #e5534b;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f7f8;
    --surface: #ffffff;
    --text: #16171a;
    --text-dim: #46484d;
    --muted: #6b6f76;
    --border: #e3e4e7;
    --accent: #2f3237;
    --accent-text: #ffffff;
    --done: #2f9e5f;
    --error: #d1453d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "KoPubWorld Dotum", "D2Coding Latin", "Roboto Mono", "Noto Sans Mono",
    "Noto Sans Mono CJK KR", "Noto Sans Mono CJK", "DejaVu Sans Mono", "Cascadia Mono",
    Consolas, ui-monospace, monospace;
  font-variant-ligatures: none;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

/* 매터픽처럼 화면을 큼직한 타이포/장식으로 채우지 않고 밀도 있게. */
h2 { font-size: 19px; margin: 2px 0 10px; }

.app-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  min-height: var(--header-h);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-header .brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.app-header .top-nav a {
  margin-left: 14px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.app-header .top-nav a:hover { color: var(--accent); }
.app-header .top-nav a[aria-current="page"] { color: var(--accent); font-weight: 700; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Matterpeek으로 돌아가는 링크. 설정 아이콘과 같은 모양으로 헤더에 붙는다. */
.back-to-peek {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  text-decoration: none;
  font-size: 15px;
  overflow: hidden;
}
.back-to-peek img { width: 20px; height: 20px; border-radius: 2px; }

.settings-gear {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  height: 32px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  line-height: 1;
  position: relative;
  top: 1px;
}
.settings-gear:hover { color: var(--accent); }

.profile-badge {
  display: flex;
  align-items: center;
  margin-left: 0;
  height: 32px;
  min-height: 32px;
  background: none;
  border: none;
  padding: 0 6px;
  font-size: 12px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
}
.profile-badge:hover { color: var(--accent); }

.profile-gate {
  max-width: 360px;
  margin: 32px auto;
  text-align: center;
}

.profile-choices {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.profile-choices .profile-btn { flex: 1; padding: 12px; font-size: 15px; }

.brand-bar {
  height: 3px;
  background: var(--accent);
  opacity: 0.5;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px;
}

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px;
  margin-bottom: 12px;
}

.hero-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-chip {
  flex-shrink: 0;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 13px;
  border-radius: 2px;
  padding: 5px 10px;
}

.hero-mid { flex: 1; min-width: 0; }

.level-title { font-weight: 700; }

.xp-text {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.streak-chip {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.xp-bar { margin-top: 10px; }

/* 카드(.today-cta) 자체가 이미 accent 테두리로 "이게 primary"라고 말하고
   있어서, 버튼까지 테두리를 겹치면 좁은 화면에서 테두리 두 겹이 붙어 답답해
   보인다 — 버튼은 flat하게 두고 카드 쪽 테두리 하나로만 신호를 준다. */
.quest-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 7px 0;
  border: none;
  background: none;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}
.quest-btn::before { content: "[ "; }
.quest-btn::after { content: " ]"; }
.quest-btn:hover { color: var(--text); }

.domain-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--domain-color, var(--accent));
  border-radius: 2px;
  padding: 10px 12px;
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text);
  transition: transform .12s ease;
}

.domain-card:active { transform: scale(0.98); }

.domain-icon {
  flex-shrink: 0;
  font-size: 20px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--domain-color, var(--accent)) 18%, transparent);
}

.domain-body { flex: 1; min-width: 0; }

.domain-card .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.domain-card .weight {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.trophy {
  margin-left: 6px;
  font-weight: 600;
}

.intro-badge {
  color: var(--accent);
  font-weight: 700;
}

.domain-clear-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--done);
  border-radius: 2px;
  padding: 8px 10px;
  font-size: 13px;
}

.progress-bar {
  height: 5px;
  border-radius: 2px;
  background: var(--border);
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar > div {
  height: 100%;
  background: var(--accent);
}

.progress-text {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.topic-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 9px 10px;
  margin-bottom: 6px;
  text-decoration: none;
  color: var(--text);
}

.topic-row .check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.topic-row.done .check {
  background: var(--done);
  border-color: var(--done);
}

.topic-row:hover .check {
  border-color: var(--domain-color, var(--accent));
}

.back-link {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.course-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.course-nav-btn {
  flex: 1;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 4px 2px;
}

.course-nav-btn:last-child { text-align: right; }

.course-nav-btn.disabled { color: var(--muted); }

.course-nav-count {
  flex: none;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
.course-nav-count:hover { color: var(--accent); }

.toc-domain-count { color: var(--muted); font-weight: 400; font-size: 12px; }
.toc-row.current { border-color: var(--accent); }
.toc-here {
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
}

/* 배지/색 없이 아주 작은 텍스트로만 core/support/background를 표시한다. */
.toc-trailing {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toc-rel { font-size: 11px; color: var(--muted); }

.toc-filter {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 12px;
}
#toc-list.core-only .toc-row:not([data-rel="core"]) { display: none; }

.key-points {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 10px 12px;
  margin: 10px 0;
  color: var(--text-dim);
}
.key-points strong { color: var(--text); }

.key-points li { margin-bottom: 6px; }

.docs-links a {
  display: block;
  margin: 4px 0;
  padding: 6px 0;
  border: none;
  background: none;
  text-decoration: none;
  font-size: 13px;
}
.docs-link-label { color: var(--accent); }
.docs-link-label::before { content: "[ "; }
.docs-link-label::after { content: " ]"; }
.docs-links a:hover .docs-link-label { color: var(--text); }
.docs-link-url {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-family: "D2Coding", ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}

/* 매터픽 스타일 — 배경/테두리 없이 "[ 텍스트 ]" 표기 자체가 버튼이다. */
/* 화면마다 "다음 진행 행동"은 이거 하나뿐이라는 걸 보여주는 유일한 테두리다 —
   toggle-done/link-btn/choice-btn 등 나머지 버튼은 계속 테두리 없이 flat하게
   둬서, 이 border 하나가 진짜 눈에 띄게 한다(action hierarchy). */
/* 테두리 박스가 좁은 화면에서 계속 부담스럽다는 피드백 — 박스 대신 굵기+색만으로
   primary를 구분한다(완전 flat, 다른 버튼들과 같은 언어). */
button.primary {
  background: none;
  border: none;
  color: var(--accent);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
button.primary::before { content: "[ "; }
button.primary::after { content: " ]"; }
button.primary:hover:not(:disabled) { color: var(--text); }
button.primary:disabled { color: var(--muted); cursor: default; }

button.toggle-done {
  background: none;
  border: none;
  color: var(--muted);
  border-radius: 0;
  padding: 7px 12px;
  cursor: pointer;
}
button.toggle-done::before { content: "[ "; }
button.toggle-done::after { content: " ]"; }
button.toggle-done:hover { color: var(--text); }

button.toggle-done.is-done {
  color: var(--done);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.confetti-piece {
  position: fixed;
  font-size: 20px;
  pointer-events: none;
  z-index: 9999;
  animation: confetti-burst 900ms ease-out forwards;
}

@keyframes confetti-burst {
  0% { transform: translate(0, 0) scale(0.6); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.1); opacity: 0; }
}

.settings-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px;
  margin-bottom: 8px;
}

.settings-block p { color: var(--muted); font-size: 13px; }

/* ---------- Reconciliation dashboard ---------- */

.reconcile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px;
  margin-bottom: 12px;
}

.reconcile-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.desired-state { font-size: 18px; font-weight: 700; margin-top: 4px; }

.ready-pct {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
}

.actual-list { margin-top: 8px; }

.actual-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 12px;
}

.actual-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actual-pct { font-weight: 700; white-space: nowrap; }

.queue-list { margin-top: 8px; }

.queue-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  margin-bottom: 6px;
  text-decoration: none;
  color: var(--text);
  background: var(--bg);
}

.queue-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}

.queue-title { font-size: 13px; }
.queue-empty { color: var(--muted); font-size: 13px; }

/* ---------- Breadcrumb / Zoom Out / Concept Map ---------- */

.breadcrumb {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.breadcrumb .crumb {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumb .crumb.current { color: var(--text); font-weight: 600; }
.breadcrumb .crumb:hover { color: var(--accent); }
.crumb-sep { margin: 0 4px; }

.zoom-out {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 2px;
  padding: 8px 10px;
  margin: 10px 0;
  font-size: 12px;
  color: var(--text-dim);
}

.zoom-out summary { cursor: pointer; font-weight: 600; color: var(--text); }

.more-detail, .simplify-box {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 2px;
  padding: 8px 10px;
  margin: 10px 0;
  font-size: 13px;
  color: var(--text-dim);
}
.more-detail summary, .simplify-box summary { cursor: pointer; font-weight: 600; color: var(--text); }
.more-detail > *:not(summary) { margin-top: 8px; }

.entry-question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.now-only-this {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  padding: 2px 0 6px;
}

.practice-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  padding: 9px 10px;
  margin: 10px 0;
}
.practice-link {
  display: block;
  margin-top: 6px;
  padding: 7px 9px;
  border-radius: 0;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.practice-link::before { content: "[ "; }
.practice-link::after { content: " ]"; }
.practice-link:hover { border-color: var(--accent); }
.practice-link.done { color: var(--done); }

.check-question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 9px 10px;
  font-size: 13px;
  margin-top: 10px;
}
.check-question summary { cursor: pointer; }
.check-question summary::after { content: " (눌러서 정답 보기)"; color: var(--muted); font-size: 12px; }
.check-question[open] summary::after { content: ""; }
.check-question p { margin: 10px 0 0; padding-top: 10px; border-top: 1px dashed var(--border); color: var(--text-dim); }

/* ---------- Beginner Entry Layer ---------- */

.beginner-hero { margin-bottom: 8px; }

.beginner-umbrella {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
}

.begin-func-list { display: flex; flex-direction: column; gap: 8px; }

.begin-func-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--domain-color, var(--accent));
  border-radius: 2px;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text);
}

.begin-func-icon { font-size: 20px; flex-shrink: 0; }
.begin-func-body p { margin: 4px 0; color: var(--muted); font-size: 13px; }
.begin-func-progress { font-size: 12px; color: var(--muted); }

.beginner-footer {
  text-align: center;
  font-size: 12px;
  margin-top: 14px;
}
.beginner-footer a { color: var(--accent); text-decoration: none; }

.beginner-map-branch {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 9px 12px;
  margin-bottom: 8px;
}
.beginner-map-branch summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.beginner-map-question { color: var(--muted); font-size: 13px; margin: 8px 0; }
.beginner-map-topic {
  display: block;
  padding: 5px 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  opacity: 0.55;
}
.beginner-map-topic.done { color: var(--done); opacity: 1; font-weight: 600; }

.siblings-box, .rel-box, .compare-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 9px 10px;
  margin: 10px 0;
  font-size: 12px;
  color: var(--text-dim);
}

.siblings-box ul { margin: 6px 0 0; padding-left: 18px; }
.siblings-box li { margin-bottom: 4px; }
.siblings-box b { color: var(--text); }

.rel-chain { margin-top: 4px; }
.rel-verb { color: var(--accent); font-weight: 600; }

.compare-table table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 12px; }
.compare-table th, .compare-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.compare-note { color: var(--muted); font-size: 12px; margin-top: 6px; }

.metaphor-box {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 2px;
  padding: 8px 10px;
  font-size: 12px;
  margin: 8px 0;
  color: var(--text-dim);
}
.metaphor-box b { color: var(--text); }

.cka-map-note {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0;
}
.cka-map-note a { color: var(--accent); text-decoration: none; }

.concept-children { margin-top: 8px; }

.concept-child-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  margin-bottom: 6px;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
}

.concept-child-row .progress-bar { flex-shrink: 0; margin-top: 0; }
.mastery-pct { font-size: 12px; color: var(--muted); font-weight: 700; }

/* ---------- Challenges ---------- */

.challenge-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.challenge-context { color: var(--muted); font-size: 13px; }
.concept-path { font-size: 12px; color: var(--muted); margin: 8px 0; }
.diff-stars { margin-left: auto; color: var(--accent); font-size: 12px; }

.choice-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }

.choice-btn {
  text-align: left;
  padding: 9px 10px;
  border-radius: 0;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.choice-btn::before { content: "[ "; }
.choice-btn::after { content: " ]"; }
.choice-btn:hover:not(:disabled) { border-color: var(--accent); }

.choice-btn:disabled { cursor: default; opacity: .8; }
/* 정답/오답을 색으로만 구분하지 않는다 — ✓/✗ 표시를 같이 준다(색맹 접근성 + 신호 이중화). */
.choice-btn.choice-correct { border-color: var(--done); color: var(--done); }
.choice-btn.choice-correct::after { content: " · ✓ ]"; }
.choice-btn.choice-wrong { border-color: var(--error); color: var(--error); }
.choice-btn.choice-wrong::after { content: " · ✗ ]"; }

.cmd-input {
  width: 100%;
  padding: 9px 10px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: "D2Coding", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  margin-top: 6px;
}

.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 9px 10px;
  font-family: "D2Coding", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  overflow-x: auto;
  white-space: pre;
}

.solution-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 10px;
  margin-top: 10px;
}

.solution-row { margin-top: 10px; }
.solution-key { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.solution-val { font-size: 13px; margin-top: 2px; color: var(--text-dim); }
code {
  font-family: "D2Coding", ui-monospace, SFMono-Regular, Menlo, monospace;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 0.92em;
}
.solution-val code { background: none; padding: 0; }

.gloss-term {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}

.gloss-popover {
  position: fixed;
  z-index: 200;
  max-width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
}
.gloss-popover-term {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.gloss-popover-def { color: var(--text); }

.hints-box { margin-top: 10px; }
.hint-line { font-size: 13px; color: var(--muted); margin: 4px 0; }
.self-report { font-size: 13px; color: var(--muted); margin-top: 12px; }

.incident-step .label { margin-bottom: 6px; }
.result-text { font-size: 13px; margin: 8px 0; }

.exam-bar {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 7px 10px;
  margin-bottom: 8px;
  position: sticky;
  /* sticky app-header 바로 아래에 붙게 — 헤더 높이(--header-h)만큼 내려서
     겹치지 않게 한다. */
  top: calc(env(safe-area-inset-top, 0px) + var(--header-h) + 4px);
  z-index: 20;
}

/* ---------- Mobile bottom navigation (section 25) ---------- */

.bottom-nav {
  display: none;
}

@media (max-width: 640px) {
  .app-header .top-nav { display: none; }
  .bottom-nav {
    display: flex;
    justify-content: space-around;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    z-index: 40;
  }
  .bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--muted);
    text-decoration: none;
    font-size: 11px;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    border-radius: 2px;
  }
  .bottom-nav a[aria-current="page"] { color: var(--accent); font-weight: 700; }
  main { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- Level line / tier labels / today CTA ---------- */

.level-line {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 4px;
}

.tier-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 12px 0 5px;
}

.beginner-umbrella-mini {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 10px;
}

/* 홈에서 유일한 primary progression 카드 — 다른 info-box와 같은 회색 테두리가
   아니라 accent 테두리를 줘서 "지금 할 일은 이거 하나"가 시각적으로도 앞선다. */
.today-cta {
  display: block;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 2px;
  padding: 12px;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 12px;
}

.today-cta-label {
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
}

.today-cta-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  margin: 4px 0;
}

.today-cta-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.today-cta-done { border-left: 3px solid var(--done); }

.beginner-secondary { margin-bottom: 12px; }

/* 홈 화면의 각 정보 묶음을 배경색이 아니라 얇은 테두리 하나로 명확히 구분한다. */
.info-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px;
  margin-bottom: 12px;
}
.info-box .label { margin-bottom: 8px; }

.beginner-secondary-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  font-size: 12px;
  margin-bottom: 8px;
}
.beginner-secondary-stat { margin-left: auto; }

.beginner-secondary-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.beginner-secondary-stat { color: var(--muted); }

.begin-func-mini-list {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.begin-func-mini {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 4px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--domain-color, var(--accent));
  border-radius: 2px;
  text-decoration: none;
  background: var(--surface);
  font-size: 11px;
  color: var(--muted);
}
.begin-func-mini-label { font-size: 11px; font-weight: 600; }
.begin-func-mini-count { font-weight: 600; }

.beginner-map-next { color: var(--accent) !important; font-weight: 700 !important; opacity: 1 !important; }

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  padding: 8px;
}
.link-btn::before { content: "[ "; }
.link-btn::after { content: " ]"; }
.link-btn:hover { color: var(--text); }

/* ---------- Lesson bottom CTA ---------- */

.lesson-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
}
.lesson-next-btn { width: 100%; padding: 12px; font-size: 14px; }
.lesson-later-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.lesson-later-link:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .lesson-cta {
    position: sticky;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    padding: 10px 0 4px;
  }
}

/* ---------- Accessibility / mobile quality (section 34) ---------- */

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button, .cmd-input, input[type="text"] {
  min-height: 44px;
}

.choice-btn { min-height: 44px; }

@media (prefers-reduced-motion: reduce) {
  .confetti-piece { animation: none !important; display: none; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

.cheat-row { margin: 10px 0 14px; }
.cheat-row .code-block { margin: 0; }
.cheat-desc { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

.code-block-wrap { position: relative; }
/* pre가 가로로 길면 스크롤 전/후 어느 시점에도 글자가 버튼 밑을 지나갈 수 있어서,
   버튼을 투명하게 두면 글자와 겹쳐 보인다 — 버튼 배경을 코드 블록과 같은 색으로
   불투명하게 칠해서 뭐가 있든 깔끔히 덮게 한다. */
.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 11px;
  padding: 4px 8px;
  min-height: 28px;
  background: var(--bg);
  border: none;
  border-radius: 0;
  color: var(--muted);
  cursor: pointer;
}
.copy-btn::before { content: "[ "; }
.copy-btn::after { content: " ]"; }
.copy-btn:hover { color: var(--text); }
.code-block { line-height: 1.6; }

@media (max-width: 640px) {
  .cmd-input, .code-block { font-size: 13px; }
}

img, svg { max-width: 100%; }
[hidden] { display: none !important; }
