:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ef;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --critical-wash: rgba(208, 59, 59, 0.10);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-wash: rgba(57, 135, 229, 0.14);
    --series-1: #3987e5;
    --series-2: #d95926;
    --good-ink: #0ca30c;
    --critical-wash: rgba(208, 59, 59, 0.18);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 var(--font);
}
[hidden] { display: none !important; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
/* Headings focused by script (route changes, sign-in screens) are not controls: no focus ring. */
h1[tabindex="-1"]:focus, h1[tabindex="-1"]:focus-visible { outline: none; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
.num, table { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.secondary { color: var(--ink-2); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; min-width: 0;
}

/* Buttons. Variants are plain classes so links styled as buttons (a.btn) get them too. */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: 6px 12px; line-height: 1.4;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button:disabled { opacity: 0.5; cursor: default; }
button[aria-disabled="true"] { opacity: 0.6; cursor: progress; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-ink); }
.danger { color: var(--critical); }
.danger-fill { background: var(--critical); border-color: var(--critical); color: #fff; }
.danger-fill:hover { background: #b02e2e; }
.small { font-size: 13px; padding: 3px 9px; }
.ghost { border-color: transparent; background: transparent; }
.ghost:hover { background: var(--surface-2); }
.link { border: 0; background: transparent; color: var(--accent-ink); padding: 6px 8px; min-height: 44px; white-space: normal; }
.link:hover { background: transparent; text-decoration: underline; }
.inline-link { font-size: 13px; font-weight: 500; white-space: nowrap; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 2px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* Form controls */
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; min-width: 0;
}
textarea { padding: 8px 10px; width: 100%; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
input::placeholder { color: var(--muted); }
[aria-invalid="true"] { border-color: var(--critical) !important; box-shadow: 0 0 0 1px var(--critical); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); min-width: 0; }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row > input, .field-row > select { flex: 1 1 auto; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.form-row .field { flex: 1 1 180px; }
.form-row .field.fixed { flex: none; }
/* The message line under a field: hint, or an error / warning / note. */
.msg { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.msg.error { color: var(--critical); }
.msg.warn { color: var(--ink); }
.msg.warn::before { content: "Note: "; font-weight: 600; }
.msg.note { color: var(--ink-2); }
/* Empty messages and live regions stay in the accessibility tree (so later text is announced) but take no space. */
.msg:empty, .signin-status:empty, .signin-error:empty { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); }

/* iOS Safari zooms into inputs below 16px. */
@media (max-width: 720px) {
  input, select, textarea { font-size: 16px; }
}

/* Touch devices: WCAG 2.5.8 / Apple HIG-sized targets. */
@media (hover: none) {
  button, .btn, select, input:not([type="checkbox"], [type="radio"]) { min-height: 44px; }
  .small { padding: 6px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Sign-in screen */
.signin { max-width: 440px; margin: 0 auto; padding: 48px 16px calc(64px + env(safe-area-inset-bottom)); }
.signin-card { position: relative; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.signin-card p { margin: 0; }
.signin-mark { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); }
.signin-mark svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.signin-notice { padding: 10px 12px; border-radius: 8px; background: var(--accent-wash); color: var(--ink); font-weight: 500; }
.signin-btn { width: 100%; justify-content: center; min-height: 44px; font-size: 15px; white-space: normal; }
.signin-key { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.signin-status { color: var(--ink-2); font-size: 14px; }
.signin-error { color: var(--critical); background: var(--critical-wash); padding: 10px 12px; border-radius: 8px; font-size: 14px; overflow-wrap: anywhere; }
.signin .field input { min-height: 44px; font-size: 16px; }
.signin-form { display: flex; flex-direction: column; gap: 12px; }
.signin-code { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.08em; }
.signin-alt { align-self: center; font-size: 14px; }
@media (max-width: 720px) {
  .signin { padding-top: 24px; }
  .signin-card { padding: 20px 16px; }
}
