/* ==================================================================
   DESIGN TOKENS
   Re-theme the whole site by editing these two blocks. Nothing below
   them contains a hard-coded colour.
   ================================================================== */

:root,
:root[data-theme="light"] {
  --canvas:       #cdc1ac;   /* page and tree background */
  --paper:        #f4eee3;   /* panels' inner surfaces, like an old album page */
  --paper-deep:   #ebe3d4;
  --card:         #fffdf8;
  --card-focus:   #fffaf0;
  --ink:          #2a231c;
  --ink-soft:     #6b5e50;
  --ink-faint:    #9a8c7a;
  --line:         #ddd2bf;
  --line-strong:  #c4b59d;
  --grid:         rgba(70, 52, 28, .2);
  --accent:       #2f5d50;   /* forest green: buttons, focus, highlights */
  --accent-hover: #244a3f;
  --accent-soft:  #3f7666;
  --accent-wash:  rgba(47, 93, 80, .1);
  --accent-ink:   #fbf7ef;
  --edge:         #b3a48b;
  --edge-hot:     #2f5d50;

  /* Family branches */
  --brickley:     #b5502e;   /* brick */
  --brown:        #8a6a3b;   /* saddle */
  --ferrell:      #3d7487;   /* slate blue */
  --home:         #c49a2c;   /* gold, Tyler & Molly's household */

  /* Confidence badges */
  --ok:           #2f6b4a;
  --ok-wash:      rgba(47, 107, 74, .12);
  --info:         #3d5f87;
  --info-wash:    rgba(61, 95, 135, .12);
  --warm:         #8a5a1f;
  --warm-wash:    rgba(196, 140, 44, .16);
  --open:         #8f3b3b;
  --open-wash:    rgba(143, 59, 59, .1);

  --shadow:       0 1px 2px rgba(60, 40, 20, .08), 0 6px 18px rgba(60, 40, 20, .08);
  --shadow-lift:  0 2px 4px rgba(60, 40, 20, .1), 0 14px 34px rgba(60, 40, 20, .16);
  --veil:         rgba(244, 238, 227, .78);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --canvas:       #0f0c0a;
  --paper:        #16120f;
  --paper-deep:   #1d1814;
  --card:         #231d18;
  --card-focus:   #2a231c;
  --ink:          #f1e9dc;
  --ink-soft:     #b9ab96;
  --ink-faint:    #857868;
  --line:         #3a3129;
  --line-strong:  #54473b;
  --grid:         rgba(241, 233, 220, .07);
  --accent:       #8cc2ad;
  --accent-hover: #a7d4c2;
  --accent-soft:  #8cc2ad;
  --accent-wash:  rgba(140, 194, 173, .13);
  --accent-ink:   #13201b;
  --edge:         #5f5244;
  --edge-hot:     #8cc2ad;

  --brickley:     #d9714b;
  --brown:        #c09a62;
  --ferrell:      #6aa6bb;
  --home:         #e0b84a;

  --ok:           #8fcca8;
  --ok-wash:      rgba(143, 204, 168, .13);
  --info:         #9cbce4;
  --info-wash:    rgba(156, 188, 228, .13);
  --warm:         #e5b46a;
  --warm-wash:    rgba(229, 180, 106, .14);
  --open:         #e59a9a;
  --open-wash:    rgba(229, 154, 154, .12);

  --shadow:       0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .28);
  --shadow-lift:  0 2px 6px rgba(0, 0, 0, .35), 0 16px 38px rgba(0, 0, 0, .45);
  --veil:         rgba(22, 18, 15, .8);
  color-scheme: dark;
}

:root {
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body:    'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --topbar:       64px;
  --panel-w:      min(440px, 42vw);
  --radius:       14px;
}

/* ==================================================================
   BASE
   ================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.page-tree { overflow: hidden; overscroll-behavior: none; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0 0 .4em; letter-spacing: -0.01em; text-wrap: balance; }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

button { font: inherit; color: inherit; }

kbd {
  font-family: var(--font-body);
  font-size: 12px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 .4em;
  color: var(--ink-soft);
  background: var(--card);
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }

.kicker { font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--accent-soft); margin: 0 0 .5em; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ==================================================================
   BUTTONS
   ================================================================== */

.button {
  display: inline-flex; align-items: center; gap: .4em;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); border-radius: 999px;
  padding: .6em 1.2em; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button:hover { background: var(--accent-hover); color: var(--accent-ink); }
.button.small { font-size: 14px; padding: .45em .95em; }
.button.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.button.ghost:hover { border-color: var(--accent); color: var(--accent); }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 40px; height: 40px; padding: 0 10px;
  border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--ink-soft); cursor: pointer;
}
.icon-button:hover { background: var(--accent-wash); color: var(--ink); }
.icon-button svg { width: 21px; height: 21px; }
.icon-button .label { font-weight: 600; font-size: 14px; }

.text-button, .link-button {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.text-button:hover, .link-button:hover { color: var(--accent-hover); }

.chip-button {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); cursor: pointer; font-size: 14px; color: var(--ink-soft);
  white-space: nowrap;
}
.chip-button strong { color: var(--ink); font-weight: 700; }
.chip-button:hover { border-color: var(--accent); }
.me-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--home); box-shadow: 0 0 0 3px color-mix(in srgb, var(--home) 25%, transparent); }

/* Theme toggle shows the icon for the theme you would switch to. */
[data-theme="dark"] #theme-button .moon,
[data-theme="light"] #theme-button .sun { display: none; }

/* ==================================================================
   TOP BAR
   ================================================================== */

.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  height: var(--topbar);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; flex-shrink: 0; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 30px; height: 30px; color: var(--accent); }
.brand-text { font-family: var(--font-display); font-weight: 600; font-size: 19px; line-height: 1.1; display: flex; flex-direction: column; }
.brand-text small { font-family: var(--font-body); font-weight: 500; font-size: 12px; color: var(--ink-soft); }

.search { position: relative; flex: 1; max-width: 460px; margin: 0 auto; }
.search input {
  width: 100%; height: 42px;
  padding: 0 40px 0 40px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink);
  font: inherit; font-size: 15px;
}
.search input::placeholder { color: var(--ink-faint); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }
.search input::-webkit-search-cancel-button { display: none; }
.search-icon { position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--ink-faint); pointer-events: none; }
.search kbd { position: absolute; right: 14px; top: 50%; translate: 0 -50%; pointer-events: none; }
.search input:focus ~ kbd { display: none; }

.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lift); padding: 6px; max-height: min(420px, 60vh); overflow: auto;
}
.result { display: flex; flex-direction: column; padding: 9px 12px; border-radius: 10px; cursor: pointer; }
.result.active, .result:hover { background: var(--accent-wash); }
.result.empty { color: var(--ink-soft); cursor: default; }
.r-name { font-weight: 600; }
.r-meta { font-size: 13px; color: var(--ink-soft); }

.top-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ==================================================================
   TREE CANVAS
   ================================================================== */

.tree {
  position: fixed; inset: var(--topbar) 0 0 0;
  overflow: hidden; touch-action: none; cursor: grab;
  background-color: var(--canvas);
  background-image: radial-gradient(var(--grid) 1.1px, transparent 1.3px);
  background-size: var(--grid-size, 28px) var(--grid-size, 28px);
  background-position: var(--grid-x, 0) var(--grid-y, 0);
  user-select: none; -webkit-user-select: none;
}
.tree:focus-visible { outline-offset: -4px; }
.tree.dragging { cursor: grabbing; }
.tree.dragging .card { cursor: grabbing; }

.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.edges { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.nodes { position: absolute; left: 0; top: 0; }

.edge { fill: none; stroke: var(--edge); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.edge.hot { stroke: var(--edge-hot); stroke-width: 2.6; }
.edge.adoptive { stroke-dasharray: 7 6; }
.edge-couple { stroke-width: 2.4; }
.edge-couple.former { stroke-dasharray: 2 6; }
.edge-couple.unrecorded { stroke-dasharray: 1 5; opacity: .7; }
.edge-sibling { stroke-dasharray: 1 6; }

.card {
  position: absolute; left: 0; top: 0;
  width: 212px; height: 104px;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  padding: 10px 14px 10px 20px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow .2s, border-color .2s, background-color .2s;
}
.card::before {
  content: ''; position: absolute; left: 7px; top: 12px; bottom: 12px; width: 4px;
  border-radius: 4px; background: var(--stripe, var(--line-strong));
}
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lift); z-index: 2; }
.card-rel { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--accent-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-name {
  font-family: var(--font-display); font-weight: 600; font-size: 17px; line-height: 1.16; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-years { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-years em { font-style: normal; color: var(--ink-faint); }

.card.role-focus {
  background: var(--card-focus);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 6px var(--accent-wash), var(--shadow-lift);
  z-index: 3;
}
.card.is-selected:not(.role-focus) { border-color: var(--accent); }
.card.is-unresolved { border-style: dashed; }

.more {
  position: absolute; left: 50%; width: 22px; height: 22px; margin-left: -11px;
  border-radius: 50%; background: var(--card); border: 1px solid var(--line-strong);
  display: grid; place-items: center;
}
.more::after { content: ''; width: 6px; height: 6px; border: solid var(--ink-soft); border-width: 2px 0 0 2px; }
.more-up { top: -12px; }
.more-up::after { transform: translateY(1.5px) rotate(45deg); }
.more-down { bottom: -12px; }
.more-down::after { transform: translateY(-1.5px) rotate(225deg); }

.load-error { width: 320px; margin: 140px 0 0 40px; padding: 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }

/* Floating controls */

.focus-pill {
  position: absolute; top: 14px; left: 50%; translate: -50% 0; z-index: 5;
  display: flex; align-items: baseline; gap: 6px; max-width: calc(100% - 32px);
  padding: 7px 16px; border-radius: 999px;
  background: color-mix(in srgb, var(--card) 92%, transparent); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: 14px; color: var(--ink-soft); white-space: nowrap;
  pointer-events: none;
}
.focus-pill strong { color: var(--ink); overflow: hidden; text-overflow: ellipsis; }

.map-controls, .branch-controls {
  position: absolute; bottom: 16px; z-index: 5;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.map-controls { right: 16px; display: flex; flex-direction: column; padding: 4px; }
.map-controls button {
  width: 42px; height: 42px; border: 0; border-radius: 12px; background: none;
  font-size: 22px; line-height: 1; color: var(--ink-soft); cursor: pointer;
  display: grid; place-items: center;
}
.map-controls button:hover { background: var(--accent-wash); color: var(--ink); }
.map-controls svg { width: 20px; height: 20px; }

.branch-controls { left: 16px; display: flex; flex-direction: column; gap: 4px; padding: 10px; }
.branch-title { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); padding: 0 4px 2px; }
.branch-toggle {
  display: flex; align-items: center; gap: 9px; min-width: 132px;
  padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; text-align: left;
}
.branch-toggle .swatch { width: 12px; height: 12px; border-radius: 4px; }
.branch-toggle.brickley .swatch { background: var(--brickley); }
.branch-toggle.brown .swatch { background: var(--brown); }
.branch-toggle.ferrell .swatch { background: var(--ferrell); }
.branch-toggle:hover { border-color: var(--accent); }
.branch-toggle[aria-pressed="false"] { background: transparent; color: var(--ink-faint); border-style: dashed; }
.branch-toggle[aria-pressed="false"] .swatch { background: transparent; box-shadow: inset 0 0 0 2px var(--line-strong); }

.legend {
  position: absolute; bottom: 22px; left: 50%; translate: -50% 0; z-index: 4;
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center;
  font-size: 12.5px; color: var(--ink-soft); pointer-events: none;
  padding: 6px 14px; border-radius: 999px; background: color-mix(in srgb, var(--canvas) 80%, transparent);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.brickley { background: var(--brickley); }
.swatch.brown { background: var(--brown); }
.swatch.ferrell { background: var(--ferrell); }
.legend .line { width: 22px; height: 0; border-top: 2.5px solid var(--edge); display: inline-block; margin-left: 6px; }
.legend .line.adoptive { border-top-style: dashed; }
.legend .line.spouse { border-top-color: var(--edge); border-top-width: 2.5px; }

/* ==================================================================
   PANELS (person record, stories)
   ================================================================== */

.panel {
  position: fixed; z-index: 20;
  top: var(--topbar); right: 0; bottom: 0; width: var(--panel-w);
  background: var(--card); border-left: 1px solid var(--line);
  box-shadow: -10px 0 40px rgba(0, 0, 0, .08);
  display: flex; flex-direction: column;
  animation: panel-in .32s cubic-bezier(.2, .8, .2, 1);
}
@keyframes panel-in { from { transform: translateX(30px); opacity: 0; } }

.panel-grip { display: none; }
.panel-close { position: absolute; top: 12px; right: 12px; z-index: 2; background: var(--card); }
.panel-body { overflow-y: auto; padding: 26px 26px 40px; overscroll-behavior: contain; }

.panel-open .map-controls { right: calc(var(--panel-w) + 16px); }
.panel-open .focus-pill { left: calc((100% - var(--panel-w)) / 2); }
.panel-open .legend { display: none; }

.rec-name { font-size: 30px; margin: 0 40px .15em 0; }
.rec-aka { margin: 0; color: var(--ink-soft); }
.rec-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 18px; }

.badge {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap; vertical-align: 1px;
}
.badge.confirmed { color: var(--ok); background: var(--ok-wash); }
.badge.strongly-supported { color: var(--info); background: var(--info-wash); }
.badge.family-recollection { color: var(--warm); background: var(--warm-wash); }
.badge.unresolved { color: var(--open); background: var(--open-wash); }

.branch-tag { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }
.branch-tag::before { content: ''; width: 8px; height: 8px; border-radius: 2px; }
.branch-tag.brickley::before { background: var(--brickley); }
.branch-tag.brown::before { background: var(--brown); }
.branch-tag.ferrell::before { background: var(--ferrell); }

.facts { margin: 0 0 18px; display: grid; gap: 10px; }
.facts div { display: grid; grid-template-columns: 76px 1fr; gap: 10px; }
.facts dt { font-size: 13px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; padding-top: 2px; }
.facts dd { margin: 0; }

.rec-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }

.rec-section { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 18px; }
.rec-section h3 { font-size: 18px; margin-bottom: 10px; }

.chip-list { display: grid; gap: 8px; }
.person-chip {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; text-align: left;
  padding: 9px 12px 9px 20px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper); cursor: pointer;
}
.person-chip::before { content: ''; position: absolute; left: 8px; top: 10px; bottom: 10px; width: 4px; border-radius: 4px; background: var(--stripe); }
.person-chip:hover { border-color: var(--accent); }
.chip-name { font-weight: 600; }
.chip-meta { font-size: 13px; color: var(--ink-soft); }
.chip-meta em { font-style: normal; color: var(--warm); font-weight: 600; }

.path { list-style: none; margin: 0; padding: 0 0 0 4px; }
.path li { position: relative; padding: 0 0 12px 22px; }
.path li::before { content: ''; position: absolute; left: 3px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.path li:not(:last-child)::after { content: ''; position: absolute; left: 7px; top: 18px; bottom: -4px; width: 1px; background: var(--line-strong); }
.path li:first-child::before { background: var(--home); }
.path-word { display: block; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); }
.path-name { font-weight: 600; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: var(--ink); }
button.path-name:hover { color: var(--accent); text-decoration: underline; }

.plain, .notes, .sources { margin: 0; padding-left: 1.1em; }
.plain li, .notes li, .sources li { margin-bottom: 8px; }
.notes li { color: var(--ink); }
.sources li { font-size: 14.5px; }
.source-meta, .claims { display: block; font-size: 13px; color: var(--ink-soft); }
.claims { color: var(--ink-faint); }

.story { padding: 14px 16px; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); margin-bottom: 10px; }
.story h4 { font-size: 18px; margin: 0 0 6px; }
.story p { margin: 0 0 10px; }
.story-era { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-soft); margin: 0 0 2px !important; }
.story-foot { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 14px; }

.stories-panel h2 { font-size: 30px; }
.story-list { list-style: none; margin: 18px 0 0; padding: 0; }

.tip-note { margin: 14px 2px 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-faint); }
.tip-note a { color: var(--ink-soft); font-weight: 600; }
.contact-line { margin-top: 26px; padding: 14px 16px; border-radius: 12px; background: var(--accent-wash); font-size: 14.5px; }

/* ==================================================================
   WELCOME
   ================================================================== */

.welcome {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px;
  background: var(--veil);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  animation: fade-in .4s ease;
}
.welcome.leaving { animation: fade-out .4s ease forwards; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; visibility: hidden; } }

.welcome-card {
  width: min(600px, 100%);
  padding: clamp(28px, 5vw, 48px);
  background: var(--card); border: 1px solid var(--line); border-radius: 26px;
  box-shadow: var(--shadow-lift);
  text-align: center;
  animation: rise .5s cubic-bezier(.2, .8, .2, 1);
}
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
.welcome h1 { font-size: clamp(32px, 5.4vw, 48px); margin-bottom: .3em; }
.welcome .lede { color: var(--ink-soft); font-size: 17px; max-width: 34em; margin: 0 auto 24px; }
.welcome-search { max-width: none; margin-bottom: 14px; text-align: left; }
.welcome-search input { height: 54px; font-size: 17px; padding-left: 46px; box-shadow: 0 0 0 5px var(--accent-wash); border-color: var(--accent); }
.welcome-search .search-icon { left: 17px; width: 20px; height: 20px; }
.welcome-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 26px 0 0; padding-top: 22px; border-top: 1px solid var(--line); }
.welcome-stats dt { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.welcome-stats dd { margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 600; }

/* ==================================================================
   ABOUT DIALOG, 404
   ================================================================== */

.sheet-dialog {
  width: min(600px, calc(100% - 32px)); max-height: calc(100% - 48px);
  padding: 28px 30px; border: 1px solid var(--line); border-radius: 22px;
  background: var(--card); color: var(--ink); box-shadow: var(--shadow-lift);
}
.sheet-dialog::backdrop { background: var(--veil); backdrop-filter: blur(4px); }
.sheet-dialog h2 { font-size: 28px; margin-right: 40px; }
.sheet-dialog h3 { font-size: 18px; margin-top: 1.3em; }
.dialog-close-row { position: absolute; top: 14px; right: 14px; margin: 0; }
.confidence-key, .howto { padding: 0; list-style: none; margin: 0; display: grid; gap: 8px; }
.confidence-key .badge { margin-right: 6px; }
.venmo-button { background: #008cff; border-color: #008cff; color: #fff; }
.venmo-button:hover { background: #0074d4; border-color: #0074d4; color: #fff; }
.venmo-button svg { width: 18px; height: 18px; }
.welcome-tip { font-size: 14px; color: var(--ink-soft); margin: 18px 0 0; }
.howto li { padding-left: 18px; position: relative; }
.howto li::before { content: ''; position: absolute; left: 2px; top: .65em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.page-plain .search, .page-plain .top-actions { display: none; }
.not-found { max-width: 560px; margin: calc(var(--topbar) + 12vh) auto 0; padding: 0 20px; text-align: center; }
.not-found h1 { font-size: clamp(32px, 6vw, 48px); }
.not-found p { color: var(--ink-soft); font-size: 18px; margin-bottom: 1.6em; }

.noscript { position: fixed; inset: auto 16px 16px 16px; z-index: 60; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; text-align: center; }

/* ==================================================================
   SMALL SCREENS
   ================================================================== */

@media (max-width: 1100px) {
  .legend { display: none; }
}

@media (max-width: 899px) {
  :root { --topbar: 112px; }
  .topbar { flex-wrap: wrap; height: var(--topbar); padding: 10px 12px; gap: 8px 10px; align-content: center; }
  .brand { order: 1; flex: 1; min-width: 0; }
  .brand-mark { width: 26px; height: 26px; flex-shrink: 0; }
  .brand-text { font-size: 17px; min-width: 0; }
  .brand-name, .brand-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-actions { gap: 0; }
  .top-actions .icon-button { min-width: 38px; padding: 0 8px; }
  .top-actions { order: 2; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .search kbd { display: none; }
  .icon-button .label { display: none; }
  .chip-button { padding: 0 12px; }

  .panel {
    top: auto; left: 0; width: auto; height: 62vh; height: 62dvh;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .14);
    animation-name: sheet-in;
  }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
  .panel-grip { display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 9px auto 0; flex-shrink: 0; }
  .panel-body { padding: 14px 20px calc(30px + env(safe-area-inset-bottom)); }
  .panel-close { top: 10px; right: 10px; }
  .rec-name { font-size: 25px; }

  .panel-open .map-controls { right: 12px; }
  .panel-open .focus-pill { left: 50%; }
  .panel-open .branch-controls, .panel-open .map-controls, .panel-open .focus-pill { display: none; }

  .map-controls { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .branch-controls { left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); padding: 6px; flex-direction: row; }
  .branch-title { display: none; }
  .branch-toggle { min-width: 0; padding: 7px 9px; font-size: 13px; gap: 6px; }
  .focus-pill { top: 10px; font-size: 13px; }
  .focus-label { display: none; }
  .welcome-stats { grid-template-columns: repeat(2, 1fr); row-gap: 14px; }
}
