:root {
  /* Brand palette */
  --maroon-dark: #5b0013;
  --maroon: #7a0019;
  --maroon-light: #900021;
  --gold-dark: #ffb71e;
  --gold: #ffcc33;
  --gold-light: #ffde7a;
  --gold-deep: #b5751f;   /* derived: gold family, AA-contrast on white for text/UI */

  /* Neutrals (brand-spec) */
  --white: #ffffff;
  --offwhite: #f9f7f6;
  --gray-lighter: #f0efee;
  --gray-light: #d5d6d2;
  --gray-medium: #777677;
  --gray-dark: #5a5a5a;
  --gray-darker: #333333;

  /* Functional tokens */
  --bg: #ffffff;
  --bg-2: var(--gray-lighter);
  --panel: var(--white);
  --panel-2: var(--offwhite);
  --ink: var(--gray-darker);
  --ink-2: var(--gray-dark);
  --muted: var(--gray-medium);
  --muted-2: #b5b4b1;
  --line: #e3e2df;
  --line-strong: #b5b4b1;
  --accent: var(--maroon);
  --accent-dark: var(--maroon-dark);
  --accent-soft: #f4dee2;     /* light maroon tint */
  --gold-soft: #fff4d4;       /* light gold tint */

  /* Tier colors */
  --page: var(--maroon);
  --section: var(--gold-deep);
  --content: var(--gray-dark);

  /* Status */
  --mvp: #3b7a4e;             /* green — semantic 'in scope' */
  --phase2: var(--gold-deep); /* gold family */
  --future: var(--gray-medium);
  --danger: #b23a2a;

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 0 rgba(31, 27, 22, 0.04), 0 1px 2px rgba(31, 27, 22, 0.04);
  --shadow-md: 0 2px 6px rgba(31, 27, 22, 0.06), 0 8px 24px rgba(31, 27, 22, 0.05);

  --font-sans: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

/* Layout shell */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* ============================================================
   UMN CHROME — global utility strip, unit header, footer
   Modeled on official UMN sites (msi.umn.edu, cfans.umn.edu,
   med.umn.edu/clhss, mnba.umn.edu).
   ============================================================ */

/* Global utility strip — thin maroon bar at the top of every umn.edu site */
.umn-utility {
  background: var(--maroon);
  color: var(--white);
  border-bottom: 1px solid color-mix(in oklab, var(--maroon-dark) 80%, black);
}
.umn-utility-inner {
  max-width: 1640px;
  margin: 0 auto;
  padding: 7px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 36px;
}
.umn-wordmark {
  display: inline-flex;
  align-items: center;
  color: var(--white);
  text-decoration: none;
  line-height: 0;
}
.umn-wordmark img {
  display: block;
  height: 28px;
  width: auto;
}
.umn-utility-links {
  display: inline-flex;
  align-items: center;
  gap: 22px;
}
.umn-utility-links a {
  color: var(--white);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.1s;
}
.umn-utility-links a:hover { color: var(--gold); }

/* Unit header — clean white band with Block M + unit wordmark */
.umn-unit-header {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.umn-unit-inner {
  max-width: 1640px;
  margin: 0 auto;
  padding: 20px 28px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.umn-unit-mark {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: inherit;
}
.umn-block-m {
  display: inline-flex;
  flex-shrink: 0;
}
.umn-block-m svg {
  display: block;
  border-radius: 2px;
}
.umn-unit-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.umn-unit-eyebrow {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--maroon);
  margin-bottom: 6px;
}
.umn-unit-title {
  font-family: var(--font-sans);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--gray-darker);
}
.umn-unit-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}
.umn-unit-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  padding: 4px 10px;
  background: var(--gold);
  border-radius: 3px;
  letter-spacing: 0.01em;
}
.umn-unit-date {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
/* The thin gold accent stripe that sits below the unit header
   — borrows from the Folwell unit-header pattern. */
.umn-unit-stripe {
  height: 4px;
  background: linear-gradient(to right, var(--maroon) 0%, var(--maroon) 60%, var(--gold) 60%, var(--gold) 100%);
}

/* UMN footer — Regents copyright + audience links, modelled on
   msi.umn.edu and cfans.umn.edu footers. */
.umn-footer {
  background: var(--maroon-dark);
  color: var(--white);
  margin-top: 60px;
}
.umn-footer-inner {
  max-width: 1640px;
  margin: 0 auto;
  padding: 36px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.umn-footer-mark-link {
  display: inline-flex;
  line-height: 0;
}
.umn-footer-mark-link img {
  display: block;
  height: 32px;
  width: auto;
}

/* ============================================================
   Secondary nav restyle — feels like a Folwell page nav now
   ============================================================ */

.topnav {
  position: sticky; top: 0; z-index: 50;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.topnav-inner {
  display: grid;
  grid-template-columns: minmax(160px, auto) 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 12px 28px;
  max-width: 1640px;
  margin: 0 auto;
}
.topnav-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 2px;
}
.topnav-eyebrow-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--maroon);
  position: relative;
  padding-left: 14px;
}
.topnav-eyebrow-label::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 8px; height: 2px;
  background: var(--gold);
  transform: translateY(-50%);
}

.nav-pills {
  display: flex;
  gap: 2px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.nav-pill {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--gray-darker);
  background: transparent;
  border: 0;
  padding: 10px 14px;
  cursor: pointer;
  position: relative;
  border-bottom: 3px solid transparent;
  transition: color 0.12s, border-color 0.12s;
  margin-bottom: -3px;
}
.nav-pill:hover {
  color: var(--maroon);
}
.nav-pill.active {
  color: var(--maroon);
  border-bottom-color: var(--gold);
  background: transparent;
}
.nav-pill .count {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--gray-lighter);
  color: var(--gray-dark);
}
.nav-pill.active .count {
  background: var(--maroon);
  color: var(--white);
}

.nav-tools {
  display: flex; align-items: center; gap: 10px;
}
.search-wrap {
  position: relative;
  width: 240px;
}
.search-input {
  width: 100%;
  background: var(--gray-lighter);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 8px 14px 8px 32px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.search-input:focus { border-color: var(--maroon); background: var(--white); box-shadow: 0 0 0 2px color-mix(in oklab, var(--maroon) 12%, transparent); }
.search-input::placeholder { color: var(--muted-2); }
.search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; opacity: 0.5;
}
.iconbtn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 7px 11px;
  font: inherit;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.iconbtn:hover { border-color: var(--line-strong); background: var(--bg-2); }
.iconbtn.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.iconbtn.tiny { padding: 4px 8px; font-size: 11px; }
.iconbtn.locate-btn {
  color: var(--maroon);
  border-color: color-mix(in oklab, var(--maroon) 30%, var(--line));
  background: color-mix(in oklab, var(--maroon) 6%, var(--white));
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
}
.iconbtn.locate-btn:hover {
  background: var(--maroon);
  color: var(--white);
  border-color: var(--maroon);
}

.rail-locate {
  margin-top: 4px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid color-mix(in oklab, var(--maroon) 30%, var(--line));
  background: color-mix(in oklab, var(--maroon) 6%, var(--white));
  color: var(--maroon);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.rail-locate:hover { background: var(--maroon); color: var(--white); border-color: var(--maroon); }

/* Locate flash — applied briefly to the targeted node element */
@keyframes locatePulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--gold) 65%, transparent), 0 0 0 2px var(--maroon); background-color: color-mix(in oklab, var(--gold) 30%, transparent); }
  50% { box-shadow: 0 0 0 8px color-mix(in oklab, var(--gold) 0%, transparent), 0 0 0 2px var(--maroon); background-color: color-mix(in oklab, var(--gold) 14%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent; background-color: transparent; }
}
.locate-flash {
  animation: locatePulse 1.6s ease-out 2;
  border-radius: var(--r-md);
  position: relative;
  z-index: 1;
}

/* Filters row */
.filters {
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}
.filters-inner {
  max-width: 1640px;
  margin: 0 auto;
  padding: 10px 28px;
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
}
.filter-group {
  display: flex; align-items: center; gap: 6px;
}
.filter-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line);
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chip:hover { border-color: var(--line-strong); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
}
.chip[data-tone="page"] .chip-dot { background: var(--page); }
.chip[data-tone="section"] .chip-dot { background: var(--section); }
.chip[data-tone="content"] .chip-dot { background: var(--content); }
.chip[data-tone="mvp"] .chip-dot { background: var(--mvp); }
.chip[data-tone="phase2"] .chip-dot { background: var(--phase2); }

.filter-stats {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* Main layout */
.main {
  display: grid;
  grid-template-columns: 1fr 380px;
  max-width: 1640px;
  margin: 0 auto;
  width: 100%;
  align-items: start;
  transition: grid-template-columns 0.22s ease;
}
.main.sb-collapsed {
  grid-template-columns: 1fr 56px;
}

.canvas {
  padding: 36px 28px 80px;
  min-width: 0;
  background: var(--white);
}

.canvas-header {
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 3px solid var(--maroon);
  position: relative;
}
.canvas-header::after {
  content: "";
  position: absolute;
  left: 0; bottom: -3px;
  width: 80px; height: 3px;
  background: var(--gold);
}
.canvas-title {
  font-family: var(--font-sans);
  font-size: 40px;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  color: var(--gray-darker);
  font-weight: 800;
}
.canvas-title em {
  font-style: normal;
  color: var(--maroon);
  position: relative;
  padding: 0 4px;
}
.canvas-title em::after {
  content: "";
  position: absolute;
  left: 4px; right: 4px; bottom: 2px;
  height: 8px;
  background: var(--gold);
  z-index: -1;
  opacity: 0.55;
}
.canvas-sub {
  font-size: 14px;
  color: var(--muted);
  max-width: 720px;
}
.canvas-meta {
  margin-top: 18px;
  display: flex;
  gap: 22px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}
.canvas-meta span strong { color: var(--maroon); font-weight: 700; }

/* Legend */
.legend {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  margin-top: 18px;
  padding: 12px 16px;
  background: var(--gray-lighter);
  border-left: 3px solid var(--gold);
  border-radius: 0 4px 4px 0;
  font-size: 12px;
}
.legend-item { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }
.legend-glyph { display: inline-flex; }

/* Category bands */
.band {
  margin-top: 44px;
  scroll-margin-top: 130px;
}
.band:first-of-type { margin-top: 28px; }
.band-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: baseline;
  padding-bottom: 12px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--maroon);
  position: relative;
}
.band-head::after {
  content: "";
  position: absolute;
  left: 0; bottom: -2px;
  width: 80px; height: 2px;
  background: var(--gold);
}
.band-num {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--maroon);
  letter-spacing: 0.08em;
  font-weight: 800;
}
.band-label {
  font-family: var(--font-sans);
  font-size: 26px;
  letter-spacing: -0.015em;
  color: var(--gray-darker);
  margin: 0;
  font-weight: 800;
}
.band-caption {
  font-size: 12.5px;
  color: var(--muted);
  text-align: right;
  max-width: 460px;
  justify-self: end;
}

.band-pages {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* Page card */
.page {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.12s, border-color 0.12s;
  overflow: hidden;
  border-top: 3px solid var(--maroon);
}
.page:hover { border-color: var(--line-strong); border-top-color: var(--maroon); box-shadow: var(--shadow-md); }
.page.selected {
  border-color: var(--maroon);
  box-shadow: 0 0 0 1px var(--maroon), var(--shadow-md);
}
.page.has-selected-child {
  border-color: color-mix(in oklab, var(--gold-deep) 40%, var(--line));
  background: linear-gradient(
    to right,
    color-mix(in oklab, var(--gold) 12%, var(--panel)) 0%,
    var(--panel) 38%
  );
}
.page.has-selected-child > .page-head .page-title h3 {
  color: var(--maroon);
}
.page.has-selected-child > .page-head::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--gold);
  border-radius: var(--r-lg) 0 0 var(--r-lg);
  margin: -1px 0 -1px -1px;
}
.page.has-selected-child > .page-head {
  position: relative;
}
.page.has-selected-child .nested-selection-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  background: var(--gold);
  color: var(--maroon-dark);
  border-radius: 999px;
}
.page.dim { opacity: 0.45; }
.page.dragging { opacity: 0.4; }
.page.drop-target { border-style: dashed; border-color: var(--accent); }

.page-head {
  display: grid;
  grid-template-columns: 22px 22px auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
}
.page-head:hover { background: var(--panel-2); }
.drag-handle {
  cursor: grab;
  color: var(--muted-2);
  display: inline-flex;
  width: 16px; height: 16px;
  align-items: center; justify-content: center;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle:hover { color: var(--ink-2); }
.expand-toggle {
  background: transparent;
  border: 0;
  width: 22px; height: 22px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px;
  transition: transform 0.18s, background 0.12s;
}
.expand-toggle:hover { background: var(--bg-2); color: var(--ink); }
.expand-toggle.open { transform: rotate(90deg); }

.type-glyph {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.type-glyph svg { display: block; }

.page-title {
  display: flex; align-items: baseline; gap: 10px; min-width: 0;
}
.page-title h3 {
  font-family: var(--font-sans);
  font-size: 20px;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--gray-darker);
  font-weight: 700;
}
.page-url {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.page-badges {
  display: flex; gap: 6px; align-items: center; flex-wrap: nowrap;
}
.badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink-2);
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
}
.badge.mvp { color: var(--mvp); border-color: color-mix(in oklab, var(--mvp) 30%, var(--line)); }
.badge.phase2 { color: var(--phase2); border-color: color-mix(in oklab, var(--phase2) 30%, var(--line)); }
.badge.future { color: var(--future); }
.badge .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
}
.comment-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.comment-badge.has { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 35%, var(--line)); }

.counts {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* Page body */
.page-body {
  padding: 4px 16px 14px 50px;
  border-top: 1px solid var(--line);
  background: linear-gradient(to bottom, var(--panel-2) 0%, var(--panel) 60%);
}
.page-summary {
  font-size: 13.5px;
  color: var(--ink-2);
  padding: 12px 0 6px;
  max-width: 820px;
  text-wrap: pretty;
}
.page-summary em {
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 14px;
  color: var(--maroon);
  font-weight: 700;
}

/* Section row */
.sections {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}
.section {
  border-left: 2px solid var(--line-strong);
  padding-left: 14px;
  margin-left: 6px;
  position: relative;
}
.section + .section { margin-top: 4px; }
.section.selected {
  border-left-color: var(--maroon);
  border-left-width: 3px;
  margin-left: 5px;
}
.section.selected > .section-head {
  background: linear-gradient(
    to right,
    color-mix(in oklab, var(--gold) 35%, var(--white)) 0%,
    color-mix(in oklab, var(--gold) 18%, var(--white)) 100%
  );
  box-shadow:
    inset 0 0 0 1px color-mix(in oklab, var(--gold-deep) 30%, transparent),
    0 1px 2px rgba(31,27,22,0.04);
  border-radius: var(--r-md);
}
.section.selected > .section-head h4 {
  color: var(--maroon);
  font-weight: 700;
}
.section.dragging { opacity: 0.4; }
.section.drop-target { border-left-style: dashed; border-left-color: var(--accent); }

.section-head {
  display: grid;
  grid-template-columns: 18px 18px 20px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px 8px 4px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.1s;
}
.section-head:hover { background: var(--panel-2); }

.section-title {
  display: flex; align-items: baseline; gap: 10px;
  min-width: 0;
}
.section-title h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}
.section-summary-inline {
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
}

/* Content list */
.contents {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px;
  padding: 6px 0 12px 28px;
}
.content {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  transition: all 0.1s;
  line-height: 1.35;
}
.content:hover { border-color: var(--line-strong); background: var(--bg-2); }
.content.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}
.content.dragging { opacity: 0.4; }
.content.drop-target { border-style: dashed; border-color: var(--accent); }
.content-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--content);
  flex-shrink: 0;
}
.content-text {
  flex: 1;
  min-width: 0;
}
.content-pips {
  display: inline-flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.content-pip {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.02em;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: var(--white);
}
.pip-sg { color: var(--maroon); }
.pip-fn { color: var(--gold-deep); }
.content.selected .content-pip { background: var(--white); }

/* Above-the-fold zone */
.fold-zone {
  margin: 14px 0 6px;
  padding: 14px 16px 0;
  background:
    linear-gradient(to bottom, var(--gold-soft) 0%, color-mix(in oklab, var(--gold-soft) 40%, var(--panel)) 100%);
  border: 1px solid color-mix(in oklab, var(--gold) 45%, var(--line));
  border-radius: var(--r-md);
  position: relative;
}
.fold-zone-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 6px;
}
.fold-zone-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--gold-deep);
}
.fold-zone-caption {
  font-size: 11.5px;
  color: var(--ink-2);
  font-style: italic;
}
.fold-list {
  list-style: none;
  margin: 0;
  padding: 0 0 12px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.fold-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: start;
  gap: 8px;
  background: var(--white);
  border: 1px solid color-mix(in oklab, var(--gold) 25%, var(--line));
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.4;
  text-wrap: pretty;
  cursor: pointer;
  transition: all 0.1s;
  position: relative;
}
.fold-item:hover {
  border-color: color-mix(in oklab, var(--gold-deep) 55%, var(--line));
  box-shadow: 0 1px 3px rgba(31,27,22,0.06);
}
.fold-item:focus-visible {
  outline: 2px solid var(--maroon);
  outline-offset: 1px;
}
.fold-item.selected {
  border-color: var(--maroon);
  background: color-mix(in oklab, var(--maroon) 5%, var(--white));
  box-shadow: 0 0 0 1px var(--maroon), 0 2px 6px rgba(122,0,25,0.08);
}
.fold-item.selected .fold-num { color: var(--maroon); }
.fold-pips {
  display: inline-flex; align-items: center; gap: 4px;
  align-self: center;
  flex-shrink: 0;
}
.fold-num {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--gold-deep);
  font-weight: 700;
  padding-top: 2px;
}
.fold-text { min-width: 0; }

.fold-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 -16px;
  padding: 4px 16px 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-deep);
  border-top: 1px dashed color-mix(in oklab, var(--gold-deep) 55%, var(--line));
  background: transparent;
  position: relative;
  top: 1px;
  font-weight: 600;
}
.fold-line-glyph { font-size: 10px; opacity: 0.7; }
.fold-line-label { padding: 0 2px; }

/* Sidebar variant — compact, no card grid */
.sb-fold-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sb-fold-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  background: color-mix(in oklab, var(--gold-soft) 60%, var(--white));
  border: 1px solid color-mix(in oklab, var(--gold) 30%, var(--line));
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.4;
}
.sb-fold-num {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--gold-deep);
  font-weight: 700;
  padding-top: 2px;
}

.sb-fold-item.is-clickable {
  cursor: pointer;
  transition: all 0.1s;
}
.sb-fold-item.is-clickable:hover {
  border-color: var(--maroon);
  background: color-mix(in oklab, var(--maroon) 5%, var(--white));
}
.sb-fold-item.is-clickable:focus-visible {
  outline: 2px solid var(--maroon);
  outline-offset: 1px;
}

/* end fold-zone */
.sidebar {
  position: sticky;
  top: 108px;
  height: calc(100vh - 108px);
  border-left: 1px solid var(--line);
  background: var(--gray-lighter);
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.6);
  overflow-y: auto;
  padding: 24px 22px 60px;
}
.sidebar-empty {
  color: var(--muted);
  font-style: italic;
  margin-top: 60px;
  text-align: center;
  padding: 0 24px;
}
.sidebar-empty .glyph {
  font-family: var(--font-serif);
  font-size: 36px;
  display: block;
  margin-bottom: 12px;
  color: var(--muted-2);
}

.sb-kicker {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.sb-kicker .type-pill {
  padding: 2px 7px; border-radius: 999px;
  color: var(--bg);
}
.sb-kicker .type-pill.page { background: var(--page); }
.sb-kicker .type-pill.section { background: var(--section); }
.sb-kicker .type-pill.content { background: var(--content); }

.sb-title {
  font-family: var(--font-sans);
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 6px 0 4px;
  color: var(--gray-darker);
  font-weight: 800;
}
.sb-breadcrumb {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 16px;
  word-break: break-word;
}
.sb-breadcrumb b { color: var(--ink-2); font-weight: 600; }

.sb-section {
  margin-top: 22px;
}
.sb-section-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.sb-section-label .count { color: var(--muted-2); }

.sb-summary {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.55;
  text-wrap: pretty;
}

.sb-meta-grid {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 6px 10px;
  font-size: 12.5px;
}
.sb-meta-grid dt {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  align-self: center;
}
.sb-meta-grid dd {
  margin: 0;
  color: var(--ink-2);
}

.sb-aeo {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.sb-aeo li {
  font-family: var(--font-sans);
  font-style: italic;
  font-size: 13.5px;
  color: var(--ink-2);
  padding-left: 14px;
  position: relative;
  line-height: 1.45;
}
.sb-aeo li::before {
  content: "“";
  position: absolute; left: 0; top: -4px;
  font-size: 20px; color: var(--maroon);
  font-weight: 700;
}

/* Comments */
.comments-list {
  display: flex; flex-direction: column; gap: 10px;
}
.comment {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.comment-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 4px;
  gap: 8px;
}
.comment-author {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.comment-role {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.comment-date {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}
.comment-body {
  font-size: 13px;
  color: var(--ink-2);
  text-wrap: pretty;
  line-height: 1.45;
}
.comments-empty {
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
  padding: 8px 0;
}

.comment-add {
  margin-top: 12px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px;
}
.comment-add textarea {
  width: 100%;
  resize: vertical;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 13px;
  background: var(--panel-2);
  color: var(--ink);
  outline: none;
}
.comment-add textarea:focus { border-color: var(--accent); background: var(--panel); }
.comment-add-actions {
  display: flex; gap: 6px; justify-content: space-between; align-items: center;
}
.comment-add-actions small {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}
.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border: 0;
  padding: 6px 12px;
  border-radius: var(--r-md);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
}
.btn-primary:hover { background: #000; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.sb-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
}

/* Bulk controls */
.bulk-controls {
  display: inline-flex; gap: 6px; align-items: center;
}

/* Drop indicator */
.drop-line {
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  margin: -1px 0;
  animation: pulse 0.6s ease infinite alternate;
}
@keyframes pulse {
  to { opacity: 0.5; }
}

/* ===== Content detail: suggestions, functionality notes, mini comments ===== */

.btn-primary.tiny {
  padding: 4px 10px;
  font-size: 11px;
}

/* Two-step delete */
.del-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.1s;
}
.del-btn:hover {
  color: var(--danger);
  border-color: color-mix(in oklab, var(--danger) 35%, var(--line));
  background: var(--white);
}
.del-confirm {
  display: inline-flex; gap: 3px; align-items: center;
}
.del-confirm-yes {
  font-family: var(--font-sans);
  font-size: 10.5px; font-weight: 600;
  padding: 3px 8px;
  background: var(--danger);
  color: var(--white);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
.del-confirm-no {
  font-family: var(--font-sans);
  font-size: 10.5px;
  padding: 3px 8px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}
.del-confirm-no:hover { color: var(--ink-2); border-color: var(--line-strong); }

/* Suggestion list & cards */
.suggestion-list {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 10px;
}
.suggestion-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  position: relative;
}
.suggestion-card::before {
  content: "";
  position: absolute;
  left: 0; top: 10px; bottom: 10px; width: 3px;
  background: var(--maroon);
  border-radius: 2px;
}
.suggestion-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 4px;
  font-size: 12px;
}
.suggestion-author { color: var(--ink); }
.suggestion-role {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: 4px;
}
.suggestion-date {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}
.suggestion-body {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
  text-wrap: pretty;
  margin: 6px 0 8px;
}
.suggestion-actions {
  display: flex; align-items: center; gap: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.upvote {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 9px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.1s;
}
.upvote:hover {
  border-color: var(--maroon);
  color: var(--maroon);
}
.upvote.voted {
  background: var(--maroon);
  color: var(--white);
  border-color: var(--maroon);
}
.upvote-count { font-weight: 700; }

/* Mini comments (nested under each card) */
.mini-comments {
  margin-top: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}
.mini-comments-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
}
.mini-comments-toggle:hover { color: var(--maroon); }
.mini-chev { margin-left: 2px; }
.mini-comments-body {
  margin-top: 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.mini-comment {
  background: var(--gray-lighter);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 9px;
  font-size: 12px;
}
.mini-comment-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
  font-size: 11px;
  color: var(--ink-2);
}
.mini-comment-meta {
  display: inline-flex; align-items: center; gap: 4px;
}
.mini-comment-role {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.mini-comment-date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}
.mini-comment-body {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.4;
}
.mini-comment-add {
  display: flex; gap: 6px;
  align-items: stretch;
}
.mini-comment-add textarea {
  flex: 1;
  resize: vertical;
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 12px;
  background: var(--white);
  color: var(--ink);
  outline: none;
}
.mini-comment-add textarea:focus { border-color: var(--maroon); }

/* Add forms */
.add-row-btn {
  width: 100%;
  text-align: left;
  background: var(--white);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  padding: 9px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.1s;
}
.add-row-btn:hover {
  border-color: var(--maroon);
  color: var(--maroon);
  background: color-mix(in oklab, var(--maroon) 4%, var(--white));
}
.add-glyph {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  background: color-mix(in oklab, var(--maroon) 15%, var(--white));
  color: var(--maroon);
}
.add-form {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.add-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 64px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 13px;
  background: var(--gray-lighter);
  color: var(--ink);
  outline: none;
}
.add-form textarea:focus { border-color: var(--maroon); background: var(--white); }
.add-form-actions {
  display: flex; align-items: center; gap: 6px;
}
.add-form-actions small {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}

/* Functionality kind picker */
.kind-picker {
  display: inline-flex;
  background: var(--gray-lighter);
  border-radius: 999px;
  padding: 2px;
  gap: 0;
  align-self: flex-start;
}
.kind-pick {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  background: transparent;
  border: 0;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--ink-2);
  cursor: pointer;
}
.kind-pick.on {
  background: var(--white);
  color: var(--maroon);
  box-shadow: 0 1px 2px rgba(31,27,22,0.06);
}

.target-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 12px;
  background: var(--white);
  color: var(--ink);
}

/* Functionality cards */
.func-list {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 10px;
}
.func-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  position: relative;
}
.func-card::before {
  content: "";
  position: absolute;
  left: 0; top: 10px; bottom: 10px; width: 3px;
  background: var(--gold);
  border-radius: 2px;
}
.func-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.func-kind {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.kind-link { color: var(--maroon); background: color-mix(in oklab, var(--maroon) 6%, var(--white)); }
.kind-action { color: var(--gold-deep); background: color-mix(in oklab, var(--gold) 12%, var(--white)); }
.kind-behavior { color: var(--gray-dark); background: var(--gray-lighter); }

.func-author { font-size: 12px; color: var(--ink-2); }
.func-role { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-left: 4px; }
.func-date { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.func-body {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
  text-wrap: pretty;
}
.func-target {
  margin-top: 8px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  background: color-mix(in oklab, var(--maroon) 5%, var(--white));
  border: 1px solid color-mix(in oklab, var(--maroon) 25%, var(--line));
  border-radius: var(--r-sm);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: all 0.1s;
}
.func-target:hover {
  background: color-mix(in oklab, var(--maroon) 9%, var(--white));
  border-color: var(--maroon);
}
.func-target-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--maroon);
}
.func-target-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.func-target-url {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* end content-detail */

/* ===== Inline add affordances (canvas) ===== */
.add-inline-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px dashed var(--line-strong);
  color: var(--ink-2);
  border-radius: 4px;
  padding: 8px 14px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.add-inline-btn:hover {
  border-color: var(--maroon);
  color: var(--maroon);
  background: color-mix(in oklab, var(--maroon) 5%, var(--white));
  border-style: solid;
}
.add-inline-btn .add-glyph {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  background: color-mix(in oklab, var(--maroon) 15%, var(--white));
  color: var(--maroon);
}

.add-section-btn {
  align-self: flex-start;
  margin-top: 6px;
  margin-left: 6px;
}
.add-content-btn {
  width: 100%;
  justify-content: center;
  background: var(--white);
}
.add-fold-btn {
  display: inline-flex;
  margin: 4px 0 8px;
  background: var(--white);
  border-color: color-mix(in oklab, var(--gold-deep) 45%, var(--line));
}
.add-fold-btn:hover {
  border-color: var(--gold-deep);
  background: color-mix(in oklab, var(--gold) 12%, var(--white));
  color: var(--gold-deep);
}
.fold-zone.fold-zone-empty {
  padding-bottom: 14px;
}
.fold-zone.fold-zone-empty .add-fold-btn {
  margin-top: 4px;
}

.add-page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: var(--white);
  border: 2px dashed var(--line-strong);
  color: var(--maroon);
  border-radius: 4px;
  padding: 18px;
  margin-top: 4px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all 0.12s;
}
.add-page-btn:hover {
  border-color: var(--maroon);
  border-style: solid;
  background: color-mix(in oklab, var(--maroon) 4%, var(--white));
  box-shadow: 0 1px 0 rgba(122,0,25,0.06);
}
.add-page-btn .add-glyph {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  background: var(--maroon);
  color: var(--white);
}

/* ===== Sidebar delete-node button ===== */
.iconbtn.del-node-btn {
  color: var(--danger);
  border-color: color-mix(in oklab, var(--danger) 30%, var(--line));
  background: var(--white);
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
}
.iconbtn.del-node-btn:hover {
  background: var(--danger);
  color: var(--white);
  border-color: var(--danger);
}
.del-node-confirm {
  display: inline-flex; align-items: center; gap: 4px;
}
.del-node-confirm .del-confirm-yes {
  font-size: 11px;
  padding: 5px 10px;
}
.del-node-confirm .del-confirm-no {
  font-size: 11px;
  padding: 5px 10px;
}

/* ===== Download / Export panel ===== */
.download-panel {
  margin-top: 36px;
  padding: 32px 28px;
  background: linear-gradient(135deg, var(--maroon-dark) 0%, var(--maroon) 100%);
  color: var(--white);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}
.download-panel::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: var(--gold);
}
.download-panel::after {
  content: "";
  position: absolute;
  right: -120px; top: -120px;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle at center, color-mix(in oklab, var(--gold) 30%, transparent), transparent 60%);
  pointer-events: none;
}
.download-inner {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 32px;
  align-items: center;
  position: relative;
  z-index: 1;
}
.download-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}
.download-title {
  font-family: var(--font-sans);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0 0 10px;
  color: var(--white);
  max-width: 520px;
}
.download-sub {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: color-mix(in oklab, var(--white) 86%, transparent);
  max-width: 540px;
}
.download-sub strong {
  color: var(--gold);
  font-weight: 700;
}
.download-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}
.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  color: var(--gray-darker);
  border: 0;
  padding: 12px 18px;
  border-radius: 4px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: all 0.12s;
  min-width: 280px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 4px 14px rgba(0,0,0,0.12);
}
.download-btn:hover {
  background: var(--gold);
  color: var(--maroon-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.04), 0 8px 20px rgba(0,0,0,0.16);
}
.download-btn svg {
  flex-shrink: 0;
  color: var(--maroon);
}
.download-btn:hover svg { color: var(--maroon-dark); }
.download-btn span:not(.download-btn-title):not(.download-btn-sub) {
  display: flex; flex-direction: column;
}
.download-btn-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
}
.download-btn-sub {
  display: block;
  font-size: 11.5px;
  color: var(--gray-medium);
  margin-top: 3px;
  font-weight: 400;
}
.download-btn:hover .download-btn-sub { color: var(--maroon-dark); }

@media (max-width: 900px) {
  .download-inner { grid-template-columns: 1fr; }
  .download-btn { min-width: 0; width: 100%; }
}
/* Footer (canvas — was the old in-canvas summary) */
.foot {
  border-top: 3px solid var(--maroon);
  padding: 22px 28px 36px;
  max-width: 1640px; margin: 0 auto;
  display: flex; justify-content: space-between; gap: 30px;
  font-size: 13px;
  color: var(--ink-2);
  flex-wrap: wrap;
  background: var(--gray-lighter);
}
.foot strong { color: var(--maroon); font-weight: 700; }

/* Small screens fallback */
@media (max-width: 1100px) {
  .main { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0;
    top: auto; height: 60vh;
    border-left: none;
    border-top: 1px solid var(--line);
    transform: translateY(100%);
    transition: transform 0.2s;
    z-index: 40;
  }
  .sidebar.mobile-open { transform: translateY(0); }
}

/* Scrollbar polish */
.sidebar::-webkit-scrollbar { width: 10px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 3px solid var(--gray-lighter); }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar-header-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.sidebar-eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* -------- Collapsed rail -------- */
.sidebar-rail {
  padding: 14px 8px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  overflow-x: hidden;
}
.rail-toggle {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.12s;
}
.rail-toggle:hover {
  border-color: var(--maroon);
  color: var(--maroon);
  background: var(--white);
}
.rail-empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--muted-2);
  margin-top: 18px;
}
.rail-empty-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.2;
  color: var(--muted);
}

.rail-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  width: 100%;
}
.rail-type-mark {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--white);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.rail-type-mark.page { border-color: color-mix(in oklab, var(--maroon) 30%, var(--line)); }
.rail-type-mark.section { border-color: color-mix(in oklab, var(--gold) 40%, var(--line)); }
.rail-type-mark.content { border-color: var(--line-strong); }

.rail-title {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.01em;
  margin: 6px 0;
  max-height: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  padding: 4px 0;
  border-left: 2px solid var(--maroon);
  padding-left: 4px;
}
.rail-title:hover { color: var(--maroon); }

.rail-pip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  width: 38px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  cursor: default;
}
.rail-pip:hover { border-color: var(--line-strong); color: var(--ink-2); }
.rail-pip-accent {
  color: var(--maroon);
  border-color: color-mix(in oklab, var(--maroon) 40%, var(--line));
  background: color-mix(in oklab, var(--maroon) 6%, var(--white));
}
.rail-pip-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.rail-pip-num { font-weight: 600; font-size: 11px; color: var(--ink-2); }
.rail-pip-label { font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }

.rail-pip.status-mvp { color: var(--mvp); border-color: color-mix(in oklab, var(--mvp) 35%, var(--line)); }
.rail-pip.status-mvp .rail-pip-label { color: var(--mvp); }
.rail-pip.status-phase2 { color: var(--gold-deep); border-color: color-mix(in oklab, var(--gold-deep) 40%, var(--line)); background: color-mix(in oklab, var(--gold) 8%, var(--white)); }
.rail-pip.status-phase2 .rail-pip-label { color: var(--gold-deep); }
.rail-pip.status-future { color: var(--muted); }

.rail-clear {
  margin-top: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.rail-clear:hover { color: var(--maroon); border-color: var(--maroon); }

/* ── Shared button ─────────────────────────────────────────────────────────── */
.btn-save {
  background: var(--maroon); color: var(--white);
  border: 1px solid var(--maroon); border-radius: 6px;
  font-size: 12px; font-weight: 600;
  padding: 5px 14px; cursor: pointer;
  transition: background 0.12s;
}
.btn-save:hover { background: var(--maroon-dark); border-color: var(--maroon-dark); }

/* ── Loading & error screens ───────────────────────────────────────────────── */
.loading-screen, .error-screen {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--white); gap: 18px;
  padding: 40px; text-align: center;
}
.loading-logo { height: 32px; }
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--maroon);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase;
}
.error-screen h2 { color: var(--maroon); margin: 0; font-size: 22px; }
.error-screen p { font-size: 13.5px; color: var(--ink-2); max-width: 500px; }
.error-screen pre {
  background: var(--gray-lighter); padding: 12px 16px;
  border-radius: var(--r-md); font-size: 11.5px;
  max-width: 600px; white-space: pre-wrap; word-break: break-all;
  text-align: left; color: var(--danger);
}

/* ── User identity banner (bottom-left) ────────────────────────────────────── */
.user-banner {
  position: fixed; bottom: 18px; left: 18px; z-index: 200;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 8px 14px;
  font-size: 12.5px; color: var(--ink-2);
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 8px;
}
.user-banner.editing {
  flex-direction: column; align-items: stretch; gap: 8px; min-width: 230px;
}
.user-banner-label {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.user-banner input {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 6px 9px; font: inherit; font-size: 12.5px; width: 100%; outline: none;
  background: var(--gray-lighter);
}
.user-banner input:focus { border-color: var(--maroon); background: var(--white); }
.user-banner-actions { display: flex; gap: 6px; }
.user-banner button {
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 4px 9px;
  font: inherit; font-size: 11.5px; cursor: pointer; color: var(--muted);
}
.user-banner button:hover { color: var(--maroon); border-color: var(--maroon); }
.user-banner .btn-save {
  background: var(--maroon); color: var(--white);
  border-color: var(--maroon); font-weight: 600; flex: 1;
}
.user-banner .btn-save:hover { background: var(--maroon-dark); border-color: var(--maroon-dark); color: var(--white); }

/* ── Sync button in topnav ──────────────────────────────────────────────────── */
.sync-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.04em; text-transform: uppercase;
  background: transparent; border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px;
  cursor: pointer; color: var(--muted);
  transition: all 0.12s;
}
.sync-btn:hover { border-color: var(--maroon); color: var(--maroon); }
.sync-btn.syncing { opacity: 0.6; cursor: not-allowed; }
.sync-btn svg { flex-shrink: 0; }
