/* Wand-Panel: dunkel, ruhig, grosse Flaechen zum Tippen. Eingeschaltete Raeume leuchten in der Farbe ihrer Lampen (--glut),
   ausgeschaltete bleiben flach. Keine Fremd-Schriften, das iPad bringt SF Pro mit. */
:root {
  --bg: #0f0e0c;
  --flaeche: #191714;
  --flaeche-2: #24211d;
  --flaeche-3: #2e2a25;
  --rand: #34302a;
  --fg: #f2ede4;
  --leise: #9b9489;
  --amber: #f5b54a;
  --rot: #f0806f;
  --gruen: #8fcf9a;
  --glut: #f5b54a;
  --text: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--text); font-size: 17px; line-height: 1.35;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
button { font: inherit; color: inherit; }
a { color: var(--amber); }
button:focus-visible, a:focus-visible, .regler:focus-visible, input:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
[hidden] { display: none !important; }

.panel { max-width: 1400px; margin: 0 auto; padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 22px; }

/* Kopf mit Uhr */
.kopf { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.zeit b { display: block; font-size: clamp(52px, 7vw, 88px); font-weight: 200; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.zeit span { display: block; margin-top: 6px; color: var(--leise); font-size: 17px; }
.kopf-rechts { display: flex; align-items: center; gap: 10px; }
.status { color: var(--leise); font-size: 14px; font-variant-numeric: tabular-nums; margin-right: 6px; }
.status.fehler { color: var(--rot); }

.knopf {
  border: 1px solid var(--rand); border-radius: 14px; background: var(--flaeche-2); min-height: 52px; padding: 0 20px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--fg);
  transition: background-color .15s ease, transform .1s ease;
}
.knopf:active { transform: scale(.97); background: var(--flaeche-3); }
.knopf.haupt { background: var(--amber); border-color: var(--amber); color: #1d1405; }
.knopf.icon { width: 52px; padding: 0; }
.knopf.klein { min-height: 40px; padding: 0 14px; font-size: 15px; border-radius: 11px; }
.knopf.warnung { color: var(--rot); }
.knopf svg { width: 24px; height: 24px; }

.abschnitt { margin: 0 0 12px; font-size: 14px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--leise); display: flex; gap: 10px; }
.abschnitt span { color: var(--fg); font-weight: 500; letter-spacing: 0; text-transform: none; }

/* Hinweis (Hue noch nicht verbunden o.ae.) */
.hinweis { border: 1px solid var(--amber); border-radius: 20px; padding: 22px; background: linear-gradient(160deg, #2b210f, var(--flaeche) 60%); display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.hinweis h2 { margin: 0; font-size: 22px; }
.hinweis p { margin: 0; color: var(--leise); max-width: 60ch; }

/* Raumkacheln */
.raeume { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.raum {
  position: relative; border: 1px solid var(--rand); border-radius: 22px; background: var(--flaeche); padding: 10px;
  display: flex; flex-direction: column; gap: 8px; transition: background-color .3s ease, border-color .3s ease, box-shadow .3s ease;
}
.raum.an {
  border-color: color-mix(in srgb, var(--glut) 45%, var(--rand));
  background: radial-gradient(130% 100% at 0% 0%, color-mix(in srgb, var(--glut) 26%, transparent), transparent 65%), var(--flaeche);
  box-shadow: 0 10px 40px color-mix(in srgb, var(--glut) 10%, transparent);
}
.raum-kopf {
  border: 0; background: none; text-align: left; cursor: pointer; padding: 10px 10px 6px; border-radius: 14px;
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 12px; row-gap: 2px; align-items: center; min-height: 76px;
}
.raum-kopf:active { background: rgba(255, 255, 255, .04); }
.raum-name { font-size: 21px; font-weight: 600; grid-column: 1; }
.raum-info { color: var(--leise); font-size: 15px; grid-column: 1; }
.raum.an .raum-info { color: color-mix(in srgb, var(--glut) 55%, var(--fg)); }
.birne {
  grid-column: 2; grid-row: 1 / span 2; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--flaeche-2); color: var(--leise); transition: background-color .3s ease, color .3s ease, box-shadow .3s ease;
}
.birne svg { width: 24px; height: 24px; }
.raum.an .birne { background: var(--glut); color: #1d1405; box-shadow: 0 0 22px color-mix(in srgb, var(--glut) 55%, transparent); }
.raum-mehr { border: 0; background: none; color: var(--leise); font-size: 15px; padding: 8px 10px 6px; text-align: left; cursor: pointer; border-radius: 10px; min-height: 40px; }
.raum-mehr:active { background: rgba(255, 255, 255, .04); }

/* Helligkeit: ganze Flaeche ist der Regler, Tippen setzt den Wert, Ziehen aendert ihn */
.regler {
  position: relative; height: 54px; border-radius: 15px; background: var(--flaeche-2); overflow: hidden; cursor: pointer;
  touch-action: pan-y; display: flex; align-items: center; padding: 0 16px;
}
.regler::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: var(--wert, 0%);
  background: color-mix(in srgb, var(--glut) 50%, #1a1814); transition: width .12s ease;
}
.regler.ziehen::before { transition: none; }
.regler-wert { position: relative; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--fg); text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.aus .regler-wert { color: var(--leise); font-weight: 500; }

/* Dialoge */
dialog {
  width: min(680px, calc(100vw - 32px)); max-height: min(88vh, 960px); padding: 0; border: 1px solid var(--rand); border-radius: 24px;
  background: var(--flaeche); color: var(--fg); box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog[open] { animation: auf .2s ease-out; }
@keyframes auf { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.dialog-kopf { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 14px 24px; background: var(--flaeche); border-bottom: 1px solid var(--rand); }
.dialog-kopf h2 { margin: 0; font-size: 24px; }
.dialog-inhalt { padding: 18px 24px 26px; display: flex; flex-direction: column; gap: 22px; }
.dialog-inhalt h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--leise); }

.szenen { display: flex; flex-wrap: wrap; gap: 8px; }
.szene { border: 1px solid var(--rand); background: var(--flaeche-2); border-radius: 999px; min-height: 46px; padding: 0 18px; font-weight: 600; cursor: pointer; }
.szene:active { transform: scale(.97); }
.szene.aktiv { border-color: var(--amber); color: var(--amber); }

.lampen { display: flex; flex-direction: column; gap: 10px; }
.lampe { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px 14px; padding: 12px 14px; border-radius: 18px; background: var(--flaeche-2); --glut: var(--amber); }
.lampe .punkt { width: 14px; height: 14px; border-radius: 50%; background: var(--flaeche-3); }
.lampe.an .punkt { background: var(--glut); box-shadow: 0 0 12px var(--glut); }
.lampe .name { font-weight: 600; }
.lampe .name small { display: block; font-weight: 400; color: var(--rot); font-size: 14px; }
.lampe .regler { grid-column: 1 / -1; height: 46px; background: var(--flaeche-3); }
.lampe.weg { opacity: .55; }

/* Schalter (Lampe an/aus) */
.schalter { width: 64px; height: 38px; border-radius: 999px; border: 0; background: var(--flaeche-3); position: relative; cursor: pointer; transition: background-color .2s ease; }
.schalter::after { content: ''; position: absolute; top: 4px; left: 4px; width: 30px; height: 30px; border-radius: 50%; background: var(--fg); transition: transform .2s ease; }
.schalter[aria-pressed="true"] { background: var(--glut); }
.schalter[aria-pressed="true"]::after { transform: translateX(26px); background: #1d1405; }
.schalter:disabled { opacity: .4; }

/* Einstellungen */
.zeilen { display: flex; flex-direction: column; gap: 8px; }
.zeile { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--flaeche-2); }
.zeile small { display: block; color: var(--leise); font-size: 14px; }
.reihe { display: flex; flex-wrap: wrap; gap: 8px; }
.meldung { margin: 0; color: var(--leise); font-size: 15px; }
.meldung.fehler { color: var(--rot); }

/* Anmelden */
.anmelden { max-width: 520px; margin: 0 auto; padding: 12vh 24px 40px; display: flex; flex-direction: column; gap: 22px; }
.anmelden .marke { font-size: 15px; font-weight: 700; letter-spacing: .2em; color: var(--amber); }
.karte { border: 1px solid var(--rand); border-radius: 22px; background: var(--flaeche); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.karte h1, .karte h2 { margin: 0; font-size: 24px; }
.karte p { margin: 0; color: var(--leise); }
.eingabe { display: flex; gap: 8px; }
.eingabe input { flex: 1; min-width: 0; min-height: 52px; border-radius: 14px; border: 1px solid var(--rand); background: var(--flaeche-2); color: var(--fg); padding: 0 16px; font: inherit; -webkit-user-select: text; user-select: text; }

@media (max-width: 600px) {
  .panel { padding: 14px 16px 32px; gap: 18px; }
  .kopf { align-items: flex-start; }
  .raeume { grid-template-columns: 1fr; }
  .dialog-inhalt { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
.zeilen + .reihe { margin-top: 10px; }
