:root {
  --bg: #f4f5f7; --surface: #ffffff; --ink: #0f172a; --muted: #5b6475; --line: #e2e5ea;
  --accent: #2457ff; --accent-ink: #ffffff; --ok: #12805c; --warn: #a15c00; --bad: #c0262d;
  --ok-bg: #e4f5ee; --warn-bg: #fdf0d8; --bad-bg: #fde8e9; --bar: #2457ff; --bar-fail: #c0262d;
  --radius: 12px; --gutter: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --surface: #141b2e; --ink: #e8ecf6; --muted: #98a2b8; --line: #263049;
    --accent: #6c8dff; --accent-ink: #0b1020; --ok: #4cc9a0; --warn: #f0b252; --bad: #ff7a80;
    --ok-bg: #12332a; --warn-bg: #3a2c10; --bad-bg: #3b1a1d; --bar: #6c8dff; --bar-fail: #ff7a80;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

header.top {
  position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 12px var(--gutter); padding-top: calc(12px + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
main { max-width: 980px; margin: 0 auto; padding: 16px var(--gutter); display: grid; gap: 16px; }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface);
  border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  flex: 1; background: none; border: 0; color: var(--muted); padding: 12px 4px; font: inherit; font-size: 13px; cursor: pointer;
  min-height: 48px;
}
nav.tabs button[aria-current="page"] { color: var(--accent); font-weight: 600; box-shadow: inset 0 2px 0 var(--accent); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 8px; }

label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; width: 100%; min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; }

button.btn {
  font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; min-height: 44px; cursor: pointer;
}
button.btn.ghost { background: transparent; color: var(--accent); }
button.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
button.btn:disabled { opacity: .55; cursor: progress; }

.pill { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

.notice { padding: 10px 12px; border-radius: 8px; font-size: 14px; background: var(--warn-bg); color: var(--warn); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }

.answer { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 12px; border: 1px solid var(--line); }
.code { font: 600 28px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 110px; }
.bars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .seg-ok { background: var(--bar); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars .seg-fail { background: var(--bar-fail); }
.bars-labels { display: flex; gap: 4px; font-size: 11px; color: var(--muted); }
.bars-labels span { flex: 1; text-align: center; overflow: hidden; }

.login { max-width: 380px; margin: 12vh auto 0; padding: 0 var(--gutter); }

@media (min-width: 760px) {
  body { padding-bottom: 0; }
  nav.tabs { position: static; border: 0; background: none; max-width: 980px; margin: 0 auto; padding: 8px var(--gutter) 0; gap: 4px; }
  nav.tabs button { flex: none; padding: 10px 16px; border-radius: 8px; min-height: 40px; }
  nav.tabs button[aria-current="page"] { background: var(--surface); box-shadow: none; border: 1px solid var(--line); }
}
@media (prefers-reduced-motion: no-preference) { button.btn { transition: opacity .15s; } }
