/* Unblockifier — one stylesheet, no build step. */

/* ---------------------------------------------------------------- themes --
   Dark is the default. The server writes data-theme on <html> from a cookie,
   so the correct palette is present in the first paint and the page never
   flashes the wrong one. */

:root,
[data-theme="dark"] {
  --bg:        #0f141d;
  --bg2:       #141b26;
  --panel:     #1a2231;
  --panel2:    #202a3b;
  --line:      #27313f;
  --line2:     #35425a;
  --text:      #e8ecf3;
  --muted:     #8f9bb0;
  --faint:     #5f6b80;
  --accent:    #e0a95f;
  --accent-dk: #b8853f;
  --accent-ink:#21180a;
  --link:      #6aa9ff;
  --paper:     #f8f4ec;
  --paper-ink: #221f19;
  --paper-line:#ded5c4;
  --paper-soft:#6d6455;
  --ok:        #63d69b;
  --warn:      #ffc86b;
  --err:       #ff8f8f;
  --shadow:    rgba(0,0,0,.45);
  --hover:     rgba(255,255,255,.02);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg:        #f4f1ea;
  --bg2:       #eae5da;
  --panel:     #fffdf8;
  --panel2:    #f1ece1;
  --line:      #ded7c8;
  --line2:     #c9c0ad;
  --text:      #23201a;
  --muted:     #5f5949;
  --faint:     #8b8474;
  --accent:    #a86e1c;
  --accent-dk: #8a5a14;
  --accent-ink:#fffdf8;
  --link:      #1f5fb5;
  --paper:     #fffdf8;
  --paper-ink: #23201a;
  --paper-line:#e2dbcc;
  --paper-soft:#6d6455;
  --ok:        #1d7a4c;
  --warn:      #8a5a14;
  --err:       #a8322f;
  --shadow:    rgba(60,50,30,.18);
  --hover:     rgba(0,0,0,.025);
  color-scheme: light;
}

:root {
  --radius:    9px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 .9rem; }

hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* ------------------------------------------------------------------ shell */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex: 0 0 232px;
  background: var(--bg2);
  border-right: 1px solid var(--line);
  padding: 1rem .75rem 2rem;
  display: flex; flex-direction: column; gap: .25rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand {
  display: block;                 /* not flex: the dot belongs to the word */
  padding: .35rem .55rem 1rem; font-weight: 700; letter-spacing: -.01em;
  color: var(--text); font-size: 1.05rem;
}
.brand:hover { text-decoration: none; }
.brand .dot { color: var(--accent); margin-left: 0; }

.side-project {
  padding: .5rem .55rem .75rem; margin-bottom: .5rem;
  border-bottom: 1px solid var(--line);
}
.side-project .t { font-weight: 650; font-size: .95rem; }
.side-project .s { color: var(--faint); font-size: .8rem; }

.side-label {
  color: var(--faint); font-size: .7rem; text-transform: uppercase;
  letter-spacing: .08em; padding: .9rem .55rem .3rem; font-weight: 700;
}

.nav-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .42rem .55rem; border-radius: 7px;
  color: var(--muted); font-size: .9rem;
}
.nav-item:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav-item.on { background: var(--panel2); color: var(--text); font-weight: 600; }
.nav-item .ic { width: 1.1rem; text-align: center; color: var(--faint); font-size: .95rem; }
.nav-item.on .ic { color: var(--accent); }
.nav-item .n { margin-left: auto; color: var(--faint); font-size: .78rem; font-variant-numeric: tabular-nums; }

.main { flex: 1 1 auto; min-width: 0; padding: 1.5rem 2rem 5rem; max-width: 1180px; }
/* The manuscript is the one page that wants the whole window. */
body.writing .main { max-width: none; }

.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.topbar h1 { margin: 0; flex: 1 1 auto; }
.topbar .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.crumb { color: var(--faint); font-size: .85rem; margin-bottom: .3rem; }
.crumb a { color: var(--muted); }

/* ----------------------------------------------------------------- panels */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.1rem;
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel-head {
  display: flex; align-items: center; gap: .75rem; margin-bottom: .85rem;
}
.panel-head h2, .panel-head h3 { margin: 0; flex: 1 1 auto; }

.grid { display: grid; gap: 1rem; }
.grid.two   { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }

.split { display: grid; grid-template-columns: 1fr 340px; gap: 1.1rem; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line2); border-radius: 7px;
  padding: .45rem .85rem; font: inherit; font-size: .875rem; font-weight: 550;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.danger:hover { background: var(--err); color: var(--panel); }
.btn.small { padding: .25rem .55rem; font-size: .8rem; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ----------------------------------------------------------------- inputs */

label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .25rem; font-weight: 600; }

/* Every text-like input, by exclusion rather than by listing them: a new input
   type should inherit the styling instead of quietly rendering unstyled. */
input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=hidden]):not([type=range]):not([type=color]),
select, textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line2); border-radius: 7px;
  padding: .48rem .65rem; font: inherit; font-size: .9rem;
}
textarea { resize: vertical; min-height: 5rem; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-dk);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
select { 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) center, calc(100% - 10px) center;
         background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 1.8rem; }

.field { margin-bottom: .85rem; }
.field-row { display: flex; gap: .6rem; }
.field-row > * { flex: 1 1 0; }

.inline-form { display: flex; gap: .5rem; align-items: center; }
.inline-form input { flex: 1 1 auto; }

.check { display: flex; align-items: flex-start; gap: .5rem; margin-bottom: .5rem; font-size: .875rem; }
.check input { width: auto; margin-top: .22rem; flex: 0 0 auto; }
.check label { margin: 0; color: var(--text); font-weight: 500; font-size: .875rem; }
.check .hint { color: var(--faint); font-size: .8rem; display: block; font-weight: 400; }

/* ----------------------------------------------------------------- tables */

table.data { width: 100%; border-collapse: collapse; font-size: .885rem; }
table.data th {
  text-align: left; color: var(--faint); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; padding: .4rem .6rem; border-bottom: 1px solid var(--line);
  font-weight: 700; white-space: nowrap;
}
table.data td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--hover); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

/* ------------------------------------------------------------------ bits */

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .82rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt  { margin-top: 1rem; }
.mb0 { margin-bottom: 0; }

.pill {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line2);
  font-size: .74rem; color: var(--muted); white-space: nowrap;
}
.pill.accent { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: var(--accent-dk); color: var(--accent); }
.pill.ok   { background: color-mix(in srgb, var(--ok) 13%, transparent); border-color: var(--ok); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 13%, transparent); border-color: var(--warn); color: var(--warn); }
.pill.err  { background: color-mix(in srgb, var(--err) 13%, transparent); border-color: var(--err); color: var(--err); }

.tag {
  display: inline-block; padding: .05rem .45rem; border-radius: 5px;
  background: var(--bg); border: 1px solid var(--line2);
  font-size: .72rem; color: var(--muted); margin-right: .25rem;
}
.tag:hover { color: var(--text); text-decoration: none; }

.type-icon { color: var(--accent); font-size: .95rem; }

.flash {
  padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1.1rem;
  border: 1px solid var(--line2); background: var(--panel);
}
.flash.ok  { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 9%, transparent); }
.flash.err { border-color: var(--err); background: color-mix(in srgb, var(--err) 9%, transparent); }

.empty {
  text-align: center; padding: 2.5rem 1rem; color: var(--faint);
  border: 1px dashed var(--line2); border-radius: var(--radius);
}
.empty h3 { color: var(--muted); }

.stat { display: flex; flex-direction: column; gap: .1rem; }
.stat .v { font-size: 1.45rem; font-weight: 680; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--faint); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }

/* ------------------------------------------------------------ entity card */

.ent-card {
  display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .8rem .9rem; color: var(--text);
}
.ent-card:hover { border-color: var(--line2); text-decoration: none; background: var(--panel2); }
.ent-card .n { font-weight: 620; margin-bottom: .15rem; }
.ent-card .s { color: var(--muted); font-size: .84rem; }

/* -------------------------------------------------------------- timeline */

.tl-row {
  display: flex; align-items: center; gap: .75rem;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: .55rem .75rem; margin-bottom: .4rem;
}
.tl-row.sel { border-color: var(--accent-dk); background: var(--panel2); }
.tl-row .pos {
  flex: 0 0 2rem; text-align: center; color: var(--faint);
  font-variant-numeric: tabular-nums; font-size: .85rem; font-weight: 650;
}
.tl-row .nm { flex: 1 1 auto; min-width: 0; }
.tl-row .nm b { display: block; font-weight: 600; }
.tl-row .grip { cursor: grab; color: var(--faint); user-select: none; padding: 0 .2rem; }
.tl-row.drag { opacity: .45; }
.tl-row.over { border-color: var(--accent); }

/* --------------------------------------------------------------- state */

.state-list { list-style: none; padding: 0; margin: 0; }
.state-list li {
  padding: .45rem .6rem; border-left: 2px solid var(--line2);
  margin-bottom: .35rem; background: var(--bg); border-radius: 0 6px 6px 0;
  font-size: .88rem;
}
.state-list li.carried { border-left-color: var(--faint); color: var(--muted); }
.state-list li.here    { border-left-color: var(--accent); }
.state-list li .src { display: block; color: var(--faint); font-size: .74rem; margin-top: .15rem; }

/* ------------------------------------------------------------ manuscript */

.ms { display: grid; grid-template-columns: 250px 1fr; gap: 1.1rem; align-items: start; }
@media (max-width: 900px) { .ms { grid-template-columns: 1fr; } }

.binder { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
          padding: .75rem; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
.binder .ch { margin-bottom: .6rem; }
.binder .ch > .h { display: flex; align-items: center; gap: .3rem; font-weight: 650; font-size: .875rem;
                   padding: .25rem .3rem; }
.binder .ch > .h .t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.binder .sc { display: block; padding: .28rem .5rem .28rem 1.1rem; border-radius: 6px;
              color: var(--muted); font-size: .845rem; }
.binder .sc:hover { background: var(--panel2); color: var(--text); text-decoration: none; }
.binder .sc.on { background: var(--panel2); color: var(--accent); font-weight: 600; }
.binder .sc .w { float: right; color: var(--faint); font-size: .74rem; }

.editor-wrap { background: var(--paper); color: var(--paper-ink);
               border-radius: var(--radius); padding: 1.5rem 1.75rem; }
.editor-wrap textarea {
  width: 100%; min-height: 62vh; background: transparent; color: var(--paper-ink);
  border: 0; padding: 0; font: 17px/1.75 var(--serif); resize: vertical;
}
.editor-wrap textarea:focus { outline: none; box-shadow: none; }
.editor-head { display: flex; gap: .6rem; align-items: center; margin-bottom: .9rem;
               padding-bottom: .75rem; border-bottom: 1px solid var(--paper-line); }
.editor-head input.title {
  flex: 1 1 auto; background: transparent; border: 0; color: var(--paper-ink);
  font: 650 1.2rem/1.3 var(--sans); padding: 0;
}
.editor-head input.title:focus { outline: none; box-shadow: none; }
.editor-foot { display: flex; gap: .75rem; align-items: center; margin-top: .75rem;
               padding-top: .7rem; border-top: 1px solid var(--paper-line); color: var(--paper-soft); font-size: .82rem; }

.prose { font: 17px/1.75 var(--serif); }
.prose p { margin: 0 0 1.1rem; text-indent: 1.4em; }
.prose p:first-child { text-indent: 0; }
.prose h2, .prose h3 { font-family: var(--sans); margin: 1.6rem 0 .8rem; }
.prose blockquote { margin: 0 0 1rem; padding-left: 1rem; border-left: 3px solid var(--paper-line); color: var(--paper-soft); }
.prose hr.scene-break { border: 0; text-align: center; margin: 1.6rem 0; }
.prose hr.scene-break::before { content: "* * *"; color: var(--paper-soft); letter-spacing: .4em; }

.chip {
  display: inline; padding: .02em .28em; border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-dk);
  border-bottom: 1px dotted var(--accent-dk); text-decoration: none;
}
.chip:hover { background: color-mix(in srgb, var(--accent) 30%, transparent); text-decoration: none; }
.chip-dead { background: color-mix(in srgb, var(--paper-ink) 7%, transparent); color: var(--paper-soft); border-bottom-style: dashed; }

/* mention autocomplete */
.mention-pop {
  position: absolute; z-index: 60; background: var(--panel); border: 1px solid var(--line2);
  border-radius: 8px; box-shadow: 0 10px 32px var(--shadow);
  min-width: 230px; max-height: 260px; overflow-y: auto; padding: .25rem;
}
.mention-pop .it { display: flex; gap: .5rem; align-items: center; padding: .35rem .55rem;
                   border-radius: 6px; cursor: pointer; font-size: .87rem; }
.mention-pop .it.on { background: var(--panel2); }
.mention-pop .it .ty { margin-left: auto; color: var(--faint); font-size: .74rem; }

/* --------------------------------------------------------------- search */

.search-box { position: relative; }
.search-results { margin-top: .5rem; }
.search-group { color: var(--faint); font-size: .72rem; text-transform: uppercase;
                letter-spacing: .06em; margin: .9rem 0 .35rem; font-weight: 700; }
mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 .12em; }

/* ---------------------------------------------------------------- cast */

.cast-grid { display: flex; gap: 2px; flex-wrap: nowrap; }
.cast-cell { width: 13px; height: 18px; border-radius: 2px; background: var(--bg); border: 1px solid var(--line); }
.cast-cell.on { background: var(--accent); border-color: var(--accent); }

.bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* -------------------------------------------------------------- unlock */

.gate { max-width: 380px; margin: 14vh auto; padding: 0 1.25rem; }
.gate .panel { text-align: center; }
.gate h1 { font-size: 1.35rem; }

/* -------------------------------------------------------------- mobile */

@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static;
             border-right: 0; border-bottom: 1px solid var(--line);
             flex-direction: row; flex-wrap: wrap; gap: .2rem; padding: .6rem; }
  .sidebar .side-label { display: none; }
  .sidebar .side-project { width: 100%; border-bottom: 0; padding-bottom: .35rem; }
  .brand { width: 100%; padding-bottom: .35rem; }
  .nav-item { padding: .3rem .5rem; font-size: .84rem; }
  .nav-item .n { display: none; }
  .main { padding: 1rem; }
  .split, .ms { grid-template-columns: 1fr; }
  .binder { position: static; max-height: none; }
  table.data { font-size: .82rem; }
}

@media print {
  .sidebar, .topbar .actions, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .main { max-width: none; padding: 0; }
}

/* -------------------------------------------------------- theme toggle -- */

.theme-toggle {
  display: flex; align-items: center; gap: .55rem;
  padding: .42rem .55rem; border-radius: 7px;
  color: var(--muted); font-size: .9rem; width: 100%;
  background: transparent; border: 0; font-family: inherit; cursor: pointer;
  text-align: left;
}
.theme-toggle:hover { background: var(--panel); color: var(--text); }
.theme-toggle .ic { width: 1.1rem; text-align: center; color: var(--faint); font-size: .95rem; }
/* The label names the mode you would switch TO, so it reads as an action.
   Not scoped to .theme-toggle: the reader header uses a plain button. */
.lbl-dark  { display: none; }
.lbl-light { display: inline; }
[data-theme="light"] .lbl-dark  { display: inline; }
[data-theme="light"] .lbl-light { display: none; }

/* ------------------------------------------------------------- AI bits -- */

.progress {
  height: 10px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; overflow: hidden;
}
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s ease; }

.run-log {
  font-family: var(--mono); font-size: .78rem; line-height: 1.5;
  max-height: 220px; overflow-y: auto; background: var(--bg);
  border: 1px solid var(--line); border-radius: 7px; padding: .6rem .75rem;
  color: var(--muted); white-space: pre-wrap;
}

.alias { color: var(--faint); font-size: .78rem; }

.cost {
  font-variant-numeric: tabular-nums;
}

/* Links inside coloured banners inherit the banner's text colour — a blue
   link on a red flash is unreadable in both themes. */
.flash a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.flash a:hover { opacity: .8; }

/* ------------------------------------------------------ AI suggest ------ */

.ai-suggest {
  margin-left: .4rem; padding: .05rem .4rem;
  background: transparent; border: 1px solid var(--line2); border-radius: 5px;
  color: var(--accent); font: inherit; font-size: .7rem; font-weight: 600;
  cursor: pointer; text-transform: none; letter-spacing: 0;
}
.ai-suggest:hover { background: var(--panel2); }
.ai-suggest:disabled { opacity: .5; cursor: progress; }
.ai-suggest.done { color: var(--ok); border-color: var(--ok); }

.ai-note {
  display: block; margin-top: .3rem; font-size: .76rem; color: var(--faint); font-weight: 400;
}
.ai-note.bad { color: var(--warn); }

/* ---------------------------------------------------- change history --- */

.hist { border-bottom: 1px solid var(--line); padding: .55rem 0; }
.hist:last-child { border-bottom: 0; }
.hist-head { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .875rem; }
.hist-head .faint { margin-left: auto; }
.hist-was {
  margin-top: .25rem; font-size: .82rem; color: var(--muted);
  border-left: 2px solid var(--line2); padding-left: .5rem;
}

/* ------------------------------------------------------------- help ---- */

.help-body { line-height: 1.68; }
.help-body h2 {
  font-size: 1.12rem; margin: 1.9rem 0 .6rem; padding-top: .3rem;
  border-top: 1px solid var(--line);
}
.help-body h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.help-body h3 { font-size: .98rem; margin: 1.3rem 0 .4rem; color: var(--muted); }
.help-body p  { margin: 0 0 .9rem; max-width: 68ch; }
.help-body ul, .help-body ol { margin: 0 0 1rem; padding-left: 1.3rem; max-width: 68ch; }
.help-body li { margin-bottom: .35rem; }
.help-body code {
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  padding: .05rem .3rem; font-size: .88em; font-family: var(--mono);
}
.help-body table.data { margin: .3rem 0 1.2rem; }
.help-body table.data td { vertical-align: top; }
.help-body hr { margin: 1.6rem 0; }

.help-body blockquote.note {
  margin: 0 0 1.1rem; padding: .7rem .95rem; max-width: 68ch;
  border: 1px solid var(--line2); border-left: 3px solid var(--muted);
  border-radius: 0 7px 7px 0; background: var(--bg);
}
.help-body blockquote.note p:last-child { margin-bottom: 0; }
.help-body blockquote.optional { border-left-color: var(--faint); }
.help-body blockquote.tip      { border-left-color: var(--ok); }
.help-body blockquote.careful  { border-left-color: var(--warn); }
.help-body blockquote.note.in   { border-left-color: var(--accent); }
.help-body blockquote:has(> strong:first-child) { }

/* --------------------------------------------------- search palette ---- */

.palette-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 1rem 1rem;
}
.palette-backdrop[hidden] { display: none; }

.palette {
  width: 100%; max-width: 640px;
  background: var(--panel); border: 1px solid var(--line2);
  border-radius: 12px; box-shadow: 0 24px 60px var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
  max-height: 74vh;
}

.palette-input { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem;
                 border-bottom: 1px solid var(--line); }
.palette-input .ic { color: var(--faint); font-size: 1.1rem; }
.palette-input input {
  flex: 1 1 auto; background: transparent; border: 0; padding: 0;
  color: var(--text); font: inherit; font-size: 1rem;
}
.palette-input input:focus { outline: none; box-shadow: none; }
.palette-close {
  background: var(--bg); border: 1px solid var(--line2); border-radius: 5px;
  color: var(--faint); font: inherit; font-size: .7rem; padding: .12rem .4rem; cursor: pointer;
}

.palette-results { overflow-y: auto; padding: .35rem; flex: 1 1 auto; }

.palette-group {
  color: var(--faint); font-size: .68rem; text-transform: uppercase;
  letter-spacing: .08em; font-weight: 700; padding: .6rem .65rem .25rem;
}
.palette-item {
  display: flex; align-items: baseline; gap: .6rem;
  padding: .45rem .65rem; border-radius: 7px; cursor: pointer;
  color: var(--text); text-decoration: none;
}
.palette-item:hover, .palette-item.on { background: var(--panel2); text-decoration: none; }
.palette-item .ic { color: var(--accent); flex: 0 0 1.1rem; text-align: center; }
.palette-item .body { flex: 1 1 auto; min-width: 0; }
.palette-item .t { font-weight: 580; }
.palette-item .m { color: var(--faint); font-size: .76rem; margin-left: .4rem; font-weight: 400; }
.palette-item .s {
  color: var(--muted); font-size: .8rem; margin-top: .1rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.palette-empty { padding: 1.6rem 1rem; text-align: center; color: var(--faint); font-size: .88rem; }

.palette-foot {
  display: flex; gap: .9rem; align-items: center;
  padding: .5rem .9rem; border-top: 1px solid var(--line);
  color: var(--faint); font-size: .74rem;
}
.palette-foot kbd {
  background: var(--bg); border: 1px solid var(--line2); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 .3rem; font-family: var(--sans); font-size: .7rem;
  margin-right: .15rem;
}
.nav-item .n kbd {
  background: var(--bg); border: 1px solid var(--line2); border-radius: 4px;
  padding: 0 .25rem; font-family: var(--sans); font-size: .68rem;
}
button.nav-item { width: 100%; background: transparent; border: 0; font: inherit; cursor: pointer; text-align: left; }

@media (max-width: 780px) {
  .palette-backdrop { padding: 4vh .6rem 1rem; }
  .palette { max-height: 86vh; }
  .palette-foot span:not(:last-child) { display: none; }
}

/* ------------------------------------------------------- getting started */

.steps { display: flex; flex-direction: column; gap: .2rem; }
.step { display: flex; gap: .75rem; padding: .55rem 0; align-items: flex-start; }
.step + .step { border-top: 1px solid var(--line); }
.step .dot {
  flex: 0 0 1.55rem; height: 1.55rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--line2);
  color: var(--faint); font-size: .78rem; font-weight: 700;
}
.step.done .dot { background: var(--ok); border-color: var(--ok); color: var(--panel); }
.step.now  .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step-body { flex: 1 1 auto; min-width: 0; }
.step-label { font-weight: 620; font-size: .92rem; }
.step-blurb { color: var(--muted); font-size: .84rem; margin-top: .1rem; }
.step.done .step-label { color: var(--muted); font-weight: 550; }

/* ------------------------------------------------------------- notes ---- */

.scratch-preview {
  margin-top: .35rem; font-size: .85rem; color: var(--muted);
  border-left: 2px solid var(--line2); padding-left: .6rem;
  white-space: pre-wrap;
}
#project-notes, #entity-scratch { font-family: var(--sans); line-height: 1.6; }

/* A timeline row is clickable in its own right, not just its title. */
.tl-row { cursor: pointer; }
.tl-row .grip { cursor: grab; }
.tl-row:hover { border-color: var(--line2); }

/* ---------------------------------------------------- node type picker -- */

.type-list { display: flex; flex-direction: column; }
.type-row {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .5rem .4rem; border-radius: 7px; cursor: pointer; margin: 0;
  font-weight: 400;
}
.type-row:hover { background: var(--hover); }
.type-row.locked { cursor: default; opacity: .72; }
.type-row input { width: auto; margin: .2rem 0 0; flex: 0 0 auto; }
.type-row .ic { color: var(--accent); width: 1.1rem; text-align: center; flex: 0 0 auto; }
.type-row .body { display: flex; flex-direction: column; min-width: 0; }
.type-row .t { font-weight: 560; font-size: .9rem; color: var(--text); }
.type-row .d { color: var(--faint); font-size: .78rem; }

.preset-card {
  display: flex; flex-direction: column; gap: .2rem; text-align: left;
  background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--radius);
  padding: .8rem .9rem; cursor: pointer; font: inherit; color: var(--text);
}
.preset-card:hover { border-color: var(--accent-dk); }
.preset-card .n { font-weight: 640; }
.preset-card .s { color: var(--muted); font-size: .82rem; }
.preset-card .c { color: var(--faint); font-size: .76rem; margin-top: .2rem; }

/* ------------------------------------------ landing, reader, admin ------ */

.landing, .reader, .admin, .gate {
  max-width: 1000px; margin: 0 auto; padding: 2rem 1.25rem 4rem;
}
.gate { max-width: 420px; padding-top: 8vh; }
.gate .panel h1 { font-size: 1.5rem; margin: 0 0 .2rem; }
.gate .panel { padding: 1.5rem; }

.landing-head { text-align: center; padding: 3rem 0 2.5rem; }
.landing-head h1 { font-size: 2.6rem; margin: 0 0 .4rem; letter-spacing: -.02em; }
.landing-head .dot { color: var(--accent); }
.landing-head .tagline { color: var(--muted); font-size: 1.05rem; margin: 0 0 .8rem; }
.landing-head .beta { color: var(--faint); font-size: .85rem; margin: 0; }

.landing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 760px) { .landing-grid { grid-template-columns: 1fr; } }
.landing-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem;
}
.landing-card h2 { margin: 0 0 .6rem; font-size: 1.2rem; }
.landing-card p { color: var(--text); line-height: 1.6; margin: 0 0 .8rem; }
.landing-card .btn-row { margin-top: 1.1rem; }
.landing-foot { text-align: center; padding-top: 2rem; }

.reader-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding-bottom: 1.2rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.reader-head .brand { font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--text); }
.reader-head .brand .dot { color: var(--accent); margin-left: 0; }
.reader-head .small { margin-left: .6rem; }

.read-card {
  display: flex; flex-direction: column; gap: .25rem; text-decoration: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; color: var(--text);
}
.read-card:hover { border-color: var(--accent-dk); text-decoration: none; }
.read-card .kind { color: var(--faint); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.read-card .t { font-weight: 620; font-size: 1.02rem; }
.read-card .by { color: var(--muted); font-size: .85rem; }
.read-card .note { color: var(--faint); font-size: .82rem; font-style: italic; margin-top: .2rem; }
.read-card .meta { margin-top: .5rem; display: flex; gap: .35rem; align-items: center; }

.read-title { margin-bottom: 2rem; }
.read-title h1 { margin: 0 0 .3rem; }
.read-body { max-width: 34rem; margin: 0 auto; font-size: 1.06rem; line-height: 1.75; }
.read-body .read-chapter {
  margin: 2.5rem 0 1.2rem; font-size: 1.15rem; text-align: center;
  text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600;
}
.read-body .read-chapter:first-child { margin-top: 0; }
.read-body .scene-break { border: 0; text-align: center; margin: 1.6rem 0; }
.read-body .scene-break::before { content: "* * *"; color: var(--faint); letter-spacing: .4em; }
.read-foot { max-width: 34rem; margin: 3rem auto 0; text-align: center; }

.share-row { border-bottom: 1px solid var(--line); padding: .7rem 0; }
.share-row:last-child { border-bottom: 0; }

.codes {
  background: var(--bg); border: 1px solid var(--line2); border-radius: 7px;
  padding: .8rem 1rem; font-family: var(--mono); font-size: .95rem; letter-spacing: .05em;
  margin: 0; user-select: all;
}

/* ------------------------------------------------------ reader covers -- */

.welcome {
  display: flex; gap: .9rem; align-items: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1.1rem; margin-bottom: 1.75rem;
}
.welcome .ic {
  flex: 0 0 2.2rem; height: 2.2rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel2); color: var(--accent); font-size: 1.05rem;
}
.welcome strong { display: block; }

.cover { display: block; width: 100%; height: auto; border-radius: 3px; }
.cover-wrap {
  display: block; margin-bottom: .7rem; border-radius: 4px; overflow: hidden;
  box-shadow: 0 4px 14px var(--shadow); line-height: 0;
}
.read-card { padding: .9rem; }
.read-card .t { font-size: 1rem; }
.read-card .kind {
  margin-top: .55rem; padding-top: .5rem; border-top: 1px solid var(--line);
}
.read-card .meta { margin-top: .4rem; }

.cover-mini { display: block; width: 74px; margin-bottom: .8rem; }
.cover-mini .cover { box-shadow: 0 3px 10px var(--shadow); }

/* --------------------------------------------------- chapter paging ---- */

.chapter-bar {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .55rem 0 .8rem; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
  max-width: 34rem; margin-left: auto; margin-right: auto;
}
.chapter-bar select { width: auto; max-width: 15rem; font-size: .82rem; padding: .25rem .45rem; }
.chapter-bar label { display: inline; margin: 0; }

.pager { display: flex; gap: .75rem; align-items: stretch; justify-content: space-between; }
.pager .btn {
  flex-direction: column; align-items: flex-start; gap: .1rem;
  text-align: left; padding: .6rem .9rem; min-width: 9rem;
}
.pager .btn .dir { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.pager .btn .ttl { font-weight: 620; }
.pager .the-end { text-align: right; }
.pager .the-end p { margin: 0 0 .4rem; }
@media (max-width: 620px) {
  .pager { flex-direction: column; }
  .pager .the-end { text-align: left; }
}


/* ---------------------------------------------------- reader text size -- */

.text-size { display: inline-flex; align-items: center; gap: .1rem; }
.text-size button {
  background: var(--panel); border: 1px solid var(--line2); color: var(--muted);
  cursor: pointer; font-family: var(--serif, Georgia, serif); line-height: 1;
  padding: .3rem .5rem;
}
.text-size button:first-child { border-radius: 6px 0 0 6px; font-size: .78rem; }
.text-size button:last-child  { border-radius: 0 6px 6px 0; border-left: 0; font-size: 1.02rem; }
.text-size button:hover:not(:disabled) { color: var(--text); background: var(--panel2); }
.text-size button:disabled { opacity: .35; cursor: default; }

[data-text="sm"] .read-body { font-size: .95rem;  line-height: 1.7;  max-width: 32rem; }
[data-text="md"] .read-body { font-size: 1.06rem; line-height: 1.75; max-width: 34rem; }
[data-text="lg"] .read-body { font-size: 1.2rem;  line-height: 1.78; max-width: 36rem; }
[data-text="xl"] .read-body { font-size: 1.35rem; line-height: 1.8;  max-width: 38rem; }

/* A reference table: many columns, dense, still readable. */
table.bible td, table.bible th { vertical-align: top; font-size: .84rem; }
table.bible td:first-child, table.bible th:first-child { width: 1.6rem; }
table.bible input[type=checkbox] { width: auto; margin: .15rem 0 0; }
table.bible td strong { font-size: .9rem; }
table.bible .faint { font-size: .76rem; }

/* ------------------------------------------------------ the writing page */

.editor-bar {
  display: flex; align-items: center; gap: .35rem;
  padding: .4rem .2rem .6rem; flex-wrap: wrap;
}
.editor-bar .tools { display: flex; align-items: center; gap: .15rem; }
.editor-bar .sep { width: 1px; height: 1.1rem; background: var(--line2); margin: 0 .35rem; }
.tool {
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--muted); cursor: pointer; font: inherit; font-size: .85rem;
  min-width: 1.9rem; padding: .22rem .45rem; line-height: 1.1;
}
.tool:hover { background: var(--panel2); color: var(--text); border-color: var(--line2); }
.tool.on { background: var(--panel2); color: var(--accent); border-color: var(--accent-dk); }

.save-state { font-size: .78rem; color: var(--faint); }
.save-state.unsaved { color: var(--warn); }
.save-state.saving  { color: var(--muted); }
.save-state.failed  { color: var(--err); font-weight: 600; }

/* A sheet of paper, rather than a form field. */
.page {
  /* A measure, not a monitor. Roughly 70 characters, which is where prose
     stops being tiring to read. */
  max-width: 46rem;
  margin: 0 auto;
  background: var(--paper);
  color: var(--paper-ink);
  border: 1px solid var(--paper-line);
  border-radius: 3px;
  box-shadow: 0 1px 2px var(--shadow), 0 8px 28px var(--shadow);
  padding: clamp(1.5rem, 5vw, 4rem) clamp(1.25rem, 6vw, 5rem);
  min-height: 60vh;
}
.page .title {
  width: 100%; background: transparent; border: 0; padding: 0;
  font-family: var(--serif); font-size: 1.5rem; font-weight: 600;
  color: var(--paper-ink); letter-spacing: -.01em;
}
.page .title:focus { outline: none; box-shadow: none; }
.page #prose-editor {
  width: 100%; background: transparent; border: 0; padding: 0; resize: none;
  min-height: 55vh; overflow: hidden;
  font-family: var(--serif);
  font-size: 1.12rem; line-height: 1.75; color: var(--paper-ink);
}
.page #prose-editor:focus { outline: none; box-shadow: none; }
.page #prose-editor::placeholder { color: var(--paper-soft); font-style: italic; }
.page .title::placeholder { color: var(--paper-soft); }

/* Paper is deliberately light in both themes, as it already was: the page is a
   page. Only the serif is new here. */
:root { --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif; }

/* Focus mode: the page, and nothing else. */
body.focus-mode .sidebar,
body.focus-mode .crumb,
body.focus-mode .topbar,
body.focus-mode .binder,
body.focus-mode .panel.mt,
body.focus-mode .editor-foot { display: none !important; }
body.focus-mode .main { max-width: none; padding-top: 1rem; }
/* Hiding the binder is not enough: the grid still reserves its column, which
   is what squeezed the page into 250px. */
body.focus-mode .ms { display: block; }
body.focus-mode .nav-toggle { display: none; }
/* Centre it, but leave the width alone: the page width is the reader's choice
   and should not change just because the surroundings went away. */
body.focus-mode .editor-wrap { margin: 0 auto; }
body.focus-mode .page { box-shadow: none; border-color: transparent; min-height: 80vh; }

.draft-recovery {
  background: var(--panel2); border: 1px solid var(--warn);
  border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .75rem;
  font-size: .88rem;
}

/* ------------------------------------------- collapsing the two sidebars */

.nav-toggle, .binder-toggle {
  background: var(--panel); border: 1px solid var(--line2); border-radius: 7px;
  color: var(--muted); cursor: pointer; font: inherit; font-size: .82rem;
  padding: .3rem .55rem; line-height: 1.2;
}
.nav-toggle:hover, .binder-toggle:hover { color: var(--text); border-color: var(--accent-dk); }

/* The sidebar handle sits out of the way until the sidebar is hidden. */
.nav-toggle { position: fixed; top: .7rem; left: .7rem; z-index: 60; display: none; }
body.nav-off .nav-toggle { display: block; }
body.nav-off .sidebar { display: none; }
body.nav-off .main { padding-left: 3.2rem; }

.binder-toggle { display: none; margin-bottom: .6rem; }
body.binder-off .binder-toggle { display: inline-block; }
body.binder-off .binder { display: none; }
body.binder-off .ms { grid-template-columns: 1fr; }

/* A quieter way to hide each one, from where it lives. */
.side-collapse {
  background: transparent; border: 0; color: var(--faint); cursor: pointer;
  font: inherit; font-size: .95rem; padding: .1rem .3rem; line-height: 1;
}
.side-collapse:hover { color: var(--text); }

/* ------------------------------------------------------ page size options */

.view-tools .lbl {
  color: var(--faint); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .07em; margin: 0 .15rem 0 .1rem;
}
.view-tools .tool { min-width: 1.6rem; padding: .22rem .35rem; }

/* The writing surface fills whatever room it is given; only the page inside
   is constrained, and only as far as the reader asked for. */
.ms .editor-wrap { max-width: none; }
[data-width="narrow"] .page { max-width: 34rem; }
[data-width="medium"] .page { max-width: 46rem; }
[data-width="wide"]   .page { max-width: 62rem; }
[data-width="full"]   .page { max-width: none; }

/* Text size on the page, matching the reader's four steps. */
[data-text="sm"] .page #prose-editor { font-size: 1rem;    line-height: 1.7; }
[data-text="md"] .page #prose-editor { font-size: 1.12rem; line-height: 1.75; }
[data-text="lg"] .page #prose-editor { font-size: 1.26rem; line-height: 1.8; }
[data-text="xl"] .page #prose-editor { font-size: 1.42rem; line-height: 1.85; }
[data-text="sm"] .page .title { font-size: 1.3rem; }
[data-text="lg"] .page .title { font-size: 1.7rem; }
[data-text="xl"] .page .title { font-size: 1.9rem; }

/* One blank line between the title and the prose, the same gap the prose
   itself uses, so the page reads as one rhythm. */
.page .title { margin-bottom: 1.75em; padding-bottom: 0; }

.brand-row { display: flex; align-items: flex-start; justify-content: space-between; }
.brand-row .side-collapse { margin: .45rem .3rem 0 0; }
.binder-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 .1rem .4rem; margin-bottom: .4rem; border-bottom: 1px solid var(--line);
}

/* -------------------------------------------------------------- modal --- */

.modal-back {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal {
  width: 100%; max-width: 26rem;
  background: var(--panel); border: 1px solid var(--line2);
  border-radius: 12px; box-shadow: 0 24px 60px var(--shadow);
  padding: 1.25rem 1.4rem;
}
.modal h3 { margin: 0 0 .5rem; font-size: 1.05rem; }
.modal p { margin: 0 0 1rem; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.modal .btn-row { justify-content: flex-end; }

/* ------------------------------------------------------- deleted scenes -- */

.binder .sc.gone {
  display: flex; align-items: center; gap: .3rem;
  color: var(--faint); font-size: .82rem; padding: .25rem .5rem;
  cursor: default;
}
.binder .sc.gone s { opacity: .8; }
.binder .sc.gone .btn { padding: 0 .3rem; font-size: .75rem; line-height: 1.3; }


/* ------------------------------------------------------------ page seams */

/* Sheets, not a scroll. The seams are drawn behind the writing at exact
   multiples of the line height, set by script, so a seam never lands across a
   line of text. Purely visual: the manuscript has no pages in it. */
.sheet { position: relative; }
.sheet-rules { position: absolute; inset: 0; pointer-events: none; z-index: 0; }

/* A page division, labelled, so it reads as deliberate rather than as a
   rendering fault. The line sits between two lines of text, never across one. */
.sheet-rules .seam {
  position: absolute; left: -1.5rem; right: -1.5rem;
  border-top: 1px dashed var(--paper-line);
}
.sheet-rules .seam span {
  position: absolute; right: 0; top: -.62rem;
  background: var(--paper); padding: 0 .4rem;
  color: var(--paper-soft); font-family: var(--sans);
  font-size: .62rem; letter-spacing: .08em; text-transform: uppercase;
}
.sheet #prose-editor { position: relative; z-index: 1; background: transparent; }
body.no-seams .sheet-rules { display: none; }

/* Dimmed markup: a mirror of the text sitting exactly under the editor, with
   the asterisks greyed. Only the colour differs, never the font, or the two
   would drift apart character by character. */
.sheet-mirror {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal;
  color: var(--paper-ink); visibility: hidden;
}
.sheet-mirror .mk { color: var(--paper-soft); font-style: normal; font-weight: inherit; }
body.dim-marks .sheet-mirror { visibility: visible; }
body.dim-marks .sheet #prose-editor { color: transparent; caret-color: var(--paper-ink); }
body.dim-marks .sheet #prose-editor::selection { background: var(--accent-dk); color: transparent; }

/* ------------------------------------------------------------ scene plan */

.scene-plan {
  max-width: 46rem; margin: 0 auto .9rem;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: .75rem 1rem;
}
[data-width="narrow"] .scene-plan { max-width: 34rem; }
[data-width="wide"]   .scene-plan { max-width: 62rem; }
[data-width="full"]   .scene-plan { max-width: none; }
.scene-plan .h {
  display: flex; align-items: center; gap: .4rem;
  color: var(--muted); font-size: .82rem; margin-bottom: .35rem;
}
.scene-plan .h .ic { color: var(--faint); }
.scene-plan p { margin: 0; color: var(--faint); line-height: 1.6; font-size: .92rem; }
body.focus-mode .scene-plan { display: none; }

/* ------------------------------------------------------- synopsis board */

.board-group { margin-bottom: 1.5rem; }
.board-head {
  display: flex; align-items: baseline; gap: .6rem;
  padding: .35rem .6rem; margin-bottom: .5rem;
  background: var(--panel2); border-radius: 7px;
}
.board-head .t { font-weight: 620; font-size: .88rem; }

.board {
  display: grid; gap: .75rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}
.board .card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .7rem .8rem;
  display: flex; flex-direction: column;
}
.board .card.unwritten { border-style: dashed; }
.board .card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: .5rem;
  padding-bottom: .4rem; margin-bottom: .5rem; border-bottom: 1px solid var(--line);
  font-size: .9rem;
}
.board .card-head a { font-weight: 600; color: var(--text); text-decoration: none; }
.board .card-head a:hover { color: var(--accent); }
.board .card-head .faint { font-size: .74rem; white-space: nowrap; }
.board textarea.card-body {
  border: 0; background: transparent; padding: 0; resize: vertical;
  font-size: .85rem; line-height: 1.55; color: var(--muted); min-height: 5.5rem;
}
.board textarea.card-body:focus { outline: none; box-shadow: none; color: var(--text); }
.board p.card-body { font-size: .82rem; line-height: 1.5; margin: 0; }
.board .card-save { align-self: flex-start; margin-top: .4rem; opacity: 0; }
.board .card:hover .card-save,
.board .card:focus-within .card-save { opacity: 1; }

/* ------------------------------------------------------- writing goals -- */

.goal-line {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  font-size: .86rem; margin-bottom: .3rem;
}
.spark {
  display: flex; align-items: flex-end; gap: 2px; height: 2.2rem; margin-top: .8rem;
}
.spark i {
  flex: 1 1 auto; background: var(--line2); border-radius: 2px 2px 0 0; min-height: 2px;
}
.spark i.met { background: var(--accent); }

/* The prose half of a bible entry, given the width it needs. */
table.bible tr.detail > td { padding-top: 0; border-top: 0; }
table.bible tr.detail .bit {
  display: flex; gap: .6rem; align-items: baseline;
  padding: .15rem 0; font-size: .82rem; line-height: 1.5;
}
table.bible tr.detail .bit .k {
  flex: 0 0 8.5rem; color: var(--faint);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  /* A margin as well as the gap: the gap alone disappears wherever flex is
     only partly supported, and the label runs into the text. */
  margin-right: .6rem;
}
table.bible tr.detail .bit .v { color: var(--muted); }
table.bible tr:not(.detail) > td { border-bottom: 0; }
table.bible tr.detail > td { border-bottom: 1px solid var(--line); padding-bottom: .6rem; }

@media (max-width: 700px) {
  table.bible tr.detail .bit { display: block; }
  table.bible tr.detail .bit .k { display: block; margin: 0 0 .1rem; }
}

/* ---------------------------------------------------------- preflight --- */

.panel.pf { padding: .8rem 1rem; margin-bottom: .6rem; border-left: 3px solid var(--line2); }
.panel.pf-stop { border-left-color: var(--err); }
.panel.pf-look { border-left-color: var(--warn); }
.pf-head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .25rem; }
.pf-head .mark {
  flex: 0 0 1.1rem; height: 1.1rem; line-height: 1.1rem; text-align: center;
  border-radius: 50%; font-size: .72rem; font-weight: 700;
  background: var(--panel2); color: var(--muted);
}
.pf-stop .pf-head .mark { background: var(--err); color: #fff; }
.pf-look .pf-head .mark { background: var(--warn); color: #201a10; }
.pf-where { margin: .45rem 0 0; padding-left: 1.1rem; font-size: .82rem; color: var(--faint); }
.pf-where li { margin-bottom: .1rem; }

/* Card actions: write it, or open its details. */
.board .card-head .nm { font-weight: 600; }
.board .card-head .tools { display: flex; align-items: center; gap: .3rem; }
.board .card-head .ic {
  background: transparent; border: 1px solid transparent; border-radius: 5px;
  color: var(--faint); cursor: pointer; font: inherit; font-size: .82rem;
  line-height: 1.1; padding: .15rem .3rem; text-decoration: none;
}
.board .card-head .ic:hover { color: var(--accent); border-color: var(--line2); background: var(--panel2); }
.board .card-head form { margin: 0; }

/* ----------------------------------------------------------- proof pages */

/* Preview is rendered text rather than an editable box, so here the pages can
   be real: one sheet ends, a gap, the next begins. */
.proof { max-width: 46rem; margin: 0 auto; }
[data-width="narrow"] .proof { max-width: 34rem; }
[data-width="wide"]   .proof { max-width: 62rem; }
[data-width="full"]   .proof { max-width: none; }

.proof-sheet {
  position: relative;
  background: var(--paper); color: var(--paper-ink);
  border: 1px solid var(--paper-line); border-radius: 3px;
  box-shadow: 0 1px 2px var(--shadow), 0 8px 28px var(--shadow);
  padding: clamp(1.5rem, 5vw, 4rem) clamp(1.25rem, 6vw, 5rem);
  margin: 0 0 1.6rem;
  overflow: hidden;
}
.proof-sheet .folio {
  position: absolute; left: 0; right: 0; bottom: .9rem;
  text-align: center; color: var(--paper-soft);
  font-family: var(--sans); font-size: .68rem; letter-spacing: .1em;
}
.proof-title { font-family: var(--serif); margin: 0 0 1.75rem; font-size: 1.5rem; }

/* Before the script runs, and whenever pages are turned off, it is one sheet. */
.proof-source {
  background: var(--paper); color: var(--paper-ink);
  border: 1px solid var(--paper-line); border-radius: 3px;
  box-shadow: 0 1px 2px var(--shadow), 0 8px 28px var(--shadow);
  padding: clamp(1.5rem, 5vw, 4rem) clamp(1.25rem, 6vw, 5rem);
}
.proof.paged .proof-source { display: none; }

/* A chapter title you can simply type over. */
.binder .ch-rename { flex: 1 1 auto; margin: 0; min-width: 0; }
/* !important because the global input rule carries seven :not() negations and
   outranks anything sane written here. A chapter title should look like a
   title, not like a form field, until you touch it. */
.binder .ch-rename input {
  width: 100%; margin: 0;
  background: transparent !important;
  border: 1px solid transparent !important;
  border-radius: 5px !important;
  padding: .1rem .25rem !important;
  box-shadow: none !important;
  font: inherit !important; font-weight: 620 !important; font-size: .82rem !important;
  color: var(--text) !important;
}
.binder .ch-rename input:hover  { border-color: var(--line2) !important; }
.binder .ch-rename input:focus  { border-color: var(--accent-dk) !important; background: var(--panel) !important; }

/* Fields inside a dialog. */
.modal .field { margin-bottom: .8rem; }
.modal .field label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .25rem; }
.modal .field input[type=text], .modal .field textarea { width: 100%; }
.modal .hint { font-size: .78rem; color: var(--faint); margin: -.4rem 0 .9rem; }

/* ------------------------------------------------------------- chapters */

.ch-card { padding: .8rem 1rem; margin-bottom: .7rem; }
.ch-card-head {
  display: flex; align-items: center; gap: .6rem;
  padding-bottom: .5rem; margin-bottom: .6rem; border-bottom: 1px solid var(--line);
}
.ch-card-head .ch-rename { flex: 1 1 auto; margin: 0; min-width: 0; }
.ch-card-head .ch-rename input {
  width: 100%; margin: 0;
  background: transparent !important; border: 1px solid transparent !important;
  border-radius: 6px !important; padding: .15rem .35rem !important;
  box-shadow: none !important; font: inherit !important;
  font-weight: 660 !important; font-size: 1rem !important; color: var(--text) !important;
}
.ch-card-head .ch-rename input:hover { border-color: var(--line2) !important; }
.ch-card-head .ch-rename input:focus { border-color: var(--accent-dk) !important; background: var(--panel2) !important; }

.ch-move { display: flex; gap: .15rem; }
.ch-move .ic {
  background: transparent; border: 1px solid transparent; border-radius: 5px;
  color: var(--faint); cursor: pointer; font: inherit; font-size: .8rem; padding: .1rem .35rem;
}
.ch-move .ic:hover { color: var(--text); border-color: var(--line2); background: var(--panel2); }
.ch-move form { margin: 0; }

.ch-body { display: grid; grid-template-columns: 1fr 20rem; gap: 1.2rem; align-items: start; }
@media (max-width: 800px) { .ch-body { grid-template-columns: 1fr; } }

.ch-scenes { margin: 0 0 .5rem; padding-left: 1.1rem; }
.ch-scenes li { margin-bottom: .3rem; font-size: .88rem; }
.ch-scenes li .faint { font-size: .74rem; margin-left: .4rem; }
.ch-scenes li .syn { display: block; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.ch-scenes li.gone { color: var(--faint); list-style: none; margin-left: -1.1rem; }
.ch-body textarea { font-size: .84rem; }
