/* Consensus Forge: dark "forge" theme */
:root {
  --bg: #0b0d12;
  --bg-2: #11141b;
  --panel: #161a23;
  --panel-2: #1c212c;
  --line: #2a3140;
  --text: #eef1f6;
  --muted: #a3acbd;          /* 7.6:1 on --bg */
  --spark: #ff9f43;
  --spark-2: #ffcf6e;
  --agree: #3ddc97;
  --disagree: #ff5d73;
  --neutral: #f5c451;
  --error: #8b93a4;
  --focus: #7cc4ff;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255,159,67,.13), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(124,196,255,.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

a { color: var(--spark-2); }
code, kbd { font-family: var(--mono); font-size: .88em; }
code { background: rgba(255,255,255,.06); padding: .1em .35em; border-radius: 6px; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; padding: 0 .3em; border-radius: 5px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--spark); color: #111; padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip-link:focus { left: 8px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(16px, 4vw, 40px);
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(11,13,18,.78);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; letter-spacing: .2px; }
.brand-mark { width: 30px; height: 30px; color: var(--spark); }
.brand-name b { color: var(--spark); }
.auth { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.auth-status { font-size: .85rem; color: var(--agree); }
.connect-slot:empty { display: none; }

/* ---------- Layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: clamp(16px, 4vw, 40px); }
.hero { max-width: 760px; margin: 8px 0 24px; }
.hero h1 { font-size: clamp(1.9rem, 5.4vw, 3.3rem); line-height: 1.08; margin: 0 0 12px; letter-spacing: -.02em; }
.grad { background: linear-gradient(90deg, var(--spark), var(--spark-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { color: var(--muted); font-size: clamp(1rem, 2.2vw, 1.12rem); margin: 0; }

.tag { display: inline-block; padding: 0 .45em; border-radius: 999px; font-weight: 600; font-size: .92em; }
.tag-agree { color: var(--agree); background: rgba(61,220,151,.12); }
.tag-disagree { color: var(--disagree); background: rgba(255,93,115,.12); }
.tag-neutral { color: var(--neutral); background: rgba(245,196,81,.12); }

/* ---------- Claim form ---------- */
.claim-card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 3vw, 24px);
  box-shadow: var(--shadow);
}
.label { display: block; font-weight: 700; margin-bottom: 8px; }
textarea {
  width: 100%; resize: vertical; min-height: 92px;
  font: inherit; font-size: 1.08rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px;
}
textarea::placeholder { color: #7d8697; }
textarea:focus { border-color: var(--spark); outline: none; box-shadow: 0 0 0 3px rgba(255,159,67,.25); }
.claim-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; }
.hint { color: var(--muted); font-size: .86rem; }
.count { white-space: nowrap; font-variant-numeric: tabular-nums; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.chip {
  font: inherit; font-size: .85rem; color: var(--text); cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
}
.chip:hover { border-color: var(--spark); }

.models-panel { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.models-panel summary { cursor: pointer; color: var(--muted); font-size: .92rem; }
.models-panel summary span { color: var(--text); }
.model-selects { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 8px; }
.model-selects label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); }
.model-selects select {
  font: inherit; font-size: .9rem; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px;
}

.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.form-msg { min-height: 1.4em; margin: 10px 0 0; color: var(--neutral); font-size: .92rem; }
.form-msg.error { color: var(--disagree); }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 700; cursor: pointer; border-radius: 12px; border: 1px solid transparent;
  padding: 12px 20px; min-height: 44px; transition: transform .08s ease, background .2s, border-color .2s, opacity .2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(90deg, var(--spark), var(--spark-2)); color: #1a1206; flex: 1 1 220px; font-size: 1.05rem; }
.btn-primary[aria-busy="true"] .btn-label::after { content: " …"; }
.btn-secondary { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { border-color: var(--spark); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--muted); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: .85rem; border-radius: 10px; }
.btn-connect { background: var(--spark); color: #1a1206; padding: 8px 16px; min-height: 40px; }

/* ---------- Results ---------- */
.results { margin-top: 28px; scroll-margin-top: 80px; }
.score-card {
  display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: clamp(16px, 3vw, 36px); align-items: center;
  background: linear-gradient(135deg, rgba(255,159,67,.08), rgba(255,255,255,0) 50%), var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(16px, 3vw, 28px); box-shadow: var(--shadow);
}
.gauge-wrap { position: relative; width: 100%; max-width: 340px; margin: 0 auto; }
.gauge { width: 100%; height: auto; display: block; }
.gauge-track, .gauge-fill { fill: none; stroke-width: 16; stroke-linecap: round; }
.gauge-track { stroke: #262c39; }
.gauge-fill { stroke-dasharray: 0 100; transition: stroke-dasharray 1.1s cubic-bezier(.2,.8,.2,1); }
.gauge-ticks text { fill: var(--muted); font-size: 9px; font-family: var(--font); }
.gauge-readout { position: absolute; left: 0; right: 0; bottom: 4%; text-align: center; display: flex; flex-direction: column; }
.gauge-value { font-size: clamp(3rem, 11vw, 4.6rem); font-weight: 800; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.gauge-caption { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .12em; }
.score-card.is-loading .gauge-value { animation: pulse 1.2s ease-in-out infinite; }

.verdict { font-size: clamp(1.15rem, 2.8vw, 1.5rem); font-weight: 800; margin: 0 0 12px; }
.verdict .v-agree { color: var(--agree); }
.verdict .v-disagree { color: var(--disagree); }
.verdict .v-neutral { color: var(--neutral); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin: 0 0 14px; }
.stats div { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stats dt { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; }
.stats dd { margin: 2px 0 0; font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tally { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #262c39; margin-bottom: 8px; }
.tally span { display: block; height: 100%; transition: flex-grow .6s ease; }
.tally .t-agree { background: var(--agree); }
.tally .t-disagree { background: var(--disagree); }
.tally .t-neutral { background: var(--neutral); }
.tally .t-error { background: #3a4150; }
.formula { margin: 6px 0 14px; }
.share-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Model cards ---------- */
.cards {
  list-style: none; padding: 0; margin: 20px 0 0;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px;
}
.card {
  --accent: var(--line);
  position: relative; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--accent);
  border-radius: var(--radius); padding: 14px; min-height: 260px;
  animation: rise .4s ease both;
}
.card:nth-child(2) { animation-delay: .05s; } .card:nth-child(3) { animation-delay: .1s; }
.card:nth-child(4) { animation-delay: .15s; } .card:nth-child(5) { animation-delay: .2s; }
.card[data-stance="agree"] { --accent: var(--agree); }
.card[data-stance="disagree"] { --accent: var(--disagree); }
.card[data-stance="neutral"] { --accent: var(--neutral); }
.card[data-state="error"] { --accent: var(--error); }
.card-head { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 4px 10px; align-items: center; }
.card-index {
  grid-row: span 2; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel-2); color: var(--muted); font-weight: 800; font-size: .85rem;
}
.card-title { min-width: 0; }
.card-model { margin: 0; font-size: .98rem; overflow-wrap: anywhere; }
.card-publisher { color: var(--muted); font-size: .78rem; }
.stance-badge {
  grid-column: 1 / -1; justify-self: start; margin-top: 8px;
  font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: .82rem;
  padding: 4px 10px; border-radius: 999px; background: var(--panel-2); color: var(--muted);
}
.card[data-stance="agree"] .stance-badge { color: #08130d; background: var(--agree); }
.card[data-stance="disagree"] .stance-badge { color: #1a0509; background: var(--disagree); }
.card[data-stance="neutral"] .stance-badge { color: #1a1404; background: var(--neutral); }
.card[data-state="loading"] .stance-badge { animation: pulse 1.2s ease-in-out infinite; }

.card-body { flex: 1; margin-top: 12px; }
.conf { height: 6px; background: #262c39; border-radius: 999px; overflow: hidden; }
.conf-bar { height: 100%; width: 0; background: var(--accent); transition: width .8s ease; }
.conf-label { margin: 6px 0 10px; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.counter { margin: 0; padding: 0 0 0 12px; border-left: 3px solid var(--accent); font-size: .95rem; color: var(--text); overflow-wrap: anywhere; }
.counter:empty { display: none; }
.counter::before { content: "Sharpest counter"; display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 4px; }
.card-error { margin: 0; color: #ffb3bd; font-size: .9rem; }
.card-error:empty { display: none; }
.skeleton { display: none; flex-direction: column; gap: 8px; }
.card[data-state="loading"] .skeleton { display: flex; }
.skeleton span { height: 10px; border-radius: 6px; background: linear-gradient(90deg, #1f2430, #2b3242, #1f2430); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton span:nth-child(2) { width: 85%; } .skeleton span:nth-child(3) { width: 60%; }
.card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.06); }
.endpoint { font-family: var(--mono); font-size: .66rem; color: var(--muted); flex: 1 1 100%; overflow-wrap: anywhere; }
.timer { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.retry-btn { margin-left: auto; }

/* ---------- Footer ---------- */
.footer { max-width: 1180px; margin: 24px auto 0; padding: 20px clamp(16px, 4vw, 40px) max(28px, env(safe-area-inset-bottom)); color: var(--muted); font-size: .88rem; border-top: 1px solid rgba(255,255,255,.06); }
.footer p { margin: 0 0 8px; }
.credit a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); text-decoration: none; }
.credit a:hover { border-color: var(--spark); }
.credit b { color: var(--spark); }

/* ---------- Animations ---------- */
@keyframes pulse { 50% { opacity: .45; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .score-card { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .cards { grid-template-columns: 1fr; }
  .card { min-height: 0; }
  .stats dd { font-size: 1.1rem; }
  .brand-name { font-size: .95rem; }
  .claim-meta { flex-direction: column; gap: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
