:root {
  color-scheme: dark;
  --paper: #f5f0e7;
  --ink: #211c18;
  --muted: #766b5f;
  --accent: #9b402f;
  --panel: rgba(250, 247, 240, 0.96);
  --shadow: rgba(18, 13, 9, 0.28);
  --timeline-bg: #0a0a14;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #0a0a14;
}

/* ── Timeline Overlay ─────────────────────────────── */

.timeline-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--timeline-bg);
  z-index: 100;
  overflow: hidden;
}

.timeline-overlay[hidden] {
  display: none;
}

.timeline-header {
  text-align: center;
  margin-top: 20px;
  margin-bottom: 8px;
  padding: 0 20px;
  z-index: 2;
  pointer-events: none;
}

.timeline-header h1 {
  margin: 0 0 4px;
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f5f0e7 0%, #c9a96e 40%, #a78bfa 70%, #60a5fa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.timeline-header p {
  margin: 0;
  color: rgba(200, 190, 240, 0.5);
  font-size: 0.9rem;
}

.lang-switch {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  justify-content: center;
  pointer-events: auto;
}

.lang-btn {
  padding: 4px 12px;
  border: 1px solid rgba(160, 140, 220, 0.25);
  border-radius: 14px;
  background: rgba(30, 20, 60, 0.3);
  color: rgba(200, 190, 230, 0.6);
  font-size: 0.72rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  border-color: rgba(180, 160, 240, 0.5);
  color: #e8e0f0;
}

.lang-btn.active {
  background: rgba(167, 139, 250, 0.25);
  border-color: #a78bfa;
  color: #c4b5fd;
}

/* ── Search & Filter Bar ──────────────────────────── */

.search-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(900px, calc(100vw - 40px));
  margin-bottom: 8px;
  padding: 0 10px;
  z-index: 2;
}

.search-input {
  flex: 1 1 240px;
  max-width: 360px;
  padding: 10px 16px;
  border: 1px solid rgba(160, 140, 220, 0.25);
  border-radius: 8px;
  background: rgba(30, 20, 60, 0.5);
  backdrop-filter: blur(8px);
  color: #e8e0f0;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.search-input::placeholder {
  color: rgba(200, 180, 230, 0.35);
}

.search-input:focus {
  border-color: #a78bfa;
  background: rgba(40, 30, 80, 0.6);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.filter-chip {
  padding: 6px 14px;
  border: 1px solid rgba(160, 140, 220, 0.2);
  border-radius: 20px;
  background: rgba(30, 20, 60, 0.3);
  backdrop-filter: blur(4px);
  color: rgba(200, 190, 230, 0.6);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: rgba(180, 160, 240, 0.5);
  color: #e8e0f0;
  background: rgba(50, 30, 90, 0.4);
}

.filter-chip.active {
  background: rgba(167, 139, 250, 0.25);
  border-color: #a78bfa;
  color: #c4b5fd;
  font-weight: 600;
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.2);
}

/* Region filter row (second dimension: geographic/cultural) */
.region-chips {
  margin-top: 8px;
  gap: 5px;
}

.region-label {
  font-size: 0.72rem;
  color: rgba(200, 190, 230, 0.5);
  align-self: center;
  margin-right: 2px;
}

.region-chip {
  border-color: rgba(110, 180, 160, 0.2);
  background: rgba(20, 50, 45, 0.3);
  color: rgba(160, 210, 195, 0.6);
}

.region-chip:hover {
  border-color: rgba(130, 210, 185, 0.5);
  color: #d8f0e8;
  background: rgba(30, 70, 60, 0.4);
}

.region-chip.active {
  background: rgba(52, 211, 153, 0.2);
  border-color: #34d399;
  color: #a7f3d0;
  font-weight: 600;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.2);
}

.surprise-button {
  padding: 8px 18px;
  border: 1px solid rgba(201, 169, 110, 0.4);
  border-radius: 8px;
  background: rgba(201, 169, 110, 0.08);
  backdrop-filter: blur(4px);
  color: #c9a96e;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.surprise-button:hover {
  background: rgba(201, 169, 110, 0.18);
  border-color: #c9a96e;
  transform: translateY(-1px);
  box-shadow: 0 0 16px rgba(201, 169, 110, 0.2);
}

/* ── Galaxy Timeline Stage ────────────────────────── */

.timeline-stage {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

#starfield-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.timeline-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
}

.timeline-viewport:active {
  cursor: grabbing;
}

.timeline-viewport.grabbing {
  cursor: grabbing;
}

.timeline-world {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  transform-origin: 0 0;
  will-change: transform;
}

/* ── Epoch Marker (HTML element) ──────────────────── */

.epoch-marker {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
  cursor: pointer;
  user-select: none;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.epoch-marker:hover {
  transform: translate(-50%, -50%) scale(1.18);
}

.epoch-marker .epoch-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  position: relative;
  transition: width 0.2s ease, height 0.2s ease;
}

.epoch-marker:hover .epoch-dot {
  width: 28px;
  height: 28px;
}

.epoch-marker .epoch-dot::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: inherit;
  opacity: 0.3;
  filter: blur(6px);
  transition: inset 0.2s ease, opacity 0.2s ease;
}

.epoch-marker:hover .epoch-dot::before {
  inset: -14px;
  opacity: 0.5;
}

.epoch-marker .epoch-dot::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 25%;
  width: 50%;
  height: 40%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
}

.epoch-marker .epoch-label {
  margin-top: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(220, 210, 240, 0.85);
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
  transition: color 0.2s ease;
}

.epoch-marker:hover .epoch-label {
  color: #fff;
}

.epoch-marker .epoch-years {
  font-size: 0.65rem;
  color: rgba(180, 160, 210, 0.6);
  white-space: nowrap;
  margin-top: 2px;
}

.epoch-marker .epoch-count {
  font-size: 0.6rem;
  color: rgba(160, 140, 200, 0.4);
  white-space: nowrap;
  margin-top: 1px;
}

/* ── Timeline Axis ────────────────────────────────── */

.epoch-band {
  position: absolute;
  height: 90px;
  transform: translateY(-50%);
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.25s ease, height 0.25s cubic-bezier(0.22, 1, 0.36, 1), filter 0.25s ease;
  pointer-events: auto;
  will-change: opacity, height;
}

.epoch-band:hover {
  opacity: 0.9;
  height: 112px;
  filter: brightness(1.15);
}

.timeline-axis {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    rgba(100, 80, 180, 0.05) 0%,
    rgba(140, 120, 220, 0.35) 20%,
    rgba(180, 160, 240, 0.55) 50%,
    rgba(140, 120, 220, 0.35) 80%,
    rgba(100, 80, 180, 0.05) 100%
  );
  box-shadow: 0 0 12px rgba(160, 140, 220, 0.15);
}

.timeline-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  border-radius: 20px;
  background: rgba(20, 10, 40, 0.6);
  backdrop-filter: blur(8px);
  color: rgba(200, 190, 230, 0.5);
  font-size: 0.75rem;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

/* ── Search Results Panel ──────────────────────────── */

.search-results {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(700px, calc(100vw - 40px));
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.5);
  z-index: 120;
  padding: 20px;
}

.search-results[hidden] {
  display: none;
}

.search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.search-results-header span {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.search-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.search-result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.search-result-card:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.search-result-card .artist-thumb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #d6c7af;
  object-fit: cover;
  margin-bottom: 6px;
  border: 2px solid rgba(0, 0, 0, 0.08);
}

.search-result-card .artist-name {
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  color: var(--ink);
}

.search-result-card .artist-meta {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 2px;
  text-align: center;
}

.icon-button.small {
  width: 28px;
  height: 28px;
  font-size: 16px;
  position: static;
}

/* ── Epoch Detail Panel ─────────────────────────────── */

.epoch-detail {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(600px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.5);
  z-index: 110;
  padding: 24px;
}

.epoch-detail[hidden] {
  display: none;
}

.epoch-detail-header {
  margin-bottom: 16px;
  padding-right: 40px;
}

.epoch-detail-header h2 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.2;
}

.epoch-detail-header .years {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.epoch-artists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.epoch-artist-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.epoch-artist-card:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.epoch-artist-card .artist-thumb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #d6c7af;
  object-fit: cover;
  margin-bottom: 8px;
  border: 2px solid rgba(0, 0, 0, 0.08);
}

.epoch-artist-card .artist-name {
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  color: var(--ink);
}

.epoch-artist-card .artist-years {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 2px;
}

.cta-button {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  text-align: center;
}

.cta-button:hover {
  background: #7d3426;
  transform: translateY(-1px);
}

/* ── Museum View ────────────────────────────────────── */

.museum-view {
  position: fixed;
  inset: 0;
  z-index: 1;
  transition: opacity 0.18s ease;
}

.museum-view.museum-fade {
  opacity: 0;
}

.museum-view[hidden] {
  display: none;
}

#museum-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 100vw;
  min-height: 100vh;
  cursor: crosshair;
}

/* Loading spinner */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(167, 139, 250, 0.2);
  border-top-color: #a78bfa;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.museum-loading {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(10, 10, 20, 0.85);
  backdrop-filter: blur(6px);
  color: #e8e0f0;
  font-size: 0.9rem;
  font-weight: 600;
}

.museum-loading[hidden] {
  display: none;
}

.museum-loading p {
  margin: 0;
  color: rgba(200, 190, 230, 0.7);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#hud {
  position: fixed;
  left: 20px;
  bottom: 18px;
  z-index: 10;
  width: min(520px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(24, 20, 17, 0.72);
  color: #fff9ef;
  box-shadow: 0 18px 40px var(--shadow);
  backdrop-filter: blur(10px);
  z-index: 2;
}

#hud strong,
#hud span {
  display: block;
}

#hud strong {
  margin-bottom: 4px;
  font-size: 15px;
}

#hud span {
  color: rgba(255, 249, 239, 0.78);
  font-size: 13px;
  line-height: 1.35;
}

.hud-button {
  margin-top: 10px;
  padding: 10px 20px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff9ef;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.hud-button:hover {
  background: rgba(255, 255, 255, 0.28);
}

.hud-button:active {
  transform: scale(0.97);
}

.panel {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 12;
  width: min(380px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 80px var(--shadow);
}

.panel[hidden] {
  display: none;
}

.panel img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #d6c7af;
}

.panel-carousel {
  position: relative;
}

.carousel-nav {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(20, 17, 14, 0.6);
  backdrop-filter: blur(6px);
}

.carousel-btn {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.carousel-btn:hover {
  background: rgba(255, 255, 255, 0.32);
}

.carousel-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.carousel-counter {
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  font-weight: 600;
  min-width: 40px;
  text-align: center;
}

.panel-content {
  padding: 18px 20px 20px;
}

.years {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.panel h1 {
  margin: 0 0 10px;
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: 0;
}

.panel p {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.5;
}

/* Two-level info panel: teaser + "learn more" facts */
.bio-teaser {
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  font-weight: 500;
}

.more-button {
  display: inline-block;
  margin: 0 0 14px;
  padding: 8px 16px;
  border: 1px solid rgba(155, 64, 47, 0.35);
  border-radius: 20px;
  background: rgba(155, 64, 47, 0.06);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.more-button:hover {
  background: rgba(155, 64, 47, 0.14);
  border-color: var(--accent);
}

.more-button:active {
  transform: scale(0.97);
}

.artist-facts {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: rgba(155, 64, 47, 0.05);
  animation: facts-in 0.25s ease;
}

.artist-facts[hidden] {
  display: none;
}

@keyframes facts-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.bio-full {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}

.fact-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fact-list li {
  display: flex;
  gap: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
}

.fact-list .fact-label {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.03em;
  padding-top: 1px;
}

.fact-list .fact-value {
  color: var(--ink);
}

.panel a {
  color: var(--accent);
  font-weight: 700;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.tts-button {
  padding: 8px 14px;
  border: 1px solid rgba(155, 64, 47, 0.35);
  border-radius: 6px;
  background: rgba(155, 64, 47, 0.08);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.tts-button:hover {
  background: rgba(155, 64, 47, 0.16);
  border-color: var(--accent);
}

.tts-button.speaking {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.fav-button {
  padding: 8px 14px;
  border: 1px solid rgba(201, 169, 110, 0.4);
  border-radius: 6px;
  background: rgba(201, 169, 110, 0.08);
  color: #8a6b2f;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.fav-button:hover {
  background: rgba(201, 169, 110, 0.18);
  border-color: #c9a96e;
}

.fav-button.saved {
  background: rgba(201, 169, 110, 0.25);
  border-color: #c9a96e;
  color: #6b4f1d;
}

.share-button {
  padding: 8px 14px;
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 6px;
  background: rgba(96, 165, 250, 0.08);
  color: #2b6cb0;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.share-button:hover {
  background: rgba(96, 165, 250, 0.18);
  border-color: #60a5fa;
}

.share-button.copied {
  background: rgba(96, 165, 250, 0.25);
  border-color: #60a5fa;
  color: #1e4e8c;
}

.artist-relations {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.artist-relations[hidden] {
  display: none;
}

.relations-title {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.relations-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.relation-chip {
  padding: 5px 10px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.relation-chip:hover {
  background: rgba(155, 64, 47, 0.1);
  border-color: var(--accent);
}

.relation-chip .rel-type {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.65rem;
  margin-left: 4px;
}

.relations-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.relations-tab {
  padding: 4px 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.03);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.relations-tab.active {
  background: rgba(155, 64, 47, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.relations-graph {
  position: relative;
  width: 100%;
  height: 260px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 50%, #f7f2e9 0%, #efe7d8 100%);
  overflow: hidden;
}

.relations-graph[hidden] {
  display: none;
}

.relations-graph canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.relations-graph-hint {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.62rem;
  color: var(--muted);
  pointer-events: none;
  white-space: nowrap;
}

.icon-button {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 17, 14, 0.72);
  color: white;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

/* ── Mobile Touch Controls ─────────────────────────── */

.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.touch-controls[hidden] {
  display: none;
}

.touch-joystick {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.25);
  pointer-events: auto;
  touch-action: none;
}

.touch-joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transform: translate(-50%, -50%);
  transition: transform 0.05s linear;
}

.touch-look {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 55%;
  pointer-events: auto;
  touch-action: none;
}

.epoch-grid-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
}

.pagination-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f0e8ff;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, opacity 0.2s;
}

.pagination-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
}

.pagination-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.pagination-page {
  font-size: 0.85rem;
  color: rgba(240, 232, 255, 0.7);
  min-width: 3.5rem;
  text-align: center;
}

/* ── Responsive ─────────────────────────────────────── */

@media (max-width: 700px) {
  .timeline-header h1 {
    font-size: 1.8rem;
  }

  .timeline-header p {
    font-size: 0.8rem;
  }

  .epoch-detail {
    width: calc(100vw - 24px);
    padding: 16px;
  }

  .panel {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100vw;
    max-height: 78vh;
    border-radius: 16px 16px 0 0;
  }

  .panel img {
    aspect-ratio: 16 / 9;
  }

  #hud {
    left: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

  .timeline-hint {
    font-size: 0.7rem;
    padding: 4px 12px;
  }

  .search-bar {
    flex-direction: column;
    gap: 8px;
    padding: 0 12px;
  }

  .search-input {
    width: 100%;
  }

  .filter-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .filter-chip {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .relations-graph {
    height: 220px;
  }

  .touch-look {
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.03) 100%);
  }
}
