/* Marginalia — paper, ink, and a little rust.
   A reading room, not a dashboard. */

@font-face {
  font-family: "Newsreader";
  src: url("/static/fonts/newsreader-normal-300_700.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/static/fonts/newsreader-italic-300_600.woff2") format("woff2");
  font-weight: 300 600;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/ibm-plex-sans-normal-400.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/ibm-plex-mono-normal-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/ibm-plex-mono-normal-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f2ecdf;
  --paper-2: #fbf8f1;
  --paper-3: #e7dece;
  --paper-4: #d9cebb;
  --ink: #17150f;
  --ink-2: #2c2921;
  --muted: #6e675a;
  --faint: #948b7c;
  --rule: rgba(23, 21, 15, 0.14);
  --rule-2: rgba(23, 21, 15, 0.28);
  --rust: #ad3a27;
  --rust-2: #8b2b1b;
  --rust-soft: rgba(173, 58, 39, 0.1);
  --moss: #4d6247;
  --ochre: #b6862c;
  --slate: #4d6470;
  --desk: #201d18;
  --desk-2: #27231d;
  --page-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 18px 46px -18px rgba(0, 0, 0, 0.55);
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "IBM Plex Sans", "Nimbus Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 2px;
  --bar: 68px;
  --map: 64px;
}

html[data-theme="dusk"] {
  color-scheme: dark;
  --paper: #191712;
  --paper-2: #211e18;
  --paper-3: #2a261f;
  --paper-4: #383229;
  --ink: #ece4d5;
  --ink-2: #d8cfbe;
  --muted: #a79d8b;
  --faint: #7c7364;
  --rule: rgba(236, 228, 213, 0.13);
  --rule-2: rgba(236, 228, 213, 0.25);
  --rust: #d05a42;
  --rust-2: #e57d64;
  --rust-soft: rgba(208, 90, 66, 0.14);
  --moss: #8da47f;
  --ochre: #d1a24b;
  --slate: #8aa5b0;
  --desk: #0e0d0b;
  --desk-2: #15130f;
  --page-shadow: 0 1px 1px rgba(0, 0, 0, 0.5), 0 20px 50px -18px rgba(0, 0, 0, 0.8);
}

html[data-theme="sepia"] {
  color-scheme: light;
  --paper: #ebdfc7;
  --paper-2: #f6edd9;
  --paper-3: #dfcfb0;
  --paper-4: #cdb995;
  --ink: #2a2117;
  --ink-2: #3b3022;
  --muted: #77664e;
  --faint: #9c886a;
  --rule: rgba(42, 33, 23, 0.15);
  --rule-2: rgba(42, 33, 23, 0.3);
  --rust: #a34528;
  --rust-2: #833318;
  --rust-soft: rgba(163, 69, 40, 0.12);
  --desk: #2b2319;
  --desk-2: #33291d;
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

html[data-theme="dusk"] body::before { opacity: 0.05; mix-blend-mode: screen; }

::selection { background: rgba(173, 58, 39, 0.24); }

a { color: var(--rust); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--rust-2); }

h1, h2, h3, h4, p, figure, blockquote { margin: 0; }

h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.015em; }
h1 { line-height: 0.98; }
h2 { line-height: 1.1; }
h3 { line-height: 1.2; }

em { font-style: italic; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img { max-width: 100%; display: block; }
svg { display: block; }

:focus-visible { outline: 2px solid var(--rust); outline-offset: 3px; }

kbd {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  padding: 3px 5px;
  border: 1px solid var(--rule-2);
  border-radius: 3px;
  color: var(--muted);
  background: var(--paper-2);
}

/* ------------------------------------------------------------------ atoms */

.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow .dot { color: var(--rust); padding: 0 0.5em; }

.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.rust { color: var(--rust); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon { width: 18px; height: 18px; flex: 0 0 auto; stroke-width: 1.6; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  font-size: 13px;
}
.wordmark:hover { color: var(--ink); }
.mark {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  background: var(--rust);
  color: var(--paper-2);
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  padding-bottom: 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.wordmark .sub {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  font-size: 14px;
  margin-left: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 28px;
  height: var(--bar);
  padding: 0 clamp(18px, 4vw, 52px);
  background: color-mix(in srgb, var(--paper) 93%, transparent);
  border-bottom: 1px solid var(--rule-2);
  backdrop-filter: blur(10px);
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 3px;
  border-bottom: 1px solid var(--rule);
  pointer-events: none;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-left: 14px;
}
.topnav a {
  position: relative;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 0;
}
.topnav a:hover { color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--ink); }
.topnav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--rust);
}

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.015em;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.btn:hover { border-color: var(--ink); background: var(--paper-2); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--rust); border-color: var(--rust); color: var(--paper-2); }
.btn.primary:hover { background: var(--rust-2); border-color: var(--rust-2); }
.btn.ink { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.ink:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--paper-2); color: var(--ink); border-color: var(--rule); }
.btn.small { min-height: 30px; padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn[aria-pressed="true"] { color: var(--rust); border-color: rgba(173, 58, 39, 0.35); background: var(--rust-soft); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { color: var(--ink); background: var(--paper-2); border-color: var(--rule); }
.icon-btn[aria-pressed="true"] { color: var(--rust); background: var(--rust-soft); border-color: transparent; }

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-2);
  padding-bottom: 2px;
}
.text-link:hover { color: var(--rust); border-color: var(--rust); }

.input, .textarea, .select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 14px;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--rust);
  box-shadow: inset 0 0 0 1px var(--rust);
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
.field { display: grid; gap: 6px; }
.field > label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border: 1px solid var(--rule);
  border-radius: 20px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.chip.rust { color: var(--rust); border-color: rgba(173, 58, 39, 0.35); background: var(--rust-soft); }

.rule {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--faint);
  margin: 42px 0;
}
.rule::before, .rule::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.rule span { font-family: var(--serif); font-size: 17px; letter-spacing: 0.3em; color: var(--rust); }
.rule.tight { margin: 24px 0; }

.section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--rule-2);
  margin-bottom: 22px;
}
.section-label h2 {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
}
.section-label .count { font-family: var(--mono); font-size: 10px; color: var(--faint); }

.progress-line {
  position: relative;
  height: 3px;
  background: var(--paper-4);
  overflow: hidden;
}
.progress-line > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--rust);
  transition: width 0.4s ease;
}
.progress-line.fine { height: 1px; background: var(--rule); }

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

.shell {
  position: relative;
  z-index: 1;
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: clamp(30px, 5vw, 64px) clamp(18px, 4vw, 52px) 80px;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 30px;
  align-items: end;
  padding-bottom: 26px;
}
.masthead h1 {
  font-size: clamp(46px, 6.8vw, 92px);
  font-weight: 350;
  letter-spacing: -0.035em;
  margin: 9px 0 12px;
}
.masthead h1 em { font-weight: 300; color: var(--rust); }
.masthead .lede {
  max-width: 45ch;
  font-family: var(--serif);
  font-size: clamp(16px, 1.6vw, 20px);
  line-height: 1.5;
  color: var(--muted);
}
.masthead-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 13px;
  padding-bottom: 4px;
}
.masthead-side .stamp {
  display: grid;
  place-items: center;
  width: 69px;
  height: 69px;
  border: 1px solid var(--rust);
  border-radius: 50%;
  color: var(--rust);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.25;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  transform: rotate(-7deg);
  opacity: 0.9;
}
.masthead-side .date { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: var(--faint); text-transform: uppercase; }

/* ---------------------------------------------------------------- current */

.current-book {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  gap: clamp(26px, 4vw, 56px);
  align-items: center;
  padding: clamp(24px, 3.6vw, 44px);
  background:
    linear-gradient(90deg, transparent 0 25px, rgba(173, 58, 39, 0.14) 25px 26px, transparent 26px),
    var(--paper-2);
  border: 1px solid var(--rule-2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 22px 50px -44px rgba(23, 21, 15, 0.6);
  position: relative;
}
.current-book::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid var(--rule);
  pointer-events: none;
}
.current-book .cover {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--paper-3);
  box-shadow: var(--page-shadow);
  transform: rotate(-0.7deg);
}
.current-book .cover img { width: 100%; height: 100%; object-fit: cover; }
.current-book .cover .ribbon {
  position: absolute;
  top: 0;
  right: 13px;
  width: 18px;
  height: 52px;
  background: var(--rust);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
}
.current-copy { min-width: 0; }
.current-copy h2 {
  font-size: clamp(32px, 4.6vw, 58px);
  font-weight: 350;
  letter-spacing: -0.03em;
  margin: 8px 0 8px;
}
.current-author { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.current-progress { margin: 24px 0 8px; max-width: 460px; }
.current-progress-meta { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: 7px; }
.current-section {
  margin: 18px 0 24px;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.35;
  max-width: 40ch;
  color: var(--ink-2);
}
.current-section .label { display: block; font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); margin-bottom: 4px; }
.current-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.current-edition { margin-left: auto; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); text-align: right; line-height: 1.6; }

.margin-quote {
  margin-top: 26px;
  padding: 15px 0 0 18px;
  border-left: 2px solid var(--rust);
  max-width: 54ch;
}
.margin-quote blockquote {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink-2);
}
.margin-quote cite {
  display: block;
  margin-top: 8px;
  font-family: var(--mono);
  font-style: normal;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ------------------------------------------------------------------- shelf */

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 326px;
  gap: clamp(32px, 5vw, 64px);
  align-items: start;
}

.bookshelf {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 30px 24px;
}
.book-card { min-width: 0; position: relative; }
.book-card .cover {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  background: var(--paper-3);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 1px rgba(23, 21, 15, 0.15), 0 15px 30px -22px rgba(23, 21, 15, 0.65);
  overflow: hidden;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.book-card .cover img { width: 100%; height: 100%; object-fit: cover; filter: saturate(0.92) contrast(1.02); }
.book-card:hover .cover { transform: translateY(-4px) rotate(-0.35deg); box-shadow: 0 2px 2px rgba(23, 21, 15, 0.18), 0 25px 42px -24px rgba(23, 21, 15, 0.7); }
.book-card .cover .spine {
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.22), rgba(255, 255, 255, 0.06));
}
.book-card .cover .open-mark {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.book-card:hover .open-mark { opacity: 1; transform: none; }
.book-card .info { padding-top: 12px; }
.book-card h3 {
  font-size: 17px;
  line-height: 1.22;
  margin-bottom: 3px;
  overflow-wrap: anywhere;
}
.book-card .byline { font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); overflow-wrap: anywhere; }
.book-card .meta-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; font-family: var(--mono); font-size: 9px; color: var(--muted); }
.book-card .progress-line { margin-top: 7px; }
.book-card[draggable="true"] { cursor: grab; }
.book-card .remove-btn { position: absolute; top: 6px; right: 6px; opacity: 0; background: var(--paper-2); border: 1px solid var(--rule); }
.book-card:hover .remove-btn { opacity: 1; }

.add-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  aspect-ratio: 2 / 3;
  border: 1px dashed var(--rule-2);
  color: var(--muted);
  text-align: center;
  padding: 20px;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.add-card:hover { border-color: var(--rust); color: var(--rust); background: var(--rust-soft); }
.add-card .plus { font-family: var(--serif); font-size: 42px; font-weight: 300; line-height: 0.8; }
.add-card .label { font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; }
.add-card .hint { font-family: var(--serif); font-style: italic; font-size: 14px; max-width: 18ch; }

/* ------------------------------------------------------------------ ledger */

.ledger {
  position: sticky;
  top: calc(var(--bar) + 22px);
  border: 1px solid var(--rule-2);
  background:
    linear-gradient(90deg, transparent 0 19px, rgba(173, 58, 39, 0.16) 19px 20px, transparent 20px),
    var(--paper-2);
  padding: 22px 22px 24px;
  box-shadow: 0 18px 44px -42px rgba(23, 21, 15, 0.8);
}
.ledger-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--rule-2); padding-bottom: 10px; margin-bottom: 16px; }
.ledger-head h2 { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; }
.ledger-head span { font-family: var(--serif); font-style: italic; font-size: 13px; color: var(--faint); }
.ledger-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 12px; margin-bottom: 22px; }
.ledger-stat strong { display: block; font-family: var(--serif); font-size: 31px; font-weight: 350; line-height: 1; letter-spacing: -0.02em; }
.ledger-stat span { display: block; margin-top: 3px; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.11em; text-transform: uppercase; color: var(--faint); }
.week-chart { display: flex; align-items: end; gap: 7px; height: 58px; padding: 0 0 18px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; }
.week-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: end; }
.week-bar i { display: block; width: 100%; max-width: 13px; background: var(--rust); min-height: 2px; opacity: 0.85; transition: height 0.4s ease; }
.week-bar span { font-family: var(--mono); font-size: 8px; color: var(--faint); text-transform: uppercase; }
.week-bar[data-max="1"] i { background: var(--rust); }

.ledger-quote blockquote {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.44;
  font-style: italic;
}
.ledger-quote cite { display: block; margin-top: 9px; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); font-style: normal; }
.ledger-quote .empty { font-family: var(--serif); font-size: 16px; line-height: 1.5; color: var(--muted); }
.ledger-clips { margin-top: 22px; border-top: 1px solid var(--rule); padding-top: 14px; }
.clip-mini { display: block; padding: 9px 0; border-bottom: 1px solid var(--rule); text-decoration: none; color: inherit; }
.clip-mini:last-child { border-bottom: 0; }
.clip-mini:hover .clip-mini-title { color: var(--rust); }
.clip-mini-title { font-family: var(--serif); font-size: 15px; line-height: 1.25; }
.clip-mini-meta { margin-top: 3px; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }

.empty-shelf {
  padding: 44px 34px;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  text-align: center;
}
.empty-shelf h3 { font-size: 30px; margin-bottom: 8px; }
.empty-shelf p { max-width: 44ch; margin: 0 auto 18px; color: var(--muted); font-family: var(--serif); font-size: 17px; }

/* --------------------------------------------------------------- site foot */

.site-foot {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 30px;
  align-items: baseline;
  justify-content: space-between;
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 22px clamp(18px, 4vw, 52px) 34px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--rust); }
.site-foot .colophon { font-family: var(--serif); font-style: italic; font-size: 13px; letter-spacing: 0; text-transform: none; }

/* ---------------------------------------------------------------- dialogs */

dialog {
  width: min(820px, calc(100vw - 32px));
  max-height: min(84dvh, 900px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
  box-shadow: 0 30px 100px -25px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
dialog::backdrop { background: rgba(23, 21, 15, 0.52); backdrop-filter: blur(3px); }
.dialog-body { padding: 24px clamp(20px, 4vw, 34px) 28px; overflow: auto; max-height: calc(min(84dvh, 900px) - 2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--rule-2); margin-bottom: 18px; }
.dialog-head h2 { font-size: 27px; font-weight: 350; }
.dialog-head .eyebrow { margin-bottom: 4px; }

.search-field { position: relative; }
.search-field .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search-field input { padding-left: 40px; min-height: 50px; font-family: var(--serif); font-size: 19px; }
.search-results { margin-top: 18px; display: grid; gap: 4px; }
.search-scope { display: flex; align-items: center; gap: 12px; margin-top: 11px; font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.search-scope label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.search-scope input { accent-color: var(--rust); }
.result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-bottom-color: var(--rule);
  text-decoration: none;
  color: inherit;
}
.result:hover { background: var(--paper); border-color: var(--rule-2); }
.result .result-kicker { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.result .result-title { margin-top: 2px; font-family: var(--serif); font-size: 17px; }
.result .result-snippet { margin-top: 3px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.result .result-snippet mark, .result-snippet .mark { background: var(--rust-soft); color: var(--rust-2); padding: 0 1px; font-weight: 500; }
.search-empty { padding: 28px 6px; color: var(--muted); font-family: var(--serif); font-size: 18px; text-align: center; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 170px;
  padding: 24px;
  border: 1px dashed var(--rule-2);
  background: var(--paper);
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--rust); background: var(--rust-soft); }
.dropzone .big { font-family: var(--serif); font-size: 22px; }
.dropzone .small { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.dropzone .icon { color: var(--rust); width: 28px; height: 28px; }
.upload-status { margin-top: 16px; display: none; }
.upload-status.show { display: block; }
.upload-status .progress-line { margin: 9px 0 6px; }
.upload-status .line { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.import-alt { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--rule); }
.import-alt summary { cursor: pointer; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.import-alt summary:hover { color: var(--rust); }
.import-alt .field { margin-top: 13px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 200;
  transform: translate(-50%, 10px);
  max-width: min(520px, calc(100vw - 30px));
  padding: 11px 16px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 4px 4px 0 rgba(23, 21, 15, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--rust); border-color: var(--rust); color: var(--paper-2); }

/* ------------------------------------------------------------------ login */

.login-page {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  background:
    radial-gradient(900px 600px at 78% 7%, rgba(173, 58, 39, 0.08), transparent 60%),
    radial-gradient(800px 700px at 8% 95%, rgba(77, 98, 71, 0.06), transparent 60%),
    var(--paper);
}
.login-wrap { display: grid; place-items: center; padding: 30px 20px; }
.login-card {
  width: min(480px, 100%);
  padding: clamp(30px, 5vw, 50px);
  background: var(--paper-2);
  border: 1px solid var(--rule-2);
  box-shadow: 0 30px 80px -70px rgba(23, 21, 15, 0.9);
  position: relative;
}
.login-card::after { content: ""; position: absolute; inset: 7px; border: 1px solid var(--rule); pointer-events: none; }
.login-card .mark { width: 48px; height: 48px; font-size: 36px; margin-bottom: 22px; }
.login-title { font-family: var(--serif); font-size: 47px; font-weight: 350; letter-spacing: -0.035em; line-height: 0.95; }
.login-sub { margin: 10px 0 28px; font-family: var(--serif); font-size: 18px; line-height: 1.45; color: var(--muted); }
.login-form { display: grid; gap: 13px; position: relative; z-index: 1; }
.login-form .input { font-family: var(--mono); letter-spacing: 0.03em; }
.login-foot { font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); margin-top: 22px; line-height: 1.7; }
.login-error { min-height: 18px; font-family: var(--mono); font-size: 10px; color: var(--rust); }
.login-page .site-foot { border-top: 0; }

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

.reader-page {
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
}
.reader-bar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--bar);
  padding: 0 14px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule-2);
}
.reader-bar .book-bound { display: flex; align-items: center; gap: 11px; min-width: 0; }
.reader-bar .mini-cover {
  width: 27px;
  height: 40px;
  object-fit: cover;
  border: 1px solid var(--rule);
  background: var(--paper-3);
  flex: 0 0 auto;
}
.reader-bar .book-meta { min-width: 0; }
.reader-bar .book-meta h1 { font-family: var(--serif); font-size: 17px; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 36vw; }
.reader-bar .book-meta p { margin-top: 3px; font-family: var(--mono); font-size: 8px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.reader-actions .btn { min-height: 32px; padding: 5px 10px; font-size: 11px; }
.reader-actions .btn .icon { width: 15px; height: 15px; }
.reader-actions .kbd-hint { display: none; }

.reader-layout {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr) 356px;
  height: calc(100dvh - var(--bar) - var(--map));
}
.reader-layout.margin-closed { grid-template-columns: 292px minmax(0, 1fr) 0; }
.reader-layout.margin-closed .margin-panel { display: none; }
.reader-layout.outline-closed { grid-template-columns: 0 minmax(0, 1fr) 356px; }
.reader-layout.outline-closed .outline-panel { display: none; }
.reader-layout.outline-closed.margin-closed { grid-template-columns: 0 minmax(0, 1fr) 0; }

.outline-panel, .margin-panel {
  position: relative;
  z-index: 4;
  min-height: 0;
  overflow-y: auto;
  background: var(--paper);
  scrollbar-width: thin;
  scrollbar-color: var(--paper-4) transparent;
}
.outline-panel { border-right: 1px solid var(--rule-2); }
.margin-panel { border-left: 1px solid var(--rule-2); background: var(--paper-2); }

.panel-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 11px;
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(6px);
}
.margin-panel .panel-head { background: color-mix(in srgb, var(--paper-2) 96%, transparent); }
.panel-head h2 { font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; }
.panel-head .panel-sub { font-family: var(--serif); font-style: italic; font-size: 12px; color: var(--faint); }

.outline-search {
  padding: 11px 16px;
  border-bottom: 1px solid var(--rule);
}
.outline-search .input {
  min-height: 32px;
  padding: 5px 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  background: transparent;
  border-color: var(--rule);
}
.outline-list { padding: 8px 0 40px; }
.outline-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: baseline;
  width: 100%;
  padding: 7px 16px 7px calc(16px + var(--indent, 0px));
  border-left: 2px solid transparent;
  text-align: left;
  color: var(--muted);
  transition: background 0.12s ease, color 0.12s ease;
}
.outline-item:hover { background: var(--paper-2); color: var(--ink); }
.outline-item .num { display: none; }
.outline-item .title { font-family: var(--serif); font-size: 14.5px; line-height: 1.25; }
.outline-item .pg { font-family: var(--mono); font-size: 8.5px; color: var(--faint); }
.outline-item[data-depth="1"] .title { font-size: 16px; color: var(--ink); font-weight: 500; }
.outline-item[data-depth="2"] .title { font-size: 14px; }
.outline-item[data-depth="3"] .title { font-size: 12.5px; color: var(--muted); }
.outline-item.current { background: var(--rust-soft); color: var(--ink); border-left-color: var(--rust); }
.outline-item.current .title { color: var(--rust-2); }
.outline-item.current .pg { color: var(--rust); }
.outline-list.show-detail .outline-item[data-depth="3"] { display: grid; }
.outline-list .outline-item[data-depth="3"] { display: none; }
.outline-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 9px 16px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.outline-toggle:hover { color: var(--rust); }

.desk {
  position: relative;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.035), transparent 55%),
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(255, 255, 255, 0.014) 79px 80px),
    var(--desk);
  padding: 30px 22px 90px;
  scroll-behavior: auto;
  scrollbar-width: thin;
  scrollbar-color: #4a4337 transparent;
}
.desk::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.09);
}
.pdf-viewer { width: 100%; max-width: 960px; margin: 0 auto; }
.pdf-page {
  position: relative;
  width: var(--page-width, 780px);
  max-width: 100%;
  margin: 0 auto 30px;
  aspect-ratio: var(--ratio, 1 / 1.414);
  background: #fffdf8;
  box-shadow: var(--page-shadow);
  outline: 1px solid rgba(255, 255, 255, 0.1);
  transition: width 0.2s ease;
}
.pdf-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pdf-page .page-label {
  position: absolute;
  right: 0;
  top: -19px;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.38);
  pointer-events: none;
}
.pdf-page.flash { outline: 2px solid var(--rust); outline-offset: 5px; }
.pdf-page .page-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #9a9284;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.pdf-page.rendered .page-loading { display: none; }

html[data-theme="sepia"] .pdf-page { background: #f8edd5; }
html[data-theme="dusk"] .pdf-page { background: #d8d2c4; outline-color: rgba(255, 255, 255, 0.06); }
html[data-theme="dusk"] .pdf-page canvas { filter: invert(0.91) hue-rotate(180deg) contrast(0.94) brightness(0.97); }
html[data-theme="sepia"] .pdf-page canvas { filter: sepia(0.2) contrast(0.98) brightness(0.99); }

.textLayer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  line-height: 1;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  caret-color: transparent;
  z-index: 2;
}
.textLayer span, .textLayer br {
  position: absolute;
  color: transparent;
  white-space: pre;
  cursor: text;
  transform-origin: 0 0;
}
.textLayer ::selection { background: rgba(173, 58, 39, 0.26); }
.textLayer .endOfContent {
  display: block;
  position: absolute;
  inset: 100% 0 0;
  z-index: -1;
  cursor: default;
  user-select: none;
}
.highlight-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.highlight-layer .hl {
  position: absolute;
  border-radius: 2px;
  opacity: 0.34;
  mix-blend-mode: multiply;
  pointer-events: auto;
  cursor: pointer;
}
html[data-theme="dusk"] .highlight-layer .hl { mix-blend-mode: screen; opacity: 0.3; }
.hl[data-color="ochre"] { background: #d6a33a; }
.hl[data-color="moss"] { background: #6f8d5f; }
.hl[data-color="rust"] { background: #c05a44; }
.hl[data-color="slate"] { background: #6a8795; }

/* selection menu */
.selection-menu {
  position: fixed;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px;
  background: var(--paper-2);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(23, 21, 15, 0.16);
}
.selection-menu .swatch {
  width: 21px;
  height: 21px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 50%;
}
.selection-menu .swatch:hover { transform: scale(1.12); }
.selection-menu .sep { width: 1px; height: 20px; background: var(--rule); margin: 0 2px; }
.selection-menu .sel-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.selection-menu .sel-action:hover { color: var(--rust); background: var(--paper); }
.selection-menu .icon { width: 13px; height: 13px; }

/* reading map */
.reading-map {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 270px;
  align-items: center;
  gap: 22px;
  height: var(--map);
  padding: 0 20px;
  background: var(--desk);
  color: #f2ecdf;
  border-top: 1px solid #0e0d0b;
}
.page-counter { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; color: rgba(242, 236, 223, 0.6); white-space: nowrap; }
.page-counter strong { font-family: var(--serif); font-size: 24px; font-weight: 350; color: #f2ecdf; margin-right: 4px; letter-spacing: 0; }
.map-wrap { min-width: 0; }
.map-track { position: relative; display: flex; gap: 1px; height: 10px; align-items: stretch; }
.map-seg { position: relative; height: 100%; background: rgba(242, 236, 223, 0.28); min-width: 2px; cursor: pointer; }
.map-seg:hover { background: rgba(242, 236, 223, 0.46); }
.map-seg.read { background: var(--rust); }
.map-seg.read:hover { background: #d2634b; }
.map-cursor {
  position: absolute;
  top: -5px;
  width: 1px;
  height: 19px;
  background: #f2ecdf;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.map-cursor::before { content: ""; position: absolute; top: -3px; left: -3px; border: 3.5px solid transparent; border-top-color: #f2ecdf; }
.map-labels { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-family: var(--mono); font-size: 8px; letter-spacing: 0.05em; color: rgba(242, 236, 223, 0.45); white-space: nowrap; overflow: hidden; }
.map-labels .truncate { max-width: 42%; }
.map-right { display: flex; align-items: center; justify-content: flex-end; gap: 13px; }
.map-stat { text-align: right; }
.map-stat strong { display: block; font-family: var(--serif); font-size: 18px; font-weight: 350; line-height: 1; }
.map-stat span { display: block; margin-top: 3px; font-family: var(--mono); font-size: 7.5px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(242, 236, 223, 0.45); }
.listen-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(242, 236, 223, 0.24);
  border-radius: 50%;
  color: rgba(242, 236, 223, 0.75);
}
.listen-btn:hover { border-color: var(--paper); color: var(--paper); }
.listen-btn[aria-pressed="true"] { background: var(--rust); border-color: var(--rust); color: var(--paper-2); }

/* margin panel */
.margin-tabs { display: flex; border-bottom: 1px solid var(--rule-2); position: sticky; top: 0; z-index: 3; background: var(--paper-2); }
.margin-tab {
  flex: 1;
  padding: 12px 8px 10px;
  border-bottom: 2px solid transparent;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}
.margin-tab:hover { color: var(--ink); }
.margin-tab[aria-selected="true"] { color: var(--rust); border-bottom-color: var(--rust); }
.margin-body { padding: 20px 20px 50px; }
.margin-section { animation: fade-in 0.22s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.brief-head .eyebrow { margin-bottom: 6px; }
.brief-head h2 { font-size: 27px; font-weight: 350; line-height: 1.05; }
.brief-range { margin-top: 6px; font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.brief-empty { margin-top: 22px; }
.brief-empty p { font-family: var(--serif); font-size: 17px; line-height: 1.5; color: var(--muted); }
.brief-empty .btn { margin-top: 16px; }
.brief-summary { margin-top: 18px; font-family: var(--serif); font-size: 16px; line-height: 1.62; color: var(--ink-2); }
.brief-block { margin-top: 24px; padding-top: 15px; border-top: 1px solid var(--rule-2); }
.brief-block h3 { font-family: var(--mono); font-size: 9px; font-weight: 500; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.brief-points { list-style: none; counter-reset: pt; display: grid; gap: 9px; }
.brief-points li { counter-increment: pt; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 7px; font-size: 13.5px; line-height: 1.5; }
.brief-points li::before { content: counter(pt); font-family: var(--mono); font-size: 9px; color: var(--rust); padding-top: 2px; }
.term-list { display: grid; gap: 0; }
.term-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--rule); }
.term-row:last-child { border-bottom: 0; }
.term-row dt { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.02em; color: var(--rust); overflow-wrap: anywhere; }
.term-row dd { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.questions { display: grid; gap: 7px; }
.question { border: 1px solid var(--rule); background: var(--paper); }
.question summary { padding: 9px 11px; cursor: pointer; font-size: 13px; line-height: 1.4; }
.question summary::marker { color: var(--rust); }
.question p { padding: 0 11px 10px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.brief-actions { display: flex; gap: 8px; margin-top: 20px; }
.brief-loading { padding: 22px 0; }
.brief-loading .loading-copy { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.loading-rule { position: relative; height: 1px; background: var(--rule); margin: 12px 0 18px; overflow: hidden; }
.loading-rule::after { content: ""; position: absolute; top: 0; left: -35%; width: 35%; height: 100%; background: var(--rust); animation: sweep 1.1s ease-in-out infinite; }
@keyframes sweep { to { left: 100%; } }
.skeleton { height: 11px; background: var(--paper-3); margin-bottom: 9px; }
.skeleton:nth-child(2) { width: 88%; }
.skeleton:nth-child(3) { width: 64%; }

.answer-box { margin-top: 22px; padding: 14px 16px; border-left: 2px solid var(--rust); background: var(--paper); }
.answer-box .eyebrow { margin-bottom: 7px; }
.answer-box .answer { font-family: var(--serif); font-size: 16px; line-height: 1.55; }
.answer-box .close { position: absolute; top: 8px; right: 8px; }
.answer-wrap { position: relative; }
.ask-form { margin-top: 20px; display: grid; gap: 8px; }
.ask-form .textarea { min-height: 70px; font-size: 13px; }

.note-card { padding: 12px 0 13px; border-bottom: 1px solid var(--rule); }
.note-card .note-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.note-card .note-page { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.note-card .note-page:hover { color: var(--rust); }
.note-card .quote { font-family: var(--serif); font-size: 15px; line-height: 1.45; margin: 6px 0 0; }
.note-card .note-body { margin-top: 7px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.note-card .note-actions { display: flex; gap: 6px; margin-top: 7px; }
.note-card .note-actions button { font-family: var(--mono); font-size: 8px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.note-card .note-actions button:hover { color: var(--rust); }
.note-card .note-color { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.note-card .note-edit { margin-top: 7px; display: grid; gap: 6px; }
.note-card .note-edit textarea { min-height: 60px; font-size: 12px; }
.notes-empty { padding: 18px 0; font-family: var(--serif); font-size: 16px; line-height: 1.5; color: var(--muted); }
.note-composer { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--rule-2); }
.note-composer h3 { font-family: var(--mono); font-size: 9px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }

/* reader dialogs */
.reader-dialog .dialog-body { padding: 22px 24px 26px; }
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; }
.shortcut-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.shortcut-row span { color: var(--muted); }
.shortcut-row kbd { min-width: 24px; text-align: center; }
.goto-form { display: flex; gap: 8px; margin-top: 16px; }
.goto-form .input { min-height: 46px; font-family: var(--mono); font-size: 20px; }

/* ------------------------------------------------------------------ clips */

.clips-page .masthead h1 { font-size: clamp(44px, 6.2vw, 80px); }
.clips-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: clamp(30px, 5vw, 64px); align-items: start; }
.clip-list { display: grid; }
.clip-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 20px 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
}
.clip-row:hover .clip-row-title { color: var(--rust); }
.clip-index { font-family: var(--mono); font-size: 10px; color: var(--faint); padding-top: 4px; }
.clip-row-title { font-family: var(--serif); font-size: 25px; line-height: 1.12; letter-spacing: -0.01em; transition: color 0.15s ease; }
.clip-row-source { margin-top: 6px; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.clip-row-summary { margin-top: 7px; max-width: 62ch; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.clip-row-meta { text-align: right; font-family: var(--mono); font-size: 8.5px; color: var(--faint); line-height: 1.7; white-space: nowrap; }
.clip-empty { padding: 40px 0; font-family: var(--serif); font-size: 20px; color: var(--muted); }
.capture-card { border: 1px solid var(--rule-2); background: var(--paper-2); padding: 22px; }
.capture-card h2 { font-size: 26px; font-weight: 350; margin-bottom: 6px; }
.capture-card p { font-family: var(--serif); font-size: 16px; line-height: 1.5; color: var(--muted); margin-bottom: 14px; }
.capture-card .field { margin-top: 11px; }
.capture-card .textarea { min-height: 150px; font-family: var(--serif); font-size: 15px; }
.capture-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.extension-note { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--rule); }
.extension-note h3 { font-family: var(--serif); font-size: 20px; margin-bottom: 4px; }
.extension-note p { font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.extension-note .steps { margin: 10px 0 0 16px; padding: 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.extension-note .steps li { margin-bottom: 3px; }

/* clip detail */
.clip-page .reader-bar { position: sticky; }
.clip-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 0; height: calc(100dvh - var(--bar)); }
.clip-article-wrap { overflow-y: auto; padding: clamp(28px, 5vw, 70px) clamp(20px, 5vw, 70px) 100px; }
.clip-article { max-width: 720px; margin: 0 auto; }
.clip-article .eyebrow { margin-bottom: 12px; }
.clip-article h1 { font-size: clamp(36px, 4.6vw, 62px); font-weight: 350; letter-spacing: -0.03em; line-height: 1; }
.clip-article .clip-byline .icon { display: inline-block; vertical-align: -2px; }
.clip-article .clip-byline { margin: 15px 0 26px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.clip-article .clip-byline a { color: var(--rust); }
.clip-text { font-family: var(--serif); font-size: 19px; line-height: 1.67; color: var(--ink-2); }
.clip-text p { margin: 0 0 1.1em; }
.clip-text h1, .clip-text h2, .clip-text h3 { margin: 1.5em 0 0.6em; font-size: 27px; }
.clip-text h4 { margin: 1.4em 0 0.5em; font-family: var(--sans); font-size: 13px; letter-spacing: 0.05em; text-transform: uppercase; }
.clip-text blockquote { margin: 1.3em 0; padding-left: 18px; border-left: 2px solid var(--rust); font-style: italic; color: var(--muted); }
.clip-text pre { overflow-x: auto; padding: 14px; background: var(--paper-3); font-family: var(--mono); font-size: 12px; line-height: 1.5; }
.clip-text code { font-family: var(--mono); font-size: 0.86em; background: var(--paper-3); padding: 1px 4px; }
.clip-text pre code { background: none; padding: 0; }
.clip-text img { margin: 1.2em 0; }
.clip-side { border-left: 1px solid var(--rule-2); background: var(--paper-2); overflow-y: auto; }
.clip-side .margin-body { padding-top: 20px; }
.clip-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.clip-actions .btn { min-height: 32px; font-size: 11px; }
.clip-note { margin-top: 20px; font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--faint); }

/* --------------------------------------------------------------- settings */

.settings-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr); gap: clamp(30px, 5vw, 64px); align-items: start; }
.settings-card { border: 1px solid var(--rule-2); background: var(--paper-2); padding: 24px; }
.settings-card + .settings-card { margin-top: 22px; }
.settings-card h2 { font-size: 28px; font-weight: 350; margin-bottom: 6px; }
.settings-card p { font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.settings-list { display: grid; gap: 0; margin-top: 15px; border-top: 1px solid var(--rule); }
.settings-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.settings-row .k { font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.settings-row .v { text-align: right; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.steps { margin: 12px 0 0 17px; padding: 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
.steps li { margin-bottom: 5px; }
code { font-family: var(--mono); font-size: 0.88em; }
.settings-card code { background: var(--paper-3); padding: 1px 5px; }

/* ------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .lower-grid { grid-template-columns: minmax(0, 1fr) 295px; gap: 34px; }
  .bookshelf { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .reader-layout { grid-template-columns: 260px minmax(0, 1fr) 320px; }
  .reader-layout.margin-closed { grid-template-columns: 260px minmax(0, 1fr) 0; }
  .reader-layout.outline-closed { grid-template-columns: 0 minmax(0, 1fr) 320px; }
  .masthead h1 { font-size: clamp(44px, 6.2vw, 78px); }
}

@media (max-width: 980px) {
  .lower-grid { grid-template-columns: 1fr; }
  .ledger { position: static; }
  .bookshelf { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .reader-layout { grid-template-columns: 0 minmax(0, 1fr) 0; }
  .reader-layout .outline-panel, .reader-layout .margin-panel { position: fixed; top: var(--bar); bottom: var(--map); width: min(330px, 88vw); z-index: 20; box-shadow: 0 0 60px rgba(0, 0, 0, 0.3); display: none; }
  .reader-layout .outline-panel { left: 0; }
  .reader-layout .margin-panel { right: 0; }
  .reader-layout.outline-open .outline-panel { display: block; }
  .reader-layout.margin-open .margin-panel { display: block; }
  .reader-layout.margin-open .margin-panel { display: block; }
  .reader-layout .desk { grid-column: 2; }
  .reader-layout.outline-open::after, .reader-layout.margin-open::after { content: ""; position: fixed; inset: var(--bar) 0 var(--map); z-index: 15; background: rgba(23, 21, 15, 0.32); }
  .clips-layout { grid-template-columns: 1fr; }
  .clip-main { grid-template-columns: 1fr; height: auto; }
  .clip-side { border-left: 0; border-top: 1px solid var(--rule-2); }
  .clip-article-wrap { overflow: visible; }
  .clip-page { overflow: auto; }
  .settings-grid { grid-template-columns: 1fr; }
  .masthead { grid-template-columns: 1fr; }
  .masthead-side { flex-direction: row; align-items: center; }
  .masthead-side .stamp { display: none; }
}

@media (max-width: 820px) {
  :root { --bar: 60px; --map: 58px; }
  .topnav { display: none; }
  .topbar { gap: 12px; }
  .top-actions .btn .long { display: none; }
  .masthead h1 { font-size: clamp(42px, 10vw, 68px); }
  .current-book { grid-template-columns: 132px minmax(0, 1fr); gap: 22px; padding: 22px 18px 24px; }
  .current-copy h2 { font-size: 30px; }
  .current-section { font-size: 17px; }
  .current-edition { display: none; }
  .margin-quote { grid-column: 1 / -1; }
  .bookshelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 16px; }
  .book-card h3 { font-size: 15px; }
  .reader-bar .book-meta h1 { max-width: 34vw; font-size: 15px; }
  .reader-bar .book-meta p { max-width: 34vw; }
  .reader-actions .btn .label { display: none; }
  .reader-actions .btn { width: 34px; padding: 5px; border-color: transparent; }
  .reader-actions .btn:hover { border-color: var(--rule); }
  .reading-map { grid-template-columns: 74px minmax(0, 1fr) 112px; gap: 12px; padding: 0 12px; }
  .page-counter strong { font-size: 19px; }
  .page-counter .of { display: none; }
  .map-labels { display: none; }
  .map-right { gap: 8px; }
  .map-stat strong { font-size: 15px; }
  .map-stat span { font-size: 7px; }
  .listen-btn { display: none; }
  .desk { padding: 18px 10px 60px; }
  .pdf-page { margin-bottom: 20px; }
  .selection-menu { max-width: calc(100vw - 16px); flex-wrap: wrap; justify-content: center; }
  .shortcut-grid { grid-template-columns: 1fr; }
  .clip-row { grid-template-columns: 32px minmax(0, 1fr); gap: 12px; }
  .clip-row-meta { grid-column: 2; text-align: left; display: flex; gap: 10px; }
  .clip-row-title { font-size: 21px; }
  .clip-article-wrap { padding: 26px 18px 60px; }
  .clip-text { font-size: 17.5px; }
  .site-foot { gap: 9px 18px; }
}

@media (max-width: 560px) {
  .shell { padding-left: 16px; padding-right: 16px; }
  .masthead h1 { font-size: 44px; }
  .masthead .lede { font-size: 16px; }
  .current-book { grid-template-columns: 100px minmax(0, 1fr); padding: 18px 16px 20px; }
  .current-copy h2 { font-size: 25px; }
  .current-actions .btn.primary { width: 100%; }
  .current-progress { margin-top: 16px; }
  .margin-quote { margin-top: 6px; }
  .bookshelf { gap: 22px 13px; }
  .book-card .byline { font-size: 8px; }
  .ledger { padding: 18px; }
  .ledger-stats { gap: 14px 10px; }
  .ledger-stat strong { font-size: 27px; }
  .reader-bar .book-meta h1 { max-width: 30vw; }
  .reader-bar .book-meta p { display: none; }
  .reader-bar { padding: 0 8px; gap: 6px; }
  .reader-actions { gap: 0; }
  .reader-actions .btn { width: 32px; }
  #focus-mode, #open-help { display: none; }
  .reading-map { grid-template-columns: 56px minmax(0, 1fr) 86px; }
  .page-counter { font-size: 8px; }
  .page-counter strong { font-size: 17px; }
  .map-stat span { display: none; }
  .clip-row { grid-template-columns: 24px minmax(0, 1fr); }
  .clip-actions .btn .label { display: none; }
  .clip-actions .btn { width: 34px; padding: 5px; }
  .dialog-body { padding: 18px 16px 22px; }
  .dropzone { min-height: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------- reader details */

.reader-boot {
  min-height: 58vh;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 7px;
  color: rgba(242, 236, 223, 0.7);
}
.reader-boot .boot-title {
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 46px);
  font-weight: 350;
  color: var(--paper);
  letter-spacing: -0.02em;
}
.reader-boot .boot-sub { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(242, 236, 223, 0.4); }
.reader-boot a { color: var(--paper); }
.pdf-page .page-label { z-index: 5; }
.pdf-page .page-loading { z-index: 0; }
.pdf-page .highlight-layer { z-index: 4; }
.pdf-page .highlight-layer .hl { z-index: 4; }
.pdf-page .textLayer { z-index: 2; }
.pdf-page .textLayer ::selection { background: rgba(173, 58, 39, 0.3); }
.outline-item[data-depth="3"].current { display: grid; }
.answer-box .answer p { margin: 0 0 0.7em; }
.answer-box .answer p:last-child { margin-bottom: 0; }
.brief-summary p { margin: 0 0 0.85em; }
.brief-summary p:last-child { margin-bottom: 0; }
.brief-empty .muted { font-size: 11px; }
.notes-empty a { color: var(--rust); }
.map-seg { border: 0; padding: 0; }
.map-cursor { left: 0; }
.reader-bar .book-meta h1 a { color: inherit; text-decoration: none; }

/* ------------------------------------------------------------------ text view */

.text-reader {
  width: min(760px, 100%);
  min-height: 70%;
  margin: 0 auto;
  padding: 34px clamp(24px, 4.4vw, 58px) 60px;
  background: var(--paper-2);
  color: var(--ink);
  box-shadow: var(--page-shadow);
  position: relative;
}
.text-reader .text-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule-2);
  margin-bottom: 26px;
}
.text-reader .text-kicker {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.text-reader .text-tools { display: flex; align-items: center; gap: 4px; }
.text-reader .text-tools button {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}
.text-reader .text-tools button:hover { border-color: var(--ink); color: var(--ink); }
.text-reader .text-heading .eyebrow { margin-bottom: 5px; }
.text-reader .text-heading h1 {
  font-family: var(--serif);
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 350;
  letter-spacing: -0.025em;
  margin-bottom: 7px;
}
.text-reader .text-heading .section-name {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 26px;
}
.text-reader .text-body {
  font-family: var(--serif);
  font-size: var(--text-size, 19px);
  line-height: 1.67;
  color: var(--ink-2);
}
.text-reader .text-body p { margin: 0 0 1.02em; }
.text-reader .text-body h3 {
  font-family: var(--serif);
  font-size: 1.28em;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 1.5em 0 0.55em;
  color: var(--ink);
}
.text-reader .text-note {
  margin-top: 30px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--faint);
}
.text-reader .text-empty { font-family: var(--serif); color: var(--muted); font-size: 18px; }
.text-reader .text-loading { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.text-reader .text-loading .loading-rule { margin-top: 14px; }

@media (max-width: 820px) {
  .map-track { gap: 0; }
  .map-seg { min-width: 1px; }
  .text-reader { padding: 24px 20px 46px; }
  .text-reader .text-body { line-height: 1.6; }
}

@media (max-width: 560px) {
  .current-book { grid-template-columns: 1fr; }
  .current-book .cover { display: none; }
  .current-copy h2 { font-size: 29px; }
  .current-actions .btn.primary { width: 100%; }
  .reader-actions .btn#toggle-text { display: inline-grid; }
}
