/* Hausseite – Wanddisplay. Nur dunkel (Dauerbetrieb an der Wand). */
@font-face { font-family: "Barlow"; src: url("/fonts/barlow-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("/fonts/barlowcondensed-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("/fonts/barlowcondensed-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  color-scheme: dark;
  --grund: #0c1116;
  --flaeche: #151c23;
  --flaeche-2: #1c252e;
  --linie: #26313b;
  --raster: #222c35;
  --text: #eef2f5;
  --text-2: #a9b5bf;
  --text-3: #74818c;
  /* Diagramm-Reihen (Kategorie-Palette, dunkel; geprüft gegen #151c23) */
  --reihe-1: #3987e5;   /* Haus  / Außen  */
  --reihe-2: #d95926;   /* PV    / Warmwasser */
  --reihe-3: #199e70;   /* WP */
  /* Status (nur mit Symbol + Wort) */
  --gut: #0ca30c;
  --warn: #fab219;
  --ernst: #ec835a;
  --kritisch: #d03b3b;
  --gut-text: #4cc94c;
  --ernst-text: #f09a77;
  --rand: 16px;
  --abstand: clamp(8px, 1.1vw, 14px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--grund);
  color: var(--text);
  font-family: "Barlow", system-ui, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

/* Nachtdimmung: Overlay ist billiger als filter() auf der ganzen Seite */
#nacht { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 50; transition: opacity 2s; }
body.nacht #nacht { opacity: .5; }

/* ---------- Login ---------- */
#login { min-height: 100%; display: grid; place-items: center; padding: var(--rand); }
.loginkarte { width: min(420px, 100%); padding: 28px; display: grid; gap: 12px; }
.loginkarte h1 { margin: 0; font-family: "Barlow Condensed"; font-weight: 600; font-size: 40px; }
.loginkarte label { color: var(--text-2); font-size: 15px; }
.loginkarte input { font: inherit; font-size: 20px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--linie);
  background: var(--grund); color: var(--text); user-select: text; }
.loginkarte button { font-size: 20px; padding: 12px; border-radius: 10px; border: 0; background: var(--reihe-1); color: #fff; cursor: pointer; }
.leise { color: var(--text-2); margin: 0; }
.fehler { color: var(--ernst-text); margin: 0; min-height: 1.3em; }

/* ---------- Seite: Querformat füllt genau den Bildschirm ---------- */
#seite {
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: var(--abstand);
  padding: var(--abstand) max(var(--rand), env(safe-area-inset-right)) var(--abstand) max(var(--rand), env(safe-area-inset-left));
}
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 16px; }

.kopf { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; min-width: 0; }
.uhr { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
#uhrzeit { font-family: "Barlow Condensed"; font-weight: 600; font-size: clamp(40px, 6.2vh, 64px); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
#datum { color: var(--text-2); font-size: clamp(16px, 2.6vh, 26px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf-rechts { display: flex; align-items: center; gap: 14px; min-width: 0; }
.hinweis { color: var(--warn); font-size: clamp(14px, 2vh, 19px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tuerknopf { position: relative; display: flex; align-items: center; gap: 8px; background: var(--flaeche-2); border: 1px solid var(--linie);
  border-radius: 12px; padding: 8px 16px; font-size: clamp(16px, 2.2vh, 20px); cursor: pointer; }
.tuerpunkt { position: absolute; top: -4px; right: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--warn); border: 2px solid var(--grund); }
.stand { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: clamp(14px, 2vh, 19px); white-space: nowrap; }
.stand .punkt { width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); }
.stand.ok .punkt { background: var(--gut); }
.stand.warn { color: var(--warn); }
.stand.warn .punkt { background: var(--warn); }

/* Kacheln: 12-Spalten-Raster; Reihe 1 = 4 große, Reihe 2 = WW, Außen, Heizstab, Regel (breit) */
.kacheln { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--abstand); }
.kachel { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 16px; padding: clamp(10px, 1.6vh, 18px) clamp(12px, 1.4vw, 20px);
  min-width: 0; display: flex; flex-direction: column; transition: opacity .6s; }
.kachel.gross { grid-column: span 3; }
.kachel.klein { grid-column: span 2; }
#k-ww { grid-column: span 3; }
.kachel.breit { grid-column: span 5; }
.kachel h2 { margin: 0; display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text-2);
  font-size: clamp(15px, 2.2vh, 22px); white-space: nowrap; overflow: hidden; }
.ic { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.marke { margin-left: auto; font-size: .72em; color: var(--text-3); border: 1px solid var(--linie); border-radius: 999px; padding: 1px 9px; overflow: hidden; text-overflow: ellipsis; }
.wert { display: flex; align-items: baseline; gap: 6px; margin-top: auto; padding-top: 4px; min-width: 0; }
.zahl { font-family: "Barlow Condensed"; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gross .zahl { font-size: clamp(44px, 10vh, 104px); }
.klein .zahl { font-size: clamp(30px, 5.6vh, 58px); }
.zahl.wort { font-size: clamp(26px, 4.6vh, 48px); overflow: hidden; text-overflow: ellipsis; }
.einheit { color: var(--text-2); font-size: clamp(18px, 3vh, 32px); white-space: nowrap; }
.unter { margin: 6px 0 0; color: var(--text-2); font-size: clamp(14px, 2vh, 20px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.unter .s-ic { width: 1em; height: 1em; flex: none; }
.unter.gut { color: var(--gut-text); }
.unter.ernst { color: var(--ernst-text); }
.unter.warn { color: var(--warn); }
.kachel.aus { opacity: .38; }
.kachel.alarm { border-color: var(--warn); }
#k-regel .unter { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- Verlauf ---------- */
.verlauf { display: grid; grid-template-rows: auto auto minmax(0, 1fr); padding: clamp(8px, 1.4vh, 14px) clamp(12px, 1.4vw, 20px) 6px; min-height: 0; }
.vkopf { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; }
.tagwahl { display: flex; align-items: center; gap: 4px; }
.tagwahl h2 { margin: 0 6px; font-weight: 500; font-size: clamp(17px, 2.4vh, 24px); min-width: 5.5em; text-align: center; }
.knopf { background: var(--flaeche-2); border: 1px solid var(--linie); border-radius: 10px; width: 44px; height: 40px; font-size: 24px; line-height: 1; cursor: pointer; }
.knopf:disabled { opacity: .3; cursor: default; }
.reiter { display: flex; background: var(--grund); border: 1px solid var(--linie); border-radius: 10px; padding: 3px; }
.reiter-k { background: none; border: 0; border-radius: 8px; padding: 7px 14px; color: var(--text-2); font-size: clamp(15px, 2vh, 18px); cursor: pointer; }
.reiter-k.aktiv { background: var(--flaeche-2); color: var(--text); }
.legende { display: flex; gap: 6px 18px; flex-wrap: wrap; list-style: none; margin: 0 0 0 auto; padding: 0; color: var(--text-2); font-size: clamp(14px, 1.9vh, 18px); }
.legende li { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.legende .strich { width: 18px; height: 3px; border-radius: 2px; }
.legende .band { width: 16px; height: 12px; border-radius: 3px; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.18); }
.summen { margin: 6px 0 0; color: var(--text-2); font-size: clamp(14px, 2vh, 19px); display: flex; flex-wrap: wrap; gap: 4px 22px; }
.summen b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.diagramm { position: relative; min-height: 0; touch-action: pan-y; }
.diagramm svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.diagramm .leer { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); font-size: 18px; text-align: center; padding: 10px; }
.tip { position: absolute; top: 4px; pointer-events: none; background: var(--flaeche-2); border: 1px solid var(--linie); border-radius: 10px;
  padding: 8px 12px; font-size: 16px; color: var(--text); white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,.4); z-index: 5; }
.tip .zeit { color: var(--text-2); margin-bottom: 4px; }
.tip .zeile { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.tip .zeile i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.tip .zeile span { margin-left: auto; padding-left: 14px; }

/* SVG-Teile */
.ax text { fill: var(--text-3); font-size: 13px; font-family: "Barlow", sans-serif; font-variant-numeric: tabular-nums; }
.ax line { stroke: var(--raster); stroke-width: 1; shape-rendering: crispEdges; }
.ax .null { stroke: #3a4752; }
.jetzt { stroke: var(--text-3); stroke-width: 1; }
.lab { font-size: 14px; font-family: "Barlow", sans-serif; fill: var(--text-2); }

/* ---------- Hochformat / Handy: scrollen statt quetschen ---------- */
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  #seite { height: auto; min-height: 100dvh; grid-template-rows: auto auto auto; }
  /* 6 Spalten: große Kacheln 2 je Reihe, WW/Außen/Heizstab 3 je Reihe, Regel ganze Breite */
  .kacheln { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kachel.gross { grid-column: span 3; }
  .kachel.klein, #k-ww { grid-column: span 2; }
  .kachel.breit { grid-column: 1 / -1; }
  .unter { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .gross .zahl { font-size: clamp(40px, 11vw, 72px); }
  .klein .zahl { font-size: clamp(30px, 8vw, 52px); }
  .zahl.wort { font-size: clamp(24px, 6.5vw, 40px); }
  .verlauf { min-height: 0; }
  .diagramm { height: clamp(260px, 60vw, 420px); }
  .legende { margin-left: 0; width: 100%; }
  #uhrzeit { font-size: clamp(38px, 11vw, 60px); }
  #datum { font-size: clamp(15px, 4vw, 22px); }
  .kopf { flex-wrap: wrap; }
}
/* Handy schmal: WW + Außen nebeneinander, Heizstab als flache Zeile über die ganze Breite */
@media (max-width: 520px) {
  .kachel.klein, #k-ww { grid-column: span 3; }
  .kachel.breit { grid-column: 1 / -1; }
  #k-heizstab { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 14px; }
  #k-heizstab .wert { margin-top: 0; padding-top: 0; }
  #k-heizstab .zahl.wort { font-size: 26px; }
  #k-heizstab .unter { margin: 0 0 0 auto; }
}
@media (max-width: 380px) {
  .kachel h2 { font-size: 14px; }
  .marke { display: none; }
}

/* ---------- Textseiten (Datenschutz) ---------- */
body.textseite { user-select: text; overflow-y: auto; }
main.text { max-width: 760px; margin: 0 auto; padding: 32px var(--rand) 48px; line-height: 1.55; font-size: 17px; }
main.text h1 { font-family: "Barlow Condensed"; font-weight: 600; font-size: 40px; margin: 0 0 4px; }
main.text h2 { font-size: 20px; font-weight: 500; margin: 28px 0 6px; }
main.text p { color: var(--text-2); margin: 0 0 10px; }
main.text a { color: #86b6ef; }

/* ---------- Haustür (Livebild, Klingel) ---------- */
.tuer { position: fixed; inset: 0; z-index: 60; background: var(--grund); display: grid; grid-template-rows: auto minmax(0, 1fr);
  gap: var(--abstand); padding: var(--abstand) var(--rand); }
.tuer-kopf { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.tuer-kopf h2 { margin: 0; font-family: "Barlow Condensed"; font-weight: 600; font-size: clamp(28px, 4.5vh, 44px); }
.tuer-status { color: var(--text-2); font-size: clamp(15px, 2.2vh, 20px); margin-right: auto; }
.tuer.klingelt .tuer-kopf h2 { color: var(--warn); }
.knopf.breit { width: auto; padding: 0 18px; height: 46px; font-size: 18px; }
.tuer-inhalt { display: grid; grid-template-columns: minmax(0, 1fr) clamp(220px, 22vw, 300px); gap: var(--abstand); min-height: 0; }
.tuer-bild { position: relative; background: #000; border-radius: 16px; overflow: hidden; min-height: 0; }
.tuer-bild video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tuer-meldung { position: absolute; inset: 0; display: grid; place-content: center; gap: 14px; text-align: center; padding: 20px;
  color: var(--text-2); font-size: 20px; background: rgba(12,17,22,.82); }
.tuer-meldung a, .tuer-meldung button { justify-self: center; background: var(--reihe-1); color: #fff; border: 0; border-radius: 10px;
  padding: 12px 20px; font-size: 18px; text-decoration: none; cursor: pointer; }
.clip-zurueck { position: absolute; left: 12px; bottom: 12px; z-index: 2; }
.tuer-liste { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 16px; padding: 12px 14px; overflow-y: auto; min-height: 0; }
.tuer-liste h3 { margin: 0 0 8px; font-weight: 500; color: var(--text-2); font-size: 18px; }
.tuer-liste ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tuer-liste li { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 8px 10px; border-radius: 10px;
  background: var(--flaeche-2); font-size: 17px; font-variant-numeric: tabular-nums; }
.tuer-liste li button { background: none; border: 1px solid var(--linie); border-radius: 8px; padding: 5px 10px; cursor: pointer; color: var(--text); }
.tuer-liste .leer { color: var(--text-3); background: none; padding: 4px 0; }
.klein { font-size: 14px; margin-top: 10px; }
.warnung { margin: 12px 0 0; padding: 10px 12px; border: 1px solid var(--warn); border-radius: 10px; color: var(--text); font-size: 15px; line-height: 1.4; }
.warnung a { color: var(--warn); }
.textknopf { background: none; border: 0; color: var(--text-3); text-decoration: underline; cursor: pointer; padding: 6px 0; font-size: 14px; }
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .tuer { overflow-y: auto; grid-template-rows: auto auto; align-content: start; }
  .tuer-inhalt { align-content: start; }
  .tuer-liste { overflow: visible; }
  .tuer-inhalt { grid-template-columns: 1fr; }
  .tuer-bild { aspect-ratio: 4 / 3; }
  .kopf-rechts { width: 100%; justify-content: space-between; }
  .hinweis { order: 3; width: 100%; }
}
