:root {
  --grund: #f4f6f8; --flaeche: #ffffff; --flaeche2: #eef1f5; --text: #1d2733; --leise: #5b6878;
  --rand: #d6dde5; --akzent: #1f6feb; --akzent-text: #ffffff; --gut: #1a7f37; --warn: #b35900; --schlecht: #c62828;
  --schatten: 0 1px 2px rgba(20,30,40,.08), 0 4px 14px rgba(20,30,40,.06);
  --raum: #11161c; --kachel: #1d252e; --kachel-text: #e9eef3;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #12171d; --flaeche: #1b222a; --flaeche2: #242d37; --text: #e6ebf0; --leise: #9aa7b4;
    --rand: #33404d; --akzent: #4c8dff; --gut: #3fb950; --warn: #e3a248; --schlecht: #ff6b6b;
    --schatten: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--grund); color: var(--text); }
body { min-height: 100vh; font-size: 16px; line-height: 1.45; }
a { color: var(--akzent); }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--rand); background: var(--flaeche); border-radius: 8px; padding: .5em .9em;
  cursor: pointer; min-height: 40px;
}
button:hover { border-color: var(--akzent); }
button.haupt { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
button.gefahr { color: var(--schlecht); }
button.klein { min-height: 32px; padding: .25em .6em; font-size: .9em; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  border: 1px solid var(--rand); background: var(--flaeche); border-radius: 8px; padding: .5em .6em; min-height: 40px; width: 100%;
}
label { display: block; margin: .6em 0 .2em; font-weight: 600; font-size: .92em; }
.zeile { display: flex; gap: .6em; align-items: center; flex-wrap: wrap; }
.zeile > * { flex: 0 0 auto; }
.wachsen { flex: 1 1 auto !important; }
.leise { color: var(--leise); font-size: .92em; }
.versteckt { display: none !important; }

header.kopf {
  display: flex; align-items: center; gap: .8em; padding: .6em 1em; background: var(--flaeche);
  border-bottom: 1px solid var(--rand); position: sticky; top: 0; z-index: 5;
}
header.kopf h1 { font-size: 1.1em; margin: 0; flex: 1 1 auto; }
header.kopf .marke { font-weight: 700; color: var(--akzent); }
main.seite { max-width: 960px; margin: 0 auto; padding: 1em; }
.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 12px; padding: 1em; box-shadow: var(--schatten); margin-bottom: 1em; }
.karte h2 { margin: 0 0 .5em; font-size: 1.1em; }
.liste { display: grid; gap: .6em; }
.eintrag { display: flex; gap: .8em; align-items: center; flex-wrap: wrap; padding: .7em; border: 1px solid var(--rand); border-radius: 10px; background: var(--flaeche); }
.eintrag .titel { font-weight: 600; }
.marke-klein { display: inline-block; font-size: .8em; padding: .1em .5em; border-radius: 99px; background: var(--flaeche2); color: var(--leise); }
.marke-klein.gut { color: var(--gut); }
.marke-klein.schlecht { color: var(--schlecht); }
.meldung { padding: .6em .8em; border-radius: 8px; background: var(--flaeche2); margin: .5em 0; }
.meldung.fehler { color: var(--schlecht); }
table { border-collapse: collapse; width: 100%; }
td, th { text-align: left; padding: .4em .5em; border-bottom: 1px solid var(--rand); vertical-align: top; }
.tabelle { overflow-x: auto; }

dialog { border: 1px solid var(--rand); border-radius: 14px; background: var(--flaeche); color: var(--text); padding: 0; width: min(640px, 96vw); max-height: 92vh; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog .dkopf { display: flex; align-items: center; padding: .8em 1em; border-bottom: 1px solid var(--rand); position: sticky; top: 0; background: var(--flaeche); }
dialog .dkopf h2 { margin: 0; font-size: 1.05em; flex: 1; }
dialog .dinhalt { padding: 1em; }
.linkzeile { border: 1px solid var(--rand); border-radius: 10px; padding: .6em; margin: .5em 0; }
.linkzeile .knoepfe { display: flex; gap: .4em; flex-wrap: wrap; margin-top: .4em; }
.adresse { font-family: ui-monospace, monospace; font-size: .82em; word-break: break-all; color: var(--leise); }

#hinweis { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #222b35; color: #fff; padding: .6em 1em; border-radius: 10px; z-index: 50; max-width: 90vw; }

/* ---------- Raum ---------- */
body.raum { background: var(--raum); color: var(--kachel-text); overflow: hidden; height: 100vh; height: 100dvh; }
body.raum header.kopf { background: #0b0f14; border-color: #222; color: #e9eef3; }
.vorraum { max-width: 760px; margin: 0 auto; padding: 1em; overflow-y: auto; height: calc(100dvh - 56px); }
.vorraum .karte { background: var(--kachel); border-color: #2c3742; color: var(--kachel-text); }
.vorraum select, .vorraum input { background: #11161c; border-color: #33404d; color: #e9eef3; }
.vorschau { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; }
.vorschau video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.pegel { height: 8px; background: #2c3742; border-radius: 4px; overflow: hidden; margin-top: .4em; }
.pegel > div { height: 100%; width: 0; background: var(--gut); transition: width .08s; }

.buehne-rahmen { display: flex; height: calc(100dvh - 56px - 72px); }
.mitte { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.buehne { flex: 1 1 auto; position: relative; min-height: 0; display: none; background: #000; }
.buehne.an { display: block; }
.buehne video, .buehne canvas { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; width: auto; height: auto; }
.buehne video { width: 100%; height: 100%; object-fit: contain; }
.buehne .bschild { position: absolute; left: .6em; top: .6em; background: rgba(0,0,0,.6); padding: .2em .6em; border-radius: 6px; font-size: .85em; z-index: 2; }
.folienleiste { position: absolute; bottom: .6em; left: 50%; transform: translateX(-50%); display: flex; gap: .4em; z-index: 3; background: rgba(0,0,0,.6); padding: .3em; border-radius: 10px; align-items: center; }
.raster { flex: 1 1 auto; display: grid; gap: 8px; padding: 8px; align-content: center; min-height: 0; overflow: auto; }
.mitte.mit-buehne .raster { flex: 0 0 140px; grid-auto-flow: column; grid-auto-columns: 220px; grid-template-columns: none !important; align-content: stretch; overflow-x: auto; }
.kachel { position: relative; background: var(--kachel); border-radius: 12px; overflow: hidden; aspect-ratio: 16/9; outline: 3px solid transparent; transition: outline-color .15s; }
.mitte.mit-buehne .kachel { aspect-ratio: auto; height: 124px; }
.kachel.spricht { outline-color: #3fb950; }
.kachel video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.kachel video.eigen { transform: scaleX(-1); }
.kachel .bild-leer { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 2.2em; font-weight: 700; color: #9aa7b4; }
.kachel .schild { position: absolute; left: .5em; bottom: .5em; background: rgba(0,0,0,.6); padding: .15em .55em; border-radius: 6px; font-size: .85em; display: flex; gap: .4em; align-items: center; max-width: calc(100% - 1em); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.kachel .hand { position: absolute; right: .5em; top: .5em; font-size: 1.4em; }

.seitenleiste { flex: 0 0 340px; background: #161d24; border-left: 1px solid #26313c; display: flex; flex-direction: column; min-height: 0; }
.seitenleiste.zu { display: none; }
.seitenleiste .reiter { display: flex; border-bottom: 1px solid #26313c; }
.seitenleiste .reiter button { flex: 1; border: 0; border-radius: 0; background: transparent; color: #c9d3dc; }
.seitenleiste .reiter button.an { box-shadow: inset 0 -3px 0 var(--akzent); color: #fff; }
.seitenleiste .inhalt { flex: 1 1 auto; overflow-y: auto; padding: .6em; }
.seitenleiste select, .seitenleiste textarea, .seitenleiste input { background: #0f1419; border-color: #33404d; color: #e9eef3; }
.nachricht { margin: .3em 0; padding: .45em .6em; border-radius: 8px; background: #1f2832; }
.nachricht.direkt { background: #2a2346; }
.nachricht .von { font-size: .8em; color: #9aa7b4; }
.nachricht .text { white-space: pre-wrap; word-break: break-word; }
.person { display: flex; align-items: center; gap: .4em; padding: .4em 0; border-bottom: 1px solid #26313c; flex-wrap: wrap; }
.person .name { flex: 1 1 auto; }

.leiste { height: 72px; display: flex; align-items: center; justify-content: center; gap: .5em; padding: .5em; background: #0b0f14; border-top: 1px solid #222; overflow-x: auto; }
.leiste button { background: #222b35; border-color: #2f3a46; color: #e9eef3; min-width: 52px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72em; padding: .35em .6em; min-height: 56px; position: relative; }
.leiste button .sym { font-size: 1.5em; line-height: 1; }
.leiste button.aus { background: #4a1f22; border-color: #6b2a2f; }
.leiste button.an { background: #1f3a63; border-color: var(--akzent); }
.leiste button.rot { background: #b3261e; border-color: #b3261e; }
.leiste .zahl { position: absolute; top: 2px; right: 4px; background: var(--akzent); color: #fff; border-radius: 99px; font-size: .9em; padding: 0 .4em; }
.leiste .trenner { width: 1px; height: 36px; background: #2f3a46; margin: 0 .2em; }

.ende { max-width: 520px; margin: 4em auto; text-align: center; padding: 1em; }

@media (max-width: 760px) {
  .seitenleiste { position: fixed; inset: 56px 0 72px 0; z-index: 10; flex-basis: auto; }
  .leiste button .wort { display: none; }
  .leiste button { min-width: 46px; }
}
body.raum button { background: #222b35; border-color: #2f3a46; color: #e9eef3; }
body.raum button.haupt { background: var(--akzent); border-color: var(--akzent); color: #fff; }
body.raum button.gefahr { color: #ff8a80; }
body.raum dialog button { background: #222b35; }
.leiste { justify-content: flex-start; }
.leiste > :first-child { margin-left: auto; }
.leiste > :last-child { margin-right: auto; }
body.raum dialog { background: #1b222a; color: #e9eef3; border-color: #33404d; }
body.raum dialog .dkopf { background: #1b222a; border-color: #33404d; }
body.raum dialog select, body.raum dialog input, body.raum dialog textarea { background: #11161c; border-color: #33404d; color: #e9eef3; }
body.raum .linkzeile { border-color: #33404d; }
.vorschau canvas { position:absolute; inset:0; width:100%; height:100%; object-fit:contain; background:#000; }
