:root {
  color-scheme: dark;
  --bg0: #07090d;
  --bg: #0b0e13;
  --bg-elev: #12171f;
  --card: #161c25;
  --card-2: #1b222c;
  --line: rgba(255, 255, 255, 0.07);
  --text: #f3f6fa;
  --muted: #8b96a5;
  --faint: #66707d;
  --water: #4ec8e6;
  --water-dim: rgba(78, 200, 230, 0.16);
  --heat: #ff8f5a;
  --heat-dim: rgba(255, 143, 90, 0.14);
  --solar: #f5c542;
  --batt: #5bd08a;
  --grid: #8b96a5;
  --house: #c9b6ff;
  --cheap: #3ee0a0;
  --danger: #ff6b7a;
  --ok: #5bd08a;
  --warn: #f5c542;
  --radius: 22px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(78, 200, 230, 0.08), transparent 50%),
    radial-gradient(900px 400px at 110% 10%, rgba(255, 143, 90, 0.06), transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
body { padding: 0; }
#app {
  width: min(430px, 100%);
  margin: 0 auto;
  padding: calc(14px + var(--safe-top)) 14px calc(18px + var(--safe-bot));
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 32px; height: 32px; border-radius: 10px;
  background:
    linear-gradient(160deg, #4ec8e6 0%, #3a8fd4 48%, #1b3a4a 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 8px 20px rgba(78,200,230,0.25);
}
h1 {
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  margin: 0;
  font-weight: 650;
}
.sub, .label, .note, time, dt {
  color: var(--muted);
  font-size: 0.78rem;
}
.sub { margin: 1px 0 0; }
.meta { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
time { font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill.lock::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 8px var(--warn);
}
.pill.open { color: var(--ok); }
.pill.open::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.card {
  background: linear-gradient(180deg, var(--card-2) 0%, var(--card) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 14px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.card h2 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.badge {
  font-size: 0.72rem;
  font-weight: 650;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--water-dim);
  color: var(--water);
}
.badge.idle { background: rgba(139,150,165,0.14); color: var(--muted); }
.badge.hot { background: rgba(91,208,138,0.16); color: var(--ok); }
.badge.warn { background: rgba(245,197,66,0.16); color: var(--warn); }
.badge.on { background: rgba(255,107,122,0.16); color: var(--danger); }
.badge.quiet { background: rgba(255,255,255,0.05); color: var(--muted); }

.hero, .soc-num {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.temp, .midtemp {
  font-weight: 650;
  letter-spacing: -0.05em;
  line-height: 1;
}
.temp { font-size: 3.15rem; }
.temp.empty { font-size: 2.2rem; opacity: 0.45; }
.temp-unit { font-size: 1.3rem; color: var(--muted); font-weight: 600; }
.midtemp { font-size: 1.85rem; }
.midtemp.empty { opacity: 0.45; }
.midtemp::after { content: "°C"; font-size: 0.9rem; color: var(--muted); margin-left: 4px; font-weight: 600; }

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0 10px;
}
.facts div {
  background: rgba(255,255,255,0.03);
  border-radius: 14px;
  padding: 8px 10px;
}
dt { margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.65rem; }
dd { margin: 0; font-weight: 650; font-size: 0.95rem; }

.progress-block { margin-bottom: 10px; }
.progress-track {
  height: 8px;
  border-radius: 99px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.progress-track span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--water), #7ee7ff);
  transition: width 0.6s ease;
}
.note { margin: 8px 0 0; line-height: 1.35; }

button.boost, .unlock button {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #04202a;
  background: linear-gradient(180deg, #7ee7ff, var(--water));
  cursor: pointer;
}
button.boost:disabled, .unlock button:disabled {
  background: #2a313b;
  color: var(--faint);
  cursor: not-allowed;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 8px 0 6px;
}
.card.heat .midtemp { color: var(--heat); }
.card.heat .midtemp.pending { color: #ffd0b0; }
.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stepper button {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--heat);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.stepper button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.stepper button:active:not(:disabled) {
  background: var(--heat-dim);
}

.card.water .temp { color: var(--water); }

.soc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
}
#soc-ring { flex: 0 0 96px; width: 96px; height: 96px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.07); stroke-width: 10; }
.ring-fg {
  fill: none;
  stroke: var(--batt);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.7s ease, stroke 0.3s;
}
.watts {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.watts li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--muted);
}
.watts strong { margin-left: auto; color: var(--text); font-weight: 650; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.solar { background: var(--solar); }
.dot.batt { background: var(--batt); }
.dot.grid { background: var(--grid); }
.dot.house { background: var(--house); }

#price-chart {
  width: 100%;
  height: 96px;
  margin: 6px 0 8px;
  display: block;
}
.legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 6px;
}
.swatch {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: -1px;
}
.swatch.cheap { background: var(--cheap); }
.swatch.today { background: #6f849c; }
.swatch.tomorrow { background: #3d4b5c; }
.windows { list-style: none; margin: 0; padding: 0; }
.windows li {
  color: var(--muted);
  font-size: 0.72rem;
  padding: 1px 0;
}
.windows strong { color: var(--cheap); font-weight: 650; }

.device-list { display: flex; flex-direction: column; gap: 7px; }
.device {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1px 12px;
  padding: 7px 10px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
}
.device h3 { margin: 0; font-size: 0.95rem; font-weight: 650; }
.device .room { color: var(--muted); font-size: 0.75rem; grid-column: 1; }
.device .state { font-size: 0.85rem; color: var(--text); }
.remote {
  justify-self: end;
  align-self: start;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  color: var(--muted);
}
.remote.on { background: rgba(91,208,138,0.16); color: var(--ok); }

.unlock p { color: var(--muted); line-height: 1.4; }
.unlock form { display: flex; flex-direction: column; gap: 10px; }
.unlock input {
  border: 1px solid var(--line);
  background: #0e1319;
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
}
.error { color: var(--danger); font-size: 0.85rem; }
.hidden, [hidden] { display: none !important; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bot));
  transform: translateX(-50%);
  background: #222a35;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  max-width: 90%;
  z-index: 20;
}
.card.errorish { outline: 1px solid rgba(255,107,122,0.35); }
.err-line { color: var(--danger); font-size: 0.78rem; margin: 8px 0 0; }

.arm-btn {
  grid-column: 1 / -1;
  margin-top: 6px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  font-size: 0.85rem;
  cursor: pointer;
}
.arm-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}
.sheet-panel {
  position: relative;
  width: min(390px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
  background: linear-gradient(180deg, var(--card-2) 0%, var(--card) 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px 16px 16px;
  box-shadow: var(--shadow);
}
.sheet-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.sheet-panel h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
#sheet-close, #arm-dismiss {
  border: 0;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 18px;
  font-size: 1.2rem;
  cursor: pointer;
}
#arm-dismiss { width: auto; padding: 10px 16px; margin-top: 12px; font-weight: 650; }
.option-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.option {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  cursor: pointer;
}
.option:active { background: rgba(62, 224, 160, 0.12); }
.option .opt-label { font-weight: 700; margin: 0 0 4px; }
.option .opt-window { margin: 0 0 4px; font-size: 0.85rem; font-weight: 600; color: var(--text); }
.option .opt-delay { margin: 0 0 4px; color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.option .opt-meta { color: var(--muted); font-size: 0.8rem; line-height: 1.35; margin: 0; }
.option .opt-cheap { color: var(--cheap); font-weight: 650; }
.option .opt-expensive { color: #ff8f5a; font-weight: 650; }
.option .opt-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(62, 224, 160, 0.16);
  color: var(--cheap);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}
.option.option-now { border-color: rgba(255,255,255,0.12); }
.arm-panel { align-self: center; border-radius: 22px; margin: 16px; text-align: center; }
.countdown {
  font-size: 4.2rem;
  font-weight: 650;
  letter-spacing: -0.05em;
  color: var(--water);
  line-height: 1;
  margin: 12px 0 8px;
}

/* Period selector: fixed bar at the bottom, HomeWizard style */
.view-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-bot));
  background: rgba(11, 14, 19, 0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.view-nav.hidden, .view-nav[hidden] { display: none; }
.view-nav button {
  flex: 1 1 0;
  max-width: 84px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 4px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
}
.view-nav button.on { background: rgba(255,255,255,0.1); color: var(--text); }
#app { padding-bottom: calc(84px + var(--safe-bot)); }

/* Chart cards */
.hc-pager, .hcf-pager { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.hc-pager button, .hcf-pager button, .hcf-x, .hcf-view {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  border-radius: 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.hc-pager button, .hcf-pager button { min-width: 44px; height: 42px; font-size: 1.4rem; line-height: 1; padding: 0 8px; }
.hc-pager button:disabled, .hcf-pager button:disabled { opacity: 0.3; cursor: default; }
.hc-pager-label, .hcf-date { flex: 1; text-align: center; font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; }
#hc-cards.hc-pending, .hcf-chart.hc-pending { opacity: 0.45; transition: opacity .12s; pointer-events: none; }
.hc-pager.hc-pending .hc-pager-label::after, .hcf-pager.hc-pending .hcf-date::after {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 8px;
  border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%;
  animation: hc-spin .6s linear infinite; vertical-align: -1px;
}
@keyframes hc-spin { to { transform: rotate(360deg); } }
.hc-note { margin: 0 0 8px; color: var(--muted); font-size: 0.85rem; min-height: 0; }
.hc-note:empty { display: none; }
.hc-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 12px;
  margin: 0 0 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.hc-card.hidden { display: none; }
.hc-card header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.hc-card h3 { margin: 0; font-size: 0.95rem; color: var(--muted); font-weight: 650; }
.hc-range { font-size: 0.8rem; color: var(--faint); }
.hc-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.hc-big { display: flex; align-items: baseline; gap: 6px; }
.hc-big b { font-size: 2.6rem; font-weight: 700; letter-spacing: -0.04em; line-height: 1.05; }
.hc-big span { font-size: 1.05rem; color: var(--muted); font-weight: 600; }
.hc-chips { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.hc-chip { font-size: 0.85rem; color: var(--muted); }
.hc-chip b { color: var(--text); font-weight: 650; }
.hc-cost { font-size: 0.95rem; font-weight: 650; color: #c4b5fd; }
.hc-save { font-size: 0.85rem; color: #8b96a5; margin-top: 2px; }
.hc-save b { color: #86efac; font-weight: 650; }
.hc-card canvas { width: 100%; height: 170px; display: block; margin: 8px 0 4px; pointer-events: none; }
.hc-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.82rem; color: var(--muted); }
.hc-legend span { display: inline-flex; align-items: center; gap: 6px; }
.hc-legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* Full-screen chart, landscape friendly */
body.hc-lock { overflow: hidden; }
.hc-full {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column;
  background: var(--bg);
  padding: calc(10px + var(--safe-top)) calc(14px + env(safe-area-inset-right, 0px)) calc(10px + var(--safe-bot)) calc(14px + env(safe-area-inset-left, 0px));
}
.hc-full.hidden { display: none; }
.hcf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hcf-name { font-size: 0.95rem; color: var(--muted); font-weight: 650; }
.hcf-total { font-size: 1.1rem; color: var(--muted); margin: 2px 0 6px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.hcf-total > b { font-size: 2.4rem; color: var(--text); font-weight: 700; letter-spacing: -0.04em; line-height: 1.05; }
.hcf-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.hcf-seg { display: flex; background: rgba(255,255,255,0.06); border-radius: 12px; padding: 3px; }
.hcf-seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.85rem; font-weight: 650; padding: 8px 9px; border-radius: 9px; cursor: pointer; }
.hcf-seg button.on { background: rgba(255,255,255,0.14); color: var(--text); }
.hcf-x { width: 40px; height: 40px; font-size: 1.1rem; }
.hcf-chart { position: relative; flex: 1 1 auto; min-height: 0; margin: 8px 0; }
.hcf-chart canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.hcf-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.hcf-msg.hidden { display: none; }
.hcf-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hcf-bar .hcf-pager { margin: 0; flex: 1; max-width: 420px; }
.hcf-viewwrap { position: relative; }
.hcf-viewwrap.hidden { display: none; }
.hcf-view { height: 42px; padding: 0 14px; font-size: 0.9rem; white-space: nowrap; }
.hcf-menu { position: absolute; right: 0; bottom: 50px; min-width: 220px; background: #232b37; border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); }
.hcf-menu.hidden { display: none; }
.hcf-menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--text); font: inherit; padding: 12px; border-radius: 10px; cursor: pointer; }
.hcf-menu button.on { background: rgba(255,255,255,0.1); font-weight: 700; }
.hcf-date { white-space: nowrap; }
@media (orientation: portrait) {
  .hcf-head { flex-direction: column-reverse; align-items: stretch; gap: 6px; }
  .hcf-right { justify-content: space-between; }
  .hcf-seg { flex: 1; }
  .hcf-seg button { flex: 1; padding: 8px 4px; }
  .hcf-bar { flex-wrap: wrap; }
  .hcf-bar .hcf-pager { max-width: none; }
  .hcf-viewwrap { width: 100%; }
  .hcf-view { width: 100%; }
  .hcf-menu { left: 0; right: 0; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .hcf-head { align-items: center; }
  .hcf-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 18px; }
  .hcf-total { margin: 0; }
  .hcf-total > b { font-size: 1.9rem; }
}
@media (max-width: 380px) {
  .hcf-seg button { padding: 8px 6px; font-size: 0.78rem; }
  .hc-big b { font-size: 2.3rem; }
}
#chart-note { margin: 0 0 8px; }

/* Samsung appliance cards and delay helper */
.samsung-stack { display: flex; flex-direction: column; gap: 10px; }
.appliance {
  padding: 12px 12px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
}
.appliance-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.appliance-icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}
.appliance-icon svg { width: 24px; height: 24px; display: block; }
.appliance[data-kind="dishwasher"] .appliance-icon {
  background: rgba(78, 200, 230, 0.16);
  color: var(--water);
}
.appliance[data-kind="washer"] .appliance-icon {
  background: rgba(201, 182, 255, 0.16);
  color: var(--house);
}
.appliance[data-kind="dryer"] .appliance-icon {
  background: rgba(255, 143, 90, 0.16);
  color: var(--heat);
}
.appliance-head h3 { margin: 0; font-size: 1.02rem; font-weight: 650; letter-spacing: -0.02em; }
.appliance-head .room { margin: 2px 0 0; }
.appliance-head .remote { margin-left: auto; }
.remote.warn {
  background: rgba(245, 197, 66, 0.16);
  color: var(--warn);
}
.appliance-state {
  margin: 8px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
}
.remote-note {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(245, 197, 66, 0.1);
  color: #e8c56a;
  font-size: 0.78rem;
  line-height: 1.35;
}
.remote-note.ok {
  background: rgba(91, 208, 138, 0.1);
  color: var(--ok);
}

.arm-wait {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(91, 208, 138, 0.08);
  border: 1px solid rgba(91, 208, 138, 0.22);
}
.arm-wait-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--ok);
  line-height: 1.35;
}
.arm-wait-window, .arm-wait-choice {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.35;
}
.arm-wait-choice { color: var(--muted); }
.arm-cancel {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.arm-cancel:hover { background: rgba(255, 255, 255, 0.04); }
.arm-wait-result {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  line-height: 1.35;
}
.arm-wait-result.ok {
  background: rgba(91, 208, 138, 0.1);
  color: var(--ok);
}
.aircon-block { margin-top: 4px; }
.aircon-block > h3 {
  margin: 4px 0 8px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.aircon-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(139,150,165,0.14);
  color: var(--muted);
  display: grid; place-items: center;
  flex: 0 0 28px;
}
.aircon-icon svg { width: 16px; height: 16px; }
.device.aircon {
  grid-template-columns: 28px 1fr auto;
  align-items: center;
}
.device.aircon h3 { grid-column: 2; }
.device.aircon .room { grid-column: 2; }
.device.aircon .state { grid-column: 2; }
.device.aircon .remote { grid-column: 3; grid-row: 1 / span 2; }

@media (min-width: 720px) {
  #app { width: min(560px, 100%); }
}

button.boost.stop {
  margin-top: 8px;
  color: #1a0e0c;
  background: linear-gradient(180deg, #ffd0b0, #ff8f5a);
}
button#lock {
  font: inherit;
  cursor: pointer;
}
.confirm-panel { text-align: left; }
.confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.confirm-actions button { flex: 1; }
.confirm-actions #confirm-cancel {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.aircon-controls {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
}
.aircon-controls .row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.chip-btn, .opt-toggle {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 99px;
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.chip-btn.on, .opt-toggle.on {
  background: rgba(94, 200, 234, 0.2);
  border-color: #5ec8ea;
  color: #d9f6ff;
}
.opt-toggle.exclusive.on {
  background: rgba(245, 197, 66, 0.18);
  border-color: #f5c542;
}
.aircon-stepper { display: flex; align-items: center; gap: 6px; }
.aircon-stepper button {
  width: 32px; height: 32px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.05);
  color: var(--text); font-weight: 700; cursor: pointer;
}

/* push state: trying / confirmed / failed */
.push { display: flex; align-items: center; gap: 8px; margin: 8px 0; padding: 8px 10px; border-radius: 10px; font-size: 14px; background: rgba(127,127,127,.12); }
.push-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex: none; font-weight: 700; border-radius: 50%; }
.push-confirmed { background: rgba(46,160,67,.16); }
.push-confirmed .push-icon { background: #2ea043; color: #fff; }
.push-failed { background: rgba(218,54,51,.16); }
.push-failed .push-icon { background: #da3633; color: #fff; }
.push-text { flex: 1; min-width: 0; }
.push-retry { border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 8px; padding: 4px 10px; font-size: 13px; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(127,127,127,.4); border-top-color: currentColor; border-radius: 50%; display: inline-block; animation: push-spin .8s linear infinite; }
@keyframes push-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* aircon remote layout */
.ac-card { display: block; }
.ac-head { display: flex; align-items: center; gap: 10px; }
.ac-titles { flex: 1; min-width: 0; }
.ac-titles h3, .ac-titles .room { margin: 0; }
.ac-power { border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--text); border-radius: 99px; padding: 8px 16px; font: inherit; font-weight: 700; cursor: pointer; min-width: 64px; }
.ac-power.on { background: rgba(94,200,234,.22); border-color: #5ec8ea; color: #d9f6ff; }
.ac-body { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 12px; align-items: stretch; }
.ac-body.ac-off { opacity: .55; }
.ac-col { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.ac-col-title { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: center; }
.ac-step { height: 52px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); font-size: 26px; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.ac-step:active:not(:disabled) { background: rgba(94,200,234,.22); }
.ac-value { text-align: center; font-size: 26px; font-weight: 750; padding: 4px 0; }
.ac-value.pending, .ac-opt.pending, .ac-mode-btn.pending, .ac-power.pending { outline: 2px dashed rgba(245,197,66,.7); outline-offset: 1px; }
.ac-value.pending { color: #f5c542; }
.ac-stack { display: flex; flex-direction: column; gap: 8px; justify-content: flex-end; }
.ac-opt { flex: 1; min-height: 52px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.ac-opt.on { background: rgba(245,197,66,.18); border-color: #f5c542; }
.ac-card button:disabled { opacity: .35; cursor: not-allowed; }
.ac-mode { position: relative; margin-top: 12px; }
.ac-mode-btn { width: 100%; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; text-align: left; }
.ac-menu { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); background: var(--card, #1b222b); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.ac-menu-item { display: block; width: 100%; text-align: left; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.ac-menu-item:last-child { border-bottom: 0; }
.ac-menu-item.on { background: rgba(94,200,234,.16); font-weight: 700; }

/* offline / paused: last known values, controls greyed out */
.offline-tag { margin: 6px 0 0; padding: 4px 10px; border-radius: 99px; display: inline-block; font-size: 12px; font-weight: 600; color: #f5c542; background: rgba(245,197,66,.12); border: 1px solid rgba(245,197,66,.4); }
.appliance.offline, .ac-card.offline, #card-dhw.offline, article.offline { filter: saturate(.55); }
.appliance.offline .appliance-state, .ac-card.offline .ac-body, .ac-card.offline .ac-mode { opacity: .55; }
article.offline button:disabled, .ac-card.offline button:disabled { opacity: .35; cursor: not-allowed; }

/* impact card: Tesla-style self-powered donut */
.hc-impact { display: flex; align-items: center; gap: 14px; margin: 8px 0 2px; }
.hc-impact svg { flex: none; }
.hc-impact-t { font-size: 0.85rem; color: var(--muted); display: grid; gap: 2px; }
.hc-impact-h { color: var(--text); font-weight: 650; }
.hc-impact-t i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.hc-impact-t b { color: var(--text); font-weight: 650; }
.hc-impact-o { margin-top: 2px; }

.car-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.car-row + .car-row { border-top: 1px solid rgba(255,255,255,.08); }
.car-row .note { margin: 2px 0 0; }
button.boost.car-climate { width: auto; min-width: 8.5rem; margin: 0; }
details.car-more { margin: 0 0 8px; font-size: 0.85rem; }
details.car-more summary { cursor: pointer; opacity: .75; padding: 4px 0; }
.car-ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
button.boost.car-sm { width: auto; margin: 0; padding: 6px 12px; min-height: 0; }
.car-in { background: rgba(255,255,255,.06); color: inherit; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; padding: 5px 8px; width: auto; max-width: 8rem; }

/* Active ATAG heat pump error banner on the heating card */
.plant-error { margin: 8px 0 12px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255,107,122,0.12); border: 1px solid rgba(255,107,122,0.4); }
.plant-error .pe-title { color: var(--danger); font-weight: 650; font-size: 0.95rem; }
.plant-error .pe-since { color: var(--danger); font-size: 0.78rem; margin-top: 2px; opacity: 0.9; }
.plant-error .pe-text { font-size: 0.82rem; margin-top: 6px; line-height: 1.35; }

/* Heating cost card: stacked daily bars, compressor vs backup element */
.hc-periods { display: flex; gap: 8px; margin: 4px 0 10px; }
.hc-bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; margin: 4px 0 6px; }
.hc-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end;
  cursor: pointer; border-radius: 4px; padding: 0; background: none; border: 0; }
.hc-col.sel { outline: 1px solid rgba(255,255,255,.45); outline-offset: 1px; }
.hc-col i { display: block; width: 100%; }
.hc-col i.hc-comp, .swatch.hc-comp { background: var(--water); }
.hc-col i.hc-elem, .swatch.hc-elem { background: var(--heat); }
.hc-col i.hc-boost, .swatch.hc-boost { background: var(--solar); }
.hc-col i:first-child { border-radius: 3px 3px 0 0; }
.hc-col.today i { opacity: .6; }
.hc-legend { margin-top: 4px; flex-wrap: wrap; }
.hc-foot { font-size: 0.72rem; opacity: .7; }
.heat-power { color: var(--heat); }
.maint { color: var(--muted, inherit); }
.pwx-big { font-size: 1.5rem; font-weight: 600; margin: 2px 0 8px; }
.pwx-bars { height: 70px; }
.pwx-bars .hc-col { cursor: default; }

/* Settings */
.set-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.set-row input { width: 20px; height: 20px; }
.set-group { margin-top: 14px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 10px; }
.set-group h3 { margin: 0 0 4px; font-size: 1rem; }
.set-group button.boost { margin: 0; }
