:root {
  --bg: #ffffff;
  --fg: #1d2330;
  --muted: #5b6475;
  --line: #e2e6ee;
  --card: #f6f8fb;
  /* Each state colour is also a text colour, so each holds 4.5:1 on --bg (test/public.test.js). */
  --operational: #15803d;
  --maintenance: #1d5fc9;
  --degraded: #b45309;
  --outage: #c0262d;
  --unknown: #6b7280;
  --on-outage: #ffffff;
  --on-degraded: #ffffff;
  /* The headline card is tinted by its state; text on it holds 4.5:1 as well. */
  --tint-operational: #edf7f0;
  --tint-maintenance: #edf3fc;
  --tint-degraded: #fdf4e8;
  --tint-outage: #fdeeee;
  /* The day bars. As text colours the four states are equally dark, so a reader who does not tell green
     from amber saw one colour; here they differ in lightness as well (test/public.test.js). */
  --bar-operational: #1f9d55;
  --bar-maintenance: #2563eb;
  --bar-degraded: #f4b33d;
  --bar-outage: #a3161c;
  --bar-no-data: #cfd4dc;
}

:root[data-theme="light"] { color-scheme: light; }

/* Dark comes from the system unless the reader picked light, or from the reader's pick of dark. The two
   blocks carry the same tokens; test/public.test.js fails if they drift apart. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #11151c;
    --fg: #e6e9ef;
    --muted: #9aa3b2;
    --line: #2a303b;
    --card: #181d26;
    --operational: #4ade80;
    --maintenance: #7aa7ff;
    --degraded: #fbbf24;
    --outage: #f87171;
    --unknown: #9aa3b2;
    --on-outage: #11151c;
    --on-degraded: #11151c;
    --tint-operational: #14231b;
    --tint-maintenance: #161f31;
    --tint-degraded: #272013;
    --tint-outage: #2b181a;
    --bar-operational: #237a4b;
    --bar-maintenance: #6b9bff;
    --bar-degraded: #f6c453;
    --bar-outage: #ff8080;
    --bar-no-data: #3a414d;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11151c;
  --fg: #e6e9ef;
  --muted: #9aa3b2;
  --line: #2a303b;
  --card: #181d26;
  --operational: #4ade80;
  --maintenance: #7aa7ff;
  --degraded: #fbbf24;
  --outage: #f87171;
  --unknown: #9aa3b2;
  --on-outage: #11151c;
  --on-degraded: #11151c;
  --tint-operational: #14231b;
  --tint-maintenance: #161f31;
  --tint-degraded: #272013;
  --tint-outage: #2b181a;
  --bar-operational: #237a4b;
  --bar-maintenance: #6b9bff;
  --bar-degraded: #f6c453;
  --bar-outage: #ff8080;
  --bar-no-data: #3a414d;
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  max-width: 880px;
  padding: 16px;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }
h3 { font-size: 1rem; margin: 0; }
p { margin: 4px 0; overflow-wrap: anywhere; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.icon {
  width: 1.1em; height: 1.1em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.tone-operational { color: var(--operational); }
.tone-maintenance { color: var(--maintenance); }
.tone-degraded { color: var(--degraded); }
.tone-outage { color: var(--outage); }
.tone-unknown, .tone-no_data { color: var(--unknown); }

.header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.controls { display: flex; align-items: center; gap: 12px; }
.lang { display: flex; gap: 4px; }
.lang button, .theme-toggle {
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
  border-radius: 6px; padding: 4px 10px; min-height: 36px; font: inherit; cursor: pointer;
}
.lang button[aria-pressed="true"] { border-color: var(--fg); font-weight: 600; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; padding: 4px; }
.theme-toggle[hidden] { display: none; }
.theme-toggle .icon { width: 20px; height: 20px; }
.lang button:focus-visible, .theme-toggle:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.lang-short { display: none; }
@media (pointer: coarse) {
  .lang button, .theme-toggle { min-height: 44px; min-width: 44px; }
}
@media (max-width: 479px) {
  /* Title, two languages and the theme toggle share one line on a 375 px phone. */
  h1 { font-size: 1.25rem; }
  .header, .controls { gap: 8px; }
  .lang-long { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .lang-short { display: inline; }
}

section { margin: 0 0 24px; }
.muted { color: var(--muted); font-size: 0.9rem; }

.banner { border-radius: 8px; padding: 10px 14px; margin: 0 0 12px; font-weight: 600; }
.banner[hidden] { display: none; }
.banner-outage { background: var(--outage); color: var(--on-outage); }
.banner-stale { background: var(--degraded); color: var(--on-degraded); }

.overall {
  display: flex; align-items: center; gap: 14px;
  border-radius: 12px; padding: 18px 20px; min-height: 76px;
  background: var(--card); border-left: 6px solid var(--unknown);
}
.overall .icon { width: 32px; height: 32px; }
.overall h2 { margin: 0; font-size: 1.45rem; line-height: 1.25; }
.overall.state-operational { background: var(--tint-operational); border-left-color: var(--operational); }
.overall.state-maintenance { background: var(--tint-maintenance); border-left-color: var(--maintenance); }
.overall.state-degraded { background: var(--tint-degraded); border-left-color: var(--degraded); }
.overall.state-outage { background: var(--tint-outage); border-left-color: var(--outage); }

.components { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; }
.components li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.components li:first-child { border-top: 0; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }

.card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 8px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin: 0 0 4px; }
.card .lead { font-weight: 500; }
.meta { font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; padding: 1px 10px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--card); font-size: 0.85rem; font-weight: 600;
}
.pill.tone-maintenance { border-color: currentColor; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0; padding: 0; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 14px; border-radius: 2px; background: var(--bar-no-data); }

.band { position: relative; margin: 0 0 14px; }
.band-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 12px; font-variant-numeric: tabular-nums; }
.bars {
  display: flex; gap: 1px; height: 28px; margin-top: 4px;
  border-radius: 3px; cursor: pointer; touch-action: pan-y;
}
.bars:focus { outline: none; }
.bars:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
.bar { flex: 1 1 0; min-width: 1px; border-radius: 1px; background: var(--bar-no-data); }
.bar.active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--fg); position: relative; }
.state-operational.bar, .state-operational.swatch { background: var(--bar-operational); }
.state-maintenance.bar, .state-maintenance.swatch { background: var(--bar-maintenance); }
.state-degraded.bar, .state-degraded.swatch { background: var(--bar-degraded); }
.state-outage.bar, .state-outage.swatch { background: var(--bar-outage); }

.tip {
  position: absolute; z-index: 10; width: max-content; max-width: min(280px, 100%);
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); box-shadow: 0 6px 18px rgb(0 0 0 / 0.18);
  font-size: 0.9rem; font-variant-numeric: tabular-nums; pointer-events: none;
}
.tip[hidden] { display: none; }
.tip p { margin: 2px 0; }
.tip .badge { font-weight: 600; }

.axis { display: flex; justify-content: space-between; margin-top: -6px; }

.skeleton-line { height: 0.9em; width: 30%; margin: 4px 0; border-radius: 4px; background: var(--line); }
.skeleton .bars { background: var(--line); cursor: default; }

.footer { border-top: 1px solid var(--line); padding-top: 12px; }
