/* ============================================================
   Agentic PowerScaler -- Cosmic Glassmorphism theme
   Dark is the default (:root); light overrides via
   html[data-theme="light"]. All colors flow through tokens so
   the theme-wave toggle only flips one attribute.
   ============================================================ */

:root {
  color-scheme: dark;

  --bg: #08090e;
  --panel: rgba(15, 18, 28, 0.55);
  --panel-solid: #0f121c;
  --panel-border: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(8, 10, 17, 0.6);
  --chip-bg: rgba(255, 255, 255, 0.06);
  --card-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);

  --text: #e7e9ee;
  --text-dim: #959cb0;
  --hero-top: #ffffff;

  --accent: #f5b93f;
  --accent-dim: #8a6d1f;
  --accent-glow: rgba(245, 158, 11, 0.28);

  /* Duelist identities: A = cool cyan, B = warm crimson/rose */
  --cyan: #22d3ee;
  --cyan-soft: rgba(6, 182, 212, 0.35);
  --cyan-faint: rgba(6, 182, 212, 0.10);
  --rose: #fb7185;
  --rose-soft: rgba(244, 63, 94, 0.35);
  --rose-faint: rgba(244, 63, 94, 0.10);

  --emerald: #34d399;
  --danger: #ff5d5d;

  --aura-a: rgba(6, 182, 212, 0.09);
  --aura-b: rgba(244, 63, 94, 0.08);

  --radius: 12px;
}

html[data-theme="light"] {
  color-scheme: light;

  --bg: #eef0f7;
  --panel: rgba(255, 255, 255, 0.66);
  --panel-solid: #ffffff;
  --panel-border: rgba(15, 23, 42, 0.12);
  --input-bg: rgba(255, 255, 255, 0.75);
  --chip-bg: rgba(15, 23, 42, 0.05);
  --card-shadow: 0 14px 34px rgba(30, 41, 59, 0.12);

  --text: #1c2130;
  --text-dim: #5a6377;
  --hero-top: #7c5a09;

  --accent: #b07d10;
  --accent-dim: #8a6d1f;
  --accent-glow: rgba(217, 119, 6, 0.22);

  --cyan: #0891b2;
  --cyan-soft: rgba(8, 145, 178, 0.35);
  --cyan-faint: rgba(8, 145, 178, 0.08);
  --rose: #e11d48;
  --rose-soft: rgba(225, 29, 72, 0.30);
  --rose-faint: rgba(225, 29, 72, 0.07);

  --emerald: #059669;
  --danger: #d43c3c;

  --aura-a: rgba(8, 145, 178, 0.10);
  --aura-b: rgba(225, 29, 72, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 45% 40% at 18% 6%, var(--aura-a), transparent 70%),
    radial-gradient(ellipse 45% 40% at 82% 6%, var(--aura-b), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: 2.5rem 1rem 4rem;
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* The expanding wave itself animates the ::view-transition-new pseudo (driven from JS);
   the defaults would cross-fade on top of it, so neutralize them. */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

.wrap { max-width: 760px; margin: 0 auto; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  position: fixed; top: 1rem; right: 1rem; z-index: 50;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  cursor: pointer; font-size: 1.05rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.theme-toggle:hover { border-color: var(--accent); transform: scale(1.08); }
.theme-toggle .to-dark { display: none; }
html[data-theme="light"] .theme-toggle .to-dark { display: inline; }
html[data-theme="light"] .theme-toggle .to-light { display: none; }

/* ---------- Hero ---------- */
header.hero { text-align: center; margin-bottom: 2.5rem; }

header.hero h1 {
  font-family: "Cinzel", Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  letter-spacing: 0.06em;
  margin: 0 0 0.4rem;
  background: linear-gradient(180deg, var(--hero-top), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px var(--accent-glow));
}

header.hero p { color: var(--text-dim); margin: 0; font-size: 0.95rem; }

/* ---------- Glass panels ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.75rem;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--card-shadow);
}

/* ---------- Clash Arena form ---------- */
.vs-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.85rem;
  align-items: stretch;
  margin-bottom: 1.1rem;
}
@media (max-width: 560px) { .vs-row { grid-template-columns: 1fr; } }

.duelist {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--input-bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.duelist .field { margin-bottom: 0; }
.duelist-a:hover, .duelist-a:focus-within {
  border-color: var(--cyan-soft);
  box-shadow: 0 0 20px var(--cyan-faint);
}
.duelist-b:hover, .duelist-b:focus-within {
  border-color: var(--rose-soft);
  box-shadow: 0 0 20px var(--rose-faint);
}
.duelist-a label { color: var(--cyan); }
.duelist-b label { color: var(--rose); }
.duelist-a input[type="text"]:focus { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan-soft); }
.duelist-b input[type="text"]:focus { border-color: var(--rose); box-shadow: 0 0 0 1px var(--rose-soft); }

.vs-badge {
  align-self: center;
  width: 54px; height: 54px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700; font-size: 0.95rem;
  color: var(--accent);
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.14), transparent 60%),
    var(--panel-solid);
  border: 1px solid var(--accent-dim);
  animation: vs-pulse 2.4s ease-in-out infinite;
}
@media (max-width: 560px) { .vs-badge { justify-self: center; } }
@keyframes vs-pulse {
  0%, 100% { box-shadow: 0 0 10px var(--accent-glow); }
  50%      { box-shadow: 0 0 26px var(--accent-glow); }
}

.field { margin-bottom: 1.1rem; display: flex; flex-direction: column; gap: 0.35rem; }

/* ---------- Roster builder ---------- */
.team-header {
  font-size: 0.78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}
.duelist-a .team-header, .team-header-a { color: var(--cyan); }
.duelist-b .team-header, .team-header-b { color: var(--rose); }

.members { display: flex; flex-direction: column; gap: 0.75rem; }

.member {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.75rem;
  background: var(--panel);
}
.member-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.4rem;
}
.member-title {
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-dim); font-weight: 600;
}
.member-name { width: 100%; }

.sub-section { margin-top: 0.7rem; }
.sub-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.3rem;
}
.sub-label {
  font-size: 0.66rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-dim); font-weight: 600;
}
.sub-section .rows { display: flex; flex-direction: column; gap: 0.35rem; }

.input-row { display: flex; gap: 0.35rem; align-items: center; }
.input-row .row-input { flex: 1; margin-top: 0; }

.add-btn {
  background: transparent; border: 1px dashed var(--panel-border);
  color: var(--text-dim); border-radius: 6px;
  padding: 0.18rem 0.55rem; font-size: 0.7rem; font-weight: 600;
  cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease;
}
.add-btn:hover { border-color: var(--accent); color: var(--accent); }
.add-member { width: 100%; margin-top: 0.75rem; padding: 0.45rem; font-size: 0.78rem; }

.row-remove {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 0.75rem; cursor: pointer; padding: 0.25rem 0.35rem;
  border-radius: 6px; line-height: 1;
  transition: color 0.15s ease;
}
.row-remove:hover { color: var(--danger); }

.team-col { display: flex; flex-direction: column; gap: 1rem; align-content: start; }

label {
  font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-dim);
}

input[type="text"] {
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:focus { outline: none; border-color: var(--accent); }

.handicap-input {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  padding: 0.5rem 0.7rem;
  border-style: dashed;
  opacity: 0.85;
}

.handicap-note {
  margin: 0.4rem 0 0.6rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
}

.checkbox-row { flex-direction: row; align-items: center; gap: 0.5rem; }
.checkbox-row label { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 0.9rem; }

button.submit {
  position: relative; overflow: hidden;
  width: 100%;
  padding: 0.85rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24 45%, #d97706);
  color: #1a1206;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  margin-top: 0.5rem;
  box-shadow: 0 0 22px var(--accent-glow);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
button.submit:hover { transform: translateY(-1px) scale(1.005); box-shadow: 0 0 32px var(--accent-glow); }
button.submit:active { transform: translateY(0); }
/* Shimmer sweep on hover */
button.submit::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.4) 50%, transparent 60%);
  transform: translateX(-130%);
  pointer-events: none;
}
button.submit:hover::after { animation: shimmer 0.9s ease; }
@keyframes shimmer { to { transform: translateX(130%); } }
button.submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Agentic loading HUD ---------- */
.htmx-indicator { display: none; padding: 1.8rem 0 0.6rem; }
/* htmx adds `htmx-request` directly onto the element targeted by hx-indicator (here, #loading
   itself) -- not onto some ancestor -- so the matching selector is compound (no space), not a
   descendant combinator. */
.htmx-indicator.htmx-request { display: block; }

.hud { max-width: 460px; margin: 0 auto; }
.hud-bar {
  height: 3px; border-radius: 999px; overflow: hidden;
  background: var(--panel-border);
}
.hud-bar-fill {
  height: 100%; width: 38%; border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--accent), var(--rose));
  animation: hud-sweep 1.5s ease-in-out infinite;
}
@keyframes hud-sweep {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(380%); }
}

.hud-steps {
  list-style: none; margin: 1.1rem 0 0; padding: 0;
  /* Real progress can produce many lines (one per contender, per stage) -- scroll the
     panel rather than letting it shove the page down mid-run. */
  max-height: 190px; overflow-y: auto;
}
.hud-steps li {
  display: flex; gap: 0.6rem; align-items: baseline;
  padding: 0.34rem 0; font-size: 0.86rem;
  color: var(--text-dim); opacity: 0.45;
  transition: opacity 0.3s ease, color 0.3s ease;
}
.hud-steps li .tick { display: inline-block; width: 1.1em; text-align: center; }
.hud-steps li.active { color: var(--text); opacity: 1; animation: step-in 0.35s ease; }
.hud-steps li.active .tick { color: var(--cyan); animation: spin 1.1s linear infinite; }
.hud-steps li.done { opacity: 0.6; }
.hud-steps li.done .tick { color: var(--emerald); }
@keyframes step-in { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

#result { margin-top: 2rem; }

.result-toolbar { display: flex; justify-content: flex-end; margin-bottom: 0.9rem; }

button.new-matchup {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
button.new-matchup:hover { border-color: var(--accent); color: var(--accent); }

.step-hint { color: var(--text-dim); font-size: 0.75rem; text-align: center; margin: 0.7rem 0 0; }

/* ---------- Version confirmation ---------- */
.preview-header { text-align: center; margin-bottom: 1.25rem; }
.preview-header h3 {
  font-family: "Cinzel", Georgia, serif; color: var(--accent);
  margin: 0 0 0.25rem; font-size: 1.15rem;
}
.preview-header p { color: var(--text-dim); font-size: 0.85rem; margin: 0; }

.franchise-line {
  color: var(--text-dim); font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.05em; margin: -0.45rem 0 0.9rem;
}

.version-label {
  display: block; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 0.3rem;
}
.version-select {
  width: 100%; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 0.55rem 2rem 0.55rem 0.6rem; font-size: 0.85rem; font-family: inherit;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23888fa5' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}
.version-select:focus { outline: none; border-color: var(--accent); }

.status-block { margin-top: 0.85rem; }
.status-badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.28rem 0.7rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; border: 1px solid;
}
.badge-complete {
  color: var(--emerald); border-color: rgba(52, 211, 153, 0.30);
  background: rgba(52, 211, 153, 0.10);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.12);
}
.badge-ongoing {
  color: #fbbf24; border-color: rgba(251, 191, 36, 0.30);
  background: rgba(251, 191, 36, 0.10);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.10);
}
html[data-theme="light"] .badge-ongoing { color: #92650b; }
.badge-unknown { color: var(--text-dim); border-color: var(--panel-border); background: var(--chip-bg); }
.status-note { color: var(--text-dim); font-size: 0.78rem; line-height: 1.45; margin-top: 0.45rem; }

.item-block { margin-top: 1rem; padding-top: 0.85rem; border-top: 1px dashed var(--panel-border); }
.refine-row { display: flex; gap: 0.4rem; margin-top: 0.55rem; }
.refine-row input { flex: 1; margin-top: 0; }
.refine-btn {
  background: transparent; color: var(--text-dim); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 0 0.7rem; font-size: 0.78rem; cursor: pointer; white-space: nowrap;
}
.refine-btn:hover { border-color: var(--accent); color: var(--accent); }

.preview-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 1.4rem; }
.preview-actions .submit { margin-top: 0; flex: 1; }
.preview-actions .new-matchup { padding: 0.85rem 1.1rem; }

/* ---------- Results ---------- */
.winner-banner {
  text-align: center;
  padding: 1.75rem 1.5rem;
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse 70% 90% at 50% 0%, rgba(245, 158, 11, 0.16), transparent 75%),
    var(--panel);
  border: 1px solid rgba(245, 158, 11, 0.40);
  box-shadow: 0 0 50px var(--accent-glow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  margin-bottom: 1.5rem;
}
.winner-banner .trophy { font-size: 2rem; filter: drop-shadow(0 0 12px var(--accent-glow)); }
.winner-banner h2 {
  font-family: "Cinzel", Georgia, serif;
  margin: 0.35rem 0 0.55rem;
  color: var(--accent);
  font-size: 1.55rem;
  letter-spacing: 0.03em;
  text-shadow: 0 0 24px var(--accent-glow);
}
.winner-banner .diff-tier {
  display: inline-block;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.40);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
}

/* ---------- Outcome probability bar ---------- */
.prob-wrap { max-width: 480px; margin: 1.1rem auto 0; }
.prob-bar {
  display: flex; height: 12px; border-radius: 999px; overflow: hidden;
  border: 1px solid var(--panel-border);
  background: var(--chip-bg);
  transform-origin: left center;
  animation: prob-grow 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes prob-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.prob-a   { background: linear-gradient(90deg, #0e7490, var(--cyan)); }
.prob-tie { background: rgba(148, 163, 184, 0.45); }
.prob-b   { background: linear-gradient(90deg, var(--rose), #be123c); }
/* Each segment opens the "script this scenario" modal. */
.prob-bar > div { cursor: pointer; transition: filter 0.15s ease; }
.prob-bar:hover > div { filter: saturate(0.6) brightness(0.8); }
.prob-bar > div:hover { filter: saturate(1.3) brightness(1.25); }

.prob-legend {
  display: flex; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
  margin-top: 0.45rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.68rem; color: var(--text-dim);
}
.prob-legend .pl { display: inline-flex; align-items: center; gap: 0.35rem; }
.prob-legend i {
  width: 8px; height: 8px; border-radius: 2px; display: inline-block;
}
.pl-a i { background: var(--cyan); }
.pl-tie i { background: rgba(148, 163, 184, 0.6); }
.pl-b i { background: var(--rose); }
.pl-a { color: var(--cyan); }
.pl-b { color: var(--rose); }
.prob-legend .pl { cursor: pointer; transition: opacity 0.15s ease; }
.prob-legend .pl:hover { opacity: 0.7; text-decoration: underline; }

.prob-hint { color: var(--text-dim); font-size: 0.72rem; margin: 0.65rem 0 0; }

/* ---------- Scenario script modal ---------- */
/* `display: flex` here outranks the UA's `[hidden] { display: none }`, so the hidden
   overlay would otherwise stay laid out and swallow every click on the page. */
.modal-overlay[hidden] { display: none; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  background: rgba(3, 5, 10, 0.68);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fade-in 0.18s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-dialog {
  width: 100%; max-width: 420px;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow), 0 0 60px rgba(0, 0, 0, 0.4);
  animation: modal-rise 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes modal-rise {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-dialog h3 {
  font-family: "Cinzel", Georgia, serif; color: var(--accent);
  margin: 0 0 0.6rem; font-size: 1.1rem;
}
.modal-body { color: var(--text-dim); font-size: 0.88rem; line-height: 1.55; margin: 0 0 1.2rem; }
.modal-body strong { color: var(--text); }
.modal-actions { display: flex; gap: 0.6rem; }
.modal-actions .submit { margin-top: 0; flex: 1; }
.modal-actions .new-matchup { padding: 0.85rem 1.1rem; }

.script-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.75rem; flex-wrap: wrap;
}
.script-header .section-title { margin-bottom: 0.9rem; }
.cached-note {
  font-size: 0.7rem; color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.error-banner {
  border: 1px solid var(--danger);
  background: rgba(255, 93, 93, 0.08);
  color: var(--danger);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
}

.factors { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-top: 0.9rem; }
.factors span {
  background: var(--chip-bg);
  border: 1px solid var(--panel-border);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 560px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.1rem;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top-width: 2px;
}
.stat-card.a { border-top-color: var(--cyan-soft); }
.stat-card.b { border-top-color: var(--rose-soft); }
.stat-card h3 { margin: 0 0 0.75rem; font-family: "Cinzel", Georgia, serif; font-size: 1.05rem; }
.stat-card.a h3 { color: var(--cyan); }
.stat-card.b h3 { color: var(--rose); }

.stat-row {
  display: flex; justify-content: space-between; align-items: center; gap: 0.6rem;
  font-size: 0.85rem; padding: 0.38rem 0; border-bottom: 1px solid var(--panel-border);
}
.stat-row:last-of-type { border-bottom: none; }
.stat-row .k { color: var(--text-dim); flex-shrink: 0; }
.stat-row .v {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  background: var(--chip-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  text-align: right;
}

.tag-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.tag-list span {
  background: var(--chip-bg);
  border: 1px solid var(--panel-border);
  padding: 0.2rem 0.55rem; border-radius: 6px; font-size: 0.75rem;
}

/* ---------- Human review gate ---------- */
.review-card { position: relative; }
.review-card h3 { margin-top: 0.5rem; }
.review-flagged { border-color: rgba(251,191,36,0.45); box-shadow: 0 0 22px rgba(251,191,36,0.10); }

.review-check {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.6rem; margin: -0.25rem 0 0.35rem;
  border: 1px solid var(--panel-border); border-radius: 8px;
  background: var(--chip-bg);
  cursor: pointer; text-transform: none; letter-spacing: 0;
  font-size: 0.82rem; font-weight: 600; color: var(--text);
}
.review-check:hover { border-color: var(--accent); }
.review-check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.review-warn {
  margin: 0.35rem 0 0.6rem; padding: 0.4rem 0.55rem;
  border-radius: 6px; font-size: 0.75rem; line-height: 1.4;
  color: #fbbf24; background: rgba(251,191,36,0.10); border: 1px solid rgba(251,191,36,0.30);
}
html[data-theme="light"] .review-warn { color: #8a5d06; }

.review-cap {
  max-width: 640px; margin: 0 auto 1.25rem; text-align: center;
  padding: 0.55rem 0.8rem; border-radius: 8px; font-size: 0.8rem;
  color: var(--text-dim); background: var(--chip-bg); border: 1px solid var(--panel-border);
}

.hint-row { margin-top: 0.85rem; padding-top: 0.7rem; border-top: 1px dashed var(--panel-border); }
.hint-row input { width: 100%; }

/* ---------- Research trail (per contender) ---------- */
.trail { margin-top: 0.85rem; border-top: 1px dashed var(--panel-border); padding-top: 0.6rem; }
.trail summary {
  cursor: pointer; list-style: none;
  font-size: 0.74rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
  transition: color 0.15s ease;
}
.trail summary::-webkit-details-marker { display: none; }
.trail summary:hover, .trail[open] summary { color: var(--accent); }
.trail-body { margin-top: 0.6rem; font-size: 0.76rem; color: var(--text-dim); }
.trail-row { display: flex; flex-direction: column; gap: 0.15rem; margin-bottom: 0.55rem; }
.trail-k {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); opacity: 0.75; font-weight: 600;
  display: block; margin-bottom: 0.25rem;
}
.trail-v { color: var(--text); line-height: 1.45; }
.trail-v.mono, .trail-traits code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.7rem;
}
.trail-note {
  background: var(--chip-bg); border: 1px solid var(--panel-border);
  border-radius: 6px; padding: 0.4rem 0.55rem; margin-bottom: 0.6rem;
  font-size: 0.72rem; line-height: 1.4;
}
.trail-traits, .trail-sources { list-style: none; padding: 0; margin: 0 0 0.6rem; }
.trail-traits li { padding: 0.16rem 0; }
.trail-traits strong { color: var(--text); }
.trail-traits .conf {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.62rem; margin-left: 0.35rem;
  padding: 0.05rem 0.3rem; border-radius: 4px;
}
.conf-high   { color: var(--emerald); background: rgba(52, 211, 153, 0.10); }
.conf-medium { color: var(--cyan); background: rgba(6, 182, 212, 0.10); }
/* Low confidence is the tell that a stat was inferred rather than sourced. */
.conf-low    { color: #fbbf24; background: rgba(251, 191, 36, 0.12); }
html[data-theme="light"] .conf-low { color: #92650b; }
.trail-sources li { padding: 0.14rem 0; word-break: break-all; }
.trail-sources a { color: var(--text-dim); font-size: 0.7rem; }
.trail-sources a:hover { color: var(--accent); }

.feat-list { list-style: none; padding: 0; margin: 0.6rem 0 0; font-size: 0.8rem; color: var(--text-dim); }
.feat-list li { padding: 0.25rem 0; }
.feat-list li strong { color: var(--text); }

/* ---------- Analysis breakdown (accordion built client-side) ---------- */
.analysis-card { margin-bottom: 1.5rem; }
.section-title {
  font-family: "Cinzel", Georgia, serif;
  color: var(--accent);
  margin: 0 0 0.9rem;
  font-size: 1.05rem;
}
.verdict-text { font-size: 0.9rem; line-height: 1.65; color: var(--text-dim); }
.verdict-text h3, .verdict-text h4 { color: var(--text); margin: 1rem 0 0.3rem; }
.verdict-text hr { border: none; border-top: 1px solid var(--panel-border); }

.acc-item {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  margin-bottom: 0.55rem;
  background: var(--input-bg);
  overflow: hidden;
}
.acc-item summary {
  padding: 0.7rem 0.95rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  transition: color 0.15s ease;
}
.acc-item summary::-webkit-details-marker { display: none; }
.acc-item summary::after { content: "+"; color: var(--text-dim); font-weight: 400; }
.acc-item[open] summary { color: var(--accent); }
.acc-item[open] summary::after { content: "\2212"; }
.acc-body { padding: 0 0.95rem 0.85rem; }
.acc-body > :first-child { margin-top: 0; }

/* ---------- Cinematic script ---------- */
.script-scene { margin-bottom: 1.25rem; }
.script-scene h4 { font-family: "Cinzel", Georgia, serif; color: var(--accent); margin-bottom: 0.2rem; }
.script-scene .atmosphere { color: var(--text-dim); font-size: 0.8rem; font-style: italic; margin-bottom: 0.6rem; }
.shot { border-left: 2px solid var(--panel-border); padding: 0.4rem 0 0.4rem 0.8rem; margin-bottom: 0.5rem; }
.shot .camera { color: var(--cyan); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.shot .action { font-size: 0.88rem; margin: 0.2rem 0; }
.shot .dialogue { font-style: italic; color: var(--text); font-size: 0.85rem; }
.shot .vfx { color: var(--text-dim); font-size: 0.75rem; }

.sources { margin-top: 1.5rem; font-size: 0.78rem; color: var(--text-dim); }
.sources a { color: var(--text-dim); }

footer { text-align: center; color: var(--text-dim); font-size: 0.75rem; margin-top: 3rem; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
