:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262625;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --good-text: #0ca30c;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html {
  background: var(--page);           /* rubber-band overscroll shows this, so match the page */
  overflow-x: hidden;
  overscroll-behavior-y: none;       /* no pull-to-refresh / bounce in the installed app */
  -webkit-text-size-adjust: 100%;
}
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
  touch-action: manipulation;        /* kills the double-tap-to-zoom delay */
  -webkit-tap-highlight-color: transparent;
}
/* Buttons, nav and cards should feel native: no text-selection or long-press callouts. */
.btn, .nav a, .brand, .days label, .card.link, .ac-item, .pill {
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 14px; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.brand { color: var(--ink); font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); display: inline-block; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav a.active { background: var(--surface-2); color: var(--ink); }

.app { max-width: 720px; margin: 0 auto; padding: 16px 16px 40px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card.link { display: block; color: inherit; }
.card.link:active { background: var(--surface-2); }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 8px; }

.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 600; padding: 10px 14px; border-radius: 10px;
  cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--critical); }
.btn.big { width: 100%; font-size: 17px; min-height: 52px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn-row .btn { flex: 1 1 auto; }

label { display: block; font-size: 13px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); min-height: 44px;
  font-size: 16px;                   /* iOS auto-zooms (and stays zoomed) on inputs smaller than 16px */
  max-width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field { position: relative; }
.ac { position: absolute; left: 0; right: 0; z-index: 20; margin-top: 4px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ac-item { padding: 10px 12px; cursor: pointer; border-top: 1px solid var(--border); }
.ac-item:first-child { border-top: 0; }
.ac-item.active, .ac-item:hover { background: var(--surface-2); }
.ac-pin { display: inline-block; margin-top: 4px; color: var(--good-text); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid-2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); font-size: 15px; min-height: 32px; }
.check input { width: 20px; height: 20px; }
.days { display: flex; gap: 6px; }
.days label {
  flex: 1; text-align: center; margin: 0; padding: 8px 0; border-radius: 8px; border: 1px solid var(--border);
  font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none;
}
.days input { display: none; }
.days input:checked + span { color: var(--accent-ink); }
.days label:has(input:checked) { background: var(--accent); border-color: transparent; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.live .dot { background: var(--accent); }
.pill.clear .dot { background: var(--good); }
.pill.off { opacity: 0.7; }

.big-num { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.big-num small { font-size: 16px; font-weight: 500; color: var(--muted); margin-left: 4px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.tile .label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.tile .value { font-size: 24px; font-weight: 600; margin-top: 2px; }
.tile .delta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.delta.good { color: var(--good-text); }
.delta.bad { color: var(--critical); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { font-size: 12px; color: var(--ink-2); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.chart { position: relative; }
.chart { overflow: hidden; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .tooltip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--page);
  font-size: 12px; padding: 6px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -100%);
  display: none; z-index: 2;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin: 6px 0 2px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 2px; background: currentColor; border-radius: 2px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--page); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  z-index: 20; max-width: calc(100vw - 32px); text-align: center;
}
.toast.error { background: var(--critical); color: #fff; }

.banner {
  background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.banner a { color: inherit; font-weight: 700; text-decoration: underline; }
.notice { background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; font-size: 14px; margin-bottom: 12px; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.center { text-align: center; }
.sep { height: 1px; background: var(--grid); margin: 12px 0; }
ol.steps { padding-left: 20px; } ol.steps li { margin-bottom: 6px; }
code { background: var(--surface-2); padding: 2px 5px; border-radius: 4px; font-size: 13px; word-break: break-all; }
