/* ==========================================================================
   Daoist Timeline — Stylesheet
   Aesthetic: Taiping Heavenly Kingdom — dark void, imperial gold, celestial
   vermillion, heavenly radiance. 太平天國 maximalism.
   ========================================================================== */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=Ma+Shan+Zheng&family=Noto+Serif+SC:wght@400;600;700&display=swap');

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Skip link for keyboard accessibility */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: var(--void);
  padding: 8px 16px;
  border-radius: 0 0 6px 6px;
  z-index: 10000;
  font-size: 0.85rem;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

:root {
  /* === THE VOID — Heavenly Darkness === */
  --void: #060610;
  --void-warm: #0a0a1a;
  --void-light: #111128;
  --void-surface: #16162e;
  --void-elevated: #1c1c38;

  /* === IMPERIAL GOLD — 天命 Mandate of Heaven === */
  --gold: #c8943e;
  --gold-bright: #d4a84a;
  --gold-light: #e8c87a;
  --gold-pale: rgba(200, 148, 62, 0.15);
  --gold-glow: rgba(200, 148, 62, 0.4);
  --gold-dim: #a8882e;

  /* === VERMILLION — Imperial Seal Red === */
  --vermillion: #c23a22;
  --vermillion-light: #d9654f;
  --vermillion-dark: #8b2515;
  --vermillion-glow: rgba(194, 58, 34, 0.3);

  /* === CELESTIAL PALETTE === */
  --jade: #2d8d6e;
  --jade-light: #3fb89e;
  --indigo: #3a5a9c;
  --indigo-light: #5a7fc5;
  --plum: #7a4a7a;
  --plum-light: #9a6a9a;
  --cinnabar: #e04030;
  --azure: #4488cc;
  --parchment: #f5eed8;
  --parchment-soft: #e0d8c0;
  --parchment-dark: #d4c5a9;
  --parchment-dim: rgba(245, 238, 216, 0.08);

  /* === CATEGORY COLORS (celestial tones) === */
  --cat-proto: #9a8858;
  --cat-classical: #c84030;
  --cat-han: #4a6aac;
  --cat-six: #8a5a8a;
  --cat-tang: #3aa88e;
  --cat-song: #c8a040;
  --cat-ming: #a85a28;
  --cat-qing: #5a80b5;
  --cat-modern: #7a7060;

  /* === SPACING === */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  /* === TYPOGRAPHY === */
  --font-body: 'EB Garamond', 'Georgia', 'Times New Roman', serif;
  --font-display: 'Playfair Display', 'Georgia', serif;
  --font-chinese: 'Noto Serif SC', 'Ma Shan Zheng', 'Songti SC', serif;
  --font-chinese-brush: 'Ma Shan Zheng', 'Noto Serif SC', cursive;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* === TRANSITIONS === */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.25s;

  /* === LAYOUT === */
  --max-width: 1200px;
  --timeline-line: 2px;
  --node-size: 14px;
  --header-height: auto;

  /* === ORNAMENTAL === */
  --border-ornate: 1px solid rgba(200, 148, 62, 0.25);
  --border-ornate-strong: 1px solid rgba(200, 148, 62, 0.5);
  --shadow-celestial: 0 0 40px rgba(200, 148, 62, 0.08), 0 0 80px rgba(200, 148, 62, 0.04);
  --shadow-heavenly: 0 4px 30px rgba(0, 0, 0, 0.5), 0 0 60px rgba(200, 148, 62, 0.06);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--void);
  color: var(--parchment);
  line-height: 1.65;
  min-height: 100vh;
}

/* === THE HEAVENLY VOID — layered celestial background === */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    /* Divine radiance from above */
    radial-gradient(ellipse at 50% -20%, rgba(200, 148, 62, 0.06) 0%, transparent 60%),
    /* Vermillion seal glow */
    radial-gradient(circle at 15% 85%, rgba(194, 58, 34, 0.04) 0%, transparent 40%),
    /* Jade mist */
    radial-gradient(circle at 85% 60%, rgba(45, 141, 110, 0.03) 0%, transparent 40%),
    /* Deep indigo depth */
    radial-gradient(ellipse at 50% 100%, rgba(58, 90, 156, 0.04) 0%, transparent 50%);
  z-index: 0;
}

/* CRT scanline overlay — matching lab hub */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  z-index: 9999;
}

a { color: var(--gold-bright); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--gold-light); text-decoration: underline; }

/* === Custom scrollbar === */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--void); }
::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 4px;
  border: 2px solid var(--void);
}
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* === Selection === */
::selection {
  background: rgba(200, 148, 62, 0.3);
  color: var(--parchment);
}

/* ==========================================================================
   Header — 天國 Heavenly Kingdom Banner
   ========================================================================== */
.site-header {
  background: var(--void);
  color: var(--parchment);
  padding: var(--space-2xl) var(--space-lg) var(--space-xl);
  text-align: center;
  position: relative;
  overflow: hidden;
  border-bottom: 2px solid var(--gold-dim);
}

/* Heavenly radiance — divine light from above */
.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    /* Central heavenly beam */
    radial-gradient(ellipse at 50% 0%, rgba(200, 148, 62, 0.18) 0%, transparent 55%),
    /* Vermillion seal aura */
    radial-gradient(circle at 20% 80%, rgba(194, 58, 34, 0.08) 0%, transparent 40%),
    /* Gold mist right */
    radial-gradient(circle at 80% 70%, rgba(200, 148, 62, 0.06) 0%, transparent 35%),
    /* Deep void gradient */
    linear-gradient(180deg, rgba(6, 6, 16, 0) 0%, rgba(6, 6, 16, 0.5) 100%);
  pointer-events: none;
  z-index: 0;
}

/* Cloud pattern overlay (祥雲 auspicious clouds) */
.site-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 10% 90%, rgba(200, 148, 62, 0.05) 0%, transparent 25%),
    radial-gradient(ellipse at 30% 85%, rgba(200, 148, 62, 0.04) 0%, transparent 20%),
    radial-gradient(ellipse at 50% 95%, rgba(200, 148, 62, 0.03) 0%, transparent 22%),
    radial-gradient(ellipse at 70% 88%, rgba(200, 148, 62, 0.04) 0%, transparent 18%),
    radial-gradient(ellipse at 90% 92%, rgba(200, 148, 62, 0.05) 0%, transparent 25%),
    /* Upper clouds */
    radial-gradient(ellipse at 20% 10%, rgba(200, 148, 62, 0.03) 0%, transparent 20%),
    radial-gradient(ellipse at 60% 5%, rgba(200, 148, 62, 0.02) 0%, transparent 18%),
    radial-gradient(ellipse at 80% 15%, rgba(200, 148, 62, 0.03) 0%, transparent 22%);
  pointer-events: none;
  z-index: 0;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Ornamental top border — imperial edict style */
.header-ornament-top {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-bottom: var(--space-lg);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  color: var(--gold-dim);
  text-transform: uppercase;
}

.header-ornament-top::before,
.header-ornament-top::after {
  content: '';
  flex: 1;
  max-width: 200px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

/* Heavenly seal — 天命 */
.heavenly-seal {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-lg);
}

.seal-character {
  font-family: var(--font-chinese-brush);
  font-size: 3.5rem;
  color: var(--vermillion);
  text-shadow:
    0 0 20px rgba(194, 58, 34, 0.4),
    0 0 40px rgba(194, 58, 34, 0.2),
    0 2px 4px rgba(0, 0, 0, 0.5);
  line-height: 1;
  border: 3px solid var(--vermillion);
  padding: 0.3em 0.4em;
  position: relative;
}

.seal-character::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(194, 58, 34, 0.5);
}

.header-title h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-sm);
  color: var(--parchment);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.header-title h1 .header-divider {
  color: var(--gold);
  margin: 0 0.3em;
  font-weight: 300;
  text-shadow: 0 0 10px rgba(200, 148, 62, 0.3);
}

.subtitle {
  font-size: clamp(0.9rem, 1.8vw, 1.1rem);
  color: rgba(245, 238, 216, 0.75);
  font-style: italic;
  margin-bottom: var(--space-xs);
  letter-spacing: 0.02em;
}

.credit {
  font-size: 0.8rem;
  color: var(--gold-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Imperial banner divider */
.header-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin: var(--space-lg) 0 var(--space-sm);
  color: var(--gold-dim);
  font-family: var(--font-chinese);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
}

.header-banner::before,
.header-banner::after {
  content: '';
  width: 100px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.header-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-xl);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid rgba(200, 148, 62, 0.15);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-num {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  color: var(--gold-bright);
  line-height: 1;
  text-shadow: 0 0 20px rgba(200, 148, 62, 0.3);
}

.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(245, 238, 216, 0.4);
  margin-top: 0.3em;
}

/* Imperial proclamation ticker */
.header-ticker {
  margin-top: var(--space-lg);
  overflow: hidden;
  position: relative;
  height: 1.6rem;
  border-top: 1px solid rgba(200, 148, 62, 0.1);
  border-bottom: 1px solid rgba(200, 148, 62, 0.1);
  background: rgba(200, 148, 62, 0.03);
}

.header-ticker-inner {
  display: flex;
  white-space: nowrap;
  animation: ticker-scroll 60s linear infinite;
  font-family: var(--font-chinese);
  font-size: 0.8rem;
  color: var(--gold-dim);
  letter-spacing: 0.5em;
  line-height: 1.6rem;
  padding-left: 100%;
}

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ==========================================================================
   Controls Bar — Imperial Command Bar
   ========================================================================== */
.controls-bar {
  background: rgba(6, 6, 16, 0.95);
  border-bottom: 1px solid rgba(200, 148, 62, 0.2);
  padding: var(--space-sm) var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.controls-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: nowrap;
}

/* Search */
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold-dim);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 0.55rem 2.2rem 0.55rem 2.5rem;
  border: 1px solid rgba(200, 148, 62, 0.2);
  border-radius: 4px;
  background: var(--void-light);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--parchment);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 148, 62, 0.12);
}

.search-wrap input::placeholder {
  color: var(--gold-dim);
  opacity: 0.5;
}

.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--gold-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  display: none;
}

.clear-btn.visible { display: block; }
.clear-btn:hover { color: var(--gold-bright); }

/* Filters */
.filter-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.filter-wrap label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-dim);
  white-space: nowrap;
}

.filter-wrap select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid rgba(200, 148, 62, 0.2);
  border-radius: 4px;
  background: var(--void-light);
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--parchment);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9' fill='none' stroke='%23c8943e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.filter-wrap select:focus {
  outline: none;
  border-color: var(--gold);
}

.filter-wrap select option {
  background: var(--void-light);
  color: var(--parchment);
}

/* View Toggle */
.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--void-surface);
  border: 1px solid rgba(200, 148, 62, 0.15);
  border-radius: 4px;
  padding: 2px;
}

.view-btn {
  background: none;
  border: none;
  padding: 6px 10px;
  border-radius: 3px;
  cursor: pointer;
  color: var(--gold-dim);
  display: flex;
  align-items: center;
  transition: all var(--duration) var(--ease);
}

.view-btn:hover { color: var(--gold-bright); }
.view-btn.active {
  background: var(--void-elevated);
  color: var(--gold-bright);
  box-shadow: 0 0 10px rgba(200, 148, 62, 0.1);
}

/* Export Button */
.export-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid rgba(200, 148, 62, 0.2);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--gold-dim);
  white-space: nowrap;
  transition: all 0.15s;
  position: relative;
  font-family: var(--font-body);
}

.export-btn:hover {
  background: rgba(200, 148, 62, 0.08);
  color: var(--gold-bright);
  border-color: var(--gold);
}

.export-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--void-elevated);
  border: 1px solid rgba(200, 148, 62, 0.3);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 100;
  overflow: hidden;
}

.export-menu button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--parchment);
  text-align: left;
  white-space: nowrap;
  font-family: var(--font-body);
}

.export-menu button:hover {
  background: rgba(200, 148, 62, 0.1);
}

/* Result Count */
.result-count {
  font-size: 0.8rem;
  color: var(--gold-dim);
  margin-left: auto;
  white-space: nowrap;
}

/* ==========================================================================
   Era Navigation — Heavenly Dynasty Tabs
   ========================================================================== */
.era-nav {
  background: var(--void-warm);
  border-bottom: 1px solid rgba(200, 148, 62, 0.15);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.era-nav::-webkit-scrollbar { display: none; }

.era-nav-inner {
  display: flex;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
  gap: 0;
}

.era-tab {
  padding: 0.7rem 1rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--gold-dim);
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-body);
  border-bottom: 2px solid transparent;
  transition: all var(--duration) var(--ease);
  position: relative;
}

.era-tab:hover {
  color: var(--gold-bright);
  background: rgba(200, 148, 62, 0.04);
}

.era-tab.active {
  color: var(--gold-bright);
  border-bottom-color: var(--gold);
  text-shadow: 0 0 10px rgba(200, 148, 62, 0.3);
}

.era-tab .era-count {
  font-size: 0.7rem;
  color: var(--gold-dim);
  opacity: 0.5;
  margin-left: 4px;
}

/* ==========================================================================
   Timeline View — Imperial Scroll
   ========================================================================== */
.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg) var(--space-2xl);
  min-height: 60vh;
  position: relative;
  z-index: 1;
}

.timeline-container {
  position: relative;
}

/* Era Section */
.era-section {
  margin-bottom: var(--space-2xl);
  position: relative;
}

.era-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid rgba(200, 148, 62, 0.2);
  position: relative;
}

/* Ornamental corner flourish on era headers */
.era-header::before {
  content: '☰';
  position: absolute;
  left: -8px;
  top: -4px;
  font-size: 0.9rem;
  color: var(--gold-dim);
  opacity: 0.5;
}

.era-header h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--gold-bright);
  letter-spacing: 0.04em;
  text-shadow: 0 0 15px rgba(200, 148, 62, 0.15);
}

.era-header .era-chinese {
  font-family: var(--font-chinese);
  font-size: 1.1rem;
  color: var(--gold-dim);
}

.era-header .era-date-range {
  font-size: 0.85rem;
  color: var(--gold-dim);
  margin-left: auto;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* Timeline line — golden thread of heaven */
.era-timeline {
  position: relative;
  padding-left: 40px;
}

.era-timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: var(--timeline-line);
  background: linear-gradient(
    to bottom,
    rgba(200, 148, 62, 0.1),
    rgba(200, 148, 62, 0.4),
    rgba(200, 148, 62, 0.1)
  );
  border-radius: 1px;
}

/* Timeline Entry */
.timeline-entry {
  position: relative;
  margin-bottom: var(--space-lg);
  cursor: pointer;
  transition: transform var(--duration) var(--ease);
}

.timeline-entry:hover {
  transform: translateX(4px);
}

/* Node — celestial orb */
.timeline-entry::before {
  content: '';
  position: absolute;
  left: -40px;
  top: 6px;
  width: var(--node-size);
  height: var(--node-size);
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: var(--void);
  z-index: 2;
  transition: all var(--duration) var(--ease);
}

.timeline-entry:hover::before {
  background: var(--gold);
  box-shadow:
    0 0 0 4px rgba(200, 148, 62, 0.15),
    0 0 12px rgba(200, 148, 62, 0.3);
}

/* Connector line from node to card */
.timeline-entry::after {
  content: '';
  position: absolute;
  left: -26px;
  top: 12px;
  width: 20px;
  height: 1px;
  background: rgba(200, 148, 62, 0.2);
}

/* Card — Imperial edict scroll */
.entry-card {
  background: var(--void-surface);
  border: 1px solid rgba(200, 148, 62, 0.12);
  border-radius: 4px;
  padding: var(--space-md) var(--space-lg);
  transition: all var(--duration) var(--ease);
  position: relative;
}

/* Left gold accent border — like an imperial seal edge */
.entry-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--gold), var(--gold-dim), transparent);
  border-radius: 4px 0 0 4px;
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}

.timeline-entry:hover .entry-card {
  border-color: rgba(200, 148, 62, 0.3);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 30px rgba(200, 148, 62, 0.04);
}

.timeline-entry:hover .entry-card::before {
  opacity: 1;
}

.entry-card-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
  flex-wrap: wrap;
}

.entry-id {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold);
  min-width: 24px;
  font-family: var(--font-mono);
}

.entry-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--parchment);
  line-height: 1.3;
}

.entry-chinese {
  font-family: var(--font-chinese);
  font-size: 1rem;
  color: var(--gold-dim);
}

.entry-meta {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-top: var(--space-xs);
  font-size: 0.82rem;
  color: rgba(245, 238, 216, 0.7);
}

.entry-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.entry-date-badge {
  display: inline-block;
  background: var(--void-elevated);
  color: var(--gold-bright);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 2px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  border: 1px solid rgba(200, 148, 62, 0.15);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-category-badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 1px 8px;
  border-radius: 2px;
  border: 1px solid currentColor;
  opacity: 0.7;
}

.entry-school-badge {
  display: inline-block;
  font-size: 0.68rem;
  padding: 1px 7px;
  border-radius: 2px;
  background: var(--jade);
  color: white;
  opacity: 0.8;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.entry-notes {
  font-size: 0.88rem;
  line-height: 1.6;
  color: rgba(245, 238, 216, 0.78);
  margin-top: var(--space-sm);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   Grid View
   ========================================================================== */
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.grid-container .era-section {
  grid-column: 1 / -1;
  margin-bottom: var(--space-md);
}

.grid-container .era-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-md);
  padding-left: 0;
}

.grid-container .era-timeline::before { display: none; }
.grid-container .timeline-entry::before { display: none; }
.grid-container .timeline-entry::after { display: none; }

.grid-container .timeline-entry {
  margin-bottom: 0;
}

.grid-container .timeline-entry:hover {
  transform: translateY(-3px);
}

.grid-container .entry-card {
  height: 100%;
}

/* ==========================================================================
   Detail Panel — Imperial Decree Modal
   ========================================================================== */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 16, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration) var(--ease), visibility var(--duration) var(--ease);
  backdrop-filter: blur(8px);
}

.detail-overlay.open {
  opacity: 1;
  visibility: visible;
}

.detail-panel {
  background: var(--void-surface);
  border: 1px solid rgba(200, 148, 62, 0.3);
  border-radius: 4px;
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--space-xl);
  position: relative;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 80px rgba(200, 148, 62, 0.06),
    inset 0 1px 0 rgba(200, 148, 62, 0.1);
  transform: translateY(20px);
  transition: transform var(--duration) var(--ease);
}

/* Imperial decree top border */
.detail-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    transparent,
    var(--gold-dim),
    var(--gold),
    var(--gold-dim),
    transparent
  );
}

.detail-overlay.open .detail-panel {
  transform: translateY(0);
}

.detail-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gold-dim);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--duration) var(--ease);
}

.detail-close:hover {
  background: rgba(200, 148, 62, 0.1);
  color: var(--gold-bright);
}

.detail-content h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--parchment);
  margin-bottom: var(--space-xs);
  padding-right: var(--space-xl);
}

.detail-content .detail-chinese {
  font-family: var(--font-chinese);
  font-size: 1.4rem;
  color: var(--gold-bright);
  margin-bottom: var(--space-md);
  text-shadow: 0 0 10px rgba(200, 148, 62, 0.2);
}

.detail-content .detail-badges {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
}

.detail-field {
  margin-bottom: var(--space-md);
}

.detail-field-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-dim);
  margin-bottom: 2px;
}

.detail-field-value {
  font-size: 0.95rem;
  color: var(--parchment);
  line-height: 1.6;
}

.detail-field-value a {
  color: var(--gold-bright);
}

.detail-divider {
  border: none;
  border-top: 1px solid rgba(200, 148, 62, 0.15);
  margin: var(--space-lg) 0;
}

.detail-notes {
  font-size: 0.95rem;
  line-height: 1.75;
  color: rgba(245, 238, 216, 0.85);
}

/* Related texts */
.related-texts-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.related-link {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.82rem;
  border: 1px solid rgba(200, 148, 62, 0.2);
  border-radius: 3px;
  background: var(--void-elevated);
  color: var(--parchment);
  text-decoration: none;
  transition: all 0.15s ease;
}

.related-link:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--void);
  text-decoration: none;
}

.related-zh {
  font-size: 0.75rem;
  opacity: 0.6;
  margin-left: 3px;
}

/* Navigation arrows in detail */
.detail-nav {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid rgba(200, 148, 62, 0.15);
}

.detail-nav-btn {
  background: none;
  border: 1px solid rgba(200, 148, 62, 0.2);
  border-radius: 4px;
  padding: 0.4rem 1rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--gold-dim);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.detail-nav-btn:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  box-shadow: 0 0 10px rgba(200, 148, 62, 0.1);
}

.detail-nav-btn:disabled {
  opacity: 0.2;
  cursor: default;
}

/* ==========================================================================
   Back to Top — Ascend to Heaven
   ========================================================================== */
.back-to-top {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--void-elevated);
  color: var(--gold);
  border: 1px solid rgba(200, 148, 62, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration) var(--ease);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 50;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background: var(--gold);
  color: var(--void);
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(200, 148, 62, 0.3);
}

/* ==========================================================================
   Footer — Heavenly Colophon
   ========================================================================== */
.site-footer {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  border-top: 1px solid rgba(200, 148, 62, 0.15);
  color: var(--gold-dim);
  font-size: 0.85rem;
  position: relative;
  z-index: 1;
}

.site-footer::before {
  content: '~ 天道無親 常與善人 ~';
  display: block;
  font-family: var(--font-chinese);
  font-size: 0.9rem;
  color: rgba(200, 148, 62, 0.25);
  letter-spacing: 0.3em;
  margin-bottom: var(--space-md);
}

.footer-small {
  font-size: 0.75rem;
  margin-top: var(--space-xs);
  opacity: 0.5;
}

.footer-small code {
  font-family: var(--font-mono);
  background: var(--void-surface);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.72rem;
  color: var(--gold-dim);
}

/* ==========================================================================
   Empty / No Results State
   ========================================================================== */
.no-results {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--gold-dim);
}

.no-results h3 {
  font-size: 1.2rem;
  font-weight: 400;
  margin-bottom: var(--space-sm);
  color: var(--gold-bright);
}

.no-results p {
  font-size: 0.9rem;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Celestial glow pulse */
@keyframes celestialPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Heavenly shimmer for gold elements */
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.timeline-entry {
  animation: fadeInUp 0.4s var(--ease) both;
}

.era-section:nth-child(1) .timeline-entry { animation-delay: 0s; }
.era-section:nth-child(2) .timeline-entry { animation-delay: 0.05s; }

/* Staggered entry within era */
.timeline-entry:nth-child(1) { animation-delay: 0s; }
.timeline-entry:nth-child(2) { animation-delay: 0.03s; }
.timeline-entry:nth-child(3) { animation-delay: 0.06s; }
.timeline-entry:nth-child(4) { animation-delay: 0.09s; }
.timeline-entry:nth-child(5) { animation-delay: 0.12s; }
.timeline-entry:nth-child(6) { animation-delay: 0.15s; }
.timeline-entry:nth-child(7) { animation-delay: 0.18s; }
.timeline-entry:nth-child(8) { animation-delay: 0.21s; }
.timeline-entry:nth-child(9) { animation-delay: 0.24s; }
.timeline-entry:nth-child(10) { animation-delay: 0.27s; }

/* Highlight on search match */
.entry-card.highlight {
  border-color: var(--gold);
  background: rgba(200, 148, 62, 0.06);
}

mark {
  background: rgba(200, 148, 62, 0.3);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

/* ==========================================================================
   Timeline Minimap
   ========================================================================== */
.minimap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-sm) var(--space-lg) var(--space-md);
  background: var(--void-warm);
  border-bottom: 1px solid rgba(200, 148, 62, 0.1);
  position: relative;
  z-index: 1;
}

.minimap-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-dim);
  margin-bottom: var(--space-xs);
}

.minimap-track {
  position: relative;
  height: 40px;
  background: var(--void-surface);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(200, 148, 62, 0.08);
}

.minimap-era-band {
  position: absolute;
  bottom: 0;
  height: 100%;
  opacity: 0.1;
}

.minimap-bar {
  position: absolute;
  bottom: 0;
  background: var(--gold);
  opacity: 0.6;
  border-radius: 1px 1px 0 0;
  transition: opacity 0.15s ease;
  cursor: default;
}

.minimap-bar:hover {
  opacity: 1;
  box-shadow: 0 0 8px rgba(200, 148, 62, 0.4);
}

.minimap-labels {
  position: relative;
  height: 16px;
  margin-top: 2px;
}

.minimap-era-label {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--gold-dim);
  opacity: 0.6;
  white-space: nowrap;
}

.minimap-markers {
  position: relative;
  height: 14px;
}

.minimap-marker {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-family: var(--font-mono);
  color: var(--gold-dim);
  opacity: 0.4;
}

/* ==========================================================================
   Statistics Dashboard — Celestial Census
   ========================================================================== */
.stats-dashboard {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
}

.stats-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--gold-bright);
  margin-bottom: var(--space-xs);
  text-shadow: 0 0 15px rgba(200, 148, 62, 0.15);
}

.stats-subtitle {
  color: var(--gold-dim);
  font-size: 0.9rem;
  margin-bottom: var(--space-xl);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.stat-card {
  background: var(--void-surface);
  border: 1px solid rgba(200, 148, 62, 0.12);
  border-radius: 4px;
  padding: var(--space-lg);
}

.stat-card h3 {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gold-bright);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-card-wide {
  grid-column: 1 / -1;
}

/* Bar charts */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-label {
  min-width: 120px;
  font-size: 0.78rem;
  color: rgba(245, 238, 216, 0.8);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 18px;
  background: var(--void-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.era-bar { background: var(--gold); opacity: 0.7; }
.school-bar { background: var(--jade); opacity: 0.7; }
.cat-bar { background: var(--vermillion); opacity: 0.7; }

.bar-value {
  min-width: 28px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold-bright);
  text-align: right;
}

/* Density chart */
.density-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 140px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(200, 148, 62, 0.1);
}

.density-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.density-bar {
  width: 100%;
  background: var(--gold);
  opacity: 0.6;
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
}

.density-bar-wrap:hover .density-bar {
  opacity: 1;
  box-shadow: 0 0 8px rgba(200, 148, 62, 0.4);
}

.density-label {
  font-size: 0.6rem;
  color: var(--gold-dim);
  position: absolute;
  bottom: -20px;
  white-space: nowrap;
}

.density-bar-wrap:nth-child(odd) .density-label { display: none; }

.density-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--gold-dim);
  margin-top: var(--space-sm);
}

/* Connected list */
.connected-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.connected-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
}

.connected-item:hover {
  background: rgba(200, 148, 62, 0.06);
}

.connected-count {
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  color: var(--void);
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 600;
}

.connected-title {
  font-size: 0.82rem;
  color: var(--parchment);
  flex: 1;
}

.connected-zh {
  font-size: 0.75rem;
  color: var(--gold-dim);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
  .controls-inner {
    flex-wrap: wrap;
  }

  .search-wrap {
    max-width: 100%;
    flex-basis: 100%;
  }

  .filter-wrap select {
    flex: 1;
  }

  .result-count {
    margin-left: auto;
  }

  .header-stats {
    gap: var(--space-lg);
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .bar-label {
    min-width: 80px;
    font-size: 0.7rem;
  }

  .era-timeline {
    padding-left: 30px;
  }

  .timeline-entry::before {
    left: -30px;
    width: 10px;
    height: 10px;
  }

  .timeline-entry::after {
    left: -20px;
    width: 14px;
  }

  .entry-card {
    padding: var(--space-md);
  }

  .detail-panel {
    padding: var(--space-lg);
    max-height: 90vh;
    border-radius: 4px;
  }

  .grid-container .era-timeline {
    grid-template-columns: 1fr;
  }

  .seal-character {
    font-size: 2.5rem;
  }

  .header-banner {
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .minimap { display: none; }

  .header-title h1 {
    font-size: 1.5rem;
  }

  .stat-num {
    font-size: 1.5rem;
  }

  .era-nav-inner {
    padding: 0 var(--space-sm);
  }

  .era-tab {
    padding: 0.6rem 0.7rem;
    font-size: 0.75rem;
  }

  .main {
    padding: var(--space-lg) var(--space-md);
  }

  .detail-overlay {
    padding: var(--space-sm);
  }

  .header-ticker { display: none; }
  .header-ornament-top { display: none; }

  .seal-character {
    font-size: 2rem;
    padding: 0.2em 0.3em;
  }
}

/* Print */
@media print {
  .controls-bar, .era-nav, .back-to-top, .detail-overlay, .header-ticker { display: none !important; }
  body { background: white; color: black; }
  body::before, body::after { display: none; }
  .site-header { background: white; color: black; border-bottom-color: #333; }
  .site-header::before, .site-header::after { display: none; }
  .entry-card { background: white; border-color: #ccc; }
  .timeline-entry { break-inside: avoid; }
  .site-footer::before { display: none; }
}
