:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6a675f;
  --line: #e4e1da;
  --accent: #1f6f5c;
  --accent-soft: #e3f0ec;
  --warn: #8a4b12;
  --warn-soft: #fbf0e3;
  --video-bg: #111;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.04);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141412;
    --surface: #1c1c19;
    --text: #ecebe6;
    --muted: #a19e94;
    --line: #2f2e2a;
    --accent: #6cc4ab;
    --accent-soft: #1d332d;
    --warn: #f0b57a;
    --warn-soft: #3a2a1a;
    --video-bg: #000;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  --bg: #141412;
  --surface: #1c1c19;
  --text: #ecebe6;
  --muted: #a19e94;
  --line: #2f2e2a;
  --accent: #6cc4ab;
  --accent-soft: #1d332d;
  --warn: #f0b57a;
  --warn-soft: #3a2a1a;
  --video-bg: #000;
  --shadow: none;
}

* { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--bar-h, 52px) + 16px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

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

button, select { font: inherit; color: inherit; }

/* ---- masthead ---- */

.masthead { padding: 40px 0 24px; border-bottom: 1px solid var(--line); }

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 { margin: 0 0 12px; font-size: clamp(24px, 3.4vw, 34px); line-height: 1.2; font-weight: 680; letter-spacing: -0.01em; }

.lede { max-width: 72ch; margin: 0 0 20px; color: var(--muted); }

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.legend div { padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.legend dt { font-weight: 650; }
.legend dt.ours { color: var(--accent); }
.legend dd { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.method { max-width: 80ch; }
.method summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.method p { color: var(--muted); font-size: 14px; }
.method strong { color: var(--text); }

/* ---- sticky bar ---- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.bar-inner { display: flex; align-items: center; gap: 12px; min-height: 52px; }

.links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 0;
}
.links::-webkit-scrollbar { display: none; }

.links .group { margin: 0 4px 0 10px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.links .group:first-child { margin-left: 0; }

.links a {
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}
.links a:hover { background: var(--accent-soft); }
.links a.active { background: var(--accent); color: var(--bg); }

.controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.speed { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.speed select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }

.ghost {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}
.ghost:hover { border-color: var(--accent); }
.ghost[aria-pressed="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ---- sections ---- */

.group-title { margin: 40px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

section.set { padding: 28px 0 4px; border-bottom: 1px solid var(--line); }

section.set h2 { margin: 0 0 4px; font-size: 22px; font-weight: 650; }
section.set h2 + .panel { margin-top: 12px; }

.set-note { margin: 0 0 4px; color: var(--muted); max-width: 80ch; }
.set-order { margin: 0 0 14px; color: var(--muted); font-size: 13px; max-width: 100ch; }

.colhead {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 8px;
  padding: 0 0 6px;
  font-size: 13px;
  font-weight: 650;
}
.colhead span.ours, figcaption.ours { color: var(--accent); }

/* ---- one prompt set: a panel one prompt tall that snaps from prompt to prompt ---- */

.viewer {
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: auto; /* past the first or last prompt, the page scrolls on */
  scrollbar-width: none;
  border-radius: 8px;
}
.viewer::-webkit-scrollbar { display: none; }
.viewer:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.row { scroll-snap-align: start; scroll-snap-stop: always; padding: 0 0 12px; }

.panel-title { margin: 18px 0 8px; font-size: 15px; font-weight: 650; }
.panel:first-of-type .panel-title { margin-top: 6px; }

.fold { margin: 0 0 16px; }
.fold > summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: fit-content;
  cursor: pointer;
  list-style: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: "\25B6"; font-size: 11px; color: var(--accent); transition: transform 0.15s; }
.fold[open] > summary::before { transform: rotate(90deg); }
.fold > summary:hover { color: var(--accent); }

.row-head { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 8px; }

.rank { display: flex; gap: 4px; flex-shrink: 0; }
.rank-btn {
  width: 34px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 650;
}
.rank-btn:hover { border-color: var(--accent); }
.rank-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }

.pick-notice { margin: 24px 0 0; border-color: var(--warn); background: var(--warn-soft); }

.prompt {
  flex: 1;
  min-width: 0;
  height: calc(2 * 1.5em);
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  cursor: zoom-in;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.prompt .tag { color: var(--text); font-weight: 600; margin-right: 6px; }

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4px 0 20px;
}
.counter { min-width: 11ch; text-align: center; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.stepper .ghost { padding: 7px 14px; font-size: 14px; }
.stepper .step-next { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.stepper .ghost:disabled { opacity: 0.4; cursor: default; border-color: var(--line); color: var(--muted); }

.clips { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 8px; }

figure { margin: 0; }

figure video {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: var(--video-bg);
  border-radius: 6px;
  cursor: zoom-in;
}

figcaption { display: none; margin-top: 3px; font-size: 12px; font-weight: 600; }

/* ---- gate ---- */

.gate {
  margin: 24px 0;
  padding: 20px;
  border: 1px solid var(--warn);
  border-radius: 10px;
  background: var(--warn-soft);
}
.gate h3 { margin: 0 0 6px; color: var(--warn); font-size: 17px; }
.gate p { margin: 0 0 12px; max-width: 75ch; }
.gate button { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--warn); background: var(--surface); cursor: pointer; font-weight: 600; }

.foot { padding: 24px 16px 48px; color: var(--muted); font-size: 13px; }

.notice { padding: 16px; border: 1px solid var(--line); border-radius: 8px; }

/* ---- overlay ---- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  background: rgb(0 0 0 / 0.72);
}
.overlay[hidden] { display: none; }

.overlay-panel {
  width: min(1400px, 100%);
  padding: 16px;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.overlay-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.overlay-title { margin: 0; font-weight: 650; }
.overlay-tools { display: flex; gap: 6px; align-items: center; }
.overlay-prompt { margin: 8px 0 12px; color: var(--muted); font-size: 14px; }

.close { width: 32px; height: 32px; border: none; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.close:hover { color: var(--text); }

.clips.large figcaption { display: block; font-size: 14px; }
.clips.large video { cursor: default; }

@media (min-width: 761px) {
  .links { flex-wrap: wrap; overflow-x: visible; }
}

/* ---- narrow screens: 2 columns, captions under each clip instead of a header row ---- */

@media (max-width: 760px) {
  .clips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .colhead { display: none; }
  figcaption { display: block; }
  .clips.large { grid-template-columns: minmax(0, 1fr); }
}
