:root {
  --bg: #0b1220;
  --card: #111827;
  --line: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #0ea5e9;
  --warn: #fbbf24;
  --bad: #f87171;
  --ok: #86efac;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
code { word-break: break-all; }
.app { min-height: 100dvh; }
.topbar {
  display: flex;
  align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: #0f172a;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.brand strong { display: block; font-size: 1.05rem; }
.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70vw;
}
.mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background:
    linear-gradient(var(--accent), var(--accent)) center/3px 16px no-repeat,
    linear-gradient(var(--accent), var(--accent)) center/16px 3px no-repeat,
    #0b1220;
  border: 1px solid #164e63;
  flex: 0 0 auto;
}
.screen {
  padding: 16px 16px 24px;
  max-width: 560px;
  margin: 0 auto;
}
.has-tabs .screen { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}
.card h1, .card h2 { margin: 0 0 8px; font-size: 1.15rem; }
.muted { color: var(--muted); }
.tight { margin: 6px 0 0; font-size: 0.85rem; }
.toast {
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 12px;
}
.toast.ok { background: #052e16; color: var(--ok); }
.toast.bad { background: #450a0a; color: #fecaca; }
.banner {
  background: #422006;
  color: #fde68a;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 12px;
  font-size: 0.92rem;
}
.banner a { color: #fde68a; }
.sensor-hit { color: inherit; text-decoration: none; display: block; }
.sensor-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sensor-top h2 { margin: 0; font-size: 1rem; }
.chev { color: var(--muted); font-size: 1.6rem; line-height: 1; }
.level { margin: 8px 0 0; }
.live-level {
  display: block;
  font-size: 3.25rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--accent);
}
.live-level.low { color: var(--bad); }
.live-level.high { color: var(--warn); }
.live-level.empty { color: var(--muted); }
.live-updated { display: block; margin-top: 4px; font-size: 0.8rem; }
.bar {
  display: block;
  height: 8px;
  margin-top: 10px;
  border-radius: 999px;
  background: #1e293b;
  overflow: hidden;
}
.live-bar { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.live-level.low + .live-updated + .bar .live-bar,
.level:has(.live-level.low) .live-bar { background: var(--bad); }
.level:has(.live-level.high) .live-bar { background: var(--warn); }
.chart-wrap { position: relative; height: 180px; margin-top: 8px; }
.chart-empty { margin: 8px 0 0; font-size: 0.85rem; }
.count { text-align: center; font-size: 0.8rem; }
.stack-form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.stack-form label, .copy-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}
input, select, button {
  border-radius: 12px;
  border: 1px solid #334155;
  background: #0f172a;
  padding: 12px;
  min-height: 48px;
}
button { font-weight: 600; cursor: pointer; }
button.primary, a.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
a.primary.link, a.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
}
button.ghost { background: transparent; }
button.danger { background: transparent; color: var(--bad); border-color: #7f1d1d; }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}
.alert { border-top: 1px solid var(--line); padding-top: 12px; }
.slot-num { margin: 0; font-weight: 700; color: var(--text); }
.back { margin: 0 0 8px; }
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #0f172a;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 3;
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
}
.tabbar a.on { color: var(--accent); }
.tabbar svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.inline { display: inline; }
.card.quiet { background: transparent; }
[hidden] { display: none !important; }
