:root {
  color-scheme: dark;
  --bg: #203747;
  --text: #eaf0f6;
  --muted: #8ba0b4;
  --faint: #6c8095;
  --rule: rgba(255, 255, 255, .13);
  --well: rgba(255, 255, 255, .07);
  --green: #4cc38a;
  --red: #f0687a;
  --amber: #e0a844;
  --meter-value: 0;
  --threshold: 10;
  font-family: "Bahnschrift", "Aptos Display", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

.shell {
  width: min(1120px, calc(100% - 44px));
  margin: 0 auto;
  padding: 26px 0 18px;
}

/* Header ------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.brand-logo {
  width: clamp(200px, 25vw, 300px);
  height: auto;
  object-fit: contain;
}

h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 400;
  letter-spacing: -.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

/* Pills become plain text with a dot / glyph - nothing to enclose them. */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .85rem;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}
.status-badge.live .status-dot { background: var(--green); }
.status-badge.error .status-dot { background: var(--red); }

.settings-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: .85rem;
  text-decoration: none;
  transition: color .2s;
}
.settings-link:hover,
.settings-link:focus-visible { color: var(--text); outline: none; }

/* Cycle strip -------------------------------------------------------- */

.cycle-panel {
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--rule);
}

.cycle-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.countdown-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.countdown-row strong {
  font: 400 1.75rem/1 "Bahnschrift", "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
.countdown-row span,
.cycle-head > span,
.cycle-phase,
footer { color: var(--faint); font-size: .82rem; }

.cycle-track {
  height: 2px;
  margin: 14px 0 10px;
  overflow: hidden;
  background: var(--rule);
}
.cycle-progress {
  width: 100%;
  height: 100%;
  background: var(--muted);
  transform-origin: left;
  transition: transform .18s linear;
}

.cycle-phase { margin: 0; }

/* Counts - two columns split by a single rule, no cards --------------- */

.meter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meter-card {
  padding: 22px 0 20px 34px;
  border-left: 1px solid var(--rule);
}
.meter-card:first-child {
  padding-left: 0;
  padding-right: 34px;
  border-left: 0;
}

.meter-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.meter-heading h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: .01em;
}
.threshold-chip {
  color: var(--faint);
  font-size: .8rem;
}
.threshold-chip b { color: var(--muted); font-weight: 500; }

.meter-layout {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 1fr;
  align-items: center;
  gap: 20px;
  padding-top: 16px;
}

.meter {
  display: grid;
  grid-template-columns: 26px minmax(64px, 84px);
  justify-content: center;
  gap: 10px;
  height: 200px;
}
.meter-scale {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1px 0;
  color: var(--faint);
  font-size: .68rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.meter-well {
  position: relative;
  overflow: hidden;
  border-radius: 7px;
  background: var(--well);
}
.meter-fill {
  position: absolute;
  inset: auto 0 0;
  height: calc(min(var(--meter-value), 100) * 1%);
  background: var(--meter-colour);
  transition: height .9s cubic-bezier(.18,.84,.25,1), background .3s;
}
.threshold-line {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: calc(min(var(--threshold), 100) * 1%);
  width: 100%;
  border-top: 1px dashed rgba(255, 255, 255, .42);
}

.meter-reading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.reading-value {
  font: 300 clamp(3.2rem, 6.5vw, 4.6rem)/.88 "Bahnschrift", "Segoe UI", sans-serif;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.reading-unit {
  margin-top: 8px;
  color: var(--faint);
  font-size: .85rem;
}
.reading-state {
  margin-top: 14px;
  color: var(--meter-colour);
  font-size: .84rem;
}

.meter-card { --meter-colour: var(--red); }
.meter-card.above-threshold { --meter-colour: var(--green); }
.meter-card.updating .reading-value { opacity: .5; }

/* Footer ------------------------------------------------------------- */

footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

@media (max-width: 800px) {
  .meter-grid { grid-template-columns: 1fr; }
  .meter-card,
  .meter-card:first-child {
    padding: 20px 0;
    border-left: 0;
    border-top: 1px solid var(--rule);
  }
  .meter-card:first-child { border-top: 0; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 14px; }
}

@media (max-width: 520px) {
  .shell { width: min(100% - 26px, 1120px); padding-top: 20px; }
  .brand-block { align-items: flex-start; flex-direction: column; gap: 12px; }
  .cycle-head { align-items: flex-start; flex-direction: column; gap: 6px; }
  .meter-layout { grid-template-columns: 1fr 1fr; gap: 14px; }
  .meter { grid-template-columns: 24px minmax(56px, 76px); height: 170px; }
  .reading-value { font-size: 2.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
