/* ==========================================================================
   Noveling — UI styles
   Sections: 1 Tokens · 2 Base · 3 Components · 4 Shell · 5 Templates
             6 Screens · 7 Responsive
   Rule: sizes, spaces, radii and colours come from tokens only.
   ========================================================================== */

/* 1. TOKENS ================================================================ */
:root {
  /* colour */
  --ink: #1c1914;
  --ink-soft: #4a453f;
  --paper: #f3efe6;
  --paper-2: #e8e1d4;
  --sea: #1f4f5b;
  --sea-deep: #163840;
  --sea-tint: rgba(31, 79, 91, 0.08);
  --clay: #a35a3a;
  --warn: #7a4f0e;
  --warn-tint: rgba(138, 90, 18, 0.1);
  --block: #8b2e2e;
  --block-tint: rgba(139, 46, 46, 0.08);
  --line: rgba(28, 25, 20, 0.12);
  --line-strong: rgba(28, 25, 20, 0.22);
  --on-sea: #f7f3eb;

  /* surfaces */
  --surface-1: rgba(255, 252, 246, 0.92);
  --surface-2: #fff;
  --shadow-1: 0 10px 30px rgba(22, 56, 64, 0.08);
  --shadow-2: 0 24px 60px rgba(22, 56, 64, 0.18);

  /* type */
  --serif: "Source Serif 4", Georgia, serif;
  --display: "Fraunces", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --fs-xs: 0.8rem;
  --fs-sm: 0.9rem;
  --fs-md: 1rem;
  --fs-lg: 1.15rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2.25rem;

  /* space (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* radii */
  --r-sm: 8px;
  --r-md: 14px;
  --r-pill: 999px;

  /* sizes */
  --h-sm: 32px;
  --h-md: 40px;
  --h-lg: 48px;
  --w-shell: 1200px;
  --w-read: var(--w-shell);
  --w-narrow: 760px;
  --w-side: 360px;
  --top-h: 60px;
  --book-h: 56px;
  --decision-clearance: 0px;
}

/* 2. BASE ================================================================== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: var(--fs-md)/1.5 var(--sans);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(31, 79, 91, 0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(163, 90, 58, 0.06), transparent 55%),
    linear-gradient(180deg, #f7f3eb 0%, var(--paper) 40%, #ebe4d7 100%);
  background-attachment: fixed;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; }
.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -100px;
  z-index: 100;
  padding: var(--sp-2) var(--sp-4);
  background: var(--sea);
  color: var(--on-sea);
  border-radius: var(--r-sm);
  font-weight: 600;
}
.skip-link:focus { top: var(--sp-3); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--ink-soft); }

/* form controls — one style everywhere */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
  width: 100%;
  min-height: var(--h-md);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { resize: vertical; line-height: 1.55; font-family: var(--serif); }
select { cursor: pointer; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sea);
  box-shadow: 0 0 0 3px var(--sea-tint);
}
input[type="checkbox"] { accent-color: var(--sea); width: 1rem; height: 1rem; }

/* 3. COMPONENTS ============================================================ */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--h-md);
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink);
  font: 500 var(--fs-sm)/1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { border-color: var(--sea); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--sea); border-color: var(--sea); color: var(--on-sea); }
.btn.primary:hover:not(:disabled) { background: var(--sea-deep); border-color: var(--sea-deep); }
.btn.secondary { background: var(--surface-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink); }
.btn.ghost:hover:not(:disabled) { color: var(--ink); background: var(--sea-tint); }
.btn.danger { background: transparent; color: var(--block); border-color: rgba(139, 46, 46, 0.35); }
.btn.danger:hover:not(:disabled) { background: var(--block-tint); border-color: var(--block); }
.hint.danger { color: var(--block); }
.btn.sm { min-height: var(--h-sm); padding: 0 var(--sp-3); font-size: var(--fs-xs); }
.btn.lg { min-height: var(--h-lg); padding: 0 var(--sp-5); font-size: var(--fs-md); }
.btn.block { width: 100%; }
.btn.grow { flex: 1; }
.btn.ghost.danger { border-color: transparent; color: var(--block); }
.btn.is-busy { cursor: progress; opacity: 0.7; }
.btn.is-busy::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--h-sm);
  height: var(--h-sm);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  font-size: var(--fs-lg);
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { border-color: var(--sea); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.account-btn {
  width: auto;
  padding: 0 var(--sp-3);
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink-soft);
  font: 500 var(--fs-sm)/1 var(--sans);
}
.account-btn.is-in {
  width: var(--h-sm);
  padding: 0;
  background: var(--paper);
  border-color: var(--line);
  color: var(--sea);
}
.account-btn.is-in:hover:not(:disabled) {
  background: var(--paper);
  border-color: var(--sea);
}
.account-glyph {
  display: grid;
  place-items: center;
  line-height: 1;
}
.account-btn.is-in .account-glyph {
  width: 1em;
  height: 1em;
  font-family: var(--display);
  font-optical-sizing: auto;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.linkish {
  padding: 0;
  border: 0;
  background: none;
  color: var(--sea);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.btn-row.end { justify-content: flex-end; }
.btn-row.center { justify-content: center; }

/* Segmented control (mode, workspace tabs, ingredient tabs) */
.seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.6);
}
.seg-btn {
  min-height: calc(var(--h-sm) - 2px);
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-soft);
  font: 500 var(--fs-sm)/1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active, .seg-btn[aria-pressed="true"], .seg-btn:has(input:checked) { background: var(--sea); color: var(--on-sea); }
label.seg-btn { display: inline-flex; align-items: center; }
.seg-btn:has(input:focus-visible) { outline: 2px solid var(--sea); outline-offset: 2px; }
.seg-divider { width: 1px; height: 18px; margin: 0 var(--sp-1); background: var(--line); }

/* Fields */
.field { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.field > span:first-child {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-soft);
}
.field.grow { flex: 1; }
.opt { font-style: normal; font-weight: 400; color: var(--ink-soft); opacity: 0.8; }
.opt::before { content: "· "; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}
.form-grid .full { grid-column: 1 / -1; }
.check-group { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-5); margin: var(--sp-3) 0; }
.check-group label { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
.hint { font-size: var(--fs-sm); color: var(--ink-soft); }
.hint:empty { display: none; }
.meta { font-size: var(--fs-sm); color: var(--ink-soft); }
.meta:empty { display: none; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--h-sm);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.chip:hover { border-color: var(--sea); }
.chip.selected, .chip[aria-checked="true"], .chip:has(input:checked) {
  background: var(--sea-tint);
  border-color: var(--sea);
  color: var(--sea-deep);
  font-weight: 500;
}

/* Cards & panels */
.card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

/* Banners */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
}
.banner-body { flex: 1; min-width: 0; }
.banner-body .hint { margin-top: var(--sp-1); color: inherit; opacity: 0.85; }
.banner p { margin: 0; }
.stale-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  flex-shrink: 0;
}
.rename-preview-list {
  list-style: none;
  margin: var(--sp-3) 0;
  padding: 0;
  max-height: 40vh;
  overflow: auto;
}
.rename-preview-list li {
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.rename-preview-list li:last-child { border-bottom: none; }
.rename-preview-list .rename-snippet {
  margin: var(--sp-1) 0 0;
  color: var(--ink-soft);
  font-style: italic;
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.banner.warn { background: var(--warn-tint); border-color: rgba(138, 90, 18, 0.3); color: var(--warn); }
.banner.block { background: var(--block-tint); border-color: rgba(139, 46, 46, 0.3); color: var(--block); }
.banner.info { background: var(--sea-tint); border-color: rgba(31, 79, 91, 0.25); color: var(--sea-deep); }
.flag-fix { margin-top: var(--sp-1); font-size: var(--fs-sm); color: var(--ink-soft); }
.flag-fix::before { content: "Fix: "; font-weight: 600; color: var(--sea); }
.form-grid > .hint.full { grid-column: 1 / -1; margin: 0; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--paper-2);
  color: var(--ink-soft);
}
.badge.approved { background: rgba(31, 79, 91, 0.12); color: var(--sea-deep); }
.badge.draft { background: rgba(163, 90, 58, 0.12); color: var(--clay); }
.badge.stale { background: var(--warn-tint); color: var(--warn); }
.badge.blocked { background: var(--block-tint); color: var(--block); }
.badge.planned { background: var(--paper-2); color: var(--ink-soft); }
.badge:empty { display: none; }

/* Dots & progress */
.dots { display: inline-flex; gap: 5px; align-items: center; }
.dots .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--paper-2); border: 1px solid var(--line-strong); }
.dots .dot.done { background: var(--sea); border-color: var(--sea); }
.dots .dot.current { background: var(--clay); border-color: var(--clay); }
.progress, .progress-fill { display: block; }
.progress { height: 6px; border-radius: var(--r-pill); background: var(--paper-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--sea); transition: width 0.6s ease; }

/* Menu (popover) */
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  top: calc(100% + var(--sp-1));
  left: 0;
  z-index: 30;
  min-width: 260px;
  max-width: 340px;
  padding: var(--sp-1);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}
.menu.right { left: auto; right: 0; }
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  width: 100%;
  min-height: var(--h-md);
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  text-align: left;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--sea-tint); outline: none; }
.menu-item.current { font-weight: 600; color: var(--sea-deep); }
.menu-item.danger { color: var(--block); }
.menu-sep { height: 1px; margin: var(--sp-1) 0; background: var(--line); }
.menu-label { padding: var(--sp-2) var(--sp-3) var(--sp-1); font-size: var(--fs-xs); color: var(--ink-soft); }

/* Disclosure (<details>) */
.disclosure { margin-top: var(--sp-4); }
.simple-export { margin: var(--sp-5) 0 var(--sp-3); }
.btn-row.wrap { flex-wrap: wrap; }
.check-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  cursor: pointer;
}
.check-inline input { margin: 0; }
.disclosure > summary {
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--sea);
  list-style: none;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: "▸ "; display: inline-block; transition: transform 0.15s ease; }
.disclosure[open] > summary::before { transform: rotate(90deg); }
.disclosure[open] > summary { margin-bottom: var(--sp-3); }
.disclosure > .field + .field, .disclosure > .hint + .field { margin-top: var(--sp-3); }

/* Modal / sheet */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: rgba(22, 56, 64, 0.35);
}
.modal-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  width: min(480px, 100%);
  max-height: calc(100vh - var(--sp-6));
  overflow: auto;
  padding: var(--sp-5);
  background: var(--paper);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}
.modal-card.lg { width: min(620px, 100%); }
.modal-title { font-family: var(--display); font-size: var(--fs-xl); font-weight: 500; letter-spacing: -0.01em; }
.modal-title + .hint { margin-top: calc(-1 * var(--sp-2)); }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); margin-top: var(--sp-2); }
.modal-foot > :only-child { margin-left: auto; }
.option-list { display: grid; gap: var(--sp-2); }
.note-list { margin: 0; padding-left: var(--sp-5); font-size: var(--fs-sm); color: var(--warn); }

/* Toast */
.toast {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: 60;
  max-width: min(90vw, 420px);
  padding: var(--sp-3) var(--sp-4);
  background: var(--sea-deep);
  color: var(--on-sea);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-sm);
}
body.has-decision-bar .toast { bottom: calc(var(--sp-5) + 72px); }

/* Busy overlay (long operations only) + load bar (quick loads) */
.busy {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(243, 239, 230, 0.6);
}
.busy-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: var(--paper);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}
.spin {
  width: 18px;
  height: 18px;
  border: 2px solid var(--paper-2);
  border-top-color: var(--sea);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loadbar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 80;
  width: 40%;
  height: 3px;
  background: var(--sea);
  animation: loadbar 1s ease-in-out infinite;
}
@keyframes loadbar { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn,
  .spin,
  .loadbar,
  .drawer-backdrop,
  .sheet-backdrop,
  .modal,
  .toast {
    transition: none !important;
    animation: none !important;
  }
  .btn.is-busy::before {
    animation: none;
    border-right-color: currentColor;
    opacity: 0.55;
  }
  .spin {
    border-top-color: var(--paper-2);
    opacity: 0.7;
  }
  .loadbar {
    transform: none;
    width: 100%;
    opacity: 0.55;
  }
}

/* 4. SHELL ================================================================= */
.app-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 243, 235, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-top-inner,
.book-header-inner,
.shell {
  width: 100%;
  max-width: var(--w-shell);
  margin: 0 auto;
  padding-left: var(--sp-5);
  padding-right: var(--sp-5);
}
.app-top-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-5);
  height: var(--top-h);
}
.brand {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--sea-deep);
  white-space: nowrap;
  cursor: pointer;
}
.nav-tabs { display: flex; gap: var(--sp-1); }
.nav-tab {
  position: relative;
  min-height: var(--h-md);
  padding: 0 var(--sp-3);
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
}
.nav-tab:hover { color: var(--ink); }
.nav-tab[aria-current="page"] { color: var(--sea-deep); }
.nav-tab[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: var(--sp-3);
  right: var(--sp-3);
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--sea);
}
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.hint.center { text-align: center; }
.app-top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  flex-wrap: nowrap;
  min-width: 0;
}
#account-wrap .menu { min-width: 12rem; }
.nav-menu-btn { display: none; }

/* Drawer (mobile primary nav) */
.drawer-backdrop, .sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(22, 56, 64, 0.4);
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  width: min(320px, 88vw);
  height: 100%;
  padding: var(--sp-4);
  background: var(--surface-2);
  box-shadow: var(--shadow-2);
  transform: translateX(0);
}
.drawer-head, .sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.drawer-title, .sheet-title {
  font-family: var(--display);
  font-size: var(--fs-lg);
  font-weight: 500;
}
.drawer-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.drawer-link {
  min-height: var(--h-lg);
  padding: 0 var(--sp-4);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  font: 500 var(--fs-md)/1 var(--sans);
  text-align: left;
  cursor: pointer;
}
.drawer-link:hover { background: var(--sea-tint); }
.drawer-link[aria-current="page"] {
  background: var(--sea-tint);
  color: var(--sea-deep);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--sea);
}
.drawer-foot { margin-top: auto; padding-top: var(--sp-4); border-top: 1px solid var(--line); }

/* Desktop: sheet chrome and mobile Actions button stay hidden */
.sheet-handle, .sheet-head, .review-sheet-btn { display: none; }

.book-header {
  position: sticky;
  top: var(--top-h);
  z-index: 15;
  background: rgba(243, 239, 230, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.book-header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--sp-4);
  height: var(--book-h);
}
.book-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  max-width: 100%;
  min-height: var(--h-md);
  padding: 0 var(--sp-3);
  margin-left: calc(-1 * var(--sp-3));
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  font-family: var(--display);
  font-size: var(--fs-lg);
  font-weight: 500;
  cursor: pointer;
}
.book-switch:hover { background: var(--sea-tint); }
.book-switch-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { font-family: var(--sans); font-size: var(--fs-xs); color: var(--ink-soft); }
.chapter-stepper { display: flex; align-items: center; gap: var(--sp-2); }
.chapter-select {
  width: auto;
  min-width: 220px;
  max-width: 320px;
  min-height: var(--h-sm);
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
}
.chapter-stepper .dots { margin-left: var(--sp-2); }
.ws-tabs { justify-self: end; }
body.mode-simple .ws-tabs { visibility: hidden; }

.shell { padding-top: var(--sp-5); padding-bottom: var(--sp-7); }
.shell > .banner { margin-bottom: var(--sp-4); }
body.mode-simple #stale-banner { display: none !important; }

/* 5. TEMPLATES ============================================================= */
.page-narrow { max-width: var(--w-narrow); margin: 0 auto; }
.page-wide { width: 100%; }
.page-read { max-width: var(--w-read); margin: 0 auto; position: relative; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.page-title { font-family: var(--display); font-size: var(--fs-xl); font-weight: 500; letter-spacing: -0.01em; }
.page-sub { margin-top: var(--sp-1); color: var(--ink-soft); }
.section { margin-top: var(--sp-7); }
.section-title { margin-bottom: var(--sp-4); font-size: var(--fs-lg); font-weight: 600; }

.billing-panel {
  margin-top: var(--sp-8);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--line);
}
.quota-bar {
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin: var(--sp-3) 0 var(--sp-2);
}
.quota-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--sea);
  transition: width 0.25s ease;
}
.quota-bar-fill.warn { background: var(--warn); }
.quota-bar-fill.block { background: var(--block); }
#quota-banner { align-items: center; gap: var(--sp-3); }
.empty { padding: var(--sp-6); text-align: center; color: var(--ink-soft); }
.layer-empty { padding: var(--sp-5) var(--sp-2); text-align: left; }

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--w-side);
  gap: var(--sp-5);
  align-items: start;
}

/* 6. SCREENS =============================================================== */

/* Reading (shared by Simple and Review) */
.read-card { padding: var(--sp-6) var(--sp-6) var(--sp-7); }
.read-head { margin-bottom: var(--sp-5); }
.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clay);
}
.chapter-title {
  margin-top: var(--sp-1);
  font-family: var(--display);
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.read-head .meta { margin-top: var(--sp-2); }
.read-card > .banner { margin-bottom: var(--sp-5); }
.prose {
  font-family: var(--serif);
  font-size: var(--fs-md);
  line-height: 1.7;
  white-space: pre-wrap;
  max-width: var(--w-read);
}
.prose.reading { font-size: var(--fs-lg); line-height: 1.75; }
.prose:empty::before { content: "No chapter yet."; color: var(--ink-soft); font-style: italic; }
.read-end {
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
}

/* Home */
.hero { padding: var(--sp-7) 0 var(--sp-5); text-align: center; }
.hero-title {
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--sea-deep);
}
.hero-lead {
  max-width: 34rem;
  margin: var(--sp-4) auto var(--sp-6);
  font-family: var(--serif);
  font-size: var(--fs-lg);
  line-height: 1.55;
  color: var(--ink-soft);
}

/* Book cards (Home + Library) */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-4);
}
.book-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  text-align: left;
  cursor: default;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.book-card:hover { border-color: var(--sea); transform: translateY(-1px); }
.book-card-main {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
}
.book-card-cover {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--sea-tint);
}
.book-card-del { align-self: flex-start; }
.cover-block { margin: var(--sp-5) 0; }
.cover-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--sp-4);
  align-items: start;
}
.cover-plate {
  width: 120px;
  aspect-ratio: 2 / 3;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper-2);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.cover-plate img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cover-empty {
  margin: 0;
  padding: var(--sp-2);
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--ink-soft);
}
.simple-cover { margin-top: var(--sp-5); }
@media (max-width: 720px) {
  .cover-row { grid-template-columns: 1fr; }
  .cover-plate { width: 140px; }
}
.book-card-title {
  font-family: var(--display);
  font-size: var(--fs-lg);
  font-weight: 500;
  line-height: 1.25;
}
.book-card-meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--sp-1) var(--sp-2); font-size: var(--fs-sm); color: var(--ink-soft); }
.book-card-meta > * { white-space: nowrap; }
.book-card .progress { margin-top: auto; }

/* Dreams */
.capture-card { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); }
.capture-foot { display: flex; align-items: center; gap: var(--sp-3); }
.dream-input { font-size: var(--fs-lg); line-height: 1.6; min-height: 5rem; }
.diary-list { display: grid; gap: var(--sp-3); margin: var(--sp-5) 0 0; padding: 0; list-style: none; }
.diary-card { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); }
.diary-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.diary-card-title { font-weight: 600; }
.diary-card-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-family: var(--serif);
  color: var(--ink-soft);
}
.diary-card .btn-row { margin-top: var(--sp-1); }

/* Wizard */
.stepper { display: flex; gap: var(--sp-5); margin: 0; padding: 0; list-style: none; font-size: var(--fs-sm); color: var(--ink-soft); }
.wiz-step { display: flex; align-items: center; gap: var(--sp-2); }
.step-dot {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-size: var(--fs-xs);
  font-weight: 600;
}
.wiz-step.active { color: var(--sea-deep); font-weight: 600; }
.wiz-step.active .step-dot, .wiz-step.done .step-dot { background: var(--sea); border-color: var(--sea); color: var(--on-sea); }
.wiz-pane { display: flex; flex-direction: column; gap: var(--sp-4); }
.length-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.length-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  text-align: left;
  cursor: pointer;
}
.length-card span { font-size: var(--fs-sm); color: var(--ink-soft); }
.length-card:hover { border-color: var(--sea); }
.length-card.selected { border-color: var(--sea); background: var(--sea-tint); box-shadow: inset 0 0 0 1px var(--sea); }
.wiz-progress-copy { font-family: var(--serif); font-size: var(--fs-lg); min-height: 1.75rem; }
.wiz-expand-row { margin-top: var(--sp-3); }
#wiz-start-mode { margin-bottom: var(--sp-2); }

/* Simple book */
.decision-bar {
  position: sticky;
  bottom: var(--sp-4);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-5);
  background: rgba(255, 252, 246, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(8px);
}
.decision-left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
  flex: 1;
}
.decision-hint { font-size: var(--fs-sm); color: var(--ink-soft); margin: 0; }
.decision-bar .btn-row { flex-wrap: nowrap; margin-left: auto; }

.simple-tip {
  margin: var(--sp-5) 0 0;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--sea-tint);
}
.simple-tip-text {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--ink-soft);
}
.simple-tip-actions { margin: 0; }
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.btn-voice[aria-pressed="true"],
#btn-listen[aria-pressed="true"],
#btn-simple-listen[aria-pressed="true"] {
  background: var(--sea-tint);
  color: var(--sea-deep);
  box-shadow: inset 0 0 0 1px var(--sea);
}
.fix-chip {
  position: absolute;
  z-index: 25;
  min-height: var(--h-sm);
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-pill);
  background: var(--sea-deep);
  color: var(--on-sea);
  font-size: var(--fs-xs);
  font-weight: 500;
  box-shadow: var(--shadow-2);
  cursor: pointer;
}

/* Review side panel */
.side-panel {
  position: sticky;
  top: calc(var(--top-h) + var(--book-h) + var(--sp-4));
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-height: calc(100vh - var(--top-h) - var(--book-h) - var(--sp-6));
  overflow: auto;
}
.side-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.side-title { font-size: var(--fs-sm); font-weight: 600; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.side-card .btn-row { flex-wrap: nowrap; }
.tone-ok { color: var(--sea); }
.mini-title.tone-block { color: var(--block); }
.side-title.tone-block { color: var(--block); }
.side-title.tone-warn { color: var(--warn); }
.disclosure-card > summary { cursor: pointer; list-style: none; }
.disclosure-card > summary::-webkit-details-marker { display: none; }
.disclosure-card > summary::after { content: "▸"; float: right; color: var(--ink-soft); transition: transform 0.15s ease; }
.disclosure-card[open] > summary::after { transform: rotate(90deg); }
.side-card .disclosure { margin-top: 0; }
.mini-title { margin-bottom: var(--sp-1); font-size: var(--fs-xs); font-weight: 600; color: var(--ink-soft); }
.seam-grid { display: grid; gap: var(--sp-3); }
.seam-text {
  max-height: 10rem;
  overflow: auto;
  padding: var(--sp-2) var(--sp-3);
  background: var(--paper-2);
  border-radius: var(--r-sm);
  font-family: var(--serif);
  font-size: var(--fs-sm);
  line-height: 1.5;
  white-space: pre-wrap;
}
.flag-list { display: grid; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.flag-list li { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.flag-list.blocker li { border-color: rgba(139, 46, 46, 0.3); background: var(--block-tint); }
.flag-list.warn li { border-color: rgba(138, 90, 18, 0.3); background: var(--warn-tint); }
.flag-code { font-size: var(--fs-xs); font-weight: 600; color: var(--sea); }
.flag-list.blocker .flag-code { color: var(--block); }
.flag-list.warn .flag-code { color: var(--warn); }
.snapshot-list { margin-top: var(--sp-4); }
.snapshot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--fs-sm);
}
#snapshot-items { display: grid; gap: var(--sp-2); margin: var(--sp-2) 0 0; padding: 0; list-style: none; }
.usage-list {
  margin: var(--sp-3) 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--sp-2);
  max-height: 14rem;
  overflow: auto;
}
.usage-row {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.flag-msg { margin-top: 2px; font-size: var(--fs-sm); line-height: 1.4; }
.flag-actions { margin-top: var(--sp-2); }
.plot-summary { font-family: var(--serif); font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-soft); }

/* Story editor */
.story-card { padding: var(--sp-5); }
.story-head { display: flex; align-items: flex-end; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.story-head .meta { padding-bottom: var(--sp-2); white-space: nowrap; }
.editor {
  min-height: 62vh;
  padding: var(--sp-4);
  font-family: var(--serif);
  font-size: var(--fs-md);
  line-height: 1.7;
}
.save-bar {
  position: sticky;
  bottom: var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-5);
  background: rgba(255, 252, 246, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-2);
}

.save-bar .hint { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); }
.dirty-note:empty { display: none; }
.dirty-note { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.dirty-note.is-dirty { color: var(--warn); }
.dirty-note.is-dirty::before { content: "● "; }
.dirty-note.is-saved { color: var(--sea); }
.dirty-note.is-saved::before { content: "✓ "; }

/* Ingredients: rail + form area */
.layers-page {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: var(--sp-5);
  align-items: start;
}
.rail {
  position: sticky;
  top: calc(var(--top-h) + var(--book-h) + var(--sp-4));
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  min-height: var(--h-md);
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-soft);
  font: 500 var(--fs-sm)/1 var(--sans);
  text-align: left;
  cursor: pointer;
}
.rail-btn:hover { color: var(--ink); background: var(--sea-tint); }
.rail-btn[aria-current="true"] { background: var(--surface-1); color: var(--sea-deep); font-weight: 600; box-shadow: inset 3px 0 0 var(--sea); }
.rail-count { font-size: var(--fs-xs); font-weight: 500; color: var(--ink-soft); }
.rail-count:empty { display: none; }
.rail-divider { height: 1px; margin: var(--sp-2) var(--sp-3); background: var(--line); }
.layer-panel { max-width: 880px; padding: var(--sp-5); }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin: var(--sp-5) 0 var(--sp-3); }
.layer-pane > .pane-head:first-child { margin-top: 0; }
.pane-title { font-family: var(--display); font-size: var(--fs-xl); font-weight: 500; margin-bottom: var(--sp-4); }
.pane-head .pane-title { margin-bottom: 0; }
.subhead { font-size: var(--fs-md); font-weight: 600; }
.pane-foot {
  position: sticky;
  bottom: var(--sp-4);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  background: rgba(255, 252, 246, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-1);
}
.pane-foot .dirty-note { margin-right: auto; }
.dial-list { display: grid; gap: var(--sp-4); margin-top: var(--sp-4); }
.dial { margin: 0; padding: 0; border: 0; min-width: 0; }
.dial legend { padding: 0; font-weight: 600; }
.dial .hint { margin: 2px 0 var(--sp-2); }
.dial .seg { flex-wrap: wrap; }
.dial-pref { margin-top: var(--sp-6); }
.dirty-note.is-clean { font-weight: 400; color: var(--ink-soft); }
.card-list { display: grid; gap: var(--sp-3); }
.char-card, .rule-card, .loc-card, .plot-card, .payoff-card {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.char-card label, .rule-card label, .loc-card label, .plot-card label, .payoff-card label {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-soft);
}
.char-card label > input, .char-card label > select, .char-card label > textarea,
.rule-card label > *, .loc-card label > *, .plot-card label > *, .payoff-card label > * {
  color: var(--ink);
  font-weight: 400;
}
.char-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.char-top strong { font-size: var(--fs-md); color: var(--ink); }
.char-top .btn { min-height: var(--h-sm); padding: 0 var(--sp-3); font-size: var(--fs-xs); }
/* Collapsible item cards (characters, places, plot chapters) */
.item-card { display: block; padding: 0; }
.item-sum {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "chev name" "chev sub";
  column-gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  list-style: none;
  cursor: pointer;
}
.item-sum::-webkit-details-marker { display: none; }
.item-sum::before {
  content: "▸";
  grid-area: chev;
  align-self: center;
  color: var(--ink-soft);
  transition: transform 0.15s ease;
}
.item-card[open] > .item-sum::before { transform: rotate(90deg); }
.item-card[open] > .item-sum { border-bottom: 1px solid var(--line); }
.item-name { grid-area: name; font-weight: 600; color: var(--ink); }
.item-sub { grid-area: sub; overflow: hidden; font-size: var(--fs-sm); color: var(--ink-soft); text-overflow: ellipsis; white-space: nowrap; }
.item-sub:empty { display: none; }
.item-body { display: grid; gap: var(--sp-3); padding: var(--sp-4); }
.char-card .item-body { grid-template-columns: 1fr 1fr; }
.char-card .item-body > label:has(textarea),
.char-card .item-body > .full,
.char-card .item-body > .item-foot { grid-column: 1 / -1; }
.item-foot { display: flex; justify-content: flex-end; padding-top: var(--sp-2); }
.beats { display: grid; gap: var(--sp-2); justify-items: start; }
.beats .beat-list { width: 100%; }
.beat-list { display: grid; gap: var(--sp-2); margin: var(--sp-2) 0; }
.beat-row { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-2); align-items: start; }
.beat-row textarea { min-height: var(--h-md); }
.beat-row .btn { min-height: var(--h-md); width: var(--h-md); padding: 0; }

/* 7. RESPONSIVE ============================================================ */
@media (max-width: 960px) {
  .workbench { grid-template-columns: 1fr; }
  .layers-page { grid-template-columns: 1fr; gap: var(--sp-3); }
  .rail {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: var(--sp-1);
    scrollbar-width: none;
  }
  .rail-btn { flex: none; min-height: var(--h-sm); border-radius: var(--r-pill); }
  .rail-btn[aria-current="true"] { box-shadow: inset 0 0 0 1px var(--sea); }
  .rail-divider { width: 1px; height: 18px; margin: auto var(--sp-1); }
  .layer-panel { max-width: none; }
  .book-header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    height: auto;
    min-height: var(--book-h);
    padding-top: var(--sp-2);
    padding-bottom: var(--sp-2);
    row-gap: var(--sp-2);
  }
  .ws-tabs {
    grid-column: 1 / -1;
    justify-self: stretch;
    overflow-x: auto;
    scrollbar-width: none;
  }
  body.mode-simple .ws-tabs { display: none; }
  .chapter-stepper .dots { display: none; }

  /* Review: sticky Actions button + bottom sheet */
  .review-sheet-btn {
    display: flex;
    position: sticky;
    bottom: var(--sp-4);
    z-index: 12;
    margin-top: var(--sp-4);
    box-shadow: var(--shadow-2);
  }
  .workbench {
    padding-bottom: calc(var(--h-lg) + var(--sp-6));
  }
  .side-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 42;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    max-height: min(88vh, 720px);
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom));
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md) var(--r-md) 0 0;
    box-shadow: var(--shadow-2);
    overflow: auto;
    transform: translateY(110%);
    transition: transform 0.22s ease;
    pointer-events: none;
  }
  body.review-sheet-open .side-panel {
    transform: translateY(0);
    pointer-events: auto;
  }
  body.drawer-open, body.review-sheet-open { overflow: hidden; }
  .sheet-handle {
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto var(--sp-2);
    border-radius: var(--r-pill);
    background: var(--line-strong);
  }
  .sheet-head { display: flex; }
}

@media (max-width: 720px) {
  :root { --top-h: 56px; }
  .app-top-inner,
  .book-header-inner,
  .shell { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  /* Fixed height + Fraunces line box sat the brand on the bottom border.
     Auto height with vertical padding keeps the title centred down to ~360px. */
  .app-top-inner {
    grid-template-columns: 1fr auto;
    height: auto;
    min-height: var(--top-h);
    padding-top: var(--sp-2);
    padding-bottom: var(--sp-2);
    align-items: center;
  }
  .brand {
    display: inline-flex;
    align-items: center;
    align-self: center;
    line-height: 1;
  }
  .nav-tabs { display: none; }
  .nav-menu-btn { display: inline-grid; }
  #btn-new-project { display: none; }
  .hide-sm { display: none; }
  .chapter-select { min-width: 0; max-width: 46vw; }
  .form-grid,
  .char-card .item-body { grid-template-columns: 1fr; }
  .length-cards { grid-template-columns: 1fr; }
  .read-card { padding: var(--sp-5) var(--sp-4) var(--sp-6); }
  .prose.reading { font-size: 1.08rem; }
  .page-head { flex-direction: column; align-items: stretch; }
  .capture-foot { flex-direction: column; align-items: stretch; }
  .decision-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom));
    border-radius: var(--r-md) var(--r-md) 0 0;
    flex-direction: column;
    align-items: stretch;
  }
  .decision-hint:empty { display: none; }
  .decision-left { width: 100%; }
  .decision-bar .btn-row { display: grid; grid-template-columns: 1fr 1fr; margin-left: 0; gap: var(--sp-2); }
  .decision-bar .btn.primary { grid-column: 1 / -1; grid-row: 1; min-height: var(--h-lg); }
  .decision-bar .btn:not(.primary) { min-height: var(--h-md); }
  body.has-decision-bar {
    --decision-clearance: calc(9.5rem + env(safe-area-inset-bottom, 0px));
  }
  body.has-decision-bar .shell { padding-bottom: var(--decision-clearance); }
  body.has-decision-bar .toast { bottom: calc(var(--decision-clearance) - 1.5rem); }
  .toast { left: var(--sp-4); right: var(--sp-4); bottom: var(--sp-4); max-width: none; }
  .save-bar { flex-direction: column; align-items: stretch; border-radius: var(--r-md); }
  .modal { place-items: end center; padding: 0; }
  .modal-card, .modal-card.lg { width: 100%; border-radius: var(--r-md) var(--r-md) 0 0; max-height: 92vh; }
  .review-sheet-btn {
    bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
  }
  #stale-banner {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
  }
  #stale-banner .stale-banner-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  #stale-banner .stale-banner-actions .btn {
    width: 100%;
  }
}
