:root {
  --bg: #0d0f0d;
  --surface: #151815;
  --surface-2: #1c201c;
  --line: #2a2f2a;
  --text: #eef0ea;
  --muted: #9aa29a;
  --accent: #c8f53a;
  --accent-ink: #0d0f0d;
  --accent-text: #c8f53a;
  --ok: #6be38f;
  --warn: #ffb547;
  --bad: #ff6b5b;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px rgba(0,0,0,.25);
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f4ee;
    --surface: #ffffff;
    --surface-2: #f0efe8;
    --line: #e0ded3;
    --text: #141613;
    --muted: #5e635c;
    --accent: #c8f53a;
    --accent-ink: #141613;
    --accent-text: #3f6a00;
    --ok: #16883f;
    --warn: #a86400;
    --bad: #c4321f;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font: 700 20px/1 var(--display); letter-spacing: -.02em; }
.logo b { color: var(--accent-text); font-weight: 800; }
.logo-bg { fill: var(--text); }
.logo-m { stroke: var(--accent); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-color-scheme: light) { .logo-bg { fill: #141613; } }
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-left: auto; }
.tabs button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  color: var(--muted); font-weight: 500; white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.access input { width: 140px; }

.banner { margin: 16px auto 0; max-width: 980px; width: calc(100% - 32px); padding: 12px 16px; border-radius: 10px; border: 1px solid var(--warn); color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); }

main { flex: 1; width: 100%; max-width: 1020px; margin: 0 auto; padding: 0 16px 60px; }

/* ---------- hero ---------- */
.hero { padding: 44px 4px 22px; }
.hero h1 { font: 800 clamp(34px, 6vw, 58px)/1 var(--display); letter-spacing: -.035em; margin: 0 0 12px; }
.hero h1 em { font-style: normal; color: var(--accent-text); position: relative; }
.hero p { margin: 0; color: var(--muted); max-width: 620px; font-size: 17px; }

/* ---------- cards + forms ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.form { display: grid; gap: 14px; }
.form label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
.form label > input, .form label > select { margin-top: 6px; }
.opt { font-weight: 400; opacity: .7; }
input, select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 15px; font-weight: 400; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type="range"] { padding: 0; background: transparent; border: 0; accent-color: var(--accent); width: 120px; box-shadow: none; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.row.tight { gap: 8px; flex-wrap: nowrap; }
.form label.inline, .form label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.form label.inline > input, .form label.check > input { margin-top: 0; }
output { font-family: var(--mono); min-width: 22px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.row .btn.primary { margin-left: auto; }

.btn {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 10px 16px;
  cursor: pointer; font-weight: 600; white-space: nowrap; transition: transform .08s ease, opacity .2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; padding: 11px 20px; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.link-btn { background: none; border: 0; color: var(--accent-text); cursor: pointer; padding: 0; font-weight: 600; font-size: 13px; }

/* ---------- progress ---------- */
.progress-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-weight: 600; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.bar.indeterminate i { width: 35%; animation: slide 1.3s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.runs { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; max-height: 340px; overflow: auto; }
.runs li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start; font-size: 14px; padding: 6px 8px; border-radius: 8px; }
.runs li:nth-child(odd) { background: var(--surface-2); }
.runs .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--line); }
.runs .dot.run { background: var(--warn); animation: pulse 1s infinite; }
.runs .dot.yes { background: var(--ok); }
.runs .dot.no { background: var(--bad); }
.runs .dot.err { background: var(--muted); }
.runs .tagset { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- results ---------- */
.result-grid { display: grid; grid-template-columns: 300px 1fr; gap: 18px; margin-bottom: 18px; }
.scorecard { display: grid; place-items: center; text-align: center; gap: 8px; }
.dial { position: relative; width: 190px; height: 190px; }
.dial svg { transform: rotate(-90deg); }
.dial .val { position: absolute; inset: 0; display: grid; place-content: center; }
.dial .num { font: 800 54px/1 var(--display); letter-spacing: -.04em; }
.dial .of { color: var(--muted); font-size: 13px; }
.grade { font: 700 14px var(--mono); padding: 4px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); }
.headline { font: 700 22px/1.25 var(--display); letter-spacing: -.02em; margin: 0 0 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.tile { background: var(--surface-2); border-radius: 10px; padding: 12px; }
.tile .k { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tile .v { font: 700 26px/1.1 var(--display); margin-top: 4px; overflow-wrap: anywhere; }
.tile .s { color: var(--muted); font-size: 12px; }

h2 { font: 700 22px/1.2 var(--display); letter-spacing: -.02em; margin: 0 0 12px; }
h3 { font: 700 16px/1.3 var(--display); margin: 0 0 10px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 26px 0 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.bars { display: grid; gap: 8px; }
.barrow { display: grid; grid-template-columns: 140px 1fr 44px; gap: 10px; align-items: center; font-size: 14px; }
.barrow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barrow .track { display: block; height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.barrow .fill { display: block; height: 100%; background: var(--muted); border-radius: 99px; }
.barrow.me .fill { background: var(--accent); }
.barrow.me .name { font-weight: 700; color: var(--accent-text); }
.barrow .pct { font-family: var(--mono); font-size: 13px; text-align: right; color: var(--muted); }

.actions { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.actions li { padding: 12px 14px; background: var(--surface-2); border-radius: 10px; border-left: 3px solid var(--line); }
.actions li.high { border-left-color: var(--accent); }
.actions li.medium { border-left-color: var(--warn); }
.actions b { display: block; margin-bottom: 2px; }
.actions p { margin: 0; color: var(--muted); font-size: 14px; }

.pill { display: inline-block; font: 500 11px/1 var(--mono); padding: 4px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; text-transform: uppercase; letter-spacing: .03em; }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pill.acc { color: var(--accent-ink); background: var(--accent); border-color: transparent; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
td .sub { color: var(--muted); font-size: 12px; display: block; }

details.answer { margin-top: 4px; }
details.answer summary { cursor: pointer; color: var(--accent-text); font-size: 13px; font-weight: 600; }
details.answer .body { margin-top: 8px; padding: 12px; background: var(--surface-2); border-radius: 8px; font-size: 14px; max-height: 360px; overflow: auto; }
details.answer .body p:first-child { margin-top: 0; }
mark { background: var(--accent); color: var(--accent-ink); padding: 0 3px; border-radius: 3px; }

.list { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.ideas { display: grid; gap: 8px; }
.idea { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.idea .q { font-weight: 600; }
.idea .a { color: var(--muted); font-size: 13px; }
.idea .btns { display: flex; gap: 6px; flex-shrink: 0; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- terms ---------- */
.terms { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.term { position: relative; cursor: pointer; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 14px 12px; display: grid; gap: 6px; transition: border-color .15s, transform .15s; }
.term:hover { transform: translateY(-1px); }
.term.selected { border-color: var(--accent-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.term .name { font: 800 19px/1.15 var(--display); letter-spacing: -.02em; }
.term .def { font-size: 14px; color: var(--muted); }
.term .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.term input { position: absolute; opacity: 0; pointer-events: none; }

/* ---------- article ---------- */
.article-layout { display: grid; grid-template-columns: 1fr 290px; gap: 18px; align-items: start; }
.viewtabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.viewtabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.viewtabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.prose { font-size: 16px; line-height: 1.7; }
.prose h1 { font: 800 32px/1.1 var(--display); letter-spacing: -.03em; }
.prose h2 { font-size: 24px; margin-top: 32px; }
.prose h3 { font-size: 18px; margin-top: 22px; }
.prose blockquote { margin: 18px 0; padding: 14px 16px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.prose blockquote p { margin: 0; }
.prose table { margin: 16px 0; }
.prose code { font-family: var(--mono); font-size: 14px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.prose .ph { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); padding: 0 4px; border-radius: 4px; font-size: 14px; }
pre.code { white-space: pre-wrap; word-break: break-word; font: 13px/1.6 var(--mono); background: var(--surface-2); padding: 14px; border-radius: 10px; max-height: 640px; overflow: auto; margin: 0; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; font-size: 14px; }
.checks li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; }
.checks .i { font-weight: 700; }
.checks .p { color: var(--ok); }
.checks .f { color: var(--bad); }
.metabox { display: grid; gap: 10px; font-size: 14px; }
.metabox .k { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.side { position: sticky; top: 80px; display: grid; gap: 14px; }
.side .card { margin: 0; }
.bigscore { font: 800 44px/1 var(--display); letter-spacing: -.03em; }

.chip-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { display: inline-flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; }
.chip button { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 0; font-size: 15px; line-height: 1; }

.history { margin-top: 30px; }
.history .item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }

.empty { color: var(--muted); font-size: 14px; }
.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: calc(100% - 32px); }
.toast.err { background: var(--bad); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .result-grid, .cols, .article-layout { grid-template-columns: 1fr; }
  .side { position: static; }
}
@media (max-width: 640px) {
  .top { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .tabs { margin-left: 0; width: 100%; overflow-x: auto; }
  .tabs button { flex: 1; padding: 7px 8px; font-size: 13px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .row .btn.primary { margin-left: 0; width: 100%; }
  .barrow { grid-template-columns: 100px 1fr 40px; }
  .idea { flex-direction: column; align-items: flex-start; }
  .row.tight { flex-wrap: wrap; }
  .hero { padding-top: 28px; }
}
