/* The Vault: black and brass (dark), paper and brass (light). Left rail = the brains, the account at its foot; a brain
   opens as a brain of stippled dots whose parts are its books; a book opens as a contents page of lessons with call
   numbers, set in a reading serif. Search results and the archive show lessons as index cards.
   Light = paper and ink, dark = black. Both come from one set of tokens (light-dark()); the Light / Dark / System
   switch sets html[data-theme] (theme.js, loaded first so nothing flashes). Phone: the rail folds into a top bar. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#F6F5F2, #0B0B0C);
  --surface: light-dark(#FFFFFF, #141416);
  --sunk: light-dark(#EDEBE6, #1D1D20);
  --rail: light-dark(#EFEDE8, #08080A);
  --ink: light-dark(#141414, #ECEAE6);
  --muted: light-dark(#6B6862, #8E8C87);
  --line: light-dark(#DEDBD4, #27272B);
  --rule: light-dark(#E2CF9F, #4A3F26);        /* the brass rule under an open lesson */
  --accent: light-dark(#806224, #D3AE66);      /* brass: the one colour that means "this one"; red stays for danger */
  --accent-ink: light-dark(#FFFFFF, #141210);
  --accent-soft: light-dark(#F2E9D3, #2B2517);
  --danger: light-dark(#B42318, #F27A6D);
  --danger-soft: light-dark(#FBE3E0, #3A1714);
  --warn: light-dark(#8A4B00, #F0A04B);
  --warn-soft: light-dark(#F7E7CF, #33240F);
  --ok: light-dark(#2F6B3A, #8CCB98);
  --toast-bg: light-dark(#141414, #ECEAE6);
  --toast-ink: light-dark(#F6F5F2, #0B0B0C);
  --mark-tile: light-dark(#FFFFFF, #141416);
  --shadow-c: light-dark(rgba(20, 20, 20, 0.07), rgba(0, 0, 0, 0.5));
  --shadow: 0 1px 0 var(--line), 0 6px 18px var(--shadow-c);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B6862' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  --f-ui: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-read: "Literata", ui-serif, Georgia, "Times New Roman", serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 6px;
  --r-ctl: 6px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238E8C87' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238E8C87' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}

/* Browsers without light-dark() (before Safari/iOS 17.5, Chrome 123, Firefox 120): the same colours as plain
   values, generated from :root above (tests/test_library.py checks they match). */
@supports not (color: light-dark(#000, #fff)) {
  :root { --bg: #F6F5F2; --surface: #FFFFFF; --sunk: #EDEBE6; --rail: #EFEDE8; --ink: #141414; --muted: #6B6862; --line: #DEDBD4; --rule: #E2CF9F; --accent: #806224; --accent-ink: #FFFFFF; --accent-soft: #F2E9D3; --danger: #B42318; --danger-soft: #FBE3E0; --warn: #8A4B00; --warn-soft: #F7E7CF; --ok: #2F6B3A; --toast-bg: #141414; --toast-ink: #F6F5F2; --mark-tile: #FFFFFF; --shadow-c: rgba(20, 20, 20, 0.07); }
  :root[data-theme="dark"] { --bg: #0B0B0C; --surface: #141416; --sunk: #1D1D20; --rail: #08080A; --ink: #ECEAE6; --muted: #8E8C87; --line: #27272B; --rule: #4A3F26; --accent: #D3AE66; --accent-ink: #141210; --accent-soft: #2B2517; --danger: #F27A6D; --danger-soft: #3A1714; --warn: #F0A04B; --warn-soft: #33240F; --ok: #8CCB98; --toast-bg: #ECEAE6; --toast-ink: #0B0B0C; --mark-tile: #141416; --shadow-c: rgba(0, 0, 0, 0.5); }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --bg: #0B0B0C; --surface: #141416; --sunk: #1D1D20; --rail: #08080A; --ink: #ECEAE6; --muted: #8E8C87; --line: #27272B; --rule: #4A3F26; --accent: #D3AE66; --accent-ink: #141210; --accent-soft: #2B2517; --danger: #F27A6D; --danger-soft: #3A1714; --warn: #F0A04B; --warn-soft: #33240F; --ok: #8CCB98; --toast-bg: #ECEAE6; --toast-ink: #0B0B0C; --mark-tile: #141416; --shadow-c: rgba(0, 0, 0, 0.5); }
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-ui); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.i { flex: none; display: block; }
.muted { color: var(--muted); }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-family: var(--f-read); font-weight: 600; letter-spacing: -0.01em; }

/* spacing system */
.stack { display: flex; flex-direction: column; gap: 22px; }
.stack.tight { gap: 14px; }
.group { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.grow { flex: 1 1 260px; min-width: 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px;
  border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface); font-weight: 500; font-size: 14px;
  white-space: nowrap; min-width: max-content; text-decoration: none; color: var(--ink);
}
.btn:hover:not(:disabled) { background: var(--sunk); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: var(--surface); font-weight: 600; }
.btn.small { min-height: 32px; padding: 0 11px; font-size: 13px; }
.btn.wide { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: var(--r-ctl);
  border: 1px solid transparent; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--sunk); color: var(--ink); }

/* fields */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field label, .lbl { font-weight: 600; font-size: 14px; }
.field small, .hint { color: var(--muted); font-size: 13px; }
.field input, .field textarea, .field select {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--r-ctl); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 16px;
}
.field textarea { resize: vertical; line-height: 1.55; min-height: 110px; }
.field textarea.reading { font-family: var(--f-read); }
.field select {
  appearance: none; -webkit-appearance: none; padding-right: 40px;
  background: var(--surface) var(--chevron) no-repeat right 14px center;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.err { margin: 0; color: var(--danger); font-size: 13.5px; }
.grow-input { flex: 1 1 240px; min-width: 0; min-height: 38px; padding: 0 12px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface); font-size: 16px; }
.grow-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.access-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.switch-row { display: flex; align-items: flex-start; gap: 14px; }
.switch-row .txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
input.switch {
  appearance: none; -webkit-appearance: none; flex: none; width: 44px; height: 26px; margin: 0; border-radius: 999px;
  background: var(--line); position: relative; cursor: pointer; transition: background-color .15s;
}
input.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform .15s;
}
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(18px); }

/* the mark: a vault door with a spoked wheel and a brass hub (same drawing as favicon.svg) */
.brand-mark { display: block; width: 32px; height: 32px; flex: none; }
.brand-mark .mt { fill: var(--mark-tile); stroke: var(--line); stroke-width: 1; }
.brand-mark .mi { fill: none; stroke: var(--ink); }
.brand-mark .ml { fill: var(--accent); }
.brand-mark .mp { fill: var(--ink); }

/* sign in: an index card */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin-card {
  position: relative; width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 28px; box-shadow: var(--shadow);
}
.signin-card > .group:first-child { padding-bottom: 14px; border-bottom: 1.5px solid var(--rule); }
.signin-card .brand-mark { width: 44px; height: 44px; }
.signin-card h1 { font-size: 28px; }
.signin-card p { margin: 0; }

/* shell: the cabinet */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--rail); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0;
  height: 100vh; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px;  /* dvh: the visible height, so the account at the foot is never under the browser's bars */
}
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-family: var(--f-read); font-weight: 600; font-size: 19px; letter-spacing: -0.01em; line-height: 1.2; }
.brand-who { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.menu-btn { display: none; }
.side-body { display: flex; flex-direction: column; gap: 18px; flex: 1 1 auto; }
.search { position: relative; }
.search input {
  width: 100%; min-height: 38px; padding: 0 12px 0 36px; border-radius: var(--r-ctl); border: 1px solid var(--line);
  background: var(--surface); font-size: 15px;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; }
.nav-label { font-family: var(--f-mono); font-size: 11.5px; color: var(--muted); padding: 0 10px; }
.brain-list { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 10px; border-radius: var(--r-ctl);
  border: 1px solid transparent; background: transparent; text-align: left; text-decoration: none; color: var(--ink); font-size: 14.5px;
}
.nav-item:hover { background: var(--sunk); }
.nav-item[aria-current="page"] { background: var(--surface); border-color: var(--line); box-shadow: 0 1px 0 var(--line); font-weight: 600; }
.nav-item .nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .ct {
  font-family: var(--f-mono); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
  min-width: 34px; text-align: center; padding: 1px 5px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface);
}
.nav-item .ct:empty { display: none; }
.nav-item.add { color: var(--muted); }
.nav-item .bi { color: var(--accent); }
.side-foot { margin-top: auto; padding: 6px 4px 0; position: relative; }


/* account: the foot of the rail (user, 2026-10-16: "sign out is too close i would put at bottom along with an account section") */
.side-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.acct {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 8px; border: 1px solid transparent;
  border-radius: var(--r-ctl); background: transparent; text-align: left; color: var(--ink);
}
.acct:hover, .acct[aria-expanded="true"] { background: var(--sunk); }
.acct > .i { color: var(--muted); }
.avatar {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent);
  color: var(--accent-ink); font-family: var(--f-read); font-weight: 600; font-size: 15px;
}
.acct-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.acct-txt b { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-txt small { color: var(--muted); font-size: 12.5px; }

/* popovers (account menu, More): fixed at the page root, so the rail's scrolling can't clip them */
.pop {
  position: fixed; z-index: 60; min-width: 240px; max-width: calc(100vw - 16px); padding: 6px; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 0 var(--line), 0 18px 40px var(--shadow-c);
  animation: pop-in .14s cubic-bezier(.3, .7, .2, 1); outline: none;
}
@keyframes pop-in { from { transform: translateY(4px) scale(.98); } }  /* movement only: a fade can stall half-way and leave it see-through */
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.pop-head { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px 6px; overflow-wrap: anywhere; }
.pop-head b { font-family: var(--f-read); font-weight: 600; font-size: 15px; }
.pop-head span { font-size: 12.5px; color: var(--muted); }
.pop-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 10px; border: 0; border-radius: var(--r-ctl);
  background: transparent; color: var(--ink); text-decoration: none; text-align: left; font-size: 14.5px;
}
.pop-item:hover, .pop-item:focus-visible { background: var(--sunk); }
.pop-item .i { color: var(--muted); }
.pop-sub { display: flex; flex-direction: column; gap: 8px; padding: 6px 8px 8px; }
.pop-lbl { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; padding: 3px; border-radius: 8px; background: var(--sunk); }
.seg button {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 0 6px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 500;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px var(--shadow-c), 0 0 0 1px var(--line); }
.main { padding: 32px clamp(16px, 4vw, 44px) 80px; min-width: 0; outline: none; }
.main.flush { padding: 0; }
.page { max-width: 900px; margin: 0 auto; }
.page.wide { max-width: 1180px; }
.pq-frame { display: block; width: 100%; height: 100vh; border: 0; background: var(--bg); }

/* brain header */
.head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px 20px; }
.head-title { display: flex; align-items: flex-start; gap: 14px; min-width: 0; flex: 1 1 320px; }
.head-icon {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: var(--r); flex: none;
  background: var(--surface); border: 1px solid var(--line); box-shadow: inset 0 -3px 0 var(--sunk); color: var(--accent);
}
.head h1 { font-size: clamp(26px, 4vw, 34px); line-height: 1.15; }
.head p { margin: 0; color: var(--muted); }
.meta { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.icon-only { width: 38px; min-width: 38px; padding: 0; }
.vk-add { align-self: flex-start; }  /* the Add to Claude button keeps its own width */

/* a brain, drawn as stippled dots (vizbrain.js); its books as the parts that light up, named in the list beside it */
.vb-mind { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); gap: 8px 48px; align-items: center; }
.vb-stage { min-width: 0; display: flex; flex-direction: column; align-items: center; }
.vb-canvas {
  display: block; width: min(100%, 680px); aspect-ratio: 6 / 5; touch-action: pan-y; cursor: grab;
  color: var(--ink); background-color: var(--bg); border: 0 solid var(--accent);  /* dots, page, lit part: read by the canvas */
}
@media (max-width: 520px) { .vb-canvas { aspect-ratio: 1 / 1; } }  /* a phone: room under the brain for its projector */
.vb-cap { min-height: 40px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; text-align: center; }
.vb-cap b { font-family: var(--f-read); font-weight: 600; font-size: 18px; }
.vb-cap span { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.vb-books { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.vb-book {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 10px 2px;
  border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 15px; transition: color .15s;
}
.vb-books li:first-child .vb-book { border-top: 1px solid var(--line); }
.vb-book .vb-name { min-width: 0; overflow-wrap: anywhere; }
.vb-book .vb-n { flex: none; font-family: var(--f-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vb-book:hover, .vb-book.on, .vb-book:focus-visible { color: var(--accent); }
.vb-book.vb-hit .vb-n { color: var(--accent); animation: vb-pulse 1.6s ease-out; }  /* a pulse just reached this book */
@keyframes vb-pulse { 0% { text-shadow: 0 0 0 transparent; } 25% { text-shadow: 0 0 10px var(--accent); } 100% { text-shadow: 0 0 0 transparent; } }
.vb-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
.vb-book.on .vb-n, .vb-book:hover .vb-n { color: var(--accent); }
@media (max-width: 980px) { .vb-mind { grid-template-columns: minmax(0, 1fr); } .vb-books { max-width: 560px; width: 100%; justify-self: center; } }
.vb-book.open { font-weight: 600; color: var(--accent); }
/* Connect: the strip under a brain's header while a Claude syncs with it; its steps tick off as pulses arrive */
.vk-sync { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; border: 1px solid var(--accent); border-radius: 12px;
  background: linear-gradient(180deg, var(--accent-soft), var(--surface)); animation: vb-rise .28s ease-out; }
.vk-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.vk-title { margin: 0; font-size: 19px; }
.vk-text { margin: 0; color: var(--muted); max-width: 70ch; }
.vk-row { display: flex; flex-wrap: wrap; gap: 8px; }
.vk-first { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.vk-steps { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.vk-step { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 14px; line-height: 1.4; }
.vk-dot { flex: none; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; border: 2px solid var(--line); }
.vk-step.on { color: var(--ink); border-color: var(--accent); }
.vk-step.on .vk-dot { border-color: var(--accent); background: var(--accent); animation: vk-beat 1.2s ease-in-out infinite; }
.vk-step.done { color: var(--ink); }
.vk-step.done .vk-dot { border-color: var(--accent); background: var(--accent); }
@keyframes vk-beat { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 25%, transparent); } }
@media (prefers-reduced-motion: reduce) { .vk-step.on .vk-dot, .vk-sync { animation: none; } }
/* a book, opened under its brain: a brass seam ties it to the lit part above */
.vb-open { position: relative; display: flex; flex-direction: column; gap: 14px; padding-top: 24px; border-top: 1px solid var(--line); scroll-margin-top: 12px; animation: vb-rise .28s ease-out; }
.vb-open::before { content: ""; position: absolute; top: -1px; left: 0; width: 96px; height: 2px; background: var(--accent); }
.vb-book-t { margin: 0; font-size: clamp(22px, 3vw, 28px); line-height: 1.2; }
/* contributors: who added this brain's lessons, by how many, with a bar for their share */
.vc-people { display: flex; flex-direction: column; gap: 12px; padding-top: 22px; border-top: 1px solid var(--line); }
.vc-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.vc-title { margin: 0; font-size: 19px; }
.vc-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.vc-row { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 48px;
  padding: 8px 12px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); text-decoration: none; overflow: hidden; }
.vc-row:hover, .vc-row.open { border-color: var(--accent); }
.vc-row.open .vc-name { color: var(--accent); font-weight: 600; }
.vc-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--sunk); color: var(--muted); }
.vc-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.vc-n { font-family: var(--f-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vc-bar { position: absolute; left: 12px; right: 12px; bottom: 6px; height: 3px; border-radius: 2px; background: var(--sunk); }
.vc-bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); border-radius: 2px; background: var(--accent); }
.vc-more { align-self: flex-start; }
.vc-book-h { margin: 6px 0 0; font-size: inherit; }
.vc-book { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; color: var(--ink); text-decoration: none; font-weight: 600; }
.vc-book:hover { color: var(--accent); }
.vb-books .vb-open { padding: 14px 0 22px; border-top: 0; }  /* opened under its own name in the list (narrow screens) */
.vb-books .vb-open::before { display: none; }
.vb-books .vb-open .head-title { display: none; }  /* the name is just above */
.vb-books .vb-open > .head { justify-content: flex-end; }
@keyframes vb-rise { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .vb-open { animation: none; } }

/* a book's contents. One lesson opens at a time (<details name>), with the card's red rule. */
.find { width: 100%; flex: none; }
.toc { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 1px 0 var(--line); }
.toc > li + li { border-top: 1px solid var(--line); }
.leaf > summary { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 10px 14px; cursor: pointer; list-style: none; }
.leaf > summary::-webkit-details-marker { display: none; }
.leaf > summary:hover { background: var(--sunk); }
.leaf > summary:focus-visible { outline-offset: -2px; }
.toc > li:first-child .leaf > summary { border-radius: var(--r) var(--r) 0 0; }
.callno-i { flex: none; min-width: 76px; font-family: var(--f-mono); font-size: 11px; color: var(--accent); letter-spacing: 0.02em; }
.leaf-t { flex: 1 1 auto; min-width: 0; font-family: var(--f-read); font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.leaf-flag { flex: none; color: var(--muted); display: inline-flex; }
.leaf-chev { flex: none; color: var(--muted); display: inline-flex; transition: transform .15s; }
.leaf[open] .leaf-chev { transform: rotate(180deg); }
.leaf[open] > summary { border-bottom: 1.5px solid var(--rule); }
.leaf.focus > summary { box-shadow: inset 3px 0 0 var(--accent); background: var(--accent-soft); }
.leaf-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.leaf-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; }
.leaf-foot .card-tools { margin: 0; gap: 6px; flex-wrap: wrap; }
.book-nav { display: flex; flex-wrap: wrap; gap: 10px; }
.book-nav a {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 38px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: var(--r-ctl); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 14px;
}
.book-nav a:hover { background: var(--sunk); }
.book-nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-nav .next { margin-left: auto; }

/* section filter: drawer labels */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; max-width: 100%; padding: 0 10px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; box-shadow: 0 1px 0 var(--line);
}
.chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .n { font-family: var(--f-mono); font-size: 11.5px; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: none; }
.chip[aria-pressed="true"] .n { color: var(--accent-ink); opacity: 0.8; }

/* sections (drawer labels) + lessons (index cards with a call-number tab) */
.section h2 {
  align-self: flex-start; max-width: 100%; display: inline-flex; gap: 10px; align-items: baseline; padding: 5px 12px;
  border: 1px solid var(--line); border-radius: 4px; background: var(--sunk); box-shadow: inset 0 1px 0 var(--surface);
  font-family: var(--f-read); font-size: 15.5px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere;
}
.section h2 .n { font-family: var(--f-mono); font-weight: 400; font-size: 12px; color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; min-width: 0;
  display: flex; flex-direction: column; gap: 10px; box-shadow: 0 1px 0 var(--line);
}
.card.lesson { position: relative; margin-top: 12px; }
.callno {
  position: absolute; top: -12px; left: 14px; height: 22px; padding: 0 9px; display: inline-flex; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 4px 4px 0 0;
  font-family: var(--f-mono); font-size: 11px; color: var(--accent); letter-spacing: 0.02em; white-space: nowrap;
}
.card.lesson .card-head { padding-bottom: 8px; border-bottom: 1.5px solid var(--rule); }
.card.focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card > .btn, .head .pill { align-self: flex-start; }
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-title { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 15.5px; overflow-wrap: anywhere; }
.card.lesson .card-title { font-family: var(--f-read); font-size: 17px; line-height: 1.35; }
.card-tools { display: flex; gap: 2px; margin: -4px -6px 0 0; }
.card-body { font-family: var(--f-read); font-size: 16px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.card-why { margin: 0; font-size: 13.5px; color: var(--muted); font-style: italic; overflow-wrap: anywhere; white-space: pre-wrap; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 12.5px; color: var(--muted); }
.tag { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 4px; background: var(--sunk); color: var(--muted); font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 0 8px; border-radius: 4px; font-size: 12px; background: var(--warn-soft); color: var(--warn); }
.card-body code, .card-why code { font-family: var(--f-mono); font-size: 0.86em; background: var(--sunk); border-radius: 4px; padding: 1px 4px; overflow-wrap: anywhere; }
.card-body strong { font-weight: 600; }
mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }

.empty {
  border: 1.5px dashed var(--line); border-radius: var(--r); padding: 28px; text-align: center; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.notice { padding: 14px 16px; border-radius: var(--r); background: var(--sunk); display: flex; gap: 10px; align-items: flex-start; }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.notice .msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

/* activity + keys lists */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: 0 1px 0 var(--line); }
.list-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; }
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-row .t { overflow-wrap: anywhere; }
.list-row .s { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
a.list-row { text-decoration: none; color: var(--ink); }
a.list-row:hover { background: var(--sunk); }

.code {
  font-family: var(--f-mono); font-size: 13px; line-height: 1.55; background: var(--sunk); border-radius: var(--r-ctl);
  padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0;
}
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }

/* dialogs */
dialog.modal {
  width: min(620px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}
dialog.modal.wide { width: min(760px, calc(100vw - 32px)); }
.imp-group { border: 1px solid var(--line); border-radius: var(--r); padding: 4px 14px; }
.imp-group > summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; gap: 8px; font-weight: 600; list-style: none; }
.imp-group > summary::-webkit-details-marker { display: none; }
.imp-group > summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; flex: none; margin-right: 4px; }
.imp-group[open] > summary::before { transform: rotate(45deg); }
.imp-group > summary .n { font-family: var(--f-mono); font-weight: 400; color: var(--muted); font-size: 13px; }
.imp-group[open] > .stack { padding: 4px 0 14px; }
.imp-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--sunk); }
.imp-row input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.imp-title { font-weight: 600; overflow-wrap: anywhere; }
.imp-body { font-family: var(--f-read); white-space: pre-wrap; overflow-wrap: anywhere; }
.imp-skip { display: flex; flex-direction: column; gap: 2px; padding: 6px 2px; overflow-wrap: anywhere; }
.imp-row .tag { align-self: flex-start; }
dialog.modal.small { width: min(440px, calc(100vw - 32px)); }
/* the connect guide: three steps beside a brain (Higgsfield's "in under a minute" box, in The Vault's look) */
dialog.modal.vt { width: min(940px, calc(100vw - 32px)); }
.vt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.vt-head h2 { font-size: clamp(19px, 2.4vw, 23px); line-height: 1.25; }
.vt-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr); gap: 22px; align-items: stretch; }
.vt-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.vt-step { display: flex; flex-direction: column; gap: 8px; padding: 16px 0; border-top: 1px solid var(--line); }
.vt-step:first-child { border-top: 0; padding-top: 2px; }
.vt-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); color: var(--ink); font-family: var(--f-mono); font-size: 13px; }
.vt-step h3 { margin: 0; font-size: 17px; font-weight: 600; }
.vt-step p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.vt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.vt-row .grow-input { flex: 1 1 180px; min-width: 0; }
.vt-after { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--r); background: var(--accent-soft); }
.vt-after p { color: var(--ink); }
.vt-side { margin: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); }
.vt-side .vb-canvas { width: 100%; }
.vt-side figcaption { color: var(--muted); font-size: 13px; text-align: center; max-width: 34ch; }
/* the Connect page's hero: a headline with Claude and The Vault as tiles in the line, over a field of dots */
.cx-hero { container-type: inline-size; position: relative; isolation: isolate; overflow: hidden; display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 14px; padding: clamp(44px, 8vw, 92px) 20px clamp(36px, 6vw, 64px); border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.cx-dots { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; color: var(--ink); pointer-events: none; }
.cx-title { margin: 0; font-family: "Archivo", var(--f-ui); font-stretch: 75%; font-weight: 800; text-transform: uppercase;
  letter-spacing: -0.01em; line-height: 1.02; font-size: clamp(28px, 4.6vw, 66px);  /* condensed bold capitals, two lines like the reference */
  font-size: clamp(28px, calc(7.2cqi - 3px), 66px); }  /* sized to the hero itself: the second line always fits its width */
.cx-line { display: block; text-wrap: balance; }  /* two lines when the font fits; wraps, never clips, if it can't load */
.cx-tile { display: inline-grid; place-items: center; width: 0.92em; height: 0.92em; vertical-align: -0.1em; border-radius: 0.22em; margin: 0 0.04em; }
.cx-tile.brand-mark { display: inline-block; width: 0.92em; height: 0.92em; }
.cx-pair { white-space: nowrap; }
.cx-claude { background: #D97757; color: #FFFFFF; }  /* Claude's own colour and mark */
.cx-tile.brand-mark .mt { fill: var(--accent); stroke: none; }  /* The Vault's tile in brass, beside Claude's */
.cx-tile.brand-mark .mi { stroke: var(--accent-ink); }
.cx-tile.brand-mark .ml { fill: var(--accent-ink); }
.cx-claude svg { width: 66%; height: 66%; }
.cx-sub { margin: 0; max-width: 46ch; color: var(--muted); font-size: clamp(15px, 1.6vw, 17px); line-height: 1.5; }
.cx-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 12px; }
.cx-btn { min-height: 50px; padding: 0 22px; font-size: 16px; font-weight: 600; border-radius: 12px; transition: box-shadow .15s, transform .15s; }
.cx-btn.primary { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 3px 0 color-mix(in srgb, var(--accent) 60%, #000), 0 12px 26px -10px color-mix(in srgb, var(--accent) 70%, transparent); }
.cx-ghost { background: color-mix(in srgb, var(--surface) 85%, transparent); border-color: var(--line); }
.cx-btn:hover:not(:disabled) { box-shadow: 0 0 0 2px var(--accent); transform: translateY(-1px); }
.cx-btn.primary:hover:not(:disabled) { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 3px 0 color-mix(in srgb, var(--accent) 60%, #000), 0 0 0 2px color-mix(in srgb, var(--accent) 45%, var(--ink)); }
.cx-form { width: min(520px, 100%); text-align: left; }
.vt-add { display: flex; flex-direction: column; gap: 6px; }
.vt-add p { margin: 0; }
.vt-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.cx-hint { margin: 6px 0 0; font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .cx-btn { transition: none; } .cx-btn:hover:not(:disabled) { transform: none; } }
@media (max-width: 520px) { .cx-actions { flex-direction: column; align-self: stretch; } .cx-btn { width: 100%; justify-content: center; } }
.vt-grid.vt-solo { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 760px) { .vt-grid { grid-template-columns: minmax(0, 1fr); } .vt-side { display: none; } }
dialog.modal::backdrop { background: rgba(21, 17, 13, 0.55); }
dialog.modal:focus, dialog.modal:focus-visible { outline: none; }  /* the dialog itself gets focus while it loads: no ring round the whole box */
.dlg-in { padding: 22px; display: flex; flex-direction: column; gap: 18px; max-height: calc(100dvh - 34px); overflow-y: auto; }
.dlg-in h2 { font-family: var(--f-read); font-size: 21px; font-weight: 600; }
.dlg-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.dlg-btns .spacer { flex: 1 1 auto; }
.prompt-view { max-height: 55vh; overflow-y: auto; }
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-ctl); }
.share-row .who { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.share-row .who b { font-weight: 600; }
.share-row .who span { font-size: 13px; color: var(--muted); }
.share-row .field { flex: 0 1 200px; }
.hist { display: flex; flex-direction: column; gap: 10px; }
.hist-item { border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.hist-item .top { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 13px; color: var(--muted); }
.hist-item .top b { color: var(--ink); }

/* toasts */
.toasts { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px calc(18px + env(safe-area-inset-bottom, 0px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: min(560px, 100%); padding: 11px 12px 11px 16px; border-radius: 8px; background: var(--toast-bg); color: var(--toast-ink); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); font-size: 14px; }
.toast .msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.toast.error { background: var(--danger); color: var(--surface); }
.toast button { flex: none; border: 0; background: transparent; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 4px 6px; }

.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 20; height: auto; max-height: 100vh; max-height: 100dvh; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); gap: 12px; }
  .menu-btn { display: inline-grid; }
  .side:not(.open) .side-body { display: none; }
  .main { padding-top: 22px; }
  .vb-open, .vb-book { scroll-margin-top: 76px; }  /* clear of the sticky top bar */
  .main.flush { padding-top: 0; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
    .leaf > summary { flex-wrap: wrap; gap: 4px 10px; }
  .callno-i { min-width: 0; width: 100%; }
  .leaf-t { flex-basis: calc(100% - 40px); }
}
@media (max-width: 440px) {
  .btn.fold { width: 38px; min-width: 38px; padding: 0; }
  .btn.fold span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0.01ms !important; }
  .spin { animation: spin 1.6s linear infinite !important; }
}
