/* Λόγος 마스터 OS — Alexandrian Scriptorium & Modern Theological Workbench */

:root {
  --paper: #F7F3EA;
  --surface: #FFFDF9;
  --soft: #EFE9DB;
  --line: #E2D9C6;
  --line-strong: #C9BC9F;
  --ink: #1F1D1A;
  --ink2: #57524A;
  --mute: #857D71;

  --rubric: #7A1F2B;
  --rubric-dark: #5C151F;
  --rubric-soft: #FBF1F2;
  --rubric-border: #E5BFC5;

  --gold: #946B22;
  --gold-soft: #F9F2E1;
  --gold-border: #DFC996;

  --cobalt: #1E4D6B;
  --cobalt-soft: #EDF4F8;
  --cobalt-border: #B8D2E2;

  --sage: #2E6A4E;
  --sage-soft: #EDF6F1;
  --sage-border: #B4D7C5;

  --danger: #B42318;
  --danger-soft: #FEF2F2;
  --danger-border: #F5B8B4;

  --font-sans: 'Pretendard', 'Noto Sans KR', 'Malgun Gothic', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Gowun Batang', 'Noto Serif KR', Georgia, serif;
  --font-greek: 'Gentium Plus', 'SBL Greek', 'Palatino Linotype', 'Times New Roman', serif;

  --fs-base: 16px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(31, 29, 26, 0.05);
  --shadow-md: 0 8px 24px rgba(31, 29, 26, 0.09);
}

[data-theme="dark"] {
  --paper: #141210;
  --surface: #1E1B18;
  --soft: #282420;
  --line: #342F29;
  --line-strong: #4A433A;
  --ink: #EDE7DC;
  --ink2: #B9B0A2;
  --mute: #8A8174;

  --rubric: #D96876;
  --rubric-dark: #EA8592;
  --rubric-soft: #2D1B1E;
  --rubric-border: #5E2E35;

  --gold: #D4A853;
  --gold-soft: #2A2316;
  --gold-border: #5B4926;

  --cobalt: #7DB4D6;
  --cobalt-soft: #18252E;
  --cobalt-border: #2E4B5E;

  --sage: #6EC498;
  --sage-soft: #17271F;
  --sage-border: #2B5240;

  --danger: #F07A73;
  --danger-soft: #2D1918;
  --danger-border: #612E2C;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: var(--fs-base); }
body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  word-break: keep-all;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--rubric);
  outline-offset: 2px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* 폴리토닉 헬라어 전용 타이포그래피 — 숨표·악센트·이오타 하기 잘림 방지 */
.greek {
  font-family: var(--font-greek);
  line-height: 1.85;
  letter-spacing: 0.01em;
  font-feature-settings: "kern" 1, "liga" 1;
}
.greek-lg { font-size: 1.45rem; }
.greek-xl { font-size: 2.05rem; line-height: 1.6; }
.greek-hero { font-size: 2.6rem; line-height: 1.45; }
.phonetic {
  font-size: 0.84rem;
  color: var(--gold);
  font-weight: 600;
}
.serif { font-family: var(--font-serif); }

/* 잠금 화면 */
.lock-screen {
  position: fixed; inset: 0; z-index: 100;
  background: var(--paper);
  display: grid; place-items: center;
  padding: 20px;
}
.lock-screen[hidden] { display: none; }
.lock-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--rubric);
  border-radius: var(--radius-lg);
  padding: 32px 26px 26px;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.lock-crest {
  width: 60px; height: 60px; margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--rubric);
  color: #F7F3EA;
  border: 2px solid var(--gold-border);
  font-family: var(--font-greek);
  font-size: 2rem; font-weight: 700;
  display: grid; place-items: center;
}
.lock-title { font-family: var(--font-serif); font-size: 1.45rem; margin-bottom: 6px; }
.lock-sub { font-size: 0.88rem; color: var(--ink2); margin-bottom: 20px; }
.lock-form { display: flex; flex-direction: column; gap: 10px; }
.lock-form input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper);
  font-size: 1rem;
  text-align: center;
}
.lock-msg { min-height: 1.4em; margin-top: 10px; font-size: 0.85rem; color: var(--danger); font-weight: 600; }
.lock-foot { margin-top: 14px; font-size: 0.76rem; color: var(--mute); line-height: 1.5; }

/* 상단 바 */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  border-top: 3px solid var(--rubric);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto;
  min-height: 56px; padding: 6px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 32px; height: 32px; flex: none;
  border-radius: 8px; background: var(--rubric); color: #F7F3EA;
  font-family: var(--font-greek); font-size: 1.2rem; font-weight: 700;
  display: grid; place-items: center;
}
.brand-text { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.brand-text strong { font-family: var(--font-serif); font-size: 1.02rem; white-space: nowrap; }
.progress-pill {
  font-size: 0.74rem; font-weight: 700;
  padding: 2px 9px; border-radius: 999px;
  background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-border);
  white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: 5px; flex: none; }
.net-badge {
  font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: var(--sage-soft); color: var(--sage); border: 1px solid var(--sage-border);
}
.net-badge.offline {
  background: var(--gold-soft); color: var(--gold); border-color: var(--gold-border);
}
.icon-btn {
  height: 32px; padding: 0 9px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  font-size: 0.78rem; font-weight: 700; color: var(--ink2);
  white-space: nowrap;
}
.icon-btn:hover { border-color: var(--rubric-border); color: var(--rubric); }
.icon-btn.glossary-trigger {
  background: var(--cobalt-soft); color: var(--cobalt); border-color: var(--cobalt-border);
}
.icon-btn.glossary-trigger:hover {
  background: var(--cobalt); color: #FFFDF9; border-color: var(--cobalt);
}
@media (max-width: 480px) {
  .topbar-inner { padding: 6px 10px; gap: 6px; }
  .brand { gap: 7px; }
  .brand-mark { width: 28px; height: 28px; font-size: 1.05rem; }
  .brand-text strong { font-size: 0.9rem; }
  .progress-pill { font-size: 0.68rem; padding: 1px 7px; }
  .topbar-actions { gap: 4px; }
  .net-badge { font-size: 0.66rem; padding: 2px 6px; }
  .icon-btn { height: 29px; padding: 0 7px; font-size: 0.72rem; }
}

/* 레이아웃: 모바일 하단 탭 / 데스크톱 좌측 레일 */
.workspace { max-width: 1180px; margin: 0 auto; }
.main-content {
  padding: 16px 14px calc(86px + env(safe-area-inset-bottom));
  max-width: 880px;
}

.main-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(31, 29, 26, 0.05);
}
.nav-btn {
  flex: 1; padding: 8px 4px 9px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.72rem; font-weight: 600; color: var(--mute);
}
.nav-btn svg {
  width: 21px; height: 21px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.nav-btn.active { color: var(--rubric); font-weight: 800; }
.nav-btn.active svg { stroke-width: 2.2; }

@media (min-width: 960px) {
  .workspace { display: grid; grid-template-columns: 204px minmax(0, 1fr); gap: 20px; padding: 18px 18px 40px; }
  .main-nav {
    position: sticky; top: 74px; align-self: start;
    flex-direction: column; gap: 4px;
    border: 1px solid var(--line); border-radius: var(--radius-md);
    padding: 10px; box-shadow: var(--shadow-sm);
  }
  .nav-btn {
    flex-direction: row; justify-content: flex-start; gap: 10px;
    padding: 11px 12px; border-radius: var(--radius-sm);
    font-size: 0.9rem;
  }
  .nav-btn.active { background: var(--rubric-soft); color: var(--rubric); }
  .main-content { padding: 0 0 40px; max-width: 940px; }
}

/* 공통 컴포넌트 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 0.88rem;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  transition: background-color 0.14s, border-color 0.14s;
}
.btn:hover { border-color: var(--rubric); color: var(--rubric); }
.btn.primary { background: var(--rubric); color: #FFFDF9; border-color: var(--rubric); }
.btn.primary:hover { background: var(--rubric-dark); color: #FFFDF9; }
.btn.sage { background: var(--sage); color: #FFFDF9; border-color: var(--sage); }
.btn.cobalt { background: var(--cobalt); color: #FFFDF9; border-color: var(--cobalt); }
.btn.gold { background: var(--gold-soft); color: var(--gold); border-color: var(--gold-border); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.btn.sm { padding: 6px 11px; font-size: 0.8rem; }
.btn.full { width: 100%; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.panel.rubric-top { border-top: 3px solid var(--rubric); }
.panel.gold-top { border-top: 3px solid var(--gold); }
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.panel-title { font-family: var(--font-serif); font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.panel-sub { font-size: 0.85rem; color: var(--ink2); margin-top: 2px; }

.subtabs {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.subtab {
  flex: none; padding: 7px 13px; border-radius: 999px;
  font-size: 0.84rem; font-weight: 600; color: var(--ink2);
  border: 1px solid var(--line); background: var(--surface);
}
.subtab.active {
  background: var(--rubric); color: #FFFDF9; border-color: var(--rubric); font-weight: 700;
}

.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 6px; line-height: 1.5; white-space: nowrap;
}
.badge.rubric { background: var(--rubric-soft); color: var(--rubric); border: 1px solid var(--rubric-border); }
.badge.gold { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-border); }
.badge.cobalt { background: var(--cobalt-soft); color: var(--cobalt); border: 1px solid var(--cobalt-border); }
.badge.sage { background: var(--sage-soft); color: var(--sage); border: 1px solid var(--sage-border); }
.badge.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 660px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grid-3 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 660px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* 요약 지표 바 */
.stat-strip {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px;
}
@media (min-width: 640px) { .stat-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 12px 13px;
}
.stat-label { font-size: 0.76rem; color: var(--mute); font-weight: 600; }
.stat-val { font-family: var(--font-serif); font-size: 1.32rem; font-weight: 700; color: var(--ink); margin-top: 2px; }
.stat-note { font-size: 0.74rem; color: var(--ink2); }

/* 오늘 20분 자동 조종사 */
.autopilot-item {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--paper);
  margin-bottom: 8px;
}
.autopilot-item.done { background: var(--sage-soft); border-color: var(--sage-border); }
.autopilot-check {
  width: 22px; height: 22px; flex: none; margin-top: 2px;
  border-radius: 6px; border: 2px solid var(--line-strong);
  display: grid; place-items: center; font-size: 0.8rem; font-weight: 800;
  background: var(--surface);
}
.autopilot-item.done .autopilot-check { background: var(--sage); border-color: var(--sage); color: #fff; }
.autopilot-body { flex: 1; min-width: 0; }
.autopilot-body h4 { font-size: 0.94rem; margin-bottom: 2px; }
.autopilot-body p { font-size: 0.82rem; color: var(--ink2); }

/* 14주 로드맵 */
.week-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); margin-bottom: 8px;
}
.week-row.current { border-color: var(--rubric); background: var(--rubric-soft); }
.week-num {
  width: 48px; flex: none; text-align: center;
  padding: 6px 4px; border-radius: var(--radius-sm);
  background: var(--soft); font-weight: 800; font-size: 0.8rem; color: var(--ink);
}
.week-row.current .week-num { background: var(--rubric); color: #FFFDF9; }

/* L1 브릿지 & 어순 시뮬레이터 & 관사 X-Ray & 좌→우 덩어리 */
.token-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.token-chip {
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--paper);
  text-align: center;
}
.token-chip.case-NOM { border-color: var(--cobalt); background: var(--cobalt-soft); }
.token-chip.case-ACC { border-color: var(--sage); background: var(--sage-soft); }
.token-chip.case-PRED { border-color: var(--rubric); background: var(--rubric-soft); }
.token-chip.case-POST { border-color: var(--gold); background: var(--gold-soft); }
.token-chip.token-masked { border-style: dashed; border-color: var(--line-strong); background: var(--surface); }
.token-chip .tk-g { font-family: var(--font-greek); font-size: 1.25rem; display: block; }
.token-chip .tk-ph { font-size: 0.72rem; color: var(--gold); display: block; margin-top: 1px; }
.token-chip .tk-l { font-size: 0.72rem; color: var(--ink2); display: block; }
.token-chip .tk-l.tk-masked { color: var(--mute); font-weight: 600; }
.token-chip .tk-k { font-size: 0.82rem; font-weight: 700; display: block; margin-top: 2px; }

.chunk-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chunk-card {
  padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--paper);
  transition: opacity 0.2s;
}
.chunk-card.locked { opacity: 0.25; filter: blur(2px); user-select: none; }
.chunk-card.active { border-color: var(--rubric); background: var(--rubric-soft); }

/* 필기 캔버스 */
.canvas-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
#writingCanvas {
  width: 100%; max-width: 360px; height: 240px;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-md);
  background: var(--surface); cursor: crosshair; touch-action: none;
}
.alpha-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px;
}
.alpha-btn {
  padding: 7px 4px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--paper);
  display: flex; flex-direction: column; align-items: center;
}
.alpha-btn.active { border-color: var(--rubric); background: var(--rubric-soft); }
.alpha-btn.mastered { border-color: var(--sage); background: var(--sage-soft); }
.alpha-btn .ag { font-family: var(--font-greek); font-size: 1.35rem; line-height: 1.3; }
.alpha-btn .an { font-size: 0.68rem; color: var(--ink2); }

/* FSRS-6 플래시카드 */
.flashcard {
  background: var(--surface); border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  border-radius: var(--radius-lg); padding: 26px 20px; text-align: center;
  box-shadow: var(--shadow-sm);
}
.flashcard.lifeline { border-top-color: var(--rubric); }
.fsrs-actions {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px;
}
.rate-btn {
  padding: 10px 6px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--paper);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-weight: 700; font-size: 0.86rem;
}
.rate-btn small { font-size: 0.72rem; font-weight: 500; color: var(--ink2); }
.rate-btn.r1 { border-color: var(--danger-border); color: var(--danger); background: var(--danger-soft); }
.rate-btn.r2 { border-color: var(--gold-border); color: var(--gold); background: var(--gold-soft); }
.rate-btn.r3 { border-color: var(--sage-border); color: var(--sage); background: var(--sage-soft); }
.rate-btn.r4 { border-color: var(--cobalt-border); color: var(--cobalt); background: var(--cobalt-soft); }

/* 백지 마스터 차트 & 약점 히트맵 */
.chart-table-wrap { overflow-x: auto; }
.chart-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.chart-table th, .chart-table td {
  border: 1px solid var(--line); padding: 8px 9px; text-align: center; vertical-align: middle;
}
.chart-table th { background: var(--soft); font-weight: 700; color: var(--ink2); font-size: 0.82rem; }
.chart-table td:first-child { text-align: left; font-weight: 700; background: color-mix(in srgb, var(--soft) 50%, var(--surface)); }
.chart-cell-input {
  width: 100%; min-width: 72px; padding: 6px 8px; text-align: center;
  border: 1.5px solid var(--line-strong); border-radius: 6px;
  background: var(--paper); font-family: var(--font-greek); font-size: 1.08rem;
}
.chart-cell-input.ok { border-color: var(--sage); background: var(--sage-soft); color: var(--sage); font-weight: 700; }
.chart-cell-input.bad { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.heat-cell-1 { background: color-mix(in srgb, var(--danger-soft) 55%, var(--surface)); }
.heat-cell-2 { background: var(--danger-soft); box-shadow: inset 0 0 0 1.5px var(--danger-border); }

/* 동적 강독실 & 단어 토큰 & LUTE 1-5 친숙도 색 */
.reader-verse {
  padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); margin-bottom: 10px;
}
.reader-verse.playing { border-color: var(--rubric); background: var(--rubric-soft); }
.verse-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.verse-ref { font-weight: 800; font-size: 0.84rem; color: var(--rubric); }
.word-flow { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: flex-end; }
.g-word {
  display: inline-flex; flex-direction: column; align-items: center;
  padding: 3px 6px; border-radius: 6px; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: background-color 0.12s;
}
.g-word:hover { background: var(--soft); }
.g-word .gw-txt { font-family: var(--font-greek); font-size: 1.32rem; line-height: 1.45; }
.g-word .gw-ph { font-size: 0.68rem; color: var(--gold); line-height: 1.2; }
.g-word .gw-gl { font-size: 0.72rem; color: var(--ink2); line-height: 1.2; }

/* LUTE 친숙도 1~5 밑줄/배경 */
.g-word.lute-1 { background: color-mix(in srgb, var(--danger-soft) 70%, transparent); border-bottom-color: var(--danger); }
.g-word.lute-2 { background: color-mix(in srgb, var(--gold-soft) 80%, transparent); border-bottom-color: var(--gold); }
.g-word.lute-3 { background: color-mix(in srgb, var(--cobalt-soft) 75%, transparent); border-bottom-color: var(--cobalt); }
.g-word.lute-4 { border-bottom-color: var(--sage); }
.g-word.lute-5 { border-bottom-color: transparent; }

.cloze-input {
  width: 82px; padding: 3px 6px; text-align: center;
  border: 1.5px dashed var(--rubric); border-radius: 6px;
  font-family: var(--font-greek); font-size: 1.15rem; background: var(--paper);
}
.cloze-input.ok { border-style: solid; border-color: var(--sage); background: var(--sage-soft); }
.cloze-input.bad { border-style: solid; border-color: var(--danger); background: var(--danger-soft); }

.verse-trans {
  margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--line);
  font-size: 0.86rem; color: var(--ink2); display: flex; flex-direction: column; gap: 4px;
}

/* 단어 X-Ray 드로어 */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 18, 16, 0.48);
}
.drawer-backdrop[hidden] { display: none; }
.word-drawer {
  position: fixed; z-index: 70;
  left: 0; right: 0; bottom: 0; max-height: 82vh; max-height: 82dvh;
  background: var(--surface); border-top: 3px solid var(--rubric);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
  display: flex; flex-direction: column;
}
.word-drawer[hidden] { display: none; }
@media (min-width: 840px) {
  .word-drawer {
    left: auto; top: 0; bottom: 0; width: 460px; max-height: 100vh; max-height: 100dvh;
    border-top: 0; border-left: 3px solid var(--rubric);
    border-radius: 0;
  }
}
.drawer-head {
  flex: none;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.drawer-greek { font-size: 1.85rem; line-height: 1.3; color: var(--rubric); }
.drawer-meta { font-size: 0.84rem; color: var(--ink2); margin-top: 3px; }
.drawer-body {
  flex: 1 1 auto; min-height: 0;
  padding: 16px 18px calc(26px + env(safe-area-inset-bottom));
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 12px;
}
.xray-box {
  padding: 12px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--paper);
}
.xray-box h4 { font-size: 0.82rem; font-weight: 800; color: var(--rubric); margin-bottom: 5px; }
.xray-box p { font-size: 0.88rem; color: var(--ink); line-height: 1.65; }

/* 오디오 컨트롤 바 */
.audio-bar {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-radius: var(--radius-md);
  background: var(--soft); border: 1px solid var(--line);
}
.audio-bar > audio { width: 100%; height: 40px; }
.audio-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.audio-controls audio { width: 100%; height: 38px; }

/* 퀴즈 선택지 */
.quiz-opt {
  width: 100%; text-align: left; padding: 11px 13px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  background: var(--paper); margin-bottom: 7px; font-size: 0.92rem;
}
.quiz-opt:hover { border-color: var(--rubric); }
.quiz-opt.selected { border-color: var(--cobalt); background: var(--cobalt-soft); color: var(--cobalt); font-weight: 700; }
.quiz-opt.correct { border-color: var(--sage); background: var(--sage-soft); color: var(--sage); font-weight: 700; }
.quiz-opt.wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); font-weight: 700; }

/* 전치사 공간 SVG 다이어그램 (마운스 8장 L10444) */
.prep-svg-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 12px; border-radius: var(--radius-md);
  background: var(--paper); border: 1px solid var(--line); margin-bottom: 12px;
}
.prep-svg { width: 100%; max-width: 520px; height: auto; display: block; }
.prep-node { cursor: pointer; transition: opacity 0.15s; }
.prep-node:hover { opacity: 0.85; }
.prep-node text { font-family: var(--font-greek); font-weight: 700; user-select: none; }
.prep-caption {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--gold-border);
  font-size: 0.86rem; text-align: center;
}
.pager-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px; padding: 10px 12px; margin: 10px 0;
  border-radius: var(--radius-sm); background: var(--soft); border: 1px solid var(--line);
  font-size: 0.84rem;
}

/* 입력·셀렉트 */
.field-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.input, .select {
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--paper);
  font-size: 0.9rem;
}
.input { flex: 1; min-width: 160px; }

/* 토스트 */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  z-index: 90; padding: 10px 18px; border-radius: 999px;
  background: var(--ink); color: var(--surface);
  font-size: 0.86rem; font-weight: 600; box-shadow: var(--shadow-md);
  max-width: 90vw; text-align: center;
}
.toast[hidden] { display: none; }

/* 간단한 툴팁/디테일 */
details.acc {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); padding: 10px 12px; margin-bottom: 8px;
}
details.acc summary { font-weight: 700; cursor: pointer; font-size: 0.92rem; }
details.acc[open] summary { margin-bottom: 8px; color: var(--rubric); }
.excerpt-pre {
  white-space: pre-wrap; font-family: var(--font-sans); font-size: 0.86rem;
  line-height: 1.72; color: var(--ink2);
}

/* ── 완전 생초보 문법 용어 클릭 링크 · 모달 · 0장 교실 · 형태소 쉬운 풀이 ── */
.term-link {
  display: inline;
  padding: 0 1px;
  font: inherit;
  color: var(--cobalt);
  font-weight: 700;
  border-bottom: 1.5px dotted var(--cobalt);
  border-radius: 2px;
  cursor: help;
  text-align: inherit;
  line-height: inherit;
  transition: background-color 0.12s, color 0.12s;
}
.term-link:hover,
.term-link:focus-visible {
  background: var(--cobalt-soft);
  color: var(--rubric);
  border-bottom-color: var(--rubric);
}

/* 생초보 환영 배너 (오늘 20분 탭 상단 · 비차단형) */
.beginner-banner {
  background: linear-gradient(135deg, var(--gold-soft) 0%, var(--surface) 62%, var(--cobalt-soft) 100%);
  border: 1.5px solid var(--gold-border);
  border-left: 4px solid var(--rubric);
  border-radius: var(--radius-md);
  padding: 16px 16px 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.beginner-banner-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.beginner-banner-head .btn { flex: none; white-space: nowrap; }
.beginner-banner h2 {
  font-family: var(--font-serif); font-size: 1.08rem; color: var(--rubric); font-weight: 800;
}
.beginner-banner p {
  font-size: 0.87rem; color: var(--ink); line-height: 1.65; margin-bottom: 8px;
}
.beginner-mini-map {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 11px;
}
.beginner-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-strong);
  font-size: 0.78rem; font-weight: 700; color: var(--ink);
}
.beginner-pill em { font-style: normal; color: var(--cobalt); }

/* 0장 역할 카드 & 몸통+꼬리 비교표 */
.ch0-sentence-hero {
  padding: 14px 16px; border-radius: var(--radius-md);
  background: var(--gold-soft); border: 1.5px solid var(--gold-border);
  text-align: center; margin-bottom: 12px;
}
.ch0-sentence-main {
  font-family: var(--font-serif); font-size: 1.22rem; font-weight: 800; color: var(--ink);
  line-height: 1.6;
}
.ch0-sentence-sub { font-size: 0.84rem; color: var(--ink2); margin-top: 4px; }
.ch0-role-card {
  padding: 13px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--paper);
}
.ch0-role-card.role-cobalt { border-left: 4px solid var(--cobalt); }
.ch0-role-card.role-gold { border-left: 4px solid var(--gold); }
.ch0-role-card.role-rubric { border-left: 4px solid var(--rubric); }
.ch0-role-card.role-sage { border-left: 4px solid var(--sage); }
.ch0-part-badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 0.84rem; font-weight: 800;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--rubric);
}
.stem-box {
  display: inline-flex; align-items: center; gap: 2px;
  font-weight: 800; white-space: nowrap;
}
.stem-body {
  padding: 2px 7px; border-radius: 6px 0 0 6px;
  background: var(--cobalt-soft); color: var(--cobalt); border: 1px solid var(--cobalt-border);
}
.stem-tail {
  padding: 2px 7px; border-radius: 0 6px 6px 0;
  background: var(--rubric-soft); color: var(--rubric); border: 1px solid var(--rubric-border);
}
.ch0-stem-table td:first-child { text-align: center; }
@media (max-width: 480px) {
  .ch0-stem-table th, .ch0-stem-table td { padding: 7px 5px; font-size: 0.82rem; }
  .ch0-stem-table .stem-body, .ch0-stem-table .stem-tail { padding: 2px 5px; font-size: 0.84rem; }
}

/* 단어 X-Ray 드로어 안의 생초보 쉬운 형태소 풀이 박스 */
.morph-plain-box {
  margin-top: 9px; padding: 10px 11px; border-radius: var(--radius-sm);
  background: var(--gold-soft); border: 1px solid var(--gold-border);
}
.morph-plain-title {
  font-size: 0.76rem; font-weight: 800; color: var(--gold); margin-bottom: 6px;
}
.morph-chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.morph-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--cobalt-border);
  font-size: 0.76rem; color: var(--ink);
}
.morph-chip strong { color: var(--cobalt); }
.morph-chip:hover { border-color: var(--rubric); background: var(--rubric-soft); }
.morph-action-tip {
  font-size: 0.83rem; font-weight: 700; color: var(--ink); line-height: 1.55;
}

/* 용어 팝업 / 전체 백과 모달 (드로어 z-index 70보다 위!) */
.glossary-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(20, 18, 16, 0.54);
}
.glossary-backdrop[hidden] { display: none; }
.glossary-modal {
  position: fixed; z-index: 85;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 24px));
  max-height: 84vh; max-height: 84dvh;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-top: 4px solid var(--cobalt);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
}
.glossary-modal[hidden] { display: none; }
@media (max-width: 560px) {
  .glossary-modal {
    left: 0; right: 0; top: auto; bottom: 0; transform: none;
    width: 100%; max-height: 86vh; max-height: 86dvh;
    border-radius: 18px 18px 0 0;
  }
}
.glossary-head {
  flex: none;
  padding: 15px 17px 11px; border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.glossary-body {
  flex: 1 1 auto; min-height: 0;
  padding: 14px 17px calc(22px + env(safe-area-inset-bottom));
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 11px;
}
.glossary-body > * { flex-shrink: 0; }
.glossary-highlight {
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--cobalt-soft); border: 1.5px solid var(--cobalt-border);
  font-size: 0.96rem; font-weight: 800; color: var(--cobalt);
}
.glossary-card {
  padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--paper);
}
.glossary-card h4 {
  font-size: 0.92rem; color: var(--rubric); font-weight: 800; margin-bottom: 4px;
}
.glossary-card p { font-size: 0.84rem; color: var(--ink); line-height: 1.6; }
.glossary-cats {
  flex: none;
  display: flex; gap: 5px; overflow-x: auto; padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}
.glossary-cat-btn {
  flex: none; padding: 6px 11px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; white-space: nowrap;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink2);
}
.glossary-cat-btn.active {
  background: var(--cobalt); color: #FFFDF9; border-color: var(--cobalt);
}
