/* Inkwren — tokens, base, reader. Themes and fonts are driven by data attributes on <html>. */
:root {
  --accent: #9a5b3a; --ink-blue: #26384f;
  --size: 1.125rem; --lh: 1.7;
  --f-spectral: "Spectral", Georgia, "Times New Roman", serif;
  --f-times: Tinos, "Times New Roman", Times, serif;
  --f-arial: Arimo, Arial, Helvetica, sans-serif;
  --f-calibri: Carlito, Calibri, "Segoe UI", sans-serif;
  --f-quicksand: Quicksand, "Trebuchet MS", sans-serif;
  --f-ui: var(--f-spectral);
  --read: var(--f-spectral);
}
html[data-theme="paper"], html:not([data-theme]) { --bg: #fbf7ee; --bg2: #f3ecdc; --fg: #2b2622; --mute: #7a6f62; --line: #e2d8c3; }
html[data-theme="sepia"] { --bg: #f1e4c6; --bg2: #e8d8b4; --fg: #3a2d1c; --mute: #7d6a4c; --line: #d6c39b; }
html[data-theme="dark"]  { --bg: #1b1916; --bg2: #24211d; --fg: #d9d0bf; --mute: #968c7a; --line: #36312a; --accent: #d49a72; }
html[data-font="spectral"] { --read: var(--f-spectral); }
html[data-font="times"] { --read: var(--f-times); }
html[data-font="arial"] { --read: var(--f-arial); }
html[data-font="calibri"] { --read: var(--f-calibri); }
html[data-font="quicksand"] { --read: var(--f-quicksand); }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--f-ui); transition: background .2s, color .2s; }
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
.wrap { max-width: 62rem; margin: 0 auto; padding: 0 1.75rem; }
.brand { font-style: italic; font-size: 1.6rem; letter-spacing: .01em; text-decoration: none; color: var(--fg); }
.brand b { color: var(--accent); font-weight: 600; }
header.top { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 0; border-bottom: 1px solid var(--line); }
.btn { border: 1px solid var(--line); background: var(--bg2); padding: .45rem .9rem; border-radius: 999px; cursor: pointer; text-decoration: none; color: var(--fg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.mute { color: var(--mute); }

/* Library */
.hero { padding: 3rem 0 1.5rem; } .hero h1 { font-weight: 500; font-size: 2.2rem; margin: 0 0 .5rem; }
.card { display: block; padding: 1.1rem 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.card h2 { margin: 0 0 .15rem; font-size: 1.35rem; font-weight: 500; }
.card p { margin: .4rem 0; line-height: 1.5; }
.chips { display: flex; gap: .6rem; flex-wrap: wrap; font-size: .85rem; color: var(--mute); }
.chlist { margin: .5rem 0 0; padding: 0; list-style: none; }
.chlist li { padding: .15rem 0; }

/* Auth */
form.auth { display: grid; gap: .8rem; padding: 2rem 0; max-width: 24rem; }
form.auth input { padding: .6rem .8rem; border: 1px solid var(--line); background: var(--bg2); border-radius: 8px; }
.err { color: #b3402a; min-height: 1.2em; }

/* Reader */
#bar { position: fixed; inset: 0 0 auto 0; height: 3px; background: var(--line); z-index: 20; }
#bar i { display: block; height: 100%; width: 0; background: var(--accent); }
.rbar { position: sticky; top: 3px; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 1rem; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); font-size: .9rem; }
.rbar .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--mute); }
.page { max-width: 38rem; margin: 0 auto; padding: 3rem 1.25rem 4rem; font-family: var(--read); font-size: var(--size); line-height: var(--lh); }
.page h1.ch { text-align: center; font-weight: 500; font-size: 1.6em; margin: 0 0 2.5rem; }
.page h1.ch small { display: block; font-size: .5em; letter-spacing: .25em; text-transform: uppercase; color: var(--mute); margin-bottom: .5rem; }
.page p { margin: 0; text-indent: 1.6em; hyphens: auto; text-align: justify; }
.page .body > p:first-child, .page .scene-break + p { text-indent: 0; }
.page blockquote { margin: 1em 1.5em; font-style: italic; } .page blockquote p { text-indent: 0; }
.scene-break { text-align: center; margin: 1.6em 0; color: var(--mute); letter-spacing: .6em; } .scene-break::before { content: "\2766"; letter-spacing: 0; }
.dropcap .body > p:first-child::first-letter { float: left; font-size: 3.4em; line-height: .85; padding: .05em .12em 0 0; color: var(--accent); }
@supports (initial-letter: 3) { .dropcap .body > p:first-child::first-letter { float: none; initial-letter: 3; font-size: inherit; line-height: inherit; padding: 0 .1em 0 0; } }
.nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.nav a.off { visibility: hidden; }
#panel { position: fixed; right: 1rem; top: 3.4rem; z-index: 30; width: 17rem; padding: 1rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.15); font-family: var(--f-ui); }
#panel[hidden] { display: none; }
#panel label { display: flex; justify-content: space-between; align-items: center; margin: .6rem 0; }
.seg { display: flex; gap: .3rem; } .seg button { padding: .25rem .6rem; border: 1px solid var(--line); background: var(--bg); border-radius: 6px; cursor: pointer; } .seg button.on { border-color: var(--accent); color: var(--accent); }

.page sup.fn { font-size: .7em; line-height: 0; } .page sup.fn a { text-decoration: none; padding: 0 .12em; scroll-margin-top: 4rem; }
.page .notes { margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid var(--line); font-size: .88em; line-height: 1.5; }
.page .notes h2 { font-size: .8em; letter-spacing: .2em; text-transform: uppercase; color: var(--mute); font-weight: 500; margin: 0 0 .8rem; }
.page .notes ol { margin: 0; padding-left: 1.4em; } .page .notes li { margin: .45em 0; scroll-margin-top: 4rem; } .page .notes a.back { text-decoration: none; }

/* Book mode: two-page spread (wide screens only; reader.js falls back to scroll below 900px) */
.page.spread { max-width: 72rem; padding: 1.25rem 2.5rem .25rem; }
.page.spread .sheet { height: calc(100vh - 9.5rem); height: calc(100dvh - 9.5rem); overflow: hidden; }
.page.spread .flow { height: 100%; column-count: 2; column-gap: 5rem; column-fill: auto; column-rule: 1px solid var(--line); transition: transform .28s ease; }
.page.spread h1.ch { margin: 1rem 0 2rem; break-after: avoid; }
.page.spread p { orphans: 2; widows: 2; }
.page.spread .notes { margin-top: 2rem; }
.spreadnav { display: flex; justify-content: center; align-items: center; gap: 1.2rem; padding: .7rem 0 1rem; font-size: .9rem; font-family: var(--f-ui); }
.spreadnav span { min-width: 5rem; text-align: center; }
@media (prefers-reduced-motion: reduce) { .page.spread .flow { transition: none; } }

/* Author tools */
[hidden] { display: none !important; }
.pagetitle { font-weight: 500; font-size: 1.9rem; margin: 1.5rem 0 1rem; }
h2.sec { font-weight: 500; font-size: 1.3rem; margin: 2.2rem 0 .8rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
h3.sub { font-weight: 500; font-size: 1.05rem; margin: 1.4rem 0 .5rem; }
.stack { display: grid; gap: .8rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row.split { justify-content: space-between; }
.field { display: grid; gap: .25rem; flex: 1 1 10rem; }
.field > span { font-size: .85rem; color: var(--mute); }
.field input, .field select, .field textarea, textarea.prose-ed, .chrow input[type=text] { width: 100%; padding: .55rem .75rem; border: 1px solid var(--line); background: var(--bg2); border-radius: 8px; font: inherit; color: inherit; }
.check { display: flex; gap: .5rem; align-items: center; }
textarea.prose-ed { min-height: 60vh; font-family: var(--f-spectral); font-size: 1.05rem; line-height: 1.6; resize: vertical; }
textarea.prose-ed.short { min-height: 8rem; }
.item { padding: .8rem 0; border-bottom: 1px solid var(--line); display: grid; gap: .5rem; }
.btn.sm { padding: .25rem .65rem; font-size: .85rem; }
.btn.danger { color: #b3402a; border-color: #b3402a55; }
.btn:disabled { opacity: .5; cursor: default; }
.badge { font-size: .75rem; padding: .1rem .55rem; border-radius: 999px; border: 1px solid var(--line); color: var(--mute); }
.badge.live { border-color: var(--accent); color: var(--accent); }
.warn-list { margin: .4rem 0; padding-left: 1.2rem; color: var(--mute); line-height: 1.5; }
.chrow { display: grid; grid-template-columns: auto 1fr auto auto; gap: .6rem; align-items: center; padding: .3rem 0; }
#status { min-height: 1.3em; font-size: .9rem; margin-top: .8rem; }
#status.bad { color: #b3402a; }
#status.ok { color: #4a7a3a; }
/* Self-hosted fonts (OFL). Latin subset, regular + bold (+ italic where the family has it). */
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/spectral-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Spectral"; font-style: italic; font-weight: 400; font-display: swap; src: url("/fonts/spectral-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/spectral-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Spectral"; font-style: italic; font-weight: 700; font-display: swap; src: url("/fonts/spectral-latin-700-italic.woff2") format("woff2"); }
@font-face { font-family: "Tinos"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/tinos-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Tinos"; font-style: italic; font-weight: 400; font-display: swap; src: url("/fonts/tinos-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Tinos"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/tinos-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Tinos"; font-style: italic; font-weight: 700; font-display: swap; src: url("/fonts/tinos-latin-700-italic.woff2") format("woff2"); }
@font-face { font-family: "Arimo"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/arimo-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Arimo"; font-style: italic; font-weight: 400; font-display: swap; src: url("/fonts/arimo-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Arimo"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/arimo-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Arimo"; font-style: italic; font-weight: 700; font-display: swap; src: url("/fonts/arimo-latin-700-italic.woff2") format("woff2"); }
@font-face { font-family: "Carlito"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/carlito-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Carlito"; font-style: italic; font-weight: 400; font-display: swap; src: url("/fonts/carlito-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Carlito"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/carlito-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Carlito"; font-style: italic; font-weight: 700; font-display: swap; src: url("/fonts/carlito-latin-700-italic.woff2") format("woff2"); }
@font-face { font-family: "Quicksand"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/quicksand-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Quicksand"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/quicksand-latin-700-normal.woff2") format("woff2"); }
