/* ==========================================================================
   Chronicle Slate — original design system
   Inspired by, never copied from, Zelda's Switch-era menu/map language.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Base palette — deep slate, luminous amber accent */
  --slate-950: #060a0e;
  --slate-900: #0b0f14;
  --slate-850: #101720;
  --slate-800: #16202b;
  --slate-700: #223040;
  --slate-600: #34495e;
  --slate-400: #7b8fa3;
  --slate-200: #c7d3dd;
  --slate-100: #e8ecef;

  --accent-amber: #e8b24d;
  --accent-amber-dim: #a97f31;
  --accent-cyan: #4fd1c5;

  /* Era palette — bespoke, not sampled from any game asset */
  --era-pre-split: #d9a441;
  --era-child: #4caf7d;
  --era-adult: #3f8ec9;
  --era-downfall: #a34a4a;
  --era-converged: #8a6fb0;
  --era-botw: #3fc9c9;
  --era-aoc: #c9a13f;
  --era-noncanon: #6b7280;

  --font-display: "Cinzel", "Spectral", serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-panel: 0 20px 60px -20px rgba(0, 0, 0, 0.6);

  /* Tech-slate energy layer */
  --glow-cyan: 0 0 12px rgba(79, 209, 197, 0.45);
  --glow-cyan-strong: 0 0 22px rgba(79, 209, 197, 0.7);
  --glow-amber: 0 0 12px rgba(232, 178, 77, 0.45);
  --glow-amber-strong: 0 0 22px rgba(232, 178, 77, 0.7);
  --grad-holo: linear-gradient(100deg, var(--accent-amber) 0%, #f0d9a0 30%, var(--accent-cyan) 70%, #7de8de 100%);
  --grad-panel-edge: linear-gradient(to bottom, rgba(232, 178, 77, 0.14), transparent 30%);
  --grad-fade-slate: linear-gradient(to bottom, rgba(6, 10, 14, 0.55), rgba(6, 10, 14, 0.92) 60%, var(--slate-950) 100%);

  /* Original abstract circuit-trace texture (not any game's glyphs) */
  --tex-circuit: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%234fd1c5' stroke-width='1' opacity='0.5'%3E%3Cpath d='M10 20h50v30h40'/%3E%3Cpath d='M150 60h-30v50h-60'/%3E%3Cpath d='M20 150v-40h35'/%3E%3Cpath d='M120 10v35h30'/%3E%3Ccircle cx='60' cy='20' r='3'/%3E%3Ccircle cx='100' cy='50' r='3'/%3E%3Ccircle cx='120' cy='110' r='3'/%3E%3Ccircle cx='55' cy='110' r='3'/%3E%3Ccircle cx='20' cy='110' r='2'/%3E%3Ccircle cx='150' cy='45' r='2'/%3E%3C/g%3E%3C/svg%3E");
  --tex-hexgrid: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cpath d='M28 0 56 16v34L28 66 0 50V16zM28 66 56 82v34L28 132 0 116V82z' fill='none' stroke='%23e8b24d' stroke-width='0.75' opacity='0.5'/%3E%3C/svg%3E");
  --tex-scanlines: repeating-linear-gradient(
    to bottom,
    rgba(79, 209, 197, 0.06) 0px,
    rgba(79, 209, 197, 0.06) 1px,
    transparent 1px,
    transparent 4px
  );
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.9; }
}

@keyframes scanline-drift {
  from { background-position: 0 0; }
  to { background-position: 0 40px; }
}

@keyframes circuit-flow {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -60; }
}

@keyframes holo-shimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(232, 178, 77, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(79, 209, 197, 0.06), transparent),
    var(--slate-950);
  color: var(--slate-100);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.25;
  color: var(--slate-100);
}

a {
  color: var(--accent-amber);
  text-decoration: none;
}

a:hover {
  color: var(--accent-cyan);
}

/* ==========================================================================
   Focus-visible — a single consistent ring for every interactive element,
   keyboard-only (mouse clicks don't trigger :focus-visible). SVG elements
   (.timeline-node) get their own outline rule near the diagram styles,
   since `outline` behaves differently there but is still transform-free
   and therefore safe under the no-CSS-transform rule.
   ========================================================================== */

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ==========================================================================
   Chronicle Slate frame — an original HUD-frame motif evoking a
   diegetic "device" reading surface. Hand-drawn corners, no ripped glyphs.
   ========================================================================== */

.slate-frame {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.slate-frame__corner {
  position: fixed;
  width: 28px;
  height: 28px;
  border: 2px solid var(--accent-amber-dim);
  opacity: 0.5;
  pointer-events: none;
  z-index: 40;
  filter: drop-shadow(0 0 6px rgba(232, 178, 77, 0.5));
  animation: pulse-glow 5s ease-in-out infinite;
}

.slate-frame__corner--tl {
  top: 14px;
  left: 14px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 6px;
}

.slate-frame__corner--tr {
  top: 14px;
  right: 14px;
  border-left: none;
  border-bottom: none;
  border-top-right-radius: 6px;
}

.slate-frame__corner--bl {
  bottom: 14px;
  left: 14px;
  border-right: none;
  border-top: none;
  border-bottom-left-radius: 6px;
}

.slate-frame__corner--br {
  bottom: 14px;
  right: 14px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 6px;
}

.slate-frame__body {
  flex: 1;
  padding: 32px 0 64px;
  position: relative;
}

/* Faint ambient hex field behind everything inside the slate */
.slate-frame__body::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--tex-hexgrid);
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
}

.slate-frame__body > * {
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Nav
   ========================================================================== */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  border-bottom: 1px solid var(--slate-700);
  background: linear-gradient(to bottom, var(--slate-850), transparent);
  position: relative;
}

/* Holographic hairline under the nav */
.nav::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--grad-holo);
  opacity: 0.5;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--slate-100);
}

.nav__brand:hover {
  color: var(--slate-100);
}

.nav__brand-mark {
  width: 14px;
  height: 14px;
  background: var(--grad-holo);
  background-size: 300% 300%;
  animation: holo-shimmer 6s ease-in-out infinite;
  transform: rotate(45deg);
  border-radius: 3px;
  box-shadow: var(--glow-amber);
}

.nav__links {
  display: flex;
  gap: 28px;
  font-size: 0.95rem;
}

.nav__links a {
  color: var(--slate-200);
}

.nav__links a.active {
  color: var(--accent-amber);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  padding: 32px 40px;
  border-top: 1px solid var(--slate-700);
  font-size: 0.82rem;
  color: var(--slate-400);
  max-width: 900px;
  margin: 0 auto;
}

.footer p {
  margin: 4px 0;
}

/* ==========================================================================
   Panels — the reusable "slate panel" chrome
   ========================================================================== */

.panel {
  background: linear-gradient(160deg, var(--slate-850), var(--slate-800));
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grad-panel-edge), var(--tex-circuit);
  background-size: 100% 100%, 160px 160px;
  opacity: 0.35;
  pointer-events: none;
}

.panel > * {
  position: relative;
}

/* ==========================================================================
   Hero / intro
   ========================================================================== */

.hero {
  padding: 24px 0 40px;
}

.hero h1 {
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  margin: 0 0 12px;
  background: var(--grad-holo);
  background-size: 250% 250%;
  animation: holo-shimmer 9s ease-in-out infinite;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(232, 178, 77, 0.25));
}

.hero p {
  color: var(--slate-200);
  max-width: 640px;
  font-size: 1.05rem;
}

/* ==========================================================================
   Filter bar
   ========================================================================== */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 16px 20px;
  margin: 24px 0;
}

.filter-bar select {
  background: var(--slate-800);
  border: 1px solid var(--slate-600);
  color: var(--slate-100);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 0.9rem;
}

.filter-bar__count {
  margin-left: auto;
  color: var(--slate-400);
  font-size: 0.85rem;
}

.filter-bar__clear {
  background: none;
  border: 1px solid var(--slate-600);
  color: var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.85rem;
}

.filter-bar__clear:hover {
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

/* ==========================================================================
   Timeline diagram
   ========================================================================== */

.timeline-bleed {
  padding: 0 32px;
}

.timeline-diagram-wrap {
  position: relative;
  display: flex;
  margin: 24px 0 48px;
  overflow-x: auto;
  /* Soft edge fade hints that the chart scrolls horizontally. */
  mask-image: linear-gradient(to right, transparent, black 18px, black calc(100% - 18px), transparent);
}

.timeline-diagram-wrap svg {
  display: block;
  /* Centers the diagram when it's narrower than the wrap (a filtered,
     sparse branch view); auto-margins resolve to 0 when the diagram
     overflows, so the full unfiltered chart still starts flush-left and
     scrolls rightward as before. flex-shrink:0 is required -- without it
     flex would compress the SVG's own box, shrinking every label the same
     way a whole-diagram CSS scale would (rejected for that reason, see
     TimelineDiagram.tsx). This never touches .timeline-node itself. */
  margin: 0 auto;
  flex-shrink: 0;
}

.timeline-branch-path {
  fill: none;
  stroke-width: 3;
  opacity: 0.75;
}

/* Energy flowing along solid branch paths */
.timeline-branch-path--flow {
  stroke-dasharray: 14 6;
  animation: circuit-flow 2.6s linear infinite;
}

/* NOTE: never put a CSS `transform` on .timeline-node — the group is
   positioned by an SVG transform *attribute*, and the CSS property would
   override it, teleporting the node to the origin on hover (flicker loop). */
.timeline-node {
  cursor: pointer;
}

/* `outline` (not `transform`) — paint-only, doesn't touch the SVG
   transform attribute that positions this group, so it's safe under the
   no-CSS-transform rule documented above. */
.timeline-node:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 4px;
  border-radius: 50%;
}

.timeline-node .timeline-node__ring,
.timeline-node .timeline-node__dot {
  transition: r 0.15s ease, stroke-width 0.15s ease, opacity 0.15s ease;
}

.timeline-node text,
.timeline-diagram text {
  font-family: var(--font-body);
  fill: var(--slate-200);
}

.timeline-node__year {
  fill: var(--slate-400);
}

.era-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 16px 0 8px;
  font-size: 0.82rem;
  color: var(--slate-400);
}

.era-legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.era-legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* ==========================================================================
   Game grid + cards
   ========================================================================== */

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin: 24px 0;
}

.game-card {
  display: flex;
  background: var(--slate-850);
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-md);
  overflow: hidden;
  color: var(--slate-100);
  transition: border-color 0.15s ease, transform 0.15s ease;
  /* The art rail is a flat 86px at every width -- cap the card so it can't
     stretch to fill a wide auto-fit track and turn the art into a thin
     sliver next to an oversized text panel. */
  max-width: 420px;
}

.game-card:hover {
  border-color: var(--accent-amber-dim);
  transform: translateY(-2px);
  color: var(--slate-100);
  box-shadow: var(--glow-amber), var(--shadow-panel);
}

.game-card__art {
  position: relative;
}

.game-card:hover .game-card__art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--tex-scanlines);
  animation: scanline-drift 1.2s linear infinite;
  pointer-events: none;
}

.game-card__branch {
  width: 5px;
  flex-shrink: 0;
}

.game-card__art {
  width: 86px;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--slate-800);
}

.game-card__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.game-card__body {
  padding: 16px 18px;
  flex: 1;
}

.game-card__body h3 {
  font-size: 1.05rem;
  margin: 0 0 4px;
}

.game-card__meta {
  font-size: 0.78rem;
  color: var(--slate-400);
  margin: 0 0 8px;
}

.game-card__synopsis {
  font-size: 0.88rem;
  color: var(--slate-200);
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   Badges
   ========================================================================== */

.confidence-badge,
.canonicity-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
}

.confidence-badge--official {
  color: var(--era-child);
}

.confidence-badge--strong-community {
  color: var(--accent-amber);
}

.confidence-badge--speculative {
  /* --era-downfall itself fails WCAG AA for small text (~3.1:1 on card
     backgrounds) -- it stays as-is for the diagram/branch color identity,
     but this badge gets a lightened variant tuned to pass 4.5:1. */
  color: #b56e6e;
}

.canonicity-badge {
  color: var(--slate-200);
  border-color: var(--slate-600);
  margin-right: 8px;
}

.canonicity-badge--non-canon {
  /* Same reasoning as confidence-badge--speculative above. */
  color: #79808c;
}

/* ==========================================================================
   Detail page
   ========================================================================== */

.detail-page {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px;
}

.detail-hero {
  border-left: 3px solid var(--accent-amber);
  padding: 8px 0 24px 20px;
  margin-bottom: 24px;
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

.detail-hero__art {
  flex-shrink: 0;
  width: 180px;
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-panel);
}

.detail-hero__art img {
  width: 100%;
  display: block;
  /* Reserve box-art's ~0.68 portrait ratio so the hero doesn't jump once
     the (always hotlinked, never locally sized) image finishes loading. */
  aspect-ratio: 0.68;
  object-fit: cover;
}

.detail-hero__info {
  min-width: 0;
}

/* The hero art was sized once (180px) and never revisited for wide
   screens; give it a bit more presence in the spacious 780px reading
   column on large desktops. */
@media (min-width: 1440px) {
  .detail-hero__art {
    width: 220px;
  }
}

/* Intentionally narrower than the site's usual 719px mobile breakpoint --
   the hero row still reads fine down to ~561px, only very small phones
   need it to stack. Not merged into the 719px convention on purpose. */
@media (max-width: 560px) {
  .detail-hero {
    flex-direction: column;
  }

  .detail-hero__art {
    width: 140px;
  }
}

.detail-hero__branch {
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
}

.detail-hero h1 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  margin: 0 0 8px;
}

.detail-hero__meta {
  color: var(--slate-400);
  font-size: 0.9rem;
  margin: 0 0 14px;
}

.detail-hero__badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-synopsis,
.detail-sourcing,
.detail-trivia {
  margin-bottom: 32px;
}

.detail-sourcing {
  padding: 16px 20px;
  background: var(--slate-850);
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-700);
}

.detail-trivia ul {
  padding-left: 20px;
}

.detail-trivia li {
  margin-bottom: 8px;
  color: var(--slate-200);
}

.not-found {
  text-align: center;
  padding: 80px 24px;
  max-width: 480px;
  margin: 0 auto;
}

.not-found__glyph {
  margin-bottom: 20px;
  filter: drop-shadow(0 0 10px rgba(79, 209, 197, 0.25));
}

.not-found h1 {
  margin: 0 0 12px;
}

.not-found p {
  color: var(--slate-200);
  margin: 0 0 28px;
}

.not-found__links {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ==========================================================================
   Codex
   ========================================================================== */

.codex-index {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
}

.codex-index__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.codex-index__card {
  display: block;
  padding: 24px;
  background: var(--slate-850);
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-lg);
  color: var(--slate-100);
}

.codex-index__card:hover {
  border-color: var(--accent-amber-dim);
  color: var(--slate-100);
}

.codex-index__card h2 {
  font-size: 1.2rem;
  margin: 0 0 8px;
}

.codex-index__card p {
  color: var(--slate-200);
  font-size: 0.9rem;
  margin: 0;
}

.codex-reader {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px;
}

.markdown-doc h1 {
  font-size: 2rem;
}

.markdown-doc h2 {
  font-size: 1.4rem;
  margin-top: 2.2em;
  border-bottom: 1px solid var(--slate-700);
  padding-bottom: 8px;
  position: relative;
}

.markdown-doc h2::before,
.section-title::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 10px;
  background: var(--accent-cyan);
  transform: rotate(45deg);
  box-shadow: var(--glow-cyan);
  vertical-align: 2px;
}

.markdown-doc h3 {
  font-size: 1.1rem;
  margin-top: 1.6em;
}

.markdown-doc p {
  color: var(--slate-200);
}

.markdown-doc a {
  text-decoration: underline;
}

.markdown-doc blockquote {
  border-left: 3px solid var(--accent-amber-dim);
  margin-left: 0;
  padding-left: 16px;
  color: var(--slate-400);
}

.markdown-doc code {
  background: var(--slate-800);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

.markdown-doc table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}

/* Plain text/data tables (not the image galleries below) scroll internally
   on narrow screens instead of blowing out the page width. `display:block`
   on <table> still gets an anonymous table box generated around its
   table-row-group children, so tabular alignment survives. */
.markdown-doc table:not(:has(img)) {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.markdown-doc th,
.markdown-doc td {
  border: 1px solid var(--slate-700);
  padding: 8px 10px;
  text-align: left;
}

/* ==========================================================================
   About
   ========================================================================== */

.about-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 24px;
}

.about-page p {
  color: var(--slate-200);
}

/* ==========================================================================
   Motion preferences
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ==========================================================================
   Game page backgrounds
   ========================================================================== */

.game-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.game-bg__image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 20%;
}

.game-bg--blur .game-bg__image {
  filter: blur(28px) saturate(1.15) brightness(0.75);
  transform: scale(1.15);
}

.game-bg--keyart .game-bg__image {
  filter: saturate(1.05) brightness(0.8);
}

.game-bg__tint,
.game-bg__texture,
.game-bg__fade {
  position: absolute;
  inset: 0;
}

.game-bg__texture {
  background-image: var(--tex-circuit);
  background-size: 320px 320px;
  opacity: 0.1;
}

.game-bg__fade {
  background: var(--grad-fade-slate);
}

/* ==========================================================================
   Chips
   ========================================================================== */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--slate-600);
  background: var(--slate-850);
  color: var(--slate-200);
  font-size: 0.85rem;
}

.chip:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
}

.chip--thread {
  border-color: var(--accent-amber-dim);
}

/* ==========================================================================
   Connections list
   ========================================================================== */

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

.connection-list__item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 12px 16px;
  background: var(--slate-850);
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-md);
}

.connection-list__type {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate-400);
  min-width: 150px;
}

.connection-list__target {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.connection-list__target img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--slate-600);
}

.connection-list__note {
  flex-basis: 100%;
  font-size: 0.85rem;
  color: var(--slate-400);
}

/* ==========================================================================
   Game pager
   ========================================================================== */

.game-pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 48px 0 24px;
  border-top: 1px solid var(--slate-700);
  padding-top: 24px;
}

.game-pager__link {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--slate-100);
  max-width: 46%;
}

.game-pager__link img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--slate-600);
  flex-shrink: 0;
}

.game-pager__link:hover img {
  border-color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
}

.game-pager__link span {
  display: flex;
  flex-direction: column;
}

.game-pager__link small {
  color: var(--slate-400);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.game-pager__link--next {
  text-align: right;
  margin-left: auto;
}

.game-pager__spacer {
  flex: 1;
}

/* ==========================================================================
   Section pages (explore/branch/threads/glossary/stats)
   ========================================================================== */

.section-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
}

.section-page__intro {
  color: var(--slate-200);
  font-size: 1.05rem;
  max-width: 640px;
  margin-bottom: 32px;
}

.explore-grid,
.branch-grid,
.thread-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 20px;
}

.explore-card,
.branch-card,
.thread-card {
  display: block;
  padding: 24px;
  color: var(--slate-100);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.explore-card:hover,
.branch-card:hover,
.thread-card:hover {
  border-color: var(--accent-cyan);
  box-shadow: var(--glow-cyan), var(--shadow-panel);
  color: var(--slate-100);
}

.explore-card h2,
.branch-card h2,
.thread-card h2 {
  font-size: 1.2rem;
  margin: 0 0 8px;
}

.explore-card p,
.branch-card p,
.thread-card p {
  color: var(--slate-200);
  font-size: 0.9rem;
  margin: 0;
}

.branch-card {
  position: relative;
  padding-left: 28px;
}

.branch-card__rail {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.branch-card__count,
.thread-card__count {
  display: block;
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.thread-card__kind {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-amber);
  margin-bottom: 8px;
}

/* Branch detail */

.branch-page__hero {
  border-left: 3px solid;
  padding: 8px 0 8px 20px;
  margin-bottom: 32px;
}

.branch-page__hero h1 {
  margin: 0 0 8px;
}

.branch-page__summary {
  font-size: 1.05rem;
  color: var(--slate-200);
  max-width: 640px;
}

.branch-page__split,
.branch-page__lineage {
  font-size: 0.9rem;
  color: var(--slate-400);
  margin: 6px 0;
}

.branch-page__arc {
  margin-bottom: 40px;
}

.branch-page__arc p {
  color: var(--slate-200);
}

/* Thread detail */

.thread-entries {
  list-style: none;
  padding: 0;
  margin: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.thread-entry {
  border-left: 3px solid var(--slate-600);
  padding: 12px 0 12px 20px;
}

.thread-entry__game {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--slate-100);
}

.thread-entry__game img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--slate-600);
}

.thread-entry__game span {
  display: flex;
  flex-direction: column;
}

.thread-entry__game small {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.thread-entry__note {
  margin: 10px 0 0;
  color: var(--slate-200);
  font-size: 0.92rem;
}

/* Glossary */

.glossary-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
}

.glossary-entry {
  padding: 20px 24px;
  scroll-margin-top: 90px;
}

.glossary-entry dt {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--accent-amber);
}

.glossary-entry dd {
  margin: 0;
}

.glossary-entry dd p {
  color: var(--slate-200);
  margin: 0 0 12px;
}

/* Stats */

.stats-callouts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-callout {
  padding: 22px;
  text-align: center;
}

.stat-callout__value {
  display: block;
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  background: var(--grad-holo);
  background-size: 250% 250%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-callout__label {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--slate-400);
}

.stats-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.bar-chart {
  padding: 20px 22px;
  margin: 0;
}

.bar-chart__title {
  font-family: var(--font-display);
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--slate-100);
}

/* ==========================================================================
   Vertical timeline (mobile) — CSS-only breakpoint toggle, SSR-safe
   ========================================================================== */

.timeline-vertical {
  display: none;
  padding: 8px 0 32px;
}

@media (max-width: 719px) {
  .timeline-diagram-wrap {
    display: none;
  }

  .timeline-vertical {
    display: block;
  }
}

.vt-branch {
  margin-bottom: 36px;
}

.vt-branch__header h2 {
  font-size: 1.15rem;
  margin: 0 0 4px;
}

.vt-branch__fork {
  font-size: 0.8rem;
  color: var(--slate-400);
  margin: 0 0 12px;
}

.vt-branch__games {
  list-style: none;
  margin: 12px 0 0;
  padding: 0 0 0 18px;
  border-left: 2px solid;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vt-game__link {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--slate-100);
}

.vt-game__art {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(79, 209, 197, 0.15);
}

.vt-game__text {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.vt-game__text small {
  color: var(--slate-400);
  font-size: 0.78rem;
}

/* Broader mobile comfort */

@media (max-width: 719px) {
  .hero h1 {
    font-size: 1.9rem;
  }

  .filter-bar {
    padding: 12px 14px;
  }

  .filter-bar__count {
    flex-basis: 100%;
    margin-left: 0;
  }

  .detail-hero {
    gap: 18px;
  }

  .game-pager {
    flex-direction: column;
  }

  .game-pager__link {
    max-width: 100%;
  }

  .connection-list__type {
    min-width: 0;
    flex-basis: 100%;
  }

  .timeline-bleed {
    padding: 0 20px;
  }
}

/* ==========================================================================
   Scrollytelling — static stacked baseline; .scrolly--active pins the stage
   ========================================================================== */

.scrolly {
  position: relative;
  margin: 24px 0 48px;
}

/* Static mode: no stage, steps stack with their own clusters. */
.scrolly:not(.scrolly--active) .scrolly__stage {
  display: none;
}

.scrolly__step {
  margin: 0 auto 48px;
  max-width: 900px;
  padding: 0 24px;
}

.scrolly__card {
  padding: 26px 30px;
  max-width: 560px;
}

.scrolly__card-era {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0 0 6px;
}

.scrolly__card h2 {
  margin: 0 0 10px;
  font-size: 1.5rem;
}

.scrolly__card p {
  margin: 0;
  color: var(--slate-200);
}

.scrolly-cluster {
  text-align: center;
}

.scrolly-cluster__era {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 22px;
}

.scrolly-cluster__medallions {
  display: flex;
  justify-content: center;
  gap: 34px;
  flex-wrap: wrap;
}

.scrolly-medallion {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--slate-200);
}

.scrolly-medallion img {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid;
  border-color: inherit;
  box-shadow: 0 0 22px rgba(79, 209, 197, 0.25);
  transition: box-shadow 0.2s ease;
}

.scrolly-medallion:hover img {
  box-shadow: var(--glow-cyan-strong);
}

.scrolly-medallion__label {
  font-size: 0.85rem;
  max-width: 140px;
  text-align: center;
  line-height: 1.3;
}

.scrolly__inline-cluster {
  margin-top: 22px;
}

/* Active (pinned) mode */

.scrolly--active .scrolly__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  display: block;
  z-index: 0;
}

.scrolly--active .scrolly__layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.55s ease;
  pointer-events: none;
}

.scrolly--active .scrolly__layer--active {
  opacity: 1;
  pointer-events: auto;
}

.scrolly--active .scrolly__rail {
  position: absolute;
  right: 40px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scrolly__rail {
  display: none;
}

.scrolly--active .scrolly__rail {
  display: flex;
}

.scrolly__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--slate-600);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Steps float over the pinned stage as spacers with a text card. */
.scrolly--active .scrolly__steps {
  position: relative;
  z-index: 1;
  margin-top: -100vh;
}

.scrolly--active .scrolly__step {
  min-height: 92vh;
  display: flex;
  align-items: center;
  margin-bottom: 0;
  max-width: 1200px;
}

.scrolly--active .scrolly__card {
  background: rgba(16, 23, 32, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.scrolly--active .scrolly__inline-cluster {
  display: none;
}

.chart-divider {
  margin: 32px 0 8px;
  padding-top: 24px;
  border-top: 1px solid var(--slate-700);
}

.chart-divider h2 {
  margin: 0 0 6px;
}

.chart-divider p {
  color: var(--slate-400);
  margin: 0;
  font-size: 0.95rem;
}

/* ==========================================================================
   Page transitions (View Transitions API — progressive enhancement)
   ========================================================================== */

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.22s;
  animation-timing-function: ease;
}

::view-transition-old(root) {
  animation-name: vt-out;
}

::view-transition-new(root) {
  animation-name: vt-in;
}

@keyframes vt-out {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@keyframes vt-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }
}

/* Sound toggle */

.sound-toggle {
  background: none;
  border: 1px solid var(--slate-600);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--slate-400);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.sound-toggle:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.sound-toggle--on {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
}

/* Mobile nav: fit 4 links + sound toggle in 390px without overflow */
@media (max-width: 719px) {
  .nav {
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px 12px;
  }

  .nav__links {
    gap: 14px;
    font-size: 0.88rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
  }

  .sound-toggle {
    width: 30px;
    height: 30px;
  }

  .slate-frame__corner {
    display: none;
  }
}

/* Pinned scrolly: reserve the left column for text cards, keep the
   medallion cluster in the right half so they never overlap. */
.scrolly--active .scrolly__layer {
  justify-content: flex-end;
  padding-right: 5vw;
}

.scrolly--active .scrolly__layer .scrolly-cluster {
  max-width: 46vw;
}

.scrolly--active .scrolly__card {
  max-width: min(560px, 42vw);
}

/* ==========================================================================
   Ambient page-level texture (behind everything, above the base gradients)
   ========================================================================== */

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.035;
}

/* ==========================================================================
   Scroll reveal (mobile-friendly)
   ========================================================================== */

.rv {
  opacity: 0;
  transform: translateY(16px);
}

.rv-in {
  opacity: 1;
  transform: none;
  transition: opacity 0.55s ease, transform 0.55s ease;
}

/* ==========================================================================
   Pixel scroll-walker
   ========================================================================== */

.scroll-walker {
  position: fixed;
  left: 18px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
  /* Promote to its own GPU layer so mobile Safari keeps it glued to the
     viewport edge during momentum/rubber-band scroll instead of briefly
     lagging behind and appearing to travel with the page. */
  will-change: transform, opacity;
  backface-visibility: hidden;
}

.scroll-walker--walking {
  opacity: 1;
}

.scroll-walker__frame--a,
.scroll-walker__frame--b {
  opacity: 0;
}

/* A small vertical bob synced to the frame swap reads as a step, not a
   left/right shift — the actual facing direction is handled separately
   by the wrapper's scaleX(dir). */
.scroll-walker--walking .scroll-walker__frame--a {
  animation: walk-frame-a 0.36s steps(1) infinite;
}

.scroll-walker--walking .scroll-walker__frame--b {
  animation: walk-frame-b 0.36s steps(1) infinite;
}

@keyframes walk-frame-a {
  0%, 49% { opacity: 1; transform: translateY(0); }
  50%, 100% { opacity: 0; transform: translateY(-1px); }
}

@keyframes walk-frame-b {
  0%, 49% { opacity: 0; transform: translateY(0); }
  50%, 100% { opacity: 1; transform: translateY(-1px); }
}

/* Threads hub grouping */

.thread-kind-section {
  margin-bottom: 44px;
}

.thread-kind-section__blurb {
  color: var(--slate-400);
  font-size: 0.9rem;
  margin: -4px 0 18px;
}

.thread-card h3 {
  font-size: 1.15rem;
  margin: 0 0 8px;
}

/* ==========================================================================
   Icon Key
   ========================================================================== */

.icon-key {
  margin-bottom: 52px;
  padding: 34px 38px;
}

@media (max-width: 719px) {
  .icon-key {
    padding: 24px 20px;
  }
}

.icon-key__title {
  margin-top: 0;
}

.icon-key__disclaimer {
  color: var(--slate-400);
  font-size: 0.88rem;
  max-width: 640px;
  margin: 0 0 20px;
}

.icon-key__group {
  margin-bottom: 30px;
}

.icon-key__group:last-child {
  margin-bottom: 0;
}

.icon-key__group h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  margin: 0 0 12px;
}

.icon-key__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.icon-key__entry {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.icon-key__entry:hover {
  background: var(--slate-800);
}

.icon-key__glyph {
  flex-shrink: 0;
}

.icon-key__text strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 3px;
}

.icon-key__text p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--slate-400);
  line-height: 1.5;
}

/* ==========================================================================
   Images embedded in essay markdown
   ========================================================================== */

.markdown-doc img {
  display: block;
  max-width: 100%;
  width: 100%;
  height: auto;
  margin: 28px auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-700);
  box-shadow: var(--shadow-panel);
  /* Most standalone essay images are portrait box art (~0.68); the few
     landscape key-art images crop slightly rather than reflowing the page
     as they load -- a deliberate CLS-vs-perfect-fit tradeoff. */
  aspect-ratio: 0.68;
  object-fit: cover;
}

.markdown-doc p:has(> img:only-child) {
  text-align: center;
}

/* Opt-in override for the rare genuinely-landscape essay image (screenshots,
   maps, wide key art) -- applied via a source-URL allowlist in
   MarkdownDoc.tsx, since plain markdown has no way to attach a per-image
   class. New images default to the portrait ratio above unless added there. */
.markdown-doc img.landscape {
  aspect-ratio: 16 / 9;
}

/* Image-comparison "tables" (each cell = one image + its caption) become a
   responsive gallery: side-by-side on desktop, full-width stacked cards on
   mobile, instead of squeezing images into narrow table columns. */
.markdown-doc table:has(img) {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  border: none;
  margin: 28px 0;
}

.markdown-doc table:has(img) thead {
  display: none;
}

.markdown-doc table:has(img) tbody,
.markdown-doc table:has(img) tr {
  display: contents;
}

.markdown-doc table:has(img) td {
  flex: 1 1 220px;
  border: none;
  padding: 0;
  text-align: center;
  vertical-align: top;
}

.markdown-doc table:has(img) img {
  margin: 0 auto 10px;
  width: 100%;
  aspect-ratio: 0.68;
  object-fit: cover;
}

.markdown-doc table:has(img) img.landscape {
  aspect-ratio: 16 / 9;
}

.markdown-doc table:has(img) em {
  display: block;
  color: var(--slate-400);
  font-size: 0.85rem;
}

.markdown-doc em:has(> img) {
  display: block;
}

/* ==========================================================================
   Print — scoped to the Codex essays. Everything else keeps screen styles
   (printing the interactive timeline/app chrome makes no sense).
   ========================================================================== */

@media print {
  .nav,
  .footer,
  .scroll-walker,
  .slate-frame__corner,
  .slate-frame__body::before,
  .icon-key {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #111 !important;
  }

  .codex-reader {
    max-width: 100%;
  }

  .markdown-doc h1,
  .markdown-doc h2,
  .markdown-doc h3,
  .markdown-doc p,
  .markdown-doc li {
    color: #111 !important;
  }

  .markdown-doc h2::before {
    background: #333 !important;
    box-shadow: none !important;
  }

  .markdown-doc a {
    color: #111 !important;
    text-decoration: underline;
  }

  /* Show the actual URL after each link, since clicking isn't possible on paper. */
  .markdown-doc a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
    color: #555 !important;
  }

  .markdown-doc img,
  .markdown-doc table:has(img) img {
    filter: grayscale(0.1);
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }

  .markdown-doc blockquote {
    border-left: 2px solid #999;
    color: #333 !important;
  }

  .markdown-doc table:not(:has(img)) {
    border: 1px solid #999;
  }

  .markdown-doc th,
  .markdown-doc td {
    border: 1px solid #999 !important;
    color: #111 !important;
  }

  a {
    color: #111 !important;
  }
}

/* ==========================================================================
   Command palette
   ========================================================================== */

.cmdk-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--slate-600);
  border-radius: 999px;
  height: 34px;
  padding: 0 12px;
  color: var(--slate-400);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.cmdk-trigger:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.cmdk-trigger__hint {
  font-size: 0.72rem;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
}

.cmdk-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6, 10, 14, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
}

.cmdk-dialog {
  width: 100%;
  max-width: 560px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--glow-cyan-strong), var(--shadow-panel);
}

.cmdk-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--slate-700);
}

.cmdk-input-icon {
  color: var(--slate-400);
  flex-shrink: 0;
}

.cmdk-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--slate-100);
  font-size: 1rem;
  font-family: var(--font-body);
}

.cmdk-input::placeholder {
  color: var(--slate-400);
}

.cmdk-esc {
  font-size: 0.7rem;
  color: var(--slate-400);
  border: 1px solid var(--slate-600);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-body);
}

.cmdk-results {
  overflow-y: auto;
  padding: 8px;
}

.cmdk-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--slate-400);
  font-size: 0.9rem;
  margin: 0;
}

.cmdk-result {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  color: var(--slate-100);
}

.cmdk-result--active,
.cmdk-result:hover {
  background: var(--slate-800);
}

.cmdk-result__kind {
  flex-shrink: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  border: 1px solid var(--slate-600);
  border-radius: 4px;
  padding: 2px 6px;
  min-width: 52px;
  text-align: center;
}

.cmdk-result__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cmdk-result__text strong {
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmdk-result__text small {
  font-size: 0.76rem;
  color: var(--slate-400);
}

@media (max-width: 719px) {
  .cmdk-trigger__hint {
    display: none;
  }

  .cmdk-trigger {
    width: 34px;
    padding: 0;
    justify-content: center;
  }

  .cmdk-overlay {
    padding: 8vh 12px 12px;
  }
}

/* ==========================================================================
   Timeline hover/focus preview card
   ========================================================================== */

.timeline-preview {
  position: absolute;
  z-index: 20;
  width: 240px;
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--slate-850);
  border: 1px solid;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
  pointer-events: none;
  animation: preview-in 0.12s ease;
}

@keyframes preview-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.timeline-preview__art {
  flex-shrink: 0;
  width: 56px;
  height: 76px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--slate-800);
}

.timeline-preview__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.timeline-preview__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.timeline-preview__body strong {
  font-size: 0.92rem;
  line-height: 1.25;
}

.timeline-preview__meta {
  font-size: 0.72rem;
  color: var(--slate-400);
  margin: 2px 0 6px;
}

.timeline-preview__body p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--slate-200);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 719px) {
  .timeline-preview {
    display: none;
  }
}

/* ==========================================================================
   Timeline mode toggle
   ========================================================================== */

.timeline-mode-toggle {
  display: inline-flex;
  border: 1px solid var(--slate-600);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
}

.timeline-mode-toggle button {
  background: none;
  border: none;
  color: var(--slate-400);
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-body);
}

.timeline-mode-toggle button.active {
  background: var(--slate-800);
  color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 24px 0;
}

.chart-controls .filter-bar {
  margin: 0;
  flex: 1;
  min-width: 280px;
}

@media (max-width: 719px) {
  .chart-controls {
    flex-direction: column;
    align-items: stretch;
  }

  /* Only drives the horizontal SVG diagram (hidden below 719px);
     VerticalTimeline has no release-order layout, so showing this here
     would be a dead control that looks broken when tapped. */
  .timeline-mode-toggle {
    display: none;
  }
}
