/* 전자책 — 따뜻한 아날로그 종이책 */

:root {
  --paper: #f5efe2;
  --paper-2: #ede4d0;
  --ink: #2a2118;
  --ink-soft: #5a4a38;
  --ink-muted: #8a7a62;
  --accent: #8b5a2b;
  --accent-2: #c97a3e;
  --accent-warm: #b8491f;
  --rule: rgba(60, 40, 20, 0.15);
  --serif: 'Gowun Batang', 'Noto Serif KR', serif;
  --sans: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'D2Coding', monospace;
  --base-size: 17px;
}

[data-theme="dark"] {
  --paper: #1c1815;
  --paper-2: #252019;
  --ink: #e8dfce;
  --ink-soft: #b5a990;
  --ink-muted: #786d58;
  --accent: #d9a068;
  --accent-2: #e8b47a;
  --accent-warm: #e07a4a;
  --rule: rgba(230, 210, 170, 0.15);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: var(--sans);
  color: var(--ink);
  background: radial-gradient(ellipse at top, #3a2f22 0%, #1a130c 70%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-size: var(--base-size);
  line-height: 1.75;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.code-body, .tool-name, .definition-term, .qa-list, .tag {
  word-break: break-word;
  overflow-wrap: anywhere;
}

[data-theme="dark"] body {
  background: radial-gradient(ellipse at top, #0a0805 0%, #000 70%);
}

.app {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: 48px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  color: rgba(255, 240, 220, 0.85);
  z-index: 30;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 240, 220, 0.08);
  gap: 12px;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand {
  font-family: var(--serif);
  letter-spacing: 0.02em;
  color: rgba(255, 240, 220, 0.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub { opacity: 0.55; margin-left: 6px; font-size: 12px; }

.icon-btn {
  background: transparent;
  border: 1px solid rgba(255, 240, 220, 0.15);
  color: rgba(255, 240, 220, 0.8);
  width: 32px; height: 32px;
  border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all 0.15s;
}
.icon-btn:hover { background: rgba(255, 240, 220, 0.08); color: #fff; }

.progress-wrap {
  flex: 1;
  max-width: 320px;
  display: flex; align-items: center; gap: 10px;
}
.progress-track {
  flex: 1; height: 3px;
  background: rgba(255, 240, 220, 0.12);
  border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-text {
  font-variant-numeric: tabular-nums;
  font-size: 12px; opacity: 0.7;
  min-width: 70px; text-align: right;
}

/* STAGE */
.stage {
  position: relative;
  overflow: hidden;
  padding: 24px 80px;
  min-height: 0;
}

.book {
  position: absolute;
  top: 24px; bottom: 24px;
  left: 80px; right: 80px;
  margin: 0 auto;
  max-width: 1100px;
  display: flex;
  filter: drop-shadow(0 30px 50px rgba(0, 0, 0, 0.5));
}

/* Center gutter */
.book::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(0, 0, 0, 0.18) 40%,
    rgba(0, 0, 0, 0.28) 50%,
    rgba(0, 0, 0, 0.18) 60%,
    transparent 100%);
  z-index: 5;
  pointer-events: none;
}

.page {
  flex: 1 1 50%;
  width: 50%;
  height: 100%;
  background: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(139, 90, 43, 0.04), transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(139, 90, 43, 0.035), transparent 50%);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.page.left {
  border-radius: 4px 0 0 4px;
  box-shadow: inset 12px 0 18px -12px rgba(80, 50, 20, 0.25);
}
.page.right {
  border-radius: 0 4px 4px 0;
  box-shadow: inset -12px 0 18px -12px rgba(80, 50, 20, 0.25);
}

.page-content {
  flex: 1;
  padding: 48px 54px 32px 54px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-muted) transparent;
  min-height: 0;
}
.page.left .page-content { padding-right: 40px; }
.page.right .page-content { padding-left: 40px; }

.page-content::-webkit-scrollbar { width: 4px; }
.page-content::-webkit-scrollbar-thumb { background: var(--ink-muted); border-radius: 99px; }

.page-footer {
  padding: 10px 54px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--serif);
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  border-top: 1px solid var(--rule);
  flex-shrink: 0;
}
.page-num { font-family: var(--serif); font-variant-numeric: tabular-nums; }
.page-chapter-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.2em; }

.block { margin-bottom: 12px; }
.block:last-child { margin-bottom: 0; }

.p {
  font-family: var(--serif);
  font-size: 0.91em;
  line-height: 1.9;
  color: var(--ink);
  text-wrap: pretty;
  margin: 0 0 10px 0;
}
.p.emphasis { font-weight: 700; color: var(--accent-warm); font-size: 1em; }
.p.muted { color: var(--ink-muted); font-style: italic; font-size: 0.79em; }

.section-title {
  font-family: var(--serif);
  font-size: 1.12em;
  font-weight: 700;
  color: var(--accent);
  margin: 16px 0 14px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}

.chapter-label {
  font-family: var(--serif);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--accent);
  margin-bottom: 24px;
  text-align: center;
}

.quote-block {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1em;
  line-height: 1.7;
  color: var(--ink-soft);
  margin: 16px 0;
  padding: 14px 20px;
  border-left: 3px solid var(--accent);
  background: linear-gradient(90deg, rgba(139, 90, 43, 0.06), transparent);
  text-wrap: balance;
}

.callout {
  font-family: var(--serif);
  font-size: 0.94em;
  line-height: 1.75;
  padding: 14px 18px;
  margin: 14px 0;
  background: rgba(139, 90, 43, 0.08);
  border-radius: 6px;
  text-wrap: balance;
}
.callout.tone-warm {
  background: linear-gradient(135deg, rgba(201, 122, 62, 0.12), rgba(139, 90, 43, 0.08));
  border-left: 3px solid var(--accent-2);
}
.callout.tone-eureka {
  background: linear-gradient(135deg, rgba(184, 73, 31, 0.12), rgba(201, 122, 62, 0.1));
  color: var(--accent-warm);
  font-weight: 600;
  text-align: center;
  font-size: 1em;
}
.callout.tone-sigh {
  background: rgba(90, 74, 56, 0.08);
  color: var(--ink-muted);
  font-style: italic;
  text-align: center;
}
.callout.tone-punchy {
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  font-size: 22px;
  text-align: center;
  letter-spacing: 0.08em;
  padding: 18px;
}

.divider {
  text-align: center;
  margin: 18px 0;
  color: var(--accent);
  letter-spacing: 1em;
  opacity: 0.5;
}
.divider::before { content: "⁂"; }

.dialogue {
  display: flex;
  margin: 8px 0;
  gap: 8px;
  animation: bubbleIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.dialogue.right { flex-direction: row-reverse; }
.dialogue-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
  font-size: 12px; font-weight: 700;
  background: var(--accent);
  color: #fff;
  margin-top: 3px;
}
.dialogue.right .dialogue-avatar { background: var(--ink); }
.dialogue-content { max-width: 75%; }
.dialogue-speaker {
  font-size: 10.5px;
  color: var(--ink-muted);
  margin-bottom: 2px;
  padding: 0 6px;
}
.dialogue.right .dialogue-speaker { text-align: right; }
.dialogue-bubble {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.6;
  padding: 9px 13px;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  word-break: keep-all;
}
[data-theme="dark"] .dialogue-bubble { background: #2c2620; color: var(--ink); }
.dialogue.left .dialogue-bubble { border-top-left-radius: 4px; }
.dialogue.right .dialogue-bubble {
  background: linear-gradient(135deg, #8b5a2b, #a56a36);
  color: #fff8eb;
  border-top-right-radius: 4px;
}

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 14px;
  border-top-left-radius: 4px;
  margin: 4px 0 4px 38px;
  align-items: center;
}
[data-theme="dark"] .typing { background: #2c2620; }
.typing span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ink-muted);
  animation: typingDot 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.code-frame {
  margin: 14px 0;
  background: #1c1a18;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.4);
  font-family: var(--mono);
}
.code-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #26231f;
}
.code-dot { width: 9px; height: 9px; border-radius: 50%; }
.code-dot.r { background: #ff5f57; }
.code-dot.y { background: #febc2e; }
.code-dot.g { background: #28c840; }
.code-filename { margin-left: 8px; color: #a89f8e; font-size: 10.5px; }
.code-body {
  padding: 12px 14px;
  color: #e8dfc8;
  font-size: 11px;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre;
  max-height: 300px;
}
.tok-tag { color: #d98a5e; }
.tok-attr { color: #c8b06a; }
.tok-str { color: #a8c078; }
.tok-kw { color: #d76a7a; }
.tok-com { color: #6b6458; font-style: italic; }
.tok-num { color: #d8a070; }

.app-card {
  margin: 16px 0;
  padding: 20px 22px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(139, 90, 43, 0.06), rgba(201, 122, 62, 0.1));
}
.app-card-name {
  font-family: var(--serif);
  font-size: 26px; font-weight: 700;
  color: var(--accent-warm);
  letter-spacing: 0.05em;
  margin: 0 0 4px 0;
}
.app-card-sub {
  font-size: 11px;
  color: var(--ink-muted);
  margin-bottom: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.app-card-desc {
  font-family: var(--serif);
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.big-number {
  text-align: center;
  margin: 20px 0;
  padding: 16px;
}
.big-number-num {
  font-family: var(--serif);
  font-size: 84px;
  line-height: 1;
  font-weight: 700;
  color: var(--accent-warm);
  letter-spacing: -0.04em;
  display: block;
  margin-bottom: 6px;
}
.big-number-label {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink-muted);
  letter-spacing: 0.15em;
}

.tool-timeline { margin: 14px 0; }
.tool-item {
  padding: 10px 14px;
  margin-bottom: 8px;
  border-left: 2px solid var(--rule);
  padding-left: 20px;
  position: relative;
}
.tool-item::before {
  content: "";
  position: absolute;
  left: -7px; top: 14px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink-muted);
}
.tool-item.highlight::before {
  border-color: var(--accent-warm);
  background: var(--accent-warm);
  box-shadow: 0 0 0 4px rgba(184, 73, 31, 0.2);
}
.tool-item.highlight { border-left-color: var(--accent-warm); }
.tool-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  font-family: var(--mono);
}
.tool-item.highlight .tool-name { color: var(--accent-warm); }
.tool-desc { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.tag {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 10px;
  background: rgba(139, 90, 43, 0.1);
  color: var(--accent);
  border-radius: 99px;
  border: 1px solid rgba(139, 90, 43, 0.2);
}

.cold-reactions { margin: 14px 0; display: flex; flex-direction: column; gap: 5px; }
.cold-item {
  font-family: var(--serif);
  font-size: 13.5px;
  font-style: italic;
  padding: 7px 12px;
  color: var(--ink-muted);
  background: rgba(90, 74, 56, 0.04);
  border-radius: 5px;
  border-left: 2px solid var(--ink-muted);
  opacity: 0.8;
}

.growth-list { margin: 14px 0; counter-reset: growth; display: flex; flex-direction: column; gap: 5px; }
.growth-item {
  counter-increment: growth;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(90deg, rgba(139, 90, 43, 0.08), transparent);
  border-radius: 5px;
  font-family: var(--serif);
  font-size: 14px;
}
.growth-item::before {
  content: "0" counter(growth);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--accent);
  font-weight: 700;
}
.growth-item::after { content: "→"; margin-left: auto; color: var(--accent); }
.growth-item:last-child::after { content: "★"; }

.definition {
  margin: 12px 0;
  padding: 12px 16px;
  background: rgba(139, 90, 43, 0.06);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}
.definition-term {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--accent-warm);
  font-size: 15px;
  margin-bottom: 3px;
}
.definition-body { font-family: var(--serif); font-size: 13.5px; color: var(--ink-soft); }

.qa-list {
  margin: 12px 0;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-soft);
  display: flex; flex-direction: column; gap: 5px;
}

.thread-post {
  margin: 14px 0;
  padding: 20px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.15);
  color: #1a1a1a;
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-line;
  position: relative;
}
[data-theme="dark"] .thread-post { background: #141414; color: #e8e8e8; border-color: rgba(255,255,255,0.1); }
.thread-post::before {
  content: "@";
  position: absolute;
  top: 12px; right: 16px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #000; color: #fff;
  font-family: var(--serif); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}

/* Chapter intro */
.chapter-intro {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 30px;
  text-align: center;
  position: relative;
}
.chapter-intro::before, .chapter-intro::after {
  content: "";
  position: absolute;
  left: 25%; right: 25%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.chapter-intro::before { top: 20%; }
.chapter-intro::after { bottom: 20%; }

.chapter-intro-num {
  font-family: var(--serif);
  font-size: 128px;
  line-height: 1;
  color: var(--accent-2);
  opacity: 0.18;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: -50px;
  user-select: none;
}
.chapter-intro-label {
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.4em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 14px;
}
.chapter-intro-title {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 10px 0;
  line-height: 1.25;
  text-wrap: balance;
}
.chapter-intro-subtitle {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 30px;
}
.chapter-intro-quote {
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  color: var(--ink-muted);
  max-width: 80%;
  margin: 0 auto;
  line-height: 1.7;
  padding-top: 24px;
  position: relative;
  text-wrap: balance;
}
.chapter-intro-quote::before {
  content: "";
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  width: 30px; height: 1px;
  background: var(--accent);
}

/* Cover */
.cover {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 36px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(201, 122, 62, 0.15), transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(139, 90, 43, 0.1), transparent 60%);
  position: relative;
}
.cover::after {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(139, 90, 43, 0.3);
  border-radius: 2px;
  pointer-events: none;
}
.cover-top { text-align: center; }
.cover-badge {
  display: inline-block;
  font-family: var(--serif);
  font-size: 10.5px;
  letter-spacing: 0.35em;
  color: var(--accent);
  text-transform: uppercase;
  padding: 5px 14px;
  border-top: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
  margin-bottom: 30px;
}
.cover-title {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  margin: 0 0 14px 0;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.cover-subtitle {
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
  color: var(--accent-warm);
}
.cover-mid { text-align: center; margin: auto 0; }
.cover-ornament {
  font-size: 26px;
  color: var(--accent);
  letter-spacing: 0.5em;
  opacity: 0.4;
}
.cover-bottom { text-align: center; }
.cover-author {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 4px;
}
.cover-affiliation {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--ink-muted);
  letter-spacing: 0.1em;
}
.cover-year {
  font-family: var(--serif);
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 16px;
  letter-spacing: 0.3em;
}

/* TOC */
.toc-title {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin: 0 0 4px 0;
  color: var(--ink);
  letter-spacing: 0.15em;
}
.toc-subtitle {
  text-align: center;
  font-family: var(--serif);
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.3em;
  margin-bottom: 22px;
  text-transform: uppercase;
}
.toc-list { display: flex; flex-direction: column; }
.toc-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 6px;
  border-bottom: 1px dotted var(--rule);
  font-family: var(--serif);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border-left: none; border-right: none; border-top: none;
  width: 100%;
}
.toc-item:hover { color: var(--accent-warm); padding-left: 10px; }
.toc-num { font-size: 12px; color: var(--accent); font-weight: 700; min-width: 26px; }
.toc-label { font-size: 14px; flex: 1; }
.toc-dots { flex: 1; border-bottom: 1px dotted var(--rule); margin: 0 4px 4px 4px; min-width: 20px; }
.toc-page-num { font-size: 12px; color: var(--ink-muted); }

/* Ending */
.ending {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
}
.ending-fin {
  font-family: var(--serif);
  font-size: 60px;
  color: var(--accent);
  letter-spacing: 0.3em;
  margin-bottom: 20px;
}
.ending-line { width: 60px; height: 2px; background: var(--accent); margin: 14px 0; }
.ending-text {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink-soft);
  font-style: italic;
  max-width: 85%;
  line-height: 1.7;
  margin-bottom: 6px;
  text-wrap: balance;
}
.ending-heart {
  font-size: 30px;
  color: var(--accent-warm);
  margin: 16px 0 8px 0;
  animation: heartBeat 1.5s infinite;
}
@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.15); }
}
.ending-hint {
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.1em;
  margin-top: 18px;
}

/* Nav buttons */
.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(255, 240, 220, 0.08);
  border: 1px solid rgba(255, 240, 220, 0.18);
  color: rgba(255, 240, 220, 0.75);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  z-index: 20;
  opacity: 1;
  transition: opacity 0.35s ease, background 0.2s, transform 0.2s, color 0.2s;
}
.nav-btn:hover { background: var(--accent); color: #fff; transform: translateY(-50%) scale(1.08); opacity: 1 !important; }
.nav-btn:disabled { opacity: 0.2; cursor: not-allowed; }
.stage.idle .nav-btn:not(:disabled) { opacity: 0; pointer-events: none; }
.nav-prev { left: 20px; }
.nav-next { right: 20px; }

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 340px;
  background: #1a130c;
  color: rgba(255, 240, 220, 0.9);
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.sidebar.open { transform: translateX(0); box-shadow: 20px 0 40px rgba(0,0,0,0.4); }
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 45;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.sidebar-backdrop.open { opacity: 1; pointer-events: all; }
.sidebar-header { padding: 20px; border-bottom: 1px solid rgba(255,240,220,0.1); }
.sidebar-title { font-family: var(--serif); font-size: 18px; margin: 0 0 4px 0; }
.sidebar-sub { font-size: 12px; opacity: 0.6; display: flex; justify-content: space-between; }
.sidebar-body { flex: 1; overflow-y: auto; padding: 12px; }
.sidebar-chapter {
  padding: 12px;
  margin-bottom: 4px;
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: baseline; gap: 12px;
  background: transparent; border: none;
  color: inherit; text-align: left; width: 100%;
  transition: background 0.15s;
  font-family: var(--serif);
}
.sidebar-chapter:hover { background: rgba(255,240,220,0.05); }
.sidebar-chapter.current { background: rgba(201,122,62,0.15); color: var(--accent-2); }
.sidebar-chapter-num { font-family: var(--mono); font-size: 11px; opacity: 0.55; min-width: 22px; }
.sidebar-chapter-title { font-size: 13.5px; font-weight: 600; }
.sidebar-chapter-sub { font-size: 11.5px; opacity: 0.55; margin-top: 2px; }

.page.entering { animation: pageFade 0.4s ease-out; }
@keyframes pageFade {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Mobile */
@media (max-width: 768px) {
  :root { --base-size: 16px; }
  .stage { padding: 12px 8px; }
  .book { left: 0; right: 0; max-width: 100%; }
  .book::before { display: none; }
  .page.left { display: none; }
  .page.right {
    flex: 1;
    width: 100%;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  }
  .page-content { padding: 26px 18px; }
  .page.right .page-content { padding-left: 18px; }
  .page-footer { padding: 10px 18px; }
  .nav-prev { left: 4px; }
  .nav-next { right: 4px; }
  .nav-btn { width: 36px; height: 36px; font-size: 15px; }
  .chapter-intro-num { font-size: 90px; margin-bottom: -35px; }
  .chapter-intro-title { font-size: 24px; }
  .cover-title { font-size: 21px; }
  .big-number-num { font-size: 64px; }
  .progress-wrap { max-width: 120px; }
  .progress-text { display: none; }
  .sidebar { width: 86%; }
  .topbar { padding: 0 10px; }
  .brand-sub { display: none; }
  .brand { font-size: 12px; }
}

.hint {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10.5px;
  color: rgba(255,240,220,0.4);
  letter-spacing: 0.15em;
  z-index: 20;
  pointer-events: none;
  display: flex;
  gap: 14px;
  align-items: center;
}
.hint kbd {
  font-family: var(--mono);
  background: rgba(255,240,220,0.1);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid rgba(255,240,220,0.15);
  font-size: 10px;
}
@media (max-width: 768px) { .hint { display: none; } }
