:root {
  --ink: #1d1a17;
  --ink-soft: #5c554d;
  --paper: #f4f1ea;
  --card: #fffdf8;
  --line: #e2dbcd;
  --accent: #b4552d;
  --accent-soft: #f0dbd0;
  --hit: #1f6d4a;
  --hit-soft: #d8ece0;
  --miss: #9a3232;
  --miss-soft: #f6dcdc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60rem 40rem at 15% -10%, #fbe9dd 0%, transparent 60%),
    radial-gradient(50rem 35rem at 95% 5%, #e6eee8 0%, transparent 55%);
}

header.site {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.5rem clamp(1rem, 5vw, 4rem);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 1.15rem; }
.tag { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }

main {
  max-width: 62rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 5vw, 2rem) 4rem;
}

.hero h1 {
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2rem, 6vw, 3.2rem);
  line-height: 1.1;
  margin: 0 0 0.75rem;
}
.hero h1 span { color: var(--accent); }
.lede { max-width: 40rem; color: var(--ink-soft); margin: 0 0 1rem; }
.meta {
  font-size: 0.82rem;
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  display: inline-block;
}

.panel {
  margin-top: 2rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.field { margin-bottom: 1.25rem; }
.field label {
  display: block;
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.4rem;
}
input[type="text"], select {
  width: 100%;
  font: inherit;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: #fff;
  color: var(--ink);
}
select { cursor: pointer; }
input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
.hint { margin: 0.4rem 0 0; font-size: 0.8rem; color: var(--ink-soft); }
.grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }

button {
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border: none;
  border-radius: 0.6rem;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: #fff;
  transition: opacity 0.15s;
}
button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: progress; }

.results { margin-top: 2rem; }

.verdict {
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  background: var(--card);
}
.verdict.hit { background: var(--hit-soft); border-color: #b9d9c8; }
.verdict.miss { background: var(--miss-soft); border-color: #e8c4c4; }
.v-label {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
}
.verdict.hit .v-label { color: var(--hit); }
.verdict.miss .v-label { color: var(--miss); }
.v-sub { color: var(--ink-soft); font-size: 0.92rem; margin-top: 0.25rem; }

.stat-row {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  margin-top: 1rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.9rem 1rem;
}
.stat .k { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); }
.stat .v { font-family: Fraunces, Georgia, serif; font-size: 1.6rem; font-weight: 700; }

.run {
  margin-top: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  overflow: hidden;
}
.run-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  background: #faf7f0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.hit { background: var(--hit); color: #fff; }
.badge.miss { background: var(--miss); color: #fff; }
.badge.queued { background: var(--ink-soft); color: #fff; }

.answer { padding: 1rem; white-space: pre-wrap; font-size: 0.94rem; }
mark.brand { background: #ffe08a; font-weight: 700; padding: 0 0.15em; border-radius: 3px; }
mark.rival { background: var(--accent-soft); padding: 0 0.15em; border-radius: 3px; }

.sources {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px dashed var(--line);
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.sources a { color: var(--accent); overflow-wrap: anywhere; }
.sources ul { margin: 0.35rem 0 0; padding-left: 1.1rem; }
.queries { font-style: italic; }

footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem clamp(1rem, 5vw, 4rem);
  color: var(--ink-soft);
  font-size: 0.8rem;
}
footer p { margin: 0; }

/* Three viewer states: explicit light, explicit dark, and un-stamped "system"
   where only prefers-color-scheme separates them. Tokens are redefined for the
   last two; every component styles through the tokens. */

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 0.4rem;
  margin-top: 2rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.tab {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 0.6rem 0.6rem 0 0;
  padding: 0.6rem 1.1rem;
  font-weight: 500;
  margin-bottom: -1px;
}
.tab:hover { color: var(--ink); opacity: 1; }
.tab.active {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
  border-bottom: 1px solid var(--card);
}
.tab .count {
  font-size: 0.75rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  margin-left: 0.3rem;
  font-weight: 700;
}
.tab.active .count { background: var(--accent); color: #fff; }

.tabpanel { margin-top: 1.5rem; }
.section-head h2 {
  font-family: Fraunces, Georgia, serif;
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
}
.snapshot-meta { margin: 0 0 1rem; color: var(--ink-soft); font-size: 0.85rem; }

/* ---------- snapshot entries ---------- */
.snapshot-list { display: flex; flex-direction: column; gap: 0.6rem; }

details.entry {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  overflow: hidden;
}
details.entry[open] { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); }
details.entry summary {
  cursor: pointer;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  list-style: none;
  font-weight: 500;
}
details.entry summary::-webkit-details-marker { display: none; }
details.entry summary::before {
  content: "▸";
  color: var(--ink-soft);
  transition: transform 0.15s;
}
details.entry[open] summary::before { transform: rotate(90deg); }
.entry .q { flex: 1; overflow-wrap: anywhere; }
.entry .pos {
  font-size: 0.75rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.entry-body {
  border-top: 1px solid var(--line);
  padding: 1rem;
  font-size: 0.92rem;
}
.entry-body .rivals {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.entry-body .answer-text { white-space: pre-wrap; }
.entry-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
  margin: 0.5rem 0;
}
.entry-body th, .entry-body td {
  border: 1px solid var(--line);
  padding: 0.35rem 0.5rem;
  text-align: left;
  vertical-align: top;
}
.scroller { overflow-x: auto; }
.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 0.75rem;
  padding: 1.5rem;
  color: var(--ink-soft);
  text-align: center;
}


/* ---------- theme ----------
   Three viewer states: explicit light, explicit dark, and the default
   un-stamped "system" where only prefers-color-scheme separates them.
   Tokens are redefined for the latter two; components style through tokens. */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --ink: #f0ece5;
  --ink-soft: #a89f93;
  --paper: #17150f;
  --card: #211e18;
  --line: #3a352c;
  --accent: #e08b5f;
  --accent-soft: #4a3527;
  --hit: #6fd39f;
  --hit-soft: #1d3a2c;
  --miss: #e88c8c;
  --miss-soft: #3c2222;
  }

  .bg { background: radial-gradient(60rem 40rem at 15% -10%, #2a201a 0%, transparent 60%); }
  input[type="text"], select { background: #171410; color: var(--ink); }
  .run-head { background: #1a1712; }
  .tab.active { border-bottom-color: var(--card); }
  mark.brand { background: #8a6a1f; color: #fff; }
}

:root[data-theme="dark"] {
  --ink: #f0ece5;
  --ink-soft: #a89f93;
  --paper: #17150f;
  --card: #211e18;
  --line: #3a352c;
  --accent: #e08b5f;
  --accent-soft: #4a3527;
  --hit: #6fd39f;
  --hit-soft: #1d3a2c;
  --miss: #e88c8c;
  --miss-soft: #3c2222;
}

:root[data-theme="dark"] .bg { background: radial-gradient(60rem 40rem at 15% -10%, #2a201a 0%, transparent 60%); }
:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] select { background: #171410; color: var(--ink); }
:root[data-theme="dark"] .run-head { background: #1a1712; }
:root[data-theme="dark"] .tab.active { border-bottom-color: var(--card); }
:root[data-theme="dark"] mark.brand { background: #8a6a1f; color: #fff; }

.facts {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  margin: 1.25rem 0 0;
}
.facts div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
}
.facts b { display: block; font-family: Fraunces, Georgia, serif; font-size: 1.05rem; }
.facts span { display: block; margin-top: 0.25rem; font-size: 0.85rem; color: var(--ink-soft); }
.verdict.queued { background: #f3efe6; border-color: var(--line); }
.verdict.queued .v-label { color: var(--ink); }
