:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --sunken: #eef0f3;
  --text: #17191d;
  --muted: #5a616e;
  --line: #dadee4;
  --accent: #2851c8;
  --accent-text: #ffffff;
  --accent-soft: #e8eefc;
  --danger: #b42318;
  --ok: #17703d;
  --warn: #8a5300;
  --warn-soft: #fff3d6;
  --mine: #eef3ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --sunken: #1f242c;
    --text: #e8eaed;
    --muted: #a3aab5;
    --line: #2d333c;
    --accent: #8fa8ff;
    --accent-text: #0b1020;
    --accent-soft: #1d2640;
    --danger: #ff9a8f;
    --ok: #6fd39a;
    --warn: #f2c25b;
    --warn-soft: #33290f;
    --mine: #1c2540;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
footer { max-width: 1040px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: 0.85rem; }
a { color: var(--accent); text-underline-offset: 2px; }
h1 { font-size: 1.65rem; line-height: 1.25; margin: 0 0 6px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 4px; }
section { margin: 28px 0 0; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
p { margin: 0 0 10px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 6px; z-index: 2; }
.skip:focus { left: 8px; }

header.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.bar { max-width: 1040px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.brand span { color: var(--accent); }
.brand .dot { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff 0 12%, var(--accent) 45%, #13254f 100%); }
nav { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; margin-left: auto; }
nav a { text-decoration: none; padding: 4px 2px; }
nav a:hover { text-decoration: underline; }
a.who { color: var(--muted); }

.narrow { max-width: 460px; margin: 24px auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.narrow h1 { margin-bottom: 12px; }
.narrow > :last-child { margin-bottom: 0; }
.show-narrow { display: none; }
.muted { color: var(--muted); }
.small, small { font-size: 0.85rem; }
.crumbs { margin: 0 0 6px; color: var(--muted); font-size: 0.9rem; }
.crumbs a { color: var(--muted); }
.error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); padding: 10px 12px; border-radius: var(--radius); }
.notice { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); padding: 10px 12px; border-radius: var(--radius); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 24px; justify-content: space-between; }
.page-head > div { min-width: 0; }
.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 0; padding: 0; list-style: none; }
.subnav a { display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); text-decoration: none; font-size: 0.9rem; }
.subnav a:hover { border-color: var(--accent); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin: 0 0 12px; }
.section-head h2 { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 12px; box-shadow: var(--shadow); }
.card .body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 8px; }
.card > :last-child { margin-bottom: 0; }
.card h1 { margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.grid .card { margin: 0; }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--accent); }
a.card h3 { color: var(--accent); }
.empty { text-align: center; padding: 28px 16px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty p:last-child { margin-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 16px 0 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 0.85rem; }
.stat.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); background: var(--warn-soft); }
.stat.warn b { color: var(--warn); }

progress { appearance: none; width: 100%; height: 8px; border: none; border-radius: 999px; background: var(--sunken); overflow: hidden; vertical-align: middle; }
progress::-webkit-progress-bar { background: var(--sunken); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--ok); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--ok); border-radius: 999px; }
.progress-row { display: flex; align-items: center; gap: 12px; margin: 14px 0 0; }
.progress-row progress { flex: 1; }
.progress-row span { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
td progress { width: 90px; }

ol.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
ol.steps li { counter-increment: step; display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
ol.steps li:first-child { border-top: none; }
ol.steps li::before { content: counter(step); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; border: 2px solid var(--line); color: var(--muted); }
ol.steps li.done::before { content: "✓"; background: var(--ok); border-color: var(--ok); color: var(--surface); }
ol.steps li.done .what { color: var(--muted); text-decoration: line-through; }
ol.steps li.next::before { border-color: var(--accent); color: var(--accent); }
ol.steps .what { font-weight: 600; }
ol.steps small { display: block; color: var(--muted); }

form.stack { display: flex; flex-direction: column; gap: 14px; margin: 12px 0 0; }
form.stack label, .row label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
form.stack label small, .row label small { font-weight: 400; }
label.check { flex-direction: row !important; align-items: center; gap: 8px; font-weight: 500 !important; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row label { flex: 1 1 170px; }
form.inline, form.inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; flex-wrap: wrap; }
form.inline-form label { font-weight: 500; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; min-height: 42px;
}
textarea { min-height: 0; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
form.inline-form select { width: auto; min-width: 0; max-width: 220px; min-height: 36px; padding: 5px 8px; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); }

button, a.button {
  font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent);
  border-radius: 8px; padding: 8px 16px; min-height: 40px; align-self: flex-start;
}
button:hover, a.button:hover { filter: brightness(1.08); }
button.secondary, a.button.secondary { background: var(--surface); color: var(--accent); border-color: var(--line); }
button.secondary:hover, a.button.secondary:hover { border-color: var(--accent); filter: none; }
button.small, a.button.small, form.inline-form button { min-height: 34px; padding: 4px 12px; font-size: 0.9rem; }
button.link { background: none; border: none; padding: 2px 0; min-height: 0; color: var(--accent); font-weight: 500; }
button.link:hover { text-decoration: underline; filter: none; }
button.link.danger { color: var(--danger); }
button.copy { min-height: 30px; padding: 2px 10px; font-size: 0.85rem; }
button.copy.done { color: var(--ok); border-color: var(--ok); }
button[aria-pressed=true] { background: var(--accent-soft); color: var(--text); border-color: var(--accent); cursor: default; }

details { margin: 12px 0 0; }
details.card > summary { margin: -16px; padding: 14px 16px; }
details.card[open] > summary { margin-bottom: 0; border-bottom: 1px solid var(--line); }
summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style-position: inside; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; background: var(--sunken); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form + form { margin-left: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.mine td { background: var(--mine); }
tr.todo td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
tr.dead td { opacity: 0.55; }

.tag { display: inline-block; font-size: 0.75rem; font-weight: 600; line-height: 1.6; padding: 0 8px; border-radius: 999px; border: 1px solid currentColor; color: var(--muted); vertical-align: middle; white-space: nowrap; }
.tag.active, .tag.s-submitted { color: var(--ok); }
.tag.s-reviewed { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.tag.s-in_progress { color: var(--accent); }
.tag.warn { color: var(--warn); background: var(--warn-soft); }
.tag.role { color: var(--accent); border-color: transparent; background: var(--accent-soft); }
code.set { font-weight: 700; letter-spacing: 0.04em; font-size: 1.02rem; }
ul.reviewers { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
ul.reviewers li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
ul.plain { margin: 0; padding: 0; list-style: none; }

.invite { display: flex; flex-direction: column; gap: 8px; }
.invite .code-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
code.invite { font-size: 1.35rem; font-weight: 700; letter-spacing: 0.08em; }
.link-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.link-line code { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; background: var(--sunken); padding: 3px 8px; border-radius: 6px; user-select: all; }
.invite .meta { color: var(--muted); font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.invite.dead { opacity: 0.6; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.secret { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.secret code { font-size: 1.4rem; font-weight: 700; letter-spacing: 0.06em; padding: 8px 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius); user-select: all; }

@media (max-width: 640px) {
  main { padding-top: 16px; }
  h1 { font-size: 1.4rem; }
  nav { margin-left: 0; width: 100%; }
  th, td { padding: 8px 10px; }
  .hide-narrow { display: none; }
  br.show-narrow { display: inline; }
  small.show-narrow { display: inline; }
  .narrow { padding: 18px; margin-top: 8px; }
}

@media (prefers-reduced-motion: no-preference) {
  a.card, button, .subnav a { transition: border-color 0.15s, filter 0.15s; }
}
