:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --paper: #fbfaf7;
  --card: #ffffff;
  --grid: rgba(15, 23, 42, .045);
  --needle: #e11d48;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --bad: #e11d48;
  --bad-bg: #fff1f2;
  --warn: #d97706;
  --violet: #7c3aed;
  --accent: #4338ca;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 16px/1.6 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
code, pre { font-family: "JetBrains Mono", ui-monospace, monospace; }
code { font-size: .86em; background: #f1f5f9; padding: .1em .35em; border-radius: 5px; }
[hidden] { display: none !important; }

main { max-width: 920px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bar ---------- */
.topbar {
  max-width: 920px; margin: 0 auto; padding: 18px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem;
  color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand svg { width: 30px; height: 30px; }
.brand rect { fill: var(--ink); }
.brand path { fill: none; stroke: #f43f5e; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
nav { display: flex; gap: 18px; font-size: .92rem; }
nav a { color: var(--ink-2); text-decoration: none; font-weight: 500; }
nav a:hover { color: var(--ink); }
nav .gh { color: var(--ink); font-weight: 600; }

/* ---------- hero ---------- */
.hero { padding: 48px 0 28px; text-align: center; }
.eyebrow { margin: 0 0 10px; color: var(--needle); font-weight: 700; font-size: .8rem;
  letter-spacing: .12em; text-transform: uppercase; }
h1 { font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.08; letter-spacing: -.03em; margin: 0 0 18px; font-weight: 800; }
h1 span { color: var(--accent); }
.lede { max-width: 640px; margin: 0 auto 28px; color: var(--ink-2); font-size: 1.08rem; }
.lede q { font-style: italic; }

.ask { display: flex; gap: 8px; max-width: 640px; margin: 0 auto; background: var(--card);
  border: 1.5px solid var(--line); border-radius: 999px; padding: 6px; box-shadow: var(--shadow); }
.ask:focus-within { border-color: var(--accent); }
.ask input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit;
  font-size: 1.02rem; padding: 10px 16px; color: var(--ink); }
.ask button { border: 0; border-radius: 999px; background: var(--ink); color: #fff; font: inherit;
  font-weight: 700; padding: 10px 22px; cursor: pointer; white-space: nowrap; }
.ask button:hover { background: var(--accent); }
.ask button:disabled { opacity: .55; cursor: wait; }

.tries { margin-top: 20px; }
.tries-label { display: block; color: var(--muted); font-size: .85rem; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  max-width: 280px; border: 1.5px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 10px 14px; cursor: pointer; font: inherit; color: var(--ink); transition: transform .15s, border-color .15s; }
.chip:hover { transform: translateY(-2px); border-color: var(--ink); }
.chip .tag { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.chip .txt { font-size: .88rem; line-height: 1.35; color: var(--ink-2); }
.chip.normal .tag { color: var(--ok); }
.chip.vague .tag { color: var(--violet); }
.chip.trick .tag { color: var(--needle); }

/* ---------- run ---------- */
.run { background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
  padding: 24px; margin: 12px 0 40px; scroll-margin-top: 16px; }
.run-q span { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.run-q p { margin: 2px 0 16px; font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; }

.strip { position: relative; border-radius: 12px; overflow: hidden;
  background:
    linear-gradient(rgba(225, 29, 72, .08) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(90deg, rgba(225, 29, 72, .08) 1px, transparent 1px) 0 0 / 20px 20px,
    #fffdf8;
  border: 1px solid #f5e9e9; }
.strip svg { display: block; width: 100%; height: 110px; }
.strip path { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#strip-idle { stroke: rgba(15, 23, 42, .25); stroke-dasharray: 6 8; animation: drift 1s linear infinite; }
#reveal-rect { transition: width .6s ease-out; }
#pen { fill: var(--needle); transition: cx .6s ease-out, cy .6s ease-out; }
@keyframes drift { to { stroke-dashoffset: -28; } }
.strip-legend { position: absolute; right: 10px; bottom: 6px; display: flex; gap: 12px; font-size: .68rem; color: var(--muted); }
.strip-legend .ok::before, .strip-legend .bad::before { content: "●"; margin-right: 4px; }
.strip-legend .ok::before { color: var(--ok); }
.strip-legend .bad::before { color: var(--needle); }

.stations { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stations li { position: relative; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px; background: #fff;
  display: flex; flex-direction: column; gap: 2px; transition: all .3s; opacity: .55; }
.stations i { font-style: normal; font-size: 1.3rem; }
.stations b { font-size: .95rem; }
.stations small { color: var(--muted); font-size: .76rem; line-height: 1.35; }
.stations li.active { opacity: 1; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(67, 56, 202, .1); }
.stations li.active::after { content: ""; position: absolute; top: 12px; right: 12px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent); animation: blink 1s infinite; }
.stations li.pass { opacity: 1; border-color: #a7f3d0; background: var(--ok-bg); }
.stations li.fail { opacity: 1; border-color: #fecdd3; background: var(--bad-bg); }
.stations li.used { opacity: 1; border-color: #ddd6fe; background: #f5f3ff; }
.stations li.skip { opacity: .45; }
.stations li .badge { position: absolute; top: 10px; right: 10px; font-size: .7rem; font-weight: 700;
  padding: 1px 8px; border-radius: 999px; background: #fff; border: 1px solid currentColor; }
.stations li.pass .badge { color: var(--ok); }
.stations li.fail .badge { color: var(--needle); }
.stations li.used .badge { color: var(--violet); }
.stations li.skip .badge { color: var(--muted); }
@keyframes blink { 50% { opacity: .2; } }

.log { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 8px; }
.log li { display: flex; gap: 10px; align-items: flex-start; font-size: .93rem; color: var(--ink-2);
  animation: rise .35s ease-out; }
.log li .ico { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: .85rem; }
.log li.search .ico { background: #eef2ff; }
.log li.pass .ico { background: var(--ok-bg); }
.log li.fail .ico { background: var(--bad-bg); }
.log li.rewrite .ico { background: #f5f3ff; }
.log li.done .ico { background: var(--ok-bg); }
.log li.refuse .ico { background: var(--bad-bg); }
.log li.wait .ico { background: #f1f5f9; }
.log li em { color: var(--ink); font-style: normal; font-weight: 600; }
.log li .why { display: block; color: var(--muted); font-size: .84rem; }
.log li .pages { display: block; color: var(--muted); font-size: .8rem; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.result { margin-top: 22px; padding-top: 22px; border-top: 1px dashed var(--line); animation: rise .4s ease-out; }
.verdict { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: .82rem; letter-spacing: .08em;
  text-transform: uppercase; padding: 6px 14px; border-radius: 8px; border: 2px solid currentColor; transform: rotate(-1.5deg); }
.verdict.ok { color: var(--ok); background: var(--ok-bg); }
.verdict.no { color: var(--needle); background: var(--bad-bg); }
.notice { margin-top: 12px; font-size: .85rem; color: #92400e; background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 10px; padding: 8px 12px; }
.answer { margin-top: 14px; font-size: 1rem; color: var(--ink); overflow-wrap: anywhere; }
.answer p { margin: 0 0 .8em; }
.answer pre { background: var(--ink); color: #e2e8f0; padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: .82rem; }
.answer pre code { background: none; padding: 0; color: inherit; }
.answer .cite { display: inline-grid; place-items: center; min-width: 1.35em; height: 1.35em; padding: 0 .3em; margin: 0 1px;
  font-size: .7em; font-weight: 700; color: #fff; background: var(--accent); border-radius: 6px; text-decoration: none; vertical-align: .25em; }
.refusal-explain { color: var(--ink-2); }
.refusal-explain b { color: var(--ink); }

.sources { display: grid; gap: 8px; margin-top: 16px; }
.sources h4 { margin: 0; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.src { display: flex; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; text-decoration: none; color: inherit;
  transition: border-color .15s; scroll-margin-top: 80px; }
.src:hover, .src:target { border-color: var(--accent); }
.src .n { flex: none; width: 24px; height: 24px; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 700;
  font-size: .78rem; display: grid; place-items: center; }
.src .t { font-weight: 600; font-size: .9rem; color: var(--ink); }
.src .x { font-size: .8rem; color: var(--muted); line-height: 1.45; margin-top: 2px; }

.meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.meta span { font-size: .78rem; color: var(--ink-2); background: #f1f5f9; border-radius: 999px; padding: 3px 10px; }
.raw { margin-top: 14px; }
.raw summary { cursor: pointer; font-size: .85rem; color: var(--muted); font-weight: 600; }
.raw pre { font-size: .74rem; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  overflow: auto; max-height: 360px; white-space: pre-wrap; word-break: break-word; }

.error { color: var(--needle); font-weight: 600; }

/* ---------- results ---------- */
.results, .how { padding: 40px 0; scroll-margin-top: 16px; }
h2 { font-size: clamp(1.5rem, 4vw, 2.1rem); letter-spacing: -.02em; line-height: 1.15; margin: 0 0 10px; }
.sub { color: var(--ink-2); max-width: 680px; margin: 0 0 24px; }
.bars { display: grid; gap: 14px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.metric-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.metric h3 { margin: 0; font-size: 1.02rem; }
.metric .hint { color: var(--muted); font-size: .82rem; }
.metric .delta { font-weight: 800; font-size: .85rem; padding: 2px 10px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); white-space: nowrap; }
.row { display: grid; grid-template-columns: 130px 1fr 52px; align-items: center; gap: 10px; margin-top: 10px; font-size: .85rem; }
.row .lbl { color: var(--ink-2); }
.row .track { height: 14px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.row .fill { height: 100%; width: 0; border-radius: 999px; transition: width 1.1s cubic-bezier(.2, .8, .2, 1); }
.row.base .fill { background: #94a3b8; }
.row.ours .fill { background: var(--accent); }
.row .val { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.row.ours .lbl { color: var(--ink); font-weight: 700; }
.fine { color: var(--muted); font-size: .8rem; margin-top: 14px; }

/* ---------- how ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 20px; }
.cards article { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.cards .num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--ink);
  color: #fff; font-weight: 800; font-size: .9rem; }
.cards h3 { margin: 12px 0 6px; font-size: 1.02rem; }
.cards p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.stack { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.stack span { font-size: .8rem; font-weight: 600; color: var(--ink-2); border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 4px 12px; }

footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 32px 16px 48px; }
footer b { color: var(--ink); }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  nav a:not(.gh) { display: none; }
  .hero { padding-top: 24px; }
  .ask { border-radius: 16px; flex-direction: column; }
  .ask button { padding: 12px; border-radius: 12px; }
  .chip { max-width: none; width: 100%; }
  .run { padding: 16px; border-radius: 18px; }
  .stations { grid-template-columns: repeat(2, 1fr); }
  .strip-legend { display: none; }
  .cards { grid-template-columns: 1fr; }
  .row { grid-template-columns: 96px 1fr 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
