:root {
  --bg: #F3F4F1; --card: #FFFFFF; --ink: #15181B; --muted: #5B6168; --line: #E2E4E0; --soft: #ECEEEA;
  --heat: #C2410C; --heat-soft: #FFF1E8; --heat-ink: #9A3412; --cool: #1D4ED8; --cool-soft: #EAF0FD; --cool-ink: #1E40AF;
  --ok: #15803D; --warn: #B45309; --warn-soft: #FEF3C7; --dark: #15181B;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, "Segoe UI", Inter, Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
button, input, select { font: inherit; color: inherit; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 8px; max-width: 1200px; margin: 0 auto; }
.top h1 { font-size: 26px; font-weight: 700; }
.top .sub { color: var(--muted); font-size: 13px; }
.title { display: flex; flex-direction: column; gap: 2px; }
.conn { font-size: 12px; padding: 6px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.conn.on::before { content: "● "; color: var(--ok); }
.conn.off::before { content: "● "; color: var(--heat); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 10px; max-width: 1200px; margin: 0 auto; scrollbar-width: none; }
.tabs a { flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); background: var(--card); border: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.tabs a.act { background: var(--ink); color: #fff; border-color: var(--ink); }

main { max-width: 1200px; margin: 0 auto; padding: 0 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h2 small { font-weight: 500; color: var(--muted); font-size: 12px; }
.dark { background: var(--dark); color: #fff; border-color: var(--dark); }
.dark .muted { color: #C9CDD1; }
.muted { color: var(--muted); font-size: 13px; }
.big { font-size: 40px; font-weight: 700; line-height: 1.05; }
.mid { font-size: 24px; font-weight: 700; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: #22272C; border-radius: 12px; padding: 10px 12px; }
.statusline { font-size: 14px; font-weight: 600; }

.chip { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.chip.komfort { background: var(--heat-soft); color: var(--heat-ink); }
.chip.absenk { background: var(--cool-soft); color: var(--cool-ink); }
.chip.wart { background: var(--warn-soft); color: var(--warn); }
.chip.grey { background: #EEF0EC; color: #3F454B; }

a.kreis { display: block; text-decoration: none; color: inherit; }
.kreis .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.kreis .head h3 { font-size: 17px; }
.temps { display: flex; align-items: baseline; gap: 10px; }
.bar { flex: 1; height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.bar > i { display: block; height: 8px; border-radius: 4px; background: #9AA1A8; }
.barrow { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; font-weight: 600; }
.dir-open { color: var(--heat); } .dir-close { color: var(--cool); } .dir-hold { color: #3F454B; } .dir-warn { color: var(--warn); }

.curve { width: 100%; height: auto; display: block; }
.stepper { display: flex; align-items: center; gap: 10px; }
.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid #D5D8D3; background: var(--card); font-weight: 600; cursor: pointer; }
.btn.sq { width: 44px; padding: 0; font-size: 22px; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.heat { color: var(--heat); } .btn.cool { color: var(--cool); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.seg { display: flex; border: 1px solid #D5D8D3; border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; min-height: 44px; border: 0; background: var(--card); font-weight: 600; cursor: pointer; border-right: 1px solid #D5D8D3; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: #fff; }

.form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; align-items: center; font-size: 14px; }
.form label { color: #3F454B; }
.form input, .form select { min-height: 40px; border: 1px solid #D5D8D3; border-radius: 10px; padding: 0 10px; background: #fff; width: 130px; text-align: right; }
.form .wide { grid-column: 1 / -1; }
.toggle { position: relative; width: 52px; height: 30px; border-radius: 999px; border: 0; background: #C9CDD1; cursor: pointer; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on { background: var(--heat); } .toggle.on::after { left: 25px; }
.toggle.warn.on { background: var(--warn); }
input[type=range] { width: 100%; accent-color: var(--ink); }
details summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 0; }
.note { font-size: 12px; color: var(--muted); }
.hand { display: grid; gap: 10px; }
.hand .line { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }

.login { max-width: 380px; margin: 40px auto; display: flex; flex-direction: column; gap: 12px; }
.login input { min-height: 48px; border-radius: 12px; border: 1px solid #D5D8D3; padding: 0 14px; font-size: 20px; text-align: center; letter-spacing: .2em; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 10; max-width: 90vw; }
.foot { text-align: center; color: var(--muted); font-size: 11px; padding: 8px 0 20px; }

@media (min-width: 900px) {
  .top h1 { font-size: 30px; }
  .split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; align-items: start; }
}
