/* ===== Deep Histomap — dark cosmic ===== */
:root {
  --bg: #05060e;
  --ink: #e8ebf5;
  --ink-dim: #9aa3bf;
  --ink-faint: #5a6280;
  --line: rgba(140, 155, 200, 0.14);
  --panel-bg: rgba(13, 16, 30, 0.92);
  --card-bg: rgba(18, 22, 40, 0.97);
  --accent: #7fb4ff;
  --glow-tech: #46d4ff;
  --glow-rel: #b78aff;
  --glow-person: #ffd27a;
  --glow-event: #ff9d5c;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --topbar-h: 52px;
  --tabs-h: 54px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font-family: inherit; cursor: pointer; }

/* ---- layers ---- */
#stars { position: fixed; inset: 0; z-index: 0; }
#map {
  position: fixed; inset: 0; z-index: 1;
  width: 100vw; height: 100vh;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
#scrubber { user-select: none; -webkit-user-select: none; }
#map.dragging { cursor: grabbing; }

/* ---- top bar ---- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: linear-gradient(to bottom, rgba(5,6,14,0.88), rgba(5,6,14,0.55) 75%, transparent);
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
#brand { display: flex; align-items: baseline; gap: 10px; flex-shrink: 0; }
#brand h1 {
  font-family: var(--serif);
  font-size: 19px; font-weight: 500; letter-spacing: 0.06em;
  background: linear-gradient(100deg, #cfe0ff, #8fb8ff 55%, #c9a6ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap;
}
#progress-counter { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }

#searchbox { position: relative; flex: 1; max-width: 380px; }
#search {
  width: 100%; padding: 7px 12px;
  background: rgba(20, 25, 48, 0.75);
  border: 1px solid rgba(130, 150, 210, 0.22);
  border-radius: 17px;
  color: var(--ink); font-size: 13px; outline: none;
  transition: border-color 0.2s, background 0.2s;
}
#search:focus { border-color: rgba(140, 170, 255, 0.55); background: rgba(22, 28, 55, 0.92); }
#search::placeholder { color: var(--ink-faint); }
#search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--card-bg);
  border: 1px solid rgba(130, 150, 210, 0.25);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  max-height: 60vh; overflow-y: auto;
}
.search-item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 12px; cursor: pointer; font-size: 13px;
}
.search-item .si-date { margin-left: auto; color: var(--ink-faint); font-size: 11px; white-space: nowrap; }
.search-item .si-cat { font-size: 10px; padding: 1px 6px; border-radius: 8px; flex-shrink: 0; }
.search-item:hover, .search-item.active { background: rgba(110, 140, 230, 0.16); }

#topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
#year-pill {
  font-size: 13px; font-variant-numeric: tabular-nums;
  color: #cdd8f5;
  padding: 5px 13px;
  background: rgba(20, 25, 48, 0.75);
  border: 1px solid rgba(130, 150, 210, 0.22);
  border-radius: 15px;
  min-width: 96px; text-align: center; white-space: nowrap;
}
#zoom-controls { display: flex; gap: 4px; }
#zoom-controls button, #about-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(20, 25, 48, 0.75);
  border: 1px solid rgba(130, 150, 210, 0.22);
  color: var(--ink-dim); font-size: 16px; line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
#zoom-controls button:hover, #about-btn:hover { color: #fff; border-color: rgba(140,170,255,0.5); }

/* ---- scrubber ---- */
#scrubber {
  position: fixed; left: 0; top: var(--topbar-h);
  width: 62px; height: calc(100vh - var(--topbar-h) - var(--tabs-h));
  z-index: 10;
  touch-action: none;
  cursor: pointer;
}

/* ---- tabs ---- */
#tabs {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--tabs-h);
  z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  background: linear-gradient(to top, rgba(5,6,14,0.92), rgba(5,6,14,0.6) 75%, transparent);
}
#tab-group { display: flex; gap: 4px; }
.tab {
  --tc: #9db8ff;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  background: transparent; border: 1px solid transparent;
  border-radius: 17px;
  color: var(--ink-dim); font-size: 13px;
  transition: all 0.2s;
  white-space: nowrap;
}
.tab::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--tc); opacity: 0.55; flex-shrink: 0;
  transition: opacity 0.2s, box-shadow 0.2s;
}
.tab[data-tab="civilizations"] { --tc: #e8b45c; }
.tab[data-tab="technology"] { --tc: #46d4ff; }
.tab[data-tab="religions"] { --tc: #b78aff; }
.tab[data-tab="people"] { --tc: #ffb36b; }
.tab:hover { color: var(--ink); }
.tab:hover::before { opacity: 0.9; }
.tab.active {
  color: #fff;
  background: color-mix(in srgb, var(--tc) 14%, transparent);
  border-color: color-mix(in srgb, var(--tc) 45%, transparent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--tc) 22%, transparent);
}
.tab.active::before { opacity: 1; box-shadow: 0 0 8px var(--tc); }
#tab-tools { display: flex; gap: 6px; }
#tab-tools button {
  padding: 7px 13px;
  background: rgba(20, 25, 48, 0.75);
  border: 1px solid rgba(130, 150, 210, 0.22);
  border-radius: 15px;
  color: var(--ink-dim); font-size: 13px;
  transition: color 0.15s, border-color 0.15s;
}
#tab-tools button:hover { color: #fff; border-color: rgba(140,170,255,0.5); }

/* ---- map svg elements ---- */
.era-band { fill: rgba(255,255,255,0.012); }
.era-band.alt { fill: rgba(120,140,220,0.028); }
.era-line { stroke: rgba(150, 165, 220, 0.18); stroke-width: 1; stroke-dasharray: 2 6; }
.era-label {
  fill: rgba(160, 175, 225, 0.35);
  font-family: var(--serif);
  letter-spacing: 0.35em; text-transform: uppercase;
  text-anchor: middle;
  pointer-events: none;
}
.grid-line { stroke: var(--line); stroke-width: 1; }
.grid-label {
  fill: var(--ink-faint); font-size: 10px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.stream { opacity: 0.92; transition: opacity 0.4s, filter 0.25s; cursor: pointer; }
.stream:hover { opacity: 1; filter: brightness(1.3) saturate(1.25); }
.stream.bg { opacity: 0.15; pointer-events: none; filter: none; }
.stream.dim { opacity: 0.42; }
.stream.dim:hover { opacity: 1; }
.stream-label.dim { opacity: 0.78; }
.stream.selected { opacity: 1; filter: brightness(1.35) saturate(1.3); }
.stream-label {
  fill: rgba(255,255,255,0.92);
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  text-anchor: middle; cursor: pointer;
  paint-order: stroke; stroke: rgba(0,0,0,0.55); stroke-width: 2.5px;
}
.stream-label.bg { opacity: 0.25; pointer-events: none; }

.marker { cursor: pointer; }
.marker .m-label {
  font-size: 11px; fill: #ccd6f0;
  paint-order: stroke; stroke: rgba(5,6,14,0.8); stroke-width: 2.5px;
  cursor: pointer;
}
.marker.visited .m-label { fill: #8d97b8; }
.marker.visited .m-core { opacity: 0.75; }
.marker .m-ring { fill: none; stroke-width: 1.2; opacity: 0; }
.marker.selected .m-ring { opacity: 0.9; }
.marker .m-check { font-size: 8px; fill: #7fd9a8; opacity: 0.9; pointer-events: none; }

.cluster { cursor: pointer; }
.cluster circle { fill: rgba(90, 105, 160, 0.25); stroke: rgba(140, 160, 230, 0.4); stroke-width: 1; }
.cluster text {
  fill: #aab6dd; font-size: 10px; text-anchor: middle;
  pointer-events: none;
}
.cluster:hover circle { fill: rgba(110, 130, 200, 0.4); }

.thread { fill: none; stroke-width: 1.4; opacity: 0.75; pointer-events: none; }
.thread-dot { cursor: pointer; }
.thread-label {
  font-size: 11px; font-weight: 600; cursor: pointer;
  paint-order: stroke; stroke: rgba(5,6,14,0.85); stroke-width: 2.5px;
}
.thread-label:hover { fill: #fff !important; }

.pop-line { fill: none; stroke: rgba(127, 217, 168, 0.55); stroke-width: 1.6; pointer-events: none; }
.pop-label { fill: rgba(127, 217, 168, 0.75); font-size: 9.5px; text-anchor: end; pointer-events: none; }

/* scrubber internals */
.scrub-track { fill: rgba(10, 13, 26, 0.72); stroke: rgba(130, 150, 210, 0.16); stroke-width: 1; }
.scrub-window { fill: rgba(127, 180, 255, 0.16); stroke: rgba(127, 180, 255, 0.5); stroke-width: 1; cursor: grab; }
.scrub-tick { stroke: rgba(150, 165, 215, 0.35); }
.scrub-tick-label { fill: var(--ink-dim); font-size: 8.5px; font-variant-numeric: tabular-nums; }
.scrub-era-label {
  fill: rgba(150, 165, 215, 0.55); font-size: 8px;
  letter-spacing: 0.12em; text-transform: uppercase; text-anchor: middle;
}
.scrub-center { stroke: #ffd27a; stroke-width: 1; opacity: 0.7; }

/* ---- panel ---- */
#panel {
  position: fixed; top: var(--topbar-h); right: 0; bottom: var(--tabs-h);
  width: min(400px, 92vw);
  z-index: 30;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  border-left: 1px solid rgba(130, 150, 210, 0.2);
  transform: translateX(105%);
  transition: transform 0.34s cubic-bezier(0.22, 0.9, 0.3, 1);
  display: flex; flex-direction: column;
}
#panel.open { transform: translateX(0); }
#panel-close {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(10, 13, 26, 0.7); border: 1px solid rgba(130,150,210,0.25);
  color: var(--ink-dim); font-size: 17px;
}
#panel-close:hover { color: #fff; }
#panel-scroll { overflow-y: auto; padding: 0 0 24px; height: 100%; }
#panel-image {
  width: 100%; height: 200px;
  background-size: cover; background-position: center 25%;
  position: relative;
  touch-action: pan-y;
  transition: background-image 0.15s;
}
#panel-image::after {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(to bottom, transparent 40%, var(--panel-bg));
  pointer-events: none;
}
.img-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(8, 10, 22, 0.62); border: 1px solid rgba(150, 165, 220, 0.3);
  color: #dde4f5; font-size: 19px; line-height: 1;
  opacity: 0.65; transition: opacity 0.15s, background 0.15s;
}
.img-nav:hover { opacity: 1; background: rgba(8, 10, 22, 0.85); }
#img-prev { left: 10px; }
#img-next { right: 10px; }
#img-count {
  position: absolute; left: 12px; bottom: 12px; z-index: 2;
  font-size: 10.5px; color: #dde4f5; font-variant-numeric: tabular-nums;
  background: rgba(8, 10, 22, 0.62); border-radius: 9px; padding: 2px 8px;
}
#panel-head { padding: 18px 22px 0; }
#panel-category {
  font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase;
  padding: 2px 9px; border-radius: 9px;
  border: 1px solid currentColor;
}
#panel-title { font-family: var(--serif); font-size: 24px; font-weight: 500; margin: 10px 0 4px; }
#panel-date { color: var(--glow-person); font-size: 13.5px; font-variant-numeric: tabular-nums; }
#panel-blurb { padding: 14px 22px 4px; font-size: 14.5px; line-height: 1.65; color: #d5dbee; }
#panel-related-wrap { padding: 14px 22px 0; }
#panel-related-wrap h3 {
  font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 9px; font-weight: 600;
}
#panel-related { display: flex; flex-wrap: wrap; gap: 7px; }
.related-chip {
  padding: 5px 12px; font-size: 12.5px;
  background: rgba(110, 140, 230, 0.12);
  border: 1px solid rgba(130, 155, 235, 0.3);
  border-radius: 14px; color: #bcd0f7;
  transition: all 0.15s;
}
.related-chip:hover { background: rgba(110, 140, 230, 0.28); color: #fff; }
#panel-wiki {
  display: inline-block; margin: 18px 22px 0;
  color: var(--accent); font-size: 13px; text-decoration: none;
  border-bottom: 1px solid rgba(127, 180, 255, 0.35);
  padding-bottom: 1px;
}
#panel-wiki:hover { border-bottom-color: var(--accent); }

/* ---- slice ---- */
#slice {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 40;
  width: min(660px, 94vw); max-height: 72vh;
  background: var(--card-bg);
  border: 1px solid rgba(130, 150, 210, 0.28);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
  display: flex; flex-direction: column;
  overflow: hidden;
}
#slice-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--line);
}
#slice-head h2 { font-family: var(--serif); font-size: 18px; font-weight: 500; }
#slice-close { background: none; border: none; color: var(--ink-dim); font-size: 20px; }
#slice-close:hover { color: #fff; }
#slice-body { overflow-y: auto; padding: 10px 20px 18px; }
.slice-group { margin-top: 10px; }
.slice-group h3 {
  font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase;
  margin-bottom: 6px; font-weight: 600;
}
.slice-item {
  display: flex; gap: 10px; align-items: baseline;
  padding: 5px 8px; border-radius: 7px; cursor: pointer; font-size: 13.5px;
}
.slice-item:hover { background: rgba(110, 140, 230, 0.14); }
.slice-item .sl-date { color: var(--ink-faint); font-size: 11.5px; min-width: 84px; font-variant-numeric: tabular-nums; }
.slice-empty { color: var(--ink-faint); font-size: 13px; padding: 8px; }

/* ---- tours ---- */
#tour-menu {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3, 4, 10, 0.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}
#tour-menu-card {
  width: min(480px, 92vw);
  background: var(--card-bg);
  border: 1px solid rgba(130, 150, 210, 0.28);
  border-radius: 14px; padding: 22px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
}
#tour-menu-card h2 { font-family: var(--serif); font-weight: 500; margin-bottom: 14px; }
.tour-option {
  display: block; width: 100%; text-align: left;
  padding: 12px 14px; margin-bottom: 8px;
  background: rgba(110, 140, 230, 0.08);
  border: 1px solid rgba(130, 155, 235, 0.22);
  border-radius: 10px; color: var(--ink);
  transition: all 0.15s;
}
.tour-option:hover { background: rgba(110, 140, 230, 0.2); }
.tour-option b { display: block; font-size: 14.5px; margin-bottom: 3px; }
.tour-option span { font-size: 12.5px; color: var(--ink-dim); }
.tour-option .tour-stops { font-size: 11px; color: var(--ink-faint); }
#tour-menu-close {
  margin-top: 6px; padding: 7px 16px;
  background: none; border: 1px solid rgba(130,150,210,0.3);
  border-radius: 14px; color: var(--ink-dim);
}
#tour-hud {
  position: fixed; bottom: calc(var(--tabs-h) + 14px); left: 50%; transform: translateX(-50%);
  z-index: 35;
  width: min(560px, 92vw);
  background: var(--card-bg);
  border: 1px solid rgba(180, 150, 255, 0.35);
  border-radius: 14px; padding: 14px 18px 12px;
  box-shadow: 0 12px 50px rgba(80, 40, 160, 0.25), 0 12px 50px rgba(0,0,0,0.5);
}
#tour-note { font-size: 13.5px; line-height: 1.5; color: #ddd5f5; margin-bottom: 10px; }
#tour-controls { display: flex; align-items: center; gap: 10px; }
#tour-controls button {
  padding: 6px 14px;
  background: rgba(150, 110, 230, 0.15);
  border: 1px solid rgba(170, 140, 240, 0.35);
  border-radius: 13px; color: #d8ccf5; font-size: 12.5px;
}
#tour-controls button:hover:not(:disabled) { background: rgba(150, 110, 230, 0.3); color: #fff; }
#tour-controls button:disabled { opacity: 0.35; cursor: default; }
#tour-progress { font-size: 12px; color: var(--ink-dim); margin: 0 auto; }
#tour-exit { margin-left: auto; }

/* ---- toast / hint / about ---- */
#toast {
  position: fixed; top: calc(var(--topbar-h) + 12px); left: 50%; transform: translateX(-50%);
  z-index: 45;
  display: flex; align-items: center; gap: 10px;
  max-width: min(520px, 92vw);
  background: var(--card-bg);
  border: 1px solid rgba(255, 210, 122, 0.3);
  border-radius: 12px; padding: 10px 16px;
  font-size: 13px; color: #f0e2c0;
  box-shadow: 0 10px 40px rgba(0,0,0,0.55);
  animation: toast-in 0.5s cubic-bezier(0.22, 0.9, 0.3, 1);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -12px); } }
#toast button { background: none; border: none; color: var(--ink-dim); font-size: 16px; flex-shrink: 0; }
#toast-text b { color: #ffd27a; cursor: pointer; }
#toast-text b:hover { text-decoration: underline; }

#intro-hint {
  position: fixed; bottom: calc(var(--tabs-h) + 16px); left: 50%; transform: translateX(-50%);
  z-index: 15;
  font-size: 12.5px; color: var(--ink-dim);
  background: rgba(13, 16, 30, 0.8);
  padding: 8px 18px; border-radius: 16px;
  border: 1px solid var(--line);
  pointer-events: none;
  transition: opacity 1s;
}
#intro-hint.fade { opacity: 0; }

#about {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3, 4, 10, 0.65); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}
#about-card {
  width: min(560px, 92vw); max-height: 80vh; overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid rgba(130, 150, 210, 0.28);
  border-radius: 14px; padding: 26px;
}
#about-card h2 { font-family: var(--serif); font-weight: 500; margin-bottom: 12px; }
#about-card p { font-size: 13.5px; line-height: 1.65; color: #cfd6ea; margin-bottom: 12px; }
#about-card kbd {
  background: rgba(120, 140, 210, 0.18); border: 1px solid rgba(130,150,210,0.3);
  border-radius: 4px; padding: 0 5px; font-size: 12px; font-family: inherit;
}
.about-fine { font-size: 12px !important; color: var(--ink-faint) !important; }
#about-close {
  padding: 7px 18px; background: rgba(110, 140, 230, 0.15);
  border: 1px solid rgba(130, 155, 235, 0.35); border-radius: 14px; color: #cdd8f5;
}

/* ---- onboarding walkthrough (coach marks) ---- */
#coach { position: fixed; inset: 0; z-index: 60; }        /* captures clicks behind the callout */
#coach.no-target { background: rgba(3, 4, 10, 0.72); }
#coach.welcome { background: rgba(3, 4, 10, 0.42); }       /* let the cinematic flight glow through */
#coach-hole {
  position: fixed; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(3, 4, 10, 0.72),
              0 0 0 1.5px rgba(127, 180, 255, 0.9),
              0 0 24px rgba(127, 180, 255, 0.45);
  transition: left 0.35s cubic-bezier(0.22,0.9,0.3,1), top 0.35s cubic-bezier(0.22,0.9,0.3,1),
              width 0.35s cubic-bezier(0.22,0.9,0.3,1), height 0.35s cubic-bezier(0.22,0.9,0.3,1);
}
#coach.no-target #coach-hole, #coach.welcome #coach-hole { display: none; }
#coach-pop {
  position: fixed; width: min(340px, 92vw);
  background: var(--card-bg);
  border: 1px solid rgba(130, 150, 210, 0.32);
  border-radius: 14px; padding: 17px 18px 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.62);
  opacity: 0;
  transition: opacity 0.25s, left 0.3s ease, top 0.3s ease;
}
#coach-pop.shown { opacity: 1; }
#coach.no-target #coach-pop, #coach.welcome #coach-pop {
  left: 50% !important; top: 50% !important;
  transform: translate(-50%, -50%);
}
#coach-skip {
  position: absolute; top: 9px; right: 11px;
  width: 24px; height: 24px; border-radius: 50%;
  background: none; border: none; color: var(--ink-faint); font-size: 15px; line-height: 1;
}
#coach-skip:hover { color: var(--ink); }
#coach-emoji { font-size: 25px; line-height: 1; margin-bottom: 8px; }
#coach-pop h3 { font-family: var(--serif); font-weight: 500; font-size: 18px; margin-bottom: 7px; color: #eaf0ff; }
#coach-body { font-size: 13.5px; line-height: 1.6; color: #cfd6ea; }
#coach-body b { color: #eaf0ff; font-weight: 600; }
#coach-body i { color: #dbe2f5; font-style: italic; }
#coach-foot { margin-top: 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
#coach-dismiss-row { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-faint); cursor: pointer; user-select: none; }
#coach-dismiss-row input { width: 13px; height: 13px; accent-color: var(--accent); cursor: pointer; }
#coach-nav { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#coach-dots { display: flex; gap: 5px; }
#coach-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(140, 160, 220, 0.3); transition: background 0.2s, transform 0.2s; }
#coach-dots i.on { background: var(--accent); transform: scale(1.3); }
#coach-prev, #coach-next {
  padding: 6px 13px; border-radius: 13px; font-size: 12.5px;
  border: 1px solid rgba(130, 155, 235, 0.35);
}
#coach-prev { background: transparent; color: var(--ink-dim); }
#coach-prev:hover:not(:disabled) { color: #fff; }
#coach-prev:disabled { opacity: 0.32; cursor: default; }
#coach-next { background: rgba(110, 140, 230, 0.22); color: #eaf0ff; }
#coach-next:hover { background: rgba(110, 140, 230, 0.36); }
@media (max-width: 720px) {
  #coach-foot { gap: 8px; }
  #coach-dismiss-row { order: 2; flex-basis: 100%; }
  #coach-nav { order: 1; width: 100%; }
}

/* category chip colors */
.cat-civilization { color: #e8b45c; }
.cat-technology { color: var(--glow-tech); }
.cat-religion { color: var(--glow-rel); }
.cat-person { color: var(--glow-person); }
.cat-event { color: var(--glow-event); }

/* ---- mobile ---- */
@media (max-width: 720px) {
  :root { --topbar-h: 92px; --tabs-h: 50px; }
  #topbar { flex-wrap: wrap; padding: 6px 10px; gap: 8px; height: var(--topbar-h); }
  #brand h1 { font-size: 16px; }
  #progress-counter { display: none; }
  #searchbox { order: 3; flex-basis: 100%; max-width: none; }
  #year-pill { min-width: 78px; font-size: 12px; padding: 4px 9px; }
  #scrubber { width: 46px; }
  #tab-group { overflow-x: auto; scrollbar-width: none; }
  .tab { padding: 6px 7px; font-size: 11px; gap: 4px; }
  .tab::before { width: 6px; height: 6px; }
  #tab-tools button { padding: 6px 8px; font-size: 12px; }
  #panel {
    top: auto; left: 0; right: 0; bottom: var(--tabs-h);
    width: 100%; max-height: 58vh; height: auto;
    border-left: none; border-top: 1px solid rgba(130, 150, 210, 0.25);
    border-radius: 16px 16px 0 0;
    transform: translateY(110%);
  }
  #panel.open { transform: translateY(0); }
  #panel-image { height: 130px; }
  #tour-hud { width: 94vw; }
}
