:root {
  --accent: #2f7cf6;
  --accent-ink: #fff;
  --bg: #f6f7fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --line: #dde2ea;
  --ink: #15181d;
  --muted: #5d6573;
  --good: #1e8e57;
  --warn: #b26a00;
  --bad: #c73a3a;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #5b9bff;
    --accent-ink: #0b0b0d;
    --bg: #0b0b0d;
    --surface: #121215;
    --surface-2: #1b1c21;
    --line: #2a2c33;
    --ink: #e8eaee;
    --muted: #9aa1ad;
    --good: #46c486;
    --warn: #e0a24a;
    --bad: #ef6b6b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: #5b9bff;
  --accent-ink: #0b0b0d;
  --bg: #0b0b0d;
  --surface: #121215;
  --surface-2: #1b1c21;
  --line: #2a2c33;
  --ink: #e8eaee;
  --muted: #9aa1ad;
  --good: #46c486;
  --warn: #e0a24a;
  --bad: #ef6b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "Noto Sans", sans-serif;
}
h1 { font-size: 1.5rem; margin: 0 0 .4rem; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 .6rem; }
.card > h2:first-child { margin-top: 0; }
a { color: var(--accent); }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 6px; font-size: .92em; word-break: break-all; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); margin: .2rem 0; }
.ok { color: var(--good); margin: .2rem 0; }

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink); cursor: pointer; display: grid; place-items: center; padding: 0;
}

.btn {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 9px 16px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.small { padding: 5px 11px; font-size: .88rem; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }

input, select {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font: inherit;
}
input:focus, select:focus, .btn:focus-visible, .tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; }
.row input { margin: 0; }
.help { color: var(--muted); margin: -6px 0 0; font-size: .9rem; }

.gate { display: grid; place-items: center; min-height: calc(100vh - 60px); padding: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  margin-bottom: 14px;
}
.card.narrow { width: 100%; max-width: 400px; }
.card.narrow form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.switch { text-align: center; margin: 12px 0 0; }

.shell { display: flex; max-width: 1100px; margin: 0 auto; }
.tabs { display: flex; flex-direction: column; gap: 2px; padding: 16px 8px; min-width: 170px; position: sticky; top: 56px; align-self: flex-start; }
.tabs button {
  text-align: left; background: none; border: 0; color: var(--ink); padding: 8px 12px; border-radius: 10px; font: inherit; cursor: pointer;
}
.tabs button.on { background: var(--surface-2); color: var(--accent); font-weight: 600; }
.content { flex: 1; min-width: 0; padding: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.grid .card { margin: 0; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin: 4px 0; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

.models { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.model { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.model header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.model h3 { margin: 0; font-size: 1rem; }
.model p { margin: 0; }
.model .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.pill { font-size: .78rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.good { color: var(--good); }
.pill.swap, .pill.slow { color: var(--warn); }
.pill.no { color: var(--bad); }
.pill.on { background: var(--accent); color: var(--accent-ink); }
.fit { font-size: .9rem; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.fit.good { border-left: 3px solid var(--good); }
.fit.swap, .fit.slow { border-left: 3px solid var(--warn); }
.fit.no { border-left: 3px solid var(--bad); }
.bar-track { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); transition: width .4s; }

.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 180px; }
.item .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.prose p { margin: 0 0 .7rem; }

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .tabs { flex-direction: row; overflow-x: auto; position: static; padding: 8px 16px; min-width: 0; }
  .tabs button { white-space: nowrap; }
  .content { padding: 0 16px 16px; }
  #who { display: none; }
  .models { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .bar-fill { transition: none; } }
