/* Spark Index — minimal, dark-first, 8px grid. */
:root {
  --bg: #111312;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #edede8;
  --muted: #a6a6a0;
  --accent: #e0ff98;
  --accent-ink: #111312;
  --accent-text: #e0ff98;
  --dot: 224, 255, 152;
  --dot-base: 237, 237, 232;
  --shadow: 0 24px 48px -24px rgba(0, 0, 0, 0.6);
  --radius: 16px;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f5f1;
    --surface: rgba(255, 255, 255, 0.7);
    --surface-hover: #fff;
    --line: rgba(17, 19, 18, 0.1);
    --line-strong: rgba(17, 19, 18, 0.24);
    --text: #161716;
    --muted: #5b5c57;
    --accent: #e0ff98;
    --accent-ink: #111312;
    --accent-text: #3f5a00;
    --dot: 92, 128, 0;
    --dot-base: 22, 23, 22;
    --shadow: 0 24px 48px -28px rgba(17, 19, 18, 0.25);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
    --bg: #f6f5f1;
    --surface: rgba(255, 255, 255, 0.7);
    --surface-hover: #fff;
    --line: rgba(17, 19, 18, 0.1);
    --line-strong: rgba(17, 19, 18, 0.24);
    --text: #161716;
    --muted: #5b5c57;
    --accent: #e0ff98;
    --accent-ink: #111312;
    --accent-text: #3f5a00;
    --dot: 92, 128, 0;
    --dot-base: 22, 23, 22;
    --shadow: 0 24px 48px -28px rgba(17, 19, 18, 0.25);
    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.top, main, .foot { position: relative; z-index: 1; }

/* ---------- Header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 32px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
.brand { line-height: 0; }
/* Logo: icon and "Spark" take the accent (lime on dark, olive on light), "Index" takes the text color. */
.logo { height: 24px; width: auto; display: block; overflow: visible; }
.logo-icon, .logo-spark { fill: var(--accent-text); }
.logo-index { fill: var(--text); }
.logo-ray { transform-box: fill-box; transform-origin: center; }
/* The three rays flicker in turn while a search runs. */
body[data-state="loading"] .logo-ray { animation: ray 900ms ease-in-out infinite; }
body[data-state="loading"] .logo-ray-2 { animation-delay: 150ms; }
body[data-state="loading"] .logo-ray-3 { animation-delay: 300ms; }
@keyframes ray { 50% { opacity: .25; transform: scale(.8); } }
@media (prefers-reduced-motion: reduce) { .logo-ray { animation: none !important; } }
.top-link { color: var(--muted); text-decoration: none; font-size: 14px; }
.top-link:hover { color: var(--text); }
.top-end { display: flex; align-items: center; gap: 16px; }
/* Light/dark toggle: sun shows in dark mode (switch to light), moon in light mode. */
.theme-toggle {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--muted); cursor: pointer;
  transition: color .2s, border-color .2s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--line-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="dark"]) .theme-toggle .moon { display: block; }
}

/* ---------- Hero / ask ---------- */
main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 32px; }
.hero {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 18vh 0 48px;
  transition: padding 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.eyebrow { margin: 0 0 16px; color: var(--muted); font-size: 14px; letter-spacing: 0.02em; }
h1 {
  margin: 0 0 40px;
  font: 400 clamp(48px, 8vw, 88px)/1 var(--serif);
  letter-spacing: -0.02em;
  transition: font-size 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), margin 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s;
}
h1 em { font-style: italic; color: var(--accent-text); }

.ask {
  position: relative; width: 100%; max-width: 640px;
  display: flex; align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  transition: border-color 0.2s;
}
.ask:focus-within { border-color: var(--accent-text); }
.ask input {
  flex: 1; min-width: 0;
  padding: 16px 8px 16px 24px;
  font-size: 18px;
  background: none; border: 0; outline: 0;
}
.ask input::placeholder { color: var(--muted); opacity: 0.8; }
.ask input::-webkit-search-cancel-button { display: none; }
.ask-go {
  flex: none; display: grid; place-items: center;
  width: 48px; height: 48px; margin: 4px;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  cursor: pointer;
  transition: transform 0.15s ease-out;
}
.ask-go:active { transform: scale(0.94); }
/* Sparks that fly out of the search button when a search starts. */
.ask-go, .example { position: relative; }
.spark { position: absolute; left: 50%; top: 50%; z-index: 50; width: 16px; height: 16px; pointer-events: none; fill: var(--accent-text); }
.spark svg { display: block; width: 100%; height: 100%; }

.examples { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 640px; margin-top: 24px; }
.example {
  padding: 8px 16px; border-radius: 999px;
  background: none; border: 1px solid var(--line);
  color: var(--muted); font-size: 14px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.example:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface); }

/* Results mode: the ask bar moves up, the title steps aside. */
body:not([data-state="empty"]) .hero { padding: 8px 0 32px; }
body:not([data-state="empty"]) h1 { font-size: 0; margin: 0; opacity: 0; }
body:not([data-state="empty"]) .eyebrow,
body:not([data-state="empty"]) .examples { display: none; }

/* ---------- Answer ---------- */
.answer { padding-bottom: 64px; }
.answer-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 14px;
}
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; width: 24px; height: 24px; border-radius: 50%; }
.chip button:hover { color: var(--text); background: var(--surface-hover); }
.chip-prev { color: var(--muted); }
.interpreted { margin: 0; color: var(--muted); font-size: 14px; }
.interpreted b { color: var(--text); font-weight: 500; }

.notice {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 16px 24px; margin-bottom: 32px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent-text);
  border-radius: 8px; background: var(--surface);
}
.notice p { margin: 0; }
.notice .directions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.notice button.retry {
  flex: none; padding: 8px 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: none;
}

.group { margin-bottom: 48px; }
.group-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 16px; }
.group-num { font: italic 400 24px/1 var(--serif); color: var(--accent-text); }
.group-title { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(256px, 1fr)); gap: 16px; }

.card {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.2s, background 0.2s, transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 50ms);
}
.card:hover { border-color: var(--line-strong); background: var(--surface-hover); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.card-main { display: flex; align-items: center; gap: 16px; padding: 16px 16px 8px; text-decoration: none; }
.fav {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--surface-hover); border: 1px solid var(--line);
}
.fav img { border-radius: 4px; }
.card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-domain { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-out { flex: none; color: var(--muted); transition: transform 0.2s, color 0.2s; }
.card-main:hover .card-out { color: var(--accent-text); transform: translate(2px, -2px); }
.card-main:hover .card-name { text-decoration: underline; text-underline-offset: 3px; }
.card-reason { margin: 0; padding: 0 16px 16px; flex: 1; color: var(--muted); font-size: 15px; text-wrap: pretty; }
.card-foot { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-top: 1px solid var(--line); }
.deep {
  padding: 4px 8px; border-radius: 8px; font-size: 14px; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); font-weight: 500;
}
.more { border: 0; background: none; padding: 4px 0; font-size: 14px; color: var(--muted); cursor: pointer; }
.more:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.votes { margin-left: auto; display: flex; gap: 0; }
.vote {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer;
}
.vote:hover { background: var(--surface-hover); color: var(--text); }
.vote[aria-pressed="true"] { color: var(--accent-text); }
.vote[aria-pressed="true"] path { fill: currentColor; fill-opacity: 0.25; }

/* Loading skeletons */
.skeleton .card-name, .skeleton .card-domain, .skeleton .card-reason span {
  display: block; height: 12px; border-radius: 4px; background: var(--line);
  animation: pulse 1.4s ease-in-out infinite;
}
.skeleton .card-name { width: 60%; height: 16px; margin-bottom: 8px; }
.skeleton .card-domain { width: 40%; }
.skeleton .card-reason span { margin-bottom: 8px; }
.skeleton .card-reason span:last-child { width: 70%; }
@keyframes pulse { 50% { opacity: 0.45; } }

.refine { max-width: 640px; margin: 16px auto 0; }
.refine label { display: block; margin: 0 0 8px 8px; font-size: 14px; color: var(--muted); }
.refine-row { display: flex; gap: 8px; }
.refine input {
  flex: 1; min-width: 0; padding: 12px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-strong); outline: 0;
}
.refine input:focus { border-color: var(--accent-text); }
.refine button {
  padding: 12px 24px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--text); color: var(--bg); font-weight: 500;
}

.foot { padding: 24px 32px 32px; text-align: center; color: var(--muted); font-size: 14px; }
.foot p { margin: 0; }

@media (max-width: 640px) {
  .top { padding: 16px; }
  main { padding: 0 16px; }
  .hero { padding-top: 12vh; }
  .ask input { font-size: 16px; padding-left: 16px; }
  .notice { flex-direction: column; padding: 16px; }
  .foot { padding: 24px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
