:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #16181d;
  --muted: #5d6573;
  --line: #dde1e7;
  --accent: #d9771c;
  --accent-text: #ffffff;
  --danger: #c0352b;
  --ok-bg: #e6f4ea;
  --ok-text: #1d6b34;
  --error-bg: #fbe9e7;
  --error-text: #a3261c;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1a1d23;
    --text: #e8eaee;
    --muted: #9aa3b2;
    --line: #2c313a;
    --accent: #f0903a;
    --accent-text: #15120e;
    --danger: #ef6b5f;
    --ok-bg: #173323;
    --ok-text: #8fd9a8;
    --error-bg: #3a1c19;
    --error-text: #ffb4ab;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.92em; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: 0.01em; }
.brand span { color: var(--accent); }

.tabs, .subtabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.subtabs { padding: 0 0 12px; background: none; border: 0; }
.tabs a, .subtabs a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.tabs a[aria-current="page"], .subtabs a[aria-current="page"] { background: var(--accent); color: var(--accent-text); }

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card.narrow { max-width: 420px; margin: 48px auto; text-align: center; }
h1, h2 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); font-size: 0.92rem; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.badge { font-size: 0.8rem; background: var(--error-bg); color: var(--error-text); padding: 2px 8px; border-radius: 999px; }

form.stack { display: flex; flex-direction: column; gap: 8px; }
form.row, div.row { display: flex; gap: 8px; flex-wrap: wrap; }
form.row > input, form.row > select, div.row > input { flex: 1 1 200px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; }
.grid .wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field code { color: var(--muted); font-size: 0.78rem; }

input, select, textarea {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  min-width: 0;
}
textarea { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button, .button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.danger { background: var(--danger); color: #fff; }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 500; }
button.link.danger { color: var(--danger); background: none; }
.button.steam { background: #171a21; color: #fff; margin-top: 8px; }

.choices { display: grid; gap: 8px; }
.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); }
.choice span { display: flex; flex-direction: column; }
.choice small, .flag small { color: var(--muted); }

.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--error-bg); color: var(--error-text); }
ul.flash { padding-left: 32px; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { color: var(--muted); font-weight: 500; font-size: 0.88rem; }
td.actions { white-space: nowrap; display: flex; gap: 12px; }
td.actions form { display: inline; }
table.log td { overflow-wrap: anywhere; }

fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; }
legend { padding: 0 6px; color: var(--muted); }
.kind label { margin-right: 16px; }
[data-kind] { display: flex; flex-direction: column; gap: 8px; }
.flags { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 12px; }
.flags legend, .presets { grid-column: 1 / -1; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.chip { background: var(--bg); color: var(--text); border: 1px solid var(--line); padding: 4px 10px; font-weight: 500; }
.flag { display: flex; gap: 8px; align-items: flex-start; }
.flag span { display: flex; flex-direction: column; line-height: 1.3; }
.flag code { color: var(--accent); font-weight: 700; padding-top: 1px; }

.cycles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.maplist { line-height: 2; }
.maplist code { background: var(--bg); padding: 2px 6px; border-radius: 6px; }

pre.output {
  background: #0d0f12;
  color: #d6dbe3;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  max-height: 60vh;
  font-size: 0.85rem;
}
.commands { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.commands dd { margin: 0; color: var(--muted); }

@media (max-width: 520px) {
  main { padding: 12px; }
  .card { padding: 14px; }
  .commands, .facts { grid-template-columns: 1fr; }
  .commands dd { margin-bottom: 6px; }
  table.list th:nth-child(3), table.list td:nth-child(3) { display: none; }
  table.log th:nth-child(3), table.log td:nth-child(3) { display: table-cell; }
}
