/* Inkfold — Ink (dark) & Paper (light). Verdigris accent, like oxidised ink on brass.
   Layout: a bookshelf library, and a writing room (binder · page). */
:root {
  --font-display: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --font-ui: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;

  /* Paper (light) */
  --bg: #eff0ec;
  --bg-2: #e7e9e3;
  --surface: #fafbf8;
  --surface-2: #f2f3ef;
  --raise: #ffffff;
  --line: #d9dcd4;
  --line-soft: #e3e5df;
  --text: #171b24;
  --text-2: #4b5160;
  --muted: #858a97;
  --accent: #2a7865;
  --accent-strong: #1d5f4f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(42, 120, 101, .10);
  --warn: #b0731f;
  --danger: #b4483a;
  --page: #fafbf8;
  --shadow-lg: 0 30px 80px -24px rgba(23, 27, 36, .28), 0 2px 6px rgba(23, 27, 36, .06);
  --shadow-sm: 0 1px 2px rgba(23, 27, 36, .06), 0 6px 20px -10px rgba(23, 27, 36, .18);
  --scrim: rgba(23, 27, 36, .38);
  color-scheme: light;

  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --binder-w: 284px;
  --measure: 680px;
  --ed-font: 'Newsreader', Georgia, serif;
  --ed-size: 19px;
  --ed-lh: 1.7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1017; --bg-2: #10141c; --surface: #151a24; --surface-2: #1b2130; --raise: #1f2635;
    --line: #262d3b; --line-soft: #1b212d; --text: #e8e5de; --text-2: #a5a9b4; --muted: #6c7281;
    --accent: #86cdb9; --accent-strong: #a6ddcd; --accent-ink: #0a1714; --accent-soft: rgba(134, 205, 185, .11);
    --warn: #e2b061; --danger: #e58b7e; --page: #0f131b;
    --shadow-lg: 0 40px 90px -30px rgba(0, 0, 0, .75), 0 0 0 1px rgba(255, 255, 255, .04);
    --shadow-sm: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -14px rgba(0, 0, 0, .7);
    --scrim: rgba(4, 6, 10, .62);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1017; --bg-2: #10141c; --surface: #151a24; --surface-2: #1b2130; --raise: #1f2635;
  --line: #262d3b; --line-soft: #1b212d; --text: #e8e5de; --text-2: #a5a9b4; --muted: #6c7281;
  --accent: #86cdb9; --accent-strong: #a6ddcd; --accent-ink: #0a1714; --accent-soft: rgba(134, 205, 185, .11);
  --warn: #e2b061; --danger: #e58b7e; --page: #0f131b;
  --shadow-lg: 0 40px 90px -30px rgba(0, 0, 0, .75), 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -14px rgba(0, 0, 0, .7);
  --scrim: rgba(4, 6, 10, .62);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.tnum { font-variant-numeric: tabular-nums; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 999px; font-weight: 600; font-size: 14px; letter-spacing: .005em; white-space: nowrap;
  transition: background .2s var(--ease), color .2s var(--ease), transform .15s var(--ease), box-shadow .2s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-quiet { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-soft); }
.btn-quiet:hover { background: var(--raise); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--text-2);
  transition: background .2s var(--ease), color .2s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-word { font-family: var(--font-display); font-size: 30px; line-height: 1; letter-spacing: -.01em; }
.brand-word em { font-style: italic; color: var(--accent); }

/* ---------- Library ---------- */
.view { height: 100%; }
#library { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.lib-wrap {
  max-width: 1180px; margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px));
  padding-block: calc(env(safe-area-inset-top, 0px) + 22px) calc(env(safe-area-inset-bottom, 0px) + 60px);
}
.lib-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lib-actions { display: flex; align-items: center; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 13px; border-radius: 999px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft); font-size: 13px; color: var(--text-2); font-weight: 500;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.chip:hover { color: var(--text); background: var(--surface-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); flex: none; }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }

.lib-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin: 52px 0 30px; }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.lib-hero h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(40px, 6vw, 64px); line-height: .98; margin: 10px 0 0; letter-spacing: -.02em; text-wrap: balance; }
.lib-hero h1 em { color: var(--accent); }
.lib-hero .sum { color: var(--text-2); margin-top: 12px; font-size: 14.5px; }
.lib-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 26px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft); flex-wrap: wrap;
}
.banner .b-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.banner.warn .b-icon { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.banner .b-text { flex: 1 1 220px; min-width: 0; }
.banner strong { display: block; font-weight: 600; font-size: 14px; }
.banner span { color: var(--text-2); font-size: 13px; }

.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 34px 26px; }
.book { display: flex; flex-direction: column; gap: 12px; text-align: left; min-width: 0; }
.cover {
  position: relative; aspect-ratio: 2 / 3; width: 100%; max-width: 100%; border-radius: 4px 10px 10px 4px; overflow: hidden;
  background: var(--cbg); color: var(--cfg); box-shadow: var(--shadow-lg);
  transition: transform .45s var(--ease), box-shadow .45s var(--ease);
  display: flex; flex-direction: column; justify-content: space-between; padding: 22px 18px 18px 24px;
}
.cover::before { /* spine */
  content: ''; position: absolute; inset: 0 auto 0 0; width: 11px;
  background: linear-gradient(90deg, rgba(0, 0, 0, .34), rgba(0, 0, 0, .08) 70%, rgba(255, 255, 255, .08));
}
.cover::after { /* paper grain + sheen */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 70% at 85% 0%, rgba(255, 255, 255, .13), transparent 55%), linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, .22));
}
.cover .frame { position: absolute; inset: 12px 10px 12px 18px; border: 1px solid color-mix(in srgb, var(--cline) 55%, transparent); border-radius: 2px; pointer-events: none; }
.cover .c-kicker { position: relative; font-size: 9.5px; letter-spacing: .24em; text-transform: uppercase; color: var(--cline); font-weight: 600; z-index: 1; }
.cover .c-title { position: relative; z-index: 1; font-family: var(--font-display); font-size: clamp(22px, 2.3vw, 27px); line-height: 1.02; letter-spacing: -.01em; text-wrap: balance; overflow-wrap: anywhere; }
.cover .c-sub { position: relative; z-index: 1; font-family: var(--font-display); font-style: italic; font-size: 14px; opacity: .78; margin-top: 6px; }
.cover .c-foot { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--cline); }
.cover .c-fold { width: 14px; height: 14px; }
.book:hover .cover, .book:focus-visible .cover { transform: translateY(-6px) rotate(-.4deg); }
.book:focus-visible { outline: none; }
.book:focus-visible .cover { outline: 2px solid var(--accent); outline-offset: 4px; }
.book .b-meta { display: flex; flex-direction: column; gap: 2px; padding-left: 2px; min-width: 0; }
.book .b-meta b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book .b-meta span { font-size: 12.5px; color: var(--muted); }
.cover.new { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--text-2); align-items: center; justify-content: center; gap: 12px; padding: 18px; }
.cover.new::before, .cover.new::after { display: none; }
.cover.new .plus { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.cover.new .plus svg { width: 24px; height: 24px; }
.book:hover .cover.new { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--text); }
.tag-sample { display: inline-block; margin-left: 6px; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); vertical-align: 1px; }

.lib-foot { margin-top: 64px; padding-top: 22px; border-top: 1px solid var(--line-soft); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 12.5px; }
.lib-foot span { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Workspace ---------- */
#workspace { display: grid; grid-template-columns: var(--binder-w) minmax(0, 1fr); }
.binder {
  background: var(--bg-2); border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; min-height: 0;
  padding-top: env(safe-area-inset-top, 0px); padding-left: env(safe-area-inset-left, 0px);
  transition: transform .35s var(--ease), opacity .35s var(--ease);
}
.binder-head { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 14px; }
.binder-head .back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 500; height: 30px; padding: 0 8px 0 4px; border-radius: 8px; align-self: flex-start; }
.binder-head .back:hover { color: var(--text); background: var(--surface-2); }
.proj-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 0 6px; }
.proj-title h2 { font-family: var(--font-display); font-weight: 400; font-size: 26px; line-height: 1.05; margin: 0; letter-spacing: -.01em; overflow-wrap: anywhere; }
.proj-title p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.binder-list { flex: 1; overflow-y: auto; padding: 4px 8px 20px; }
.binder-label { font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); padding: 10px 10px 8px; display: flex; justify-content: space-between; align-items: center; }
.chapter { margin-bottom: 4px; }
.row {
  position: relative; display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 6px 0 4px; border-radius: 9px;
  cursor: pointer; user-select: none; -webkit-user-select: none; transition: background .15s var(--ease), color .15s var(--ease);
}
.row:hover { background: var(--surface-2); }
.row .grip { width: 18px; height: 26px; display: grid; place-items: center; color: var(--muted); opacity: 0; cursor: grab; touch-action: none; flex: none; }
.row:hover .grip, .row .grip:focus-visible { opacity: .8; }
@media (pointer: coarse) { .row .grip { opacity: .55; } }
.row .grip svg { width: 14px; height: 14px; }
.row .r-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.row .r-count { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .r-more { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); opacity: 0; flex: none; }
.row:hover .r-more, .row .r-more:focus-visible, .row.active .r-more { opacity: 1; }
@media (pointer: coarse) { .row .r-more { opacity: .7; } }
.row .r-more:hover { background: var(--line-soft); color: var(--text); }
.row .r-more svg { width: 16px; height: 16px; }
.chapter-row .r-title { font-weight: 600; font-size: 13.5px; }
.chapter-row .caret { width: 18px; height: 18px; display: grid; place-items: center; color: var(--muted); transition: transform .2s var(--ease); flex: none; }
.chapter-row .caret svg { width: 14px; height: 14px; }
.chapter.closed .caret { transform: rotate(-90deg); }
.chapter.closed .scenes { display: none; }
.scenes { padding-left: 14px; position: relative; }
.scenes::before { content: ''; position: absolute; left: 13px; top: 2px; bottom: 6px; width: 1px; background: var(--line-soft); }
.scene-row .r-title { color: var(--text-2); }
.scene-row.active { background: var(--accent-soft); }
.scene-row.active .r-title { color: var(--text); font-weight: 500; }
.scene-row.active::before { content: ''; position: absolute; left: -2px; top: 9px; bottom: 9px; width: 2px; border-radius: 2px; background: var(--accent); }
.scene-row.conflict .r-title::after { content: 'conflict'; margin-left: 6px; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--warn); }
.add-scene { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px 0 26px; font-size: 13px; color: var(--muted); border-radius: 8px; width: 100%; }
.add-scene:hover { color: var(--accent); background: var(--surface-2); }
.add-scene svg { width: 14px; height: 14px; }
.row input.rename { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--accent); border-radius: 6px; padding: 4px 8px; font-size: 14px; outline: none; }
.row.dragging { opacity: .35; }
.drop-line { position: absolute; left: 8px; right: 8px; height: 2px; background: var(--accent); border-radius: 2px; pointer-events: none; z-index: 5; box-shadow: 0 0 0 3px var(--accent-soft); }
.drop-into { box-shadow: inset 0 0 0 1.5px var(--accent); }
.binder-foot { border-top: 1px solid var(--line-soft); padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 10px; }
.binder-foot .totals { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.binder-foot .totals b { color: var(--text); font-weight: 600; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; background: var(--page); }
.topbar {
  display: flex; align-items: center; gap: 4px; height: calc(56px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(10px, env(safe-area-inset-left, 0px)); padding-right: max(10px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line-soft); background: color-mix(in srgb, var(--page) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  transition: opacity .5s var(--ease), transform .5s var(--ease); z-index: 3;
}
.crumbs { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; padding: 0 8px; overflow: hidden; }
.crumbs .c1 { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; }
.crumbs .sep { color: var(--line); }
.crumbs .c2 { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fmt { display: flex; align-items: center; gap: 2px; padding: 0 6px; margin: 0 4px; border-left: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); }
.fmt .icon-btn { width: 34px; height: 34px; }
.fmt .icon-btn b, .fmt .icon-btn i { font-family: var(--font-display); font-size: 19px; line-height: 1; }
.fmt .icon-btn b { font-family: var(--font-ui); font-weight: 800; font-size: 15px; }
.fmt .icon-btn i { font-size: 21px; }
.fmt .icon-btn .h { font-family: var(--font-display); font-size: 20px; }
.fmt .icon-btn .ast { font-family: var(--font-display); font-size: 20px; line-height: 1; transform: translateY(2px); }

.scroller { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative; scroll-behavior: auto; }
.page {
  max-width: calc(var(--measure) + 64px); margin: 0 auto; min-height: 100%;
  padding-left: max(32px, env(safe-area-inset-left, 0px)); padding-right: max(32px, env(safe-area-inset-right, 0px));
  padding-block: clamp(36px, 9vh, 96px) 55vh;
}
.scene-kicker { font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; display: flex; gap: 10px; align-items: center; }
.scene-kicker .k-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.scene-title {
  width: 100%; background: none; border: 0; outline: none; padding: 0; margin: 0 0 28px; color: var(--text);
  font-family: var(--font-display); font-size: clamp(32px, 4.4vw, 46px); line-height: 1.08; letter-spacing: -.015em;
}
.scene-title::placeholder { color: var(--muted); }
.editor, .md-editor {
  font-family: var(--ed-font); font-size: var(--ed-size); line-height: var(--ed-lh); color: var(--text);
  outline: none; caret-color: var(--accent); min-height: 40vh; overflow-wrap: break-word;
  font-optical-sizing: auto; hanging-punctuation: first; font-kerning: normal;
}
.editor p { margin: 0 0 .9em; }
.editor.indent p { margin: 0; }
.editor.indent p + p { text-indent: 1.6em; }
.editor h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.55em; line-height: 1.2; margin: 1.3em 0 .5em; }
.editor h3 { font-family: var(--font-ui); font-weight: 700; font-size: .78em; letter-spacing: .14em; text-transform: uppercase; margin: 1.8em 0 .6em; color: var(--text-2); }
.editor blockquote { margin: 1.2em 0; padding: .1em 0 .1em 1.2em; border-left: 2px solid var(--accent); color: var(--text-2); font-style: italic; }
.editor blockquote p { margin: 0; }
.editor hr { border: 0; height: auto; margin: 1.6em 0; text-align: center; }
.editor hr::after { content: '⁂'; color: var(--muted); font-size: 1.1em; letter-spacing: .3em; }
.editor ul, .editor ol { margin: 0 0 .9em; padding-left: 1.4em; }
.editor strong { font-weight: 650; }
.editor:empty::before { content: attr(data-placeholder); color: var(--muted); font-style: italic; }
.md-editor { width: 100%; border: 0; background: none; resize: none; display: block; overflow: hidden; font-family: var(--font-mono); font-size: calc(var(--ed-size) * .86); }

.statusbar {
  position: absolute; right: max(14px, env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 3;
  display: flex; align-items: center; gap: 12px; padding: 7px 14px; border-radius: 999px; font-size: 12.5px; color: var(--text-2);
  background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line-soft);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: opacity .5s var(--ease);
}
.statusbar b { color: var(--text); font-weight: 600; }
.statusbar .saved { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.statusbar .saved .dot { width: 6px; height: 6px; box-shadow: none; }
.statusbar .saved.pending .dot { background: var(--muted); }

/* Focus mode */
body.focus .binder { transform: translateX(-100%); opacity: 0; pointer-events: none; position: absolute; inset: 0 auto 0 0; width: var(--binder-w); z-index: 10; }
body.focus #workspace { grid-template-columns: 0 minmax(0, 1fr); }
body.focus.typing .topbar { opacity: 0; transform: translateY(-8px); pointer-events: none; }
body.focus.typing .statusbar { opacity: 0; }
body.focus .fmt { display: none; }

/* Mobile workspace */
.only-narrow { display: none !important; }
@media (max-width: 860px) {
  #workspace { grid-template-columns: minmax(0, 1fr); }
  .binder { position: fixed; inset: 0 auto 0 0; width: min(86vw, 340px); z-index: 20; transform: translateX(-102%); }
  body.binder-open .binder { transform: none; box-shadow: var(--shadow-lg); }
  body.binder-open .drawer-scrim { opacity: 1; pointer-events: auto; }
  .only-narrow { display: inline-grid !important; }
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--page); }
  .fmt { position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 4; border: 0; margin: 0; padding: 4px;
    border-radius: 14px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line-soft); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
  .statusbar { bottom: auto; top: calc(66px + env(safe-area-inset-top, 0px)); right: max(10px, env(safe-area-inset-right, 0px)); padding: 5px 11px; font-size: 11.5px; }
  .statusbar .proj-total { display: none; }
  .page { padding-left: max(22px, env(safe-area-inset-left, 0px)); padding-right: max(22px, env(safe-area-inset-right, 0px)); padding-top: 64px; }
  .hide-narrow { display: none !important; }
}
.drawer-scrim { position: fixed; inset: 0; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .3s var(--ease); z-index: 15; }

/* ---------- Popovers ---------- */
.pop {
  position: fixed; z-index: 60; min-width: 200px; max-width: calc(100vw - 24px); padding: 6px; border-radius: 13px;
  background: var(--raise); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line-soft);
  animation: pop .18s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.pop .mi { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border-radius: 8px; font-size: 14px; text-align: left; color: var(--text); }
.pop .mi:hover { background: var(--surface-2); }
.pop .mi svg { width: 16px; height: 16px; color: var(--text-2); }
.pop .mi.danger, .pop .mi.danger svg { color: var(--danger); }
.pop hr { border: 0; border-top: 1px solid var(--line-soft); margin: 6px 4px; }

.type-panel { width: 320px; padding: 16px; display: flex; flex-direction: column; gap: 18px; }
.type-panel h4, .field-label { margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.font-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.font-opt { padding: 10px 10px 8px; border-radius: 10px; text-align: left; box-shadow: inset 0 0 0 1px var(--line-soft); background: var(--surface); }
.font-opt span { display: block; font-size: 22px; line-height: 1; }
.font-opt small { display: block; font-size: 11px; color: var(--muted); margin-top: 6px; font-family: var(--font-ui); }
.font-opt.on { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-soft); }
.slider-row { display: grid; grid-template-columns: 82px 1fr 40px; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
.slider-row output { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-size: 12.5px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) var(--p, 50%), var(--line) var(--p, 50%)); }
input[type=range]::-moz-range-track { height: 3px; border-radius: 3px; background: var(--line); }
input[type=range]::-moz-range-progress { height: 3px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; margin-top: -7.5px; background: var(--raise); box-shadow: 0 1px 4px rgba(0, 0, 0, .3), inset 0 0 0 1.5px var(--accent); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--accent); background: var(--raise); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 0; }
.toggle-row .t-text { min-width: 0; }
.toggle-row .t-text b { display: block; font-weight: 500; font-size: 14px; }
.toggle-row .t-text span { font-size: 12.5px; color: var(--muted); }
.switch { position: relative; width: 40px; height: 24px; border-radius: 999px; background: var(--line); flex: none; transition: background .2s var(--ease); }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .25s var(--ease); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }

.seg { display: flex; padding: 3px; border-radius: 11px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); gap: 2px; }
.seg button { flex: 1; height: 32px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); transition: background .2s var(--ease), color .2s var(--ease); }
.seg button.on { background: var(--raise); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: var(--scrim); animation: fade .25s var(--ease);
  padding-top: max(20px, env(safe-area-inset-top, 0px)); padding-bottom: max(20px, env(safe-area-inset-bottom, 0px)); }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: min(560px, 100%); max-height: min(88vh, 820px); display: flex; flex-direction: column; border-radius: 22px; overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line-soft); animation: rise .35s var(--ease);
}
.sheet.wide { width: min(720px, 100%); }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.985); } }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 22px 6px; }
.sheet-head h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1.05; letter-spacing: -.01em; }
.sheet-head p { margin: 6px 0 0; color: var(--text-2); font-size: 13.5px; max-width: 46ch; }
.sheet-body { padding: 16px 22px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px calc(16px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
@media (max-width: 600px) {
  .sheet-wrap { place-items: end stretch; padding: 0; padding-top: env(safe-area-inset-top, 0px); }
  .sheet { width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; animation: slideup .4s var(--ease); }
  .sheet-head { padding-top: 14px; }
  .sheet-head::before { content: ''; position: absolute; left: 50%; transform: translateX(-50%); margin-top: -8px; width: 38px; height: 4px; border-radius: 4px; background: var(--line); }
  .sheet-foot .btn { flex: 1; }
}
@keyframes slideup { from { transform: translateY(100%); } }

.group { display: flex; flex-direction: column; gap: 10px; }
.group-title { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.card { border-radius: var(--radius); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); padding: 14px 16px; }
.card-list { border-radius: var(--radius); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.card-list > * + * { border-top: 1px solid var(--line-soft); }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 54px; }
.li .li-text { flex: 1; min-width: 0; }
.li .li-text b { display: block; font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .li-text span { display: block; font-size: 12.5px; color: var(--muted); }
.li .li-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface); color: var(--text-2); flex: none; box-shadow: inset 0 0 0 1px var(--line-soft); }
.empty-note { font-size: 13px; color: var(--muted); padding: 14px; text-align: center; }
.field { display: flex; flex-direction: column; gap: 6px; }
.input {
  height: 44px; border-radius: 11px; border: 0; padding: 0 14px; background: var(--surface-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line); outline: none; width: 100%; font-size: 15px; transition: box-shadow .2s var(--ease);
}
.input:focus { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-soft); }
textarea.input { height: auto; min-height: 92px; padding: 12px 14px; resize: vertical; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; word-break: break-all; }
.cover-picks { display: flex; gap: 10px; flex-wrap: wrap; }
.cover-pick { width: 38px; height: 54px; border-radius: 3px 6px 6px 3px; background: var(--cbg); box-shadow: inset 4px 0 0 rgba(0, 0, 0, .25); position: relative; }
.cover-pick.on { outline: 2px solid var(--accent); outline-offset: 3px; }

.formats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fmt-card { text-align: left; padding: 14px; border-radius: var(--radius); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); display: flex; flex-direction: column; gap: 4px; transition: box-shadow .2s var(--ease), background .2s var(--ease); }
.fmt-card .ext { font-family: var(--font-mono); font-size: 11px; color: var(--accent); letter-spacing: .04em; }
.fmt-card b { font-weight: 600; font-size: 15px; }
.fmt-card span { font-size: 12.5px; color: var(--muted); }
.fmt-card.on { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-soft); }

/* Sync */
.sync-big { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 8px 0; }
.code-display { font-family: var(--font-mono); font-size: clamp(30px, 8vw, 42px); font-weight: 500; letter-spacing: .14em; padding: 14px 22px; border-radius: 16px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.code-input { text-align: center; font-family: var(--font-mono); font-size: 22px; letter-spacing: .22em; text-transform: uppercase; height: 56px; }
.qr { background: #fff; padding: 12px; border-radius: 14px; width: min(280px, 100%); aspect-ratio: 1; box-shadow: var(--shadow-sm); }
.qr svg { width: 100%; height: 100%; display: block; }
.scan-box { position: relative; width: min(320px, 100%); aspect-ratio: 1; border-radius: 18px; overflow: hidden; background: #000; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; }
.scan-box::after { content: ''; position: absolute; inset: 14%; border: 2px solid rgba(255, 255, 255, .85); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
.status-line { display: flex; align-items: center; gap: 10px; justify-content: center; color: var(--text-2); font-size: 14px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.done-mark { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.done-mark svg { width: 30px; height: 30px; stroke-width: 2; }
.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; counter-reset: s; }
.steps li { display: flex; gap: 12px; font-size: 14px; color: var(--text-2); align-items: flex-start; }
.steps li::before { counter-increment: s; content: counter(s); width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.split2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .split2, .formats { grid-template-columns: 1fr; } }
.choice { text-align: left; padding: 16px; border-radius: var(--radius); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); display: flex; flex-direction: column; gap: 6px; transition: box-shadow .2s var(--ease); }
.choice:hover { box-shadow: inset 0 0 0 1.5px var(--accent); }
.choice .ci { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.choice b { font-weight: 600; font-size: 15px; }
.choice span { font-size: 12.5px; color: var(--muted); }
.note { font-size: 12.5px; color: var(--muted); text-align: center; }

/* Toasts */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(460px, calc(100vw - 32px)); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 11px 12px 11px 16px; border-radius: 14px; background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow-lg); animation: rise .35s var(--ease); max-width: 100%; }
.toast span { flex: 1; min-width: 0; }
.toast button { color: var(--accent); font-weight: 700; font-size: 13.5px; padding: 6px 8px; border-radius: 8px; filter: brightness(.85); }
:root[data-theme="dark"] .toast button { filter: none; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: all .3s var(--ease); }

/* Splash */
#splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); transition: opacity .5s var(--ease); }
#splash.gone { opacity: 0; pointer-events: none; }
#splash .brand-mark { width: 54px; height: 54px; animation: breathe 1.6s var(--ease) infinite; }
@keyframes breathe { 50% { transform: scale(.94); opacity: .7; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 600px) {
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 16px; }
  .cover { padding: 16px 12px 14px 20px; }
  .cover .c-title { font-size: 20px; }
  .lib-hero { margin: 36px 0 24px; }
}

/* ======================================================================
   Phase 2 — board, outline, goals, sprints, sound, stats
   ====================================================================== */
:root {
  --st-idea: #8a8f9c; --st-draft: #b5801f; --st-revised: #4a7bc2; --st-final: #2a7865;
  --dimmed: color-mix(in srgb, var(--text) 28%, var(--page));
  --heat-0: #e3e5df;
  --cork: #e8eae4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --st-idea: #8d93a3; --st-draft: #e2b061; --st-revised: #8fb0ea; --st-final: #86cdb9; --heat-0: #1c2230; --cork: #0f131b; }
}
:root[data-theme="dark"] { --st-idea: #8d93a3; --st-draft: #e2b061; --st-revised: #8fb0ea; --st-final: #86cdb9; --heat-0: #1c2230; --cork: #0f131b; }
.theme-fade, .theme-fade *, .theme-fade *::before, .theme-fade *::after { transition: background-color .45s var(--ease), color .45s var(--ease), border-color .45s var(--ease), fill .45s var(--ease), box-shadow .45s var(--ease) !important; }

/* status + labels */
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em; white-space: nowrap;
  color: var(--st); background: color-mix(in srgb, var(--st) 13%, transparent); }
.st-idea { --st: var(--st-idea); } .st-draft { --st: var(--st-draft); } .st-revised { --st: var(--st-revised); } .st-final { --st: var(--st-final); }
.st-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st); flex: none; display: inline-block; }
.st-idea.st-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--st); }
.lbl-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--lbl); flex: none; display: inline-block; transform: rotate(45deg); }
.lbl-pop { display: flex; gap: 8px; padding: 4px; flex-wrap: wrap; }
.lbl-sw { width: 30px; height: 30px; border-radius: 50%; background: var(--lbl); display: grid; place-items: center; color: var(--muted); transition: transform .15s var(--ease); }
.lbl-sw:hover { transform: scale(1.08); }
.lbl-sw.none { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.lbl-sw.none svg { width: 14px; height: 14px; }
.lbl-sw.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.seg button .st-dot { margin-right: 6px; vertical-align: 1px; }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

/* binder additions */
.bh-top { display: flex; justify-content: space-between; align-items: center; }
.bh-top .icon-btn { width: 34px; height: 34px; }
.scene-row .st-dot { margin-left: 2px; }
.scene-row .lbl-dot { margin: 0 4px; }
.goal-strip { display: flex; align-items: center; gap: 12px; padding: 10px; margin: -2px -4px 0; border-radius: 12px; text-align: left; transition: background .2s var(--ease); }
.goal-strip:hover { background: var(--surface-2); }
.gs-text { display: flex; flex-direction: column; min-width: 0; }
.gs-text b { font-size: 15px; font-weight: 700; }
.gs-text b small { font-size: 12px; color: var(--muted); font-weight: 500; }
.gs-text > span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring { flex: none; display: block; }
.ring .ring-bg { stroke: var(--line); }
.ring .ring-fg { stroke: var(--accent); transition: stroke-dashoffset .8s var(--ease); }
.ring .ring-check { stroke: var(--accent); }
.target-strip { display: flex; flex-direction: column; gap: 6px; }
.ts-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); gap: 8px; }
.bar { height: 4px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .8s var(--ease); }

/* library today row */
.today-row { display: inline-flex; align-items: center; gap: 12px; margin-top: 16px; padding: 7px 16px 7px 8px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft); font-size: 13.5px; color: var(--text-2); flex-wrap: wrap; transition: box-shadow .2s var(--ease); }
.today-row:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.today-row b { color: var(--text); }
.streak { display: inline-flex; align-items: center; gap: 5px; color: var(--st-draft); font-weight: 600; }
.streak svg { width: 15px; height: 15px; }

/* cover art */
.cover.has-img { background-size: cover; background-position: center; padding: 0; }
.cover.has-img::after { background: linear-gradient(105deg, rgba(255, 255, 255, .12), transparent 30%), linear-gradient(180deg, transparent 70%, rgba(0, 0, 0, .18)); }
.cover-edit { display: flex; gap: 16px; align-items: flex-start; }
.cover-thumb { width: 84px; aspect-ratio: 2 / 3; border-radius: 3px 8px 8px 3px; flex: none; box-shadow: var(--shadow-sm), inset 5px 0 0 rgba(0, 0, 0, .22); display: flex; align-items: flex-end; padding: 8px 8px 8px 12px; font-family: var(--font-display); font-size: 13px; line-height: 1.05; overflow: hidden; background-size: cover; }
.cover-edit-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
textarea.input.prose { font-family: var(--font-ui); font-size: 14.5px; word-break: normal; line-height: 1.5; }
.pd-sum-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pd-sum-label small { font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--muted); }
textarea.input.pd-summary { font-family: var(--ed-font); font-size: 16px; line-height: 1.6; min-height: 110px; max-height: 320px; }

/* topbar views */
.view-seg { flex: none; margin-right: 4px; }
.view-seg button { height: 30px; padding: 0 12px; font-size: 12.5px; }
.view-seg button svg { width: 15px; height: 15px; }
body:not([data-view="write"]) .fmt, body:not([data-view="write"]) [data-act="type"], body:not([data-view="write"]) [data-act="focus"] { display: none !important; }
body:not([data-view="write"]) .statusbar .sb-words, body:not([data-view="write"]) .statusbar .proj-total, body:not([data-view="write"]) .statusbar .saved { display: none; }
body:not([data-view="write"]) .statusbar:not(:has(.sprint-pill:not([hidden]))) { display: none; }
@media (max-width: 1100px) { .crumbs .c1, .crumbs .sep { display: none; } }
@media (max-width: 860px) {
  .crumbs { display: none; }
  .view-seg { margin-right: auto; }
  .view-seg button span { display: none; }
  .view-seg button { padding: 0 11px; }
}
.view-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; min-height: 0; }

/* editor kicker extras */
.scene-kicker { flex-wrap: wrap; row-gap: 8px; }
.k-spacer { flex: 1; }
.k-pill { cursor: pointer; letter-spacing: .04em; text-transform: none; }
.k-pill:hover { filter: brightness(.95); }
.k-pov { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 500; color: var(--text-2); }
.k-more { width: 26px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); }
.k-more:hover { background: var(--surface-2); color: var(--text); }
.k-more svg { width: 16px; height: 16px; }

/* focus dimming */
.editor.dim:focus > * { color: var(--dimmed); transition: color .35s var(--ease); }
.editor.dim:focus > .cur { color: var(--text); }
.editor.dim.dim-s:focus > .cur { color: var(--dimmed); }
::highlight(ink-sentence) { color: var(--text); }
.editor.dim:focus blockquote { border-color: var(--line); }

/* ---------- Corkboard ---------- */
#boardView { background: var(--cork); background-image: radial-gradient(color-mix(in srgb, var(--text) 9%, transparent) 1px, transparent 1.2px); background-size: 18px 18px; }
.board { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 40px;
  padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); padding-block: 36px 120px; }
.b-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.b-title { min-width: 0; }
.b-head h3 { margin: 4px 0 0; font-family: var(--font-display); font-weight: 400; font-size: 28px; line-height: 1.1; letter-spacing: -.01em; }
.b-count { font-size: 12.5px; color: var(--muted); }
.b-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 18px; min-height: 60px; }
.card-ix {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 14px; border-radius: 6px; cursor: pointer; min-height: 172px; min-width: 0;
  background: var(--raise);
  background-image: linear-gradient(var(--raise) 52px, transparent 52px), repeating-linear-gradient(180deg, transparent 0 23px, color-mix(in srgb, var(--st-revised) 13%, transparent) 23px 24px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 10px 24px -14px rgba(0, 0, 0, .35), inset 0 3px 0 var(--lbl, transparent);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.card-ix:hover { transform: translateY(-3px) rotate(-.25deg); box-shadow: 0 2px 4px rgba(0, 0, 0, .06), 0 18px 34px -16px rgba(0, 0, 0, .4), inset 0 3px 0 var(--lbl, transparent); }
.card-ix:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cx-top { display: flex; align-items: center; gap: 8px; }
.cx-grip { width: 20px; height: 24px; margin-left: -6px; display: grid; place-items: center; color: var(--muted); cursor: grab; touch-action: none; opacity: .55; }
.cx-grip svg { width: 14px; height: 14px; }
.card-ix:hover .cx-grip { opacity: 1; }
.cx-num { font-family: var(--font-mono); font-size: 11px; color: var(--muted); flex: 1; }
.card-ix h4 { margin: 2px 0 0; font-family: var(--font-display); font-weight: 400; font-size: 21px; line-height: 1.15; overflow-wrap: anywhere; }
.cx-syn { margin: 0; flex: 1; font-family: var(--ed-font); font-size: 14px; line-height: 24px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.cx-syn.empty { color: var(--muted); font-style: italic; }
.card-ix footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.cx-pov { display: inline-flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-pov svg { width: 12px; height: 12px; }
.cx-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 0 0 6px 6px; overflow: hidden; background: var(--line-soft); }
.cx-bar i { display: block; height: 100%; background: var(--accent); }
.card-ix.conflict::after { content: 'Conflicted copy'; position: absolute; top: -9px; right: 12px; font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; background: var(--warn); color: var(--raise); }
.b-add { min-height: 172px; border-radius: 6px; border: 1.5px dashed var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; transition: border-color .2s var(--ease), color .2s var(--ease); }
.b-add:hover { border-color: var(--accent); color: var(--accent); }
.b-add svg { width: 20px; height: 20px; }
.b-newch { align-self: flex-start; }
.cx-ghost { position: fixed; z-index: 70; pointer-events: none; margin: 0; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5), inset 0 3px 0 var(--lbl, transparent) !important; transition: none; opacity: .96; }
.cx-ph { border-radius: 6px; border: 2px dashed var(--accent); background: var(--accent-soft); }
@media (max-width: 600px) { .b-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } .card-ix, .b-add { min-height: 150px; } .card-ix h4 { font-size: 18px; } .board { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); } }

/* ---------- Outline ---------- */
.outline-wrap { padding: 28px max(24px, env(safe-area-inset-right, 0px)) 120px max(24px, env(safe-area-inset-left, 0px)); overflow-x: auto; }
.outline { width: 100%; min-width: 900px; border-collapse: separate; border-spacing: 0; font-size: 13.5px; max-width: 1320px; margin: 0 auto; }
.outline th { position: sticky; top: 0; z-index: 1; background: var(--page); text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--line); }
.outline td { padding: 4px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.outline tbody tr:not(.o-ch):hover td { background: var(--surface-2); }
.o-ch td { padding: 22px 8px 8px; border-bottom: 1px solid var(--line); }
.o-ch div { display: flex; align-items: baseline; gap: 12px; }
.o-ch b { font-family: var(--font-display); font-weight: 400; font-size: 21px; flex: 1; }
.o-ch .tnum { font-size: 12px; color: var(--muted); }
.o-n { width: 36px; color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
.o-c { width: 44px; text-align: center; }
.o-w { width: 96px; text-align: right; }
.o-t { width: 92px; }
.o-syn { min-width: 260px; }
.o-in { width: 100%; height: 34px; border: 0; background: transparent; padding: 0 8px; border-radius: 7px; outline: none; color: var(--text); font-size: 13.5px; }
.o-in:hover { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft); }
.o-in:focus { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--accent); }
.o-in::placeholder { color: var(--muted); }
.o-title { font-weight: 600; min-width: 180px; }
.o-t .o-in { text-align: right; }
.o-sel { position: relative; display: inline-flex; }
.o-sel select { appearance: none; -webkit-appearance: none; border: 0; height: 26px; padding: 0 24px 0 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; color: var(--st); background: color-mix(in srgb, var(--st) 13%, transparent); cursor: pointer; outline: none; }
.o-sel::after { content: ''; position: absolute; right: 10px; top: 10px; width: 5px; height: 5px; border-right: 1.5px solid var(--st); border-bottom: 1.5px solid var(--st); transform: rotate(45deg); pointer-events: none; }
.o-sel select:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.o-dot { width: 18px; height: 18px; border-radius: 5px; background: var(--lbl, transparent); box-shadow: inset 0 0 0 1.5px var(--lbl, var(--line)); transform: rotate(45deg) scale(.8); }
.o-bar { height: 3px; border-radius: 3px; background: var(--line-soft); margin-top: 4px; overflow: hidden; }
.o-bar i { display: block; height: 100%; background: var(--accent); }
.outline .icon-btn { width: 32px; height: 32px; }
.outline .icon-btn svg { width: 16px; height: 16px; }

/* ---------- Sprint ---------- */
.sprint-pill { display: inline-flex; align-items: center; gap: 8px; height: 26px; padding: 0 10px 0 4px; margin-left: -8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; }
.sprint-pill b { font-weight: 700; color: var(--text); }
.sprint-pill.break { background: color-mix(in srgb, var(--st-draft) 14%, transparent); color: var(--st-draft); }
.sprint-pill.break .ring-fg { stroke: var(--st-draft); }
.sp-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.sprint-panel { gap: 16px; }
.dur-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.dur { display: flex; flex-direction: column; align-items: center; padding: 10px 0 8px; border-radius: 10px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft); }
.dur b { font-size: 18px; font-weight: 700; line-height: 1; }
.dur small { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.dur.on { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-soft); color: var(--accent); }
.dur.on small { color: var(--accent); }
.sprint-result { display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; padding: 6px 0 4px; }
.sr-big { font-family: var(--font-display); font-size: 84px; line-height: .9; display: flex; flex-direction: column; align-items: center; }
.sr-big small { font-family: var(--font-ui); font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-top: 10px; }
.sr-row { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; border-radius: var(--radius); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.sr-row div { display: flex; flex-direction: column; padding: 14px 6px; gap: 2px; }
.sr-row div + div { border-left: 1px solid var(--line-soft); }
.sr-row b { font-size: 20px; font-weight: 700; }
.sr-row span { font-size: 11.5px; color: var(--muted); }

/* ---------- Sound ---------- */
.snd-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-height: min(52vh, 360px); overflow-y: auto; padding: 2px; margin: -2px; }
.snd { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft); font-weight: 600; font-size: 13.5px; transition: box-shadow .2s var(--ease), background .2s var(--ease); }
.snd svg { width: 20px; height: 20px; color: var(--text-2); }
.snd.on { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); }
.snd.on svg { color: var(--accent); animation: breathe 2.4s var(--ease) infinite; }
.snd.loading { opacity: .7; }
.snd.loading svg { animation-duration: 1s; }
.snd span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slider-row span svg { width: 16px; height: 16px; }

/* ---------- Celebration ---------- */
.celebrate { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 14px; pointer-events: none; text-align: center; animation: fade .3s var(--ease); }
.celebrate.small { top: auto; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); flex-direction: row; gap: 12px; padding: 10px 18px 10px 10px; border-radius: 999px; background: var(--raise); box-shadow: var(--shadow-lg); text-align: left; }
.celebrate.out { opacity: 0; transform: translate(-50%, -8px); transition: all .6s var(--ease); }
.cb-burst { position: relative; width: 96px; height: 96px; display: grid; place-items: center; }
.celebrate.small .cb-burst { width: 40px; height: 40px; }
.cb-burst i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: bloom 1.6s var(--ease) forwards; }
.cb-burst i:nth-child(2) { animation-delay: .18s; } .cb-burst i:nth-child(3) { animation-delay: .36s; }
@keyframes bloom { 0% { transform: scale(.3); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } }
.cb-check { width: 58%; height: 58%; border-radius: 50%; background: var(--accent); stroke: var(--accent-ink); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; padding: 14%; animation: pop .5s var(--ease); box-shadow: 0 10px 30px -8px color-mix(in srgb, var(--accent) 60%, transparent); }
.cb-check path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw .5s .2s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.cb-text { display: flex; flex-direction: column; gap: 4px; }
.cb-text b { font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1; }
.cb-text span { font-size: 13.5px; color: var(--text-2); }
.celebrate:not(.small) .cb-text { padding: 12px 20px; border-radius: 16px; background: color-mix(in srgb, var(--raise) 92%, transparent); box-shadow: var(--shadow-lg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.celebrate.small .cb-text b { font-size: 18px; }

/* ---------- Stats ---------- */
.sheet.xwide { width: min(940px, 100%); }
.tiles { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: var(--radius); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); min-width: 0; }
.tile-today { flex-direction: row; align-items: center; gap: 18px; }
.tt-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ts-when { font-size: 11.5px; color: var(--muted); }
.sr-badge { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: -6px; }
.sr-badge .cb-burst { width: 64px; height: 64px; }
.sr-badge b { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.t-label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.t-label svg { width: 14px; height: 14px; }
.tile b { font-family: var(--font-display); font-weight: 400; font-size: 38px; line-height: 1.05; }
.tile b small { font-family: var(--font-ui); font-size: 12.5px; color: var(--muted); }
.t-sub { font-size: 12px; color: var(--muted); }
.goal-edit { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 2px; flex-wrap: wrap; }
.goal-edit input { width: 68px; height: 26px; border: 0; border-radius: 7px; padding: 0 6px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--text); font-size: 12.5px; outline: none; }
.goal-edit input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
@media (max-width: 760px) { .tiles { grid-template-columns: 1fr 1fr; } .tile-today { grid-column: 1 / -1; } }
.heat-wrap { display: flex; gap: 8px; }
.heat-days { display: grid; grid-template-rows: 16px repeat(7, 13px); row-gap: 3px; font-size: 10px; color: var(--muted); flex: none; }
.heat-days span { line-height: 13px; }
.heat-scroll { overflow-x: auto; min-width: 0; padding-bottom: 4px; }
.heat-months { display: grid; grid-template-columns: repeat(26, 13px); column-gap: 3px; height: 16px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.heat { display: grid; grid-template-columns: repeat(26, 13px); grid-template-rows: repeat(7, 13px); gap: 3px; }
.heat i, .heat-legend i { width: 13px; height: 13px; border-radius: 3px; display: block; background: var(--heat-0); }
.heat i.fut { background: transparent; }
.heat .l1, .heat-legend .l1 { background: color-mix(in srgb, var(--accent) 25%, var(--heat-0)); }
.heat .l2, .heat-legend .l2 { background: color-mix(in srgb, var(--accent) 50%, var(--heat-0)); }
.heat .l3, .heat-legend .l3 { background: color-mix(in srgb, var(--accent) 75%, var(--heat-0)); }
.heat .l4, .heat-legend .l4 { background: var(--accent); }
.heat-legend { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.heat-legend span:first-child { margin-right: 4px; } .heat-legend span:last-child { margin-left: 4px; }
.hours-card { display: flex; flex-direction: column; gap: 10px; }
.hours-lead { margin: 0; font-size: 14px; color: var(--text-2); }
.hours-lead b { color: var(--text); }
.hours { display: flex; flex-direction: column; gap: 6px; }
.hours-bars { display: grid; grid-template-columns: repeat(24, 1fr); gap: 4px; height: 120px; align-items: end; border-bottom: 1px solid var(--line); }
.hb { height: 100%; display: flex; align-items: flex-end; }
.hb i { display: block; width: 100%; border-radius: 4px 4px 1px 1px; background: var(--line); min-height: 2px; transition: height .8s var(--ease); }
.hb.has i { background: color-mix(in srgb, var(--accent) 45%, var(--surface-2)); }
.hb.peak i { background: var(--accent); }
.hours-axis { position: relative; height: 14px; font-size: 10.5px; color: var(--muted); }
.hours-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.plan-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px; }
.plan-cover { width: 34px; height: 50px; border-radius: 2px 5px 5px 2px; box-shadow: inset 3px 0 0 rgba(0, 0, 0, .25); }
.plan-main { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.plan-top { display: flex; justify-content: space-between; gap: 10px; }
.plan-top b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-top span { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.plan-line { font-size: 12.5px; color: var(--muted); }
.plan-line .ok { color: var(--accent); font-weight: 600; }
.plan-line .late { color: var(--st-draft); font-weight: 600; }
.plan-inputs { display: flex; gap: 8px; }
.plan-inputs label { display: flex; flex-direction: column; gap: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.plan-inputs .input { height: 34px; font-size: 13px; width: 116px; padding: 0 10px; }
.plan-inputs label:last-child .input { width: 148px; }
@media (max-width: 760px) { .plan-row { grid-template-columns: 34px minmax(0, 1fr); } .plan-inputs { grid-column: 1 / -1; } .plan-inputs label { flex: 1; } .plan-inputs .input, .plan-inputs label:last-child .input { width: 100%; } }

/* ======================================================================
   Phase 3 — story bible, relationships, revision tools
   ====================================================================== */
.view-fill { flex: 1; min-height: 0; overflow: hidden; display: flex; }
.av { display: inline-grid; place-items: center; flex: none; border-radius: 50%; background-size: cover; background-position: center; color: #fff; font-weight: 700; letter-spacing: .02em; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); overflow: hidden; }
.av.sq { border-radius: 28%; }
.av svg { width: 46%; height: 46%; stroke: #fff; }
.av.big { box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(0, 0, 0, .08); }

/* Bible */
.bible { flex: 1; display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 0; width: 100%; }
.bible.is-map { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
.bible.is-map .bb-side { border-right: 0; border-bottom: 1px solid var(--line-soft); padding: 12px max(16px, env(safe-area-inset-left, 0px)); }
.bible.is-map .bb-tabs { max-width: 560px; flex-wrap: nowrap; }
.bible.is-map .bb-tabs button { flex: 1; }
.seg button { white-space: nowrap; padding: 0 12px; }
body:not([data-view="write"]) [data-act="panel"] { display: none; }
.bb-side { border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 12px; padding: 16px 12px calc(16px + env(safe-area-inset-bottom, 0px)); min-height: 0; background: var(--bg-2); }
.bible.is-map .bb-side { padding-bottom: 16px; }
.bb-tabs { flex-wrap: wrap; }
.bb-tabs button { flex: 1 1 40%; font-size: 12.5px; }
.bb-search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-radius: 10px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft); color: var(--muted); }
.bb-search svg { width: 16px; height: 16px; }
.bb-search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); font-size: 14px; }
.bb-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.bb-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; text-align: left; transition: background .15s var(--ease); }
.bb-item:hover { background: var(--surface-2); }
.bb-item.on { background: var(--accent-soft); }
.bi-text { min-width: 0; display: flex; flex-direction: column; }
.bi-text b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bi-text span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bb-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 36px 12px; color: var(--muted); font-size: 13px; }
.bb-empty svg { width: 28px; height: 28px; color: var(--accent); }
.bb-empty b { color: var(--text); font-size: 14px; }
.bb-new { align-self: stretch; }
.bb-main { min-width: 0; min-height: 0; overflow-y: auto; position: relative; }
.bible.is-map .bb-main { overflow: hidden; }
.bd { max-width: 760px; margin: 0 auto; padding: 36px max(28px, env(safe-area-inset-right, 0px)) 120px max(28px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 22px; }
.bd-head { display: flex; gap: 20px; align-items: flex-start; }
.bd-photo { position: relative; border-radius: 50%; flex: none; }
.bd-cam { position: absolute; right: 2px; bottom: 2px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--raise); color: var(--text); box-shadow: var(--shadow-sm); opacity: 0; transition: opacity .2s var(--ease); }
.bd-cam svg { width: 15px; height: 15px; }
.bd-photo:hover .bd-cam, .bd-photo:focus-visible .bd-cam { opacity: 1; }
@media (pointer: coarse) { .bd-cam { opacity: 1; } }
.bd-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.bd-name { border: 0; background: none; outline: none; padding: 0; color: var(--text); font-family: var(--font-display); font-size: clamp(32px, 4.5vw, 44px); line-height: 1.05; letter-spacing: -.015em; width: 100%; }
.bd-name::placeholder, .bd-alias::placeholder { color: var(--muted); }
.bd-alias { border: 0; background: none; outline: none; padding: 2px 0; color: var(--text-2); font-size: 14px; width: 100%; }
.role-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.rchip { height: 28px; padding: 0 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line); transition: all .2s var(--ease); }
.rchip:hover { color: var(--text); }
.rchip.on { background: var(--text); color: var(--bg); box-shadow: none; }
.bd-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .bd-grid { grid-template-columns: 1fr 1fr; } }
textarea.bd-area { min-height: 64px; resize: none; overflow: hidden; }
.chips-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 44px; padding: 6px 8px; border-radius: 11px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.chips-input:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-soft); }
.chips-input input { flex: 1; min-width: 120px; border: 0; background: none; outline: none; color: var(--text); font-size: 14px; height: 30px; padding: 0 6px; }
.chip-t { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px 0 11px; border-radius: 999px; background: var(--raise); box-shadow: inset 0 0 0 1px var(--line-soft); font-size: 13px; }
.chip-t button { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.chip-t button:hover { background: var(--surface-2); color: var(--text); }
.chip-t svg { width: 12px; height: 12px; }
.arc { display: grid; grid-template-columns: 1fr 28px 1fr; align-items: center; gap: 8px; }
.arc-arrow { display: grid; place-items: center; color: var(--accent); }
@media (max-width: 640px) { .arc { grid-template-columns: 1fr; } .arc-arrow { transform: rotate(90deg); } }
.bd-notes { min-height: 120px; padding: 12px 14px; border-radius: 11px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); outline: none; font-family: var(--ed-font); font-size: 16px; line-height: 1.65; }
.bd-notes:focus { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-soft); }
.bd-notes:empty::before { content: attr(data-placeholder); color: var(--muted); font-style: italic; }
a.wl { display: inline-block; padding: 0 7px; margin: 0 1px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-family: var(--font-ui); font-size: .82em; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.6; }
a.wl:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.bd-sec { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.bd-sec-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.rel-list { display: flex; flex-direction: column; border-radius: var(--radius); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.rel-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; min-height: 50px; flex-wrap: wrap; }
.rel-row + .rel-row { border-top: 1px solid var(--line-soft); }
.rel-sw, .rc-rel i, .rm-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--k); flex: none; }
.rel-phrase { font-size: 13px; color: var(--text-2); min-width: 92px; }
.rel-who { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 3px; border-radius: 999px; transition: background .15s var(--ease); }
.rel-who:hover { background: var(--surface); }
.rel-who b { font-size: 14px; font-weight: 600; }
.rel-note { flex: 1; font-size: 12.5px; color: var(--muted); font-style: italic; min-width: 0; }
.rel-row .icon-btn { margin-left: auto; width: 32px; height: 32px; }
.rel-row .icon-btn svg { width: 15px; height: 15px; }
.mention-list { display: flex; flex-direction: column; gap: 2px; }
.mention { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; text-align: left; font-size: 14px; color: var(--text); transition: background .15s var(--ease); }
.mention:hover { background: var(--surface-2); }
.mention svg { width: 16px; height: 16px; color: var(--muted); }
.mention span:not(.av) { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention b { font-size: 12px; color: var(--muted); font-weight: 600; }
.bd-back { margin: -16px 0 -8px -8px; }
.ac { min-width: 220px; }
.ac .mi { gap: 10px; }
@media (max-width: 860px) {
  .bible { grid-template-columns: minmax(0, 1fr); }
  .bible .bb-main { display: none; }
  .bible.has-sel .bb-side { display: none; }
  .bible.has-sel .bb-main, .bible.is-map .bb-main { display: block; }
  .bible.is-map .bb-side { border-right: 0; border-bottom: 1px solid var(--line-soft); padding-bottom: 12px; }
  .bible.is-map { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .bd { padding-top: 24px; }
  .bd-head { flex-direction: column; gap: 12px; }
  .bd { position: relative; }
  .bd-head > [data-entry-menu] { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); top: 20px; }
}
@media (min-width: 861px) { .bd-back { display: none !important; } }

/* Hover card */
.hovercard { position: fixed; z-index: 75; width: 290px; padding: 14px; border-radius: 16px; background: var(--raise); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line-soft); display: flex; flex-direction: column; gap: 10px; animation: pop .18s var(--ease); }
.hc-top { display: flex; gap: 12px; align-items: center; }
.hc-top div { display: flex; flex-direction: column; min-width: 0; }
.hc-top b { font-family: var(--font-display); font-weight: 400; font-size: 22px; line-height: 1.05; }
.hc-top span { font-size: 12px; color: var(--muted); }
.hovercard p { margin: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.5; }
.hc-traits { display: flex; flex-wrap: wrap; gap: 5px; }
.hc-traits span { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); color: var(--text-2); }
.hovercard .btn { align-self: flex-start; }
::highlight(ink-name) { text-decoration: underline dotted color-mix(in srgb, var(--accent) 70%, transparent) 1.5px; text-underline-offset: 4px; }

/* Relationship editor */
.rel-builder { display: flex; flex-direction: column; gap: 12px; }
.rel-kinds { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 560px) { .rel-kinds { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rk { display: flex; align-items: center; gap: 7px; height: 36px; padding: 0 10px; border-radius: 10px; font-size: 12.5px; font-weight: 600; color: var(--text-2); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); white-space: nowrap; overflow: hidden; }
.rk i { width: 9px; height: 9px; border-radius: 3px; background: var(--k); flex: none; }
.rk.on { color: var(--text); box-shadow: inset 0 0 0 1.5px var(--k); background: color-mix(in srgb, var(--k) 10%, var(--surface)); }
.rel-sentence { margin: 2px 0; text-align: center; font-family: var(--font-display); font-size: 22px; line-height: 1.25; text-wrap: balance; }
.rel-sentence b { font-weight: 400; }
select.input { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

/* Relationship map */
.rmap { display: flex; flex-direction: column; height: 100%; }
.rm-bar { display: flex; align-items: center; gap: 12px; padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.rm-mode button { padding: 0 14px; }
.rm-mode button svg { width: 15px; height: 15px; }
.rm-hint { font-size: 12.5px; color: var(--muted); }
.rm-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.rm-check input { accent-color: var(--accent); width: 16px; height: 16px; }
.rm-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--cork); background-image: radial-gradient(color-mix(in srgb, var(--text) 8%, transparent) 1px, transparent 1.2px); background-size: 22px 22px; touch-action: none; }
.rm-svg { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; -webkit-user-select: none; }
.rm-svg:active { cursor: grabbing; }
.rm-node { cursor: pointer; transition: opacity .25s var(--ease); }
.rm-node .halo { fill: var(--page); stroke: var(--line); stroke-width: 1; }
.rm-node.hero .halo { stroke: var(--accent); stroke-width: 2; }
.rm-node .rim { fill: none; stroke: rgba(0, 0, 0, .08); }
.rm-node .ini { fill: #fff; font: 700 17px var(--font-ui); letter-spacing: .02em; pointer-events: none; }
.rm-node .nm { fill: var(--text); font: 600 13px var(--font-ui); paint-order: stroke; stroke: var(--cork); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.rm-node .rl { fill: var(--muted); font: 500 10.5px var(--font-ui); letter-spacing: .06em; text-transform: uppercase; paint-order: stroke; stroke: var(--cork); stroke-width: 4px; pointer-events: none; }
.rm-node.sel .halo { stroke: var(--accent); stroke-width: 3; }
.rm-edge { cursor: pointer; transition: opacity .25s var(--ease); }
.rm-edge .hit { stroke: transparent; stroke-width: 16; fill: none; }
.rm-edge .ln { fill: none; stroke-width: 2.2; stroke-linecap: round; }
.rm-edge .ln.dash { stroke-dasharray: 6 5; }
.rm-edge.faint .ln { stroke-width: 1.6; opacity: .55; }
.rm-edge .elabel rect { fill: var(--page); stroke-width: 1; }
.rm-edge .elabel text { font: 600 10.5px var(--font-ui); }
.rm-edge:hover .ln { stroke-width: 3.2; }
.rm-svg.has-sel .rm-node:not(.linked) { opacity: .25; }
.rm-svg.has-sel .rm-edge:not(.on) { opacity: .12; }
.rm-svg.dragging .elabel { opacity: .5; }
.tl { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.tl.spouse { stroke-width: 2.6; }
.tl.dash { stroke-dasharray: 5 5; }
.rm-zoom { position: absolute; right: max(14px, env(safe-area-inset-right, 0px)); top: 14px; display: flex; flex-direction: column; gap: 2px; padding: 4px; border-radius: 12px; background: var(--raise); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line-soft); }
.rm-zoom .icon-btn { width: 34px; height: 34px; }
.rm-legend { position: absolute; left: max(14px, env(safe-area-inset-left, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); display: flex; flex-wrap: wrap; gap: 6px 14px; max-width: calc(100% - 28px); padding: 8px 12px; border-radius: 12px; background: color-mix(in srgb, var(--raise) 92%, transparent); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line-soft); font-size: 12px; color: var(--text-2); }
.rm-legend:empty { display: none; }
.rm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rm-legend i.dash { background: repeating-linear-gradient(90deg, var(--k) 0 4px, transparent 4px 6px); height: 3px; border-radius: 2px; width: 14px; }
.rm-loose { color: var(--muted); }
.rm-card { position: absolute; left: max(14px, env(safe-area-inset-left, 0px)); top: 14px; width: min(300px, calc(100% - 80px)); padding: 14px; border-radius: 16px; background: var(--raise); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line-soft); display: flex; flex-direction: column; gap: 10px; animation: pop .2s var(--ease); }
.rc-top { display: flex; align-items: center; gap: 10px; }
.rc-top div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rc-top b { font-family: var(--font-display); font-weight: 400; font-size: 21px; line-height: 1.05; }
.rc-top span { font-size: 12px; color: var(--muted); }
.rc-top .icon-btn { width: 30px; height: 30px; }
.rc-list { display: flex; flex-direction: column; max-height: 200px; overflow-y: auto; }
.rc-rel { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 8px; font-size: 13px; text-align: left; }
.rc-rel:hover { background: var(--surface-2); }
.rc-rel span { color: var(--text-2); }
.rc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.rm-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 24px; color: var(--muted); font-size: 13.5px; z-index: 2; background: color-mix(in srgb, var(--cork) 80%, transparent); }
.rm-empty svg { width: 34px; height: 34px; color: var(--accent); }
.rm-empty b { color: var(--text); font-size: 16px; }
.rm-empty span { max-width: 40ch; }

/* Side panel */
.sidepanel { position: absolute; z-index: 5; top: calc(56px + env(safe-area-inset-top, 0px)); right: 0; bottom: 0; width: min(360px, 100%); background: var(--surface); border-left: 1px solid var(--line-soft); display: flex; flex-direction: column; box-shadow: -20px 0 40px -30px rgba(0, 0, 0, .25); animation: slidein .3s var(--ease); padding-right: env(safe-area-inset-right, 0px); }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }
body.panel-wide .sidepanel { width: min(46%, 640px); }
@media (min-width: 1180px) { body.panel-open .scroller { margin-right: 360px; } body.panel-open.panel-wide .scroller { margin-right: min(46%, 640px); } body.panel-open .statusbar { right: calc(374px + env(safe-area-inset-right, 0px)); } body.panel-open.panel-wide .statusbar { right: calc(min(46%, 640px) + 14px); } }
@media (max-width: 860px) { .sidepanel { width: 100%; top: calc(56px + env(safe-area-inset-top, 0px)); } body.panel-wide .sidepanel { width: 100%; } }
.sp-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line-soft); }
.sp-tabs { flex: 1; }
.sp-head .icon-btn { width: 34px; height: 34px; }
.sp-body { flex: 1; overflow-y: auto; padding: 14px 14px calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 14px; }
.sp-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 30px 16px; color: var(--muted); font-size: 13px; }
.sp-empty svg { width: 26px; height: 26px; color: var(--accent); }
.notes-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.notes-head div { display: flex; flex-direction: column; }
.notes-head b { font-size: 14px; }
.notes-head span { font-size: 12px; color: var(--muted); }
.cmt-list { display: flex; flex-direction: column; gap: 10px; }
.ncard { padding: 12px; border-radius: 14px; background: var(--raise); box-shadow: var(--shadow-sm), inset 3px 0 0 var(--st-draft); display: flex; flex-direction: column; gap: 8px; cursor: pointer; transition: box-shadow .2s var(--ease); }
.ncard.pulse { box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-draft) 35%, transparent); }
.ncard.orphan { box-shadow: var(--shadow-sm), inset 3px 0 0 var(--muted); }
.ncard.resolved { opacity: .75; box-shadow: inset 0 0 0 1px var(--line-soft); }
.ncard blockquote { margin: 0; font-family: var(--ed-font); font-style: italic; font-size: 13.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ncard textarea { border: 0; background: var(--surface-2); border-radius: 9px; padding: 8px 10px; resize: none; outline: none; color: var(--text); font-size: 14px; line-height: 1.45; overflow: hidden; }
.ncard textarea:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.ncard p { margin: 0; font-size: 14px; }
.cmt-warn { font-size: 12px; color: var(--muted); }
.cmt-foot { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.cmt-foot span { flex: 1; }
.cmt-foot button { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border-radius: 7px; font-weight: 600; color: var(--text-2); }
.cmt-foot button:hover { background: var(--surface-2); color: var(--text); }
.cmt-foot svg { width: 13px; height: 13px; }
.cmt-done summary { cursor: pointer; font-size: 12.5px; color: var(--muted); padding: 6px 0; }
.cmt-done .ncard { margin-top: 8px; }
.editor mark.cmt { background: color-mix(in srgb, var(--st-draft) 18%, transparent); color: inherit; border-bottom: 2px solid color-mix(in srgb, var(--st-draft) 70%, transparent); border-radius: 2px; cursor: pointer; padding: 0 1px; }
.editor mark.cmt.flash { animation: flash 1.2s var(--ease); }
@keyframes flash { 30% { background: color-mix(in srgb, var(--st-draft) 55%, transparent); } }
.editor ins { text-decoration: none; }
.editor.show-rev ins[data-r] { color: var(--rc); background: color-mix(in srgb, var(--rc) 8%, transparent); border-radius: 2px; }
.editor ins[data-r="2"] { --rc: #4a7bc2; } .editor ins[data-r="3"] { --rc: #3f9668; } .editor ins[data-r="4"] { --rc: #9168c4; } .editor ins[data-r="5"] { --rc: #c2513f; } .editor ins[data-r="6"] { --rc: #b88a1e; }
.rev-ind { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); margin-right: 4px; white-space: nowrap; }
.rev-ind i { width: 8px; height: 8px; border-radius: 50%; }
body:not([data-view="write"]) .rev-ind { display: none; }

.rv-sec { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.rv-sec:last-child { border-bottom: 0; }
.rv-h { display: flex; flex-direction: column; gap: 2px; }
.rv-h b { font-size: 14px; }
.rv-h span { font-size: 12px; color: var(--muted); }
.rounds { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.round { height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-size: 13px; font-weight: 700; color: var(--text-2); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.round i { width: 8px; height: 8px; border-radius: 50%; background: var(--rc); }
.round.on { box-shadow: inset 0 0 0 1.5px var(--rc); color: var(--text); background: color-mix(in srgb, var(--rc) 10%, var(--surface)); }
.read-score { display: flex; align-items: center; gap: 14px; }
.rs-dial { --p: 50; width: 58px; height: 58px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line-soft) 0); position: relative; }
.rs-dial::before { content: ''; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
.rs-dial b { position: relative; font-family: var(--font-display); font-weight: 400; font-size: 22px; }
.read-score div:last-child { display: flex; flex-direction: column; }
.read-score div:last-child b { font-size: 14px; }
.read-score span { font-size: 12px; color: var(--muted); }
.rv-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.rv-grid div { display: flex; flex-direction: column; padding: 10px; }
.rv-grid div + div { border-left: 1px solid var(--line-soft); }
.rv-grid b { font-size: 16px; } .rv-grid span { font-size: 11px; color: var(--muted); }
.hl-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 11px; text-align: left; transition: background .15s var(--ease); }
.hl-row:hover { background: var(--surface-2); }
.hl-row.on { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.hl-row .t-text { flex: 1; display: flex; flex-direction: column; }
.hl-row .t-text b { font-size: 13.5px; font-weight: 600; } .hl-row .t-text span { font-size: 11.5px; color: var(--muted); }
.hl-n { font-size: 12.5px; color: var(--muted); }
.hl-sw { width: 16px; height: 16px; border-radius: 5px; flex: none; }
.hl-sw.ink-adverb { background: color-mix(in srgb, #d8913f 40%, transparent); }
.hl-sw.ink-passive { background: color-mix(in srgb, #5a88cf 35%, transparent); }
.hl-sw.ink-repeat { background: color-mix(in srgb, #d0625a 35%, transparent); }
.hl-sw.ink-long { background: color-mix(in srgb, #c9ad3c 40%, transparent); }
.hl-sw.ink-dialogue { background: var(--text); }
::highlight(ink-adverb) { background-color: color-mix(in srgb, #d8913f 30%, transparent); }
::highlight(ink-passive) { background-color: color-mix(in srgb, #5a88cf 25%, transparent); }
::highlight(ink-repeat) { text-decoration: underline wavy #d0625a 1.5px; text-underline-offset: 4px; }
::highlight(ink-long) { background-color: color-mix(in srgb, #c9ad3c 22%, transparent); }
::highlight(ink-find) { background-color: color-mix(in srgb, var(--accent) 34%, transparent); color: var(--text); }
::highlight(ink-speak) { background-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.editor.dlg-only { color: var(--dimmed); }
.editor.dlg-only * { color: inherit; }
::highlight(ink-dialogue) { color: var(--text); }
.over { display: flex; flex-wrap: wrap; gap: 6px; }
.over button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; font-size: 13px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.over button b { font-size: 11.5px; color: var(--muted); }
.over button.on { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-soft); }
.nc-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.nc-row s { color: var(--danger); text-decoration-thickness: 1.5px; }
.nc-row small { color: var(--muted); }
.ref-pick { height: 40px; font-size: 14px; }
.ref-body { display: flex; flex-direction: column; gap: 12px; }
.ref-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 28px; line-height: 1.1; }
.ref-text { font-family: var(--ed-font); font-size: calc(var(--ed-size) * .88); line-height: var(--ed-lh); color: var(--text); }
.ref-text p { margin: 0 0 .8em; } .ref-text hr { border: 0; text-align: center; } .ref-text hr::after { content: '⁂'; color: var(--muted); }
.ref-text mark { background: none; color: inherit; } .ref-text ins { text-decoration: none; }
.ref-entry { display: flex; gap: 14px; align-items: center; }
.ref-row { display: flex; flex-direction: column; gap: 2px; }
.ref-row span { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ref-row p { margin: 0; font-size: 14px; line-height: 1.55; }

/* Find & replace */
.fr-inputs { display: flex; flex-direction: column; gap: 8px; }
.fr-field { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.fr-field:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-soft); }
.fr-field input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); font-size: 15px; }
.fr-opts { display: flex; align-items: center; gap: 6px; }
.fr-opt { height: 32px; min-width: 40px; padding: 0 10px; border-radius: 9px; font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line); }
.fr-opt.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.fr-summary { font-size: 13px; color: var(--muted); }
.fr-summary b { color: var(--text); }
.fr-results { display: flex; flex-direction: column; gap: 14px; }
.fr-sh { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 0 4px 6px; }
.fr-sh b { font-size: 14px; } .fr-sh span { font-size: 12px; color: var(--muted); }
.fr-hit { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 10px; font-family: var(--ed-font); font-size: 14.5px; line-height: 1.5; color: var(--text-2); transition: background .15s var(--ease); }
.fr-hit:hover { background: var(--surface-2); }
.fr-hit mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--text); border-radius: 3px; padding: 0 1px; }

/* Version history */
.vh { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; min-height: 420px; }
@media (max-width: 760px) { .vh { grid-template-columns: 1fr; } }
.vh-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.vh-save { display: flex; gap: 6px; }
.vh-save .input { height: 36px; font-size: 13.5px; }
.vh-list { display: flex; flex-direction: column; gap: 2px; max-height: 460px; overflow-y: auto; }
.vh-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 11px; text-align: left; transition: background .15s var(--ease); }
.vh-item:hover { background: var(--surface-2); }
.vh-item.on { background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); }
.vh-item b { font-size: 13.5px; font-weight: 600; }
.vh-item span { font-size: 12px; color: var(--muted); }
.vh-item i { font-style: normal; font-weight: 600; } .vh-item i.up { color: var(--accent); } .vh-item i.down { color: var(--danger); }
.vh-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.vh-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.vh-legend { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); align-items: center; }
.vh-legend .del, .vh-legend .add { padding: 2px 8px; border-radius: 6px; }
.vh-legend .del { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); text-decoration: line-through; }
.vh-legend .add { background: var(--accent-soft); color: var(--accent); }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 760px) { .diff { grid-template-columns: 1fr; } }
.diff-col { border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); min-width: 0; overflow: hidden; }
.diff-h { padding: 10px 14px; font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line-soft); }
.diff-body { padding: 12px 14px; max-height: 440px; overflow-y: auto; font-family: var(--ed-font); font-size: 14.5px; line-height: 1.6; }
.diff-body p { margin: 0 0 .7em; }
.diff-body p.ph { min-height: 1.6em; background: repeating-linear-gradient(135deg, transparent 0 6px, var(--line-soft) 6px 7px); border-radius: 6px; }
.diff-body del { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); text-decoration: line-through; border-radius: 3px; }
.diff-body ins { background: var(--accent-soft); color: var(--accent); text-decoration: none; border-radius: 3px; }

/* Read aloud */
.speech-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 40; display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 6px; border-radius: 999px; background: var(--raise); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line-soft); animation: rise .3s var(--ease); max-width: calc(100vw - 24px); }
.speech-bar [data-sp-play] { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.speech-bar [data-sp-play]:hover { background: var(--accent-strong); color: var(--accent-ink); }
.sb-meta { display: flex; flex-direction: column; min-width: 0; }
.sb-meta b { font-size: 13px; } .sb-meta span { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.speech-bar select { height: 32px; border: 0; border-radius: 9px; background: var(--surface-2); color: var(--text); font-size: 12.5px; padding: 0 8px; max-width: 140px; outline: none; }
@media (max-width: 600px) { .speech-bar #sbVoice { display: none; } .speech-bar { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); } }

/* ======================================================================
   Phase 4 — themes, modes, timeline, compile, lock, palette
   ====================================================================== */
:root[data-theme="midnight"] {
  --bg: #0b1020; --bg-2: #0e1428; --surface: #121a33; --surface-2: #18213d; --raise: #1c2747;
  --line: #27335a; --line-soft: #1a2442; --text: #e4e8f5; --text-2: #a3acc6; --muted: #6b7593;
  --accent: #8fb4ff; --accent-strong: #b3cbff; --accent-ink: #0a1020; --accent-soft: rgba(143, 180, 255, .13);
  --warn: #e7b46a; --danger: #ef8d84; --page: #0d1326; --cork: #0c1224; --heat-0: #1a2442;
  --st-idea: #8b95b3; --st-draft: #e7b46a; --st-revised: #8fb4ff; --st-final: #7fd1b9;
  --shadow-lg: 0 40px 90px -30px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -14px rgba(0, 0, 0, .75);
  --scrim: rgba(3, 6, 14, .65); color-scheme: dark;
}
:root[data-theme="sepia"] {
  --bg: #17120d; --bg-2: #1b1610; --surface: #211a13; --surface-2: #2a2118; --raise: #30261b;
  --line: #3d3023; --line-soft: #2b2219; --text: #ecdcc4; --text-2: #bba98e; --muted: #857560;
  --accent: #e0a95a; --accent-strong: #efc07c; --accent-ink: #1a1209; --accent-soft: rgba(224, 169, 90, .14);
  --warn: #e0a95a; --danger: #e68a74; --page: #1a140e; --cork: #140f0a; --heat-0: #2b2219;
  --st-idea: #9a8a72; --st-draft: #e0a95a; --st-revised: #b7b08a; --st-final: #a8c48a;
  --shadow-lg: 0 40px 90px -30px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 220, 170, .04);
  --shadow-sm: 0 1px 0 rgba(255, 230, 190, .03) inset, 0 10px 30px -14px rgba(0, 0, 0, .75);
  --scrim: rgba(8, 5, 2, .65); color-scheme: dark;
}
:root[data-theme="oled"] {
  --bg: #000; --bg-2: #050505; --surface: #0b0b0b; --surface-2: #121212; --raise: #171717;
  --line: #262626; --line-soft: #161616; --text: #e8e8e8; --text-2: #a2a2a2; --muted: #6a6a6a;
  --accent: #86cdb9; --accent-strong: #a6ddcd; --accent-ink: #001510; --accent-soft: rgba(134, 205, 185, .12);
  --warn: #e2b061; --danger: #e58b7e; --page: #000; --cork: #000; --heat-0: #161616;
  --st-idea: #8a8a8a; --st-draft: #e2b061; --st-revised: #8fb0ea; --st-final: #86cdb9;
  --shadow-lg: 0 0 0 1px #222; --shadow-sm: 0 0 0 1px #1c1c1c;
  --scrim: rgba(0, 0, 0, .75); color-scheme: dark;
}
.theme-picks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .theme-picks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.theme-pick { display: flex; flex-direction: column; gap: 8px; padding: 8px 8px 10px; border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); text-align: left; transition: box-shadow .2s var(--ease); }
.theme-pick b { font-size: 13px; font-weight: 600; padding-left: 4px; }
.theme-pick.on { box-shadow: inset 0 0 0 2px var(--accent); }
.tp-sw { position: relative; height: 54px; border-radius: 9px; background: var(--a); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .2); }
.tp-sw i:first-child { position: absolute; left: 12px; right: 30%; top: 14px; height: 6px; border-radius: 3px; background: var(--b); box-shadow: 0 10px 0 var(--b), 0 20px 0 var(--b); opacity: .9; }
.tp-sw i:nth-child(2) { position: absolute; right: 10px; top: 12px; width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.tp-sw i.half { position: absolute; inset: 0 0 0 50%; background: var(--b); }
.sel-sm { height: 34px; width: auto; font-size: 13px; padding-left: 10px; }

/* New project: mode picker */
.mode-picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mode-pick { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 10px; row-gap: 2px; padding: 12px; border-radius: 14px; text-align: left; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); transition: box-shadow .2s var(--ease), background .2s var(--ease); }
.mode-pick .mp-ic { grid-row: span 2; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.mode-pick b { font-size: 14px; font-weight: 600; }
.mode-pick span:last-child { font-size: 12px; color: var(--muted); line-height: 1.35; }
.mode-pick.on { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-soft); }
.mode-pick.on .mp-ic { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
@media (max-width: 520px) { .mode-picks { grid-template-columns: 1fr; } }
.book { position: relative; }
.cover-lock { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 2; }
.cover-lock svg { width: 15px; height: 15px; }

/* Screenplay */
.editor.sp { font-family: 'Courier Prime', 'Courier New', Courier, monospace; font-size: calc(var(--ed-size) * .86); line-height: 1.5; max-width: 62ch; }
.editor.sp p { margin: 0; min-height: 1.5em; }
.editor.sp p[data-el="heading"] { text-transform: uppercase; font-weight: 700; margin-top: 1.8em; }
.editor.sp p[data-el="heading"]:first-child { margin-top: 0; }
.editor.sp p:not([data-el]), .editor.sp p[data-el="action"] { margin-top: 1em; }
.editor.sp p[data-el="character"] { text-transform: uppercase; margin-top: 1em; margin-left: 37%; }
.editor.sp p[data-el="paren"] { margin-left: 26%; margin-right: 28%; }
.editor.sp p[data-el="dialogue"] { margin-left: 17%; margin-right: 22%; }
.editor.sp p[data-el="transition"] { text-transform: uppercase; text-align: right; margin-top: 1em; }
.editor.sp p[data-el="centered"] { text-align: center; margin-top: 1em; }
.editor.sp p.e::before { position: absolute; color: var(--muted); pointer-events: none; font-weight: 400; }
.editor.sp p[data-el="heading"].e::before { content: 'INT. LOCATION – DAY'; }
.editor.sp p[data-el="character"].e::before { content: 'CHARACTER'; }
.editor.sp p[data-el="dialogue"].e::before { content: 'Dialogue'; }
.editor.sp p[data-el="transition"].e::before { content: 'CUT TO:'; right: 0; }
.editor.sp p { position: relative; }
.editor.sp:empty::before { content: 'INT. LOCATION – DAY'; font-style: normal; }
@media (max-width: 600px) { .editor.sp p[data-el="character"] { margin-left: 30%; } .editor.sp p[data-el="dialogue"] { margin-left: 10%; margin-right: 8%; } .editor.sp p[data-el="paren"] { margin-left: 20%; margin-right: 14%; } }
body[data-mode="screenplay"] .scene-title { font-size: clamp(26px, 3.4vw, 34px); }
.el-pick { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 12px; margin-right: 4px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); min-width: 124px; justify-content: space-between; }
.el-pick svg { width: 14px; height: 14px; color: var(--muted); }
.sp-ac { position: fixed; z-index: 70; min-width: 220px; max-width: 320px; padding: 6px; border-radius: 12px; background: var(--raise); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line-soft); display: flex; flex-direction: column; animation: pop .15s var(--ease); }
.sp-ac button { text-align: left; padding: 7px 10px; border-radius: 8px; font-family: 'Courier Prime', 'Courier New', monospace; font-size: 14px; color: var(--text); }
.sp-ac button.on { background: var(--accent-soft); color: var(--accent); }
.sp-ac-hint { font-size: 11px; color: var(--muted); padding: 4px 10px 2px; }
.sb-extra { color: var(--text-2); }

/* Poetry */
.ed-wrap { position: relative; }
.editor.poem p { margin: 0 0 1.4em; }
.editor.poem.poem-center p { text-align: center; }
.syl-gutter { position: absolute; top: 0; right: -54px; width: 40px; pointer-events: none; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.syl-gutter span { position: absolute; right: 0; display: flex; align-items: center; }
@media (max-width: 860px) { .syl-gutter { right: -18px; width: 16px; font-size: 10px; } }
.syl-btn .h { font-family: var(--font-mono) !important; font-size: 13px !important; font-weight: 600; }

/* Journal */
.k-mood, .k-when { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 5px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line); }
.k-mood:hover, .k-when:hover { color: var(--text); background: var(--surface-2); }
.k-mood svg.i, .k-when svg { width: 13px; height: 13px; }
.k-when { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 500; padding-left: 7px; }
.mood-face { flex: none; }
.mood-face circle:first-child { fill: color-mix(in srgb, var(--mc) 18%, transparent); stroke: var(--mc); stroke-width: 1.5; }
.mood-face .eye { fill: var(--mc); }
.mood-face path { fill: none; stroke: var(--mc); stroke-width: 1.6; stroke-linecap: round; }
.pop .mi .mood-face { width: 18px; height: 18px; }
.cal { width: 100%; max-width: 980px; margin: 0 auto; padding: 32px max(24px, env(safe-area-inset-right, 0px)) 120px max(24px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 22px; }
.cal-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.cal-head h2 { margin: 6px 0 4px; font-family: var(--font-display); font-weight: 400; font-size: clamp(34px, 5vw, 48px); line-height: 1; letter-spacing: -.015em; }
.cal-head p { margin: 0; color: var(--muted); font-size: 13.5px; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-wd { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 0 4px 4px; }
.cal-cell { position: relative; aspect-ratio: 5 / 4; min-height: 64px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft); display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: 10px; text-align: left; transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.cal-cell.pad { background: transparent; box-shadow: none; }
.cal-cell:not(.pad):not([disabled]):hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px var(--line), var(--shadow-sm); }
.cal-cell[disabled] { opacity: .45; cursor: default; }
.cal-cell.has { background: var(--raise); box-shadow: inset 0 0 0 1px var(--line), 0 6px 18px -12px rgba(0, 0, 0, .3); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-d { font-size: 13px; font-weight: 700; color: var(--text-2); }
.cal-cell.has .cal-d { color: var(--text); }
.cal-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.cal-w { position: absolute; right: 10px; bottom: 9px; font-size: 11px; color: var(--muted); }
.cal-new { align-self: flex-start; }
@media (max-width: 600px) { .cal-grid { gap: 4px; } .cal-cell { padding: 6px; border-radius: 10px; min-height: 0; } .cal-w { display: none; } .cal-cell .mood-face { width: 16px; height: 16px; } }

/* Timeline */
.tline { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.tl-bar { display: flex; align-items: center; gap: 14px; padding: 14px max(20px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.tl-hint { font-size: 12.5px; color: var(--muted); max-width: 70ch; }
.tl-scroll { flex: 1; overflow: auto; min-height: 260px; background: var(--cork); background-image: radial-gradient(color-mix(in srgb, var(--text) 8%, transparent) 1px, transparent 1.2px); background-size: 22px 22px; }
.tl-canvas { position: relative; margin: 10px 0 30px; }
.tl-lane { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); }
.tl-lane span { position: sticky; left: 0; display: inline-block; max-width: 130px; padding: 8px 12px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); background: linear-gradient(90deg, var(--cork) 70%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 1; }
.tl-axis { position: absolute; left: 0; right: 0; top: 4px; height: 20px; }
.tl-tick { position: absolute; font-size: 11px; color: var(--text-2); white-space: nowrap; padding-left: 2px; border-left: 1px solid var(--line); padding: 0 8px; }
.tl-path { position: absolute; inset: 0; pointer-events: none; }
.tl-path path { fill: none; stroke: color-mix(in srgb, var(--accent) 55%, transparent); stroke-width: 2; stroke-dasharray: 2 6; stroke-linecap: round; }
.tl-card { position: absolute; width: 170px; padding: 10px 12px; border-radius: 12px; text-align: left; background: var(--raise); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line-soft); display: flex; flex-direction: column; gap: 4px; transition: transform .2s var(--ease), box-shadow .2s var(--ease); z-index: 2; }
.tl-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.tl-card.flash { box-shadow: var(--shadow-sm), inset 0 0 0 1.5px color-mix(in srgb, var(--st-revised) 60%, transparent); }
.tl-top { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.tl-fb { margin-left: auto; font-family: var(--font-ui); font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--st-revised); }
.tl-card b { font-size: 14px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tl-when { font-size: 12px; color: var(--text-2); }
.tl-tray { padding: 14px max(20px, env(safe-area-inset-left, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 10px; background: var(--page); }
.tl-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 120px; overflow-y: auto; }
.tl-chip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.tl-chip span { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.tl-chip:hover { box-shadow: inset 0 0 0 1.5px var(--accent); }
.tl-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 40px 24px; color: var(--muted); font-size: 13.5px; }
.tl-empty svg { width: 32px; height: 32px; color: var(--accent); }
.tl-empty b { color: var(--text); font-size: 16px; }
.tl-empty span { max-width: 46ch; }
.when-btn { text-align: left; color: var(--text); }
#boardView:has(.tline), #boardView:has(.cal) { background: var(--page); background-image: none; display: flex; flex-direction: column; }
#boardView:has(.tline) { overflow: hidden; }

/* Compile */
.cp-formats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cp-tpls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 760px) { .cp-tpls { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cp-tpl { display: flex; flex-direction: column; gap: 4px; padding: 10px 10px 12px; border-radius: 14px; text-align: left; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.cp-tpl b { font-size: 13.5px; font-weight: 600; margin-top: 6px; }
.cp-tpl > span:last-child { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.cp-tpl.on { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-soft); }
.cp-prev { height: 74px; border-radius: 6px; background: #fdfdfb; box-shadow: 0 6px 16px -10px rgba(0, 0, 0, .4), inset 0 0 0 1px rgba(0, 0, 0, .08); padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; overflow: hidden; }
.cp-prev i { display: block; height: 3px; border-radius: 2px; background: #c9c9c2; }
.tp-manuscript i { height: 2px; margin-bottom: 4px; } .tp-manuscript i:first-child { width: 40%; align-self: center; background: #8a8a83; }
.tp-book i:first-child { width: 30%; align-self: center; height: 6px; background: #6a6a63; margin-bottom: 4px; } .tp-book i { width: 100%; }
.tp-reading i:first-child { width: 55%; height: 5px; background: #6a6a63; } .tp-reading i:nth-child(3) { width: 80%; }
.tp-custom i:first-child { width: 45%; height: 5px; background: var(--accent); } .tp-custom i:nth-child(2) { width: 70%; } .tp-custom i:nth-child(4) { width: 85%; }
.cp-custom { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; padding: 14px; border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); margin-top: 4px; }
@media (max-width: 640px) { .cp-custom { grid-template-columns: 1fr 1fr; } }
.cp-custom .input { height: 38px; font-size: 13.5px; background-color: var(--surface); }
.cp-row { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.cp-row .toggle-row { gap: 12px; }
.cp-contents-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.cp-quick { display: flex; gap: 4px; }
.cp-quick button { height: 28px; padding: 0 10px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line); }
.cp-quick button:hover { color: var(--text); background: var(--surface-2); }
.cp-tree { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; padding: 6px; border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.cp-check { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.cp-check:hover { background: var(--surface); }
.cp-check input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.cp-check b { font-weight: 600; flex: 1; min-width: 0; }
.cp-check > span.tnum { font-size: 12px; color: var(--muted); }
.cp-check.sm { font-size: 13px; padding: 5px 8px; }
.cp-check.sm span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.cp-scenes { padding-left: 26px; display: flex; flex-direction: column; }
.cp-sum { font-size: 13px; color: var(--muted); }
@media (max-width: 600px) { .cp-sum { width: 100%; text-align: center; } }

/* Passwords */
.pw-meter { display: flex; flex-direction: column; gap: 6px; }
.pw-meter i { display: block; height: 4px; width: 0; border-radius: 4px; background: var(--danger); transition: width .3s var(--ease), background .3s var(--ease); }
.pw-meter i[data-s="2"] { background: var(--warn); } .pw-meter i[data-s="3"], .pw-meter i[data-s="4"] { background: var(--accent); }
.pw-meter span { font-size: 12px; color: var(--muted); }
.pw-err { margin: 0; color: var(--danger); font-size: 13px; }
.warn-box { align-items: flex-start; padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 10%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 35%, transparent); font-size: 13px; line-height: 1.45; }

/* Lock screen */
body.is-locked > *:not(#lockScreen):not(.toasts) { visibility: hidden; }
.lock { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: var(--bg); padding: max(20px, env(safe-area-inset-top, 0px)) 20px max(20px, env(safe-area-inset-bottom, 0px)); animation: fade .3s var(--ease); }
.lock::before { content: ''; position: absolute; inset: 0; background: radial-gradient(60% 50% at 50% 30%, var(--accent-soft), transparent 70%); pointer-events: none; }
.lock.out { opacity: 0; transform: scale(1.02); transition: all .35s var(--ease); }
.lock-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; width: min(320px, 100%); text-align: center; }
.lock-inner .brand-mark { width: 46px; height: 46px; margin-bottom: 4px; }
.lock h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 32px; line-height: 1.05; }
.lock p { margin: 0; color: var(--text-2); font-size: 14px; min-height: 20px; }
.lock p.long { font-size: 12.5px; line-height: 1.45; }
.pin-dots { display: flex; gap: 14px; margin: 8px 0 12px; }
.pin-dots i { width: 13px; height: 13px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--text-2); transition: background .15s var(--ease), transform .15s var(--ease); }
.pin-dots i.on { background: var(--text); box-shadow: none; transform: scale(1.1); }
.shake { animation: shake .45s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px 22px; }
.keypad button { width: 72px; height: 72px; border-radius: 50%; font-size: 26px; font-weight: 400; color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); display: grid; place-items: center; transition: background .12s var(--ease), transform .12s var(--ease); font-variant-numeric: tabular-nums; }
.keypad button:active { background: var(--line); transform: scale(.94); }
.keypad button svg { width: 22px; height: 22px; }
.keypad.small { grid-template-columns: repeat(3, 60px); gap: 10px 18px; }
.keypad.small button { width: 60px; height: 60px; font-size: 22px; }
.keypad button.ok { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.lock-forgot { margin-top: 10px; font-size: 13px; color: var(--muted); }
.lock-forgot:hover { color: var(--text); }
.pin-setup { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 6px 0 4px; }
.pin-setup p { margin: 0; color: var(--text-2); font-size: 14px; }
.pin-field { display: flex; gap: 12px; min-height: 16px; }
.pin-field i { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--text-2); }
.pin-field i.on { background: var(--text); box-shadow: none; }

/* Command palette */
.pal-wrap { position: fixed; inset: 0; z-index: 90; background: var(--scrim); display: flex; justify-content: center; align-items: flex-start; padding: max(12vh, 20px) 16px 16px; animation: fade .18s var(--ease); }
.pal { width: min(640px, 100%); max-height: min(70vh, 560px); display: flex; flex-direction: column; border-radius: 20px; overflow: hidden; background: var(--raise); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line-soft); animation: rise .25s var(--ease); }
.pal-in { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 58px; border-bottom: 1px solid var(--line-soft); color: var(--muted); }
.pal-in input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); font-size: 17px; }
.pal-list { flex: 1; overflow-y: auto; padding: 6px; }
.pal-g { padding: 10px 12px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.pal-it { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 6px 12px; border-radius: 10px; text-align: left; color: var(--text); }
.pal-it svg { width: 17px; height: 17px; color: var(--text-2); flex: none; }
.pal-it.on { background: var(--accent-soft); }
.pal-it.on svg { color: var(--accent); }
.pal-l { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; font-size: 14.5px; white-space: nowrap; overflow: hidden; }
.pal-l small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.pal-k { display: flex; gap: 3px; flex: none; }
.pal-empty { padding: 30px; text-align: center; color: var(--muted); font-size: 14px; }
.pal-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line-soft); font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.pal-foot span { display: inline-flex; align-items: center; gap: 4px; }
kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; font-family: var(--font-ui); font-size: 11.5px; font-weight: 600; color: var(--text-2); background: var(--surface-2); box-shadow: inset 0 -1px 0 var(--line), inset 0 0 0 1px var(--line-soft); }
@media (pointer: coarse) { .pal-foot { display: none; } }
.kb-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 28px; }
@media (max-width: 640px) { .kb-grid { grid-template-columns: 1fr; } }
.kb-group { display: flex; flex-direction: column; gap: 4px; }
.kb-group .group-title { margin-bottom: 4px; }
.kb-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.kb-keys { display: flex; gap: 3px; flex: none; }
.kb-row code { font-family: var(--font-mono); font-size: 12.5px; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); }

/* Tablet and mid widths */
@media (max-width: 1280px) and (min-width: 861px) {
  .view-seg button span { display: none; }
  .view-seg button { padding: 0 11px; }
  .crumbs .c2 { max-width: 140px; }
}
@media (max-width: 1060px) and (min-width: 861px) {
  :root { --binder-w: 248px; }
  .fmt .icon-btn { width: 30px; }
  .crumbs { display: none; }
  .view-seg { margin-right: auto; }
}


/* ================================================================ v1.4 additions */
:root { --tree-line: #8a8f99; }
:root[data-theme="dark"], :root[data-theme="midnight"], :root[data-theme="sepia"], :root[data-theme="oled"] { --tree-line: #6f7685; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --tree-line: #6f7685; } }

/* ---------- Pictures in scenes ---------- */
.editor figure.ink-img { margin: 1.4em auto; display: block; max-width: 100%; position: relative; cursor: pointer; user-select: none; border-radius: 6px; transition: box-shadow .2s var(--ease); }
.editor figure.ink-img img { display: block; width: 100%; height: auto; border-radius: 6px; }
.editor figure.ink-img[data-cap]::after { content: attr(data-cap); display: block; text-align: center; font-style: italic; font-size: .82em; color: var(--text-2); margin-top: .5em; line-height: 1.4; }
.editor figure.ink-img:hover, .editor figure.ink-img.sel { box-shadow: 0 0 0 2px var(--accent); }
.editor figure.ink-img.missing img { min-height: 120px; background: var(--surface-2); }
.editor figure.ink-img.missing::before { content: 'Picture not found on this device'; position: absolute; inset: 0; display: grid; place-items: center; font: 500 13px var(--font-ui); color: var(--muted); }
.ref-text figure.ink-img { margin: 1em auto; } .ref-text figure.ink-img img { width: 100%; height: auto; border-radius: 5px; }
.ref-text figure[data-cap]::after { content: attr(data-cap); display: block; text-align: center; font-style: italic; font-size: .85em; color: var(--text-2); }
.img-panel { width: min(340px, calc(100vw - 24px)); }
.img-panel .seg { width: 100%; } .img-panel .seg button { flex: 1; }

/* ---------- First names ---------- */
.bd-first { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); min-height: 26px; }
.bd-first:empty { display: none; }
.bd-first .warn { color: var(--warn); display: inline-flex; gap: 6px; align-items: flex-start; }
.bd-first .warn svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }
.bd-first b { color: var(--text); font-weight: 600; }
.bd-first .warn b { color: inherit; }
.switch.sm { width: 32px; height: 20px; }
.switch.sm::after { width: 14px; height: 14px; }
.switch.sm[aria-checked="true"]::after { transform: translateX(12px); }
.switch[disabled] { opacity: .4; cursor: not-allowed; }
.bd-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 640px) { .bd-grid.four { grid-template-columns: 1fr 1fr; } }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }

/* ---------- Custom profile tabs ---------- */
.bd-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line-soft); margin-bottom: -6px; }
.bd-tab { position: relative; padding: 9px 14px 11px; font-size: 14px; font-weight: 600; color: var(--muted); border-radius: 8px 8px 0 0; display: inline-flex; align-items: center; gap: 6px; }
.bd-tab:hover { color: var(--text); background: var(--surface-2); }
.bd-tab.on { color: var(--text); }
.bd-tab.on::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.bd-tab.add { color: var(--accent); font-weight: 500; }
.bd-tab.add svg { width: 15px; height: 15px; }
.bd-tab .own-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--st-draft, #d8913f); display: inline-block; }
.bd-tab-edit { font: 600 14px var(--font-ui); padding: 7px 10px; border-radius: 8px; border: 0; outline: none; background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--text); width: 160px; }
.bd-custom { display: flex; flex-direction: column; gap: 16px; }
.bd-custom-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.cf-row { display: flex; flex-direction: column; gap: 6px; }
.cf-head { display: flex; align-items: center; gap: 6px; }
.cf-label { flex: 1; border: 0; background: none; outline: none; padding: 2px 0; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.cf-label:focus { color: var(--text); }
.cf-label::placeholder { color: var(--muted); opacity: .7; }
.cf-rm { width: 26px; height: 26px; opacity: 0; } .cf-rm svg { width: 14px; height: 14px; }
.cf-row:hover .cf-rm, .cf-rm:focus-visible { opacity: 1; }
@media (pointer: coarse) { .cf-rm { opacity: 1; } }
.bd-custom > .btn { align-self: flex-start; }
.tab-new { width: min(320px, calc(100vw - 24px)); }
.tab-new .seg { width: 100%; } .tab-new .seg button { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Series ---------- */
.series-block { margin-bottom: 44px; }
.series-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.series-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.sh-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sh-text h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 28px; line-height: 1.05; letter-spacing: -.01em; overflow-wrap: anywhere; }
.sh-text > span:last-child { font-size: 12.5px; color: var(--muted); }
.shelf-label { margin: 0 0 16px; }
.book { position: relative; }
.book .b-meta .book-no { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.sr-book .sr-cover { width: 30px; height: 44px; border-radius: 4px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.sr-book .sr-no { display: inline-block; margin-right: 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.sr-book [data-up] svg { transform: rotate(180deg); }
.sr-book [data-up][disabled] { opacity: .3; }
.sr-book.leaving { opacity: .45; }
.sr-book.leaving b { text-decoration: line-through; }
.bb-shared { display: flex; align-items: center; gap: 8px; margin: 0 2px 10px; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); color: var(--text-2); font-size: 12.5px; line-height: 1.35; }
.bb-shared svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.bb-shared b { color: var(--text); font-weight: 600; }

/* ---------- Welcome back ---------- */
.welcome { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; margin: -8px 0 32px; padding: 22px; border-radius: calc(var(--radius) + 4px); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft), 0 18px 40px -30px rgba(0, 0, 0, .35); }
.welcome.solo { grid-template-columns: 1fr; padding: 14px; }
.welcome.solo .wb-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.wb-main { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; min-width: 0; }
.wb-where { margin: 0; font-size: 15.5px; color: var(--text-2); }
.wb-where b { color: var(--text); font-weight: 600; }
.wb-excerpt { margin: 2px 0 6px; padding: 2px 0 2px 16px; border-left: 2px solid var(--accent); font-family: var(--ed-font, var(--font-display)); font-size: 17px; line-height: 1.6; color: var(--text); font-style: italic; overflow-wrap: anywhere; }
.wb-excerpt.empty, .wb-excerpt.locked { font-family: var(--font-ui); font-size: 14px; color: var(--muted); border-left-color: var(--line); display: flex; gap: 8px; align-items: center; }
.wb-excerpt.locked svg { width: 15px; height: 15px; }
.wb-stats { display: grid; grid-template-columns: 1fr; gap: 8px; align-content: start; }
.wb-tile { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); text-align: left; min-width: 0; transition: box-shadow .2s var(--ease); }
.wb-tile:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.wb-tile > span:last-child { display: flex; flex-direction: column; gap: 1px; min-width: 0; font-size: 12.5px; color: var(--muted); }
.wb-tile b { font-family: var(--font-display); font-weight: 400; font-size: 26px; line-height: 1.05; color: var(--text); }
.wb-tile b small { font-family: var(--font-ui); font-size: 12.5px; color: var(--muted); }
.wb-ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.wb-ic.flame { background: color-mix(in srgb, var(--st-draft, #d8913f) 16%, transparent); color: var(--st-draft, #d8913f); }
.wb-ic svg { width: 22px; height: 22px; }
.lv-badge { position: relative; width: 44px; height: 44px; flex: none; display: grid; place-items: center; align-content: center; border-radius: 13px; background: linear-gradient(145deg, var(--accent), var(--accent-strong)); color: var(--accent-ink); font: 800 19px/1 var(--font-ui); box-shadow: 0 6px 16px -8px var(--accent); }
.lv-badge small { font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; opacity: .85; margin-bottom: 1px; }
.lv-badge.big { width: 64px; height: 64px; font-size: 28px; border-radius: 18px; }
.lv-text { flex: 1; }
.wb-level .lv-text b { font-family: var(--font-ui); font-size: 15px; font-weight: 700; }
.lv-bar { display: block; height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--text) 10%, transparent); overflow: hidden; margin: 5px 0 3px; }
.lv-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.lv-bar.big { height: 10px; margin: 14px 0 8px; }
.lv-hero { display: flex; align-items: center; gap: 16px; }
.lv-hero b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1.1; }
.lv-hero span.tnum { color: var(--muted); font-size: 13.5px; }
.gs-lv { margin-left: auto; position: relative; flex: none; display: grid; place-items: center; align-content: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font: 800 14px/1 var(--font-ui); overflow: hidden; }
.gs-lv small { font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.gs-lv i { position: absolute; left: 0; bottom: 0; height: 3px; width: var(--p); background: var(--accent); }
@media (max-width: 760px) {
  .welcome { grid-template-columns: 1fr; padding: 16px; margin-top: -4px; }
  .welcome.solo .wb-stats { grid-template-columns: 1fr; }
  .wb-excerpt { font-size: 16px; }
}

/* ---------- Family tree ---------- */
.tl.t { stroke: var(--tree-line); stroke-width: 2.4; opacity: 1; }
.tl.t.couple { stroke-width: 2; }
.tl-dot { fill: var(--tree-line); }
.ring .ring-bg { fill: var(--page); stroke: var(--tree-line); stroke-width: 2; }
.ring .ring-o { fill: none; stroke: var(--tree-line); stroke-width: 1.6; }
.rm-node.tree .halo { fill: none; stroke: none; }
.rm-node.tree.sel .halo { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: none; }
.rm-node.tree .t-fill { filter: brightness(1.12); }
.rm-node.tree .t-sil { fill: rgba(255, 255, 255, .92); pointer-events: none; }
.rm-node.tree .tn-label rect { fill: var(--raise); stroke: var(--line); stroke-width: 1; }
.rm-node.tree .tn-label text { fill: var(--text); font: 600 12.5px var(--font-ui); pointer-events: none; }
.rm-node.tree.loose { opacity: .75; }
.rm-legend i.round { border-radius: 50%; }
.rm-legend .lg-ring { width: 16px; height: 16px; }

/* ================================================================ v1.5 Maps */
.mapv { flex: 1; min-height: 0; min-width: 0; display: grid; grid-template-columns: 230px minmax(0, 1fr) 300px; position: relative; }
.mv-side { border-right: 1px solid var(--line-soft); background: var(--bg-2); overflow: auto; padding: 14px 12px 20px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.mv-sec { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 2px; min-height: 30px; }
.mv-sec .icon-btn { width: 28px; height: 28px; }
.mv-list { display: flex; flex-direction: column; gap: 2px; }
.mv-map { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; text-align: left; font-size: 13.5px; color: var(--text-2); min-width: 0; }
.mv-map:hover { background: var(--surface-2); color: var(--text); }
.mv-map.on { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.mv-thumb { width: 38px; height: 28px; border-radius: 5px; flex: none; background: var(--surface-2) center/cover; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.mv-mtitle { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-new { align-self: flex-start; margin: 4px 0 6px 4px; }
.mv-layers { display: flex; flex-direction: column; gap: 2px; }
.mv-layer { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 9px; }
.mv-layer .icon-btn { width: 28px; height: 28px; flex: none; }
.mv-layer .icon-btn svg { width: 15px; height: 15px; }
.mv-layer.on { background: var(--accent-soft); }
.mv-layer.off .mv-lname { opacity: .45; text-decoration: line-through; }
.mv-lname { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 6px; font-size: 13px; text-align: left; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mv-lname small { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.mv-lrename { flex: 1; min-width: 0; font: 500 13px var(--font-ui); padding: 5px 7px; border: 0; border-radius: 7px; outline: none; background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--accent); }
.mv-layer-note { text-align: left !important; font-size: 11.5px; padding: 4px 6px; }
.mv-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.mv-top { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); min-height: 54px; }
.mv-top .btn.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mv-crumbs { display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; font-size: 14px; white-space: nowrap; }
.mv-crumbs button { color: var(--text-2); padding: 3px 6px; border-radius: 6px; }
.mv-crumbs button:hover { background: var(--surface-2); color: var(--text); }
.mv-crumbs b { font-family: var(--font-display); font-weight: 400; font-size: 21px; overflow: hidden; text-overflow: ellipsis; }
.mv-crumbs .sep { color: var(--muted); }
.mv-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--cork); background-image: radial-gradient(color-mix(in srgb, var(--text) 8%, transparent) 1px, transparent 1.2px); background-size: 22px 22px; touch-action: none; }
.mv-svg { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; cursor: grab; }
.mv-svg:active { cursor: grabbing; }
.mv-stage.tool-pin .mv-svg, .mv-stage.tool-label .mv-svg, .mv-stage.tool-region .mv-svg, .mv-stage.tool-route .mv-svg, .mv-stage.tool-ruler .mv-svg { cursor: crosshair; }
.mv-svg #mvImg { filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .18)); }
.mv-svg .mk { cursor: pointer; }
.mv-stage:not(.tool-select) .mk { pointer-events: none; }
.mv-svg .mk.locked { pointer-events: none; }
.mv-svg .mk.sel .pin-body { stroke: var(--accent); stroke-width: 3.5; }
.mv-svg .mk.sel > path:not(.hit), .mv-svg .mk.sel text { filter: drop-shadow(0 0 3px color-mix(in srgb, var(--accent) 90%, transparent)); }
.mv-svg .mk:hover .pin-body { filter: brightness(1.08); }
.mv-h { fill: #fff; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; cursor: move; }
.mv-hmid { fill: var(--accent); stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: copy; opacity: .85; }
.mv-zoom { top: 14px; }
.mv-hint { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 999px; background: color-mix(in srgb, var(--raise) 94%, transparent); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line-soft); font-size: 13px; color: var(--text-2); max-width: calc(100% - 120px); flex-wrap: wrap; justify-content: center; }
.mv-hint .btn[disabled] { opacity: .45; pointer-events: none; }
.mv-scalebar { position: absolute; left: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 3px; padding: 6px 10px 6px; border-radius: 9px; background: color-mix(in srgb, var(--raise) 90%, transparent); box-shadow: var(--shadow-sm); font-size: 11.5px; font-weight: 600; color: var(--text); }
.mv-scalebar i { display: block; height: 6px; border: 2px solid var(--text); border-top: 0; }
.mv-tools { display: flex; gap: 4px; justify-content: center; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line-soft); background: var(--bg-2); overflow-x: auto; }
.mv-tool { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 62px; padding: 7px 8px 6px; border-radius: 11px; font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.mv-tool svg { width: 20px; height: 20px; }
.mv-tool:hover { background: var(--surface-2); color: var(--text); }
.mv-tool.on { background: var(--accent); color: var(--accent-ink); }
.mv-detail { border-left: 1px solid var(--line-soft); background: var(--surface); overflow: auto; min-height: 0; }
.mvd { padding: 16px 16px 30px; display: flex; flex-direction: column; gap: 14px; }
.mvd-h { display: flex; align-items: center; gap: 10px; }
.mvd-h b { flex: 1; font-size: 15px; }
.mvd-h .icon-btn { width: 30px; height: 30px; }
.mvd-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.mvd-ic svg { width: 17px; height: 17px; }
.mvd-sec { display: flex; flex-direction: column; gap: 8px; }
.mvd-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mvd-row b { flex: 1; font-size: 14px; }
.mvd .field { margin: 0; }
.mvd-del { align-self: flex-start; color: var(--danger); }
.mvd-place { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.mvd-pcard { display: flex; align-items: center; gap: 12px; }
.mvd-pcard b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 22px; line-height: 1.1; }
.mvd-pcard span { font-size: 12.5px; color: var(--muted); }
.mvd-notes { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.mvd-scenes { display: flex; flex-direction: column; gap: 2px; }
.mvd-scenes button, .mj-sc button { display: flex; align-items: baseline; gap: 8px; text-align: left; padding: 6px 8px; border-radius: 8px; font-size: 13px; color: var(--text); }
.mvd-scenes button:hover, .mj-sc button:hover { background: var(--surface-2); }
.mvd-scenes .tnum { color: var(--muted); font-size: 11.5px; min-width: 16px; }
.mvd-scenes small { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.mv-icons { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.mv-icon { aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-soft); }
.mv-icon svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mv-icon:hover { color: var(--text); background: var(--surface-2); }
.mv-icon.on { color: var(--accent-ink); background: var(--accent); box-shadow: none; }
.mv-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.mv-color { width: 26px; height: 26px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.mv-color.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.mv-seg { width: 100%; } .mv-seg button { flex: 1; }
.mv-speeds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mv-speeds label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--muted); }
.mv-speeds .input { padding: 8px 10px; }
.mv-scale-line, .mv-counts { margin: 0; font-size: 13.5px; color: var(--text-2); }
.mv-scale-line b { color: var(--text); }
.mv-scale-in { display: flex; gap: 8px; } .mv-scale-in .input { flex: 1; } .mv-scale-in .seg { width: auto; }
.mv-measure, .mv-len { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.mv-measure > b, .mv-len > b { font-family: var(--font-display); font-weight: 400; font-size: 32px; line-height: 1; }
.mv-tt { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.mv-tt b { color: var(--text); font-weight: 600; }
.linkish { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.mv-empty { flex: 1; display: grid; place-items: center; padding: 24px; background: var(--cork); }
.mv-empty-card { max-width: 440px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 28px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line-soft); }
.mv-empty-card h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 32px; }
.mv-empty-card p { margin: 0; color: var(--text-2); line-height: 1.55; font-size: 14.5px; }
.mv-empty-ic { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.mv-empty-ic svg { width: 28px; height: 28px; }
/* journeys */
.mj-up { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.mj-up b { color: var(--text); }
.mj-up input { width: 100%; accent-color: var(--accent); }
.mj-char { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 3px 0 0 var(--jc); }
.mj-head { display: flex; align-items: center; gap: 10px; }
.mj-head b { flex: 1; font-size: 14.5px; }
.mj-head .icon-btn { width: 28px; height: 28px; }
.mj-pov { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--text-2); }
.mj-pov input { accent-color: var(--jc); }
.mj-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mj-steps li { display: flex; gap: 10px; align-items: flex-start; }
.mj-steps li.off { opacity: .55; }
.mj-n { flex: none; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: var(--jc); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.mj-steps li > div { min-width: 0; flex: 1; }
.mj-steps b { font-size: 13.5px; }
.mj-steps small { color: var(--muted); }
.mj-sc { display: flex; flex-direction: column; }
.mj-sc button { padding: 3px 6px; font-size: 12.5px; color: var(--text-2); margin-left: -6px; }
.mj-warn { display: flex; flex-direction: column; gap: 6px; }
.mj-warn p { margin: 0; display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 1.45; color: var(--warn); padding: 8px 10px; border-radius: 9px; background: color-mix(in srgb, var(--warn) 10%, transparent); }
.mj-warn svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
/* place picker + cast */
.pp-search { margin: 0 0 10px; }
.pp-list { display: flex; flex-direction: column; gap: 2px; max-height: min(52vh, 440px); overflow: auto; }
.pp-g { padding: 8px 6px 4px; }
.pp-row { display: flex; align-items: center; gap: 12px; padding: 7px 8px; border-radius: 10px; text-align: left; color: var(--text); }
.pp-row:hover, .pp-row.on { background: var(--surface-2); }
.pp-row > span:not(.av) { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pp-row b { font-weight: 600; font-size: 14px; }
.pp-row small { font-size: 12px; color: var(--muted); }
.pp-row em { font-style: normal; font-size: 12px; color: var(--accent); font-weight: 700; }
.pp-row > svg { width: 18px; height: 18px; color: var(--accent); }
.pp-new { color: var(--accent); } .pp-new svg, .pp-clear svg { width: 18px; height: 18px; margin: 0 6px; }
.pp-clear { color: var(--text-2); }
.cast-list { display: flex; flex-direction: column; gap: 4px; }
.cast-row { display: flex; align-items: center; gap: 12px; padding: 6px 4px; flex-wrap: wrap; }
.cast-name { flex: 1; min-width: 120px; display: flex; flex-direction: column; }
.cast-name b { font-size: 14px; font-weight: 600; } .cast-name small { font-size: 12px; color: var(--muted); }
.cast-seg button { padding-inline: 10px; }
.k-where.set { color: var(--text); }
.k-where span { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-cast { padding: 0 9px 0 7px; }
.cx-place { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); margin-top: -4px; }
.cx-place svg { width: 12px; height: 12px; color: var(--accent); }
.o-pl { min-width: 130px; }
.o-place { padding: 5px 8px; border-radius: 7px; font-size: 13.5px; color: var(--text); text-align: left; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-place:hover { background: var(--surface-2); }
.o-place.empty { color: var(--muted); }
@media (max-width: 1100px) { .mapv { grid-template-columns: 200px minmax(0, 1fr) 270px; } }
@media (max-width: 860px) {
  .mapv { grid-template-columns: minmax(0, 1fr); }
  .mv-side { position: absolute; z-index: 6; left: 0; top: 0; bottom: 0; width: min(280px, 86vw); transform: translateX(-102%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg, 0 10px 40px rgba(0,0,0,.25)); }
  .mapv.side-open .mv-side { transform: none; }
  .mv-detail { position: absolute; z-index: 5; left: 0; right: 0; bottom: 64px; max-height: 52%; border-left: 0; border-top: 1px solid var(--line-soft); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, .14); display: none; }
  .mv-detail.has { display: block; }
  .mv-tool { min-width: 54px; font-size: 10.5px; }
  .mv-hint { top: auto; bottom: 14px; max-width: calc(100% - 28px); }
  .mv-scalebar { bottom: 64px; }
}

/* avatars never stretch, whatever list they're in */
.av, .mention .av, .pp-row > .av { flex: none !important; }

/* Linked from Mapfold */
.mf-world { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 16px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft); }
.mf-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mf-head > div { display: flex; flex-direction: column; min-width: 0; }
.mf-list { display: flex; flex-direction: column; }
.mf-map { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-top: 1px solid var(--line-soft); font-size: 14px; }
.mf-map span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-tag { font-style: normal; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--line-soft); color: var(--text-2); }
.mf-new, .mf-update { background: color-mix(in srgb, var(--accent, #c9a227) 22%, transparent); color: var(--text); }
.mf-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 18px 8px; }
.mf-empty h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 26px; }
.mf-badge { padding: 10px 12px; border-radius: 12px; background: var(--surface-2, var(--line-soft)); }
.mv-empty-card .btn-ghost { margin-top: -4px; }

/* ---------------------------------------------------------------- Reader preview */
.rd {
  --rd-page: #fbf8f1; --rd-ink: #2b2620; --rd-muted: #8f8676; --rd-desk: #e6e0d4; --rd-desk-2: #d6cebf; --rd-chrome: rgba(255, 252, 246, .82); --rd-chrome-ink: #3b352c; --rd-edge: #e3dccd; --rd-accent: #9a6b3f;
  position: fixed; inset: 0; z-index: 56; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, var(--rd-desk), var(--rd-desk-2)); color: var(--rd-chrome-ink);
  opacity: 0; transform: scale(.985); transition: opacity .28s var(--ease), transform .36s var(--ease);
  -webkit-user-select: none; user-select: none; touch-action: none;
}
.rd.in { opacity: 1; transform: none; }
.rd.out { opacity: 0; transform: scale(.99); }
.rd[data-rtheme="sepia"] { --rd-page: #f4e8d2; --rd-ink: #4a3a28; --rd-muted: #9a8466; --rd-desk: #d9c9ab; --rd-desk-2: #c6b393; --rd-chrome: rgba(246, 236, 216, .84); --rd-chrome-ink: #4a3a28; --rd-edge: #e2d2b4; --rd-accent: #8a5a2b; }
.rd[data-rtheme="night"] { --rd-page: #1f1e1c; --rd-ink: #d8d1c4; --rd-muted: #8b8478; --rd-desk: #121212; --rd-desk-2: #0a0a0a; --rd-chrome: rgba(28, 27, 25, .82); --rd-chrome-ink: #ddd6c9; --rd-edge: #2b2a27; --rd-accent: #d6a873; }
body.reading { overflow: hidden; }

.rd-top, .rd-bottom { position: relative; z-index: 3; display: flex; align-items: center; gap: 6px; padding: calc(10px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 10px max(14px, env(safe-area-inset-left, 0px)); transition: opacity .3s var(--ease), transform .3s var(--ease); }
.rd-bottom { flex-direction: column; align-items: stretch; gap: 4px; padding: 6px max(22px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)); width: min(720px, 100%); justify-self: center; }
.rd.calm .rd-top { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.rd.calm .rd-bottom { opacity: 0; transform: translateY(8px); pointer-events: none; }
.rd-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--rd-chrome-ink); background: var(--rd-chrome); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), inset 0 0 0 1px color-mix(in srgb, var(--rd-chrome-ink) 10%, transparent); transition: transform .15s var(--ease); }
.rd-btn:active { transform: scale(.94); }
.rd-btn svg { width: 18px; height: 18px; }
.rd-aa { font-family: var(--font-display); font-size: 19px; letter-spacing: -.01em; }
.rd-where { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.2; }
.rd-where b { font-family: var(--font-display); font-weight: 400; font-size: 19px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-where span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--rd-muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 13px; }
.rd-range { height: 26px; }
.rd-range::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--rd-accent) var(--p, 0%), color-mix(in srgb, var(--rd-chrome-ink) 16%, transparent) var(--p, 0%)) !important; }
.rd-range::-moz-range-progress { background: var(--rd-accent); }
.rd-range::-webkit-slider-thumb { box-shadow: 0 1px 4px rgba(0, 0, 0, .3), inset 0 0 0 1.5px var(--rd-accent) !important; }
.rd-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--rd-muted); }

.rd-stage { position: relative; display: grid; place-items: center; min-height: 0; cursor: default; }
.rd-book { position: relative; perspective: 2800px; transition: transform .45s var(--ease); --shift: 0; }
.rd-book.closed { transform: translateX(calc(var(--pw) * -.5)); }
.rd-book.sliding { transition: none; transform: translateX(calc(var(--pw) * -.5 * var(--shift))); }
.rd-book.fade { opacity: .25; transition: opacity .12s; }
.rd-book.bump-r { animation: rd-bump-r .35s var(--ease); }
.rd-book.bump-l { animation: rd-bump-l .35s var(--ease); }
@keyframes rd-bump-r { 40% { translate: -6px 0; } }
@keyframes rd-bump-l { 40% { translate: 6px 0; } }
.rd-half { position: absolute; top: 0; height: 100%; width: var(--pw); }
.rd-left { left: 0; }
.rd-right { left: var(--pw); }
.rd-solo { left: 0; width: 100%; }

/* a page */
.rd-page { position: absolute; inset: 0; overflow: hidden; background: var(--rd-page); color: var(--rd-ink); }
.rd-half .rd-page, .rd-face .rd-page { box-shadow: 0 28px 50px -24px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .08); }
.rd-page.right { border-radius: 2px 6px 6px 2px; background-image: linear-gradient(90deg, rgba(0, 0, 0, .13), rgba(0, 0, 0, .04) 3%, transparent 9%); box-shadow: 0 28px 50px -24px rgba(0, 0, 0, .45), 1px 0 0 var(--rd-edge), 2px 0 0 color-mix(in srgb, var(--rd-edge) 70%, #000 6%), 3px 0 0 var(--rd-edge), 4px 1px 2px rgba(0, 0, 0, .12); }
.rd-page.left { border-radius: 6px 2px 2px 6px; background-image: linear-gradient(270deg, rgba(0, 0, 0, .13), rgba(0, 0, 0, .04) 3%, transparent 9%); box-shadow: 0 28px 50px -24px rgba(0, 0, 0, .45), -1px 0 0 var(--rd-edge), -2px 0 0 color-mix(in srgb, var(--rd-edge) 70%, #000 6%), -3px 0 0 var(--rd-edge), -4px 1px 2px rgba(0, 0, 0, .12); }
.rd-page.solo { border-radius: 4px 8px 8px 4px; background-image: linear-gradient(90deg, rgba(0, 0, 0, .07), transparent 4%); }
.rd[data-rtheme="night"] .rd-page.right, .rd[data-rtheme="night"] .rd-page.left { background-blend-mode: normal; }
.rd-page.blank.left, .rd-page.blank.right { background-color: var(--rd-page); }
.rd-run { position: absolute; top: calc(var(--padt) * .42); left: var(--padx); right: var(--padx); text-align: center; font: 600 9.5px/1 var(--font-ui); letter-spacing: .22em; text-transform: uppercase; color: var(--rd-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-folio { position: absolute; bottom: calc(var(--padb) * .38); left: 0; right: 0; text-align: center; font: 12px/1 var(--rd-font); color: var(--rd-muted); }
.rd-body { position: absolute; left: var(--padx); top: var(--padt); width: var(--cw); height: var(--ch); overflow: hidden; }

/* the text, flowed into one column per page */
.rd-flow, .rd-measure { font-family: var(--rd-font); font-size: var(--rd-size); line-height: 1.62; }
.rd-flow { width: var(--cw); height: var(--ch); column-width: var(--cw); column-gap: 60px; column-fill: auto; text-align: justify; -webkit-hyphens: auto; hyphens: auto; widows: 2; orphans: 2; overflow-wrap: break-word; font-optical-sizing: auto; }
.rd-measure { position: absolute; left: -99999px; top: 0; width: var(--cw); height: var(--ch); overflow: hidden; visibility: hidden; pointer-events: none; }
.rd-flow p { margin: 0; text-indent: 1.4em; }
.rd-flow .rd-ch + p, .rd-flow .rd-sep + p, .rd-flow h2 + p, .rd-flow h3 + p, .rd-flow figure + p, .rd-flow blockquote + p, .rd-flow ul + p, .rd-flow ol + p { text-indent: 0; }
.rd-ch { padding-top: calc(var(--ch) * .16); margin-bottom: 2.4em; text-align: center; break-inside: avoid; break-after: avoid; }
.rd-kicker { margin: 0 0 .9em !important; text-indent: 0 !important; text-align: center; font: 600 .62em/1.2 var(--font-ui); letter-spacing: .28em; text-transform: uppercase; color: var(--rd-muted); }
.rd-ch-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 2.15em; line-height: 1.08; letter-spacing: -.01em; text-wrap: balance; color: var(--rd-ink); }
.rd-ch::after { content: ''; display: block; width: 36px; height: 1px; margin: 1.3em auto 0; background: var(--rd-muted); opacity: .6; }
.rd-flow:not(.rd-poem):not(.rd-journal) .rd-ch + p::first-letter { float: left; font-family: var(--font-display); font-size: 3.6em; line-height: .82; padding: .06em .09em 0 0; color: var(--rd-accent); }
.rd-sep { text-indent: 0 !important; text-align: center !important; margin: .9em 0 !important; color: var(--rd-muted); letter-spacing: .4em; break-after: avoid; }
.rd-flow h2:not(.rd-ch-title), .rd-flow h3 { margin: 1.4em 0 .7em; text-indent: 0; text-align: center; font-family: var(--font-display); font-weight: 400; font-size: 1.35em; line-height: 1.2; break-after: avoid; break-inside: avoid; }
.rd-flow blockquote { margin: .8em 1.4em; font-style: italic; }
.rd-flow blockquote p { text-indent: 0; }
.rd-flow ul, .rd-flow ol { margin: .6em 0 .6em 1.4em; padding: 0; text-align: left; }
.rd-flow strong { font-weight: 600; }
.rd-flow figure { margin: 1em auto; break-inside: avoid; text-align: center; max-width: 100%; }
.rd-flow figure img { display: block; width: 100%; height: auto; max-height: calc(var(--ch) - 4em); object-fit: contain; border-radius: 2px; }
.rd-flow figure[data-cap]::after { content: attr(data-cap); display: block; margin-top: .5em; font-size: .8em; font-style: italic; color: var(--rd-muted); text-indent: 0; }
.rd-flow figure.missing { display: none; }
.rd-poem { text-align: left; -webkit-hyphens: manual; hyphens: manual; }
.rd-poem p { text-indent: 0 !important; }
.rd-poem .rd-scene-title, .rd-journal .rd-scene-title { margin-top: 1.6em; }
.rd-journal p { text-indent: 0; margin-bottom: .6em; }
.rd-journal .rd-scene-title { font-family: var(--font-ui); font-size: .72em; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--rd-muted); }

/* front matter */
.rd-front { text-align: left; }
.rd-blurb { padding-top: calc(var(--ch) * .14); }
.rd-blurb-text p { text-indent: 0 !important; margin-bottom: .9em; font-style: italic; font-size: 1.04em; line-height: 1.6; text-align: left; }
.rd-blurb-text p:first-child::first-letter { font-family: var(--font-display); font-style: normal; font-size: 1.5em; }
.rd-toc { padding-top: calc(var(--ch) * .1); }
.rd-toc ol { list-style: none; margin: 1.4em 0 0; padding: 0; }
.rd-toc li { display: flex; align-items: baseline; gap: 8px; padding: .38em 0; cursor: pointer; break-inside: avoid; text-align: left; }
.rd-toc li span { max-width: 78%; }
.rd-toc li i { flex: 1; border-bottom: 1px dotted color-mix(in srgb, var(--rd-muted) 70%, transparent); transform: translateY(-.3em); }
.rd-toc li b { font-weight: 400; color: var(--rd-muted); font-size: .9em; }
.rd-toc li:hover span { color: var(--rd-accent); }
.rd-titlepage { display: grid; place-items: center; text-align: center; padding: 12% 12%; }
.rd-titlepage h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(30px, calc(var(--pw) * .085), 56px); line-height: 1.04; letter-spacing: -.015em; text-wrap: balance; }
.rd-tp-sub { margin: .6em 0 0; font-family: var(--font-display); font-style: italic; font-size: clamp(16px, calc(var(--pw) * .04), 24px); color: var(--rd-muted); }
.rd-orn { display: block; margin: 1.4em 0; font-size: 20px; color: var(--rd-accent); }
.rd-tp-author { margin: 0; font: 600 11px/1.3 var(--font-ui); letter-spacing: .3em; text-transform: uppercase; }
.rd-cover { background: var(--cv-bg) !important; color: var(--cv-fg); }
.rd-cover.has-img { background: #000 !important; }
.rd-cover-img { position: absolute; inset: 0; background: center/cover no-repeat; }
.rd-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0, 0, 0, .28), rgba(255, 255, 255, .06) 1.6%, rgba(0, 0, 0, .1) 3%, transparent 7%), linear-gradient(135deg, rgba(255, 255, 255, .07), transparent 40%); pointer-events: none; }
.rd-cover-frame { position: absolute; inset: 6.5%; border: 1px solid var(--cv-line); opacity: .55; }
.rd-cover-in { position: absolute; inset: 11% 12%; display: flex; flex-direction: column; justify-content: space-between; text-align: center; }
.rd-cover-in h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(32px, calc(var(--pw) * .1), 64px); line-height: 1; letter-spacing: -.015em; text-wrap: balance; overflow-wrap: anywhere; }
.rd-cover-sub { margin: .6em 0 0; font-family: var(--font-display); font-style: italic; font-size: clamp(15px, calc(var(--pw) * .042), 24px); opacity: .8; }
.rd-cover-kicker, .rd-cover-author { font: 600 10px/1.3 var(--font-ui); letter-spacing: .3em; text-transform: uppercase; color: var(--cv-line); }

/* the turning leaf */
.rd-leaf { position: absolute; top: 0; height: 100%; width: var(--pw); transform-style: preserve-3d; will-change: transform; z-index: 2; --sf: 0; --sb: 0; --gl: 0; }
.rd-leaf.on-right { left: var(--pw); transform-origin: 0 50%; }
.rd-leaf.on-left { left: 0; transform-origin: 100% 50%; }
.rd-leaf.solo { left: 0; width: 100%; transform-origin: 0 50%; }
.rd-face { position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.rd-face.back { transform: rotateY(180deg); }
.rd-face::after { content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; }
.rd-leaf.on-right .front::after, .rd-leaf.solo .front::after { background: linear-gradient(90deg, rgba(0, 0, 0, calc(var(--sf) * .9)), rgba(0, 0, 0, calc(var(--sf) * .35)) 40%, rgba(255, 255, 255, calc(var(--gl) * .10)) 85%, rgba(0, 0, 0, calc(var(--sf) * .5))); }
.rd-leaf.on-right .back::after, .rd-leaf.solo .back::after { background: linear-gradient(270deg, rgba(0, 0, 0, calc(var(--sb) * .9)), rgba(0, 0, 0, calc(var(--sb) * .3)) 45%, rgba(255, 255, 255, calc(var(--gl) * .08)) 88%, transparent); }
.rd-leaf.on-left .front::after { background: linear-gradient(270deg, rgba(0, 0, 0, calc(var(--sf) * .9)), rgba(0, 0, 0, calc(var(--sf) * .35)) 40%, rgba(255, 255, 255, calc(var(--gl) * .10)) 85%, rgba(0, 0, 0, calc(var(--sf) * .5))); }
.rd-leaf.on-left .back::after { background: linear-gradient(90deg, rgba(0, 0, 0, calc(var(--sb) * .9)), rgba(0, 0, 0, calc(var(--sb) * .3)) 45%, rgba(255, 255, 255, calc(var(--gl) * .08)) 88%, transparent); }
.rd-leaf .rd-page { box-shadow: 0 0 calc(var(--gl) * 40px) rgba(0, 0, 0, calc(var(--gl) * .35)); }
.rd-cast { position: absolute; top: 0; height: 100%; width: var(--pw); pointer-events: none; z-index: 1; opacity: 0; }
.rd-cast[data-side="right"] { left: var(--pw); background: linear-gradient(90deg, rgba(0, 0, 0, .34), rgba(0, 0, 0, .1) 30%, transparent 65%); }
.rd-cast[data-side="left"] { left: 0; background: linear-gradient(270deg, rgba(0, 0, 0, .34), rgba(0, 0, 0, .1) 30%, transparent 65%); }
.rd-cast[data-side="solo"] { left: 0; width: 100%; background: linear-gradient(90deg, rgba(0, 0, 0, .22), transparent 45%); }

/* panels */
.rd-panel { position: absolute; z-index: 5; top: calc(60px + env(safe-area-inset-top, 0px)); right: max(14px, env(safe-area-inset-right, 0px)); width: min(320px, calc(100vw - 28px)); max-height: calc(100% - 140px); overflow: auto; padding: 14px; border-radius: 18px; background: var(--rd-chrome); color: var(--rd-chrome-ink); -webkit-backdrop-filter: blur(22px) saturate(1.3); backdrop-filter: blur(22px) saturate(1.3); box-shadow: 0 24px 60px -18px rgba(0, 0, 0, .45), inset 0 0 0 1px color-mix(in srgb, var(--rd-chrome-ink) 10%, transparent); animation: pop .18s var(--ease); touch-action: pan-y; }
.rd-panel-h { margin: 4px 2px 8px; font: 700 10.5px/1 var(--font-ui); letter-spacing: .18em; text-transform: uppercase; color: var(--rd-muted); }
.rd-panel-h:not(:first-child) { margin-top: 16px; }
.rd-toc-list { display: flex; flex-direction: column; }
.rd-toc-list button { display: flex; align-items: baseline; gap: 10px; padding: 9px 10px; border-radius: 10px; text-align: left; font-family: var(--rd-font); font-size: 15px; color: inherit; }
.rd-toc-list button span { flex: 1; min-width: 0; }
.rd-toc-list button b { font: 500 12px var(--font-ui); color: var(--rd-muted); }
.rd-toc-list button:hover { background: color-mix(in srgb, var(--rd-chrome-ink) 7%, transparent); }
.rd-toc-list button.on { background: color-mix(in srgb, var(--rd-accent) 16%, transparent); }
.rd-size { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px; border-radius: 12px; background: color-mix(in srgb, var(--rd-chrome-ink) 6%, transparent); }
.rd-size button { flex: 1; height: 38px; border-radius: 9px; font-family: var(--font-display); color: inherit; }
.rd-size button:first-child { font-size: 15px; }
.rd-size button:last-child { font-size: 24px; }
.rd-size button:hover { background: color-mix(in srgb, var(--rd-chrome-ink) 8%, transparent); }
.rd-size span { min-width: 34px; text-align: center; font-size: 12px; color: var(--rd-muted); }
.rd-seg { display: flex; flex-direction: column; gap: 4px; }
.rd-seg button { padding: 9px 12px; border-radius: 10px; text-align: left; font-size: 16px; color: inherit; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rd-chrome-ink) 10%, transparent); }
.rd-seg button.on { box-shadow: inset 0 0 0 1.5px var(--rd-accent); background: color-mix(in srgb, var(--rd-accent) 10%, transparent); }
.rd-themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rd-sw { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px 8px; border-radius: 12px; font-size: 11.5px; color: inherit; }
.rd-sw i { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font: italic 18px var(--font-display); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.rd-sw.sw-paper i { background: #fbf8f1; color: #2b2620; }
.rd-sw.sw-sepia i { background: #f4e8d2; color: #4a3a28; }
.rd-sw.sw-night i { background: #1f1e1c; color: #d8d1c4; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); }
.rd-sw.on i { box-shadow: 0 0 0 2px var(--rd-page), 0 0 0 4px var(--rd-accent); }

@media (max-width: 600px) {
  .rd-top { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  .rd-btn { width: 38px; height: 38px; }
  .rd-where b { font-size: 17px; }
}
