:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --surface: rgba(15, 23, 42, 0.8);
  --surface-border: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.72);
  --accent: #64748b;
  --accent-dark: #334155;
  --eye: #94a3b8;
  --background-a: #111827;
  --background-b: #374151;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 15%, color-mix(in srgb, var(--accent) 38%, transparent), transparent 34rem),
    linear-gradient(145deg, var(--background-a), var(--background-b));
  transition: background 450ms ease;
}

body.state-idle {
  --accent: #22c55e;
  --accent-dark: #166534;
  --eye: #14532d;
  --background-a: #052e16;
  --background-b: #15803d;
}
body.state-running {
  --accent: #f59e0b;
  --accent-dark: #92400e;
  --eye: #fff7ed;
  --background-a: #451a03;
  --background-b: #d97706;
}
body.state-fault {
  --accent: #ef4444;
  --accent-dark: #7f1d1d;
  --eye: #fff1f2;
  --background-a: #450a0a;
  --background-b: #b91c1c;
}
body.state-offline,
body.state-unknown {
  --accent: #94a3b8;
  --accent-dark: #334155;
  --eye: #cbd5e1;
  --background-a: #111827;
  --background-b: #475569;
}

button { font: inherit; }
.app-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.status-card {
  width: min(100%, 520px);
  min-height: min(760px, calc(100dvh - 36px));
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px clamp(18px, 5vw, 38px) 24px;
  border: 1px solid var(--surface-border);
  border-radius: 32px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(0,0,0,.38);
  backdrop-filter: blur(18px);
}
.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.connection-pill {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.2);
  color: var(--muted);
  font-size: .86rem;
}
.connection-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148,163,184,.15);
}
.connection-dot.online { background: #4ade80; box-shadow: 0 0 0 4px rgba(74,222,128,.16); }
.connection-dot.connecting { background: #fbbf24; animation: pulse 1s infinite alternate; }
.connection-dot.offline { background: #fb7185; }
.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
  color: white;
  background: rgba(0,0,0,.18);
  font-size: 1.35rem;
}

.ram { position: relative; width: 230px; height: 205px; margin-top: 16px; }
.ram-face {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 158px;
  height: 154px;
  transform: translateX(-50%);
  border-radius: 46% 46% 42% 42%;
  background: linear-gradient(145deg, rgba(255,255,255,.96), rgba(226,232,240,.84));
  box-shadow: inset 0 -10px 18px rgba(15,23,42,.12), 0 18px 35px rgba(0,0,0,.25);
}
.ram-face::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 20px;
  width: 42px;
  height: 30px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #334155;
  opacity: .78;
}
.horn {
  position: absolute;
  top: 18px;
  width: 104px;
  height: 104px;
  border: 18px solid rgba(255,255,255,.88);
  border-bottom-color: transparent;
  border-radius: 50%;
  filter: drop-shadow(0 12px 12px rgba(0,0,0,.22));
}
.horn-left { left: 3px; transform: rotate(-28deg); }
.horn-right { right: 3px; transform: rotate(28deg); }
.eye {
  position: absolute;
  top: 48px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0f172a;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.08);
}
.eye-left { left: 31px; }
.eye-right { right: 31px; }
.eye span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--eye);
  box-shadow: 0 0 18px color-mix(in srgb, var(--eye) 85%, transparent);
  transition: background 250ms, opacity 250ms;
}
.state-idle .eye span { opacity: .12; box-shadow: none; }
.state-running .eye-left span { animation: blinkLeft 1.1s infinite steps(1); }
.state-running .eye-right span { animation: blinkRight 1.1s infinite steps(1); }
.state-fault .eye span { animation: blinkBoth .68s infinite steps(1); }

.eyebrow { margin: 0; color: var(--muted); letter-spacing: .18em; font-weight: 800; font-size: .78rem; }
h1 {
  margin: 9px 0 8px;
  text-align: center;
  font-size: clamp(2.25rem, 10vw, 4.5rem);
  line-height: .95;
  letter-spacing: -.04em;
  text-wrap: balance;
}
.state-fault h1 { font-size: clamp(1.75rem, 8vw, 3.4rem); line-height: 1; }
.state-message { margin: 4px 0 0; text-align: center; color: var(--muted); font-size: clamp(1.05rem, 4vw, 1.28rem); }
.state-duration { min-height: 1.5em; margin: 9px 0 0; font-weight: 800; }
.warning {
  width: 100%;
  margin-top: 15px;
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(251,191,36,.16);
  border: 1px solid rgba(251,191,36,.42);
  text-align: center;
}
.boiler-panel {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}
.boiler-panel > div {
  padding: 14px;
  border-radius: 16px;
  background: rgba(0,0,0,.18);
}
.boiler-panel span { display: block; color: var(--muted); font-size: .8rem; }
.boiler-panel strong { display: block; margin-top: 4px; font-size: 1.15rem; }
.actions { width: 100%; display: grid; gap: 10px; margin-top: auto; padding-top: 24px; }
.primary-button, .secondary-button {
  min-height: 54px;
  border-radius: 16px;
  border: 0;
  padding: 12px 18px;
  font-weight: 850;
}
.primary-button { color: #111827; background: #ffffff; }
.secondary-button { color: #ffffff; background: rgba(0,0,0,.24); border: 1px solid rgba(255,255,255,.2); }
footer { width: 100%; margin-top: 20px; text-align: center; color: var(--muted); font-size: .82rem; }
.diagnostic { margin-top: 4px; opacity: .72; }

@keyframes pulse { to { opacity: .35; } }
@keyframes blinkLeft { 0%,49% { opacity: 1; } 50%,100% { opacity: .12; } }
@keyframes blinkRight { 0%,49% { opacity: .12; } 50%,100% { opacity: 1; } }
@keyframes blinkBoth { 0%,44% { opacity: 1; } 45%,100% { opacity: .08; } }

@media (max-height: 700px) {
  .status-card { min-height: calc(100dvh - 24px); padding-top: 12px; }
  .ram { transform: scale(.78); height: 158px; margin-top: -2px; }
  .actions { padding-top: 14px; }
}


/* Bojler a venkovní teplota */
.boiler-panel > div {
  min-width: 0;
}
.boiler-panel strong {
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.boiler-panel > div:nth-child(3) strong {
  font-size: 1.05rem;
}
@media (max-width: 370px) {
  .boiler-panel {
    grid-template-columns: 1fr;
  }
}
