:root {
  font: 16px/1.53 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #2a252b;
  background: #f8f6f8;
  --surface: #fff;
  --muted: #625a62;
  --border: #ded5dc;
  --accent: #6f4564;
  --accent-deep: #58334f;
  --tint: #f1e9f0;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.24; letter-spacing: -.025em; }
h1 { font-size: clamp(1.75rem, 3.2vw, 2.45rem); }
h2 { font-size: clamp(1.25rem, 2.2vw, 1.65rem); }
h3 { font-size: 1.1rem; }
a { color: var(--accent-deep); text-underline-offset: .2em; }
button, input, textarea, select { font: inherit; }
button, summary { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #97718d; outline-offset: 3px; }

.layout { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; align-self: start; min-height: 100vh; padding: 27px 14px; border-right: 1px solid var(--border); background: var(--surface); }
.brand { display: grid; gap: 5px; padding: 6px 11px 26px; }
.brand strong { font-size: 1.18rem; }
.brand > span:last-child { color: var(--muted); font-size: .92rem; }
.book { position: relative; width: 28px; height: 21px; margin-bottom: 6px; color: var(--accent); }
.book::before, .book::after { content: ""; position: absolute; width: 14px; height: 21px; border: 2px solid currentColor; border-radius: 4px; }
.book::before { left: 0; transform: skewY(8deg); }
.book::after { right: 0; transform: skewY(-8deg); }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { display: block; padding: 10px 12px; border-radius: 8px; color: inherit; text-decoration: none; }
.sidebar nav a:hover, .sidebar nav a[aria-current="page"] { color: var(--accent-deep); background: var(--tint); }
.body { min-width: 0; }
.topbar { display: flex; align-items: center; min-height: 57px; padding: 11px clamp(19px, 4vw, 44px); border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar.offline { flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.workspace { width: min(100%, 1420px); margin-inline: auto; padding: 30px clamp(19px, 4vw, 56px) 55px; }
.workspace > h1, .view-title { margin-bottom: 20px; }
.block { margin-top: 21px; }
.block > h2 { margin-bottom: 12px; }
.stack { display: grid; gap: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card, .stage-tile, .editor, .blank, .collection {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.card, .editor { padding: clamp(14px, 2vw, 22px); }
.blank { min-height: 88px; }
.blank.large { min-height: min(43vh, 360px); }
.compact { min-height: 24px; }
.stage-tile { display: grid; align-content: start; gap: 5px; min-height: 90px; padding: 16px; color: inherit; text-decoration: none; }
.stage-tile:hover, .button:hover { border-color: #b497ac; background: #faf4f9; }
.stage-tile span { color: var(--accent); font-size: .9rem; }
.heading-row, .strip, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.heading-row { justify-content: space-between; margin-bottom: 14px; gap: 15px; }
.strip { margin-bottom: 14px; }
.actions { margin-top: 15px; }
.actions [hidden] { display: none; }
.button, .strip a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--accent-deep); text-decoration: none;
}
.button.primary, .strip [aria-current="step"], .strip [aria-pressed="true"] { border-color: var(--accent); background: var(--tint); font-weight: 650; }
.button:disabled { opacity: .53; cursor: default; }
.steps { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px 0; }
.boundary .card { min-height: 73px; }
.boundary h2 { color: var(--muted); font-size: .94rem; font-weight: 620; }
.editor { margin-top: 12px; }
.editor h2 { margin-bottom: 14px; }
.editor h3 { margin-bottom: 9px; }
.fields { display: grid; gap: 16px; }
.answer-fields { min-width: 0; margin: 0; border: 0; padding: 0; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span, legend, label.field { font-weight: 630; }
.field input:not([type="checkbox"]):not([type="radio"]), .field textarea, .field select {
  width: 100%; padding: 8px 10px; min-height: 40px;
  border: 1px solid #c9bdc7; border-radius: 7px; background: var(--surface);
  color: inherit; font-weight: 400;
}
.field textarea { resize: vertical; }
fieldset.field { margin: 0; border: 0; padding: 0; }
legend { padding: 0 0 7px; }
.choices { display: flex; flex-wrap: wrap; gap: 7px; }
.choice { display: flex; align-items: flex-start; gap: 7px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; }
.choice input { margin-top: .35em; accent-color: var(--accent); }
.collection { padding: 12px 14px; }
.collection summary, .strategy summary { font-weight: 650; }
.collection-body { margin-top: 11px; }
.strategy { min-height: 51px; }
.strategy [open] { min-width: 0; }
.projection { display: grid; gap: 9px; margin: 12px 0 0; }
.projection div { border-top: 1px solid var(--border); padding-top: 9px; }
.projection dt { font-weight: 630; }
.projection dd { min-height: 22px; margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.projection dd a { margin-left: .5em; }
.bookigai-layout { display: grid; grid-template-columns: minmax(250px, 1fr) minmax(230px, .75fr); gap: 20px; }
.wheel { display: grid; place-items: center; grid-template-columns: repeat(2, 1fr); width: min(100%, 425px); aspect-ratio: 1.15; gap: 0; margin: auto; padding: 16px 26px; }
.wheel button { width: 100%; aspect-ratio: 1; border-radius: 50%; border: 1px solid #bca3b7; background: #f6edf5; color: var(--accent-deep); padding: 10px; font-weight: 650; }
.wheel button[aria-pressed="true"] { border: 2px solid var(--accent); background: #eee0eb; }
.lane { min-height: 165px; }
.controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(155px, .4fr); gap: 11px; margin-bottom: 15px; }
.save-status { position: fixed; right: 20px; bottom: 20px; border-radius: 8px; background: #fff; padding: 7px 10px; }
.save-status:empty { display: none; }

.reader-home { display: grid; justify-items: start; gap: 12px; margin-bottom: 21px; }
.reader-compass { display: grid; gap: 14px; background: var(--tint); border-color: #cbb6c7; }
.reader-eyebrow { color: var(--accent-deep); font-weight: 650; font-size: .9rem; }
.reader-north-star { margin: 0; max-width: 40ch; font-size: clamp(1.3rem, 2.4vw, 1.85rem); line-height: 1.4; font-weight: 650; letter-spacing: -.025em; }
.reader-source { font-size: .9rem; }
.reader-journey { display: grid; gap: 9px; margin: 25px 0 20px; }
.reader-journey p { max-width: 92ch; white-space: pre-line; }
.reader-part-nav { gap: 8px; margin: 21px 0; }
.reader-parts { display: grid; gap: 20px; }
.reader-part { scroll-margin-top: 20px; padding: clamp(18px, 2.6vw, 30px); border-left: 4px solid var(--accent); }
.reader-part-heading { display: grid; gap: 5px; }
.reader-transition { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 20px 0; }
.reader-state { min-width: 0; padding: 14px 16px; border-radius: 8px; background: var(--tint); }
.reader-state h3 { margin-bottom: 6px; font-size: .9rem; letter-spacing: 0; color: var(--accent-deep); }
.reader-state p { white-space: pre-line; }
.reader-chapters-label { margin: 20px 0 9px; }
.reader-chapter-list { margin: 0; padding-left: 1.9rem; }
.reader-chapter-list li { padding-left: 4px; }
.reader-chapter-list li::marker { color: var(--accent-deep); font-weight: 650; }
.reader-chapter-link { display: grid; gap: 3px; padding: 12px 10px; margin-left: -10px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; border-radius: 5px; overflow-wrap: anywhere; }
.reader-chapter-link:hover { background: var(--tint); }
.reader-chapter-link strong { color: var(--accent-deep); }
.reader-chapter-link span { font-size: .92rem; color: var(--muted); }
.reader-part-question { margin: 17px 0 7px; color: var(--muted); }
.reader-frame { display: grid; align-content: start; gap: 10px; scroll-margin-top: 20px; }
#reader-bonuses { scroll-margin-top: 20px; }
.reader-frame-preview { padding: clamp(18px, 2.6vw, 30px); background: var(--tint); border-color: #cbb6c7; }
.reader-frame-preview h2 { font-size: clamp(1.4rem, 2.5vw, 1.9rem); }
.reader-frame-preview .button { justify-self: start; margin-top: 6px; }
.reader-frame-title { max-width: 35ch; }
.reader-tone-sample { background: var(--tint); }
.reader-copy { display: grid; align-content: start; gap: 10px; min-width: 0; }
.reader-copy p, .reader-structure-step > p { white-space: pre-line; }
.reader-muted { color: var(--muted); }
.reader-disclosure { min-width: 0; }
.reader-disclosure > summary { font-weight: 650; color: var(--accent-deep); }
.reader-disclosure-body { padding-top: 16px; }
.reader-source-list { margin: 0; padding-left: 1.4rem; display: grid; gap: 9px; }
.reader-source-list li { padding-left: 3px; overflow-wrap: anywhere; }
.reader-source-list p { margin-top: 4px; font-size: .9rem; }
.reader-breadcrumbs { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 19px; font-size: .9rem; }
.reader-chapter-title { margin: 7px 0 14px; }
.reader-chapter-structure { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.reader-structure-step { display: grid; align-content: start; gap: 15px; }
.reader-structure-step > h3 { display: flex; align-items: baseline; gap: 8px; color: var(--accent-deep); }
.reader-status { justify-self: start; padding: 3px 8px; border-radius: 5px; background: var(--tint); color: var(--accent-deep); font-size: .88rem; }
.reader-quote { margin: 0; padding: 4px 0 4px 14px; border-left: 3px solid var(--accent); font-size: 1.06rem; line-height: 1.5; white-space: pre-line; }
.reader-source-links { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .88rem; }
.reader-chapter-nav { padding-top: 10px; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 215px minmax(0, 1fr); }
  .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 740px) {
  .layout { display: block; }
  .sidebar { position: static; min-height: 0; padding: 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 8px 10px; }
  .brand .book { margin: 0; }
  .sidebar nav { display: flex; overflow: auto; padding: 3px; }
  .sidebar nav a { white-space: nowrap; padding: 7px 9px; }
  .topbar { min-height: 42px; }
  .workspace { padding-top: 21px; }
  .bookigai-layout { grid-template-columns: 1fr; }
  .reader-chapter-structure { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .grid, .grid.three, .controls { grid-template-columns: 1fr; }
  .reader-transition { grid-template-columns: 1fr; gap: 9px; }
  .reader-part { padding: 16px; }
  .reader-part-nav .button { min-height: 44px; }
}
