@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --fjord: #173a45;
  --fjord-2: #21505d;
  --fjord-line: rgba(255, 255, 255, 0.16);
  --mist: #eef2f2;
  --paper: #ffffff;
  --ink: #18252b;
  --muted: #5a6c73;
  --rule: #d5dee0;
  --frost: #8cc3d3;
  --ember: #f0a531;
  --ember-deep: #c97d0e;
  --alarm: #d2462f;
  --ok: #3e9c7f;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --text: "Atkinson Hyperlegible", system-ui, sans-serif;
  --gutter: 20px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font-family: var(--text);
  font-size: 17px;
  line-height: 1.45;
}

button { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--ember); outline-offset: 2px; }

/* ---------- hero ---------- */
.hero {
  background: var(--fjord);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) var(--gutter) 26px;
}
.hero[data-state="alarm"] { background: #5b2219; }
.hero[data-state="offline"] { background: #3a4448; }

.hero-top, .state, .state-text, .thermo { max-width: 560px; margin-left: auto; margin-right: auto; }

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.78);
}
.house { font-family: var(--display); font-weight: 600; font-size: 20px; letter-spacing: 0.02em; color: #fff; }

.refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid var(--fjord-line);
  border-radius: 999px;
  padding: 6px 12px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  cursor: pointer;
}
.refresh svg { width: 16px; height: 16px; }
.refresh.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.state {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(54px, 17vw, 84px);
  line-height: 0.95;
  margin-top: 26px;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}
.state-text { margin-top: 0; margin-bottom: 0; color: rgba(255, 255, 255, 0.86); max-width: 560px; }
.state-text strong { color: #fff; }

/* thermometer laid on its side */
.thermo { margin-top: 28px; }
.scale { position: relative; padding-top: 9px; }
.ribbon {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #6fb3c9 0%, #9fd0dc 18%, #d8d3a6 40%, var(--ember) 65%, #e0612f 100%);
}
.pin {
  position: absolute;
  top: 0;
  width: 4px;
  height: 28px;
  margin-left: -2px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
  transition: left 0.6s ease;
}
.ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  font-family: var(--display);
  font-weight: 500;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.55);
  font-variant-numeric: tabular-nums;
}

.readings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0 0;
}
.readings div { border-top: 1px solid var(--fjord-line); padding-top: 8px; }
.readings dt { font-size: 14px; color: rgba(255, 255, 255, 0.7); }
.readings dd {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 40px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.burner { display: flex; align-items: center; gap: 10px; margin: 16px 0 0; color: rgba(255, 255, 255, 0.86); }
.flame {
  width: 12px;
  height: 16px;
  border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
  background: rgba(255, 255, 255, 0.25);
}
.burner.on .flame { background: var(--ember); box-shadow: 0 0 12px var(--ember); animation: flicker 2.4s ease-in-out infinite; }
@keyframes flicker { 50% { transform: scaleY(1.12); opacity: 0.85; } }

/* ---------- main ---------- */
main { max-width: 560px; margin: 0 auto; padding: 0 var(--gutter) calc(env(safe-area-inset-bottom) + 28px); }

h2 { font-family: var(--display); font-weight: 600; font-size: 26px; margin: 28px 0 12px; }

.quick-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-btn {
  text-align: left;
  border: 0;
  border-radius: 14px;
  padding: 16px 16px 14px;
  cursor: pointer;
  min-height: 92px;
}
.quick-btn strong { display: block; font-family: var(--display); font-weight: 700; font-size: 28px; line-height: 1; margin-bottom: 6px; }
.quick-btn span { display: block; font-size: 14px; line-height: 1.3; }
.quick-btn.arrive { background: var(--ember); color: #2b1a00; }
.quick-btn.leave { background: var(--fjord-2); color: #fff; }
.quick-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.quick-btn[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--ink); }
.hint { font-size: 15px; color: var(--muted); margin: 10px 0 0; }

.circuits { margin-top: 30px; border-top: 1px solid var(--rule); }
.circuit { padding: 18px 0 20px; border-bottom: 1px solid var(--rule); }
.circuit-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.circuit-name { font-family: var(--display); font-weight: 600; font-size: 26px; margin: 0; }
.circuit-mode { font-weight: 700; color: var(--fjord-2); }
.circuit-temps { margin: 2px 0 12px; color: var(--muted); font-size: 15px; }

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #dfe7e8;
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 10px 2px;
  font-size: 14px;
  cursor: pointer;
  color: var(--ink);
}
.segmented button[aria-pressed="true"] { background: var(--paper); font-weight: 700; box-shadow: 0 1px 2px rgba(23, 58, 69, 0.18); }
.segmented button:disabled { cursor: not-allowed; opacity: 0.5; }

.tech { margin-top: 24px; }
.tech summary { cursor: pointer; font-family: var(--display); font-weight: 600; font-size: 22px; padding: 6px 0; }
.tech dl { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 10px 0 0; font-size: 15px; }
.tech dt { color: var(--muted); }
.tech dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.foot { margin-top: 32px; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 15px; }

/* ---------- sheet ---------- */
.sheet {
  border: 0;
  border-radius: 18px 18px 0 0;
  padding: 22px var(--gutter) calc(env(safe-area-inset-bottom) + 20px);
  width: 100%;
  max-width: 560px;
  margin: auto auto 0;
  background: var(--paper);
  color: var(--ink);
}
.sheet::backdrop { background: rgba(10, 28, 34, 0.55); }
.sheet h2 { margin-top: 0; }
.sheet p { margin: 0 0 20px; }
.sheet-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-buttons button { border: 0; border-radius: 12px; padding: 14px; font-weight: 700; cursor: pointer; }
.sheet-buttons .secondary { background: #e3eaeb; }
.sheet-buttons .primary { background: var(--fjord); color: #fff; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  transform: translate(-50%, 120%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 15px;
  max-width: calc(100% - 2 * var(--gutter));
  transition: transform 0.25s ease, visibility 0.25s;
  pointer-events: none;
  visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }
.toast.error { background: var(--alarm); }

/* ---------- login ---------- */
.login-body { background: var(--fjord); color: #fff; min-height: 100vh; display: flex; align-items: center; }
.login { width: 100%; max-width: 420px; margin: 0 auto; padding: var(--gutter); }
.login h1 { font-family: var(--display); font-weight: 700; font-size: 64px; line-height: 0.95; margin: 0 0 8px; }
.login p { color: rgba(255, 255, 255, 0.8); margin: 0 0 28px; }
.login label { display: block; font-size: 15px; margin-bottom: 6px; color: rgba(255, 255, 255, 0.85); }
.login input {
  width: 100%;
  font: inherit;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--fjord-line);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.login button { margin-top: 14px; width: 100%; border: 0; border-radius: 12px; padding: 14px; font-weight: 700; background: var(--ember); color: #2b1a00; cursor: pointer; }
.login .error { color: #ffb4a6; min-height: 1.4em; margin: 12px 0 0; }

@media (min-width: 720px) {
  .hero { padding-top: 28px; padding-bottom: 36px; }
}

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