/* === GLOBAL CONFLICT MONITOR — Editorial redesign ============================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,500;8..60,600;8..60,700&family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

* { box-sizing: border-box; }
html, body, #root { margin: 0; height: 100%; }

:root {
  /* Paper / ink palette */
  --paper:        #f3eee2;   /* warm off-white */
  --paper-2:      #ebe4d3;
  --paper-3:      #e2d9c3;
  --rule:         rgba(26, 24, 21, 0.14);
  --rule-strong:  rgba(26, 24, 21, 0.32);
  --ink:          #1a1815;
  --ink-2:        #4a4640;
  --ink-3:        #7a7468;
  --ink-4:        #a39d8c;

  /* Globe stage — deep ink, only inverts inside the canvas */
  --stage:        #0d1219;
  --stage-2:      #161c27;
  --stage-rule:   rgba(245, 241, 232, 0.12);
  --stage-rule-2: rgba(245, 241, 232, 0.24);
  --stage-ink:    #e8e3d4;
  --stage-ink-2:  #a39d8c;
  --stage-ink-3:  #6f6a5e;

  /* Cartographer accents */
  --red:          #a8392c;   /* active conflict */
  --red-deep:     #7a2920;
  --red-soft:     rgba(168, 57, 44, 0.12);
  --sage:         #5a6b52;   /* resolved */
  --sage-soft:    rgba(90, 107, 82, 0.14);
  --ochre:        #c08a2e;

  --serif:  'Source Serif 4', 'Source Serif Pro', Georgia, serif;
  --sans:   'Inter Tight', -apple-system, system-ui, sans-serif;
  --mono:   'JetBrains Mono', ui-monospace, monospace;
}

/* === THEME: Atlas — antique cartographer, warm sepia stage ================== */
[data-theme="atlas"] {
  --paper: #efe6d0;
  --paper-2: #e4d8b8;
  --paper-3: #d8c89b;
  --rule: rgba(60, 40, 20, 0.18);
  --rule-strong: rgba(60, 40, 20, 0.40);
  --ink: #2a1f12;
  --ink-2: #5a4528;
  --ink-3: #8a7048;
  --ink-4: #b09a72;

  --stage: #1f1812;
  --stage-2: #2a2118;
  --stage-rule: rgba(232, 210, 160, 0.14);
  --stage-rule-2: rgba(232, 210, 160, 0.30);
  --stage-ink: #efe2c2;
  --stage-ink-2: #b09a72;
  --stage-ink-3: #7a6748;

  --red: #b54a2c;
  --red-deep: #7a2c18;
  --red-soft: rgba(181, 74, 44, 0.14);
  --sage: #6e6a3a;
  --sage-soft: rgba(110, 106, 58, 0.16);
  --ochre: #c8932a;
}

/* === THEME: Midnight — dark, editorial, low-key ============================== */
[data-theme="midnight"] {
  --paper: #161922;
  --paper-2: #1f2330;
  --paper-3: #2a2f3e;
  --rule: rgba(220, 220, 230, 0.10);
  --rule-strong: rgba(220, 220, 230, 0.24);
  --ink: #e8e6dc;
  --ink-2: #b0aea2;
  --ink-3: #807e72;
  --ink-4: #5a584e;

  --stage: #080a10;
  --stage-2: #0e1118;
  --stage-rule: rgba(232, 230, 220, 0.10);
  --stage-rule-2: rgba(232, 230, 220, 0.22);
  --stage-ink: #e8e6dc;
  --stage-ink-2: #807e72;
  --stage-ink-3: #4f4d44;

  --red: #d04a3a;
  --red-deep: #9a2e22;
  --red-soft: rgba(208, 74, 58, 0.18);
  --sage: #7a8c6e;
  --sage-soft: rgba(122, 140, 110, 0.18);
  --ochre: #d49a3e;
}
[data-theme="midnight"] body { background: var(--paper); }
[data-theme="midnight"] .rail-card { background: rgba(31, 35, 48, 0.92); }
[data-theme="midnight"] .ds-party { background: var(--paper-3); }
[data-theme="midnight"] .tweaks { background: var(--paper-2); }
[data-theme="midnight"] .tw-row select { background: var(--paper-3); color: var(--ink); }
[data-theme="midnight"] .rb-bar { background: var(--paper-3); }
[data-theme="midnight"] .rb-density-past .rb-bar { background: var(--ink-2); }
[data-theme="midnight"] .ds-intensity .seg { background: var(--paper-3); }

/* === THEME: Bone — pure, monochromatic, restrained =========================== */
[data-theme="bone"] {
  --paper: #f6f4ee;
  --paper-2: #ece8de;
  --paper-3: #ddd7c6;
  --rule: rgba(40, 38, 34, 0.12);
  --rule-strong: rgba(40, 38, 34, 0.30);
  --ink: #1c1a16;
  --ink-2: #4c4842;
  --ink-3: #82796d;
  --ink-4: #aea493;

  --stage: #1c1a16;
  --stage-2: #2a2620;
  --stage-rule: rgba(246, 244, 238, 0.12);
  --stage-rule-2: rgba(246, 244, 238, 0.26);
  --stage-ink: #f6f4ee;
  --stage-ink-2: #aea493;
  --stage-ink-3: #6e665a;

  --red: #4c4842;
  --red-deep: #1c1a16;
  --red-soft: rgba(76, 72, 66, 0.12);
  --sage: #82796d;
  --sage-soft: rgba(130, 121, 109, 0.14);
  --ochre: #82796d;
}

/* === THEME: Crimson — high-contrast, dramatic ================================ */
[data-theme="crimson"] {
  --paper: #faf6ef;
  --paper-2: #f0e8d8;
  --paper-3: #e4d8c0;
  --rule: rgba(40, 14, 14, 0.14);
  --rule-strong: rgba(40, 14, 14, 0.34);
  --ink: #2a0e0e;
  --ink-2: #5a2a26;
  --ink-3: #8a5a52;
  --ink-4: #b89484;

  --stage: #14080a;
  --stage-2: #1f0e10;
  --stage-rule: rgba(250, 230, 220, 0.12);
  --stage-rule-2: rgba(250, 230, 220, 0.28);
  --stage-ink: #faeae0;
  --stage-ink-2: #b89484;
  --stage-ink-3: #7a5a52;

  --red: #c8321a;
  --red-deep: #8a1d10;
  --red-soft: rgba(200, 50, 26, 0.14);
  --sage: #6e6a3a;
  --sage-soft: rgba(110, 106, 58, 0.14);
  --ochre: #d49a3e;
}

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
  font-feature-settings: "ss01", "ss02", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* === APP LAYOUT — masthead / two-pane / ribbon =============================== */
.app {
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height — adjusts for mobile browser chrome */
  display: grid;
  grid-template-rows: 64px 1fr 132px;
  grid-template-columns: 100%;
}

/* === MASTHEAD ================================================================ */
.masthead {
  display: grid;
  grid-template-columns: minmax(280px, 340px) auto 1fr minmax(200px, 300px) auto;
  align-items: center;
  gap: 24px;
  padding: 0 28px 0 32px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.mh-brand { display: flex; align-items: baseline; gap: 14px; }
.mh-mark {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1;
  color: var(--ink);
}
.mh-mark .amp { color: var(--red); font-style: italic; font-weight: 400; padding: 0 1px; }
.mh-sub {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}
.mh-credit {
  font-family: var(--serif);
  font-style: italic;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.005em;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1px;
  transition: color 160ms ease, border-color 160ms ease;
  align-self: baseline;
}
.mh-credit::before {
  content: '·';
  display: inline-block;
  margin-right: 8px;
  color: var(--rule-strong);
  font-style: normal;
}
.mh-credit:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.mh-spine {
  display: flex; justify-content: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-2);
  letter-spacing: 0.005em;
}
.mh-meta {
  display: flex; align-items: center; gap: 18px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}
.mh-meta .num { color: var(--ink); font-weight: 500; }
.mh-meta .sep { width: 1px; height: 14px; background: var(--rule); }

/* === LENS DROPDOWN ============================================================ */
.lens-wrap { position: relative; }
.lens-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 70%, var(--ink) 4%);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background 160ms ease;
}
.lens-btn:hover { background: color-mix(in srgb, var(--paper) 50%, var(--ink) 8%); }
.lens-btn.open { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.lens-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.lens-dot.myth { background: color-mix(in srgb, var(--accent) 60%, gold 40%); }
.lens-label { letter-spacing: 0.08em; }
.lens-sub { opacity: 0.6; font-weight: 500; letter-spacing: 0.04em; text-transform: none; font-size: 10.5px; }
.lens-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.28);
  padding: 6px 0;
  z-index: 30;
  font-family: var(--sans);
  max-height: 70vh;
  overflow-y: auto;
}
.lm-section {
  padding: 10px 14px 4px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3, var(--ink));
  opacity: 0.55;
}
.lm-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink);
  text-align: left;
}
.lm-item:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.lm-item.on { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.lm-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.lm-dot.myth { background: color-mix(in srgb, var(--accent) 55%, gold 45%); }
.lm-name { font-weight: 600; flex: 1; }
.lm-sub { opacity: 0.55; font-size: 11px; }
.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px;
  background: color-mix(in srgb, var(--paper) 60%, var(--ink) 4%);
}
.mt-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border: 0;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2, var(--ink));
  opacity: 0.62;
  transition: background 160ms ease, color 160ms ease, opacity 160ms ease;
  white-space: nowrap;
}
.mt-btn:hover { opacity: 0.95; }
.mt-btn .mt-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}
.mt-btn.on {
  background: var(--ink);
  color: var(--paper);
  opacity: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

/* === SEARCH ================================================================== */
.search-wrap { position: relative; }
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  background: var(--paper-2, var(--paper));
  border-radius: 2px;
  transition: border-color 0.12s, background 0.12s;
}
.search-bar:focus-within {
  border-color: var(--rule-strong, var(--ink-3));
  background: var(--paper);
}
.search-ico {
  color: var(--ink-3);
  flex-shrink: 0;
  stroke-width: 2;
}
.search-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.005em;
  color: var(--ink);
}
.search-bar input::placeholder {
  color: var(--ink-3);
  font-style: italic;
}
.search-clear {
  border: none;
  background: none;
  color: var(--ink-3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  font-family: var(--serif);
}
.search-clear:hover { color: var(--ink); }

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 420px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  z-index: 100;
  border-radius: 2px;
}
.sr-empty {
  padding: 14px 14px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-3);
}
.sr-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background 0.08s;
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: var(--paper-2, rgba(0,0,0,0.03)); }
.sr-item.active { background: var(--paper-2, rgba(0,0,0,0.04)); }
.sr-name {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.25;
  margin-bottom: 3px;
}
.sr-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.sr-years {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-2, var(--ink-3));
}
.sr-region { color: var(--ink-3); }
.sr-status {
  margin-left: auto;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px solid currentColor;
}
.sr-status.ongoing { color: var(--red, #a8392c); }
.sr-status.resolved { color: var(--ink-3); }

/* === MAIN — single full-bleed stage ========================================== */
.main {
  position: relative;
  background: var(--stage);
  overflow: hidden;
  min-height: 0;
}

/* Cesium widget fills */
.cesium-widget,
.cesium-widget canvas { width: 100% !important; height: 100% !important; display: block; }
.cesium-widget-credits { display: none !important; }
.globe-wrap { position: absolute; inset: 0; }

/* === LOADING ================================================================= */
.globe-loading {
  position: absolute; inset: 0; z-index: 20;
  background: var(--stage);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
}
.loading-ring {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--stage-rule-2);
  border-top-color: var(--paper);
  animation: spin 1.1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-label {
  font-family: var(--sans); font-size: 11px;
  letter-spacing: 0.22em; color: var(--stage-ink-2);
  text-transform: uppercase;
}

/* === LEFT RAIL — masthead column over the stage ============================== */
.rail {
  position: absolute;
  top: 22px; left: 22px; bottom: 22px;
  width: 360px;
  z-index: 6;
  display: flex; flex-direction: column;
  pointer-events: none;
}
.rail > * { pointer-events: auto; }

.rail-card {
  background: rgba(243, 238, 226, 0.97);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(26, 24, 21, 0.08);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18), 0 18px 40px rgba(0,0,0,0.35);
}

/* ── Year card (always visible) ─────────────────────────────────────────────── */
.rail-year {
  padding: 18px 22px 16px;
}
.ry-eyebrow {
  font-family: var(--sans);
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3);
}
.ry-year {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 64px;
  line-height: 0.92;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 8px 0 4px;
  font-feature-settings: "lnum";
}
.ry-year .era {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  color: var(--ink-3);
  letter-spacing: 0;
  margin-left: 6px;
  vertical-align: 0.32em;
}

/* === YearInput — click-to-type year editor ================================ */
/* Display mode: inherits surrounding type so the affordance is just a subtle
   underline on hover/focus. The element is a role="button" span. */
.yi-display {
  display: inline-block;
  cursor: text;
  border-radius: 3px;
  padding: 0 2px;
  margin: 0 -2px;
  outline: none;
  transition: background 0.12s, box-shadow 0.12s;
}
.yi-display:hover {
  background: color-mix(in srgb, currentColor 8%, transparent);
}
.yi-display:focus-visible {
  background: color-mix(in srgb, currentColor 10%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, currentColor 30%, transparent);
}
/* Subtle blinking caret hint at the right edge of the year on hover */
.yi-display:hover::after {
  content: '';
  display: inline-block;
  width: 1px; height: 0.65em;
  background: currentColor;
  margin-left: 3px;
  vertical-align: -0.05em;
  animation: yiCaret 1s steps(2, end) infinite;
  opacity: 0.55;
}
@keyframes yiCaret { 50% { opacity: 0; } }

/* Input mode: inherits font from parent so size/family match the static
   display exactly. We override only what's needed for an editable field. */
.yi-input {
  font: inherit;
  color: inherit;
  background: color-mix(in srgb, currentColor 6%, transparent);
  border: 0;
  border-bottom: 1.5px solid currentColor;
  border-radius: 3px 3px 0 0;
  padding: 0 4px;
  margin: 0 -4px;
  outline: none;
  letter-spacing: inherit;
  font-feature-settings: inherit;
  width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
.yi-input::placeholder {
  color: var(--ink-3);
  font-style: italic;
  font-weight: 400;
  opacity: 0.6;
  letter-spacing: 0;
}
/* Desktop rail-year specific: keep large numeric feel, prevent line wrap */
.ry-year-input {
  font-size: inherit;
  line-height: 0.92;
  max-width: 6.5ch;
}
.ry-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}
.ry-cell .ry-k {
  font-family: var(--sans);
  font-size: 9.5px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-3);
}
.ry-cell .ry-v {
  font-family: var(--serif);
  font-size: 22px; font-weight: 500;
  color: var(--ink);
  margin-top: 2px;
  letter-spacing: -0.01em;
  font-feature-settings: "lnum";
}
.ry-cell .ry-v .unit {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0;
  margin-left: 3px;
}

/* ── Dossier card (when conflict selected) ──────────────────────────────────── */
.dossier {
  margin-top: 14px;
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.ds-head {
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--rule);
}
.ds-kicker {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.ds-status {
  font-family: var(--sans);
  font-size: 9.5px; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
}
.ds-status.active { color: var(--red); }
.ds-status.ended  { color: var(--sage); }
.ds-status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}
.ds-status.active .dot { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.85); }
}
.ds-region {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  margin-left: auto;
}
.ds-close {
  background: transparent; border: none;
  color: var(--ink-3); cursor: pointer;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  font-size: 14px; line-height: 1;
  margin-right: -6px;
  border-radius: 2px;
}
.ds-close:hover { color: var(--ink); background: var(--paper-3); }

.ds-name {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.08;
  color: var(--ink);
  margin: 0;
  text-wrap: pretty;
}
.ds-dates {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-3);
  margin-top: 6px;
  font-feature-settings: "lnum";
}

.ds-body {
  padding: 16px 22px 20px;
  overflow-y: auto;
  flex: 1;
}
.ds-summary {
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0 0 18px;
  text-wrap: pretty;
}
.ds-summary::first-letter {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 600;
  float: left;
  line-height: 0.9;
  margin: 4px 6px 0 0;
  color: var(--ink);
}
.ds-fields {
  display: flex; flex-direction: column;
  gap: 14px;
}
.ds-field { display: flex; flex-direction: column; gap: 4px; }
.ds-fk {
  font-family: var(--sans);
  font-size: 9.5px; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-3);
}
.ds-fv {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  line-height: 1.45;
}
.ds-fv.numeric {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.005em;
  font-feature-settings: "lnum";
}
.ds-parties {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.ds-party {
  font-family: var(--sans);
  font-size: 11.5px;
  padding: 3px 9px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink-2);
}
.ds-intensity {
  display: inline-flex; gap: 3px;
  align-items: center;
}
.ds-intensity .seg {
  width: 22px; height: 5px;
  background: var(--paper-3);
}
.ds-intensity .seg.on { background: var(--red); }
.ds-intensity.ended .seg.on { background: var(--sage); }
.ds-intensity .ilabel {
  margin-left: 8px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

/* === EMPTY-STATE prompt under year card ===================================== */
.rail-prompt {
  margin-top: 14px;
  padding: 18px 22px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  text-wrap: pretty;
}
.rail-prompt strong {
  font-style: normal;
  font-weight: 600;
  color: var(--ink);
}
.rail-prompt .legend {
  margin-top: 14px;
  display: flex; flex-direction: column; gap: 6px;
  font-family: var(--sans);
  font-style: normal;
  font-size: 11.5px;
  color: var(--ink-2);
}
.rail-prompt .legend-row { display: flex; align-items: center; gap: 10px; }
.rail-prompt .legend-row .swatch {
  width: 22px; height: 3px;
}

/* === GLOBE CONTROLS ========================================================= */
.globe-controls {
  position: absolute;
  bottom: 22px; right: 22px;
  z-index: 6;
  display: flex; align-items: center; gap: 10px;
}
.gc-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: rgba(13, 18, 25, 0.78);
  border: 1px solid var(--stage-rule-2);
  color: var(--stage-ink-2);
  font-family: var(--sans); font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(10px);
  border-radius: 2px;
  transition: color 0.15s, border-color 0.15s;
}
.gc-btn:hover { color: var(--stage-ink); border-color: rgba(245, 241, 232, 0.4); }
.gc-btn.on    { color: var(--paper); border-color: rgba(245, 241, 232, 0.5); }
.gc-btn .gc-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--stage-ink-3);
}
.gc-btn.on .gc-dot { background: var(--paper); animation: pulse 1.6s ease-in-out infinite; }

/* North-arrow compass mark — bottom-left */
.compass {
  position: absolute;
  bottom: 24px; left: 22px;
  z-index: 5;
  display: flex; align-items: center; gap: 10px;
  font-family: var(--sans); font-size: 10px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--stage-ink-3);
  pointer-events: none;
}
.compass svg { display: block; }

/* Hide rail when on small screens (tablet) */
@media (max-width: 880px) and (min-width: 821px) {
  .rail { left: 12px; right: 12px; width: auto; top: 12px; }
  .compass { display: none; }
}

/* === PANEL TOGGLE BUTTONS =================================================== */
.mh-burger {
  display: none;
  appearance: none;
  width: 36px; height: 36px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  align-items: center; justify-content: center;
  padding: 0;
}
.mh-burger.open { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.panel-toggle {
  appearance: none;
  position: absolute;
  width: 28px; height: 44px;
  background: var(--paper);
  border: 1px solid rgba(26, 24, 21, 0.12);
  color: var(--ink);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 8;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  border-radius: 0 4px 4px 0;
  transition: background 0.15s;
}
.panel-toggle:hover { background: color-mix(in srgb, var(--paper) 88%, var(--ink) 12%); }
.rail-toggle {
  top: 30px;
  right: -28px;
}
.rail.collapsed .rail-toggle {
  /* When collapsed, button stays visible at the edge */
}
.tl-toggle {
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 22px;
  border-radius: 4px 4px 0 0;
  border-bottom: none;
}

/* === RAIL COLLAPSED STATE =================================================== */
.rail {
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
}
.rail.collapsed {
  transform: translateX(calc(-100% - 22px));
}
.rail.collapsed .rail-toggle {
  transform: translateX(28px);
}

/* === RIBBON COLLAPSED STATE ================================================= */
.app.tl-closed { grid-template-rows: 64px 1fr 14px; }
.ribbon { transition: padding 0.28s ease, height 0.28s ease; position: relative; }
.ribbon.collapsed {
  padding: 0;
  height: 14px;
  overflow: hidden;
}
.ribbon.collapsed > *:not(.panel-toggle) { display: none; }
.ribbon.collapsed .tl-toggle {
  top: -10px;
}

/* === MOBILE DRAWER ========================================================== */
.mobile-drawer {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex; align-items: flex-start;
  justify-content: stretch;
  animation: fadein 0.16s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.md-sheet {
  margin: 64px 0 0;
  width: 100%;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: 16px 18px 22px;
  display: flex; flex-direction: column;
  gap: 12px;
  animation: slidedown 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slidedown { from { transform: translateY(-16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.md-row {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 13px;
}
.md-row:last-of-type { border-bottom: none; }
.md-row.md-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  padding: 12px 4px 14px;
}
.md-k {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.md-v {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--ink);
  font-weight: 500;
}
.md-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.md-value {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink);
}
.md-action {
  appearance: none;
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 12px 4px;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  letter-spacing: 0.04em;
}
.md-action:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.md-action .md-arrow {
  font-size: 18px;
  color: var(--ink-3);
}

/* ===== MOBILE LAYOUT (< 820px) ============================================== */
@media (max-width: 820px) {
  .app {
    grid-template-rows: 56px 1fr auto;
    /* Account for iOS safe areas */
    padding-bottom: env(safe-area-inset-bottom);
  }
  /* Tap targets must be ≥ 44px per Apple HIG */
  .mh-burger, .panel-toggle, .lens-btn, .gc-btn, .lm-item, .md-action {
    min-height: 38px;
  }
  .mh-burger { width: 38px; height: 38px; }
  .rail-toggle, .tl-toggle {
    width: 80px; /* easier to tap */
  }
  /* Masthead — compact, only brand + lens + burger */
  .masthead {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    padding: 0 10px;
  }
  .mh-brand { gap: 0; flex-direction: column; align-items: flex-start; min-width: 0; }
  .mh-mark {
    font-size: 16px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: visible;
    color: var(--ink);
  }
  .mh-sub { display: none; }
  .mh-credit { display: none; }
  .mh-spine, .mh-meta, .search-wrap { display: none; }
  .mh-burger { display: inline-flex; }

  .lens-wrap { justify-self: end; min-width: 0; }
  .lens-btn { padding: 7px 10px; font-size: 10px; gap: 5px; max-width: 100%; }
  .lens-sub { display: none; }
  .lens-label { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lens-menu {
    position: fixed;
    top: 64px;
    left: 12px;
    right: 12px;
    min-width: 0;
    max-height: 60vh;
  }

  /* Rail becomes a bottom sheet — sits ABOVE the timeline */
  .rail {
    position: fixed;
    top: auto; left: 0; right: 0;
    bottom: calc(96px + env(safe-area-inset-bottom));
    width: 100%;
    max-height: 60vh;
    padding: 0;
    flex-direction: column;
    z-index: 10;
    pointer-events: none;
    transition: max-height 0.3s ease, bottom 0.3s ease;
  }
  .app.tl-closed .rail { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .rail > * { pointer-events: auto; }
  .rail.collapsed {
    max-height: 0;
    overflow: visible; /* keep toggle pull-tab visible above the collapsed rail */
  }
  .rail.collapsed .rail-card { display: none; }
  /* Move rail-toggle to top edge of sheet on mobile — visible as pull-tab */
  .rail-toggle {
    top: -22px; right: auto; left: 50%;
    transform: translateX(-50%);
    width: 64px; height: 22px;
    border-radius: 6px 6px 0 0;
    border-bottom: none;
    background: var(--paper);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
  }
  .rail.collapsed .rail-toggle {
    transform: translateX(-50%);
  }
  .rail-card {
    border-radius: 0;
    box-shadow: 0 -12px 30px rgba(0,0,0,0.4);
    max-height: calc(60vh - 22px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
  .rail.collapsed .rail-card { /* card still in DOM but hidden by translate */ }
  .rail-year { padding: 12px 16px 10px; }
  .ry-year { font-size: 36px; }
  .ry-year .era { font-size: 15px; }
  .ry-meta { grid-template-columns: 1fr 1fr 1fr; gap: 8px 12px; padding-top: 10px; margin-top: 10px; }
  .ry-cell .ry-v { font-size: 15px; }

  .dossier { margin-top: 0; max-height: calc(70vh - 130px); }
  .rail-prompt { margin-top: 0; padding: 14px 16px; font-size: 13px; }
  .ds-head { padding: 12px 16px 8px; }
  .ds-name { font-size: 20px; line-height: 1.15; }
  .ds-body { padding: 0 16px 18px; }

  /* Compass — already hidden via earlier media query; ensure */
  .compass { display: none; }

  /* Globe controls — top-right on mobile so they don't crowd the rail at the bottom */
  .globe-controls { bottom: auto; top: 12px; right: 12px; }
  .gc-btn { padding: 7px 10px; font-size: 9.5px; letter-spacing: 0.1em; }

  /* Timeline — label ABOVE, full-width track BELOW */
  .ribbon {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    grid-template-rows: auto !important;
    gap: 6px !important;
    padding: 22px 14px 14px !important;
    width: 100% !important;
    box-sizing: border-box;
  }
  .rb-eras { display: none !important; }
  .rb-left {
    display: flex !important;
    flex-direction: row !important;
    align-items: baseline !important;
    justify-content: center !important;
    gap: 12px !important;
    padding: 0 4px 2px !important;
    width: 100% !important;
    order: 0 !important;
  }
  .rb-left .rb-eyebrow { font-size: 9px; letter-spacing: 0.18em; }
  .rb-left .rb-zoom    { font-size: 11.5px; }
  .rb-left .rb-hint    { display: none !important; }
  .rb-track-wrap {
    height: 64px !important;
    width: 100% !important;
    padding-right: 36px !important;
    touch-action: none;
    order: 1 !important;
  }
  .rb-tick { font-size: 9.5px; }
  .rb-ticks { height: 18px; }
  /* Larger grip on touch */
  .rb-thumb-grip { width: 14px; height: 22px; }
  .app.tl-open   { grid-template-rows: 56px 1fr 116px; }
  .app.tl-closed { grid-template-rows: 56px 1fr 16px; }
  .tl-toggle { top: 0; }
  .ribbon.collapsed { height: 16px; }

  /* Search modal-style on mobile when open via drawer */
  .search-wrap.mobile-open { display: block; position: fixed; left: 12px; right: 12px; top: 64px; z-index: 200; }

  /* Lens dropdown items larger touch targets */
  .lm-item { padding: 12px 14px; font-size: 13px; }

  /* Panel toggle on the rail when collapsed should be visible peeking */
  .rail.collapsed .rail-card { /* keep visible — translation handles offset */ }
}

/* ===== TINY MOBILE (< 480px) extra tightening =============================== */
@media (max-width: 480px) {
  .masthead { padding: 0 10px; gap: 6px; }
  .mh-mark { font-size: 14px; line-height: 1.05; }
  .lens-btn { padding: 6px 9px; font-size: 9.5px; }
  .lens-label { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ry-year { font-size: 32px; }
  .ry-year .era { font-size: 14px; }
  .ry-meta { grid-template-columns: 1fr 1fr; }
  .ry-meta > :nth-child(3) { grid-column: span 2; }
}

/* === RIBBON (timeline) ====================================================== */
.ribbon {
  background: var(--paper);
  border-top: 1px solid var(--rule);
  padding: 14px 28px 16px;
  display: grid;
  grid-template-columns: 240px 1fr 360px;
  gap: 28px;
  align-items: stretch;
}

.rb-left {
  display: flex; flex-direction: column;
  justify-content: center;
  gap: 4px;
}

/* Hold-to-scrub playback buttons (◀ ▶) — sit in the rb-left column on
   desktop, inline next to the labels on mobile. Press and hold to advance. */
.rb-pcontrols {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.rb-step {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  padding: 0;
  background: var(--paper);
  color: var(--ink-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.06s;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.rb-step:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}
.rb-step:active,
.rb-step.active {
  background: var(--red);
  color: var(--paper);
  border-color: var(--red);
  transform: scale(0.96);
}
.rb-step.active svg {
  animation: rbStepPulse 0.7s ease-in-out infinite;
}
@keyframes rbStepPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
.rb-eyebrow {
  font-family: var(--sans);
  font-size: 9.5px; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3);
}
.rb-zoom {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-2);
  font-feature-settings: "lnum";
}
.rb-hint {
  font-family: var(--sans);
  font-size: 10.5px;
  color: var(--ink-4);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.rb-track-wrap {
  position: relative;
  height: 96px;
}
.rb-track {
  position: absolute;
  inset: 0 0 26px 0;
  cursor: ew-resize;
  touch-action: none; /* we drive pointer events ourselves */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.rb-density {
  position: absolute; inset: 0;
  display: flex; align-items: flex-end;
  gap: 1px;
  pointer-events: none;
}
.rb-density-past {
  will-change: clip-path;
}
.rb-bar {
  flex: 1; min-width: 1px;
  background: var(--paper-3);
}
.rb-density-past .rb-bar { background: var(--ink-2); opacity: 0.78; }

/* baseline rule */
.rb-track::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0;
  border-bottom: 1px solid var(--rule-strong);
}

/* Native range — kept for keyboard accessibility only; pointer interaction
   is driven by our custom track handlers so the entire track is a hit zone. */
.rb-range {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  appearance: none; background: transparent;
  margin: 0;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
}
.rb-range::-webkit-slider-runnable-track { background: transparent; height: 100%; }
.rb-range::-moz-range-track { background: transparent; height: 100%; }
.rb-range::-webkit-slider-thumb {
  appearance: none;
  width: 2px; height: 100%;
  background: var(--red);
  border-radius: 0;
  margin-top: 0;
}
.rb-range::-moz-range-thumb {
  width: 2px; height: 100%;
  background: var(--red);
  border: none; border-radius: 0;
}

/* Custom thumb — vertical cursor line + grip handle for visibility/grab affordance.
   pointer-events:none — the parent .rb-track handles all input. */
.rb-thumb {
  position: absolute;
  top: 0; bottom: 0;
  width: 0;
  transform: translateX(-1px);
  z-index: 3;
  pointer-events: none;
}
.rb-thumb-line {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 2px;
  background: var(--red);
  box-shadow: 0 0 0 0.5px rgba(168, 57, 44, 0.3),
              0 0 6px rgba(168, 57, 44, 0.45);
}
.rb-thumb-grip {
  position: absolute;
  top: 50%; left: 1px;
  transform: translate(-50%, -50%);
  width: 12px; height: 18px;
  background: var(--red);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35),
              inset 0 0 0 0.5px rgba(0,0,0,0.2);
}

.rb-ticks {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 22px;
  pointer-events: none;
}
.rb-tick {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px solid var(--rule-strong);
  padding-left: 5px;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  font-feature-settings: "lnum";
  white-space: nowrap;
  user-select: none;
}

/* Era buttons (right column) */
.rb-eras {
  display: flex; align-items: center;
  flex-wrap: wrap; gap: 4px;
  align-content: center;
  justify-content: flex-end;
}
.rb-era {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 2px;
  letter-spacing: 0.01em;
  transition: background 0.12s, color 0.12s;
}
.rb-era:hover { background: var(--paper-2); color: var(--ink); }
.rb-era.now { color: var(--red); font-weight: 600; }
.rb-era.now:hover { background: var(--red-soft); }

/* === THEME PANEL ============================================================ */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--rule-strong); background: var(--paper-2); }
.theme-toggle .tt-swatches {
  display: inline-flex;
  gap: 0;
}
.theme-toggle .tt-swatches span {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1px solid var(--rule);
  margin-left: -3px;
}
.theme-toggle .tt-swatches span:first-child { margin-left: 0; }

.theme-panel {
  position: fixed;
  top: 60px;
  right: 22px;
  z-index: 40;
  width: 296px;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  padding: 16px 18px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.10), 0 24px 60px rgba(0,0,0,0.28);
  animation: tpIn 0.16s ease-out;
}
@keyframes tpIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tp-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--sans);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 14px;
}
.tp-head button {
  background: transparent; border: none; cursor: pointer;
  color: var(--ink-3); font-size: 14px; line-height: 1;
}
.tp-head button:hover { color: var(--ink); }

.tp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.tp-card {
  position: relative;
  padding: 0;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s, transform 0.12s;
}
.tp-card:hover { border-color: var(--rule-strong); }
.tp-card.on {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}
.tp-preview {
  height: 56px;
  display: flex;
  align-items: stretch;
}
.tp-preview .pl, .tp-preview .pr {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  font-weight: 500;
}
.tp-preview .arc {
  width: 22px; height: 1.5px;
  border-radius: 1px;
}
.tp-preview .dot {
  width: 4px; height: 4px; border-radius: 50%;
}
.tp-preview .stage-mini {
  display: flex; align-items: center; justify-content: center;
  gap: 4px;
}
.tp-name {
  padding: 8px 12px 9px;
  border-top: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
}
.tp-name .nm {
  font-family: var(--sans);
  font-size: 12px; font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.tp-name .sub {
  font-family: var(--sans);
  font-size: 9.5px;
  color: var(--ink-3);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tp-toggles {
  border-top: 1px solid var(--rule);
  padding-top: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.tp-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink);
}
.tp-toggle input[type="checkbox"] { accent-color: var(--red); }
.tweaks {
  position: fixed;
  right: 22px;
  bottom: 158px;
  z-index: 30;
  width: 280px;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  padding: 14px 18px 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
}
.tw-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--sans);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 12px;
}
.tw-head button {
  background: transparent; border: none;
  color: var(--ink-3); cursor: pointer;
  font-size: 14px; line-height: 1;
}
.tw-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0;
  font-family: var(--sans); font-size: 13px;
  color: var(--ink);
}
.tw-row select {
  font-family: var(--sans); font-size: 12px;
  background: var(--paper-2);
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  padding: 4px 6px;
  border-radius: 2px;
}
.tw-row input[type="checkbox"] { accent-color: var(--red); }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(26,24,21,0.18); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(26,24,21,0.32); }
