:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --text: #15202b;
  --muted: #5b6875;
  --border: #dde3e9;
  --accent: #0f5c8c;
  --accent-text: #ffffff;
  --ok: #1f7a4d;
  --warn: #9a5b00;
  --warn-bg: #fff4e0;
  --danger: #b3261e;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1318;
    --surface: #182029;
    --text: #e8edf2;
    --muted: #93a1ae;
    --border: #2a3542;
    --accent: #4fa3d9;
    --accent-text: #071621;
    --ok: #5cc493;
    --warn: #f0b45a;
    --warn-bg: #2d2412;
    --danger: #f28b82;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 560px; margin: 0 auto; padding: 12px 16px 32px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  max-width: 560px; margin: 0 auto;
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
h1 {
  /* Tall, thin, condensed sans serif. */
  font-family: "Oswald", "Bahnschrift Light Condensed", "Roboto Condensed", "Arial Narrow", sans-serif;
  font-weight: 300; font-size: 2.5rem; line-height: 1.1; letter-spacing: .01em;
  margin: 0; white-space: nowrap;
}
.app-version {
  font-family: Calibri, Carlito, "Segoe UI", sans-serif;
  font-size: .8rem; color: var(--muted); white-space: nowrap;
}
h2 { font-size: 1rem; margin: 0 0 8px; }

.topbar .pill { margin-left: auto; } /* stays right-aligned when it wraps under the title on phones */
.pill { font-size: .8rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); }
.pill-off { color: var(--muted); }
.pill-on { color: var(--ok); border-color: currentColor; }
.pill-sim { color: var(--warn); border-color: currentColor; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-head h2 { margin: 0; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary h2 { display: inline; }
details > summary::after { content: "▸"; float: right; color: var(--muted); }
details[open] > summary::after { content: "▾"; }
details[open] > summary { margin-bottom: 8px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-variant-numeric: tabular-nums; }
.warn { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 10px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 0; min-width: 0; }

.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; padding: 12px 14px; border-radius: 12px; cursor: pointer;
  min-height: 48px;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-big { width: 100%; font-size: 1.15rem; min-height: 64px; margin-bottom: 8px; }
.btn-small { padding: 6px 10px; min-height: 34px; font-size: .85rem; }
.btn-danger { color: var(--danger); }
.btn[aria-pressed="true"] { background: var(--danger); color: #fff; border-color: var(--danger); }

.actions { margin-bottom: 12px; }

.result-card { text-align: center; padding: 24px 16px; }
.result-label { color: var(--muted); font-size: .9rem; text-transform: uppercase; letter-spacing: .06em; }
.result-value { font-size: 3.2rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; margin: 6px 0; }
.result-detail { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.status { margin-top: 10px; font-size: .9rem; min-height: 1.3em; }
.status.is-warn { color: var(--warn); }
.status.is-error { color: var(--danger); }
.status.is-ok { color: var(--ok); }

input[type="text"], input[type="number"], select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
.field { display: block; margin: 10px 0; font-size: .9rem; color: var(--muted); }
.field > input, .field > select { margin-top: 4px; }
.field output { float: right; color: var(--text); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.seg { display: flex; gap: 8px; margin-bottom: 8px; }
.seg label {
  flex: 1; text-align: center; border: 1px solid var(--border); border-radius: 10px; padding: 10px;
  cursor: pointer;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.history { list-style: none; margin: 8px 0 0; padding: 0; }
.history li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.history .h-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .h-time { color: var(--muted); font-size: .8rem; }
.history .h-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.history button { background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 6px; }

.footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
