/* 46556 Unified Design System — Stylesheet (Phase 5 Cohesion)
   Governed by the Imus Standard, Chisel & Mouse architectural credentials,
   Gwern/Tufte editorial rhythm, and Craig Mod metadata tokens.
   100% Vanilla CSS — Zero Build Step — Zero WebFont Dependencies. */

:root {
  /* Surface and Background Roles */
  --ink: #17150f;          /* Primary matte background */
  --card: #201e17;         /* Container / card surface */
  --card-hover: #26231b;   /* Interactive card hover */
  --surface-alt: #1a1812;  /* Secondary / table header surface */
  --surface-input: #12110d;/* Input background */

  /* Text and Foreground Roles (WCAG AA Compliant) */
  --paper: #f4efe3;        /* Primary high-contrast text (15.3:1 contrast on ink) */
  --ivory: #efe5cb;        /* Secondary heading & body text (13.5:1 contrast) */
  --body-muted: #d8d0ba;   /* Standard reading body text (10.5:1 contrast) */
  --mut: #8d8570;          /* Tertiary / metadata / label text (4.8:1 contrast) */

  /* Accent and Structural Roles */
  --brass: #c9a227;        /* Primary architectural accent (6.1:1 contrast) */
  --brass-hover: #dbb335;  /* Hover state for brass */
  --teal: #10626e;         /* Secondary accent */
  --teal-light: #5bc0be;   /* Informational light teal callout header */
  --warning: #f59e0b;      /* Warning / alert callout header */
  --line: #37332a;         /* Structural border / divider line */

  /* Interactive & Utility Roles */
  --focus-ring: #c9a227;   /* High-visibility focus indicator */
  --select-bg: rgba(201, 162, 39, 0.25); /* Text selection highlight */

  /* Font Families */
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Typography Scale */
  --text-display: clamp(2rem, 4.5vw, 3.25rem);
  --text-h1: clamp(1.75rem, 3.5vw, 2.5rem);
  --text-h2: clamp(1.35rem, 2.5vw, 1.75rem);
  --text-h3: 1.15rem;
  --text-lede: clamp(1.05rem, 1.8vw, 1.2rem);
  --text-body: 1rem;
  --text-sm: 0.875rem;
  --text-xs: 0.75rem;
  --text-meta: 0.6875rem;

  /* Spacing Scale */
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 96px;

  /* Radii Tokens */
  --radius-none: 0px;
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-pill: 9999px;

  /* Layout Containers */
  --container-reading: 72ch;
  --container-content: 900px;
  --container-wide: 1100px;
  --container-full: 1400px;
}

/* Base Reset & Core Elements */
* { box-sizing: border-box; }
::selection { background: var(--select-bg); color: var(--paper); }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-serif);
  font-size: var(--text-body);
  line-height: 1.6;
}

a {
  color: var(--brass);
  text-decoration: none;
}
a:hover {
  color: var(--brass-hover);
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--focus-ring) !important;
  outline-offset: 2px !important;
}

h1, h2, h3, h4 {
  font-weight: normal;
  margin-top: 0;
}
h1 {
  font-size: var(--text-h1);
  line-height: 1.2;
}
h2 {
  font-size: var(--text-h2);
  line-height: 1.28;
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-xs);
}
h3 {
  font-size: var(--text-h3);
  line-height: 1.35;
  margin-bottom: var(--space-xs);
}
p {
  margin-top: 0;
  margin-bottom: var(--space-md);
  color: var(--body-muted);
}
code, pre {
  font-family: var(--font-mono);
}

/* Header & Site Navigation */
header.site {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 20px 5vw;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: 14px;
}
.wordmark {
  font-size: 28px;
  letter-spacing: .35em;
  font-weight: bold;
  color: var(--paper);
  text-decoration: none;
  font-family: var(--font-serif);
}
.wordmark span { color: var(--brass); }
.coords {
  color: var(--mut);
  font-size: var(--text-meta);
  letter-spacing: .14em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.site-links {
  display: flex;
  gap: 1.1rem;
  font-size: 14px;
  flex-wrap: wrap;
  align-items: center;
  font-family: var(--font-sans);
}
.site-links a {
  color: var(--ivory);
  text-decoration: none;
  letter-spacing: .03em;
}
.site-links a:hover,
.site-links a.active {
  color: var(--brass);
  border-bottom: 1px solid var(--brass);
  text-decoration: none;
}

/* Main Layout & Containers */
main { padding: 0 5vw; }
.hero, .atlas-hero, .library-hero, .report-hero {
  padding: 0 5vw 8px;
  max-width: var(--container-wide);
  margin: 0 auto;
}
.library-hero, .report-hero {
  padding: 40px 5vw 20px;
}
.hero img {
  width: 100%;
  height: min(76vh, 900px);
  object-fit: cover;
  object-position: center;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius-none);
}
.hero h1, .atlas-hero h1, .library-hero h1, .report-hero h1 {
  font-size: var(--text-display);
  line-height: 1.12;
  margin: 30px 0 10px;
}
.hero h1 em, .atlas-hero h1 em, .library-hero h1 em, .report-hero h1 em {
  color: var(--brass);
  font-style: normal;
}
.hero p.lede, .atlas-hero p.lede, .library-hero p.lede, .report-hero p.lede,
p.lede {
  font-size: var(--text-lede);
  color: var(--body-muted);
  max-width: 62ch;
  line-height: 1.55;
}
.sub {
  color: var(--mut);
  max-width: 70ch;
  font-size: var(--text-sm);
}
.content-section {
  max-width: var(--container-content);
  margin: 40px auto 0;
}
.legal {
  padding: 0 5vw;
  max-width: var(--container-reading);
  margin: 0 auto;
}
.legal h1 {
  font-weight: normal;
  margin-top: 32px;
}
.legal p,
.legal li {
  color: var(--body-muted);
  font-size: 15px;
}

/* Cards & Offers Grid */
.card, .tcard, .libcard, .storybox, .gauge-card, .canopy-stat-card, .lib-stat-card, .stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.offers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 22px;
  margin-top: 26px;
}
.card {
  padding: 0 0 20px;
  display: flex;
  flex-direction: column;
}
.card img {
  width: 100%;
  height: 230px;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--line);
}
.card .body {
  padding: 18px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.card h3 {
  margin: 0;
  font-size: 21px;
  font-weight: normal;
  color: var(--paper);
}
.price {
  font-size: 24px;
  color: var(--brass);
  font-variant-numeric: tabular-nums;
}
.card p {
  margin: 0;
  color: var(--body-muted);
  font-size: 15px;
}
.card ul {
  margin: 4px 0 6px;
  padding-left: 18px;
  color: var(--body-muted);
  font-size: 14.5px;
}
.res {
  margin-top: auto;
  padding: 14px 20px 0;
}

/* Buttons & Interactive Elements */
button.reserve {
  width: 100%;
  padding: 13px;
  background: var(--brass);
  color: #17150f;
  border: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
button.reserve:hover:not([disabled]) {
  background: var(--brass-hover);
}
button.reserve[disabled] {
  background: var(--line);
  color: var(--mut);
  cursor: not-allowed;
}

.fineprint {
  font-size: var(--text-xs);
  color: var(--mut);
  margin-top: 8px;
}

/* Steps Grid */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 22px;
  margin-top: 20px;
}
.step {
  border-top: 2px solid var(--brass);
  padding-top: 10px;
}
.step h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: normal;
  color: var(--ivory);
}
.step p {
  margin: 0;
  color: var(--body-muted);
  font-size: 14.5px;
}

/* FAQ Section */
.faq { max-width: 78ch; }
.faq h3 {
  margin: 22px 0 4px;
  font-size: 17px;
  font-weight: normal;
  color: var(--ivory);
}
.faq p {
  margin: 0;
  color: var(--body-muted);
  font-size: 15px;
}

/* Mailbox Component */
.mailbox {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 22px;
  margin: 26px 0;
  border-radius: var(--radius-sm);
}
.mailbox input[type=email] {
  width: min(420px, 90%);
  padding: 11px;
  font-family: inherit;
  font-size: 15px;
  background: var(--surface-input);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.mailbox button {
  padding: 11px 18px;
  background: var(--brass);
  color: #17150f;
  border: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
.mailbox button:hover {
  background: var(--brass-hover);
}

/* Tags & Scale Badges */
.tag, .scale-badge {
  display: inline-block;
  border: 1px solid var(--brass);
  color: var(--brass);
  padding: 2px 8px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-family: var(--font-sans);
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
}

/* Stat Grids & Stat Cards */
.stat-grid, .canopy-stat-grid, .stat-summary-grid, .lib-summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin: 24px 0;
}
.stat-card, .canopy-stat-card, .lib-stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 18px;
  border-radius: var(--radius-sm);
}
.stat-card .label, .canopy-stat-card .label, .stat-card .stat-label {
  font-size: 11px;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-family: var(--font-sans);
}
.stat-card .val, .canopy-stat-card .val, .lib-stat-card .num, .stat-card .stat-val {
  font-size: 26px;
  color: var(--brass);
  font-family: var(--font-serif);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.stat-card .sub, .canopy-stat-card .sub {
  font-size: 12.5px;
  color: var(--mut);
  margin-top: 4px;
}
.canopy-stat-card .note {
  font-size: 13px;
  color: var(--body-muted);
  margin: 0;
}

/* Tables & Registers (ProPublica / Craighill Pattern) */
.table-wrap, .roster-table-wrap, .ledger-table-wrap {
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
}
table.data-table, table.roster-table, table.ledger-table, table.canopy-table, table.profile-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--card);
}
table.data-table th, table.roster-table th, table.ledger-table th, table.canopy-table th, table.profile-table th {
  background: var(--surface-alt);
  color: var(--paper);
  padding: 10px 14px;
  border: 1px solid var(--line);
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-family: var(--font-sans);
  font-weight: 600;
}
table.data-table td, table.roster-table td, table.ledger-table td, table.canopy-table td, table.profile-table td {
  padding: 10px 14px;
  border: 1px solid var(--line);
  text-align: left;
  color: var(--ivory);
  font-variant-numeric: tabular-nums;
}
table.data-table tr:hover td, table.roster-table tr:hover td, table.ledger-table tr:hover td, table.canopy-table tr:hover td {
  background: rgba(201, 162, 39, 0.04);
}
table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Callouts, Pinpoints & Action Buttons */
.callout {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  padding: 16px 20px;
  margin: 24px 0;
  border-radius: var(--radius-sm);
}
.callout.erratum {
  border-left-color: var(--teal-light);
}
.callout.deferred {
  border-left-color: var(--warning);
  background: #1c170d;
}
.pinpoint {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--mut);
  margin: 8px 0 16px;
  border-left: 2px solid var(--brass);
  padding-left: 10px;
  line-height: 1.4;
}
.callout-box {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 20px;
  margin: 24px 0;
  border-left: 3px solid var(--brass);
  border-radius: var(--radius-sm);
}

.btn-row {
  margin: 30px 0;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.action-btn {
  padding: 11px 18px;
  background: var(--brass);
  color: #17150f;
  border: 0;
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
.action-btn:hover {
  background: var(--brass-hover);
  color: #17150f;
  text-decoration: none;
}
.action-btn.secondary {
  background: var(--card);
  color: var(--paper);
  border: 1px solid var(--line);
}
.action-btn.secondary:hover {
  border-color: var(--brass);
  color: var(--brass);
}
.action-link {
  font-size: 13px;
  color: var(--brass);
  text-decoration: none;
  margin-top: 10px;
  display: inline-block;
  cursor: pointer;
}
.action-link:hover {
  text-decoration: underline;
  color: var(--brass-hover);
}

/* Badges & Status Pills */
.tier-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: normal;
  letter-spacing: .04em;
  font-family: var(--font-sans);
}
.tier-historic { background: #2e2611; color: var(--brass); border: 1px solid #785e13; }
.tier-supporting { background: #172428; color: #5bc0be; border: 1px solid #28535b; }
.tier-placement { background: #261f22; color: #d88c9a; border: 1px solid #5a353c; }
.tier-none { background: #222; color: #888; border: 1px solid #444; }

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: #1a2a1a;
  color: #66bb6a;
  border: 1px solid #2e7d32;
  font-family: var(--font-sans);
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-right: 6px;
  font-family: var(--font-sans);
}
.badge-measured { background: #172a1a; color: #66bb6a; border: 1px solid #2e7d32; }
.badge-documented { background: #14232a; color: #4fc3f7; border: 1px solid #0288d1; }
.badge-derived { background: #2a2014; color: #ffb74d; border: 1px solid #f57c00; }
.badge-estimate { background: #261b24; color: #ba68c8; border: 1px solid #7b1fa2; }
.badge-coll { background: var(--card); color: var(--ivory); border: 1px solid var(--line); }

.deep-dive-panel {
  display: none;
  background: var(--surface-input);
  border: 1px solid var(--brass);
  padding: 24px;
  margin: 24px 0;
  border-radius: var(--radius-sm);
}
.deep-dive-panel h3 { margin-top: 0; color: var(--brass); }

/* Quadrant Layouts & Tabs */
.quad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.quad-card {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  padding: 14px;
  border-top: 2px solid var(--brass);
  border-radius: var(--radius-sm);
}
.quad-card .quad-name { font-size: 13px; color: var(--ivory); font-weight: normal; }
.quad-card .quad-val { font-size: 22px; color: var(--brass); font-variant-numeric: tabular-nums; margin: 4px 0; }
.quad-card .quad-sub { font-size: 12px; color: var(--mut); }

.quad-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 24px 0 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.tab-btn {
  padding: 10px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--paper);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  transition: all 0.15s ease;
}
.tab-btn.active, .tab-btn:hover {
  background: var(--brass);
  color: #17150f;
  font-weight: 600;
  border-color: var(--brass);
}

/* Header & Footer Branding / Typography */
header.site .wordmark,
footer.site strong,
footer.fineprint strong {
  color: var(--body-muted);
}

/* Footer & Attribution Rhythm */
footer.site, footer.fineprint {
  border-top: 1px solid var(--line);
  margin-top: 64px;
  padding: 32px 5vw 48px;
  color: var(--mut);
  font-size: 13px;
  line-height: 1.6;
}
footer.site p, footer.fineprint p {
  max-width: 90ch;
  margin: 6px 0;
}
footer.site a, footer.fineprint a {
  color: var(--ivory);
  text-decoration: none;
}
footer.site a:hover, footer.fineprint a:hover {
  color: var(--brass);
  text-decoration: underline;
}




/* ==========================================================================
   Console Minimal (C4) Chrome & One-View Atlas Architecture (§2, §3, §4, §5)
   ========================================================================== */

/* Top Chrome Bar */
.atlas-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  z-index: 20;
  gap: var(--space-sm);
  flex-shrink: 0;
}
.atlas-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}
.atlas-topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}
.chip-strip {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1 1 auto;
  min-width: 0;
}
.chip-strip::-webkit-scrollbar {
  display: none;
}
.preset-chip {
  flex: none; /* never shrink under the label — the strip scrolls instead
                 (Noah, 2026-11-06: words falling out of their pills at
                 mid desktop widths; min-width:44px let pills collapse) */
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}
.preset-chip:hover {
  border-color: var(--brass);
  color: var(--ivory);
}
.preset-chip.active {
  background: var(--brass);
  color: var(--ink);
  font-weight: 600;
  border-color: var(--brass);
}
.icon-btn {
  flex: none;
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-xs);
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.icon-btn:hover {
  border-color: var(--brass);
  color: var(--brass);
}
.icon-btn.active {
  background: var(--brass);
  color: var(--ink);
  border-color: var(--brass);
}
.pill-btn {
  min-height: 44px;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  border: 1px solid var(--brass);
  color: var(--brass);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-weight: 500;
  transition: all 0.15s ease;
}
.pill-btn:hover {
  background: var(--brass);
  color: var(--ink);
  text-decoration: none;
}

/* Paper Viewport & Deckle Ground (§2) */
.paper-viewport {
  position: relative;
  flex: 1;
  background: radial-gradient(circle at 50% 50%, #252019 0%, #1a1711 65%, #14120d 100%);
  padding: var(--space-sm);
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
}
.paper-canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.6), 0 3px 8px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  background: #ede5d8;
  border: 1px solid rgba(141, 133, 112, 0.35);
}
#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Paper Furniture Overlays */
.paper-compass {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 52px;
  height: 52px;
  pointer-events: none;
  z-index: 5;
  opacity: 0.85;
}
.paper-scale-bar {
  position: absolute;
  bottom: 16px;
  right: 16px;
  pointer-events: none;
  z-index: 5;
  font-family: var(--font-serif);
  font-size: 11px;
  color: #4a4231;
  letter-spacing: .06em;
}

/* Floating Stat Card (§3, §4) */
.stat-card-float {
  position: absolute;
  bottom: 24px;
  left: 24px;
  width: 320px;
  max-height: calc(100vh - 140px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  z-index: 10;
  font-family: var(--font-sans);
  color: var(--paper);
  overflow-y: auto;
  box-sizing: border-box;
}
.stat-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--space-xs);
  margin-bottom: var(--space-xs);
}
.stat-card-place {
  font-family: var(--font-serif);
  font-size: var(--text-h3);
  color: var(--ivory);
  margin: 0;
}
.stat-card-sub {
  font-size: var(--text-xs);
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.stat-row-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}
.stat-clickable-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s ease;
}
.stat-clickable-row:hover {
  background: var(--surface-alt);
}
.stat-clickable-row .lbl {
  font-size: var(--text-sm);
  color: var(--body-muted);
}
.stat-clickable-row .val {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--brass);
}
.stat-expansion-pane {
  display: none;
  padding: var(--space-xs) var(--space-sm);
  margin-bottom: var(--space-xs);
  background: var(--surface-alt);
  border-left: 2px solid var(--brass);
  font-size: var(--text-xs);
  color: var(--body-muted);
  line-height: 1.5;
  border-radius: var(--radius-sm);
}
.stat-expansion-pane.open {
  display: block;
}

/* Feature Mode inside Stat Card */
.feature-stat-summary {
  display: none;
}
.feature-stat-summary.open {
  display: block;
}
.feature-stat-summary h3 {
  font-family: var(--font-serif);
  font-size: var(--text-h3);
  color: var(--ivory);
  margin: 0 0 var(--space-xs);
}
.feature-stat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
  margin-bottom: var(--space-sm);
}
.feature-stat-table td {
  padding: 4px 0;
}
.feature-stat-table .k {
  color: var(--mut);
  width: 38%;
}

/* Responsive Detail Panel (§3) */
.detail-panel {
  position: absolute;
  top: 56px;
  right: 0;
  width: 420px;
  height: calc(100% - 56px);
  background: var(--card);
  border-left: 1px solid var(--line);
  z-index: 25;
  padding: var(--space-lg);
  box-sizing: border-box;
  overflow-y: auto;
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.5);
  display: none;
}
.detail-panel.open {
  display: block;
}
.detail-panel-close {
  float: right;
  background: none;
  border: none;
  color: var(--mut);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}
.detail-panel-close:hover {
  color: var(--brass);
}

/* The Data Tray (§3) */
.data-tray {
  position: absolute;
  top: 64px;
  left: 16px;
  width: 360px;
  max-height: calc(100vh - 120px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  z-index: 20;
  padding: var(--space-md);
  box-sizing: border-box;
  overflow-y: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  display: none;
}
.data-tray.open {
  display: block;
}
.tray-group {
  margin-bottom: var(--space-sm);
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--space-xs);
}
.tray-group:last-of-type {
  border-bottom: none;
}
.tray-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xs) 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ivory);
  cursor: pointer;
  user-select: none;
}
.tray-group-header:hover {
  color: var(--brass);
}
.tray-group-content {
  display: none;
  padding: var(--space-xs) 0 var(--space-xs);
  flex-direction: column;
  gap: var(--space-xs);
}
.tray-group-content.open {
  display: flex;
}
.tray-layer-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--body-muted);
  cursor: pointer;
}
.tray-layer-toggle input {
  cursor: pointer;
}

/* Search Flyout Popover (§3) */
.search-popover {
  position: absolute;
  top: 64px;
  left: 200px;
  width: 320px;
  background: var(--card);
  border: 1px solid var(--brass);
  border-radius: var(--radius-sm);
  z-index: 30;
  padding: var(--space-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  display: none;
}
.search-popover.open {
  display: block;
}
.search-popover input {
  width: 100%;
  box-sizing: border-box;
  padding: var(--space-xs) var(--space-sm);
  background: var(--surface-input);
  border: 1px solid var(--line);
  color: var(--paper);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}
.search-results-list {
  max-height: 220px;
  overflow-y: auto;
  margin-top: var(--space-xs);
  list-style: none;
  padding: 0;
}
.search-results-list li {
  padding: var(--space-xs);
  font-size: var(--text-xs);
  color: var(--body-muted);
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.search-results-list li:hover {
  background: var(--surface-alt);
  color: var(--brass);
}

/* Tabbed Records Drawer (§5) */
.records-drawer-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 13, 9, 0.82);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  box-sizing: border-box;
}
.records-drawer-modal.open {
  display: flex;
}
.records-drawer-sheet {
  position: relative;
  width: 100%;
  max-width: 1060px;
  height: 88vh;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.85);
  overflow: hidden;
}
.records-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.records-tabs-bar {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  scrollbar-width: none;
  padding: var(--space-xs) var(--space-lg);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.records-tab-btn {
  padding: var(--space-xs) var(--space-md);
  min-height: 44px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--body-muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  cursor: pointer;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: all 0.15s ease;
}
.records-tab-btn:hover {
  color: var(--ivory);
  border-color: var(--brass);
}
.records-tab-btn.active {
  background: var(--brass);
  color: var(--ink);
  font-weight: 600;
  border-color: var(--brass);
}
.records-tab-content-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  color: var(--paper);
  overflow-x: auto;
}
.records-tab-pane {
  display: none;
}
.records-tab-pane.active {
  display: block;
}

/* Mobile & Touch Layout Constraints (§3) */
@media (max-width: 1023px) {
  .detail-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 80vh;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    z-index: 35;
  }
}
@media (max-width: 768px) {
  .atlas-topbar {
    padding: 0 var(--space-sm);
  }
  .search-popover {
    left: 16px;
    right: 16px;
    width: auto;
  }
  .data-tray {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    /* Noah, 2026-11-06: the tray took the whole screen, so the effect
       of a control on the map was invisible. Cap it at half the
       viewport — the map stays in view while the tray scrolls. */
    max-height: 52vh;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border-bottom: none;
    z-index: 30;
  }
  .stat-card-float {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 30vh;
    border-radius: var(--radius-none);
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-sizing: border-box;
    z-index: 15;
  }
  .records-drawer-modal {
    padding: 0;
  }
  .records-drawer-sheet {
    height: 100vh;
    max-width: 100vw;
    border-radius: 0;
  }
}

/* Floating map legend — follows the building shading (height / era /
   beds / use classes); hidden while the Buildings preset is off. */
#map-legend {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  width: 196px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  font-family: var(--font-sans);
}
#map-legend .ml-title {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ivory);
  margin-bottom: 6px;
}
@media (max-width: 640px) {
  /* Docked bottom-left of the VISIBLE map (Noah, 2026-11-06): the sheet
     overlays the frame's bottom strip on phones, so the dock offset is
     synced to the sheet height in JS (fallback value here ≈ sheet + 12). */
  #map-legend { top: auto; bottom: 244px; left: 12px; right: auto; width: 184px; }
  /* Phone header (QC F1, 2026-11-06): two rows — wordmark + Own pill on
     row 1, the full chip strip on row 2 — so no control leaves the screen
     and the wordmark is never clipped. Coords are decorative: hidden here. */
  .atlas-topbar { flex-wrap: wrap; height: auto; padding: 6px var(--space-sm); row-gap: 6px; }
  .atlas-topbar-left { display: contents; }
  .wordmark { order: 1; font-size: 22px; letter-spacing: .24em; }
  .atlas-topbar-right { order: 2; }
  .atlas-topbar-right .coords { display: none; }
  .chip-strip { order: 3; flex: 1 1 100%; }
  .preset-chip { padding: 4px 10px; font-size: 12px; }
  .search-popover { top: 108px; }
}

/* Records drawer tables: fixed layout, numerics never wrap or clip */
#dorms-table { table-layout: fixed; }
#dorms-table th:nth-child(1), #dorms-table td:nth-child(1) { width: 21%; }
#dorms-table th:nth-child(2), #dorms-table td:nth-child(2) { width: 33%; overflow-wrap: break-word; }
#dorms-table th:nth-child(3), #dorms-table td:nth-child(3) { width: 9%; white-space: nowrap; }
#dorms-table th:nth-child(4), #dorms-table td:nth-child(4) { width: 8%; white-space: nowrap; }
#dorms-table th:nth-child(5), #dorms-table td:nth-child(5) { width: 15%; white-space: nowrap; }
#dorms-table th:nth-child(6), #dorms-table td:nth-child(6) { width: 14%; white-space: nowrap; }

/* Growth player (tray group) */
.growth-head { font-size: 15px; margin: 2px 0 6px; }
.growth-head strong { color: var(--brass); font-size: 19px; }
#growth-year { width: 100%; accent-color: var(--brass); }
.growth-play { background: none; border: 1px solid var(--brass); color: var(--brass); border-radius: 999px; padding: 5px 14px; font: inherit; font-size: 13px; cursor: pointer; margin: 6px 0 8px; }
.growth-play:hover { background: rgba(201, 162, 39, 0.12); }
#growth-spark { width: 100%; height: 64px; display: block; }
.growth-note { color: var(--mut); font-size: 12px; line-height: 1.5; margin: 6px 0; }
.growth-ev { font-size: 12.5px; line-height: 1.5; margin: 4px 0; }
.growth-ev.dim { color: var(--mut); }

/* ==========================================================================
   2026-11-06 mobile chrome round 2 (Noah): compass tap, collapsible legend
   and frame-stats bar.
   ========================================================================== */
.paper-compass { pointer-events: auto; cursor: pointer; }
.ml-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ml-toggle, .stat-toggle {
  display: none; background: none; border: 1px solid var(--line);
  border-radius: var(--radius-pill); color: var(--paper);
  width: 26px; height: 26px; align-items: center; justify-content: center;
  cursor: pointer; font-size: 11px; flex: none; padding: 0;
}
@media (max-width: 640px) {
  #map-legend .ml-toggle { display: inline-flex; }
  #map-legend.collapsed { width: auto; }
  #map-legend.collapsed .ml-body { display: none; }
  #map-legend.collapsed .ml-toggle { transform: rotate(180deg); }
}
@media (max-width: 768px) {
  .stat-toggle { display: inline-flex; }
  #stat-card.collapsed .stat-toggle { transform: rotate(-90deg); }
  #stat-card.collapsed .stat-row-group, #stat-card.collapsed #ghosts-note { display: none; }
  /* Feature mode too: collapsing must shrink the card to its header
     even when a building record is showing (Noah, 2026-11-06: with a
     building selected the toggle flipped the class but nothing moved). */
  #stat-card.collapsed #stat-feature-mode.open { display: none; }
  #stat-card.collapsed { max-height: none; }
}

/* Search input at 16px: iOS Safari auto-zooms focused inputs below 16px,
   which pushed the selected card's close button off-screen (Noah, 2026-11-06). */
.search-popover input { font-size: 16px; }

/* Frame-card micro-sections (Noah, 2026-11-06): Buildings / Canopy /
   Water groups inside the stats card, values live on map move. */
.stat-section { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.stat-section:first-child { margin-top: 2px; padding-top: 0; border-top: none; }
.stat-section-head {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--brass); margin: 0 0 2px; font-weight: 600;
}
.stat-clickable-row.stat-static { cursor: default; }
.stat-clickable-row .val-ellipsis {
  max-width: 55%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Load-in guard: canvas stays hidden until the reveal choreography starts,
   so the first frame is the blank sheet, never a flash of the finished map. */
#paper-wrap.booting #map { opacity: 0; }
#paper-wrap #map { transition: opacity .45s ease; }

/* Ghosts lock-in timeline bar (2026-11-06) */
#ghost-timeline {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(23, 21, 15, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  color: var(--paper);
  font-size: 13px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
  max-width: min(560px, calc(100% - 24px));
}
#ghost-timeline[hidden] { display: none; }
#ghost-timeline .gt-label {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--brass);
  white-space: nowrap;
}
#ghost-timeline input[type="range"] {
  flex: 1 1 180px;
  min-width: 110px;
  accent-color: var(--brass);
  height: 28px;
}
#ghost-year-val {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--ivory);
  min-width: 42px;
  text-align: right;
}
#ghost-play {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--brass);
  background: transparent;
  color: var(--brass);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
@media (max-width: 640px) {
  #ghost-timeline {
    bottom: auto;
    top: 10px;
    left: 10px;
    right: 10px;
    transform: none;
    max-width: none;
    padding: 5px 12px;
  }
}

/* Records Drawer tables (Noah, 2026-11-06: columns overlapped on
   mobile — the plain .table tables in the panes had no cell rules at
   all, and width:100% crushed them instead of scrolling). */
.records-tab-pane table {
  border-collapse: collapse;
}
.records-tab-pane th, .records-tab-pane td {
  padding: 8px 10px;
  vertical-align: top;
}
@media (max-width: 640px) {
  .records-tab-content-area { padding: var(--space-md); }
  .records-tab-pane table {
    font-size: 12px;
    min-width: 540px; /* columns get real room; the pane scrolls sideways */
  }
  .records-tab-pane th, .records-tab-pane td { padding: 6px 8px; }
}
