:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #16191f;
  --muted: #5d6573;
  --line: #e1e4ea;
  --accent: #b8860b;
  --accent-text: #ffffff;
  --ok: #1d7a46;
  --ok-bg: #e5f4ea;
  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --bad: #b42318;
  --bad-bg: #fde8e6;
  --live: #b42318;
  --paper: #2459a8;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101318;
    --card: #191d24;
    --text: #e9ecf1;
    --muted: #9aa3b2;
    --line: #2a303a;
    --accent: #d4a62a;
    --accent-text: #15120a;
    --ok: #5fd08f;
    --ok-bg: #12301f;
    --warn: #f1c24f;
    --warn-bg: #332a10;
    --bad: #ff8a80;
    --bad-bg: #3a1714;
    --live: #ff6b5e;
    --paper: #78a6ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.top nav { display: flex; gap: 14px; margin-left: auto; }
.top nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.top nav a:hover { color: var(--text); }
main { max-width: 720px; margin: 0 auto; padding: 16px; }
footer { max-width: 720px; margin: 0 auto 32px; padding: 0 16px; text-align: center; }
h1 { font-size: 1.45rem; margin: 8px 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 14px 0 6px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 0 0 14px;
}
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; letter-spacing: .02em; color: #fff;
}
.badge.paper { background: var(--paper); }
.badge.live { background: var(--live); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.pill.on { background: var(--ok-bg); color: var(--ok); }
.pill.off { background: var(--line); color: var(--muted); }
.pill.long { background: var(--ok-bg); color: var(--ok); }
.pill.short { background: var(--bad-bg); color: var(--bad); }
.pill.flat { background: var(--line); color: var(--muted); }
.flash, .alert { padding: 12px 14px; border-radius: var(--radius); margin: 0 0 14px; }
.flash.ok, .alert.ok { background: var(--ok-bg); color: var(--ok); }
.flash.warn, .alert.warn { background: var(--warn-bg); color: var(--warn); }
.flash.error, .alert.error { background: var(--bad-bg); color: var(--bad); }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.status-row:first-of-type { border-top: 0; padding-top: 0; }
.status-row .label { color: var(--muted); font-size: .9rem; }
.status-row .value { font-weight: 600; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 8px 0 0; }
dl.facts dt { color: var(--muted); font-size: .9rem; }
dl.facts dd { margin: 0; font-weight: 500; word-break: break-word; }
button, .button {
  display: inline-block; appearance: none; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px;
  cursor: pointer; text-decoration: none; text-align: center; min-height: 44px;
}
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger, .button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.block, .button.block { display: block; width: 100%; }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 6px; min-height: 0; }
button.small, .button.small { padding: 6px 12px; min-height: 36px; font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.actions form { margin: 0; }
form.inline { display: inline; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=date], input[inputmode], textarea, select {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
input[type=checkbox] { width: 20px; height: 20px; }
textarea { min-height: 110px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }
.hint { color: var(--muted); font-size: .875rem; margin: 4px 0 0; }
.copybox { display: flex; gap: 8px; align-items: stretch; margin: 6px 0 12px; }
.copybox code, .copybox input { flex: 1; min-width: 0; }
code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
code { padding: 8px 10px; display: block; word-break: break-all; }
pre { padding: 12px; overflow-x: auto; max-height: 320px; margin: 6px 0 0; }
ol.steps, ul.plain { padding-left: 22px; }
ol.steps li { margin: 6px 0; }
.wizard { display: flex; gap: 4px; margin: 0 0 6px; }
.wizard span { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.wizard span.done { background: var(--accent); }
.wizard-label { color: var(--muted); font-size: .85rem; margin: 0 0 12px; }
.qr { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 8px; display: block; margin: 8px 0; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.codes code { text-align: center; font-size: 1rem; }
.instrument h2 { display: flex; align-items: center; gap: 8px; }
.events { list-style: none; padding: 0; margin: 0; }
.events li { padding: 10px 0; border-top: 1px solid var(--line); }
.events li:first-child { border-top: 0; }
.events .meta { color: var(--muted); font-size: .8rem; }
.events .kind { text-transform: uppercase; font-weight: 700; letter-spacing: .03em; }
.pager { display: flex; justify-content: space-between; margin-top: 12px; }
.device { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.device:first-child { border-top: 0; }
details summary { cursor: pointer; font-weight: 600; }
.error-text { color: var(--bad); font-weight: 600; }
.center { text-align: center; }
@media (min-width: 640px) {
  .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
}
code.inline-code { display: inline; padding: 1px 6px; word-break: break-all; }
.spaced { margin-top: 20px; }
