:root {
  --blue: #00a3e0;
  --blue-dark: #0089bf;
  --blue-soft: #eaf6fc;
  --ink: #22303a;
  --ink-2: #3b4a55;
  --ink-3: #4a5963;
  --muted: #6b7a85;
  --line: #dbe3e8;
  --line-2: #e3e9ed;
  --bg: #e9eef2;
  --side: #2c3740;
  --side-w: 288px;
  --sans: 'Source Sans 3', 'Segoe UI', sans-serif;
  --serif: 'Source Serif 4', Georgia, serif;
}
html, body { margin: 0; padding: 0; background: var(--bg); }
* { box-sizing: border-box; }
body { min-height: 100vh; font-family: var(--serif); color: var(--ink); }
a { color: var(--blue-dark); text-decoration: none; }
a:hover { color: #006a94; text-decoration: underline; }
button { font: inherit; }
p { margin: 0; text-wrap: pretty; }
[hidden] { display: none !important; }

/* ---------- Sidebar ---------- */
.side {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--side-w); z-index: 30;
  background: var(--side); color: #dfe7ec; display: flex; flex-direction: column;
  font-family: var(--sans); transition: transform .25s ease;
}
.side-head { padding: 22px 22px 18px; border-bottom: 1px solid #3c4952; display: flex; flex-direction: column; gap: 4px; }
.side-title { font-size: 20px; line-height: 1.15; font-weight: 800; color: #fff; }
.side-author { font-size: 13px; color: #a9b8c2; }
.side-nav { flex: 1; overflow-y: auto; padding: 12px 10px 24px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 6px; font-size: 15px; font-weight: 600; color: #dfe7ec;
}
.nav-item:hover { background: #36434d; color: #dfe7ec; text-decoration: none; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-num { font-size: 12px; font-weight: 400; color: #8fa0ab; }
.nav-item.active .nav-num { color: #e6f6fd; }
.nav-subs { display: flex; flex-direction: column; padding: 4px 0 8px 14px; margin-left: 12px; border-left: 1px solid #42505a; }
.nav-sub { color: #b9c7d0; padding: 5px 10px; font-size: 14px; border-radius: 5px; }
.nav-sub:hover { color: #fff; background: #36434d; text-decoration: none; }
.nav-soon { margin: 18px 12px 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #7d8e99; font-weight: 700; }
.nav-upcoming { padding: 6px 12px; font-size: 14px; color: #6f808b; }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(20, 28, 34, .45); z-index: 25; }

.wrap { padding-left: var(--side-w); padding-bottom: 110px; transition: padding-left .25s; }
.side-collapsed .side { transform: translateX(-100%); }
.side-collapsed .wrap { padding-left: 0; }

@media (max-width: 899px) {
  .side { transform: translateX(-100%); }
  .wrap { padding-left: 0; }
  .side-open .side { transform: none; }
  .side-open .backdrop { display: block; }
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; font-family: var(--sans);
  background: rgba(233, 238, 242, .94); backdrop-filter: blur(6px); border-bottom: 1px solid #d6dee4;
}
.topbar-in { max-width: 940px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 12px; }
.page-label { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pager { display: flex; gap: 8px; }
.btn {
  border: 1px solid #c7d2da; background: #fff; border-radius: 6px; padding: 6px 12px; cursor: pointer;
  font-size: 14px; color: var(--ink); white-space: nowrap; display: inline-block; line-height: 1.4;
}
.btn:hover { border-color: var(--blue); color: var(--ink); text-decoration: none; }
.menu-btn { padding: 6px 10px; }
.btn-primary { border-color: var(--blue); background: var(--blue); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #0090c8; color: #fff; }
.btn.disabled { opacity: .45; cursor: default; pointer-events: none; }

/* ---------- Page sheets ---------- */
.main { max-width: 940px; margin: 0 auto; padding: 32px 20px; display: flex; flex-direction: column; gap: 40px; }
.sheet { overflow-wrap: break-word; background: #fff; box-shadow: 0 4px 24px rgba(30, 45, 60, .10); padding: clamp(32px, 7vw, 80px) clamp(24px, 7vw, 88px); }
.running { font-family: var(--sans); font-size: 13px; color: var(--muted); letter-spacing: .04em; margin-bottom: 36px; }
[id^="sec-"] { scroll-margin-top: 76px; }

.cover { width: 100%; box-shadow: 0 10px 40px rgba(30, 45, 60, .22); background: #6f80c8; }
.cover img { display: block; width: 100%; height: auto; }

.title-page { padding: clamp(40px, 8vw, 96px) clamp(24px, 7vw, 88px); min-height: 960px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.title-img { width: 100%; max-width: 560px; height: auto; margin-top: 24px; }
.title-author { margin-top: 72px; display: flex; flex-direction: column; gap: 6px; font-family: var(--sans); font-size: 17px; color: var(--ink-3); }
.title-author .name { font-size: 26px; font-weight: 700; color: var(--ink); }
.grow { flex: 1; }
.title-logo { width: 150px; height: auto; margin-top: 80px; }

.copy-page { display: flex; flex-direction: column; gap: 16px; font-size: 17px; line-height: 1.6; }
.copy-page h2 { margin: 0 0 6px; font-family: var(--sans); font-size: 30px; font-weight: 800; }
.imprint { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; font-size: 14px; line-height: 1.55; color: var(--ink-2); }

.toc-page h2 { margin: 0 0 28px; font-family: var(--sans); font-size: 40px; font-weight: 800; color: var(--blue); }
.toc { display: flex; flex-direction: column; }
.toc-row { display: flex; align-items: baseline; gap: 8px; color: var(--ink); }
.toc-row:hover { text-decoration: none; color: var(--blue-dark); }
.toc-row .dots { flex: 1; border-bottom: 1px dotted #d0d8de; transform: translateY(-4px); }
.toc-row.lvl0 { margin-top: 18px; padding: 3px 0; font-family: var(--sans); font-weight: 700; font-size: 18px; color: var(--blue-dark); }
.toc-row.lvl0 .dots { border-bottom-color: #b8c4cc; }
.toc-row.lvl1 { padding: 2px 0 2px 22px; font-size: 16px; }
.toc-row.lvl2 { padding: 2px 0 2px 44px; font-size: 15px; }
.toc-row.dead { color: #8a98a2; cursor: default; }

.intro-page { font-size: 17px; line-height: 1.65; }
.intro-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; margin-bottom: 22px; }
.intro-page h1 { margin: 0; font-family: var(--sans); font-size: clamp(30px, 9vw, 44px); font-weight: 800; color: var(--blue); line-height: 1; }
.intro-page h3 { margin: 34px 0 8px; font-family: var(--sans); font-size: 22px; font-weight: 700; }
.intro-page p + p { margin-top: 16px; }

/* ---------- Chapter ---------- */
.chapter { padding: clamp(28px, 6vw, 72px) clamp(20px, 6vw, 80px); font-size: 17px; line-height: 1.6; }
.chapter .running { margin-bottom: 40px; }
.chap-head { border-bottom: 6px solid var(--blue); padding-bottom: 18px; margin-bottom: 30px; font-family: var(--sans); }
.chap-kicker { font-size: 22px; font-style: italic; color: var(--blue); font-weight: 600; }
.chap-head h1 { margin: 4px 0 0; font-size: clamp(38px, 6vw, 60px); font-weight: 800; letter-spacing: .01em; line-height: 1; }

.blk { display: flex; flex-direction: column; margin: 0 0 30px; }
.num { width: 26px; flex: none; color: var(--muted); }
.kicker { font-family: var(--sans); font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--blue); }
.quote { font-style: italic; color: var(--ink-2); font-size: 16px; line-height: 1.45; text-wrap: pretty; }
.quote .by { display: block; font-style: normal; font-family: var(--sans); font-size: 13px; color: var(--muted); margin-top: 3px; }

.sec-head { margin-top: 28px; border-top: 3px solid var(--blue); padding-top: 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.sec-head-text { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sec-head h2 { margin: 0; font-family: var(--sans); font-size: clamp(26px, 3.6vw, 34px); font-weight: 800; line-height: 1.15; text-wrap: balance; }

.sound { margin-top: 28px; border-top: 3px solid var(--blue); padding-top: 20px; display: flex; flex-direction: column; gap: 14px; }
.sound-top { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 18px 32px; }
.sound-sym { display: flex; align-items: baseline; gap: 12px; font-family: var(--sans); }
.sound-sym .sym { font-size: 52px; font-weight: 700; color: var(--blue); line-height: 1; }
.sound-sym .as-in { font-size: 15px; font-weight: 700; color: var(--muted); letter-spacing: .1em; }
.sound-sym .word { font-size: 34px; font-weight: 800; letter-spacing: .04em; line-height: 1; }
.sound-quote { flex: 1; min-width: 240px; }
.lips-tongue { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; background: var(--blue-soft); padding: 14px 18px; border-radius: 4px; }
.lt-k { font-family: var(--sans); font-weight: 700; color: var(--blue-dark); }
.video { width: 100%; aspect-ratio: 16 / 9; background: #1d262d; border-radius: 4px; overflow: hidden; }
.video iframe { display: block; width: 100%; height: 100%; border: 0; }

.blk-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.blk-head-text { display: flex; flex-direction: column; gap: 3px; font-family: var(--sans); }
.blk-head h3 { margin: 0; font-size: 21px; font-weight: 700; line-height: 1.25; }
.blk-head .sub { font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--ink-3); }

.paras { display: flex; flex-direction: column; gap: 14px; }
.figure { display: block; width: 100%; max-width: 880px; height: auto; margin: 0 auto; }

.vowels { display: flex; flex-direction: column; border-top: 2px solid var(--ink); }
.vrow { display: grid; grid-template-columns: 34px 62px minmax(0, 1fr) minmax(0, 1.15fr); gap: 6px 14px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 16px; line-height: 1.4; }
.vrow .num { width: auto; }
.vsym { font-family: var(--sans); font-weight: 700; color: var(--blue); }
.vsent { font-style: italic; color: var(--ink-2); }
@media (max-width: 600px) {
  .vrow { grid-template-columns: 34px 62px minmax(0, 1fr); }
  .vsent { grid-column: 2 / -1; }
}

.spell { display: flex; flex-direction: column; }
.srow { display: grid; grid-template-columns: 28px minmax(120px, 210px) minmax(0, 1fr); gap: 12px; padding: 4px 0; }
.srow .num { width: auto; }
.pat { font-weight: 600; }
@media (max-width: 600px) { .srow { grid-template-columns: 24px minmax(0, 40%) minmax(0, 1fr); gap: 10px; } }
.exc { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.exc .kicker { letter-spacing: .1em; }
.exc-row { display: grid; grid-template-columns: minmax(80px, 120px) minmax(0, 1fr); gap: 12px; }
.note { margin-top: 14px; font-size: 14px; line-height: 1.5; color: var(--ink-3); }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 40px; }
.nlist { display: flex; flex-direction: column; gap: 4px; }
.nlist-loose { gap: 6px; }
.nrow { display: flex; gap: 10px; }

.ctab { display: flex; flex-direction: column; }
.crow { display: grid; grid-template-columns: 30px 1fr 1fr; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line-2); }
.crow .num { width: auto; }
.crow > span { min-width: 0; hyphens: auto; }
.chead, .thead { border-bottom: 2px solid var(--blue); font-family: var(--sans); font-weight: 700; color: var(--blue); }

.cons { display: flex; flex-direction: column; border-top: 2px solid var(--ink); }
.cons-row { display: grid; grid-template-columns: minmax(150px, 190px) minmax(0, 1fr); gap: 8px 18px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cons.paired .cons-row { grid-template-columns: minmax(130px, 170px) minmax(130px, 170px) minmax(0, 1fr); }
.cons-head { font-family: var(--sans); font-weight: 700; color: var(--blue); font-size: 15px; padding: 6px 0; }
.cons-snd { display: flex; gap: 10px; align-items: baseline; }
.cons-sym { font-family: var(--sans); font-weight: 700; color: var(--blue); min-width: 40px; }
.cons-desc { background: var(--blue-soft); padding: 6px 12px; border-radius: 4px; font-size: 16px; line-height: 1.45; }
@media (max-width: 640px) {
  .cons-row, .cons.paired .cons-row { grid-template-columns: 1fr 1fr; }
  .cons-row:not(.paired) .cons-desc, .cons-desc { grid-column: 1 / -1; }
  .cons-head span:last-child { display: none; }
}

.box-warn { border: 2px solid var(--ink); padding: 18px 22px; display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.box-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.box-title-wrap { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.box-title { font-family: var(--sans); font-weight: 800; font-size: 18px; }
.box-title.soft { font-size: 19px; color: var(--blue-dark); }
.dont { font-family: var(--sans); font-size: 11px; font-weight: 800; letter-spacing: .1em; color: #fff; background: #c8102e; padding: 3px 8px; border-radius: 3px; }
.wtab { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; max-width: 340px; }
.wh { font-family: var(--sans); font-weight: 700; color: var(--blue); }
.box-soft { background: var(--blue-soft); padding: 22px 24px; display: flex; flex-direction: column; gap: 10px; }
.advice { font-style: italic; }
.advice-by { font-family: var(--sans); font-weight: 600; font-size: 14px; color: var(--ink-2); }
.box-tip { flex-direction: row; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.box-tip img { width: 110px; height: auto; flex: none; }
.tip-body { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 10px; }

/* --colw (set per list from its longest item) makes narrow screens drop columns before words overflow */
.nums { columns: var(--colw, 8em) var(--cols); column-gap: 40px; }
.nums .nrow { break-inside: avoid; padding: 2px 0; }
@media (max-width: 640px) { .nums { column-gap: 24px; } }
.lines { display: flex; flex-direction: column; gap: 2px; }

.box-nested { flex-direction: row; gap: 20px; align-items: flex-start; }
.box-nested.box-warn { max-width: none; }
.box-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.box-body > .blk { margin: 0; }
.box-icon { width: 110px; height: auto; flex: none; }
@media (max-width: 640px) { .box-nested { flex-direction: column; align-items: stretch; } }
.box-panel { background: var(--blue-soft); }

.tbl-wrap { overflow-x: auto; }
.tbl { display: flex; flex-direction: column; }
.trow { display: flex; gap: 14px; padding: 5px 0; border-bottom: 1px solid var(--line-2); }
.trow.thead { border-bottom: 2px solid var(--blue); }
.cell { flex: 1 1 0; min-width: 0; text-wrap: pretty; hyphens: auto; overflow-wrap: break-word; }

.dialog { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 14px 40px; }
.dlines { display: flex; flex-direction: column; gap: 2px; }

.script { display: flex; flex-direction: column; gap: 12px; }
.sline { display: flex; gap: 14px; }
.speaker { min-width: 62px; flex: none; font-family: var(--sans); font-weight: 700; white-space: nowrap; }
.sline-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ipa { font-family: var(--sans); font-size: 13px; color: var(--blue-dark); letter-spacing: .02em; white-space: pre-wrap; }

.words { display: flex; flex-direction: column; gap: 18px; }
.wgroup { display: flex; flex-direction: column; gap: 8px; }
.wcap { font-family: var(--sans); font-weight: 700; color: var(--blue-dark); font-size: 15px; }
.wgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 4px 16px; padding: 12px 16px; border: 1px solid #d6dee4; }

/* ---------- CD track button ---------- */
.trk {
  width: 58px; height: 58px; border-radius: 50%; flex: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05;
  font-family: var(--sans); border: 2px solid var(--blue); background: #fff; color: var(--blue-dark); padding: 0;
}
.trk-big { width: 62px; height: 62px; }
.trk-cd { font-size: 10px; font-weight: 700; }
.trk-lbl { font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.trk-n { font-size: 17px; font-weight: 800; }
.trk-big .trk-n { font-size: 18px; }
.trk.sel { background: var(--blue-soft); }
.trk.on { background: var(--blue); color: #fff; box-shadow: 0 0 0 5px rgba(0, 163, 224, .22); }
.trk.miss { border-style: dashed; border-color: #b8c4cc; color: #9aa8b2; }

/* ---------- Audio player ---------- */
.player { position: fixed; bottom: 16px; right: 16px; left: calc(var(--side-w) + 16px); z-index: 40; display: flex; justify-content: center; pointer-events: none; }
.side-collapsed .player { left: 16px; }
@media (max-width: 899px) { .player { left: 16px; } }
.player-in {
  pointer-events: auto; width: 100%; max-width: 720px; background: var(--side); color: #fff; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(20, 30, 40, .35); padding: 10px 14px; display: flex; align-items: center; gap: 14px; font-family: var(--sans);
}
.player-toggle { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; cursor: pointer; font-size: 15px; flex: none; }
.player-info { display: flex; flex-direction: column; min-width: 0; flex: none; }
.player-label { font-size: 15px; font-weight: 700; }
.player-file { font-size: 12px; color: #a9b8c2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.player-seek { flex: 1; height: 22px; display: flex; align-items: center; cursor: pointer; min-width: 60px; }
.player-bar { width: 100%; height: 5px; background: #46545e; border-radius: 3px; overflow: hidden; }
.player-fill { height: 100%; width: 0; background: var(--blue); }
.player-time { font-size: 13px; color: #cfd9df; font-variant-numeric: tabular-nums; flex: none; }
.player-close { border: 0; background: transparent; color: #a9b8c2; cursor: pointer; font-size: 18px; flex: none; padding: 4px; }
@media (max-width: 520px) { .player-info { display: none; } }

/* Intonation arrows (Chapter 7): ↗ rising, ↘ falling, raised over the word they follow */
.into {
  display: inline-block; margin: 0 .1em 0 .05em; color: var(--blue-dark);
  font-family: var(--sans); font-weight: 700; font-size: .95em; line-height: 1;
  transform: translateY(-.3em);
}
.nw { white-space: nowrap; }

/* Linking marks (Chapter 8): inserted /y/ /w/ glides and silent letters */
main sup { font-size: .68em; color: var(--blue-dark); font-weight: 700; }
main s { color: #9aa7b0; text-decoration-color: #c0392b; }
/* Linking tie between words: a small arc under the gap, as printed in the book */
.tie { display: inline-block; width: .45em; margin: 0 .05em; color: var(--blue); font-family: var(--sans);
  font-size: .9em; line-height: 1; transform: translateY(.35em); text-align: center; overflow: visible; }

/* Index (back matter) */
.ix-letters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 28px; font-family: var(--sans); font-weight: 700; }
.ix-letters a { min-width: 30px; padding: 4px 0; text-align: center; border: 1px solid var(--line); border-radius: 4px; }
.ix-letters a:hover { background: var(--blue-soft); text-decoration: none; }
.ix { column-count: 2; column-gap: 48px; }
@media (max-width: 640px) { .ix { column-count: 1; } }
.ix-group { break-inside: avoid-column; margin-bottom: 20px; scroll-margin-top: 70px; }
.ix-letter { font-family: var(--sans); font-size: 22px; font-weight: 800; color: var(--blue); border-bottom: 2px solid var(--blue); margin-bottom: 6px; }
.ix-entry { break-inside: avoid; padding: 2px 0; }
.ix-row { line-height: 1.45; }
.ix-sub { padding-left: 20px; font-size: .94em; }
.ix-term { margin-right: 8px; }
.ix-refs { font-family: var(--sans); font-size: .92em; color: #8a98a2; }
