:root {
  --ink: #1b2a41;
  --ink-2: #33475b;
  --muted: #6b7a8c;
  --paper: #f6f1e7;
  --paper-2: #fbf8f2;
  --card: #ffffff;
  --line: #e2dccf;
  --accent: #0f766e;
  --accent-2: #0b5f59;
  --copper: #b5651d;
  --danger: #b42318;
  --warn: #b7791f;
  --ok: #2f7d4a;
  --info: #2b6cb0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(27, 42, 65, .06), 0 6px 20px rgba(27, 42, 65, .06);
  --font: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-ui); line-height: 1.5; display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1 0 auto; }
a { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--font); color: var(--ink); margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .75rem; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; background: var(--paper-2); padding: .1em .3em; border-radius: 4px; }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 1000; }
.skip-link:focus { left: .5rem; top: .5rem; }
:focus-visible { outline: 3px solid var(--copper); outline-offset: 2px; }

.topbar { background: var(--ink); color: #fff; }
.topbar-inner { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: .6rem 1rem; gap: 1rem; }
.brand { color: #fff; text-decoration: none; font-family: var(--font); font-size: 1.25rem; display: flex; align-items: center; gap: .4rem; }
.brand-mark { color: #f2c17d; }
.topnav { display: flex; gap: .75rem; align-items: center; }
.topnav a { color: #dfe7f0; text-decoration: none; padding: .35rem .5rem; border-radius: 6px; }
.topnav a:hover { background: rgba(255,255,255,.1); }
.inline-form { display: inline; margin: 0; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.container-wide { max-width: 1500px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.container-narrow { max-width: 680px; margin: 0 auto; padding: 2rem 1rem 3rem; }

.flashes { max-width: 1200px; margin: .75rem auto 0; padding: 0 1rem; }
.flash { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: .5rem; border: 1px solid var(--line); background: var(--card); }
.flash-error { border-color: #f3c1bb; background: #fdf1ef; color: var(--danger); }
.flash-success { border-color: #bfe0c9; background: #eef8f1; color: var(--ok); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font: inherit; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--paper-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; }
.topnav .btn-ghost { color: #dfe7f0; }
.btn-sm { padding: .3rem .6rem; font-size: .875rem; }
.btn-copper { background: var(--copper); border-color: var(--copper); color: #fff; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; letter-spacing: .01em; background: var(--paper); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.badge-accent { background: #e2f3f1; border-color: #b5ddd9; color: var(--accent-2); }
.badge-copper { background: #fbeee2; border-color: #efcfb2; color: #8a4a12; }
.badge-danger { background: #fdecea; border-color: #f5c2bd; color: var(--danger); }
.badge-warn { background: #fdf5e6; border-color: #f0dcae; color: #7a5410; }
.badge-ok { background: #eaf6ee; border-color: #bfe0c9; color: var(--ok); }
.badge-info { background: #e8f0fb; border-color: #bfd4f2; color: var(--info); }
.badge-user { background: #fff7e6; border-color: #f2d59b; color: #7a5410; }
.badge-ai { background: #eef2f6; border-color: #d3dce6; color: var(--ink-2); }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; margin-left: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid #cfc7b8; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; }
textarea.idea { min-height: 220px; font-family: var(--font); font-size: 1.05rem; }
.form-row { margin-bottom: 1rem; }
.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-section { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1.25rem; }
.form-section h3 { margin-bottom: .75rem; }
.look-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .75rem; }
@media (max-width: 520px) { .look-grid { grid-template-columns: 1fr; } }
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
.check input { margin-top: .3rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table-wrap { overflow-x: auto; }

.book-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.book-list > .card + .card { margin-top: 0; }
.book-card { display: flex; flex-direction: column; min-width: 0; }
.book-card-top { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: .75rem; }
.book-card-cover { flex: none; }
.book-card-info { flex: 1; min-width: 0; }
.book-card h3 { font-size: 1.2rem; margin-bottom: 0; }
.book-meta { display: flex; flex-wrap: wrap; gap: .5rem 1rem; color: var(--muted); font-size: .85rem; margin: .5rem 0 0; }

.view-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); flex: none; }
.view-switch button { border: 0; background: transparent; padding: .4rem .75rem; font: inherit; font-size: .875rem; cursor: pointer; color: var(--ink-2); }
.view-switch button + button { border-left: 1px solid var(--line); }
.view-switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.view-switch button:hover:not([aria-pressed="true"]) { background: var(--paper-2); }
html[data-books-layout="list"] [data-books-panel="cards"] { display: none !important; }
html[data-books-layout="list"] [data-books-panel="list"] { display: block !important; }
.books-table-card { padding: 0; overflow: hidden; }
.books-table-card .table-wrap { margin: 0; }
.books-table { min-width: 920px; font-variant-numeric: tabular-nums; }
.books-table th, .books-table td { vertical-align: middle; }
.books-table .books-title, .books-table .books-status, .books-table .books-genre, .books-table .books-actions { white-space: normal; }
.books-table .col-cover { width: 3.4rem; }
.books-table .dash-cover { width: 40px; }
.dash-cover-empty { background: var(--paper); border: 1px dashed var(--line); box-shadow: none; }
.books-title-link { font-family: var(--font); font-size: 1.05rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.books-title-link:hover { text-decoration: underline; }
.books-series { margin: .2rem 0 0; }
.books-words { font-variant-numeric: tabular-nums; min-width: 9rem; }
.books-words .progress { margin-top: .35rem; }
.books-sort { display: inline-flex; align-items: center; gap: .3rem; background: none; border: 0; padding: 0; margin: 0; font: inherit; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); cursor: pointer; }
.books-sort:hover { color: var(--ink); }
.books-sort-mark { font-size: .75rem; opacity: .35; text-transform: none; letter-spacing: 0; }
th[aria-sort="ascending"] .books-sort, th[aria-sort="descending"] .books-sort { color: var(--ink); }
th[aria-sort="ascending"] .books-sort-mark, th[aria-sort="descending"] .books-sort-mark { opacity: 1; }
.books-actions-row { gap: .35rem; flex-wrap: wrap; }
.books-actions .books-actions-row { justify-content: flex-end; }
.progress { height: 6px; background: var(--paper); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress > span { display: block; height: 100%; background: var(--accent); }

.run-panel { border-left: 4px solid var(--accent); }
.run-panel.state-failed { border-left-color: var(--danger); }
.run-panel.state-needs_user { border-left-color: var(--copper); }
.run-panel.state-paused { border-left-color: var(--warn); }
.run-panel.state-succeeded { border-left-color: var(--ok); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.event-log { list-style: none; padding: 0; margin: .5rem 0 0; max-height: 200px; overflow: auto; font-size: .85rem; }
.event-log li { padding: .2rem 0; border-bottom: 1px dashed var(--line); color: var(--ink-2); }

.book-nav { display: flex; gap: .25rem; flex-wrap: wrap; margin: .25rem 0 1rem; border-bottom: 1px solid var(--line); }
.book-nav a { padding: .5rem .8rem; text-decoration: none; color: var(--ink-2); border-bottom: 3px solid transparent; }
.book-nav a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }

.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs [role=tab] { background: none; border: 0; border-bottom: 3px solid transparent; padding: .6rem .9rem; font: inherit; cursor: pointer; color: var(--ink-2); }
.tabs [role=tab][aria-selected=true] { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }
[hidden] { display: none !important; }

.field { margin-bottom: .6rem; }
.field-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; gap: .4rem; align-items: center; }
.editable { border: 1px dashed transparent; border-radius: 6px; padding: .2rem .35rem; margin: 0 -.35rem; min-height: 1.4em; white-space: pre-wrap; }
.editable:hover { border-color: #cfc7b8; background: var(--paper-2); }
.editable:focus { border-style: solid; border-color: var(--accent); background: #fff; outline: none; }
.editable.dirty { background: #fff7e6; border-color: #f2d59b; }
.entity-card h3 { margin-bottom: .25rem; }
.chapter-block { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; background: var(--card); margin-bottom: .75rem; }
.chapter-block summary { cursor: pointer; font-weight: 600; font-family: var(--font); font-size: 1.05rem; }
.scene-plan { border-top: 1px solid var(--line); padding-top: .6rem; margin-top: .6rem; }
.savebar { position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding: .6rem 1rem; display: flex; gap: .6rem; align-items: center; justify-content: flex-end; box-shadow: 0 -4px 12px rgba(0,0,0,.05); z-index: 5; }

.workspace { display: grid; grid-template-columns: 280px minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
.pane { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; }
.pane-scroll { max-height: calc(100vh - 220px); overflow: auto; }
.scene-list { list-style: none; margin: 0; padding: 0; }
.scene-list .chapter { font-weight: 600; margin: .6rem 0 .25rem; display: flex; justify-content: space-between; gap: .5rem; align-items: center; font-family: var(--font); }
.scene-list .scene a { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem .4rem; border-radius: 6px; text-decoration: none; color: var(--ink-2); font-size: .9rem; }
.scene-list .scene a:hover { background: var(--paper-2); }
.scene-list .scene a[aria-current=true] { background: #e2f3f1; color: var(--accent-2); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-right: .3rem; }
.dot-accepted { background: var(--ok); } .dot-issue { background: var(--danger); } .dot-planned { background: #cfc7b8; } .dot-candidate { background: var(--warn); }
.editor { width: 100%; min-height: 60vh; font-family: var(--font); font-size: 1.08rem; line-height: 1.7; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fffdf9; }
.editor-status { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin: .5rem 0; }
.prose { font-family: var(--font); font-size: 1.05rem; line-height: 1.7; }
.prose p { margin-bottom: 1em; }
.diff-add { background: #eaf6ee; border-left: 3px solid var(--ok); padding-left: .6rem; }
.diff-del { background: #fdecea; border-left: 3px solid var(--danger); padding-left: .6rem; text-decoration: line-through; color: #7a2e27; }
.md { line-height: 1.6; } .md p { margin-bottom: .6em; } .md ul { padding-left: 1.2rem; }

.finding { border-left: 4px solid var(--line); padding: .5rem .75rem; margin-bottom: .6rem; background: var(--paper-2); border-radius: 0 8px 8px 0; }
.finding.sev-blocking, .finding.sev-critical { border-left-color: var(--danger); }
.finding.sev-advisory { border-left-color: var(--warn); }
.finding.sev-info { border-left-color: var(--info); }
.evidence { font-family: var(--font); font-style: italic; color: var(--ink-2); border-left: 2px solid var(--line); padding-left: .6rem; margin: .3rem 0; font-size: .95rem; }

.chat-log { display: flex; flex-direction: column; gap: .6rem; max-height: 40vh; overflow: auto; margin-bottom: .6rem; }
.chat-q { align-self: flex-end; background: #e2f3f1; padding: .5rem .7rem; border-radius: 10px 10px 2px 10px; max-width: 95%; }
.chat-a { background: var(--paper-2); border: 1px solid var(--line); padding: .6rem .8rem; border-radius: 10px 10px 10px 2px; }
.citation { display: inline-block; font-size: .75rem; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: .05rem .4rem; margin: .15rem .15rem 0 0; color: var(--accent-2); text-decoration: none; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(27,42,65,.45); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 100; }
.modal { background: var(--card); border-radius: 12px; max-width: 560px; width: 100%; padding: 1.25rem; box-shadow: 0 20px 60px rgba(0,0,0,.25); max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: .5rem; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
/* ---------------- settings window ----------------
   Sections down the left (grouped: This book · Account, Sign out pinned to the foot), the chosen section's rows on the right. */
body.settings-open { overflow: hidden; }
.topnav-settings { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .6rem; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.settings-backdrop { padding: 2.5vh 1rem; align-items: center; }
.settings-dialog { display: grid; grid-template-columns: 230px minmax(0, 1fr); width: min(1000px, 100%); height: min(720px, 95vh); background: var(--card); border-radius: 14px; box-shadow: 0 24px 70px rgba(27, 42, 65, .3); overflow: hidden; }
.settings-nav { display: flex; flex-direction: column; background: var(--paper-2); border-right: 1px solid var(--line); min-height: 0; }
.settings-nav-scroll { flex: 1; overflow: auto; padding: 1.1rem .8rem .8rem; }
.settings-group + .settings-group { margin-top: 1.1rem; }
.settings-group-label { font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); padding: 0 .55rem; margin-bottom: .4rem; }
.settings-tab { display: flex; align-items: center; gap: .55rem; width: 100%; text-align: left; padding: .5rem .6rem; border: 0; border-radius: 8px; background: none; color: var(--ink-2); font: inherit; font-size: .92rem; cursor: pointer; line-height: 1.3; }
.settings-tab svg { flex: none; opacity: .75; }
.settings-tab:hover { background: rgba(27, 42, 65, .05); color: var(--ink); }
.settings-tab[aria-selected="true"] { background: #e9e3d6; color: var(--ink); font-weight: 600; }
.settings-tab[aria-selected="true"] svg { opacity: 1; color: var(--accent-2); }
.settings-nav-footer { border-top: 1px solid var(--line); padding: .6rem .8rem; }
.settings-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.settings-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.5rem .6rem; }
.settings-pane-head h2 { margin: 0; font-size: 1.35rem; }
.settings-pane-body { flex: 1; overflow: auto; padding: 0 1.5rem 1.5rem; }
.settings-intro { margin: .1rem 0 .4rem; }
.settings-section { padding-top: 1.2rem; }
.settings-section:first-child { padding-top: .2rem; }
.settings-section h3 { font-size: 1rem; margin-bottom: .1rem; }
.settings-section p { margin: 0; }
.settings-row { display: grid; grid-template-columns: 160px minmax(0, 1fr) auto; gap: .4rem 1.25rem; align-items: start; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border-bottom: 0; }
.settings-row-label { font-size: .9rem; font-weight: 600; color: var(--ink-2); padding-top: .3rem; }
.settings-row-value { font-size: .95rem; padding-top: .3rem; overflow-wrap: anywhere; }
.settings-row-value a { color: var(--accent-2); }
.settings-row-hint { margin-top: .2rem; line-height: 1.4; }
.settings-row-action { display: flex; justify-content: flex-end; }
.settings-row-danger .settings-row-label { color: var(--danger); }
.settings-editor { grid-column: 1 / -1; background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem; margin-top: .2rem; }
.settings-editor label { margin-bottom: .3rem; }
.settings-editor input[type=text], .settings-editor input[type=number] { max-width: 480px; }
.settings-editor-error { color: var(--danger); margin: .5rem 0 0; }
.settings-editor-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .8rem; flex-wrap: wrap; }
.settings-progress { margin-top: .4rem; max-width: 320px; }
.settings-error { color: var(--danger); }
@media (max-width: 760px) {
  .settings-backdrop { padding: 0; align-items: stretch; }
  .settings-dialog { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); width: 100%; height: 100dvh; border-radius: 0; }
  .settings-nav { flex-direction: row; align-items: center; min-width: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .settings-nav-scroll { display: flex; gap: .5rem; min-width: 0; padding: .6rem .6rem; overflow-x: auto; overflow-y: hidden; }
  .settings-group { display: flex; gap: .25rem; align-items: center; }
  .settings-group + .settings-group { margin: 0 0 0 .4rem; padding-left: .6rem; border-left: 1px solid var(--line); }
  .settings-group-label { display: none; }
  .settings-tab { width: auto; white-space: nowrap; padding: .45rem .6rem; }
  .settings-nav-footer { border-top: 0; border-left: 1px solid var(--line); padding: .6rem .5rem; }
  .settings-footer-btn span { position: absolute; left: -9999px; }
  .settings-pane-head { padding: 1rem 1rem .4rem; }
  .settings-pane-body { padding: 0 1rem 1.5rem; }
  .settings-row { grid-template-columns: 1fr auto; }
  .settings-row-label { grid-column: 1 / -1; padding-top: 0; }
  .settings-row-value, .settings-row-label { padding-top: 0; }
  .settings-editor { padding: .8rem; }
}

/* ---------------- buy credits ---------------- */
.buy-packs { border: 0; padding: 0; margin: .6rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.buy-pack { flex-direction: column; align-items: flex-start; gap: .2rem; position: relative; padding: .7rem .8rem; }
.buy-pack input { position: absolute; opacity: 0; pointer-events: none; }
.buy-pack b { font-family: var(--font); font-size: 1.15rem; display: block; }
.buy-pack small { display: block; color: var(--muted); font-size: .8rem; }
.buy-pack:has(input:focus-visible) { outline: 3px solid var(--copper); outline-offset: 2px; }
.buy-custom { margin-top: .8rem; }
.buy-guide { display: block; margin-top: .4rem; color: var(--ink-2); }
.buy-custom input { max-width: 240px; }

/* ---------------- admin ---------------- */
.admin-stats .stat b { font-size: 1.3rem; }
.admin-toolbar { margin-bottom: .6rem; }
.admin-toolbar input[type=search] { flex: 1 1 240px; }
.admin-table td { vertical-align: middle; }
.admin-user { min-width: 200px; }
.admin-user .badge { vertical-align: middle; }
.admin-actions { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.admin-form { max-width: 560px; }
.admin-form .form-row { margin-bottom: .8rem; }
.admin-form .form-grid { gap: 0 .8rem; }
.admin-form .check { margin: .4rem 0; }
@media (max-width: 760px) {
  .admin-actions { justify-content: flex-start; }
  .admin-actions .btn { flex: 1 1 auto; justify-content: center; }
}

.toast-root { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 200; }
.toast { background: var(--ink); color: #fff; padding: .6rem .9rem; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; }
.toast-error { background: var(--danger); }

.stat { display: flex; flex-direction: column; }
.stat b { font-size: 1.4rem; font-family: var(--font); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.assumption-list li { margin-bottom: .3rem; }
.timeline li { padding: .3rem 0; border-left: 2px solid var(--line); padding-left: .8rem; margin-left: .3rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .75rem; font-size: .9rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* ---------------- landing ---------------- */
.landing { max-width: none; padding: 0; }
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 2.5rem; align-items: center; max-width: 1200px; margin: 0 auto; padding: 4rem 1.25rem 3rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; color: var(--copper); font-weight: 700; margin-bottom: .6rem; }
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); line-height: 1.1; margin-bottom: 1rem; }
.lede { font-size: 1.15rem; color: var(--ink-2); max-width: 60ch; }
.hero-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 1.2rem; }
.hero-chat { display: flex; flex-direction: column; gap: .6rem; }
.hc { padding: .55rem .8rem; border-radius: 10px; font-size: .95rem; max-width: 90%; }
.hc-user { align-self: flex-end; background: #e2f3f1; border-radius: 10px 10px 2px 10px; }
.hc-sys { align-self: flex-start; background: var(--paper-2); border: 1px solid var(--line); font-style: italic; color: var(--ink-2); }
.hc-done { background: #fbeee2; border-color: #efcfb2; color: #7a4a12; font-style: normal; font-weight: 600; }
.band { max-width: 1200px; margin: 0 auto; padding: 3rem 1.25rem; }
.band h2 { font-size: 1.9rem; margin-bottom: .4rem; }
.band-alt { max-width: none; background: var(--card); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.band-alt > * { max-width: 1200px; margin-left: auto; margin-right: auto; }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.steps li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.1rem 1rem; position: relative; }
.step-n { display: inline-flex; width: 2rem; height: 2rem; border-radius: 50%; background: var(--ink); color: #fff; align-items: center; justify-content: center; font-weight: 700; margin-bottom: .6rem; font-family: var(--font); }
.steps h3 { font-size: 1.1rem; margin-bottom: .4rem; }
.steps p { font-size: .95rem; color: var(--ink-2); margin: 0; }
.features { margin-top: 1.25rem; }
.feature h3 { font-size: 1.05rem; margin-bottom: .35rem; }
.feature p { color: var(--ink-2); font-size: .95rem; }
.band-cta { text-align: center; padding-bottom: 3rem; }
.band-cta .lede { margin: 0 auto 1.2rem; }
.quote-band { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem 2.5rem; }
.pull-quote { margin: 0; padding: 1.35rem 1.5rem 1.2rem 1.55rem; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--copper); border-radius: 0 var(--radius) var(--radius) 0; box-shadow: var(--shadow); }
.pull-quote blockquote { margin: 0; }
.pull-quote p { margin: 0; font-family: var(--font); font-size: 1.2rem; line-height: 1.45; color: var(--ink); font-style: italic; }
.pull-quote figcaption { margin-top: .75rem; }
.pull-quote cite { font-style: normal; font-size: .82rem; font-weight: 600; letter-spacing: .02em; color: var(--copper); }
.pull-quote cite a { color: inherit; text-decoration: none; }
.pull-quote cite a:hover, .pull-quote cite a:focus-visible { text-decoration: underline; }
.samples-band { background: var(--ink); color: #dfe7f0; }
.samples-inner { max-width: 1200px; margin: 0 auto; padding: 3rem 1.25rem; }
.samples-inner h2 { font-size: 1.9rem; margin-bottom: .4rem; color: #fff; }
.samples-inner .muted { color: #9aabbd; }
.sample-shelf { list-style: none; padding: 0; margin: 1.75rem 0 0; display: grid; grid-template-columns: repeat(2, 200px); justify-content: start; gap: 2rem; }
.sample-shelf li { margin: 0; min-width: 0; }
.sample-book { display: flex; flex-direction: column; align-items: stretch; text-align: left; text-decoration: none; color: inherit; gap: .65rem; }
.sample-book img { width: 100%; height: auto; display: block; border-radius: 2px 8px 8px 2px; box-shadow: 2px 0 0 rgba(0, 0, 0, .25), 0 12px 32px rgba(0, 0, 0, .35); background: #0d1520; transition: transform .18s ease, box-shadow .18s ease; }
.sample-book:hover img, .sample-book:focus-visible img { transform: translateY(-4px); box-shadow: 2px 0 0 rgba(0, 0, 0, .25), 0 16px 36px rgba(0, 0, 0, .45); }
.sample-meta { display: flex; flex-direction: column; gap: .15rem; }
.sample-meta b { font-family: var(--font); font-size: 1.15rem; color: #fff; }
.sample-meta span { color: #e2b07a; font-size: .82rem; font-weight: 600; letter-spacing: .02em; }
.sample-blurb { color: #c5d0dc; font-size: .9rem; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; padding-top: 2.5rem; } .hero-card { order: 2; } .sample-shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 420px; gap: 1.25rem; } }

/* ---------------- site footer + legal ---------------- */
.site-footer { flex-shrink: 0; background: var(--ink); color: #c5d0dc; }
.site-footer-inner { max-width: 1200px; margin: 0 auto; padding: 1.1rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.site-footer-copy { margin: 0; font-size: .9rem; color: #9aabbd; }
.site-footer-nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.site-footer-nav a { color: #dfe7f0; text-decoration: none; font-size: .9rem; }
.site-footer-nav a:hover, .site-footer-nav a:focus-visible { text-decoration: underline; }
@media (max-width: 520px) {
  .site-footer-inner { flex-direction: column; align-items: flex-start; gap: .45rem; }
}

.legal { padding-bottom: 4rem; }
.legal-doc .lede { margin-bottom: .6rem; }
.legal-toc { margin: 1.75rem 0 2rem; padding: 1rem 1.15rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.legal-toc-title { font-size: 1rem; margin: 0 0 .5rem; }
.legal-toc ol { margin: 0; padding-left: 1.2rem; }
.legal-toc > ol > li { margin: .35rem 0; }
.legal-toc ol ol { margin-top: .25rem; margin-bottom: .4rem; }
.legal-toc a { text-decoration: none; }
.legal-toc a:hover, .legal-toc a:focus-visible { text-decoration: underline; }
.legal-doc h2 { font-size: 1.55rem; margin-top: 2.4rem; padding-top: 1.4rem; border-top: 1px solid var(--line); }
.legal-doc h3 { font-size: 1.15rem; margin-top: 1.5rem; }
.legal-doc ul { margin: 0 0 1rem; padding-left: 1.2rem; }
.legal-doc li { margin: .3rem 0; color: var(--ink-2); }
.legal-doc p { color: var(--ink-2); }
.legal-doc section:target { scroll-margin-top: 1.25rem; }
.legal-doc h2:target, .legal-doc h3:target { scroll-margin-top: 1.25rem; }

/* ---------------- opening screen ---------------- */
.start-form { margin-top: 2.5rem; }
.start-label { font-family: var(--font); font-size: 2rem; font-weight: 400; margin-bottom: .8rem; color: var(--ink); }
.start-idea { min-height: 200px; font-size: 1.15rem; padding: 1rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow); }
.btn-lg { padding: .75rem 1.4rem; font-size: 1.05rem; }
.start-meta { align-items: flex-start; }
.start-notes { display: flex; flex-direction: column; gap: .15rem; }
.start-short { color: var(--copper); font-weight: 600; }
@media (max-width: 520px) { .start-meta { flex-direction: column; align-items: stretch; } .start-meta .btn-lg { width: 100%; justify-content: center; } }
.prefs summary { cursor: pointer; color: var(--accent-2); font-weight: 600; }
.prefs { overflow: visible; }
.prefs .form-grid > div { overflow: visible; }
.label-with-help { display: flex; align-items: center; gap: .2rem; margin-bottom: .25rem; position: relative; }
.label-with-help label { margin-bottom: 0; }
.label-with-help:hover, .label-with-help:focus-within { z-index: 5; }
.check-with-help { display: flex; align-items: flex-start; gap: .15rem; margin-top: .65rem; }
.check-with-help .check { flex: 1; min-width: 0; }
.check-with-help .help-tip { flex: none; margin-top: .05rem; }
.help-tip { position: relative; display: inline-flex; align-items: center; }
.help-tip.is-open { z-index: 6; }
.help-tip-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7rem; height: 1.7rem; margin: -.2rem 0; padding: 0;
  border: 0; background: transparent; cursor: help; border-radius: 50%;
}
.help-tip-mark {
  display: flex; align-items: center; justify-content: center;
  width: 1.1rem; height: 1.1rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-2);
  font: 700 .72rem/1 var(--font-ui);
}
.help-tip-btn:hover .help-tip-mark, .help-tip-btn:focus-visible .help-tip-mark,
.help-tip.is-open .help-tip-mark, .label-with-help:hover .help-tip-mark {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.help-tip-pop {
  position: absolute; z-index: 40; left: 0; bottom: calc(100% + .4rem);
  width: 18.5rem; max-width: min(18.5rem, calc(100vw - 2rem));
  padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); font-weight: 400; font-size: .85rem; line-height: 1.45;
  text-align: left; box-shadow: 0 8px 24px rgba(27, 42, 65, .16);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(.2rem); transition: opacity .12s ease, transform .12s ease, visibility .12s;
}
.help-tip-pop::after {
  content: ""; position: absolute; top: 100%; left: .85rem;
  border: 7px solid transparent; border-top-color: #fff; filter: drop-shadow(0 1px 0 var(--line));
}
.help-tip:hover .help-tip-pop, .help-tip.is-open .help-tip-pop, .help-tip-btn:focus-visible + .help-tip-pop,
.label-with-help:hover .help-tip-pop {
  opacity: 1; visibility: visible; pointer-events: auto; transform: none;
}
.help-tip-what { display: block; color: var(--ink-2); }
.help-tip-ex { display: block; margin-top: .45rem; }
.help-tip-ex b { color: var(--copper); font-weight: 600; }
@media (max-width: 520px) {
  .help-tip-pop { width: min(18.5rem, calc(100vw - 2rem)); left: 50%; transform: translate(-50%, .2rem); }
  .help-tip:hover .help-tip-pop, .help-tip.is-open .help-tip-pop, .help-tip-btn:focus-visible + .help-tip-pop,
  .label-with-help:hover .help-tip-pop { transform: translate(-50%, 0); }
  .help-tip-pop::after { left: 50%; margin-left: -7px; }
}

/* ---------------- series / sequels ---------------- */
.series-kicker { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0 0 .6rem; }
.series-kicker a { color: inherit; }
.series-carry-body { margin-top: .7rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); font-size: .95rem; }
.series-carry-body p { margin: 0 0 .6rem; }
.series-carry-body p:last-child { margin-bottom: 0; }
.notice { padding: .55rem .8rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper); }
.notice-warn { border-color: #f0dcae; background: #fdf5e6; color: #7a5410; }
.series-line { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.series-line a { color: inherit; }
.book-card .series-tag { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; margin: 0 0 .35rem; }

/* ---------------- studio ---------------- */
.studio-body { overflow: hidden; display: block; }
.studio-body .site-footer { display: none; }
.studio { height: calc(100vh - 52px); display: flex; flex-direction: column; padding: 0; max-width: none; }
#studio { display: flex; flex-direction: column; height: 100%; }
.studio-bar { display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; border-bottom: 1px solid var(--line); background: var(--card); flex-wrap: wrap; }
.studio-title { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.studio-title h1 { font-size: 1.25rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.studio-status { display: flex; flex-direction: column; flex: 1; min-width: 160px; }
.studio-status > span:first-child { font-weight: 600; }
.studio-controls { display: flex; gap: .4rem; align-items: center; position: relative; }
.studio-tabs { display: none; }
.studio-panels { display: grid; grid-template-columns: 35% 6px 1fr; flex: 1; min-height: 0; }
.chat-pane, .book-pane { display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat-pane { border-right: 1px solid var(--line); background: var(--paper-2); }
.divider { background: var(--line); cursor: col-resize; }
.divider:hover, .divider:focus { background: var(--accent); }
.chat-scroll { flex: 1; overflow: auto; padding: 1rem; }
.chat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.chat-msg { max-width: 92%; }
.chat-user { align-self: flex-end; }
.chat-user .chat-bubble { background: #e2f3f1; border-radius: 12px 12px 3px 12px; }
.chat-assistant .chat-bubble { background: var(--card); border: 1px solid var(--line); border-radius: 12px 12px 12px 3px; }
.kind-milestone .chat-bubble { background: transparent; border: 0; color: var(--ink-2); padding: .2rem .4rem; font-style: italic; }
.kind-exception .chat-bubble { border-color: #f3c1bb; background: #fdf1ef; }
/* live agent steps: small, quiet lines; the newest one shows a spinner while the run is working */
.kind-progress { max-width: 100%; }
.kind-progress .chat-bubble { background: transparent; border: 0; color: var(--ink-2); padding: .1rem .4rem .1rem 1.4rem; font-size: .86rem; position: relative; }
.kind-progress .chat-bubble::before { content: ""; position: absolute; left: .45rem; top: .72em; width: .45rem; height: .45rem; border-radius: 50%; background: var(--accent); opacity: .7; }
.kind-progress.live .chat-bubble::before { background: transparent; border: 2px solid var(--accent); border-right-color: transparent; width: .55rem; height: .55rem; left: .38rem; top: .6em; animation: spin .9s linear infinite; }
.kind-progress.collapsed { display: none; }
.error-ref { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .75rem; background: rgba(0,0,0,.05); padding: 0 .3rem; border-radius: 3px; }
.chat-steps-toggle { background: none; border: 0; color: var(--ink-2); font-size: .78rem; padding: 0 .4rem; cursor: pointer; text-decoration: underline dotted; }
.chat-steps-toggle:hover, .chat-steps-toggle:focus { color: var(--accent); }
.chat-bubble { padding: .55rem .8rem; line-height: 1.5; word-wrap: break-word; }
.chat-bubble p { margin: 0 0 .5em; } .chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul, .chat-bubble ol { margin: .3em 0 .5em; padding-left: 1.3em; }
.chat-bubble h1, .chat-bubble h2, .chat-bubble h3 { font-size: 1em; margin: .6em 0 .3em; }
.chat-bubble code { font-size: .9em; background: rgba(0,0,0,.05); padding: 0 .25em; border-radius: 3px; }
.chat-bubble blockquote { margin: .4em 0; padding-left: .7em; border-left: 3px solid var(--line); color: var(--ink-2); }
.chat-refs { margin-top: .25rem; }
.chat-facts { font-size: .8rem; margin: .3rem 0 0; padding-left: 1rem; }
.chat-msg.pending .chat-bubble { opacity: .8; }
.chat-compose { display: flex; gap: .5rem; padding: .6rem 1rem; border-top: 1px solid var(--line); background: var(--card); align-items: flex-end; }
.chat-compose textarea { flex: 1; min-height: 44px; resize: none; }
.sr-only { position: absolute; left: -9999px; }
.book-scroll { flex: 1; overflow: auto; padding: 1.5rem clamp(1rem, 6vw, 5rem) 6rem; background: #fffdf9; }
.book { max-width: 720px; margin: 0 auto; font-family: var(--font); font-size: 1.12rem; line-height: 1.75; }
.book-title { text-align: center; font-size: 2.2rem; margin: 1rem 0 2rem; }
.book .chapter h2 { text-align: center; margin: 2.5rem 0 1.25rem; font-size: 1.5rem; }
.book .scene p { margin: 0 0 1em; text-indent: 1.4em; }
.book .scene p:first-of-type { text-indent: 0; }
.scene-break { text-align: center; color: var(--muted); margin: 1.2em 0; letter-spacing: .4em; }
.scene.drafting { opacity: .75; border-left: 3px solid var(--warn); padding-left: 1rem; }
.drafting-label { float: right; }
.scene.flash { background: #fff7e6; transition: background 1.5s; }
.synopsis { font-family: var(--font-ui); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; font-size: 1rem; line-height: 1.55; }
.outline li { margin-bottom: .5rem; }
.book-done, .book-attention { font-family: var(--font-ui); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-top: 2rem; }
.book-attention { border-left: 4px solid var(--copper); }
.book-attention-clear { border-left-color: var(--ok, #2e7d4f); }
.book-attention .attention-list { padding-left: 1.1rem; margin: .6rem 0 0; }
.book-attention .attention-list li { margin: 0 0 .75rem; overflow-wrap: anywhere; white-space: normal; }
.book-attention .attention-list li p { margin: .35rem 0 0; line-height: 1.5; }
.issue-list { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; gap: .75rem; }
.issue { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; background: var(--paper-2); transition: opacity .3s; }
.issue.issue-sent { opacity: .55; }
.issue-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .35rem; }
.issue p { margin: .3rem 0; line-height: 1.45; }
.issue-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
@media (max-width: 600px) { .issue-actions .btn { flex: 1 1 auto; } }
.jump-latest { position: absolute; bottom: 1rem; right: 1.5rem; box-shadow: var(--shadow); }
.selection-menu { position: absolute; z-index: 5; display: flex; gap: .25rem; padding: .25rem; background: var(--ink); border-radius: 9px; box-shadow: var(--shadow); max-width: calc(100% - 16px); flex-wrap: wrap; }
.selection-menu .btn { background: transparent; color: #fff; border-color: transparent; white-space: nowrap; }
.selection-menu .btn:hover, .selection-menu .btn:focus-visible { background: rgba(255,255,255,.14); }
.selection-menu .btn:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.insert-marker { position: absolute; z-index: 4; height: 2px; background: var(--copper); border-radius: 2px; pointer-events: none; }
.insert-marker::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--copper); }
.book .scene { cursor: text; }

/* ---------------- story links: cast and places as clickable outlines in the text, a metadata strip per scene, and the popover ---------------- */
#links-btn.active { background: #e2f3f1; border-color: #b5ddd9; color: var(--accent-2); }
.ent { cursor: pointer; border-radius: 4px; padding: 0 .14em; margin: 0 -.04em; box-shadow: inset 0 0 0 1px rgba(15, 118, 110, .38); background: rgba(15, 118, 110, .045); -webkit-box-decoration-break: clone; box-decoration-break: clone; transition: background .12s, box-shadow .12s; }
.ent-location { box-shadow: inset 0 0 0 1px rgba(181, 101, 29, .42); background: rgba(181, 101, 29, .05); }
.ent:hover, .ent:focus-visible { background: #e2f3f1; box-shadow: inset 0 0 0 1px var(--accent); }
.ent-location:hover, .ent-location:focus-visible { background: #fbeee2; box-shadow: inset 0 0 0 1px var(--copper); }
.ent:focus-visible { outline: 2px solid var(--copper); outline-offset: 1px; }
.ent.ent-active { background: #cfe9e5; box-shadow: inset 0 0 0 1px var(--accent-2); }
.ent-location.ent-active { background: #f6dfc9; box-shadow: inset 0 0 0 1px var(--copper); }
.scene-meta { font-family: var(--font-ui); font-size: .78rem; line-height: 1.5; color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .4rem; margin: 0 0 1em; padding: .4rem .65rem; border: 1px dashed var(--line); border-radius: 8px; background: var(--paper-2); text-indent: 0; }
.scene-meta .meta-label { font-weight: 600; color: var(--muted); letter-spacing: .02em; text-transform: uppercase; font-size: .7rem; }
.scene-meta .meta-sep { color: var(--line); }
.scene-meta .meta-prefix { color: var(--muted); font-weight: 400; }
.scene-meta .meta-time { font-style: italic; }
.scene-meta .ent { padding: 0 .4em; margin: 0; }
.scene-meta .ent-thread { box-shadow: inset 0 0 0 1px var(--line); background: var(--card); border-radius: 999px; color: var(--ink-2); }
.scene-meta .ent-thread:hover, .scene-meta .ent-thread:focus-visible, .scene-meta .ent-thread.ent-active { background: var(--paper); box-shadow: inset 0 0 0 1px var(--ink-2); }
.ent-pop { position: absolute; z-index: 30; width: min(400px, calc(100% - 16px)); max-height: min(72vh, 520px); overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 44px rgba(27, 42, 65, .22), 0 2px 6px rgba(27, 42, 65, .1); padding: .85rem 1rem .9rem; font-family: var(--font-ui); font-size: .9rem; line-height: 1.5; color: var(--ink); }
.ent-pop-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.ent-pop-head h3 { display: inline; font-size: 1.1rem; margin: 0; vertical-align: middle; }
.ent-pop-head .badge { vertical-align: middle; }
.ent-pop-sub { margin: .2rem 0 0; }
.ent-pop-body { margin-top: .6rem; }
.ent-pop-body p { margin: 0 0 .5rem; }
.ent-pop-body .kv { margin: .4rem 0 0; }
.ent-pop-where { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .6rem; padding-top: .55rem; border-top: 1px dashed var(--line); }
.ent-pop-nav { display: inline-flex; gap: .1rem; flex-shrink: 0; }
.ent-pop-nav .btn { line-height: 1; padding: .15rem .4rem; }
.ent-pop-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .7rem; }
@media (max-width: 600px) { .ent-pop-actions .btn { flex: 1 1 auto; } }
.mini-card.flash { background: #fff7e6; transition: background 1.5s; }

/* ---------------- in-text illustrations ---------------- */
.book .illustration { margin: 1.6em auto; width: 100%; font-family: var(--font-ui); cursor: default; }
.book .illustration.aspect-wide { max-width: 100%; }
.book .illustration.aspect-square { max-width: 520px; }
.book .illustration.aspect-tall { max-width: 420px; }
.illustration-frame { position: relative; background: var(--paper); border-radius: 6px; overflow: hidden; box-shadow: 0 6px 20px rgba(27, 42, 65, .18), 0 1px 3px rgba(27, 42, 65, .12); }
.aspect-wide .illustration-frame { aspect-ratio: 3 / 2; }
.aspect-square .illustration-frame { aspect-ratio: 1 / 1; }
.aspect-tall .illustration-frame { aspect-ratio: 2 / 3; }
.illustration-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.illustration-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; color: var(--muted); font-size: .9rem; padding: 1rem; text-align: center;
  background: repeating-linear-gradient(135deg, var(--paper) 0 12px, var(--paper-2) 12px 24px); }
.illustration-placeholder.illustration-failed { color: var(--danger); background: var(--paper-2); }
.illustration-placeholder small { color: var(--muted); font-size: .75rem; line-height: 1.3; max-width: 36ch; }
.illustration figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: .8rem; padding: .45rem .2rem 0; font-size: .85rem; color: var(--ink-2); }
.illustration-caption { font-style: italic; flex: 1; }
.illustration-tools { display: flex; gap: .2rem; align-items: center; flex-shrink: 0; }
.illustration-tools .btn, .illustration-tools a.btn { font-size: .75rem; padding: .15rem .45rem; }
.illustration-nav { display: inline-flex; align-items: center; gap: .1rem; margin-right: .3rem; padding-right: .3rem; border-right: 1px solid var(--line); }
.illustration-nav .btn { line-height: 1; padding: .15rem .35rem; }
.illustration-nav .btn[disabled] { opacity: .3; cursor: default; }
.illustration-count { min-width: 3.2em; text-align: center; white-space: nowrap; }
.illustration.flash { outline: 3px solid var(--copper); outline-offset: 6px; border-radius: 6px; transition: outline-color 1.5s; }
.illustration:hover .illustration-tools, .illustration:focus-within .illustration-tools { opacity: 1; }
@media (hover: hover) { .illustration-tools { opacity: .6; transition: opacity .15s; } }
.illustration-form .form-row { margin-bottom: .9rem; }
.illustration-form label { display: block; font-weight: 600; margin-bottom: .3rem; }
.illustration-form .hint { color: var(--muted); font-weight: 400; font-size: .8rem; }
.illustration-form select, .illustration-form textarea { width: 100%; }
.illustration-form .passage { font-family: var(--font); font-size: .95rem; line-height: 1.5; color: var(--ink-2); background: var(--paper-2); border-left: 3px solid var(--copper); padding: .5rem .8rem; border-radius: 0 6px 6px 0; margin: 0 0 1rem; max-height: 7.5em; overflow: hidden; }
.illustration-form .aspects { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.illustration-form .aspects .choice { flex-direction: column; align-items: center; text-align: center; gap: .35rem; padding: .6rem .4rem; }
.illustration-form .aspects .choice input { position: absolute; opacity: 0; pointer-events: none; }
.illustration-form .aspects .choice { position: relative; }
.aspect-icon { display: block; border: 2px solid var(--ink-2); border-radius: 3px; background: #fff; }
.aspect-icon.tall { width: 22px; height: 33px; } .aspect-icon.wide { width: 36px; height: 24px; } .aspect-icon.square { width: 28px; height: 28px; }
.choice:has(input:checked) .aspect-icon { border-color: var(--accent); background: #eaf6f4; }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chapters-menu { position: absolute; top: 56px; right: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; z-index: 25; min-width: 280px; padding: .3rem; }
.chapters-menu a { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem .7rem; text-decoration: none; color: var(--ink); border-radius: 6px; }
.chapters-menu a:hover { background: var(--paper-2); }
.chapters-menu a.done span:first-child::before { content: "✓ "; color: var(--ok); }
.details-drawer { position: absolute; top: 56px; right: 0; bottom: 0; width: min(480px, 100%); background: var(--card); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0,0,0,.08); overflow: auto; padding: 1rem 1.2rem; z-index: 20; }
.details-drawer details { border-top: 1px solid var(--line); padding: .5rem 0; }
.details-drawer summary { cursor: pointer; font-weight: 600; font-family: var(--font); }
.details-body { padding: .5rem 0 .3rem; font-size: .92rem; }
.mini-card { padding: .4rem 0; border-bottom: 1px dashed var(--line); }

/* ---------------- covers ---------------- */
.book-cover-figure { margin: 0 auto 2rem; max-width: 320px; }
.book-cover { display: block; width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px; box-shadow: 0 10px 30px rgba(27, 42, 65, .25), 0 2px 6px rgba(27, 42, 65, .15); }
.cover-drawer { width: min(560px, 100%); }
.cover-form fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
.cover-form legend { font-weight: 600; margin-bottom: .4rem; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem; }
.choice { display: flex; gap: .55rem; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; cursor: pointer; background: var(--paper-2); }
.choice:has(input:checked) { border-color: var(--accent); background: #eaf6f4; }
.choice input { margin-top: .25rem; }
.choice small { display: block; color: var(--muted); font-size: .78rem; }
.cover-form .hint { color: var(--muted); font-weight: 400; font-size: .8rem; }
.cover-form input[type=text], .cover-form select, .cover-form textarea { width: 100%; }
#cover-btn .count { display: inline-block; min-width: 1.2rem; padding: 0 .35rem; border-radius: 999px; background: var(--ink); color: #fff; font-size: .7rem; text-align: center; margin-left: .2rem; }
.cover-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-top: 1.25rem; }
.cover-card { margin: 0; border: 1px solid var(--line); border-radius: 10px; padding: .6rem; background: var(--card); }
.cover-card.selected { border-color: var(--copper); box-shadow: 0 0 0 2px rgba(181, 101, 29, .2); }
.cover-thumb { aspect-ratio: 2 / 3; background: var(--paper); border-radius: 6px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.cover-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; color: var(--muted); font-size: .9rem; padding: 1rem; text-align: center; }
.cover-failed { color: var(--danger); }
.cover-failed small { color: var(--muted); font-size: .72rem; line-height: 1.3; }
.cover-card figcaption { padding-top: .5rem; font-size: .85rem; }
.cover-rationale { margin: .35rem 0 0; line-height: 1.35; }
.cover-zoom { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: inherit; }
.cover-zoom:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.cover-zoom img { display: block; }
.book-cover-figure .cover-zoom { border-radius: 4px; }
.cover-fonts { margin: .35rem 0 0; }
.cover-legacy { margin: .35rem 0 0; color: var(--copper); line-height: 1.35; }
.cover-thumb.relettering { opacity: .55; filter: saturate(.6); transition: opacity .2s; }
.cover-inspiration > label { display: block; font-weight: 600; margin-bottom: .4rem; }
.sample-pick { display: grid; grid-template-columns: 96px 1fr; gap: .8rem; align-items: start; padding: .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-2); }
.sample-preview { aspect-ratio: 2 / 3; border-radius: 4px; background: var(--paper); border: 1px dashed var(--line); overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; text-align: center; padding: .3rem; }
.sample-preview:has(img) { border-style: solid; padding: 0; }
.sample-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sample-input input[type=file] { width: 100%; max-width: 100%; font-size: .85rem; }
.sample-input p { margin: .45rem 0 0; line-height: 1.35; }
@media (max-width: 420px) { .sample-pick { grid-template-columns: 72px 1fr; gap: .6rem; } }

/* ---------------- cover lettering ---------------- */
.lettering-details summary { cursor: pointer; font-weight: 600; }
.lettering-details summary .hint { font-weight: 400; font-size: .8rem; color: var(--muted); }
.lettering-details .lettering-body { padding-top: .8rem; }
.lettering-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .2rem .8rem; }
.lettering-grid .form-row { margin-bottom: .6rem; }
.lettering-grid label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }
.lettering-grid select { width: 100%; }
.let-hint { margin: .25rem 0 0; min-height: 1em; line-height: 1.3; }
.lettering-preview { border: 1px solid var(--line); border-radius: 8px; padding: 1rem .9rem .6rem; text-align: center; margin-top: .4rem; background: #f4efe6; color: #1a1714; overflow: hidden; }
.lettering-preview.lp-dark { background: #23201c; color: #f5f1ea; }
.lp-title { font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.1; overflow-wrap: anywhere; }
.lp-subtitle { font-size: 1rem; margin-top: .35rem; opacity: .92; }
.lp-author { font-size: .95rem; margin-top: .55rem; }
.book-title:has(+ .book-subtitle) { margin-bottom: .4rem; }
.book-subtitle { text-align: center; font-style: italic; color: var(--ink-2); margin: 0 0 2rem; font-size: 1.15rem; }
.lp-note { margin: .8rem 0 0; opacity: .75; }
.lp-placeholder { opacity: .7; font-family: Georgia, "Times New Roman", serif; }
.lp-auto { margin: .7rem 0 0; color: #e8c27a; }
.lettering-preview:not(.lp-dark) .lp-auto { color: #8a5a12; }
.modal:has(.lettering-editor) { max-width: 760px; }

/* ---------------- cover layout editor ---------------- */
.modal:has(.cover-editor) { max-width: 1140px; }
.cover-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 1.1rem; align-items: start; }
.ce-stage-wrap { min-width: 0; }
.ce-stage { position: relative; margin: 0 auto; background: #111; border-radius: 6px; overflow: hidden; user-select: none; touch-action: none; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.ce-art { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.chip.picture { margin-left: auto; border-color: var(--copper); }
.ce-safe { position: absolute; border: 1px dashed rgba(90, 200, 120, .9); pointer-events: none; }
.ce-safe span { position: absolute; right: 4px; bottom: 2px; font-size: .62rem; color: rgba(90, 200, 120, .95); text-shadow: 0 0 3px #000; }
.ce-bands, .ce-band { position: absolute; left: 0; right: 0; pointer-events: none; }
.ce-bands { inset: 0; }
.ce-els { position: absolute; inset: 0; }
.ce-el { position: absolute; cursor: grab; outline: 1px dashed transparent; border-radius: 2px; }
.ce-el:hover { outline-color: rgba(255,255,255,.45); }
.ce-el.selected { outline: 2px solid var(--accent); }
.ce-el:focus-visible { outline: 3px solid var(--accent); }
.ce-el:active { cursor: grabbing; }
.ce-text { display: block; white-space: normal; overflow-wrap: break-word; }
.ce-handle { position: absolute; top: 50%; width: 10px; height: 26px; margin-top: -13px; background: var(--accent); border: 2px solid #fff; border-radius: 4px; cursor: ew-resize; opacity: 0; }
.ce-handle-l { left: -6px; } .ce-handle-r { right: -6px; }
.ce-el.selected .ce-handle { opacity: 1; }
.ce-status { min-height: 1.2em; margin: .2rem 0 0; color: var(--ink-2); }
.ce-panel { min-width: 0; }
.ce-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .8rem; }
.chip { border: 1px solid var(--line); background: var(--paper-2); border-radius: 999px; padding: .25rem .7rem; font-size: .82rem; cursor: pointer; color: var(--ink); }
.chip.on { border-color: var(--accent); background: #eaf6f4; font-weight: 600; }
.chip.off { opacity: .6; text-decoration: line-through; }
.chip.add { border-style: dashed; color: var(--ink-2); }
.ce-h { margin: 0 0 .5rem; font-size: 1.05rem; }
.ce-words { margin: 0 0 .7rem; line-height: 1.35; }
.ce-row { margin-bottom: .6rem; }
.ce-row label, .ce-label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .25rem; }
.ce-row label output { font-weight: 400; color: var(--muted); float: right; }
.ce-row select, .ce-row input[type=text], .ce-row input[type=range] { width: 100%; }
.ce-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.ce-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.ce-seg button { border: 0; background: var(--paper-2); padding: .3rem .8rem; cursor: pointer; font-size: 1rem; color: var(--ink); }
.ce-seg button + button { border-left: 1px solid var(--line); }
.ce-seg button.on { background: var(--accent); color: #fff; }
.ce-colour { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.ce-colour label { flex: 0 0 100%; margin-bottom: 0; }
.ce-colour input[type=color] { width: 44px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; }
.ce-details { border-top: 1px solid var(--line); padding: .5rem 0 .2rem; }
.ce-details summary { cursor: pointer; font-weight: 600; font-size: .9rem; list-style: none; }
.ce-details summary .check { display: inline-flex; gap: .4rem; align-items: center; }
.ce-details[open] summary { margin-bottom: .5rem; }
.ce-footer { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .8rem; }
.ce-footer select { max-width: 100%; }
@media (max-width: 860px) { .cover-editor { grid-template-columns: 1fr; } .ce-stage-wrap { position: sticky; top: 0; background: var(--card); z-index: 1; padding-bottom: .3rem; } .ce-el.selected .ce-handle { width: 14px; height: 34px; margin-top: -17px; } }
.lettering-editor { display: grid; gap: 1rem; grid-template-columns: minmax(120px, 160px) 1fr; align-items: start; }
.lettering-editor .lettering-current img { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); display: block; }
.lettering-editor .lettering-current p { margin: .5rem 0 0; }
@media (max-width: 640px) { .lettering-editor { grid-template-columns: 1fr; } .lettering-editor .lettering-current { display: flex; gap: .8rem; align-items: center; } .lettering-editor .lettering-current img { width: 90px; } .lettering-editor .lettering-current p { margin: 0; } }

/* ---------------- publish ---------------- */
.publish-drawer { width: min(640px, 100%); }
.publish-cover { display: flex; gap: .9rem; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: .6rem; margin: 0 0 1rem; background: var(--paper-2); }
.publish-cover:empty { display: none; }
.publish-cover img { width: 72px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px; flex: none; box-shadow: 0 2px 6px rgba(27, 42, 65, .2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 .8rem; }
/* label with a small action on the same line (the About-the-author sparkle) */
.label-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: .3rem; }
.label-row label { margin: 0; }
.btn-sparkle { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px; border: 1px solid var(--accent); color: var(--accent-2); background: #f3faf9; font-size: .78rem; line-height: 1.4; white-space: nowrap; }
.btn-sparkle:hover { background: var(--accent); color: #fff; }
.btn-sparkle .sparkle { width: 14px; height: 14px; fill: currentColor; flex: none; }
.btn-sparkle.working .sparkle { animation: sparkle-pulse 1s ease-in-out infinite; }
@keyframes sparkle-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.25); opacity: .55; } }
.bio-draft textarea, .bio-draft select { width: 100%; }
.bio-draft .bio-draft-intro { margin: 0 0 .7rem; }
.bio-draft .form-row { margin-bottom: .7rem; }
@media (max-width: 480px) { .btn-sparkle span { display: none; } .btn-sparkle { padding: .3rem .5rem; } }
.pub-title-line { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-2); min-height: 2.2rem; }
.pub-title-line > span:first-child { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.publish-blockers { margin: .6rem 0 0; padding-left: 1.1rem; color: var(--ink-2); }
.publish-blockers li { margin: .25rem 0; }
#publish-btn .count { margin-left: .2rem; color: #fff; }
.publish-list { margin-top: .5rem; }
.pkg-card { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; margin: .6rem 0; background: var(--card); }
.pkg-card.status-ready { border-color: var(--copper); }
.pkg-progress { display: flex; align-items: center; gap: .5rem; color: var(--muted); padding: .6rem 0 .2rem; }
.pkg-failed { color: var(--danger); padding: .5rem 0 .2rem; }
.pkg-preview { margin: .6rem 0 .2rem; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); position: relative; }
.pkg-preview img { width: 100%; height: auto; display: block; }
.pkg-previews { display: grid; gap: .6rem; grid-template-columns: 1fr; }
.pkg-previews:has(.pkg-preview + .pkg-preview) { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.pkg-preview-label { position: absolute; left: .4rem; top: .4rem; background: rgba(27, 42, 65, .78); color: #fff; padding: .1rem .45rem; border-radius: 999px; pointer-events: none; }
.pkg-meta { display: flex; flex-wrap: wrap; gap: .2rem .8rem; }
.pkg-edition b { font-weight: 600; color: var(--ink-2); }

/* formats accordion in the Publish form */
.pub-formats { margin: .4rem 0 1.1rem; }
.pub-format { border: 1px solid var(--line); border-radius: 10px; margin: .5rem 0; background: var(--card); transition: opacity .15s; }
.pub-format.off { opacity: .62; }
.pub-format.off.open { opacity: 1; }
.pub-format-head { display: flex; align-items: center; gap: .6rem; padding: .45rem .55rem .45rem .7rem; }
.pub-format-check { flex: none; align-items: center; margin: 0; cursor: pointer; }
.pub-format-check input { margin: 0; width: 1.05rem; height: 1.05rem; }
.pub-format-toggle { flex: 1 1 auto; display: flex; align-items: center; justify-content: flex-end; gap: .5rem; min-width: 0; background: none; border: 0; padding: .3rem .2rem; cursor: pointer; color: var(--ink-2); text-align: right; font: inherit; }
.pub-format-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.pub-format-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-chevron { width: 18px; height: 18px; flex: none; transition: transform .15s; }
.pub-format.open .pub-chevron { transform: rotate(180deg); }
.pub-format-body { border-top: 1px solid var(--line); padding: .8rem .8rem .7rem; }
.pub-format-body .form-row:last-child { margin-bottom: 0; }
@media (max-width: 480px) { .pub-format-summary { display: none; } }
.pkg-files { margin: .5rem 0; font-size: .9rem; }
.pkg-files summary { cursor: pointer; font-weight: 600; }
.pkg-files ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.pkg-files li { margin: .3rem 0; line-height: 1.35; }
.marketing-plan { margin-top: .7rem; line-height: 1.5; overflow-wrap: anywhere; max-width: min(40rem, 100%); }
.marketing-plan h1, .marketing-plan h2, .marketing-plan h3 { font-size: 1rem; margin: .9rem 0 .35rem; line-height: 1.3; }
.marketing-plan p { margin: 0 0 .55rem; }
.marketing-plan ul, .marketing-plan ol { margin: .3rem 0 .6rem; padding-left: 1.2rem; }
.marketing-plan li { margin: .25rem 0; }

/* ---------------- reader review ---------------- */
.review-drawer { width: min(600px, 100%); }
.review-form { border: 1px solid var(--line); border-radius: 10px; padding: .8rem .9rem .6rem; background: var(--paper-2); margin: .4rem 0 1rem; }
.review-form fieldset { border: 0; padding: 0; margin: 0 0 .9rem; }
.review-form legend { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; padding: 0; }
.review-form .choice { background: var(--card); }
.review-form textarea { width: 100%; }
.review-submit-row { gap: .8rem; align-items: center; flex-wrap: wrap; }
.review-list-title { margin: 1.2rem 0 .5rem; }
.review-card.status-ready { border-color: var(--copper); }
.review-card .progress { margin: .4rem 0; }
.review-top { display: flex; flex-direction: column; gap: .15rem; margin: .5rem 0 0; }
.review-headline { margin: 0; font-size: 1.1rem; line-height: 1.3; font-family: var(--font); }
.review-verdict { margin: .2rem 0 .5rem; }
.stars { display: inline-flex; gap: .05rem; font-size: 1.15rem; line-height: 1; letter-spacing: 0; white-space: nowrap; vertical-align: -1px; }
.star { color: #d8d0c2; }
.star.on { color: #d49a12; }
.book-review .stars { font-size: 1rem; }
.review-btn-stars { color: #b07d0a; font-weight: 700; margin-left: .15rem; }
.review-text { font-family: var(--font); font-size: 1rem; line-height: 1.6; overflow-wrap: anywhere; }
.review-text p { margin: 0 0 .7rem; }
.review-section { margin: .4rem 0 .6rem; }
.review-quote { margin: .35rem 0; padding-left: .7rem; border-left: 3px solid var(--line); color: var(--ink-2); font-family: var(--font); font-style: italic; font-size: .92rem; }
.review-problem .chat-refs { margin: .2rem 0 .3rem; }
.fix-actions { align-items: center; }
.fix-actions .btn svg { vertical-align: -2px; margin-right: .15rem; }
.fix-state { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 600; padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); white-space: nowrap; }
.fix-queued { color: var(--warn); border-color: #f0dcae; background: #fdf5e6; }
.fix-working { color: var(--accent-2); border-color: #b5ddd9; background: #eaf6f4; }
.fix-done { color: var(--ok); border-color: #bfe0c9; background: #eaf6ee; }
.fix-clarify { color: var(--copper); border-color: #efd2b8; background: #fbeee2; }
.fix-note { color: var(--muted); flex: 1 1 12rem; line-height: 1.35; }
.review-journal { margin: .5rem 0 0; padding-left: 0; list-style: none; display: grid; gap: .6rem; }
.review-journal li { line-height: 1.45; }
.review-engagement { color: var(--accent); letter-spacing: .08em; font-size: .75rem; margin-right: .3rem; }
.review-engagement .off { color: #d8d0c2; }
.book-review { border-left: 4px solid #d49a12; }
.book-review .small { line-height: 1.5; }
@media (max-width: 760px) {
  .studio-controls { flex-wrap: wrap; }
  .review-submit-row .btn { width: 100%; justify-content: center; }
}

/* full-screen zoomable image viewer */
body.lightbox-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(12, 18, 28, .94); display: flex; flex-direction: column; animation: fadein .12s ease-out; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.lightbox-dialog { display: flex; flex-direction: column; height: 100%; }
.lightbox-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem .8rem; color: #e8e2d6; font-family: var(--font-ui); font-size: .9rem; flex-wrap: wrap; }
.lightbox-caption { opacity: .85; }
.lightbox-tools { display: flex; gap: .35rem; align-items: center; margin-left: auto; }
.lightbox-tools .btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); color: #fff; }
.lightbox-tools .btn:hover { background: rgba(255,255,255,.2); }
.lightbox-zoom { min-width: 4.2rem; font-variant-numeric: tabular-nums; }
.lightbox-viewport { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; cursor: zoom-out; }
.lightbox-viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lightbox-img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; user-select: none; -webkit-user-drag: none; transform-origin: center center; transition: transform .06s linear; cursor: zoom-in; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.lightbox-viewport.zoomed .lightbox-img { cursor: grab; transition: none; }
.lightbox-viewport.zoomed:active .lightbox-img { cursor: grabbing; }
@media (max-width: 760px) { .lightbox-caption { display: none; } .lightbox-bar { padding: .4rem .5rem; } }

.dash-cover { display: block; width: 64px; height: auto; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 3px; box-shadow: 0 2px 8px rgba(27, 42, 65, .2); }

@media (max-width: 760px) {
  .studio-tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--card); }
  .studio-tabs [role=tab] { flex: 1; padding: .6rem; border: 0; background: none; font: inherit; border-bottom: 3px solid transparent; }
  .studio-tabs [role=tab][aria-selected=true] { border-bottom-color: var(--accent); font-weight: 600; }
  .studio-panels { grid-template-columns: 1fr !important; }
  .divider { display: none; }
  #studio[data-pane="chat"] .book-pane { display: none; }
  #studio[data-pane="book"] .chat-pane { display: none; }
  .studio-title h1 { max-width: 60vw; }
  .book-scroll { padding: 1rem 1rem 5rem; }
  .book { font-size: 1.02rem; }
  .details-drawer { top: 0; }
}

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .workspace .pane-right { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; }
  .pane-scroll { max-height: none; }
  .topbar-inner { flex-wrap: wrap; }
  .editor { min-height: 45vh; font-size: 1rem; }
  h1 { font-size: 1.5rem; }
  .savebar { flex-wrap: wrap; justify-content: stretch; }
  .savebar .btn { flex: 1; justify-content: center; }
}
