:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5d6470;
  --line: #e2e5ea;
  --accent: #e8590c;
  --accent-text: #ffffff;
  --ok-bg: #e6f4ea; --ok: #1e6b34;
  --bad-bg: #fdecea; --bad: #a4251b;
  --info-bg: #e8f0fe; --info: #1a4fa0;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --surface: #1b1e24; --text: #eceef2; --muted: #9aa2ae; --line: #2c3038;
    --accent: #ff7a2f; --accent-text: #111317;
    --ok-bg: #16301f; --ok: #7fd49a; --bad-bg: #3a1a17; --bad: #ff9a8f; --info-bg: #182640; --info: #8fb6ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: .25rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
section.card > h2:first-child { margin-top: 0; }
h3 { font-size: .95rem; margin: 1.25rem 0 .4rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; text-align: center; padding: 12px 4px; min-height: 48px;
  color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 600;
}
.tabs a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

.cards, .plain { list-style: none; margin: 0; padding: 0; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px;
}
section.card { padding: 16px; margin-bottom: 16px; }
.plain li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.plain li:last-child { border-bottom: 0; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.row > div:first-child { min-width: 0; }
.row.gap { justify-content: flex-start; gap: 8px; margin-top: 8px; }
.wrap { flex-wrap: wrap; }
.right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.top-space { margin-top: 12px; }
.stack { display: grid; gap: 12px; }
.narrow { max-width: 420px; margin: 8vh auto 0; }
form.inline { display: inline; margin: 0; }

label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
input, select, button { font: inherit; }
input, select {
  width: 100%; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text);
}
.row select { width: auto; flex: 1; min-width: 0; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button {
  min-height: 44px; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 600;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
button.link { background: none; border: 0; padding: 4px; min-height: 0; color: var(--accent); text-decoration: underline; }
button.danger { color: var(--bad); }

.badge {
  display: inline-block; white-space: nowrap; padding: 2px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; background: var(--bg); color: var(--muted);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--info-bg); color: var(--info); }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.bad { background: var(--bad-bg); color: var(--bad); }
.flash a { color: inherit; font-weight: 700; }
.copy { margin-top: 8px; font-family: ui-monospace, monospace; font-size: .85rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { min-height: 32px; padding: 4px 10px; border-radius: 999px; font-size: .85rem; background: var(--bg); }
pre { white-space: pre-wrap; margin: 4px 0 0; color: var(--muted); }
