:root {
  --bg: #f6f7f9; --card: #fff; --fg: #1d2330; --muted: #667085; --line: #dde1e8;
  --space-xs: .25rem; --space-sm: .5rem; --space-md: .75rem; --space-lg: 1rem; --space-xl: 1.25rem;
  --radius-sm: 6px; --radius-md: 8px; --radius-lg: 10px; --radius-xs: 4px;
  --page-width: 56rem;
  --accent: #2f6fed; --accent-fg: #fff; --danger: #c5302a; --ok-bg: #e7f6ec; --ok-fg: #17653a; --err-bg: #fdecea; --err-fg: #8f1f1a;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171d; --card: #1c2029; --fg: #e6e9f0; --muted: #9aa3b5; --line: #2c3240;
    --accent: #6b9bff; --accent-fg: #0d1220; --danger: #ff7b73; --ok-bg: #12301f; --ok-fg: #7fd9a1; --err-bg: #3a1815; --err-fg: #ffaba5; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, sans-serif; }
header,footer { background: var(--card); border-bottom: 1px solid var(--line); }
header .bar, footer .bar { max-width: var(--page-width); margin: 0 auto; padding: var(--space-sm) var(--space-lg); display: flex; gap: var(--space-lg); align-items: center; flex-wrap: wrap; }
header a.brand { display: flex; align-items: center; gap: var(--space-sm); padding: 0; font-weight: 600; font-size: 1.1rem; user-select: none; }
header a.brand:hover { background: none; }
.hero { display: flex; flex-direction: column; align-items: center; gap: var(--space-sm); font-weight: 600; font-size: 1.25rem; user-select: none; }
header .menu { display: flex; gap: var(--space-lg); align-items: center; flex-wrap: wrap; margin-left: auto; }
header .menu-toggle, header .menu-btn { display: none; }
header nav { display: flex; gap: var(--space-xs); flex-wrap: wrap; }
header a, footer a { color: var(--fg); text-decoration: none; padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-sm); }
header a.active, header a:hover, , footer a.active { background: var(--bg); }
header a.active, footer a.active { font-weight: 600; }
main { max-width: var(--page-width); margin: 1.5rem auto; padding: 0 var(--space-lg); }
p { margin: 0; }
h1 { font-size: 1.4rem; margin: 0 0 var(--space-lg); }
.page-head { display: flex; gap: var(--space-lg); justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: var(--space-sm); color: var(--muted); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--fg); text-decoration: underline; }
.subnav { display: flex; gap: var(--space-xs) var(--space-lg); flex-wrap: wrap; margin: calc(-1 * var(--space-sm)) 0 var(--space-xl); font-size: .9rem; }
h2 { font-size: 1.05rem; margin: 0; }
section, .card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-lg) var(--space-xl); margin-bottom: var(--space-xl); }
/* vertical rhythm inside boxes: one gap between siblings, no stray margins */
section > * + *, .card > * + *, .flash > * + *, details.fold > * + * { margin-top: var(--space-md); }
.narrow { max-width: 24rem; margin: 3rem auto; }
table { width: 100%; border-collapse: collapse; }
td.actions, th.actions { text-align: right; white-space: nowrap; }
td.actions .row { justify-content: flex-end; flex-wrap: nowrap; }
th, td { text-align: left; padding: .45rem var(--space-sm); border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
tr:last-child td { border-bottom: 0; }
form.stack { display: grid; gap: var(--space-md); max-width: 26rem; }
label { display: grid; gap: var(--space-xs); font-weight: 600; font-size: .9rem; }
label.inline { display: flex; gap: var(--space-sm); align-items: center; font-weight: 400; }
input[type=text], input[type=password], input[type=email], input[type=number], select {
  font: inherit; padding: .45rem var(--space-sm); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); color: var(--fg); width: 100%; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, .btn { font: inherit; cursor: pointer; padding: .45rem .9rem; border-radius: var(--radius-sm); border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); text-decoration: none; display: inline-block; }
button.secondary, .btn.secondary { background: transparent; color: var(--accent); }
button:hover, .btn:hover { filter: brightness(1.1); }
button.secondary:hover, .btn.secondary:hover, button.danger:hover { background: var(--bg); filter: none; }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.small { padding: .15rem var(--space-sm); font-size: .9rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.danger-zone { border-color: var(--danger); }
.danger-zone h2 { color: var(--danger); }
.hint { color: var(--muted); font-size: .85rem; font-weight: 400; }
.checks { display: flex; gap: var(--space-xs) var(--space-xl); flex-wrap: wrap; }
code.copy { user-select: all; }
details.fold { margin-bottom: var(--space-xl); }
details.fold > summary { list-style: none; cursor: pointer; display: inline-block; }
details.fold > summary::-webkit-details-marker { display: none; }
section > details.fold { margin-bottom: 0; }

.muted { color: var(--muted); }
.swatch { vertical-align: -1px; margin-right: .35rem; }
.flash, .error { padding: var(--space-sm) .9rem; border-radius: var(--radius-md); margin-bottom: var(--space-lg); }
section .flash { margin-bottom: 0; }
.flash { background: var(--ok-bg); color: var(--ok-fg); }
.error { background: var(--err-bg); color: var(--err-fg); }
code { background: var(--bg); padding: .1rem .35rem; border-radius: var(--radius-xs); word-break: break-all; }
.row { display: flex; gap: var(--space-sm); flex-wrap: wrap; align-items: center; }
.tag { font-size: .75rem; border: 1px solid var(--line); border-radius: 999px; padding: 0 .5rem; color: var(--muted); }
@media (max-width: 36rem) { th.hide, td.hide { display: none; }
  header .bar { gap: var(--space-sm); justify-content: space-between; }
  header a.brand span { display: none; }
  header .menu-btn { display: flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
  header .menu-btn span, header .menu-btn span::before, header .menu-btn span::after { display: block; width: 1.1rem; height: 2px; background: var(--fg); position: relative; }
  header .menu-btn span::before, header .menu-btn span::after { content: ""; position: absolute; left: 0; }
  header .menu-btn span::before { top: -6px; }
  header .menu-btn span::after { top: 6px; }
  header .menu-toggle:focus-visible + .menu-btn { outline: 2px solid var(--accent); outline-offset: 2px; }
  header .menu { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: var(--space-sm); margin-left: 0; }
  header .menu-toggle:checked ~ .menu { display: flex; }
  header nav { flex-direction: column; }
  header nav a { padding: var(--space-sm); }
  header .menu form.row { justify-content: space-between; flex-wrap: nowrap; border-top: 1px solid var(--line); padding-top: var(--space-sm); } }

.card h1 { margin-bottom: 0; }
.narrow button[type=submit] { width: 100%; }
.quote { text-align: center; font-size: .85rem; }
.colorfield { display: flex; gap: var(--space-sm); align-items: center; }
.colorfield input[type=color] { display: none; width: 2.4rem; height: 2.2rem; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); cursor: pointer; flex: none; }
.colorfield.enhanced input[type=color] { display: block; }
