/* Gage Commonplace
   Subject: Chris Gage's self-hosted commonplace book. Typed objects (books, people, meetings, tasks)
   kept by an AI Scribe. Job: capture and control everything by asking.
   Type: EB Garamond for titles (the book), Source Sans 3 for the interface, Source Code Pro for figures.
   Colour: gilt leads (bookbinding gold leaf), ink for text, the Pandora set gives each type its own cloth.
   Signature: Scribe writes in the margin as a ruled ledger, every change an entry you can undo;
   books without covers are drawn as cloth-bound volumes. */

@font-face { font-family: 'EB Garamond'; src: url(/fonts/garamond.woff2) format('woff2'); font-weight: 400 800; font-display: swap; }
@font-face { font-family: 'EB Garamond'; src: url(/fonts/garamond-italic.woff2) format('woff2'); font-weight: 400 800; font-style: italic; font-display: swap; }
@font-face { font-family: 'Source Sans 3'; src: url(/fonts/sourcesans.woff2) format('woff2'); font-weight: 200 900; font-display: swap; }
@font-face { font-family: 'Source Sans 3'; src: url(/fonts/sourcesans-italic.woff2) format('woff2'); font-weight: 200 900; font-style: italic; font-display: swap; }
@font-face { font-family: 'Source Code Pro'; src: url(/fonts/sourcecode.woff2) format('woff2'); font-weight: 200 900; font-display: swap; }

:root {
  --paper: oklch(0.988 0.004 85);
  --leaf: oklch(0.974 0.006 85);
  --binding: oklch(0.958 0.009 85);
  --well: oklch(0.935 0.011 85);
  --rule: oklch(0.905 0.012 85);
  --rule-strong: oklch(0.84 0.016 85);
  --ink: oklch(0.282 0.020 85);
  --ink-soft: oklch(0.490 0.034 85);
  --ink-faint: oklch(0.62 0.026 85);
  --gilt: oklch(0.557 0.115 81);
  --gilt-hi: oklch(0.649 0.129 85);
  --gilt-wash: oklch(0.649 0.129 85 / 0.14);
  --on-gilt: oklch(0.99 0.01 85);
  --danger: oklch(0.52 0.15 25);
  --ok: oklch(0.56 0.11 145);
  --c-gilt: oklch(0.649 0.129 85);
  --c-slate: oklch(0.596 0.060 235);
  --c-moss: oklch(0.597 0.088 123);
  --c-clay: oklch(0.722 0.108 40);
  --c-rose: oklch(0.719 0.084 18);
  --c-oxblood: oklch(0.401 0.096 22);
  --c-plum: oklch(0.394 0.072 324);
  --c-ink: oklch(0.42 0.05 250);
  --shadow-1: 0 1px 2px oklch(0.3 0.03 85 / 0.08), 0 2px 8px oklch(0.3 0.03 85 / 0.06);
  --shadow-2: 0 2px 6px oklch(0.3 0.03 85 / 0.10), 0 12px 32px oklch(0.3 0.03 85 / 0.14);
  --font-display: 'EB Garamond', 'Iowan Old Style', Georgia, serif;
  --font-sans: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Source Code Pro', ui-monospace, Menlo, monospace;
  --r: 8px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --side: 256px;
  --margin: 400px;
  color-scheme: light;
}
.dark {
  --paper: oklch(0.205 0.012 85);
  --leaf: oklch(0.227 0.014 85);
  --binding: oklch(0.185 0.011 85);
  --well: oklch(0.255 0.015 85);
  --rule: oklch(0.30 0.014 85);
  --rule-strong: oklch(0.37 0.018 85);
  --ink: oklch(0.917 0.007 85);
  --ink-soft: oklch(0.731 0.023 85);
  --ink-faint: oklch(0.58 0.02 85);
  --gilt: oklch(0.70 0.125 83);
  --gilt-hi: oklch(0.76 0.13 85);
  --gilt-wash: oklch(0.70 0.125 83 / 0.16);
  --on-gilt: oklch(0.2 0.02 85);
  --c-slate: oklch(0.68 0.07 235);
  --c-moss: oklch(0.68 0.09 123);
  --c-oxblood: oklch(0.58 0.12 22);
  --c-plum: oklch(0.60 0.09 324);
  --c-ink: oklch(0.66 0.06 250);
  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.3), 0 2px 8px oklch(0 0 0 / 0.25);
  --shadow-2: 0 2px 6px oklch(0 0 0 / 0.35), 0 12px 32px oklch(0 0 0 / 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 400 16px/1.55 var(--font-sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--gilt); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--gilt-wash); }
.mono { font-family: var(--font-mono); font-size: 0.86em; letter-spacing: -0.01em; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.sc { font-variant: all-small-caps; letter-spacing: 0.06em; font-weight: 600; }
.hide { display: none !important; }

/* ───────────────────────── shell */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr) 0; height: 100vh; transition: grid-template-columns 280ms var(--ease); }
.app.with-scribe { grid-template-columns: var(--side) minmax(0, 1fr) var(--margin); }
.side { background: var(--binding); border-right: 1px solid var(--rule); display: flex; flex-direction: column; min-height: 0; }
.main { overflow-y: auto; min-width: 0; position: relative; scroll-behavior: smooth; }
.margin { border-left: 1px solid var(--rule); background: var(--leaf); min-width: 0; overflow: hidden; display: flex; flex-direction: column; }

.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 12px; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand-name { font: 600 21px/1 var(--font-display); letter-spacing: 0.01em; }
.brand-name em { font-style: italic; font-weight: 500; color: var(--gilt); }
.side-search { margin: 4px 12px 10px; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r); background: var(--paper); border: 1px solid var(--rule); color: var(--ink-soft); font-size: 14px; }
.side-search:hover { border-color: var(--rule-strong); color: var(--ink); }
.kbd { font: 500 11.5px/1 var(--font-mono); padding: 3px 5px; border-radius: 4px; border: 1px solid var(--rule-strong); color: var(--ink-soft); background: var(--leaf); }
.side-search .kbd { margin-left: auto; }
.side-scroll { overflow-y: auto; flex: 1; padding: 0 8px 12px; }
.nav-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 4px; color: var(--ink-faint); font-size: 14px; }
.nav-h button { color: var(--ink-faint); font-size: 18px; line-height: 1; padding: 0 4px; border-radius: 4px; }
.nav-h button:hover { color: var(--gilt); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 6px; font-size: 15px; color: var(--ink); position: relative; }
.nav a:hover { background: var(--well); }
.nav a.on { background: var(--paper); box-shadow: var(--shadow-1); font-weight: 600; }
.nav a.on::before { content: ''; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--tc, var(--gilt)); }
.nav .ic { width: 20px; text-align: center; font-size: 15px; flex: none; }
.nav .n { margin-left: auto; font: 500 12.5px var(--font-mono); color: var(--ink-faint); }
.tab-mark { width: 8px; height: 8px; border-radius: 2px; background: var(--tc); flex: none; margin-left: 2px; }
.side-foot { border-top: 1px solid var(--rule); padding: 10px 12px; display: flex; gap: 6px; align-items: center; }
.side-foot .btn { flex: 1; justify-content: center; }

/* ───────────────────────── buttons, inputs */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: var(--r); font-size: 14.5px; font-weight: 600; border: 1px solid var(--rule-strong); background: var(--paper); color: var(--ink); white-space: nowrap; transition: background 160ms, border-color 160ms, transform 120ms; }
.btn:hover { background: var(--well); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--gilt); border-color: var(--gilt); color: var(--on-gilt); }
.btn.primary:hover { background: var(--gilt-hi); border-color: var(--gilt-hi); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn.ghost:hover { background: var(--well); color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 14px; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn.sm.icon { width: 28px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.field .hint { font-size: 14px; color: var(--ink-faint); }
.input, select.input, textarea.input { width: 100%; padding: 8px 11px; border-radius: var(--r); border: 1px solid var(--rule-strong); background: var(--paper); font-size: 15px; outline: none; transition: border-color 150ms, box-shadow 150ms; }
.input:focus { border-color: var(--gilt); box-shadow: 0 0 0 3px var(--gilt-wash); }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.5; }
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--well); gap: 2px; }
.seg button { height: 28px; padding: 0 11px; border-radius: 7px; font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-1); }

/* ───────────────────────── page scaffolding */
.page { max-width: 980px; margin: 0 auto; padding: 36px 48px 120px; }
.page.wide { max-width: 1240px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); margin-bottom: 22px; min-height: 28px; }
.crumbs a:hover { color: var(--ink); }
.crumbs .sp { flex: 1; }
.h-display { font: 500 52px/1.04 var(--font-display); letter-spacing: -0.012em; margin: 0; }
.h-title { font: 500 44px/1.08 var(--font-display); letter-spacing: -0.01em; margin: 0; outline: none; word-break: break-word; }
.h-title:empty::before { content: 'Untitled'; color: var(--ink-faint); }
.h-sec { font: 600 15px/1.2 var(--font-sans); margin: 0 0 12px; display: flex; align-items: baseline; gap: 10px; color: var(--ink); }
.h-sec .count { font: 500 12.5px var(--font-mono); color: var(--ink-faint); }
.h-sec a.more { margin-left: auto; font-size: 14px; font-weight: 500; color: var(--ink-soft); }
.h-sec a.more:hover { color: var(--gilt); }
.empty { padding: 28px; text-align: center; color: var(--ink-faint); font-size: 15px; border: 1px dashed var(--rule-strong); border-radius: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: 999px; background: var(--well); font-size: 14px; color: var(--ink); max-width: 100%; }
.chip .x { color: var(--ink-faint); margin-left: 2px; }
.chip .x:hover { color: var(--danger); }
a.chip:hover { background: var(--gilt-wash); }
.chip img { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; margin-left: -5px; }
.chip.book img { border-radius: 2px; height: 20px; width: 14px; }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 6px; font-size: 14px; font-weight: 600; background: color-mix(in oklch, var(--pc, var(--ink-soft)) 16%, transparent); color: color-mix(in oklch, var(--pc, var(--ink-soft)) 80%, var(--ink)); white-space: nowrap; }
.typechip { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--tc); }
.typechip .sw { width: 9px; height: 9px; border-radius: 2px; background: var(--tc); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--pc, var(--ink-faint)); flex: none; }

/* ───────────────────────── covers */
.cover { position: relative; overflow: hidden; background: var(--well); flex: none; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover.book, .cover.poster { aspect-ratio: 2 / 3; border-radius: 3px 6px 6px 3px; box-shadow: var(--shadow-1); }
.cover.book::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, oklch(0 0 0 / 0.22) 0, oklch(1 0 0 / 0.16) 3%, oklch(0 0 0 / 0.06) 6%, transparent 10%); pointer-events: none; }
.cover.poster { border-radius: 6px; }
.cover.wide { aspect-ratio: 16 / 9; border-radius: 10px; }
.cover.avatar { aspect-ratio: 1; border-radius: 50%; }
.cloth { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 14% 11% 12%; background: var(--cloth); color: oklch(0.96 0.03 85); text-align: center; }
.cloth::before { content: ''; position: absolute; inset: 6%; border: 1px solid oklch(0.85 0.1 85 / 0.55); border-radius: 2px; pointer-events: none; }
.cloth .t { font: 500 var(--ct, 17px)/1.12 var(--font-display); text-wrap: balance; }
.cloth .a { font: 600 var(--ca, 10px)/1.2 var(--font-sans); letter-spacing: 0.16em; text-transform: uppercase; color: oklch(0.86 0.11 85); }
.cloth .rule { width: 30%; height: 1px; background: oklch(0.85 0.11 85 / 0.7); margin: 0 auto; }
.mono-face { position: absolute; inset: 0; display: grid; place-items: center; font: 500 var(--mf, 28px)/1 var(--font-display); color: oklch(0.97 0.02 85); background: var(--cloth); }

/* ───────────────────────── home */
.greet { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.greet .date { font: 500 14px var(--font-mono); color: var(--ink-soft); margin-bottom: 8px; letter-spacing: 0.02em; }
.ask { position: relative; margin-bottom: 36px; }
.ask textarea { width: 100%; resize: none; border-radius: 14px; border: 1px solid var(--rule-strong); background: var(--leaf); padding: 18px 120px 18px 52px; font: 400 19px/1.4 var(--font-sans); outline: none; min-height: 64px; box-shadow: var(--shadow-1); transition: border-color 160ms, box-shadow 160ms; }
.ask textarea:focus { border-color: var(--gilt); box-shadow: 0 0 0 4px var(--gilt-wash), var(--shadow-1); }
.ask .nib { position: absolute; left: 18px; top: 20px; width: 22px; height: 22px; color: var(--gilt); }
.ask .go { position: absolute; right: 10px; top: 13px; }
.ask-ideas { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ask-ideas button { font-size: 14px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--rule); color: var(--ink-soft); background: transparent; }
.ask-ideas button:hover { border-color: var(--gilt); color: var(--ink); background: var(--gilt-wash); }
.home-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 28px 40px; }
.home-grid > section { min-width: 0; }
.span-2 { grid-column: 1 / -1; }
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 12px; padding: 9px 10px; margin: 0 -10px; border-radius: 8px; min-height: 42px; }
.row:hover { background: var(--well); }
.row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15.5px; }
.row .meta { font: 500 13px var(--font-mono); color: var(--ink-faint); white-space: nowrap; }
.row .meta.late { color: var(--danger); }
.row .ic { width: 22px; text-align: center; flex: none; }
.tick { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--rule-strong); flex: none; display: grid; place-items: center; transition: background 150ms, border-color 150ms; }
.tick:hover { border-color: var(--ok); }
.tick.done { background: var(--ok); border-color: var(--ok); }
.tick.done::after { content: '✓'; color: white; font-size: 12px; font-weight: 700; }
.when { display: grid; grid-template-columns: 58px 1fr; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.when:last-child { border-bottom: 0; }
.when .d { text-align: center; line-height: 1.05; }
.when .d b { display: block; font: 500 26px var(--font-display); }
.when .d span { font: 600 11.5px var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.when .t { font-size: 15.5px; font-weight: 600; }
.when .s { font-size: 14px; color: var(--ink-soft); }
.shelf { display: flex; gap: 16px; overflow-x: auto; padding: 4px 2px 12px; scroll-snap-type: x mandatory; }
.shelf .vol { width: 104px; flex: none; scroll-snap-align: start; }
.vol .cover { transition: transform 260ms var(--ease), box-shadow 260ms var(--ease); }
.vol:hover .cover { transform: translateY(-4px) rotate(-0.6deg); box-shadow: var(--shadow-2); }
.vol .vt { font-size: 14px; font-weight: 600; margin-top: 8px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vol .vs { font-size: 14px; color: var(--ink-faint); }
.daily-card { border: 1px solid var(--rule); border-radius: 12px; padding: 16px 18px; background: var(--leaf); }
.daily-card .md { font-size: 15px; max-height: 260px; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, #000 75%, transparent); mask-image: linear-gradient(180deg, #000 75%, transparent); }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.proj { border: 1px solid var(--rule); border-radius: 12px; padding: 14px 16px; background: var(--leaf); display: grid; gap: 6px; transition: border-color 160ms, transform 200ms var(--ease); }
.proj:hover { border-color: var(--rule-strong); transform: translateY(-2px); }
.proj .pt { font: 500 21px/1.15 var(--font-display); }
.proj .ps { font-size: 14px; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; }

/* ───────────────────────── collections */
.coll-head { display: flex; align-items: flex-end; gap: 18px; margin-bottom: 22px; }
.coll-head .big-ic { font-size: 40px; line-height: 1; }
.coll-head .grow { flex: 1; min-width: 0; }
.coll-head .sub { color: var(--ink-soft); font-size: 15px; margin-top: 6px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.toolbar .input { width: 240px; height: 34px; padding: 0 11px; }
.toolbar select.input { width: auto; }
.toolbar .sp { flex: 1; }
.gallery { display: grid; gap: 28px 22px; grid-template-columns: repeat(auto-fill, minmax(var(--gw, 148px), 1fr)); }
.gallery.wide { --gw: 250px; }
.gallery.avatar { --gw: 150px; text-align: center; }
.gallery.avatar .cover { width: 112px; margin: 0 auto; }
.card { display: block; min-width: 0; }
.card .cover { transition: transform 260ms var(--ease), box-shadow 260ms var(--ease); }
.card:hover .cover { transform: translateY(-4px); box-shadow: var(--shadow-2); }
.card .ct { font-size: 15px; font-weight: 600; margin-top: 10px; line-height: 1.25; }
.card .cs { font-size: 14px; color: var(--ink-soft); margin-top: 3px; display: flex; gap: 6px; align-items: center; justify-content: inherit; flex-wrap: wrap; }
.card.textcard { border: 1px solid var(--rule); border-radius: 12px; padding: 16px; background: var(--leaf); }
.card.textcard:hover { border-color: var(--rule-strong); }
.card.textcard .ct { margin-top: 0; font: 500 21px/1.2 var(--font-display); }
.card.textcard .ex { font-size: 14px; color: var(--ink-soft); margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.stars { color: var(--gilt); letter-spacing: 1px; font-size: 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 12px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.grid th { text-align: left; font-weight: 600; color: var(--ink-soft); padding: 10px 14px; border-bottom: 1px solid var(--rule); background: var(--leaf); white-space: nowrap; cursor: pointer; user-select: none; }
table.grid th:hover { color: var(--ink); }
table.grid td { padding: 9px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover td { background: var(--well); }
table.grid td.tt { font-weight: 600; display: flex; align-items: center; gap: 10px; max-width: 360px; }
table.grid td.tt .cover { width: 24px; }
table.grid td.tt .cover.avatar, table.grid td.tt .cover.wide { width: 28px; aspect-ratio: 1; border-radius: 50%; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.lane { background: var(--leaf); border: 1px solid var(--rule); border-radius: 12px; padding: 10px; min-height: 120px; transition: background 150ms, border-color 150ms; }
.lane.over { background: var(--gilt-wash); border-color: var(--gilt); }
.lane-h { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-size: 14px; font-weight: 700; }
.lane-h .n { font: 500 12.5px var(--font-mono); color: var(--ink-faint); margin-left: auto; }
.bcard { display: block; background: var(--paper); border: 1px solid var(--rule); border-radius: 9px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow-1); cursor: grab; }
.bcard:hover { border-color: var(--rule-strong); }
.bcard.dragging { opacity: 0.4; }
.bcard .bt { font-size: 15px; font-weight: 600; line-height: 1.3; }
.bcard .bm { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; font-size: 14px; color: var(--ink-soft); align-items: center; }
.bcard .cover { width: 44px; float: right; margin: 0 0 4px 10px; }
.list-rows .row { border-bottom: 1px solid var(--rule); border-radius: 0; margin: 0; padding: 11px 6px; }
.list-rows .row:hover { border-radius: 8px; }

/* ───────────────────────── object page */
.obj-hero { display: grid; gap: 34px; grid-template-columns: 1fr; margin-bottom: 18px; }
.obj-hero.has-side { grid-template-columns: 210px minmax(0, 1fr); align-items: start; }
.obj-hero.avatar { grid-template-columns: 120px minmax(0, 1fr); align-items: center; }
.banner { margin: -36px -48px 26px; height: 230px; position: relative; overflow: hidden; background: var(--well); }
.banner img { width: 100%; height: 100%; object-fit: cover; }
.cover-wrap { position: relative; }
.obj-hero .cover-wrap .cover { width: 100% !important; }
.cover-wrap .cover-act { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); opacity: 0; transition: opacity 160ms; white-space: nowrap; }
.cover-wrap:hover .cover-act, .banner:hover .cover-act { opacity: 1; }
.banner .cover-act { position: absolute; right: 16px; bottom: 14px; opacity: 0; transition: opacity 160ms; }
.obj-icon { font-size: 42px; line-height: 1; margin-bottom: 10px; display: inline-block; border-radius: 8px; padding: 2px; cursor: pointer; }
.obj-icon:hover { background: var(--well); }
.obj-type { margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.obj-sub { margin-top: 10px; font-size: 16px; color: var(--ink-soft); }
.obj-sub a { color: var(--ink); border-bottom: 1px solid var(--rule-strong); }
.obj-sub a:hover { border-color: var(--gilt); }
.props { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 2px 14px; margin-top: 22px; font-size: 15px; }
.props .pk { color: var(--ink-soft); padding: 7px 0; display: flex; align-items: center; gap: 7px; min-height: 36px; }
.props .pk .k-ic { width: 16px; color: var(--ink-faint); font: 500 12px var(--font-mono); text-align: center; }
.props .pv { min-height: 36px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 3px 0; min-width: 0; }
.props .pv input.bare { border: 0; background: transparent; outline: none; width: 100%; padding: 6px 8px; margin-left: -8px; border-radius: 6px; font-size: 15px; }
.props .pv input.bare:hover { background: var(--well); }
.props .pv input.bare:focus { background: var(--paper); box-shadow: 0 0 0 1px var(--rule-strong); }
.props .pv input.bare::placeholder { color: var(--ink-faint); }
.props .pv .add { color: var(--ink-faint); font-size: 14px; padding: 3px 8px; border-radius: 6px; }
.props .pv .add:hover { background: var(--well); color: var(--ink); }
.props .pv .open { color: var(--ink-faint); padding: 0 6px; }
.props .more-props { grid-column: 1 / -1; margin-top: 4px; }
.rate button { font-size: 19px; color: var(--rule-strong); padding: 0 1px; transition: color 120ms, transform 120ms; }
.rate button.on { color: var(--gilt); }
.rate:hover button { color: var(--gilt-hi); }
.rate button:hover ~ button { color: var(--rule-strong); }
.rate button:active { transform: scale(1.2); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.tag { font-size: 14px; color: var(--ink-soft); }
.tag::before { content: '#'; color: var(--ink-faint); }
.body-bar { display: flex; align-items: center; justify-content: space-between; margin: 34px 0 6px; padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
.editor { width: 100%; border: 0; outline: none; background: transparent; resize: none; font: 400 17px/1.7 var(--font-sans); min-height: 240px; padding: 8px 0; overflow: hidden; }
.saved { font: 500 12.5px var(--font-mono); color: var(--ink-faint); transition: opacity 400ms; }

/* Markdown */
.md { font-size: 17px; line-height: 1.7; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 1.5em 0 0.4em; }
.md h1 { font-size: 30px; } .md h2 { font-size: 25px; } .md h3 { font-size: 20px; }
.md h4 { font-size: 16px; margin: 1.2em 0 0.3em; }
.md p { margin: 0.55em 0; }
.md ul, .md ol { padding-left: 1.4em; margin: 0.5em 0; }
.md li { margin: 0.2em 0; }
.md li.task { list-style: none; margin-left: -1.4em; display: flex; gap: 10px; align-items: flex-start; }
.md li.task input { margin-top: 7px; accent-color: var(--ok); width: 16px; height: 16px; flex: none; cursor: pointer; }
.md li.task.done > span { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: var(--rule-strong); }
.md blockquote { margin: 1em 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--gilt); font: italic 400 19px/1.55 var(--font-display); color: var(--ink-soft); }
.md code { font-family: var(--font-mono); font-size: 0.86em; background: var(--well); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--well); padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-size: 14px; }
.md pre code { background: none; padding: 0; }
.md a { color: var(--gilt); border-bottom: 1px solid color-mix(in oklch, var(--gilt) 40%, transparent); }
.md a.wl { color: var(--ink); font-weight: 600; border-bottom: 1.5px solid var(--gilt); }
.md a.wl:hover { background: var(--gilt-wash); }
.md a.wl.missing { color: var(--ink-soft); border-bottom-style: dashed; font-weight: 500; }
.md img { max-width: 100%; border-radius: 8px; }
.md hr { border: 0; border-top: 1px solid var(--rule); margin: 1.6em 0; }
.md table { border-collapse: collapse; margin: 1em 0; font-size: 15px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--rule); padding: 6px 10px; text-align: left; }
.md th { background: var(--leaf); }
.md mark { background: var(--gilt-wash); color: inherit; padding: 0 2px; border-radius: 3px; }

.linked { margin-top: 54px; }
.linked-group { margin-bottom: 26px; }
.linked .shelf .vol { width: 96px; }
.ord { position: absolute; top: 6px; left: 8px; z-index: 2; font: 600 12px var(--font-mono); background: oklch(0.2 0.02 85 / 0.72); color: white; border-radius: 4px; padding: 1px 5px; }

/* ───────────────────────── calendar, graph, ledger */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); border-radius: 12px; overflow: hidden; }
.cal .dow { padding: 8px 10px; font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); background: var(--leaf); }
.cal .day { min-height: 118px; padding: 6px 8px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); cursor: pointer; display: flex; flex-direction: column; gap: 3px; transition: background 140ms; min-width: 0; }
.cal .day:hover { background: var(--leaf); }
.cal .day.out { background: color-mix(in oklch, var(--well) 50%, transparent); color: var(--ink-faint); }
.cal .day .num { font: 500 19px var(--font-display); display: flex; align-items: center; gap: 6px; }
.cal .day.today .num b { background: var(--gilt); color: var(--on-gilt); border-radius: 999px; padding: 0 8px; font-weight: 600; }
.cal .day .has-note { width: 6px; height: 6px; border-radius: 50%; background: var(--gilt); }
.cal .ev { font-size: 13.5px; line-height: 1.3; padding: 2px 6px; border-radius: 5px; background: color-mix(in oklch, var(--tc) 15%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev .tm { font: 500 11.5px var(--font-mono); color: var(--ink-soft); margin-right: 4px; }
.graph-wrap { position: relative; height: calc(100vh - 170px); min-height: 420px; border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; background: var(--leaf); }
.graph-wrap canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.graph-legend { position: absolute; left: 14px; top: 14px; display: flex; flex-wrap: wrap; gap: 6px; max-width: 70%; }
.graph-legend button { font-size: 13.5px; padding: 3px 9px; border-radius: 999px; background: var(--paper); border: 1px solid var(--rule); display: inline-flex; gap: 6px; align-items: center; }
.graph-legend button.off { opacity: 0.4; }
.ledger-entry { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--rule); align-items: start; }
.ledger-entry .when-col { font: 500 13px/1.5 var(--font-mono); color: var(--ink-faint); }
.ledger-entry .prompt { font: italic 500 20px/1.3 var(--font-display); }
.ledger-entry.undone .prompt, .ledger-entry.undone .items { text-decoration: line-through; color: var(--ink-faint); }
.ledger-entry .items { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ───────────────────────── Scribe, the margin */
.scribe-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--rule); }
.scribe-head .nm { font: 600 21px/1 var(--font-display); display: flex; align-items: center; gap: 8px; }
.scribe-head .nm svg { width: 18px; height: 18px; color: var(--gilt); }
.scribe-head .model { font: 500 12px var(--font-mono); color: var(--ink-faint); margin-left: 2px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scribe-head .sp { flex: 1; }
.scribe-log { flex: 1; overflow-y: auto; padding: 18px 18px 8px; scroll-behavior: smooth; }
.msg-user { margin: 6px 0 16px auto; max-width: 88%; width: fit-content; background: var(--paper); border: 1px solid var(--rule); border-radius: 14px 14px 4px 14px; padding: 10px 14px; font-size: 15.5px; white-space: pre-wrap; box-shadow: var(--shadow-1); }
.msg-ai { margin: 0 0 22px; }
.ledger { position: relative; margin: 2px 0 10px; padding-left: 16px; }
.ledger::before { content: ''; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--rule-strong); }
.ll { position: relative; font-size: 14px; line-height: 1.4; padding: 4px 0; color: var(--ink-soft); animation: ink-in 420ms var(--ease) both; }
.ll::before { content: ''; position: absolute; left: -15px; top: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--leaf); border: 1.5px solid var(--rule-strong); }
.ll.ok::before { border-color: var(--gilt); background: var(--gilt); }
.ll.err { color: var(--danger); }
.ll.err::before { border-color: var(--danger); }
.ll.run::before { border-color: var(--gilt); animation: breathe 1.1s ease-in-out infinite; }
.ll.change { color: var(--ink); font-weight: 600; }
.ll.change::before { border-radius: 2px; background: var(--gilt); border-color: var(--gilt); transform: rotate(45deg); }
.ll .verb { font-variant: all-small-caps; letter-spacing: 0.06em; color: var(--gilt); font-weight: 700; margin-right: 4px; }
.ll a { border-bottom: 1px solid var(--gilt); }
@keyframes ink-in { from { clip-path: inset(0 100% 0 0); opacity: 0.2; } to { clip-path: inset(0 0 0 0); opacity: 1; } }
@keyframes breathe { 50% { transform: scale(1.35); background: var(--gilt-wash); } }
.reply { font-size: 15.5px; line-height: 1.6; }
.reply.md { font-size: 15.5px; }
.reply.md p { margin: 0.35em 0; }
.reply.err { color: var(--danger); }
.stamp { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 10px 8px 12px; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); font-size: 14px; }
.stamp .n { font-weight: 700; }
.stamp .sp { flex: 1; }
.stamp.undone { color: var(--ink-faint); text-decoration: line-through; }
.thinking { display: inline-flex; gap: 5px; padding: 6px 0 6px 16px; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--gilt); animation: blot 1.2s ease-in-out infinite; }
.thinking i:nth-child(2) { animation-delay: 0.15s; } .thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blot { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1.1); } }
.scribe-empty { padding: 8px 2px; }
.scribe-empty h3 { font: 500 28px/1.15 var(--font-display); margin: 6px 0 8px; }
.scribe-empty p { color: var(--ink-soft); font-size: 15px; margin: 0 0 16px; }
.sugg { display: grid; gap: 8px; }
.sugg button { text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--rule); background: var(--paper); font-size: 14.5px; transition: border-color 150ms, background 150ms; }
.sugg button:hover { border-color: var(--gilt); background: var(--gilt-wash); }
.composer { border-top: 1px solid var(--rule); padding: 12px 14px 14px; background: var(--leaf); }
.ctx { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 13.5px; color: var(--ink-soft); min-height: 24px; }
.ctx .chip { height: 24px; font-size: 13.5px; background: var(--paper); border: 1px solid var(--rule); }
.composer-box { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--rule-strong); border-radius: 12px; background: var(--paper); padding: 6px 6px 6px 12px; transition: border-color 150ms, box-shadow 150ms; }
.composer-box:focus-within { border-color: var(--gilt); box-shadow: 0 0 0 3px var(--gilt-wash); }
.composer textarea { flex: 1; border: 0; outline: none; background: transparent; resize: none; font-size: 15.5px; line-height: 1.45; max-height: 180px; padding: 6px 0; }
.chat-list { padding: 8px; }
.chat-list a { display: block; padding: 9px 10px; border-radius: 8px; font-size: 14.5px; }
.chat-list a:hover { background: var(--well); }
.chat-list .d { font: 500 12px var(--font-mono); color: var(--ink-faint); }

/* ───────────────────────── overlays */
.scrim { position: fixed; inset: 0; background: oklch(0.2 0.02 85 / 0.34); backdrop-filter: blur(2px); z-index: 50; display: grid; place-items: start center; padding-top: 11vh; animation: fade 160ms ease both; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(0.985); } }
.dialog { width: min(560px, calc(100vw - 32px)); max-height: 78vh; overflow: auto; background: var(--paper); border-radius: 16px; box-shadow: var(--shadow-2); border: 1px solid var(--rule); animation: rise 220ms var(--ease) both; }
.dialog.wide { width: min(820px, calc(100vw - 32px)); }
.dialog-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 6px; }
.dialog-h h2 { font: 500 26px var(--font-display); margin: 0; }
.dialog-b { padding: 12px 22px 18px; }
.dialog-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 18px; }
.palette { width: min(640px, calc(100vw - 32px)); background: var(--paper); border-radius: 16px; box-shadow: var(--shadow-2); border: 1px solid var(--rule); overflow: hidden; animation: rise 200ms var(--ease) both; }
.palette input { width: 100%; border: 0; outline: none; background: transparent; padding: 18px 20px; font-size: 19px; border-bottom: 1px solid var(--rule); }
.palette .res { max-height: 56vh; overflow-y: auto; padding: 6px; }
.palette .grp { font-size: 13px; color: var(--ink-faint); padding: 10px 12px 4px; font-weight: 600; }
.palette .it { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; cursor: pointer; }
.palette .it.sel { background: var(--well); }
.palette .it .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15.5px; }
.palette .it .snip { display: block; font-size: 13.5px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette .it .cover { width: 22px; }
.palette .it .cover.avatar, .palette .it .cover.wide { width: 24px; aspect-ratio: 1; border-radius: 50%; }
.pop { position: fixed; z-index: 60; min-width: 220px; max-width: 340px; background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--shadow-2); padding: 6px; animation: rise 160ms var(--ease) both; max-height: 360px; overflow-y: auto; }
.pop .mi { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; font-size: 14.5px; text-align: left; }
.pop .mi:hover, .pop .mi.sel { background: var(--well); }
.pop .mi.danger { color: var(--danger); }
.pop .mi .cover { width: 18px; }
.pop .mi .cover.avatar { width: 20px; }
.pop input.input { margin-bottom: 4px; }
.pop .sep { height: 1px; background: var(--rule); margin: 5px 4px; }
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; justify-items: center; }
.toast { display: flex; align-items: center; gap: 14px; background: var(--ink); color: var(--paper); padding: 10px 12px 10px 16px; border-radius: 12px; font-size: 14.5px; box-shadow: var(--shadow-2); animation: rise 240ms var(--ease) both; }
.toast button { color: var(--gilt-hi); font-weight: 700; padding: 3px 6px; }
.toast.err { background: var(--danger); color: white; }

/* ───────────────────────── settings */
.set-grid { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 40px; }
.set-nav { position: sticky; top: 24px; align-self: start; display: grid; gap: 2px; }
.set-nav a { padding: 7px 10px; border-radius: 7px; font-size: 15px; color: var(--ink-soft); }
.set-nav a:hover { background: var(--well); color: var(--ink); }
.set-sec { margin-bottom: 48px; scroll-margin-top: 24px; }
.set-sec h2 { font: 500 30px var(--font-display); margin: 0 0 4px; }
.set-sec > p { color: var(--ink-soft); margin: 0 0 20px; font-size: 15px; }
.set-card { border: 1px solid var(--rule); border-radius: 14px; padding: 20px; background: var(--leaf); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }
.code { font: 500 13.5px/1.55 var(--font-mono); background: var(--well); padding: 12px 14px; border-radius: 10px; white-space: pre-wrap; word-break: break-all; }
.type-row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--rule); }
.type-row:last-child { border-bottom: 0; }
.type-row .ic { font-size: 20px; width: 26px; text-align: center; }
.type-row .t { flex: 1; font-weight: 600; }
.prop-ed { display: grid; grid-template-columns: 1fr 130px 1fr 30px; gap: 8px; align-items: center; margin-bottom: 8px; }
.prop-ed .input { height: 34px; padding: 0 9px; font-size: 14.5px; }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--ink-soft); margin-top: 10px; }

/* ───────────────────────── login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 30% 20%, var(--gilt-wash), transparent 60%), var(--paper); }
.login-card { width: min(400px, 100%); text-align: center; }
.login-card .brand-mark { width: 54px; height: 54px; margin: 0 auto 18px; display: block; }
.login-card h1 { font: 500 44px/1.05 var(--font-display); margin: 0 0 6px; }
.login-card h1 em { color: var(--gilt); }
.login-card p { color: var(--ink-soft); margin: 0 0 28px; }
.login-card form { display: grid; gap: 10px; }
.login-card .input { height: 46px; text-align: center; font-size: 17px; }
.login-card .btn { height: 46px; justify-content: center; font-size: 16px; }
.login-card .err { color: var(--danger); font-size: 14.5px; min-height: 22px; }

/* ───────────────────────── small screens */
.mob-bar { display: none; }
@media (max-width: 1180px) { .app.with-scribe { grid-template-columns: var(--side) minmax(0, 1fr) 360px; } :root { --margin: 360px; } }
@media (max-width: 980px) {
  .app, .app.with-scribe { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform 260ms var(--ease); box-shadow: var(--shadow-2); }
  .app.nav-open .side { transform: none; }
  .margin { position: fixed; inset: 0; z-index: 45; transform: translateY(100%); transition: transform 300ms var(--ease); border: 0; }
  .app.with-scribe .margin { transform: none; }
  .mob-bar { display: flex; position: sticky; top: 0; z-index: 30; align-items: center; gap: 8px; padding: 10px 12px; background: color-mix(in oklch, var(--paper) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
  .mob-bar .brand-name { font-size: 19px; flex: 1; }
  .page { padding: 22px 18px 110px; }
  .banner { margin: -22px -18px 22px; height: 170px; }
  .home-grid { grid-template-columns: 1fr; }
  .h-display { font-size: 38px; }
  .h-title { font-size: 34px; }
  .obj-hero.has-side { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .obj-hero.has-side .cover-wrap { width: 150px; }
  .obj-hero.avatar { grid-template-columns: minmax(0, 1fr); }
  .obj-hero.avatar .cover-wrap { width: 96px; }
  .crumbs .mono, .crumbs .saved { display: none; }
  .cover-wrap .cover-act { opacity: 1; }
  .props { grid-template-columns: 110px minmax(0, 1fr); }
  .set-grid { grid-template-columns: 1fr; }
  .set-nav { display: none; }
  .two { grid-template-columns: 1fr; }
  .ask textarea { padding-right: 64px; font-size: 17px; }
  .ask .go .lbl { display: none; }
  .gallery { --gw: 120px; gap: 22px 14px; }
  .fab { display: grid !important; }
}
.fab { display: none; position: fixed; right: 18px; bottom: 18px; z-index: 35; width: 56px; height: 56px; border-radius: 50%; background: var(--gilt); color: var(--on-gilt); place-items: center; box-shadow: var(--shadow-2); }
.fab svg { width: 24px; height: 24px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
