:root {
  --bg: #0f1115;
  --panel: #161a20;
  --panel2: #1d222b;
  --line: #272d38;
  --text: #e7eaf0;
  --muted: #8c95a4;
  --accent: #42d6a4;
  --accent-ink: #06281d;
  --danger: #ff6b6b;
  --warn: #f5b84b;
  --radius: 10px;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --panel2: #eef0f4;
    --line: #dde1e8;
    --text: #1a1f29;
    --muted: #677184;
    --accent: #0c9d6c;
    --accent-ink: #ffffff;
    --danger: #d43c3c;
    --warn: #a86a00;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, p { margin: 0; }

.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; letter-spacing: .01em; }
.marble {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 32% 30%, #d9fff0 0 8%, var(--accent) 38%, #14795a 100%);
  box-shadow: inset -2px -3px 5px rgb(0 0 0 / .25);
}

/* ---- login & dialogs ---- */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: var(--bg); z-index: 10; }
.card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px; display: grid; gap: 14px; }
.card h2 { font-size: 17px; }
.card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.card label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.sub { color: var(--muted); margin-top: -6px; }
input:not([type=checkbox]):not([type=range]), select {
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; outline: none; width: 100%; color: var(--text);
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; border-radius: var(--radius); padding: 10px 14px; }
.primary:hover { filter: brightness(1.07); }
.ghost { display: flex; align-items: center; gap: 8px; color: var(--muted); padding: 8px 10px; border-radius: var(--radius); text-align: left; }
.ghost:hover { background: var(--panel2); color: var(--text); }
.error { color: var(--danger); font-size: 13px; }
.sso { display: grid; gap: 8px; }
.sso a { display: block; text-align: center; text-decoration: none; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-weight: 550; }
.sso a:hover { border-color: var(--accent); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.me-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.me-row small { display: block; color: var(--muted); }
.me-row a { color: var(--muted); font-size: 13px; }
.warn { color: var(--warn); font-size: 13px; }
dialog { border: 0; padding: 0; background: none; color: inherit; }
dialog::backdrop { background: rgb(0 0 0 / .55); }
.meter { height: 6px; border-radius: 3px; background: var(--panel2); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }

/* ---- layout ---- */
#app { display: grid; grid-template-columns: 290px 1fr; height: 100%; }
#side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
#side > header { padding: 16px 16px 12px; }
#channels { flex: 1; overflow-y: auto; padding: 4px 8px; }
#addChannel { margin: 4px 8px 8px; font-size: 13px; }

.chan { border-radius: var(--radius); margin-bottom: 2px; }
.chan-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; border-radius: var(--radius); color: var(--muted); font-weight: 550; text-align: left; }
.chan-head:hover { background: var(--panel2); color: var(--text); }
.chan.current > .chan-head { color: var(--text); }
.chan-head .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-head .count { font-size: 12px; font-weight: 400; opacity: .7; }
.chan-head .del { opacity: 0; padding: 2px; border-radius: 6px; color: var(--muted); display: grid; }
.chan-head:hover .del { opacity: .8; }
.chan-head .del:hover { color: var(--danger); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); flex: none; }

.user { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 22px; border-radius: var(--radius); position: relative; }
.user:hover { background: var(--panel2); }
.user .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.user .flags { display: flex; gap: 4px; color: var(--muted); }
.user .flags .ic { width: 14px; height: 14px; }
.user .flags .off { color: var(--danger); }
.user input[type=range] { width: 70px; accent-color: var(--accent); display: none; }
.user:hover input[type=range] { display: block; }
.user.me .name::after { content: " (du)"; color: var(--muted); }
.user .flags .ok { color: var(--accent); }

.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff; background: hsl(var(--hue, 160) 45% 42%);
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px transparent; transition: box-shadow .12s;
}
.speaking .avatar, .avatar.speaking { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }

#me { border-top: 1px solid var(--line); padding: 12px; display: grid; gap: 10px; }
#me .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
#me .who div { display: grid; min-width: 0; }
#me .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#me small { color: var(--muted); font-size: 12px; }
.controls { display: flex; gap: 8px; }
.round { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); color: var(--text); flex: none; }
.round:hover { filter: brightness(1.15); }
.round.off { background: color-mix(in srgb, var(--danger) 22%, var(--panel2)); color: var(--danger); }
.round.on { background: var(--accent); color: var(--accent-ink); }
.round.primary { background: var(--accent); color: var(--accent-ink); padding: 0; }
.round:disabled { opacity: .4; cursor: not-allowed; }

#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#top { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); min-height: 56px; }
#top h1 { font-size: 17px; display: flex; align-items: center; gap: 6px; }
#top h1 .ic { color: var(--muted); }
.grow { flex: 1; }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--panel2); color: var(--muted); white-space: nowrap; }
.badge.rec { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.badge.rec::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 34px; height: 20px; border-radius: 10px; background: var(--line); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

#body { flex: 1; display: flex; min-height: 0; }
#stage { flex: 1; display: grid; gap: 10px; padding: 12px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-content: center; background: #000; min-width: 0; overflow: auto; }
.tile { position: relative; background: #05070a; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; min-height: 120px; max-height: 100%; }
.tile video { width: 100%; height: 100%; max-height: calc(100vh - 90px); object-fit: contain; display: block; }
.tile .label { position: absolute; left: 8px; bottom: 8px; background: rgb(0 0 0 / .6); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.tile .full { position: absolute; right: 8px; top: 8px; background: rgb(0 0 0 / .6); color: #fff; border-radius: 6px; padding: 5px; display: grid; opacity: 0; transition: opacity .15s; }
.tile:hover .full { opacity: 1; }
.tile.own { color: #9aa3b2; font-size: 14px; padding: 24px; text-align: center; }

#chat { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#body.sharing #chat { flex: none; width: 340px; border-left: 1px solid var(--line); }
#feed { flex: 1; overflow-y: auto; padding: 14px 18px 6px; display: flex; flex-direction: column; gap: 10px; }
#feed:empty::before { content: "Noch nichts los hier. Sag oder schreib etwas."; color: var(--muted); margin: auto; }
.entry { display: grid; grid-template-columns: 30px 1fr; gap: 0 10px; }
.entry .avatar { grid-row: span 2; margin-top: 2px; }
.entry .meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: baseline; }
.entry .meta b { color: var(--text); font-size: 14px; }
.entry .meta .tag { display: inline-flex; align-items: center; gap: 4px; align-self: center; font-size: 11px; font-weight: 600; padding: 1px 8px 1px 6px; border-radius: 99px; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.entry .meta .tag .ic { width: 12px; height: 12px; stroke-width: 2.2; }
.entry .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.entry .text a { color: var(--accent); }
/* What was recognised from speech reads differently from what was typed: a
   coloured bar and the "Transkript" label, so nobody mistakes one for the other. */
.entry.spoken .text { margin-top: 3px; padding: 2px 0 2px 10px; border-left: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); }
.entry:not(.spoken) .seg { display: block; }
.seg { border-radius: 4px; }
.seg .anchor { position: relative; display: inline-block; width: 0; height: 1em; vertical-align: middle; }
.seg.mine:hover, .seg.mine.open { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.seg .edited { margin-left: 5px; font-size: 11px; color: var(--muted); font-style: normal; }
.seg.flip .tools { left: auto; right: 0; }
.seg .tools { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); display: none; gap: 2px; padding: 2px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 14px rgb(0 0 0 / .25); z-index: 2; white-space: nowrap; }
.seg.mine:hover .tools, .seg.mine.open .tools { display: inline-flex; }
.seg.editing .tools { display: none; }
.seg .tools button { display: grid; place-items: center; width: 26px; height: 24px; border-radius: 6px; color: var(--muted); }
.seg .tools button:hover { background: var(--line); color: var(--text); }
.seg .tools button[data-act=del]:hover { color: var(--danger); }
.seg .tools .ic { width: 14px; height: 14px; }
.seg.editing .body { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 3px; background: var(--panel2); padding: 0 3px; }
.notice { text-align: center; font-size: 12px; color: var(--muted); }

#composer { display: flex; gap: 8px; padding: 10px 18px 16px; }
#composer input { flex: 1; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: var(--radius); z-index: 20; max-width: min(90vw, 480px); box-shadow: 0 8px 30px rgb(0 0 0 / .35); }

@media (max-width: 760px) {
  body { overflow: auto; }
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 46vh; }
  #main { min-height: 54vh; }
  #body { flex-direction: column; }
  #body.sharing #chat { width: auto; border-left: 0; flex: 1; }
  #stage { grid-template-columns: 1fr; }
}
