:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --ink: #1d2433;
  --ink-2: #4b5363;
  --muted: #8a909c;
  --border: #e4e1da;
  --accent: #053060;        /* 하바사 남색 */
  --accent-hover: #032244;
  --accent-soft: #e8f0f9;
  --ok: #18794e;
  --ok-soft: #eaf5ef;
  --ng: #b42318;
  --ng-soft: #fcefed;
  --gold: #b7791f;
  --gold-soft: #fbf3e4;
  --mark: #d92d20;
  --radius: 16px;
  /* 버튼 크기 기준: 모든 버튼 44px, 보기 버튼만 48px */
  --h-control: 44px;
  --h-choice: 48px;
  --r-control: 10px;
  --shadow: 0 1px 2px rgba(29, 36, 51, .06), 0 8px 24px rgba(29, 36, 51, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
svg.board, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* ── 상단 바 ── */
.appbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.appbar-inner {
  max-width: 1040px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-title { font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.brand-sub { font-size: 13px; color: var(--muted); }
.meter { width: 180px; flex: none; }
.meter-label { font-size: 12.5px; color: var(--ink-2); text-align: right; margin-bottom: 6px; font-weight: 600; }
.meter-bar { height: 6px; border-radius: 99px; background: #ebe8e1; overflow: hidden; }
.meter-bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .4s ease; }

.container { max-width: 1040px; margin: 0 auto; padding: 18px 20px 28px; }

/* ── 홈 ── 하바사 홈과 같은 틀 (머리 띠 · 주 버튼 · 2×2 타일 · 손글씨 문구) */
:root {
  --font-display: "Gowun Batang", "Nanum Myeongjo", "AppleMyungjo", serif;
  --font-hand: "Nanum Pen Script", cursive;
  --kaya: #e2b86c;          /* 비자나무 바둑판 */
  --kaya-soft: #f6ead2;
  --kaya-line: #e3cfa6;
  --slate: #17191c;         /* 흑돌 */
  --shell: #fbfaf7;         /* 백돌 */
}
.brand[role=button] { cursor: pointer; }
.home { max-width: 440px; margin: 0 auto; }
.home.show { display: block; }

.hh { margin: -18px -20px 0; padding: 24px 22px 18px; background: linear-gradient(160deg, var(--kaya-soft) 0%, #f1e2c4 100%);
  border-bottom: 1px solid var(--kaya-line); }
.hh-top { display: flex; align-items: center; gap: 18px; }
.hh-illust { width: 124px; flex: none; padding: 4px; border-radius: 10px; background: var(--kaya); box-shadow: 0 3px 10px rgba(61, 42, 18, .18); }
.hh-greet { display: flex; flex-direction: column; line-height: 1.5; }
.hh-hello { font-size: 13.5px; font-weight: 500; color: #7a5b28; }
.hh-name { font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.hh-saying { margin-top: 14px; padding: 2px 0 0 12px; border-left: 3px solid #d2a95a; min-height: 3.6em; }
.hh-saying-text { display: block; font-size: 15px; line-height: 1.6; color: #3b3326; word-break: keep-all; }
.hh-saying-ref { display: block; margin-top: 4px; font-size: 12.5px; font-weight: 600; color: #9a6c1f; }

.home-body { display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: 22px 0 8px; }
.primary-tile { display: flex; align-items: center; gap: 18px; width: 100%; padding: 22px 20px; border: 0; border-radius: 20px;
  background: linear-gradient(135deg, #1a5fa8 0%, var(--accent) 100%); color: #fff; text-align: left; cursor: pointer;
  box-shadow: 0 4px 20px rgba(5, 48, 96, .25); transition: transform .13s, box-shadow .15s; }
.primary-tile:active { transform: scale(.98); }
.pt-icon svg { width: 42px; height: 42px; display: block; }
.pt-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pt-label { font-size: 17px; font-weight: 800; }
.pt-sub { margin-top: 2px; font-size: 13px; color: rgba(255, 255, 255, .78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-chev svg { width: 22px; height: 22px; display: block; opacity: .7; stroke-width: 2.5; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 8px 18px;
  border: 0; border-radius: 16px; background: var(--surface); cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .07); transition: transform .13s, box-shadow .15s; }
.tile:active { transform: scale(.97); }
.tile-icon { color: var(--accent); display: flex; }
.tile-icon svg { width: 32px; height: 32px; }
.tile-label { font-size: 14px; font-weight: 700; }
.tile-sub { margin-top: -6px; font-size: 12px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-sub.done { color: var(--ok); }
.tile-badge { position: absolute; top: 12px; right: 12px; width: 10px; height: 10px; border-radius: 50%; background: #e5484d; border: 2px solid var(--surface); }
@media (hover: hover) {
  .primary-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(23, 25, 28, .32); }
  .tile:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 0, 0, .1); }
}
.primary-tile:focus-visible, .tile:focus-visible, .util-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.tagline { margin-top: 10px; text-align: center; font-family: var(--font-hand); font-size: 30px; color: #7a5b28; letter-spacing: .04em; }
.util-row { display: flex; justify-content: center; }
.util-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.util-btn svg { width: 15px; height: 15px; }
.font-sheet { padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.font-sheet-title { font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 10px; text-align: center; }
.font-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.font-opt { display: flex; flex-direction: column; align-items: center; gap: 2px; height: 64px; justify-content: center;
  border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.font-opt span { font-weight: 800; color: var(--ink); }
.font-opt.on { border-color: var(--slate); background: var(--surface-2); }

/* 하위 화면 공통: ‹ 홈 */
.subpage { max-width: 720px; margin: 0 auto; }
.sub-topbar { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.sub-topbar .back { margin: 0; }
.sub-title { font-size: 15px; font-weight: 800; color: var(--ink-2); }
.sub-topbar::after { content: ""; flex: 1; }

/* 놓아보기 화면 */
.free-wrap { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.free-panel { display: grid; gap: 10px; padding: 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.free-size { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.free-size .seg.on { background: var(--slate); color: #fff; border-color: var(--slate); }
.free-turn { margin: 0; font-weight: 700; }
@media (max-width: 820px) { .free-wrap { grid-template-columns: minmax(0, 1fr); } }

/* 내 기록 화면 */
.rec-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.rec-stat { padding: 14px 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); text-align: center; }
.rec-stat b { display: block; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rec-stat span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.rec-clear { width: 100%; margin-top: 16px; }

.thumb { display: block; width: 100%; height: auto; border-radius: 6px; pointer-events: none; }

@media (max-width: 560px) {
  .hh { margin: -12px -12px 0; padding: 20px 16px 16px; }
  .hh-illust { width: 112px; }
}

/* ── 문제집 안 (단원 목록) ── */
.book { max-width: 720px; margin: 0 auto; }
.back { height: 36px; padding: 0 12px 0 6px; margin: 0 0 10px; border: 0; background: none; cursor: pointer;
  font-size: 14.5px; font-weight: 700; color: var(--accent); }
.book-head { padding: 18px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 12px; }
.book-title { margin: 0 0 2px; font-size: 21px; font-weight: 800; }
.book-sub { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.units { display: grid; gap: 8px; }
.unit { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; text-align: left; }
.unit .uno { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; font-weight: 800; color: var(--ink-2); }
.unit.done .uno { background: var(--ok); border-color: var(--ok); color: #fff; }
.unit .ubody { flex: 1; min-width: 0; }
.unit .uname { font-weight: 800; font-size: 15px; }
.unit .umeta { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.unit .bar { height: 5px; }
#study .setbar .back { margin: 0; }

/* ── 문제집·단원 ── */
.setbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs { display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px; background: #e9e6df; }
.tab {
  height: 36px; padding: 0 16px; border: 0; border-radius: 9px; cursor: pointer;
  background: transparent; font-size: 14px; font-weight: 700; color: var(--ink-2);
}
.tab.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(29, 36, 51, .12); }
.unit-select {
  height: var(--h-control); min-width: 220px; padding: 0 12px; border-radius: var(--r-control);
  border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: 14px; font-weight: 600; color: var(--ink);
}

/* ── 문제 번호 ── */
.pager { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
  transition: border-color .15s, background .15s;
}
@media (hover: hover) { .pill:hover { border-color: #c9c5bb; } }
.pill .st { width: 16px; height: 16px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; }
.pill.perfect .st { background: var(--gold); }
.pill.solved .st { background: var(--ok); }
.pill.todo .st { border: 1.5px solid #c9c5bb; }
.pill.now { background: var(--ink); border-color: var(--ink); color: #fff; }
.pill.now.todo .st { border-color: rgba(255, 255, 255, .5); }

/* ── 화면 ── */
.screen { display: none; }
.screen.show { display: block; }
.layout.show { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 820px) { .layout.show { grid-template-columns: minmax(0, 1fr); gap: 16px; } }

/* ── 바둑판 ── */
.board-frame {
  background: var(--surface); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow);
}
svg.board { display: block; width: 100%; height: auto; border-radius: 10px; user-select: none; }
.gb-grid line { stroke: #3d2a12; stroke-opacity: .85; }
.gb-star { fill: #3d2a12; }
.gb-num { font-size: 17px; font-weight: 700; text-anchor: middle; font-family: "Pretendard", system-ui, sans-serif; }
.gb-num.on-black { fill: #fff; }
.gb-num.on-white { fill: #1d2433; }
.gb-mark { fill: none; stroke: var(--mark); stroke-width: 3; stroke-linejoin: round; }
.gb-letter { cursor: pointer; }
.gb-letter circle { fill: rgba(255, 255, 255, .92); stroke: var(--accent); stroke-width: 2; transition: fill .15s; }
.gb-letter text { font-size: 16px; font-weight: 800; fill: var(--accent); text-anchor: middle; font-family: "Pretendard", system-ui, sans-serif; }
@media (hover: hover) { .gb-letter:hover circle { fill: var(--accent); } }
@media (hover: hover) { .gb-letter:hover text { fill: #fff; } }
.gb-letter.off { cursor: default; opacity: .3; }
.gb-letter.off:hover circle { fill: rgba(255, 255, 255, .92); }
.gb-letter.off:hover text { fill: var(--accent); }
.gb-ghost { opacity: .5; pointer-events: none; }
.gb-cross { stroke: var(--ng); stroke-width: 2.6; stroke-linecap: round; opacity: .8; pointer-events: none; }
.gb-hit rect { cursor: pointer; }
.gb-pop { animation: gb-pop .32s cubic-bezier(.2, .9, .3, 1.2); transform-box: fill-box; transform-origin: center; }
@keyframes gb-pop { from { opacity: 0; transform: scale(.5); } to { opacity: 1; transform: scale(1); } }

.board-caption { margin-top: 10px; font-size: 13px; color: var(--muted); text-align: center; }
.board-caption #qnum { color: var(--ink-2); font-weight: 700; }
.board-caption .dot { margin: 0 6px; }

/* ── 오른쪽 패널 ── */
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
  display: flex; flex-direction: column; }
.panel > .eyebrow, .panel > .prompt { order: 0; }
#turn-panel, #waiting, #end-panel { order: 1; }
.panel > .timeline { order: 2; margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--border); }
@media (max-width: 820px) { .panel { padding: 20px; } }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--accent); text-transform: uppercase; margin-bottom: 6px; }
.prompt { font-size: 21px; line-height: 1.4; font-weight: 800; letter-spacing: -0.025em; margin: 0 0 6px; }
.sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.choices button {
  height: var(--h-choice); border-radius: var(--r-control); cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--border);
  font-size: 18px; font-weight: 800; color: var(--ink);
  transition: border-color .15s, background .15s, transform .08s;
}
@media (hover: hover) { .choices button:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); } }
.choices button:active:not(:disabled) { transform: scale(.97); background: var(--accent-soft); }
.btn:active { transform: scale(.98); }
.choices button.tried { background: var(--surface-2); color: #c3c0b8; border-style: dashed; cursor: default; text-decoration: line-through; }
.notice { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; font-size: 14px; line-height: 1.6;
  background: var(--ng-soft); color: var(--ng); }
.notice.good { background: var(--ok-soft); color: var(--ok); }
.notice:empty { display: none; }
.confirm { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 10px 12px;
  border-radius: 12px; background: var(--accent-soft); }
.confirm span { flex: 1; font-weight: 700; font-size: 14.5px; }
.confirm .btn { flex: none; height: 40px; padding: 0 16px; }
.choices { margin-top: 12px; }

.hint-toggle {
  margin-top: 0; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--accent); font-size: 14px; font-weight: 600;
}
@media (hover: hover) { .hint-toggle:hover { text-decoration: underline; } }
.turn-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.answer-toggle { color: var(--ink-2); }
.verdict.shown { background: var(--accent-soft); }
.verdict.shown .verdict-icon { background: var(--accent); }
.verdict.shown .verdict-title { color: var(--accent); }
.hint-box {
  margin-top: 10px; padding: 14px 16px; border-radius: 12px;
  background: var(--gold-soft); border: 1px solid #f0dfbd; color: #5c4210; line-height: 1.7;
}

/* 한 수씩 주고받기 */

.turn-label { margin: 0 0 12px; color: var(--ink-2); font-size: 14px; font-weight: 600; }
.waiting { margin: 0; padding: 14px 0; color: var(--muted); font-size: 14px; }

/* 놓아보기 */
#sandbox { order: 1; }
.sandbox { padding: 14px; border-radius: 12px; border: 1.5px solid var(--accent); background: var(--accent-soft); }
.sandbox-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.sandbox-head span { font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.sandbox-help { margin: 0 0 10px; font-size: 13.5px; color: var(--ink-2); }
.sandbox-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sandbox-tools .seg { font-size: 13px; padding: 0 4px; }
.sandbox-end { width: 100%; margin-top: 10px; }

/* 선생님 검토 모드 */
.review-badge { margin-left: 6px; padding: 2px 8px; border-radius: 99px; background: var(--gold); color: #fff; font-size: 11.5px; font-weight: 700; vertical-align: 2px; }
.review { margin-top: 16px; padding: 14px; border-radius: 12px; border: 1.5px dashed var(--gold); background: var(--gold-soft); }
.review-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.review-head span { font-size: 12.5px; color: var(--ink-2); }
.review-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.review-tools .seg.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.review-help { margin: 0 0 8px; font-size: 13px; color: #5c4210; }
.review-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.rv-chip { height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; font-weight: 700; cursor: pointer; }
.rv-chip.ans { border-color: var(--ok); color: var(--ok); }
.rv-chip.removed { text-decoration: line-through; color: var(--ng); border-color: var(--ng); background: var(--ng-soft); }
.rv-chip.added { border-color: var(--gold); color: var(--gold); }
.review-memo { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--border); font: inherit; font-size: 14px; resize: vertical; background: var(--surface); }
.review-actions { display: flex; gap: 8px; margin-top: 8px; }
.review-actions .btn { flex: 1 1 0; }
.gb-plus { stroke: var(--gold); stroke-width: 3.2; stroke-linecap: round; pointer-events: none; }
.pill.reviewed::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); margin-left: 2px; }

/* 판정 */
.verdict { display: flex; gap: 12px; align-items: center; padding: 16px; border-radius: 12px; margin-bottom: 24px; }
.verdict.ok { background: var(--ok-soft); }
.verdict.ng { background: var(--ng-soft); }
.verdict-icon { width: 34px; height: 34px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 17px; }
.verdict.ok .verdict-icon { background: var(--ok); }
.verdict.ng .verdict-icon { background: var(--ng); }
.verdict-title { font-weight: 800; font-size: 16.5px; }
.verdict.ok .verdict-title { color: var(--ok); }
.verdict.ng .verdict-title { color: var(--ng); }
.verdict-sub { font-size: 13.5px; color: var(--ink-2); }

/* 수순 타임라인 */
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.counter { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li {
  position: relative; display: flex; gap: 12px; padding: 8px 10px; border-radius: 10px;
  transition: opacity .25s, background .25s;
}
.timeline li::before {
  content: ""; position: absolute; left: 22px; top: 34px; bottom: -8px; width: 1.5px; background: var(--border);
}
.timeline li:last-child::before { display: none; }
.timeline li.todo { opacity: .28; }
.timeline li.done { opacity: .65; }
.timeline li.now { background: var(--accent-soft); }
.stone-badge {
  position: relative; z-index: 1; flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 800;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.stone-badge.black { background: radial-gradient(circle at 35% 30%, #666, #111 60%); color: #fff; }
.stone-badge.white { background: radial-gradient(circle at 35% 30%, #fff, #e3e0d8); color: var(--ink); border: 1px solid #c9c5bb; }
.step-body { line-height: 1.65; padding-top: 1px; }
.step-who { font-weight: 800; margin-right: 6px; }
.tri { color: var(--mark); font-weight: 800; }

/* 수순 넘기기: 같은 크기 버튼 3개 */
.player { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.seg {
  height: var(--h-control); border-radius: var(--r-control); cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; font-weight: 600; color: var(--ink-2); transition: background .15s, border-color .15s;
}
.seg:hover:not(:disabled) { background: var(--surface-2); border-color: #c9c5bb; }
.seg:disabled { opacity: .4; cursor: default; }
.seg svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* 정리 */
.lesson { margin-top: 16px; padding: 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.lesson-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--accent); margin-bottom: 4px; }
.lesson-title { font-weight: 800; font-size: 16px; margin-bottom: 4px; }
.lesson-title:empty { display: none; }
.lesson-text { margin: 0; color: var(--ink-2); line-height: 1.7; }

/* 버튼 */
/* 나란히 놓인 버튼은 같은 너비 */
.actions { display: flex; gap: 8px; margin-top: 24px; }
.actions .btn { flex: 1 1 0; }
.actions.center { max-width: 400px; margin-left: auto; margin-right: auto; }
.btn {
  height: var(--h-control); padding: 0 16px; border-radius: var(--r-control); cursor: pointer;
  font-size: 15px; font-weight: 700; border: 1.5px solid transparent; transition: background .15s, border-color .15s;
}
.btn.primary { background: var(--accent); color: #fff; }
@media (hover: hover) { .btn.primary:hover { background: var(--accent-hover); } }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
@media (hover: hover) { .btn.secondary:hover { border-color: #c9c5bb; } }

/* 결과 화면 */
.summary { max-width: 520px; margin: 24px auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 40px 28px; text-align: center; }
.summary-big { font-size: 52px; font-weight: 800; letter-spacing: -0.03em; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.summary-detail { margin: 0 0 6px; color: var(--ink-2); }
.summary-msg { margin: 0; color: var(--muted); }

/* 아래 */
.foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; }
.foot-note { font-size: 12px; color: var(--muted); text-align: center; }
.link { background: none; border: 0; padding: 6px 0; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.link:hover:not(:disabled) { color: var(--accent); }
.link:disabled { opacity: .35; cursor: default; }
@media (max-width: 820px) {
  .board-caption { margin-top: 6px; }
}
@media (max-width: 560px) {
  :root { --h-choice: 52px; --radius: 14px; }
  body { font-size: 15px; padding-bottom: env(safe-area-inset-bottom); }
  .appbar-inner { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .container { padding: 12px 12px 24px; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-title { font-size: 16px; }
  .brand-sub { display: none; }
  .meter { width: 104px; }
  .meter-label { font-size: 11.5px; margin-bottom: 4px; }

  /* 문제집 탭·단원: 화면 너비에 꽉 차게 */
  .setbar { gap: 8px; margin-bottom: 10px; }
  .tabs { display: flex; width: 100%; }
  .tab { flex: 1 1 0; padding: 0 8px; font-size: 13.5px; }
  .unit-select { width: 100%; min-width: 0; }

  /* 문제 번호: 한 줄로, 옆으로 밀어서 보기 */
  .pager { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 12px; padding: 2px 12px 6px;
           scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .pager::-webkit-scrollbar { display: none; }
  .pill { flex: none; height: 34px; padding: 0 12px; }

  .layout.show { gap: 12px; }
  .board-frame { padding: 6px; }
  .board-caption { font-size: 12px; }
  .panel { padding: 16px; }
  .eyebrow { display: none; }
  .prompt { font-size: 17.5px; margin-bottom: 10px; }
  .turn-label { margin-bottom: 10px; font-size: 13.5px; }
  .verdict { margin-bottom: 12px; padding: 12px 14px; }
  .lesson { margin-top: 12px; padding: 14px; }
  .actions { margin-top: 16px; flex-wrap: wrap; }
  .actions .btn { flex: 1 1 40%; height: 48px; }
  .timeline li { padding: 6px 4px; }
  .timeline li::before { left: 16px; }
  .step-body { font-size: 14.5px; }

  /* 아래 이동 버튼 */
  .foot { margin-top: 14px; }
  .foot-note { display: none; }
  .link { height: 44px; padding: 0 14px; border-radius: var(--r-control); background: var(--surface); border: 1px solid var(--border); }
  .summary { margin: 8px auto; padding: 28px 18px; }
}

/* 홈·문제집 화면에서는 위쪽 진행 막대 대신 원형 그래프를 씀 */
body[data-screen="home"] .meter, body[data-screen="book"] .meter, body[data-screen="free"] .meter, body[data-screen="records"] .meter { visibility: hidden; }
.book-title { font-family: var(--font-display); font-weight: 700; font-size: 24px; }
.unit .uname { font-size: 15.5px; }

/* 급수 · 연속 학습일 · 오늘의 목표 */
.hh-top { position: relative; }
.hh-greet { flex: 1; min-width: 0; }
.hh-level { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 13px; color: #7a5b28; font-weight: 600; }
.hh-level b { padding: 1px 9px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 800; }
.goal { width: 58px; height: 58px; flex: none; position: relative; }
.goal svg { width: 100%; height: 100%; display: block; transform: rotate(-90deg); }
.goal .track { fill: none; stroke: rgba(122, 91, 40, .18); stroke-width: 6; }
.goal .val { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; }
.goal .goal-text { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.05;
  font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }
.goal .goal-text small { display: block; font-size: 9.5px; font-weight: 700; color: #7a5b28; }
.rec-level { display: grid; gap: 8px; padding: 18px; margin-bottom: 12px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.rec-level-top { display: flex; align-items: baseline; justify-content: space-between; }
.rec-level-top b { font-family: var(--font-display); font-size: 30px; }
.rec-level-top span { font-size: 13px; color: var(--muted); }
.rec-level .bar { height: 8px; }
.rec-level p { margin: 0; font-size: 13px; color: var(--ink-2); }
@media (max-width: 560px) { .goal { width: 52px; height: 52px; } }

/* 진행 막대 (단원·급수) */
.bar { display: block; height: 6px; border-radius: 99px; background: #ebe8e1; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; }
