/* ─────────────────────────── Design tokens ───────────────────────────
   Warm Museum Palette: parchment background, museum navy primary,
   discovery amber accent, with five domain colors used as the page-
   level personality cue. Never neon, never candy. Curiosity ≠ cartoon.
─────────────────────────────────────────────────────────────────────── */

:root {
  /* surfaces */
  --bg:           #F7F1E5;          /* parchment */
  --bg-elev:      #FFFDF8;          /* warm white card */
  --bg-soft:      #EFE5D0;          /* soft surface for chips, blocks */
  --bg-hero:      linear-gradient(180deg, #F7F1E5 0%, #ECE0C7 100%);

  /* ink */
  --ink:          #263238;          /* deep slate */
  --ink-soft:     #3E4750;
  --ink-muted:    #6B7280;

  /* primary — museum navy */
  --primary:      #1E3A5F;
  --primary-soft: #DCE8F5;
  --primary-ink:  #0E1F36;

  /* accent — discovery amber */
  --accent:       #D99A29;
  --accent-soft:  #F8E8C7;
  --accent-ink:   #6A430B;

  /* domain colors (chip / hero tints) */
  --d-history:    #B86B4B; --d-history-soft: #F3D9CC; --d-history-ink: #7A3F2A;
  --d-art:        #1E3A5F; --d-art-soft:     #DCE8F5; --d-art-ink:     #0E1F36;
  --d-science:    #7A9B76; --d-science-soft: #E4F0DF; --d-science-ink: #3E5F3B;
  --d-tech:       #78A6C8; --d-tech-soft:    #DCE8F5; --d-tech-ink:    #2C5878;
  --d-culture:    #D99A29; --d-culture-soft: #F8E8C7; --d-culture-ink: #6A430B;

  /* borders & rings */
  --border:        #E8DCC8;
  --border-strong: #D4C0A0;
  --ring:          rgba(30, 58, 95, 0.22);

  /* legacy aliases (a few templates still reference these) */
  --surface-hi: var(--bg-elev);

  /* shadow — soft, navy-tinted */
  --shadow-sm: 0 1px 2px rgba(30, 58, 95, 0.05), 0 2px 6px rgba(30, 58, 95, 0.06);
  --shadow-md: 0 8px 24px rgba(30, 58, 95, 0.08), 0 2px 4px rgba(30, 58, 95, 0.05);
  --shadow-lg: 0 24px 60px rgba(30, 58, 95, 0.14);

  --radius-sm: 10px;
  --radius:    16px;
  --radius-lg: 20px;
  --ease:     cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --bg:           #0F1620;          /* deep navy-tinted */
  --bg-elev:      #182233;
  --bg-soft:      #1F2B3F;
  --bg-hero:      linear-gradient(180deg, #0F1620 0%, #1A2638 100%);

  --ink:          #F0E9D8;          /* warm parchment ink */
  --ink-soft:     #C9C2B0;
  --ink-muted:    #8E8F99;

  --primary:      #78A6C8;          /* lifted navy → sky for contrast */
  --primary-soft: rgba(120, 166, 200, 0.18);
  --primary-ink:  #C8E0EE;

  --accent:       #E9B763;
  --accent-soft:  rgba(217, 154, 41, 0.18);
  --accent-ink:   #F3D0A3;

  --d-history:    #D08F6E; --d-history-soft: rgba(184, 107, 75, 0.20); --d-history-ink: #E8B499;
  --d-art:        #97B7DA; --d-art-soft:     rgba(30, 58, 95, 0.30);   --d-art-ink:     #C8DAEE;
  --d-science:    #9DBE99; --d-science-soft: rgba(122, 155, 118, 0.18); --d-science-ink: #C7DEC4;
  --d-tech:       #9CC4DF; --d-tech-soft:    rgba(120, 166, 200, 0.18); --d-tech-ink:    #C7DEEC;
  --d-culture:    #E9B763; --d-culture-soft: rgba(217, 154, 41, 0.18); --d-culture-ink: #F3D0A3;

  --border:        #2C3850;
  --border-strong: #3D4B66;
  --ring:          rgba(120, 166, 200, 0.32);

  --surface-hi: var(--bg-elev);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* legacy aliases for old code paths */
:root, [data-theme="dark"] {
  /* the old code uses --accent/--accent-soft/--accent-ink already; kept */
}

/* ─────────────────────────── Base ─────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease);
}

h1, h2, h3, h4, h5 {
  font-family: 'Fraunces', 'Playfair Display', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--ink);
  margin: 0;
}

h1 { font-size: clamp(2rem, 4.2vw, 3.25rem); }
h2 { font-size: clamp(1.5rem, 2.8vw, 2.1rem); }
h3 { font-size: 1.15rem; font-weight: 600; }

p { margin: 0; color: var(--ink-soft); }
p.muted { color: var(--ink-muted); }

a { color: var(--accent-ink); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent); }

code {
  font-family: 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 0.9em;
  background: var(--bg-soft);
  padding: 0.1em 0.4em;
  border-radius: 6px;
  color: var(--ink);
}

img { max-width: 100%; height: auto; display: block; }

::selection { background: var(--accent-soft); color: var(--ink); }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 1rem;
  top: 1rem;
  background: var(--ink);
  color: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  z-index: 1000;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2rem);
}

.eyebrow {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin: 0 0 0.75rem;
}

.muted { color: var(--ink-muted); }

/* ─────────────────────────── Buttons ─────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.25rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease),
    background-color 0.18s, color 0.18s, border-color 0.18s;
  text-decoration: none;
  font-family: inherit;
}
.btn-sm { padding: 0.55rem 1rem; font-size: 0.88rem; }

.btn-primary {
  background: var(--primary);
  color: #FFFDF8;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  background: var(--primary-ink);
  color: #FFFDF8;
}

.btn-amber {
  background: var(--accent);
  color: #2B2111;
  box-shadow: var(--shadow-sm);
}
.btn-amber:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  filter: brightness(1.04);
  color: #2B2111;
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Domain skin utilities ──
   Apply .domain-history etc. on a container; the class re-binds the
   primary/accent variables locally so any descendant using them gets
   tinted automatically (chips, hero gradients, buttons). */
.domain-history { --d-active: var(--d-history); --d-active-soft: var(--d-history-soft); --d-active-ink: var(--d-history-ink); }
.domain-art     { --d-active: var(--d-art);     --d-active-soft: var(--d-art-soft);     --d-active-ink: var(--d-art-ink); }
.domain-science { --d-active: var(--d-science); --d-active-soft: var(--d-science-soft); --d-active-ink: var(--d-science-ink); }
.domain-tech, .domain-technology { --d-active: var(--d-tech); --d-active-soft: var(--d-tech-soft); --d-active-ink: var(--d-tech-ink); }
.domain-culture { --d-active: var(--d-culture); --d-active-soft: var(--d-culture-soft); --d-active-ink: var(--d-culture-ink); }

.domain-chip {
  --d-active: var(--accent);
  --d-active-soft: var(--accent-soft);
  --d-active-ink: var(--accent-ink);
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .22rem .65rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 500;
  background: var(--d-active-soft);
  color: var(--d-active-ink);
  border: 1px solid color-mix(in srgb, var(--d-active) 30%, transparent);
  letter-spacing: 0.01em;
}

/* ─────────────────────────── Header ─────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 0.9rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
}
.brand:hover { color: var(--ink); }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary);
  color: var(--accent);
}
.brand-mark svg { width: 20px; height: 20px; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-text strong {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-text small {
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  justify-content: center;
}
.nav a {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-soft);
}
.nav a:hover {
  background: var(--bg-soft);
  color: var(--ink);
}
.nav a.active {
  background: var(--primary-soft);
  color: var(--primary);
}
.nav a.active:hover { color: var(--primary); background: var(--primary-soft); }

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  color: var(--ink-soft);
  background: transparent;
  transition: background-color .15s, color .15s;
}
.nav-icon:hover { background: var(--bg-soft); color: var(--primary); }
.nav-icon svg { width: 18px; height: 18px; }

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .25rem .25rem .75rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-size: .85rem;
  font-weight: 500;
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  text-decoration: none;
}
.user-pill:hover { color: var(--primary-ink); }
.user-pill-name { font-weight: 600; }
.user-pill-out {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--primary-ink);
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.user-pill-out:hover { background: rgba(255, 255, 255, 0.55); }
.user-pill-anon {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--ink-soft);
  padding: .25rem .85rem;
}
.user-pill-anon:hover { border-color: var(--primary); color: var(--primary); }

/* Language toggle in the header. */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 44px;
  padding: 0 .65rem;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--ink-soft);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
}
.lang-toggle:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* Tri-lingual visibility — hides UI labels and content blocks whose
   data-lang doesn't match the active <html lang>.
   - UI labels emit three spans (data-lang="en"/"zh-CN"/"zh-TW")
   - Content cards/pages emit a generic data-lang="en" or "zh"; ZH content
     stays visible under both Chinese variants because the language detector
     can't reliably distinguish CN vs TW. */
html[lang="en"] [data-lang="zh"],
html[lang="en"] [data-lang="zh-CN"],
html[lang="en"] [data-lang="zh-TW"],
html[lang="zh-CN"] [data-lang="en"],
html[lang="zh-CN"] [data-lang="zh-TW"],
html[lang="zh-TW"] [data-lang="en"],
html[lang="zh-TW"] [data-lang="zh-CN"] {
  display: none !important;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.theme-toggle:hover { border-color: var(--border-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
.icon-sun { display: none; }
.icon-moon { display: inline; }
[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }

/* ─────────────────────────── Hero ─────────────────────────── */

.hero {
  padding: clamp(3rem, 8vw, 6rem) 0 clamp(2rem, 5vw, 4rem);
  background: var(--bg-hero);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

.hero-copy h1 em {
  font-style: italic;
  color: var(--accent-ink);
  font-weight: 500;
}

.hero-copy .lede {
  font-size: 1.12rem;
  color: var(--ink-soft);
  margin-top: 1.25rem;
  max-width: 46ch;
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 2.75rem 0 0;
}
.hero-stats > div {
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.hero-stats dt {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}
.hero-stats dd {
  margin: 0.4rem 0 0;
  font-family: 'Fraunces', serif;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}
.hero-stats .dd-sm {
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
  line-height: 1.3;
}

/* Hero decorative art — stacked cards with soft gold glow */
.hero-art {
  position: relative;
  aspect-ratio: 4 / 4.3;
  min-height: 320px;
}
.hc {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  box-shadow: var(--shadow-md);
}
.hc1 {
  inset: 12% 18% 18% 0;
  background: linear-gradient(135deg, #d8a866 0%, #b07a39 100%);
  border: none;
  transform: rotate(-6deg);
}
.hc2 {
  inset: 6% 8% 22% 12%;
  background: var(--bg-elev);
  transform: rotate(2deg);
  background-image: radial-gradient(circle at 25% 30%, color-mix(in srgb, var(--accent) 30%, transparent) 0%, transparent 55%);
}
.hc3 {
  inset: 20% 0 4% 22%;
  background: linear-gradient(150deg, var(--ink) 0%, #2a241b 100%);
  transform: rotate(-2deg);
  color: var(--bg);
  background-image: linear-gradient(150deg, var(--ink) 0%, #2a241b 100%),
    radial-gradient(circle at 70% 70%, color-mix(in srgb, var(--accent) 80%, transparent) 0%, transparent 45%);
  background-blend-mode: normal;
}
.hc-glow {
  position: absolute;
  right: -5%;
  bottom: -10%;
  width: 65%;
  aspect-ratio: 1;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 40%, transparent) 0%, transparent 60%);
  filter: blur(30px);
  pointer-events: none;
}

/* ─────────────────────────── Sections ─────────────────────────── */

.section-head {
  margin-bottom: 2.5rem;
  max-width: 42rem;
}
.section-head h2 { margin-top: 0.25rem; }

.features { padding: clamp(3rem, 6vw, 5rem) 0; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

.feature {
  padding: 1.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s;
}
.feature:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--accent-ink);
  margin-bottom: 1rem;
}
.feature-icon svg { width: 22px; height: 22px; }
.feature h3 { margin-bottom: 0.4rem; }
.feature p { font-size: 0.95rem; }

/* API section */
.api { padding: clamp(3rem, 6vw, 5rem) 0 clamp(4rem, 8vw, 6rem); background: var(--bg-soft); border-top: 1px solid var(--border); }

.endpoints {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}
.endpoints li {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 1.25rem;
  align-items: start;
  padding: 1.25rem 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.method {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.35rem 0;
  border-radius: 8px;
  color: #fff;
  margin-top: 0.25rem;
}
.method-get { background: #4a6b8f; }
.method-post { background: var(--accent); color: #1a1208; }
.endpoint-path {
  display: inline-block;
  font-size: 0.95rem;
  background: transparent;
  padding: 0;
  color: var(--ink);
}
.endpoints p { margin-top: 0.35rem; font-size: 0.92rem; }

/* ─────────────────────────── List page ─────────────────────────── */

.list { padding: clamp(2.5rem, 5vw, 4rem) 0 5rem; }

.list-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.list-title h1 { margin: 0.25rem 0 0.35rem; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.4rem 0.3rem 1rem;
  box-shadow: var(--shadow-sm);
  min-width: min(360px, 90vw);
  transition: border-color 0.18s, box-shadow 0.18s;
}
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}
.search .search-icon {
  width: 18px; height: 18px;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.55rem 0.25rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  outline: none;
}
.search input::placeholder { color: var(--ink-muted); }
.search-clear {
  display: inline-flex;
  width: 24px; height: 24px;
  align-items: center; justify-content: center;
  border-radius: 999px;
  color: var(--ink-muted);
  font-size: 1.2rem;
  line-height: 1;
  text-decoration: none;
}
.search-clear:hover { background: var(--bg-soft); color: var(--ink); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s;
  cursor: zoom-in;
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.card-media {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-soft);
}
.card-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease);
}
.card:hover .card-media img {
  transform: scale(1.04);
}

.card-body { padding: 1rem 1.1rem 1.1rem; flex: 1; display: flex; flex-direction: column; gap: 0.55rem; }

.card-response {
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.card-meta {
  margin-top: auto;
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* Empty state */
.empty {
  grid-column: 1 / -1;
  padding: 4rem 1rem;
  text-align: center;
  background: var(--bg-elev);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty-illo {
  display: inline-flex;
  margin-bottom: 1rem;
  color: var(--ink-muted);
}
.empty-illo svg { width: 56px; height: 56px; }
.empty h3 { margin-bottom: 0.5rem; }
.empty p { color: var(--ink-muted); max-width: 36ch; margin: 0 auto; }

/* ─────────────────────────── Pagination ─────────────────────────── */

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 0.85rem;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  font-variant-numeric: tabular-nums;
}
.page-link:hover {
  background: var(--bg-soft);
  color: var(--ink);
  border-color: var(--border-strong);
}
.page-link.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.page-link.disabled {
  color: var(--ink-muted);
  background: transparent;
  border-color: transparent;
  cursor: not-allowed;
}
.pagination .gap {
  color: var(--ink-muted);
  padding: 0 0.25rem;
}

/* ─────────────────────────── Lightbox ─────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  /* 9999 sits comfortably above Leaflet's control layers (which top out
     around 1000) and our sticky page chrome. */
  z-index: 9999;
  background: rgba(10, 8, 5, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  animation: lightbox-in 0.25s var(--ease-out);
}
.lightbox[hidden] { display: none; }

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

.lightbox-figure {
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}
.lightbox-figure img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: lightbox-img 0.35s var(--ease-out);
}
@keyframes lightbox-img {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.lightbox-figure figcaption {
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.95rem;
  max-width: 60ch;
  text-align: center;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  align-items: center;
}
.lightbox-figure figcaption:empty { display: none; }
.lightbox-open {
  display: inline-block;
  padding: .35rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #FFFDF8;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.22);
  transition: background .15s, transform .15s;
}
.lightbox-open:hover { background: rgba(255, 255, 255, 0.24); color: #FFFDF8; transform: translateY(-1px); }
.lightbox-open[hidden] { display: none; }

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.2); transform: scale(1.05); }
.lightbox-close svg { width: 20px; height: 20px; }

/* ─────────────────────────── Error page ─────────────────────────── */

.error-screen {
  padding: clamp(4rem, 10vw, 8rem) 0;
}
.error-inner {
  max-width: 44rem;
}
.error-detail {
  margin: 1.5rem 0 2rem;
  padding: 1rem 1.25rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.88rem;
  color: var(--ink-soft);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ─────────────────────────── Footer ─────────────────────────── */

.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
  flex-wrap: wrap;
}
.footer-inner .dot { opacity: 0.5; }

/* ─────────────────────────── Animations ─────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  .feature, .card, .hero-stats > div {
    opacity: 0;
    transform: translateY(12px);
    animation: enter 0.6s var(--ease-out) forwards;
  }
  .card:nth-child(n+4) { animation-delay: 0.05s; }
  .card:nth-child(n+7) { animation-delay: 0.1s; }
}
@keyframes enter {
  to { opacity: 1; transform: translateY(0); }
}

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

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { min-height: 240px; max-width: 28rem; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .list-header { flex-direction: column; align-items: stretch; }
  .search { min-width: 0; }
  .endpoints li { grid-template-columns: 64px 1fr; gap: 0.9rem; padding: 1rem 1.1rem; }
}

@media (max-width: 560px) {
  .nav { display: none; }
  .header-inner { gap: 0.75rem; }
  .hero-ctas { flex-direction: column; align-items: stretch; }
  .hero-ctas .btn { justify-content: center; }
  .grid { grid-template-columns: 1fr; gap: 1rem; }
  .hero-stats { grid-template-columns: 1fr 1fr; }
}
