/* ---------- Fonts (self-hosted Google Fonts, works offline) ---------- */
@font-face { font-family: 'Cormorant Garamond'; font-weight: 300; font-style: normal; font-display: swap; src: url(../fonts/cormorant-garamond-latin-300-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 300; font-style: italic; font-display: swap; src: url(../fonts/cormorant-garamond-latin-300-italic.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 400; font-style: normal; font-display: swap; src: url(../fonts/cormorant-garamond-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 400; font-style: italic; font-display: swap; src: url(../fonts/cormorant-garamond-latin-400-italic.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/cormorant-garamond-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Dancing Script'; font-weight: 500; font-display: swap; src: url(../fonts/dancing-script-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Dancing Script'; font-weight: 700; font-display: swap; src: url(../fonts/dancing-script-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Red Hat Display'; font-weight: 400; font-display: swap; src: url(../fonts/red-hat-display-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Red Hat Display'; font-weight: 500; font-display: swap; src: url(../fonts/red-hat-display-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Red Hat Display'; font-weight: 700; font-display: swap; src: url(../fonts/red-hat-display-latin-700-normal.woff2) format('woff2'); }

/* ---------- Theme tokens ---------- */
:root {
  --serif: 'Cormorant Garamond', Garamond, 'Times New Roman', serif;
  --script: 'Dancing Script', 'Brush Script MT', cursive;
  --ui: 'Red Hat Display', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --brand: #252E65;        /* top bar + cover */
  --brand-ink: #FFFFFF;    /* text on brand */
  --accent: #C9A45C;       /* gold: decorative + on navy */
  --accent-ink: #8A6A2F;   /* gold dark enough for text on white (5.0:1) */
  --page: #FFFFFF;
  --desk: #F3F1EC;         /* background behind the page */
  --text: #1F1F1F;
  --muted: #5F6470;
  --rule: #2B2B2B;
  --ruled: #D9D9D9;
  --sidebar: #FFFFFF;
  --sidebar-line: #E6E3DC;
  --hover: #F6F3EC;
  --danger: #C62828;
  --shadow: 0 2px 6px rgba(20,20,40,.08), 0 12px 36px rgba(20,20,40,.10);
  --line: 32px;
  --radius: 6px;
}
[data-theme="blue"] {
  --brand: #FFFFFF;
  --brand-ink: #2F6FD0;
  --accent: #2F6FD0;
  --accent-ink: #255BB0;
  --desk: #EEF4FA;
  --sidebar-line: #CADCED;
  --hover: #EEF4FA;
}
[data-theme="blue"] .topbar { border-bottom: 3px solid #2F6FD0; }
[data-theme="blue"] .wordmark .gold { color: #255BB0; }
[data-dark="true"] {
  --page: #1B1D26;
  --desk: #111219;
  --text: #E8E6E1;
  --muted: #A3A6B2;
  --rule: #8C8F9C;
  --ruled: #343746;
  --sidebar: #171922;
  --sidebar-line: #2A2D3A;
  --hover: #22252F;
  --accent-ink: #D9C08A;
  --shadow: 0 2px 10px rgba(0,0,0,.5);
}
[data-dark="true"][data-theme="blue"] { --brand: #171922; --brand-ink: #8DB6F0; --accent: #8DB6F0; --accent-ink: #8DB6F0; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--desk); color: var(--text); font-family: var(--ui); font-size: 16px; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; border-radius: 3px; }
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--page); padding: 10px 14px; z-index: 100; border-radius: 4px; }
.skip-link:focus { top: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--sidebar-line); background: var(--page); cursor: pointer; font-family: var(--ui); font-weight: 500; font-size: 15px; text-decoration: none; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
[data-theme="blue"] .btn.primary { background: #2F6FD0; color: #fff; border-color: #2F6FD0; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn[aria-pressed="true"] { background: var(--hover); border-color: var(--accent-ink); }
.icon-btn { padding: 0; width: 44px; border-radius: 50%; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 14px; padding: 8px 16px; min-height: 60px; background: var(--brand); color: var(--brand-ink); }
.topbar .btn { background: transparent; color: var(--brand-ink); border-color: rgba(255,255,255,.25); }
[data-theme="blue"] .topbar .btn { border-color: var(--sidebar-line); }
.topbar .btn:hover { background: rgba(255,255,255,.1); }
.wordmark { font-family: var(--serif); font-weight: 600; letter-spacing: .14em; font-size: 19px; white-space: nowrap; text-decoration: none; }
.wordmark .gold { color: var(--accent); }
.progress-wrap { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 120px; max-width: 420px; margin-left: auto; }
.progress { flex: 1; height: 8px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
[data-theme="blue"] .progress { background: #CADCED; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress-label { font-size: 13px; white-space: nowrap; }
.views { display: flex; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; overflow: hidden; }
[data-theme="blue"] .views { border-color: var(--sidebar-line); }
.views button { min-height: 40px; padding: 0 14px; border: 0; background: transparent; color: var(--brand-ink); cursor: pointer; font-weight: 500; font-size: 14px; }
.views button[aria-pressed="true"] { background: var(--accent); color: #1F1F1F; }
[data-theme="blue"] .views button[aria-pressed="true"] { color: #fff; background: #2F6FD0; }
.menu-toggle { display: none; }

/* settings popover */
.popover { position: absolute; right: 12px; top: 64px; width: 290px; background: var(--page); color: var(--text); border: 1px solid var(--sidebar-line); border-radius: 10px; box-shadow: var(--shadow); padding: 14px; z-index: 60; }
.popover h3 { font: 600 12px var(--ui); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 10px 0 6px; }
.popover h3:first-child { margin-top: 0; }
.popover .row { display: flex; flex-wrap: wrap; gap: 8px; }
.popover label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.popover label.check input { width: 20px; height: 20px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100vh - 60px); }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--sidebar-line); overflow-y: auto; position: sticky; top: 60px; height: calc(100vh - 60px); padding: 12px 0 40px; }
.sidebar .front-links { padding: 0 12px 8px; display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--sidebar-line); }
.sidebar .front-links a { font-size: 13px; padding: 8px 10px; border-radius: 6px; text-decoration: none; min-height: 36px; display: inline-flex; align-items: center; }
.sidebar .front-links a:hover { background: var(--hover); }
.side-part { font-family: var(--serif); font-style: italic; font-size: 18px; padding: 16px 18px 6px; color: var(--muted); }
.side-ch { border-left: 4px solid transparent; }
.side-ch.current { border-left-color: var(--accent); background: var(--hover); }
.side-ch-head { display: flex; align-items: center; }
.side-ch-head a { flex: 1; display: flex; gap: 8px; align-items: baseline; padding: 10px 6px 10px 14px; min-height: 44px; text-decoration: none; font-size: 15px; }
.side-ch-head a .n { color: var(--muted); font-size: 12px; min-width: 22px; }
.side-ch-head .count { font-size: 12px; color: var(--muted); padding-right: 4px; white-space: nowrap; }
.side-ch-head .count.done { color: var(--accent-ink); font-weight: 700; }
.side-ch-head button { width: 40px; min-height: 44px; border: 0; background: transparent; cursor: pointer; color: var(--muted); }
.side-ch-head button svg { transition: transform .2s; }
.side-ch-head button[aria-expanded="true"] svg { transform: rotate(90deg); }
.side-qs { list-style: none; margin: 0; padding: 0 8px 8px 40px; }
.side-qs a { display: flex; gap: 10px; align-items: flex-start; padding: 7px 8px; font-size: 13px; line-height: 1.35; text-decoration: none; border-radius: 6px; color: var(--text); }
.side-qs a:hover { background: var(--page); }
.side-qs a[aria-current="page"] { font-weight: 700; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--muted); margin-top: 4px; }
.dot.answered { background: var(--text); border-color: var(--text); }
.dot.flagged { border-color: var(--accent-ink); background: transparent; box-shadow: inset 0 0 0 2px var(--page), inset 0 0 0 5px var(--accent-ink); }
.dot.skipped { border-style: dashed; }
.dot.answered.flagged { background: var(--accent-ink); border-color: var(--accent-ink); box-shadow: none; }
.scrim { display: none; }

.main { padding: 20px 24px 120px; min-width: 0; }
.crumbs { max-width: 820px; margin: 0 auto 12px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { opacity: .6; }
.sample-banner { max-width: 820px; margin: 0 auto 12px; padding: 10px 14px; border: 1px dashed var(--accent-ink); border-radius: 8px; font-size: 14px; color: var(--accent-ink); background: var(--page); }

/* ---------- Page card ---------- */
.page { position: relative; max-width: 820px; margin: 0 auto; background: var(--page); box-shadow: var(--shadow); border-radius: 3px; padding: 56px 64px 40px; aspect-ratio: 8.5 / 11; display: flex; flex-direction: column; }
.page.auto { aspect-ratio: auto; min-height: 60vh; }
/* cover, dividers and openers scale to fit the screen while keeping the 8.5:11 page shape */
.page.fit { width: min(100%, max(480px, calc((100vh - 250px) * 0.7727))); padding: 40px; }
.page.fit .cover-title { font-size: clamp(34px, 5.2vh, 56px); }
.page.fit .cover-art { width: 60%; }
.page.fit .opener-illus .illus, .opener .illus { width: 60%; }
.page .home { position: absolute; top: 14px; right: 14px; color: var(--muted); }
.page.turn { animation: turn .32s ease-out; transform-origin: left center; }
@keyframes turn { from { opacity: 0; transform: perspective(1400px) rotateY(-6deg) translateX(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page.turn { animation: none; } * { transition: none !important; } }

.label { font-family: var(--ui); font-weight: 700; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink); margin: 0 0 10px; }
.tag-custom { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 99px; background: var(--hover); color: var(--accent-ink); font-size: 11px; letter-spacing: .06em; border: 1px solid var(--accent-ink); }
.question { font-family: var(--serif); font-weight: 400; font-size: 24px; line-height: 1.3; margin: 0 0 18px; }

/* ruled writing area */
.ruled { position: relative; flex: 1; display: flex; min-height: calc(var(--line) * 10); }
.ruled textarea, .ruled .live {
  flex: 1; width: 100%; min-height: calc(var(--line) * 10); resize: none; border: 0; outline: none; padding: 0 4px; margin: 0;
  font-family: var(--serif); font-weight: 300; font-size: 21px; line-height: var(--line); color: var(--text);
  background-color: transparent;
  background-image: linear-gradient(to bottom, transparent calc(var(--line) - 1px), var(--ruled) calc(var(--line) - 1px), var(--ruled) var(--line));
  background-size: 100% var(--line); background-attachment: local; background-position: 0 6px; padding-top: 6px;
}
.ruled textarea:focus-visible { outline: none; }
.ruled:focus-within { box-shadow: 0 -2px 0 0 transparent, 0 2px 0 0 var(--accent); }
.ruled .live { white-space: pre-wrap; overflow-wrap: anywhere; overflow-y: auto; }
.ruled .live .interim { color: var(--muted); font-style: italic; }
.ruled .live .caret { display: inline-block; width: 2px; height: 1em; background: var(--danger); vertical-align: -2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.page.big .ruled, .page.big .ruled textarea { min-height: calc(var(--line) * 18); }

/* toolbar */
.page.big .toolbar { position: sticky; bottom: 68px; background: var(--page); z-index: 2; margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--sidebar-line); }
.toolbar .spacer { flex: 1; }
.toolbar .meta { font-size: 13px; color: var(--muted); display: flex; gap: 14px; align-items: center; }
.saved { display: inline-flex; align-items: center; gap: 6px; }
.saved::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #2E7D32; }
.saved.saving::before { background: var(--accent); }
.rec { display: none; align-items: center; gap: 8px; color: var(--danger); font-weight: 700; font-size: 14px; }
.rec.on { display: inline-flex; }
.rec .pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
.rec.paused .pulse { animation: none; opacity: .4; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(198,40,40,.6); } 70% { box-shadow: 0 0 0 10px rgba(198,40,40,0); } 100% { box-shadow: 0 0 0 0 rgba(198,40,40,0); } }
.btn.mic[aria-pressed="true"] { background: var(--danger); color: #fff; border-color: var(--danger); }
.note { font-size: 14px; color: var(--muted); background: var(--hover); border-radius: 8px; padding: 10px 12px; margin-top: 10px; }
.status-pill { font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--accent-ink); color: var(--accent-ink); }

.media-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.thumb { position: relative; width: 96px; height: 96px; border-radius: 4px; overflow: hidden; border: 1px solid var(--sidebar-line); background: var(--hover); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .rm, .clip .rm { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; display: grid; place-items: center; }
.clip { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 40px 6px 8px; border: 1px solid var(--sidebar-line); border-radius: 99px; font-size: 13px; }
.clip .rm { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); }
.clip audio { height: 32px; max-width: 220px; }

/* bottom nav */
.bottom-nav { position: fixed; left: 300px; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: color-mix(in srgb, var(--desk) 88%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--sidebar-line); }
.dots { flex: 1; display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; }
.dots a { width: 28px; height: 44px; display: grid; place-items: center; }
.dots a .dot { margin: 0; width: 12px; height: 12px; }
.dots a[aria-current="step"] .dot { box-shadow: 0 0 0 2px var(--page), 0 0 0 4px var(--accent-ink); }

/* ---------- Book-ish pages ---------- */
.script { font-family: var(--script); font-weight: 500; }
.cover { background: var(--brand); color: #fff; align-items: center; justify-content: center; text-align: center; }
[data-theme="blue"] .cover { background: #fff; color: #2F6FD0; outline: 3px solid #2F6FD0; outline-offset: -18px; }
.cover .home { color: inherit; }
.cover-title { font-family: var(--serif); font-weight: 400; letter-spacing: .18em; line-height: 1.15; font-size: 56px; margin: 0; text-transform: uppercase; }
.cover-title span { display: block; }
.cover-title .dads { border-top: 1px solid currentColor; border-bottom: 1px solid currentColor; padding: 6px 0 8px; margin: 10px auto; width: fit-content; min-width: 70%; color: var(--accent); }
[data-theme="blue"] .cover-title .dads { color: #2F6FD0; }
.cover-sub { font-family: var(--script); font-size: 28px; margin: 28px 0 36px; color: inherit; }
.cover-art { width: 66%; max-width: 360px; color: inherit; }
.cover-art .fill { fill: #252E65; }
[data-theme="blue"] .cover-art .fill { fill: #fff; }
.cover .begin { margin-top: 32px; background: var(--accent); color: #1F1F1F; border: 0; }
[data-theme="blue"] .cover .begin { background: #2F6FD0; color: #fff; }

.h-script { font-family: var(--script); font-weight: 500; font-size: 44px; margin: 0 0 18px; line-height: 1.15; }
.body-serif { font-family: var(--serif); font-weight: 300; font-size: 21px; line-height: 1.55; }
.body-serif p { margin: 0 0 1em; }
.sig-line { display: flex; flex-direction: column; gap: 4px; margin-top: 18px; max-width: 360px; }
.sig-line input { border: 0; border-bottom: 1px solid var(--rule); background: transparent; font-family: var(--script); font-size: 30px; padding: 4px 2px; min-height: 48px; }
.sig-line small { font-size: 12px; color: var(--muted); }

.toc-grid { display: grid; grid-template-columns: 1fr 1fr; margin-top: 10px; }
.toc-grid > section { padding: 18px 22px; }
.toc-grid > section:nth-child(odd) { border-right: 1px solid var(--rule); }
.toc-grid > section:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
.toc-grid h3 { font-family: var(--script); font-weight: 500; font-size: 28px; margin: 0; }
.toc-grid h3 small { display: block; font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--muted); }
.toc-grid ol { list-style: none; padding: 0; margin: 10px 0 0; }
.toc-grid li a { display: flex; gap: 8px; align-items: baseline; min-height: 40px; padding: 6px 0; text-decoration: none; font-family: var(--serif); font-size: 18px; }
.toc-grid li a:hover .t { text-decoration: underline; }
.toc-grid li .t { flex: 1; }
.toc-grid li .prog { font-family: var(--ui); font-size: 12px; color: var(--muted); }
.toc-grid li .prog.done { color: var(--accent-ink); font-weight: 700; }
.toc-front { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.divider { align-items: center; justify-content: center; text-align: center; }
.divider-frame { border: 1px solid var(--rule); padding: 70px 40px; width: 78%; }
.divider-frame .num { font-family: var(--script); font-size: 64px; margin: 0; }
.divider-frame .name { font-family: var(--serif); font-style: italic; font-size: 22px; margin: 10px 0 0; }

.opener { align-items: center; text-align: center; justify-content: center; }
.opener .kicker { font-family: var(--serif); font-weight: 600; letter-spacing: .25em; font-size: 16px; margin: 0; }
.opener .title-block { width: 80%; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 18px 0 22px; margin: 16px 0 36px; }
.opener h2 { font-family: var(--script); font-weight: 500; font-size: 50px; margin: 0; line-height: 1.1; }
.opener .illus { width: 60%; max-width: 320px; color: var(--text); }
.opener .meta { margin-top: 28px; font-size: 14px; color: var(--muted); }

.form-grid { display: grid; gap: 16px; }
.field label { display: block; font-family: var(--serif); font-size: 19px; margin-bottom: 4px; }
.field input, .field textarea { width: 100%; border: 0; border-bottom: 1px solid var(--rule); background: transparent; font-family: var(--serif); font-weight: 300; font-size: 20px; padding: 6px 2px; min-height: 44px; }
.field textarea { resize: vertical; line-height: var(--line); background-image: linear-gradient(to bottom, transparent calc(var(--line) - 1px), var(--ruled) calc(var(--line) - 1px)); background-size: 100% var(--line); border-bottom: 0; min-height: calc(var(--line) * 3); }

table.timeline { width: 100%; border-collapse: collapse; font-family: var(--serif); font-size: 17px; }
table.timeline th { font-family: var(--ui); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--rule); color: var(--muted); }
table.timeline td { border-bottom: 1px solid var(--ruled); padding: 0; }
table.timeline input { width: 100%; border: 0; background: transparent; padding: 8px 6px; min-height: 44px; font-family: var(--serif); font-size: 17px; }
table.timeline td.x { width: 44px; }
.table-scroll { overflow-x: auto; }

/* family tree */
.ftree { display: flex; flex-direction: column-reverse; gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.ftree .gen { display: grid; gap: 6px; min-width: max-content; }
.ftree .gen-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ftree .row { display: grid; gap: 4px; }
.fnode { min-height: 44px; min-width: 44px; padding: 6px 8px; border: 1px solid var(--rule); border-radius: 4px; background: var(--page); cursor: pointer; font-family: var(--serif); font-size: 15px; line-height: 1.15; text-align: center; }
.fnode .r { display: block; font-family: var(--ui); font-size: 10px; color: var(--muted); }
.fnode.filled { border-color: var(--accent-ink); background: var(--hover); }
.gen-5 .fnode { font-size: 11px; padding: 4px 2px; }
.gen-5 .fnode .r { font-size: 9px; }

dialog { border: 1px solid var(--sidebar-line); border-radius: 10px; background: var(--page); color: var(--text); padding: 22px; width: min(520px, 92vw); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10,12,30,.45); }
dialog h3 { margin: 0 0 12px; font-family: var(--script); font-weight: 500; font-size: 30px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* recipes */
.recipe { border: 1px solid var(--rule); border-radius: 4px; padding: 18px; margin-bottom: 16px; }
.recipe .head { display: flex; gap: 10px; align-items: center; }
.recipe .head input { flex: 1; font-family: var(--script); font-size: 28px; border: 0; border-bottom: 1px solid var(--rule); background: transparent; min-height: 48px; }
.recipe .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }

.chapter-list .item { border-top: 1px solid var(--sidebar-line); padding: 22px 0; }
.chapter-list .item:first-child { border-top: 0; }
.chapter-list .ruled, .chapter-list .ruled textarea { min-height: calc(var(--line) * 6); }
.chapter-list .q-actions { display: flex; gap: 8px; margin-top: 6px; }

.closing { text-align: center; align-items: center; justify-content: center; }
.closing .actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 28px; }

.add-custom { display: flex; gap: 8px; margin-top: 10px; }
.add-custom input { flex: 1; min-height: 44px; border: 1px solid var(--sidebar-line); border-radius: 8px; padding: 0 12px; background: var(--page); font-family: var(--serif); font-size: 18px; }

/* ---------- Book preview ---------- */
.book-toolbar { max-width: 820px; margin: 0 auto 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.book-toolbar .spacer { flex: 1; }
.book { max-width: 820px; margin: 0 auto; }
.bpage { background: var(--page); box-shadow: var(--shadow); padding: 72px 80px; margin-bottom: 24px; min-height: 400px; }
.bpage.fill { aspect-ratio: 8.5 / 11; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.bpage.cover { background: var(--brand); color: #fff; }
[data-theme="blue"] .bpage.cover { background: #fff; color: #2F6FD0; outline: 3px solid #2F6FD0; outline-offset: -18px; }
.bq { margin: 0 0 26px; break-inside: auto; }
.bq h4 { font-family: var(--serif); font-weight: 600; font-size: 20px; margin: 0 0 8px; line-height: 1.3; break-after: avoid; }
.bq .ans { font-family: var(--serif); font-weight: 300; font-size: 19px; line-height: 1.6; white-space: pre-wrap; }
.bq .ans.empty { color: var(--muted); font-style: italic; }
.bq .photos { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.bq .photos img { max-width: 48%; max-height: 300px; border: 1px solid var(--sidebar-line); }
.bq .flag-note { font-family: var(--ui); font-size: 11px; color: var(--accent-ink); }
.book h3.section { font-family: var(--script); font-weight: 500; font-size: 36px; margin: 0 0 16px; }
.book .toc-list { columns: 2; font-family: var(--serif); font-size: 17px; }
.book .toc-list div { break-inside: avoid; margin-bottom: 4px; }
.book dl { font-family: var(--serif); font-size: 18px; }
.book dt { font-weight: 600; }
.book dd { margin: 0 0 10px; font-weight: 300; white-space: pre-wrap; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: 100%; width: min(320px, 86vw); z-index: 70; transform: translateX(-105%); transition: transform .25s; box-shadow: var(--shadow); padding-top: 16px; }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(10,12,30,.4); z-index: 65; }
  .bottom-nav { left: 0; padding: 8px 10px; }
  .main { padding: 12px 10px 130px; }
  .page { aspect-ratio: auto; min-height: calc(100vh - 220px); padding: 40px 20px 20px; }
  .question { font-size: 22px; }
  .cover-title { font-size: 40px; }
  .progress-wrap .progress-label { display: none; }
  .wordmark { font-size: 15px; letter-spacing: .08em; }
  .toc-grid { grid-template-columns: 1fr; }
  .toc-grid > section { border-right: 0 !important; border-bottom: 1px solid var(--rule); }
  .recipe .cols { grid-template-columns: 1fr; }
  .bpage { padding: 36px 22px; }
  .divider-frame { width: 100%; padding: 50px 16px; }
  .opener .title-block { width: 100%; }
  .dots { display: none; }
  .bottom-nav .pos { flex: 1; text-align: center; font-size: 13px; color: var(--muted); }
}
@media (min-width: 901px) { .bottom-nav .pos { display: none; } }
@media (max-width: 560px) {
  .views button { padding: 0 10px; font-size: 13px; }
  .topbar { gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
  .progress-wrap { order: 5; flex-basis: 100%; max-width: none; margin: 0; }
}
