/* Vault shell theme. Explainers style themselves; this only styles the shell. */

:root {
  --bg: oklch(96.5% 0.012 145);
  --sidebar: oklch(92.5% 0.018 145);
  --surface: oklch(98.5% 0.006 145);
  --surface-2: oklch(94.5% 0.012 145);
  --ink: oklch(22% 0.024 130);
  --muted: oklch(48% 0.035 130);
  --faint: oklch(60% 0.026 130);
  --border: oklch(84% 0.018 145);
  --border-strong: oklch(75% 0.026 145);
  --accent: oklch(54% 0.15 32);
  --accent-2: oklch(46% 0.12 205);
  --accent-soft: oklch(92% 0.045 32);
  --selected: oklch(90% 0.033 205);
  --shadow: 0 10px 32px rgb(35 41 33 / 0.08);
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0e0e0e;
  --sidebar: #161616;
  --surface: #1e1e1e;
  --surface-2: #1a1a1a;
  --ink: #f2f0eb;
  --muted: #9a9a9a;
  --faint: #6e6e6e;
  --border: #2a2a2a;
  --border-strong: #594039;
  --accent: #ec5b2b;
  --accent-2: #ee7948;
  --accent-soft: #2c1b15;
  --selected: #2c1b15;
  --shadow: 0 16px 42px rgb(0 0 0 / 0.48);
}

* { box-sizing: border-box; }

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input { font: inherit; }

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: color-mix(in oklch, var(--accent) 24%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------------------- library page */

body.library {
  height: 100dvh;
  overflow: hidden;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  height: 100dvh;
  transition: grid-template-columns 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0px minmax(0, 1fr);
}

.sidebar {
  /* fixed width so content doesn't reflow while the track animates;
     the translate keeps its right edge glued to the shrinking track */
  width: 310px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: translate 280ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s 0s;
}

.app-shell.sidebar-collapsed .sidebar {
  translate: -100% 0;
  visibility: hidden;
  transition: translate 280ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s 280ms;
}

.sidebar-toggle-btn {
  position: absolute;
  left: 310px;
  top: 15px;
  z-index: 10;
  transition: left 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.app-shell.sidebar-collapsed .sidebar-toggle-btn {
  left: 12px;
}

.app-shell.sidebar-collapsed .workspace-header {
  /* clear the floating toggle; keep content column centered */
  padding-left: max(60px, calc((100% - 980px) / 2 + 34px));
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 14px 10px;
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.95rem;
}

.search {
  position: relative;
  padding: 0 10px 11px;
}

.search .topics-btn {
  display: none;
}

.search input {
  width: 100%;
  height: 34px;
  padding: 6px 34px 6px 34px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
}

.search input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent-2) 18%, transparent);
}

.search input::placeholder { color: var(--faint); }

.search .glyph {
  position: absolute;
  left: 21px;
  top: 50%;
  translate: 0 -50%;
  color: var(--faint);
  pointer-events: none;
}

.search kbd {
  position: absolute;
  right: 20px;
  top: 50%;
  translate: 0 -50%;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--faint);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
}

.tree {
  flex: 1;
  overflow: auto;
  padding: 4px 8px 12px;
}

.topic-node { margin: 1px 0; }

.folder-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
  border-radius: 6px;
}

.folder-row.is-active {
  background: var(--selected);
}

.folder-row:hover:not(:has(:disabled)) {
  background: var(--surface-2);
}

.folder-row.is-active:hover:not(:has(:disabled)) {
  background: var(--selected);
}

.chevron-btn {
  display: grid;
  place-items: center;
  width: 22px;
  min-height: 30px;
  border: 0;
  border-radius: 6px 0 0 6px;
  background: transparent;
  color: var(--faint);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
}

.chevron-btn:hover:not(:disabled) {
  color: var(--ink);
}

.chevron-btn:disabled {
  cursor: default;
  opacity: 0.45;
}

.chevron-spacer {
  width: 22px;
}

.folder {
  width: 100%;
  min-height: 30px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 0 6px 6px 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px 4px 2px;
  text-align: left;
}

.all-folder {
  grid-template-columns: 22px minmax(0, 1fr) auto;
  border-radius: 6px;
  padding: 4px 8px;
  gap: 0 5px;
}

.all-folder:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
}

.all-folder[aria-pressed="true"] {
  background: var(--selected);
  color: var(--ink);
}

.folder:hover:not(:disabled) {
  color: var(--ink);
}

.folder[aria-pressed="true"] {
  color: var(--ink);
}

.folder:disabled {
  cursor: default;
  opacity: 0.45;
}

.folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 560;
}

.folder-count {
  min-width: 20px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.72rem;
  text-align: right;
}

.tree-files {
  display: grid;
  gap: 1px;
  padding: 1px 0 5px 26px;
  transition: opacity 150ms ease;
}

.tree-files[hidden] {
  display: none;
}

.tree-file {
  min-height: 28px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  color: var(--muted);
  border-radius: 5px;
  padding: 3px 7px;
  text-decoration: none;
}

.tree-file:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.tree-file span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-num {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-align: right;
}

.tree-file:hover .file-num { color: var(--accent); }

.sidebar-status {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 0.74rem;
  padding: 9px 12px;
}

.topic-backdrop {
  display: none;
}

.workspace {
  min-width: 0;
  overflow: auto;
  background:
    linear-gradient(90deg, color-mix(in oklch, var(--accent-2) 8%, transparent), transparent 28%),
    var(--bg);
}

.workspace-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  /* full-bleed bar; inner content tracks the 980px column */
  padding: 28px max(34px, calc((100% - 980px) / 2 + 34px)) 16px;
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.workspace-kicker {
  margin: 0 0 2px;
  color: var(--accent-2);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92rem;
}

.workspace-header h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.workspace-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.workspace-tools {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.workspace-theme-toggle {
  min-height: 30px;
  padding: 4px 9px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--surface) 82%, var(--accent-soft));
}

.workspace-theme-toggle:hover {
  border-color: var(--accent);
}

.workspace-count {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.sort-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-family: var(--mono);
  letter-spacing: 0.01em;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}

.sort-btn:hover {
  color: var(--ink);
}

.sort-btn.is-active {
  background: color-mix(in oklch, var(--accent) 14%, var(--surface));
  color: var(--accent);
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  max-width: 980px;
  margin-inline: auto;
  padding: 15px 34px 0;
}

.active-filters button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
  cursor: pointer;
}

.active-filters button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.explainer-list {
  max-width: 980px;
  margin-inline: auto;
  padding: 16px 34px 70px;
}

.explainer-row {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(130px, auto);
  gap: 18px;
  align-items: start;
  border-bottom: 1px solid var(--border);
  padding: 18px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  animation: row-in 380ms cubic-bezier(0.22, 1, 0.36, 1) var(--stagger, 0ms) backwards;
  transition: background 140ms ease;
}

@keyframes row-in {
  from {
    opacity: 0;
    translate: 0 10px;
  }
}

.explainer-row:first-child { border-top: 1px solid var(--border); }

.explainer-row:hover,
.explainer-row:focus-within {
  background: color-mix(in oklch, var(--surface-2) 70%, transparent);
}

.explainer-row:hover .row-title,
.explainer-row:focus-within .row-title {
  color: var(--accent);
}

/* stretched hit target — whole row opens the explainer */
.row-hit {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
}

.row-index {
  position: relative;
  z-index: 1;
  padding-top: 5px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.row-copy {
  min-width: 0;
}

.row-title {
  position: relative;
  z-index: 1;
  display: inline-block;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
}

.row-desc {
  max-width: 66ch;
  margin: 5px 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.tagbar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  cursor: pointer;
  font-size: 0.72rem;
}

.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.row-aside {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: end;
  gap: 6px;
  color: var(--faint);
  font-size: 0.78rem;
  pointer-events: none;
}

.row-topic {
  color: var(--accent-2);
  font-weight: 650;
}

/* demoted on desktop — whole row is the open control */
.open-link {
  display: none;
  margin-top: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 4px 10px;
  text-decoration: none;
  pointer-events: auto;
}

.open-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  margin-top: 16px;
  padding: 42px 20px;
  text-align: center;
}

.empty .btn { margin-top: 14px; }

.empty-page {
  max-width: 28rem;
  margin: 0 auto;
  padding-top: 18vh;
  border: none;
}

.empty-kicker {
  margin: 0 0 6px;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.empty-title {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 550;
  color: var(--ink);
}

.empty-actions {
  margin: 18px 0 0;
}

.empty-hint {
  margin: 18px 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.empty-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}

.empty-topics .btn {
  margin-top: 0;
}

.empty-latest {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  text-align: left;
}

.empty-latest-label {
  margin: 0 0 10px;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.empty-latest-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empty-latest-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1rem;
}

.empty-latest-list a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.empty-latest-list .topic {
  flex-shrink: 0;
  font-family: var(--sans, system-ui, sans-serif);
  font-size: 0.75rem;
  color: var(--muted);
}

.empty-search-hint {
  margin-top: 22px;
  font-size: 0.9rem;
}

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

.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn {
  padding: 8px 14px;
  font-size: 0.82rem;
}

.icon-btn {
  min-width: 44px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.btn:hover,
.icon-btn:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

/* ------------------------------------------------------------ viewer page */

body.viewer {
  height: 100dvh;
  overflow: hidden;
}

/* the entire chrome: one floating pill that ducks out while reading */
.viewer-pill {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: color-mix(in oklch, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: translate 240ms cubic-bezier(0.22, 1, 0.36, 1), opacity 240ms ease;
}

.viewer-pill.is-hidden {
  translate: 0 -70px;
  opacity: 0;
}

.pill-back {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
}

.pill-back:hover {
  background: var(--surface-2);
  color: var(--accent);
}

.pill-sep {
  width: 1px;
  height: 15px;
  background: var(--border-strong);
  flex-shrink: 0;
}

.pill-sep[hidden],
.pill-nav[hidden] {
  display: none;
}

.pill-crumb {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35em;
  min-width: 0;
  max-width: min(42vw, 280px);
  padding: 0 8px 0 6px;
  font-size: 0.82rem;
  line-height: 1.2;
}

.pill-topic {
  flex-shrink: 0;
  max-width: 9em;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.pill-topic:hover {
  color: var(--accent);
}

.pill-title {
  overflow: hidden;
  color: var(--ink);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill-nav {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding-right: 2px;
}

.pill-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  text-decoration: none;
}

.pill-step:hover {
  background: var(--surface-2);
  color: var(--accent);
}

.pill-step[aria-disabled="true"] {
  opacity: 0.28;
  pointer-events: none;
}

.viewer-pill .icon-btn {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.viewer-pill .icon-btn:hover { background: var(--surface-2); }

.viewer-pill .btn-label { display: none; }

/* fixed-theme explainers pin the chrome; hide the pointless toggle */
html[data-fixed-theme] #theme-toggle { display: none; }

.viewer-frame {
  display: block;
  width: 100%;
  height: 100dvh;
  border: 0;
  background: var(--bg);
  opacity: 0;
  transition: opacity 180ms ease;
}

.viewer-frame.is-ready {
  opacity: 1;
}

.viewer-frame.is-failed {
  display: none;
}

.viewer-stage {
  position: relative;
  width: 100%;
  height: 100dvh;
}

.viewer-status,
.viewer-error {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
  background: var(--bg);
}

.viewer-status[hidden],
.viewer-error[hidden] {
  display: none;
}

.viewer-skeleton {
  width: min(420px, 70vw);
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--surface-2),
    color-mix(in oklch, var(--accent) 18%, var(--surface)),
    var(--surface-2)
  );
  background-size: 200% 100%;
  animation: vault-shimmer 1.2s ease-in-out infinite;
}

.viewer-status-copy,
.viewer-error p {
  margin: 0;
  color: var(--muted);
}

.viewer-error h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
}

.viewer-error .empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

@keyframes vault-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .viewer-skeleton {
    animation: none;
  }
  .viewer-frame {
    transition: none;
  }
}

/* ----------------------------------------------------------- start here */

.start-here {
  padding: 18px max(34px, calc((100% - 980px) / 2 + 34px)) 4px;
}

.start-here-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.start-here-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
}

.start-here-dismiss {
  border: 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  min-height: 36px;
  padding: 4px 8px;
}

.start-here-dismiss:hover {
  color: var(--ink);
}

.start-here-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.start-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background:
    linear-gradient(160deg, color-mix(in oklch, var(--accent) 8%, transparent), transparent 55%),
    var(--surface);
  text-decoration: none;
  color: inherit;
  min-height: 118px;
  transition: border-color 160ms ease, transform 160ms ease;
}

.start-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.start-card-kicker {
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.start-card-title {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
}

.start-card-desc {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ----------------------------------------------------------- series page */

body.series-page {
  min-height: 100dvh;
  background:
    radial-gradient(circle at top left, color-mix(in oklch, var(--accent) 12%, transparent), transparent 42%),
    var(--bg);
}

.series-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 760px;
  margin: 0 auto;
  padding: 22px 20px 0;
}

.series-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.series-kicker {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.series-main h1 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: clamp(1.8rem, 1.4rem + 2vw, 2.4rem);
  line-height: 1.15;
}

.series-lede {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.series-units {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.series-unit a,
.series-unit > div {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "num title status"
    "num part status"
    "num desc status";
  gap: 2px 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
}

.series-unit.is-planned > div {
  opacity: 0.72;
}

.series-unit a:hover {
  border-color: var(--accent);
}

.series-unit-num {
  grid-area: num;
  align-self: start;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  padding-top: 4px;
}

.series-unit-title {
  grid-area: title;
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 600;
}

.series-unit-part {
  grid-area: part;
  color: var(--faint);
  font-size: 0.78rem;
}

.series-unit-status {
  grid-area: status;
  align-self: start;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.series-unit-desc {
  grid-area: desc;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.series-back {
  margin-top: 28px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.noscript-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 50;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

@media (max-width: 760px) {
  body.library {
    height: auto;
    overflow: auto;
  }

  body.library.topics-open {
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    display: block;
    min-height: 100dvh;
  }

  /* collapsing is a desktop affordance; on mobile topics live in a bottom sheet */
  .sidebar-toggle-btn { display: none; }

  .sidebar,
  .app-shell.sidebar-collapsed .sidebar {
    position: sticky;
    top: 0;
    z-index: 8;
    width: auto;
    translate: none;
    visibility: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 color-mix(in oklch, var(--surface) 60%, transparent);
  }

  .app-shell.sidebar-collapsed .workspace-header {
    padding-left: 18px;
  }

  .app-shell.topics-open .sidebar {
    z-index: 22;
  }

  .sidebar-top {
    padding: 10px 12px 6px;
  }

  .brand {
    font-size: 0.98rem;
  }

  .search {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    padding: 6px 12px 10px;
    background: color-mix(in oklch, var(--sidebar) 92%, transparent);
    backdrop-filter: blur(12px);
  }

  .search .topics-btn {
    display: inline-flex;
    align-items: center;
    max-width: 42vw;
    min-height: 40px;
    padding-inline: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .search input {
    height: 40px;
    min-width: 0;
    padding: 7px 12px;
  }

  .search .glyph,
  .search kbd {
    display: none;
  }

  .tree {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    max-height: min(72dvh, 560px);
    padding: 14px 12px calc(18px + env(safe-area-inset-bottom));
    background: var(--sidebar);
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -18px 44px rgb(0 0 0 / 0.18);
    translate: 0 100%;
    visibility: hidden;
    transition:
      translate 260ms cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0s 260ms;
    overscroll-behavior: contain;
  }

  .tree::before {
    content: "";
    display: block;
    width: 38px;
    height: 4px;
    margin: 0 auto 12px;
    border-radius: 999px;
    background: var(--border-strong);
  }

  .app-shell.topics-open .tree {
    translate: 0 0;
    visibility: visible;
    transition:
      translate 260ms cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0s;
  }

  .folder,
  .tree-file {
    min-height: 44px;
  }

  .topic-backdrop {
    position: fixed;
    inset: 0;
    z-index: 18;
    display: block;
    border: 0;
    background: rgb(0 0 0 / 0.34);
    opacity: 0;
    visibility: hidden;
    transition: opacity 180ms ease, visibility 0s 180ms;
  }

  .app-shell.topics-open .topic-backdrop {
    opacity: 1;
    visibility: visible;
    transition: opacity 180ms ease, visibility 0s;
  }

  .sidebar-status {
    display: none;
  }

  .workspace {
    overflow: visible;
  }

  .workspace-header {
    position: static;
    align-items: start;
    flex-wrap: wrap;
    padding: 22px 18px 14px;
  }

  .workspace-meta {
    align-items: flex-start;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
  }

  .workspace-theme-toggle .btn-label {
    display: none;
  }

  .start-here,
  .active-filters,
  .explainer-list {
    padding-left: 18px;
    padding-right: 18px;
  }

  .sort-btn {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 0.7rem;
  }

  .explainer-row {
    grid-template-columns: 34px minmax(0, 1fr);
    padding-left: 6px;
    padding-right: 6px;
    margin-left: -6px;
    margin-right: -6px;
  }

  .row-aside {
    grid-column: 2;
    justify-items: start;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px 10px;
    pointer-events: none;
  }

  .open-link {
    display: inline-flex;
  }
}

@media (max-width: 560px) {
  .viewer-pill {
    top: 10px;
    left: 10px;
    right: 10px;
    max-width: calc(100vw - 20px);
  }

  .pill-crumb {
    max-width: none;
    flex: 1;
  }

  .pill-topic {
    display: none;
  }

  .btn .btn-label,
  .search kbd {
    display: none;
  }

  .workspace-header h1 {
    font-size: 1.35rem;
  }

  .series-unit a,
  .series-unit > div {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "num status"
      "title title"
      "part part"
      "desc desc";
  }
}
