:root {
  --text: #fff; --muted: rgba(255,255,255,.62); --glass: rgba(255,255,255,.10); --glass2: rgba(255,255,255,.16);
  --line: rgba(255,255,255,.18); --accent: #ffc35a; --bad: #ff5f6d; --ok: #4cd97b; --r: 22px;
  --blur: blur(24px) saturate(170%);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: #151225; }
body { margin: 0; color: var(--text); min-height: 100vh;
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 100px);
  user-select: none; -webkit-user-select: none; }

/* Hintergrund mit weichen Farbflecken */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: radial-gradient(120% 80% at 0% 0%, #2c1f5c 0%, #151225 55%), #151225; }
.bg i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; }
.bg .b1 { width: 60vw; height: 60vw; background: #ff8a3d; top: -10vw; right: -15vw; }
.bg .b2 { width: 70vw; height: 70vw; background: #6a4cff; bottom: 10vh; left: -30vw; }
.bg .b3 { width: 50vw; height: 50vw; background: #00b3c7; bottom: -15vw; right: -10vw; opacity: .35; }

.glass { background: var(--glass); border: 1px solid var(--line); border-radius: var(--r);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }

header { display: flex; justify-content: space-between; align-items: flex-end; padding: 14px 2px 6px; }
.eyebrow { margin: 0; color: var(--muted); font-size: 14px; font-weight: 500; }
h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -.6px; }
#summary { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.pill { padding: 8px 14px; border-radius: 99px; background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); font-size: 14px; font-weight: 600; }

/* Szenen-Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 14px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 99px;
  background: var(--glass); border: 1px solid var(--line); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  font-weight: 600; font-size: 14px; transition: transform .12s; }
.chip:active { transform: scale(.94); }

/* Raeume & Kacheln */
.room { margin-top: 24px; }
.roomHead { display: flex; justify-content: space-between; align-items: center; margin: 0 4px 10px; }
.roomHead h3 { margin: 0; font-size: 20px; font-weight: 700; }
.roomHead button { font-size: 13px; color: var(--muted); padding: 6px 12px; border-radius: 99px; background: var(--glass); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { position: relative; min-height: 112px; padding: 14px; text-align: left; display: flex; flex-direction: column;
  justify-content: space-between; transition: transform .12s, background .25s, color .25s; }
.tile:active { transform: scale(.95); }
.tile.on { background: rgba(255,255,255,.88); color: #15131f; border-color: rgba(255,255,255,.9); }
.tile.offline { opacity: .45; }
.tile.hiddenDev { border-style: dashed; }
.icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; background: var(--glass2); }
.tile.on .icon { background: var(--glow, var(--accent)); box-shadow: 0 0 22px var(--glow, var(--accent)); }
.tname { font-weight: 600; font-size: 15px; margin-top: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tstate { font-size: 13px; color: var(--muted); }
.tile.on .tstate { color: rgba(21,19,31,.6); }
.more { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); font-size: 20px; }
.tile.on .more { color: rgba(21,19,31,.5); }
.bri { position: absolute; left: 14px; right: 14px; bottom: 8px; height: 3px; border-radius: 2px; background: rgba(0,0,0,.1); overflow: hidden; }
.bri i { display: block; height: 100%; background: var(--glow, var(--accent)); }

/* Szenen */
.scene { min-height: 96px; padding: 14px; text-align: left; display: flex; flex-direction: column; justify-content: space-between; position: relative; }
.scene .emo { font-size: 28px; }
.scene b { font-size: 15px; }
.scene small { color: var(--muted); font-size: 12px; }
.scene.flash { animation: flash .6s; }
@keyframes flash { 30% { background: rgba(255,255,255,.7); color: #15131f; } }
.addBtn { width: 100%; margin-top: 14px; padding: 16px; border-radius: var(--r); border: 1px dashed var(--line);
  color: var(--muted); font-weight: 600; background: rgba(255,255,255,.04); }
.hint { color: var(--muted); font-size: 13px; margin: 14px 4px; }

/* Zeitplaene */
.sched { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 10px; text-align: left; width: 100%; }
.sched .time { font-size: 26px; font-weight: 700; min-width: 76px; font-variant-numeric: tabular-nums; }
.sched .info { flex: 1; min-width: 0; }
.sched .info b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched .info small { color: var(--muted); font-size: 12px; }
.sched.disabled { opacity: .5; }
.switch { position: relative; width: 51px; height: 31px; flex: none; border-radius: 99px; background: rgba(255,255,255,.2); transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(20px); }

/* Strom */
.seg { display: flex; padding: 3px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); margin-top: 14px; }
.seg button { flex: 1; padding: 8px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.sel { background: rgba(255,255,255,.9); color: #15131f; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.stat { padding: 14px 16px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 28px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.chartBox { margin-top: 10px; padding: 14px 12px 8px; }
#eChart { width: 100%; height: 170px; display: block; }
.axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 4px; padding: 0 2px; }
.edev { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-top: 10px; }
.edev .info { flex: 1; min-width: 0; }
.edev .info b { font-size: 15px; display: block; }
.edev .info small { color: var(--muted); font-size: 12px; }
.edev .bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,.12); margin-top: 6px; overflow: hidden; }
.edev .bar i { display: block; height: 100%; background: var(--accent); }
.edev .switch { transform: scale(.8); transform-origin: right center; }
.edev .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Tab-Leiste */
#tabs { position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 10px); display: flex; padding: 6px;
  border-radius: 26px; background: rgba(30,26,50,.55); border: 1px solid var(--line);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); z-index: 5; }
#tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 20px;
  font-size: 11px; font-weight: 600; color: var(--muted); }
#tabs button span { font-size: 20px; filter: grayscale(1); opacity: .7; }
#tabs button.sel { background: rgba(255,255,255,.14); color: #fff; }
#tabs button.sel span { filter: none; opacity: 1; }

/* Sheet */
#sheetBg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 10; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; max-height: 90vh; overflow-y: auto;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 22px); border-radius: 28px 28px 0 0;
  background: rgba(40,34,66,.72); border-top: 1px solid var(--line); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(100%); } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.3); margin: 0 auto 14px; }
#sheet h2 { margin: 0; font-size: 22px; }
#sheet .sub { color: var(--muted); margin: 4px 0 18px; font-size: 14px; }
.big { width: 100%; padding: 15px; border-radius: 16px; background: var(--glass2); font-weight: 700; margin-bottom: 16px; }
.big.on { background: rgba(255,255,255,.9); color: #15131f; }
.big.danger { background: rgba(255,95,109,.18); color: var(--bad); }
.field { display: block; margin-bottom: 16px; color: var(--muted); font-size: 13px; font-weight: 600; }
.field input[type=text], .field input[type=time], .field select {
  display: block; width: 100%; margin-top: 6px; padding: 13px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255,255,255,.08); color: var(--text); font: 16px -apple-system, system-ui, sans-serif; -webkit-appearance: none; appearance: none; }
.field select option { color: #000; }
input[type=range] { width: 100%; margin-top: 10px; accent-color: #fff; height: 34px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-top: 10px; }
.swatches button { aspect-ratio: 1; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); }
.swatches button.sel { border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.3); }
.emojis { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.emojis button { width: 44px; height: 44px; border-radius: 12px; font-size: 22px; background: rgba(255,255,255,.06); }
.emojis button.sel { background: rgba(255,255,255,.3); }
.days { display: flex; gap: 6px; margin-top: 8px; }
.days button { flex: 1; padding: 10px 0; border-radius: 12px; background: rgba(255,255,255,.08); font-weight: 600; font-size: 13px; }
.days button.sel { background: rgba(255,255,255,.9); color: #15131f; }
.pick { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px; margin-top: 6px; border-radius: 14px; background: rgba(255,255,255,.06); text-align: left; }
.pick .chk { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 14px; flex: none; }
.pick.sel .chk { background: var(--ok); border-color: var(--ok); }
.pick .nm { flex: 1; min-width: 0; }
.pick .nm small { display: block; color: var(--muted); font-size: 12px; }
.pick .st { font-size: 12px; padding: 5px 10px; border-radius: 99px; background: rgba(255,255,255,.12); }
.pick .st.on { background: rgba(255,255,255,.9); color: #15131f; }
.row2 { display: flex; gap: 10px; }
.row2 > * { flex: 1; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; color: var(--text); font-size: 15px; }

/* Kopfzeile: Profil */
.hdrBtns { display: flex; gap: 8px; align-items: center; }
.avatar { width: 38px; height: 38px; border-radius: 50%; font-weight: 700; font-size: 15px; color: #15131f;
  background: var(--me, rgba(255,255,255,.3)); border: 2px solid rgba(255,255,255,.5); }
.dot { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 10px; font-weight: 700; color: #15131f; flex: none; }

/* Listen */
.chip.sel { background: rgba(255,255,255,.9); color: #15131f; }
.chip .cnt { font-size: 12px; opacity: .6; }
.addItem { display: flex; margin-top: 14px; padding: 4px 4px 4px 14px; border-radius: 18px; }
.addItem input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font-size: 16px; padding: 10px 0; outline: none; }
.addItem input::placeholder { color: var(--muted); }
.addItem button { width: 42px; height: 42px; border-radius: 14px; background: rgba(255,255,255,.9); color: #15131f; font-size: 22px; font-weight: 700; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; margin-top: 8px; border-radius: 16px; width: 100%; text-align: left; }
.item .box { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); flex: none; display: grid; place-items: center; font-size: 14px; }
.item.done .box { background: var(--ok); border-color: var(--ok); }
.item .txt { flex: 1; min-width: 0; font-size: 16px; }
.item.done .txt { text-decoration: line-through; color: var(--muted); }
.item .del { color: var(--muted); font-size: 18px; padding: 4px 6px; }
.doneHead { display: flex; justify-content: space-between; align-items: center; margin: 22px 4px 2px; color: var(--muted); font-size: 14px; font-weight: 600; }
.doneHead button { color: var(--accent); font-size: 14px; font-weight: 600; }

/* Notizen */
.notes { columns: 2; column-gap: 10px; margin-top: 14px; }
.note { break-inside: avoid; display: block; width: 100%; margin-bottom: 10px; padding: 14px; text-align: left; border-radius: 20px; }
.note b { display: block; font-size: 15px; margin-bottom: 4px; }
.note p { margin: 0; font-size: 14px; color: rgba(255,255,255,.82); white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
.note .meta { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.note .rem { display: inline-block; margin-top: 8px; font-size: 12px; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.14); }
.note .pin { float: right; font-size: 13px; }
.colors { display: flex; gap: 8px; margin-top: 8px; }
.colors button { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); }
.colors button.sel { border: 3px solid #fff; }
textarea.ta { display: block; width: 100%; min-height: 160px; margin-top: 6px; padding: 13px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255,255,255,.08); color: var(--text); font: 16px/1.4 -apple-system, system-ui, sans-serif; resize: vertical; }
.field input[type=datetime-local] { display: block; width: 100%; margin-top: 6px; padding: 13px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255,255,255,.08); color: var(--text); font: 16px -apple-system, system-ui, sans-serif; -webkit-appearance: none; }
.optRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 15px; }
.optRow small { display: block; color: var(--muted); font-size: 12px; }
.users { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 18px; }
.users button { display: flex; align-items: center; gap: 8px; padding: 10px 16px 10px 10px; border-radius: 99px; background: rgba(255,255,255,.1); font-weight: 600; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 92px); z-index: 20;
  padding: 11px 18px; border-radius: 99px; font-size: 14px; font-weight: 600; white-space: nowrap;
  background: rgba(30,26,50,.8); border: 1px solid var(--line); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
#toast.err { background: rgba(255,95,109,.85); }
