/* =============================================================
   톰뭉과 동네 한 바퀴 — Classic 단행본 스타일 (custom.css)
   디자인 토큰: untitled/project/pages-classic.jsx 기반
   - 본명조 본문, 38ch measure, hairline rules, ❦ ornament
   ============================================================= */

@import url("https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@300;400;500;600;700;900&family=Nanum+Myeongjo:wght@400;700;800&family=Pretendard:wght@300;400;500;600;700;800&display=swap");

/* ── Tokens ───────────────────────────────────────────────── */
:root {
  --font-serif: "Noto Serif KR", "Nanum Myeongjo", "본명조", serif;
  --font-sans: "Pretendard", "Pretendard Variable", system-ui, "Apple SD Gothic Neo", "맑은 고딕", sans-serif;
  --font-dropcap: "Nanum Myeongjo", "Noto Serif KR", serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --body-size: 18px;
  --body-leading: 1.78;
  --measure: 74ch;
  --measure-cap: 56rem;
  --content-pad-y: 56px;
  --content-pad-x: clamp(16px, 4vw, 56px);

  --tracking-eyebrow: 0.18em;
  --tracking-cover: 0.32em;
}

/* ── Theme: Light (default) ───────────────────────────────── */
.light, html[data-theme="light"], :root {
  --paper: #fbfaf6;
  --ink: #1f1c18;
  --ink-muted: rgba(31, 28, 24, 0.55);
  --ink-faint: rgba(31, 28, 24, 0.18);
  --rule: rgba(31, 28, 24, 0.15);
  --paper-soft: #f3f1ec;

  --bg-color: var(--paper);
  --text-color: var(--ink);
  --border-color: var(--rule);
  --sidebar-bg: rgba(243, 241, 236, 0.60);
  --pre-bg: var(--paper-soft);
  --code-bg: rgba(31, 28, 24, 0.06);

  /* mdbook sidebar 변수 오버라이드 */
  --sidebar-fg: rgba(31, 28, 24, 0.55);
  --sidebar-active: #1f1c18;
  --sidebar-non-existant: rgba(31, 28, 24, 0.25);
}

/* ── Theme: Sepia (mdBook rust theme 재해석) ─────────────── */
.rust, html[data-theme="rust"] {
  --paper: #f3e9d2;
  --ink: #3a2e1c;
  --ink-muted: rgba(58, 46, 28, 0.6);
  --ink-faint: rgba(58, 46, 28, 0.22);
  --rule: rgba(58, 46, 28, 0.2);
  --paper-soft: #ebe0c2;

  --bg-color: var(--paper);
  --text-color: var(--ink);
  --border-color: var(--rule);
  --sidebar-bg: rgba(235, 224, 194, 0.60);
  --pre-bg: var(--paper-soft);
  --code-bg: rgba(58, 46, 28, 0.08);

  --sidebar-fg: rgba(58, 46, 28, 0.6);
  --sidebar-active: #3a2e1c;
  --sidebar-non-existant: rgba(58, 46, 28, 0.25);
}

/* ── Theme: Dark (coal/navy/ayu) ──────────────────────────── */
.coal, .navy, .ayu,
html[data-theme="coal"], html[data-theme="navy"], html[data-theme="ayu"] {
  --paper: #1a1815;
  --ink: #e8e3d8;
  --ink-muted: rgba(232, 227, 216, 0.55);
  --ink-faint: rgba(232, 227, 216, 0.2);
  --rule: rgba(232, 227, 216, 0.18);
  --paper-soft: #232120;

  --bg-color: var(--paper);
  --text-color: var(--ink);
  --border-color: var(--rule);
  --sidebar-bg: rgba(35, 33, 32, 0.60);
  --pre-bg: var(--paper-soft);
  --code-bg: rgba(232, 227, 216, 0.08);

  --sidebar-fg: rgba(232, 227, 216, 0.55);
  --sidebar-active: #e8e3d8;
  --sidebar-non-existant: rgba(232, 227, 216, 0.2);
}

/* ── Base ──────────────────────────────────────────────────── */
html, body {
  background: var(--paper);
  color: var(--ink);
}

body {
  font-family: var(--font-serif);
  font-size: var(--body-size);
  line-height: var(--body-leading);
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: 40px;
}

::selection {
  background-color: var(--ink);
  color: var(--paper);
}

/* ── Content container ──────────────────────────────────── */
.content {
  max-width: min(var(--measure), var(--measure-cap));
  margin: 0 auto;
  padding: var(--content-pad-y) var(--content-pad-x) 80px;
}

.content main {
  max-width: none;
}

/* ── Headings ──────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.25;
  margin-top: 1.6em;
  margin-bottom: 0.6em;
  color: var(--ink);
  text-wrap: balance;
}

.chapter h1,
.content h1 {
  font-size: 2.6em;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--ink);
  border: none;
  padding: 0 0 0.4em 0;
  margin: 0.4em 0 0.8em;
  border-bottom: 0.5px solid var(--rule);
}

.chapter h2,
.content h2 {
  font-size: 1.4em;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  border: none;
  margin-top: 2em;
  margin-bottom: 0.5em;
  padding-bottom: 0;
}

.chapter h3,
.content h3 {
  font-size: 1.15em;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 1.6em;
}

.chapter h4 { font-size: 1em; font-weight: 600; }

/* ── Body paragraphs ───────────────────────────────────────── */
/* 한글 본문은 좌측 정렬 — justify는 word-break:keep-all 과 결합되면
   어절 사이 공백이 과하게 벌어진다. blockquote 등 센터링 컴포넌트는
   별도 규칙에서 text-align 을 다시 지정한다. */
p {
  margin: 1.1em 0;
  text-align: left;
  word-break: keep-all;
  text-wrap: pretty;
  hyphens: auto;
}

/* Drop cap — 챕터 첫 단락에 자동 적용. 명시 차단은 .no-dropcap */
.chapter > p:first-of-type:not(.no-dropcap)::first-letter,
.chapter > .lead:first-of-type::first-letter {
  float: left;
  font-family: var(--font-dropcap);
  font-weight: 700;
  font-size: 4em;
  line-height: 0.9;
  margin: 0.12em 0.12em -0.05em 0;
  color: var(--ink);
}

/* chapter-opener 블록 다음 첫 단락에도 드롭캡 */
.chapter > .chapter-opener + p:not(.no-dropcap)::first-letter {
  float: left;
  font-family: var(--font-dropcap);
  font-weight: 700;
  font-size: 4em;
  line-height: 0.9;
  margin: 0.12em 0.12em -0.05em 0;
  color: var(--ink);
}

/* ── Links ─────────────────────────────────────────────────── */
a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 0.5px solid var(--ink-faint);
  transition: border-color 0.2s ease;
}

a:hover {
  border-bottom-color: var(--ink);
}

/* ── Reference blockquote ─────────────────────────────────── */
blockquote {
  margin: 1.8em 0;
  padding: 0.9em 1.1em 0.9em 16px;
  max-width: none;
  background: transparent;
  border: none;
  border-left: 0.5px solid var(--rule);
  border-radius: 0;
  text-align: left;
  font-style: normal;
  font-size: 0.88em;
  font-weight: 400;
  line-height: var(--body-leading);
  color: var(--ink);
}

blockquote p { margin: 0.6em 0; text-align: left; }
blockquote p:first-child { margin-top: 0; }
blockquote p:last-child { margin-bottom: 0; }

/* ── Tables ────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 2em 0;
  font-family: var(--font-sans);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}

table thead tr {
  border-bottom: 0.5px solid var(--rule);
}

table th {
  background: transparent;
  color: var(--ink-muted);
  padding: 10px 8px;
  text-align: left;
  font-weight: 500;
  font-size: 0.78em;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

table td {
  padding: 10px 8px;
  border-bottom: 0.5px solid var(--ink-faint);
  color: var(--ink);
}

table tr:nth-child(even) { background: transparent; }
table tr:last-child td { border-bottom: none; }
table tr:hover { background: rgba(127, 127, 127, 0.04); }

/* ── Callouts (.tip / .warning) — hairline 톤 ─────────────── */
.tip, .warning {
  margin: 1.8em 0;
  padding: 0.8em 0 0.8em 16px;
  border: none;
  border-left: 0.5px solid var(--rule);
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  font-size: 0.96em;
  color: var(--ink);
}

.tip::before {
  content: "TIP";
  display: block;
  margin-bottom: 0.4em;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.72em;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.warning::before {
  content: "주의 · NOTE";
  display: block;
  margin-bottom: 0.4em;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.72em;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* 다크/세피아에서도 동일 hairline (덮어쓰기 제거) */
.light .warning, .rust .warning, .coal .warning, .navy .warning, .ayu .warning,
html[data-theme="light"] .warning,
html[data-theme="rust"] .warning,
html[data-theme="coal"] .warning,
html[data-theme="navy"] .warning,
html[data-theme="ayu"] .warning,
.light .tip, .rust .tip, .coal .tip, .navy .tip, .ayu .tip,
html[data-theme="light"] .tip,
html[data-theme="rust"] .tip,
html[data-theme="coal"] .tip,
html[data-theme="navy"] .tip,
html[data-theme="ayu"] .tip {
  background: transparent;
  border-left: 0.5px solid var(--rule);
  color: var(--ink);
}

/* ── Section break (hr) → ❦ ornament ───────────────────────── */
hr {
  border: 0;
  height: auto;
  background: transparent;
  text-align: center;
  margin: 3em 0;
  overflow: visible;
  position: relative;
}

hr::after {
  content: "❦";
  font-family: serif;
  font-size: 1.4em;
  letter-spacing: 0.6em;
  color: var(--ink-faint);
}

/* hairline 룰만 필요할 때 사용하는 명시 클래스 */
hr.hairline,
.hairline {
  display: block;
  height: 0;
  width: 32px;
  margin: 1.2em auto;
  border: 0;
  border-top: 0.5px solid var(--ink-faint);
  background: transparent;
}

hr.hairline::after, .hairline::after { content: ""; }

/* ── Lists ─────────────────────────────────────────────────── */
ul, ol {
  padding-left: 1.6em;
  margin: 1.1em 0;
}

li {
  margin: 0.4em 0;
  text-wrap: pretty;
}

/* ── Code ──────────────────────────────────────────────────── */
pre {
  background: var(--pre-bg);
  border: 0.5px solid var(--rule);
  border-radius: 2px;
  padding: 1em 1.2em;
  overflow-x: auto;
  margin: 1.6em 0;
  font-size: 0.9em;
  font-family: var(--font-mono);
  line-height: 1.55;
}

code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 2px;
  font-size: 0.88em;
}

pre code {
  background: transparent;
  padding: 0;
  font-size: 1em;
}

/* ── Perspective Box (톰뭉의 관점) ────────────────────────── */
.perspective-box {
  margin: 2rem 0;
  padding: 1.2rem 1.5rem;
  border: 1px solid var(--links, #4183c4);
  border-radius: 10px;
  background: var(--quote-bg, rgba(65,131,196,0.05));
  font-size: 0.95rem;
  line-height: 1.8;
}
.pb-label {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--links, #4183c4);
  margin-bottom: 0.55rem;
}
.perspective-box p { margin: 0.5rem 0; line-height: 1.7; }

/* ── Images / Figures ─────────────────────────────────────── */
img {
  max-width: 100%;
  height: auto;
  margin: 1.8em 0;
  border-radius: 0;
  box-shadow: none;
}

figure {
  margin: 2em 0;
  text-align: center;
}

figure img { margin: 0 0 0.5em; }

figcaption,
figure em,
.caption {
  display: block;
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 0.78em;
  line-height: 1.55;
  color: var(--ink-muted);
  text-align: left;
  border-left: 0.5px solid var(--ink-faint);
  padding-left: 12px;
  margin-top: 8px;
}

/* ── Illustrations ────────────────────────────────────────── */
.illus-full {
  display: block;
  width: 100%;
  height: auto;
  margin: 2.4em 0;
  border-radius: 2px;
}

.illus-center {
  display: block;
  width: 65%;
  max-width: 540px;
  height: auto;
  margin: 2.4em auto;
  border-radius: 2px;
}

.illus-half {
  float: right;
  width: 42%;
  max-width: 340px;
  height: auto;
  margin: 0.4em 0 1.6em 2em;
  border-radius: 2px;
  clear: right;
}

/* 삽화 하단 캡션 */
.illus-caption {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.76em;
  color: var(--ink-muted);
  text-align: center;
  margin-top: -1.8em;
  margin-bottom: 2em;
}

/* float 해제 */
.illus-clear { clear: both; }

@media only screen and (max-width: 768px) {
  .illus-center { width: 90%; max-width: none; }
  .illus-half {
    float: none;
    width: 90%;
    max-width: none;
    margin: 2em auto;
    display: block;
  }
}

/* ── Sidebar (TOC) ────────────────────────────────────────── */
:root { --sidebar-target-width: 310px; }

.sidebar {
  background: var(--sidebar-bg) !important;
  background-color: var(--sidebar-bg) !important;
  border-right: 0.5px solid var(--rule);
  font-family: var(--font-sans);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.sidebar-iframe-inner {
  background-color: var(--sidebar-bg) !important;
}

.sidebar .sidebar-scrollbox {
  padding: 1.4em 0 2em;
}

.sidebar .chapter {
  margin: 0;
}

.sidebar .chapter li > a,
.sidebar a {
  color: var(--ink-muted);
  border: none;
  border-left: 2px solid transparent;
  padding: 0.44em 1.1em;
  border-radius: 0;
  font-size: 0.9em;
  letter-spacing: -0.005em;
  line-height: 1.45;
  display: block;
  transition: color 0.15s ease, background 0.15s ease;
}

/* 챕터 번호 — mono, 작게, 연하게 */
.sidebar a strong {
  font-family: var(--font-mono);
  font-size: 0.72em;
  font-weight: 400;
  color: var(--ink-faint);
  letter-spacing: 0;
  vertical-align: 0.06em;
  margin-right: 0.5em;
  transition: color 0.15s ease;
}

/* 호버 */
.sidebar a:hover {
  color: var(--ink);
  background: rgba(127, 127, 127, 0.05);
}

/* 활성 항목 — !important 로 mdbook 기본 purple 완전 차단 */
.sidebar a.active {
  color: var(--ink) !important;
  font-weight: 600;
  background: rgba(31, 28, 24, 0.05) !important;
  border-left-color: var(--ink) !important;
}

.sidebar a.active strong {
  color: var(--ink-muted) !important;
}

/* 섹션 구분선 */
.sidebar .spacer {
  background: var(--rule);
  height: 0.5px;
  margin: 0.6em 1.1em;
}

.sidebar .part-title {
  font-family: var(--font-sans);
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 1.4em 1.1em 0.4em;
}

/* ── Page navigation arrows ───────────────────────────────── */
.nav-chapters {
  font-size: 1.6em;
  color: var(--ink-faint);
  border-radius: 0;
  transition: color 0.2s ease;
}

.nav-chapters:hover {
  color: var(--ink);
  background: transparent;
}

.mobile-nav-chapters {
  background: var(--paper-soft);
  border: 0.5px solid var(--rule);
  color: var(--ink-muted);
}

/* ── Menu bar (top) ───────────────────────────────────────── */
.menu-bar {
  background: var(--paper);
  border-bottom: 0.5px solid var(--rule);
  font-family: var(--font-sans);
}

.menu-title {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.menu-bar .icon-button {
  color: var(--ink-muted);
  transition: color 0.15s ease;
}

.menu-bar .icon-button:hover {
  color: var(--ink);
  background: transparent;
}

/* ── Classic Cover (preface 상단 HTML 블록) ──────────────── */
.classic-cover {
  margin: 0 -1em 3em;
  padding: 4em 2em;
  background: #1f1c18;
  color: #f1ece1;
  font-family: var(--font-serif);
  display: flex;
  flex-direction: column;
  min-height: 60vh;
  border-radius: 2px;
}

.classic-cover .eyebrow {
  font-family: var(--font-sans);
  font-size: 0.72em;
  font-weight: 500;
  letter-spacing: var(--tracking-cover);
  text-transform: uppercase;
  color: rgba(241, 236, 225, 0.55);
  margin-bottom: 2em;
}

.classic-cover .cover-title {
  font-family: var(--font-serif);
  font-size: 3.5em;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: #f1ece1;
  border: none;
  margin: 0 0 0.5em;
  padding: 0;
  text-wrap: balance;
}

.classic-cover .hairline {
  display: block;
  width: 48px;
  height: 1px;
  background: rgba(241, 236, 225, 0.35);
  margin: 0.6em 0 1em;
  border: 0;
}

.classic-cover .cover-sub {
  font-size: 1em;
  line-height: 1.55;
  color: rgba(241, 236, 225, 0.78);
  font-style: italic;
  max-width: 28ch;
  margin: 0 0 2em;
  text-align: left;
}

.classic-cover footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-sans);
  font-size: 0.78em;
  color: rgba(241, 236, 225, 0.6);
}

/* ── Chapter opener 블록 ──────────────────────────────────── */
.chapter-opener {
  text-align: center;
  padding: 3em 0 2.5em;
  margin: 0 0 2em;
  border-bottom: 0.5px solid var(--rule);
}

.chapter-opener .eyebrow {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.72em;
  font-weight: 500;
  letter-spacing: var(--tracking-cover);
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 1.6em;
}

.chapter-opener h1 {
  font-size: clamp(1.6em, 3.2vw, 2.8em);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.1;
  border: none;
  padding: 0;
  margin: 0 0 0.3em;
  color: var(--ink);
  white-space: nowrap;
  text-wrap: nowrap;
}

.chapter-opener .opener-en {
  display: block;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-muted);
  font-size: 0.88em;
  margin-bottom: 1.6em;
}

.chapter-opener .opener-quote {
  margin: 1.2em auto 0.4em;
  border: none;
  padding: 0;
  font-size: 1em;
  line-height: 1.7;
  font-style: italic;
  color: var(--ink-muted);
  max-width: 32ch;
  text-wrap: pretty;
}

.chapter-opener .opener-attr {
  font-family: var(--font-sans);
  font-size: 0.78em;
  color: var(--ink-muted);
  margin: 0.6em 0 0;
  text-align: center;
}

/* ── Mobile ───────────────────────────────────────────────── */
@media only screen and (max-width: 768px) {
  :root {
    --body-size: 17px;
    --content-pad-y: 32px;
    --content-pad-x: 20px;
    --measure: 100%;
  }

  .chapter h1, .content h1 { font-size: 2em; }
  .chapter h2, .content h2 { font-size: 1.25em; }
  .chapter h3, .content h3 { font-size: 1.08em; }

  blockquote { font-size: 0.85em; padding: 0.8em 0.9em 0.8em 12px; }

  table { font-size: 0.85em; }
  table th, table td { padding: 8px 6px; }

  .classic-cover { padding: 3em 1.2em; min-height: 50vh; }
  .classic-cover .cover-title { font-size: 2.6em; }

  .chapter-opener { padding: 2em 0 1.6em; }
  .chapter-opener h1 { font-size: 2em; white-space: normal; text-wrap: pretty; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  body { font-size: 11pt; line-height: 1.65; }
  .sidebar, .menu-bar, .nav-chapters, .mobile-nav-chapters { display: none !important; }
  .content { max-width: none; padding: 0; }
  .chapter-opener { page-break-before: always; }
  hr { page-break-after: avoid; }
  a { color: var(--ink); border-bottom: none; }
  #audio-bar { display: none !important; }
}

/* ── Audio Player Bar ─────────────────────────────────────── */
#audio-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9999;
  background: var(--paper, #fff);
  border-top: 1px solid var(--border-color, #e0ddd8);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  padding: 8px 16px;
  transition: transform .3s ease, opacity .3s ease;
}

.ab-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 860px;
  margin: 0 auto;
}

.ab-btn {
  flex-shrink: 0;
  background: var(--links, #b5651d);
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: opacity .15s;
}
.ab-btn:hover { opacity: .85; }
.ab-btn svg { width: 16px; height: 16px; fill: #fff; stroke: none; }

.ab-label {
  flex-shrink: 0;
  font-size: .78em;
  color: var(--ink, #3a3530);
  opacity: .7;
  white-space: nowrap;
}

.ab-progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ab-time {
  font-size: .72em;
  font-variant-numeric: tabular-nums;
  color: var(--ink, #3a3530);
  opacity: .6;
  white-space: nowrap;
}

.ab-progress {
  flex: 1;
  height: 4px;
  accent-color: var(--links, #b5651d);
  cursor: pointer;
  min-width: 0;
}

.ab-speed {
  flex-shrink: 0;
  font-size: .75em;
  background: transparent;
  border: 1px solid var(--border-color, #e0ddd8);
  border-radius: 4px;
  padding: 2px 4px;
  color: var(--ink, #3a3530);
  cursor: pointer;
}

.ab-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  font-size: .9em;
  color: var(--ink, #3a3530);
  opacity: .4;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.ab-close:hover { opacity: .8; }

.ab-volume {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ab-mute {
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .55;
  transition: opacity .15s;
}
.ab-mute:hover { opacity: .9; }
.ab-mute svg { width: 18px; height: 18px; fill: var(--ink, #3a3530); }
.ab-vol-range {
  width: 70px;
  height: 4px;
  accent-color: var(--links, #b5651d);
  cursor: pointer;
}

@media (max-width: 600px) {
  .ab-label { display: none; }
  .ab-speed { display: none; }
  .ab-vol-range { display: none; }
}

/* ── Advisor Panel ─────────────────────────────────────────── */
@media print {
  #advisor-trigger, #advisor-panel { display: none !important; }
}

#advisor-trigger {
  position: fixed;
  right: 20px;
  bottom: 76px; /* audio-bar 위 */
  z-index: 9998;
  background: linear-gradient(135deg, #d4752a 0%, #b5651d 100%);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: .85em;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 18px rgba(181,101,29,.42);
  transition: transform .15s, box-shadow .15s;
  animation: adv-trigger-glow 2.8s ease-in-out infinite;
}
#advisor-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(181,101,29,.55);
  animation: none;
}
@keyframes adv-trigger-glow {
  0%, 100% { box-shadow: 0 4px 18px rgba(181,101,29,.42); }
  50%       { box-shadow: 0 4px 26px rgba(181,101,29,.72); }
}
.adv-trigger-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.adv-trigger-icon::before {
  content: '✦';
  font-size: 1em;
  line-height: 1;
  color: rgba(255,255,255,.92);
  animation: adv-icon-spin 6s linear infinite;
  display: inline-block;
}
@keyframes adv-icon-spin {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.15); }
  100% { transform: rotate(360deg) scale(1); }
}

/* AI 뱃지 — 패널 타이틀 옆 */
.adv-ai-badge {
  display: inline-block;
  background: linear-gradient(135deg, #d4752a, #b5651d);
  color: #fff;
  font-size: .58em;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 4px;
  position: relative;
  top: -1px;
}

#advisor-panel {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, visibility .22s;
}
#advisor-panel.open { visibility: visible; opacity: 1; pointer-events: auto; }
.adv-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
}
.adv-card {
  position: relative;
  background: var(--paper, #fff);
  color: var(--ink, #3a3530);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  padding: 20px 22px 18px;
  font-family: inherit;
}

.adv-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.adv-title  { margin: 0; font-size: 1.05em; }
.adv-close {
  background: transparent; border: none; color: var(--ink, #3a3530);
  font-size: 1.05em; cursor: pointer; opacity: .55; padding: 4px;
}
.adv-close:hover { opacity: 1; }

.adv-pii {
  font-size: .72em;
  color: var(--ink, #3a3530);
  opacity: .6;
  background: var(--paper-soft, #f5f1ec);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 12px;
  line-height: 1.5;
}

.adv-form { display: flex; flex-direction: column; gap: 10px; }
.adv-freetext {
  resize: vertical; min-height: 70px;
  padding: 10px 12px; border: 1px solid var(--border-color, #e0ddd8); border-radius: 6px;
  background: var(--paper, #fff); color: var(--ink, #3a3530); font-family: inherit; font-size: .92em;
}
.adv-more summary {
  cursor: pointer; font-size: .82em; color: var(--links, #b5651d);
  margin: 4px 0; padding: 2px 0;
}
.adv-more label { display: flex; flex-direction: column; gap: 4px; font-size: .78em; margin-top: 6px; opacity: .85; }
.adv-more input {
  padding: 6px 10px; border: 1px solid var(--border-color, #e0ddd8); border-radius: 4px;
  background: var(--paper, #fff); color: var(--ink, #3a3530); font-family: inherit; font-size: .9em;
}
.adv-submit {
  background: var(--links, #b5651d); color: #fff; border: none;
  padding: 10px 16px; border-radius: 6px; font-size: .92em; font-family: inherit;
  cursor: pointer; transition: opacity .15s;
}
.adv-submit:hover { opacity: .9; }
.adv-submit:disabled { opacity: .55; cursor: wait; }

.adv-result { margin-top: 18px; }
.adv-cover {
  font-size: 1.05em; font-weight: 600; line-height: 1.55;
  padding: 14px; background: var(--paper-soft, #f5f1ec); border-radius: 8px;
  margin-bottom: 12px;
}
.adv-topics { display: flex; flex-direction: column; gap: 8px; }
.adv-topic {
  display: flex; justify-content: space-between; align-items: center;
  background: transparent;
  border: 1px solid var(--border-color, #e0ddd8); color: var(--ink, #3a3530);
  border-radius: 6px; padding: 10px 12px; cursor: pointer; font-family: inherit; font-size: .92em;
  transition: background .15s, border-color .15s;
}
.adv-topic::after { content: '▶'; font-size: .65em; opacity: .4; flex-shrink: 0; margin-left: 8px; transition: transform .2s, opacity .2s; }
.adv-topic:hover { background: var(--paper-soft, #f5f1ec); }
.adv-topic[aria-expanded="true"] { background: var(--paper-soft, #f5f1ec); border-color: var(--links, #b5651d); }
.adv-topic[aria-expanded="true"]::after { transform: rotate(90deg); opacity: .65; }
.adv-expansion {
  font-size: .92em; line-height: 1.7; padding: 10px 12px 4px 12px;
  border-left: 2px solid var(--links, #b5651d); margin-top: -4px; margin-bottom: 4px;
}
.adv-expansion p { margin: .5em 0; }
.adv-expansion a { color: var(--links, #b5651d); text-decoration: underline; }
.adv-disclaimer {
  font-size: .72em; opacity: .55; margin-top: 14px; line-height: 1.5;
}
.adv-status {
  font-size: .78em; color: var(--ink, #3a3530); opacity: .7; margin-top: 10px;
}

/* G1: 입력 칩 온보딩 */
.adv-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;
}
.adv-chip {
  background: var(--paper-soft, #f5f1ec);
  border: 1px solid var(--border-color, #e0ddd8);
  color: var(--ink, #3a3530);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: .78em; font-family: inherit; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.adv-chip:hover { background: var(--border-color, #e0ddd8); }
.adv-chip.active {
  background: var(--links, #b5651d); color: #fff;
  border-color: var(--links, #b5651d);
}

/* G5: 대화 스레드 */
.adv-thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.adv-thread-item {
  background: var(--paper-soft, #f5f1ec);
  border-radius: 8px; padding: 10px 12px;
  font-size: .86em; opacity: .75;
}
.adv-thread-q {
  font-size: .82em; opacity: .65; margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.adv-thread-q::before { content: '↳ '; }
.adv-thread-a { font-weight: 500; line-height: 1.5; }

/* G5: 새 대화 버튼 */
.adv-actions { margin-top: 12px; }
.adv-new-chat {
  background: transparent;
  border: 1px solid var(--border-color, #e0ddd8);
  color: var(--ink, #3a3530); opacity: .65;
  border-radius: 6px; padding: 6px 12px;
  font-size: .78em; font-family: inherit; cursor: pointer;
  transition: opacity .12s;
}
.adv-new-chat:hover { opacity: 1; }

/* G2: 스트리밍 커서 */
.adv-stream-cursor {
  display: inline-block;
  animation: adv-blink .8s step-end infinite;
  color: var(--links, #b5651d);
}
@keyframes adv-blink { 50% { opacity: 0; } }

/* G3: 구조화 응답 섹션 헤더 */
.adv-expansion .adv-section-title {
  font-size: .9em; font-weight: 700; margin: 12px 0 4px;
  color: var(--links, #b5651d); border-bottom: 1px solid var(--border-color, #e0ddd8);
  padding-bottom: 2px;
}
.adv-expansion .adv-section-title:first-child { margin-top: 4px; }

/* G7: 피드백 버튼 */
.adv-feedback {
  display: flex; gap: 8px; margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--border-color, #e0ddd8);
}
.adv-fb-btn {
  background: transparent;
  border: 1px solid var(--border-color, #e0ddd8);
  color: var(--ink, #3a3530);
  border-radius: 6px; padding: 5px 10px;
  font-size: .78em; font-family: inherit; cursor: pointer;
  transition: background .12s;
}
.adv-fb-btn:hover { background: var(--paper-soft, #f5f1ec); }
.adv-fb-thanks, .adv-fb-retry {
  font-size: .78em; opacity: .65; line-height: 2;
}

/* P2-B: 팔로업 질문 칩 */
.adv-followup {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--border-color, #e0ddd8);
  align-items: center;
}
.adv-followup-label {
  font-size: .72em; opacity: .5; flex-basis: 100%; margin-bottom: 2px;
}
.adv-followup-chip {
  background: transparent;
  border: 1px solid rgba(181,101,29,.35);
  color: #b5651d;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .78em; font-family: inherit; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.adv-followup-chip:hover {
  background: rgba(181,101,29,.06);
  border-color: #b5651d;
}

/* G6: 챕터 말미 CTA */
.adv-chapter-cta {
  margin: 40px 0 24px;
  background: var(--paper-soft, #f5f1ec);
  border: 1px solid var(--border-color, #e0ddd8);
  border-radius: 10px;
  padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.adv-chapter-cta-text {
  margin: 0; font-size: .92em; font-weight: 500;
  color: var(--ink, #3a3530);
}
.adv-chapter-cta-btn {
  background: var(--links, #b5651d); color: #fff; border: none;
  border-radius: 6px; padding: 9px 16px;
  font-size: .88em; font-family: inherit; cursor: pointer;
  white-space: nowrap; transition: opacity .15s;
}
.adv-chapter-cta-btn:hover { opacity: .88; }

/* G8: 인라인 섹션 트리거 */
.adv-inline-trigger {
  display: inline-flex; align-items: center;
  margin: 6px 0 16px;
  padding: 4px 12px;
  background: transparent;
  border: 1px dashed var(--links, #b5651d);
  color: var(--links, #b5651d);
  border-radius: 4px; font-size: .78em; font-family: inherit;
  cursor: pointer; opacity: .6;
  transition: opacity .15s, background .15s;
}
.adv-inline-trigger:hover { opacity: 1; background: rgba(181, 101, 29, 0.07); }

/* 드래그 핸들 — 모바일 bottom sheet 전용 */
.adv-drag-handle { display: none; }

@media (max-width: 600px) {
  #advisor-trigger { padding: 9px 12px; bottom: 72px; right: 12px; }
  .adv-trigger-text { display: none; }

  /* Bottom Sheet */
  #advisor-panel { align-items: flex-end; }
  .adv-drag-handle {
    display: flex;
    width: 100%;
    height: 28px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: grab;
    touch-action: pan-y;
  }
  .adv-drag-handle::after {
    content: '';
    width: 40px; height: 4px;
    background: var(--border-color, #e0ddd8);
    border-radius: 2px;
  }
  .adv-card {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    padding: 0 18px calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.32,0,.67,0);
  }
  #advisor-panel.open .adv-card { transform: translateY(0); }
  .adv-header {
    position: sticky; top: 0; z-index: 1;
    background: var(--paper, #fff);
    padding-top: 12px; padding-bottom: 8px; margin-bottom: 0;
  }
  .adv-chips { gap: 5px; }
  .adv-chip { font-size: .75em; padding: 4px 10px; }
  .adv-chapter-cta { flex-direction: column; align-items: flex-start; }
}

/* mdBook 기본 prev/next 화살표 숨김 — chapter-nav.js의 카드로 대체 */
.nav-chapters,
.mobile-nav-chapters {
  display: none !important;
}
