:root {
  --bg: #111318;
  --panel: #1a1d24;
  --panel-2: #232731;
  --border: #2e3340;
  --text: #e6e8ee;
  --muted: #8b92a3;
  --accent: #4f7cff;
  --danger: #e5484d;
  --ok: #3fb950;
  --warn: #d29922;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
}
button:hover { filter: brightness(1.15); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.active { background: var(--ok); border-color: var(--ok); color: #fff; }
button.ghost { background: transparent; }
button.small { padding: 4px 10px; font-size: 12px; }

input, select {
  width: 100%;
  margin-top: 4px;
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
}
input[type="range"] { padding: 0; accent-color: var(--accent); }
input[type="checkbox"] { width: auto; margin: 0 6px 0 0; accent-color: var(--accent); }
label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
label.check { display: flex; align-items: center; color: var(--text); }

/* Lobby */
.lobby { display: grid; place-items: center; height: 100%; }
.card {
  width: min(360px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}
.card h1 { margin: 0 0 4px; font-size: 22px; }
.card p { margin: 0 0 18px; }
.card button { width: 100%; margin-top: 6px; }

/* Hauptansicht */
.app {
  display: grid;
  grid-template-columns: 290px 1fr;
  grid-template-rows: 1fr auto;
  height: 100%;
}
.sidebar {
  grid-row: 1 / 3;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}
.sidebar h3 {
  margin: 18px 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.roomhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.roomhead h2 { margin: 0; font-size: 18px; overflow: hidden; text-overflow: ellipsis; }
.hint { margin: -2px 0 8px; font-size: 12px; color: var(--muted); }








.stage { position: relative; overflow: auto; padding: 12px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 12px;
}
.empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); pointer-events: none; }

.tile {
  position: relative;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  cursor: zoom-in;
}
.tile:fullscreen { border: 0; border-radius: 0; cursor: zoom-out; }
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile.local { border-color: var(--accent); }
.tile .label {
  position: absolute; left: 8px; bottom: 8px;
  background: rgba(0, 0, 0, .65);
  padding: 3px 8px; border-radius: 6px; font-size: 12px;
}
.tile .stats {
  position: absolute; left: 8px; top: 8px; margin: 0;
  background: rgba(0, 0, 0, .65);
  padding: 4px 8px; border-radius: 6px;
  font: 11px/1.45 ui-monospace, Consolas, monospace;
  white-space: pre;
}

.controls {
  display: flex; justify-content: center; gap: 10px;
  padding: 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 8px; z-index: 10;
}

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .sidebar { grid-row: auto; max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .grid { grid-template-columns: 1fr; }
  .controls { flex-wrap: wrap; }
}

/* ---------------------------------------------------------------------------
   Kanäle
   --------------------------------------------------------------------------- */
.sidebar { display: flex; flex-direction: column; padding-bottom: 0; }
.serverhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.serverhead h2 { margin: 0; font-size: 17px; }
.sectionhead { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.sectionhead h3 { margin: 0; }
.addchannel { display: flex; gap: 6px; margin: 8px 0 0; }
.addchannel input { margin: 0; }

.channels { list-style: none; margin: 8px 0 0; padding: 0; }
.channel { margin-bottom: 2px; }
.chan-head {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: 6px;
  color: var(--muted); cursor: pointer; user-select: none;
}
.chan-head:hover { background: var(--panel-2); color: var(--text); }
.channel.current > .chan-head { background: var(--panel-2); color: var(--text); font-weight: 600; }
.chan-icon { width: 16px; text-align: center; opacity: .8; }
.chan-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-count { font-size: 11px; color: var(--muted); }
.chan-del {
  display: none; padding: 0 6px; border: 0; background: transparent;
  color: var(--muted); font-size: 15px; line-height: 1;
}
.chan-head:hover .chan-del { display: inline-block; }
.chan-del:hover { color: var(--danger); }

.members { list-style: none; margin: 0 0 4px; padding: 0 0 0 26px; }
.members li { display: flex; align-items: center; gap: 7px; padding: 3px 4px; font-size: 13px; }
.members li.self { font-weight: 600; }
.members .icons { margin-left: auto; font-size: 12px; letter-spacing: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.connected { background: var(--ok); }
.dot.connecting { background: var(--warn); }
.dot.failed { background: var(--danger); }

.settings { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.settings summary { cursor: pointer; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.settings[open] summary { margin-bottom: 4px; }

.me {
  position: sticky; bottom: 0; margin: auto -16px 0;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; background: var(--panel); border-top: 1px solid var(--border);
}
.me #meChannel { margin-left: auto; font-size: 12px; }

.stagehead { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; }
.stagehead h2 { margin: 0; font-size: 18px; }

button:disabled { opacity: .45; cursor: not-allowed; filter: none; }

/* Anmeldung */
.linkbtn {
  display: block; width: 100%; margin-top: 10px; padding: 4px;
  background: transparent; border: 0; color: var(--muted); font-size: 13px;
}
.linkbtn:hover { color: var(--text); text-decoration: underline; }
.formerror {
  margin: 0 0 14px; padding: 8px 10px; border-radius: 6px;
  background: rgba(229, 72, 77, .15); color: #ff8a8d; font-size: 13px;
}
.settings .small { margin: 2px 0 6px; }

/* ---------------------------------------------------------------------------
   Textkanäle & Chat
   --------------------------------------------------------------------------- */
.stage { display: flex; flex-direction: column; padding: 0; }
.voiceview { position: relative; flex: 1; overflow: auto; padding: 12px; }
.textview { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.textview .stagehead { padding: 12px 16px; margin: 0; border-bottom: 1px solid var(--border); }

.channel.unread > .chan-head { color: var(--text); font-weight: 600; }
.channel.unread > .chan-head::before {
  content: ''; width: 6px; height: 6px; margin-left: -12px; margin-right: 0;
  border-radius: 50%; background: var(--text);
}
.channel.viewing > .chan-head { background: var(--panel-2); color: var(--text); }

.messages { flex: 1; overflow-y: auto; padding: 12px 16px; }
.messages .empty-chat { color: var(--muted); text-align: center; margin-top: 40px; }
.msg-group { margin-top: 14px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; }
.msg-author.self { color: var(--accent); }
.msg-time { font-size: 11px; color: var(--muted); }
.msg-text { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; padding: 1px 0; }
.msg-text a { color: #7aa2ff; }
.day-divider {
  display: flex; align-items: center; gap: 10px; margin: 18px 0 4px;
  color: var(--muted); font-size: 11px;
}
.day-divider::before, .day-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.messageform { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.messageform textarea {
  flex: 1; resize: none; overflow-y: hidden; max-height: 160px; margin: 0;
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
}

/* Dateien im Chat */
.textview { position: relative; }
.attach { padding: 6px 10px; font-size: 18px; line-height: 1; background: transparent; }
.attachment { margin: 6px 0 2px; max-width: min(480px, 100%); }
.attachment img, .attachment video {
  display: block; max-width: 100%; max-height: 360px;
  border-radius: 8px; background: #000; cursor: zoom-in;
}
.attachment audio { width: 100%; }
.filecard {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
}
.filecard:hover { border-color: #56607a; }
.filecard .ficon { font-size: 26px; }
.filecard .fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filecard .fsize { font-size: 12px; color: var(--muted); }
.filecard .fmeta { min-width: 0; flex: 1; }
.filecard .fdl { font-size: 12px; color: #7aa2ff; }

.uploads { padding: 0 16px; }
.upload {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
  padding: 8px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border);
  font-size: 13px;
}
.upload .uname { flex: 0 1 auto; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload progress { flex: 1; accent-color: var(--accent); height: 8px; }
.upload .upct { width: 42px; text-align: right; color: var(--muted); font-size: 12px; }

.dropoverlay {
  position: absolute; inset: 10px; z-index: 5;
  display: grid; place-items: center;
  border: 2px dashed var(--accent); border-radius: 12px;
  background: rgba(17, 19, 24, .85); font-size: 18px; pointer-events: none;
}

/* Bild in groß */
.lightbox {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, .88); cursor: zoom-out;
}
.lightbox img { max-width: 94vw; max-height: 88vh; border-radius: 6px; }
.lightbox a { position: absolute; bottom: 18px; color: #c9d4ff; font-size: 13px; }
.upload .uinfo { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------------------------------------------------------------------------
   Eigener Bereich unten links: Name + Symbol-Buttons
   --------------------------------------------------------------------------- */
.app { grid-template-rows: 1fr; }
.sidebar { grid-row: 1; }
.me { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; margin: auto -16px 0; }
.mehead { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mename { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
#meName { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me #meChannel { margin: 0; font-size: 11px; color: var(--muted); }
.me #meChannel.live { color: var(--ok); }
.mehead button { margin-left: auto; }
.mebar { display: flex; gap: 4px; }
.ibtn {
  flex: 1; display: grid; place-items: center;
  height: 32px; padding: 0; border-radius: 6px;
  background: transparent; border: 0; color: var(--muted);
}
.ibtn:hover:not(:disabled) { background: var(--panel-2); color: var(--text); filter: none; }
.ibtn svg { width: 18px; height: 18px; }
.ibtn.on { color: var(--text); }
.ibtn.active { background: rgba(63, 185, 80, .18); color: var(--ok); }
.ibtn.muted { background: rgba(229, 72, 77, .15); color: var(--danger); }
.ibtn.leave:not(:disabled) { color: var(--danger); }
.ibtn.leave:hover:not(:disabled) { background: rgba(229, 72, 77, .15); color: var(--danger); }
.ibtn:disabled { opacity: .3; }
.members .icons { display: flex; gap: 4px; letter-spacing: 0; }
.mini { display: inline-grid; width: 14px; height: 14px; color: var(--muted); }
.mini svg { width: 14px; height: 14px; }
.mini.live { color: var(--ok); }
.mini.off { color: var(--danger); }
.addbtn { color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 8px; }
.addbtn:hover { color: var(--text); }

/* ---------------------------------------------------------------------------
   Zeichenbrett
   --------------------------------------------------------------------------- */
.boardview { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.boardhead { padding: 12px 16px; margin: 0; border-bottom: 1px solid var(--border); }
.boardtools {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.boardtools .toolgroup { display: flex; gap: 2px; align-items: center; }
.boardtools .ibtn { flex: 0 0 34px; width: 34px; height: 34px; }
.boardtools .ibtn.selected { background: rgba(79, 124, 255, .2); color: #9db6ff; }
.boardtools .sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.boardtools .spacer { flex: 1; }
.swatch {
  width: 22px; height: 22px; padding: 0; border-radius: 50%;
  border: 2px solid transparent; outline: 1px solid rgba(255,255,255,.15); cursor: pointer;
}
.swatch.selected { border-color: var(--bg); outline: 2px solid #fff; }
.colorpick { display: grid; place-items: center; margin: 0; }
.colorpick input { width: 28px; height: 26px; padding: 0; margin: 0; border: 0; background: none; cursor: pointer; }
.sizepick { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); }
.sizepick input { width: 110px; margin: 0; }
.sizedot { display: inline-block; width: 22px; height: 22px; position: relative; }
.sizedot::after {
  content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: var(--d, 4px); height: var(--d, 4px); max-width: 22px; max-height: 22px;
  border-radius: 50%; background: var(--c, #fff);
}
.boardwrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 12px; overflow: hidden; }
.boardframe { position: relative; box-shadow: 0 2px 16px rgba(0,0,0,.4); border-radius: 6px; overflow: hidden; }
.boardframe canvas {
  display: block; width: 100%; height: 100%;
  background: #fff; touch-action: none; cursor: crosshair;
}
.cursorlayer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.rcursor { position: absolute; transform: translate(-2px, -2px); transition: left .06s linear, top .06s linear; }
.rcursor svg { width: 16px; height: 16px; display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.rcursor span {
  position: absolute; left: 14px; top: 12px; white-space: nowrap;
  padding: 1px 6px; border-radius: 4px; font-size: 11px; color: #fff;
}

/* Direktnachrichten */
.dm-icon { position: relative; display: inline-grid; place-items: center; }
.dm-icon .dot { width: 9px; height: 9px; }
.dm-empty { padding: 4px 8px; font-size: 12px; color: var(--muted); }
#dmForm select { margin: 0; flex: 1; }
.members li.clickable { cursor: pointer; border-radius: 4px; }
.members li.clickable:hover { background: var(--panel-2); }

.downloadlink { text-align: center; text-decoration: none; }

/* Sprechanzeige */
.members li .dot { transition: box-shadow .12s; }
.members li.speaking .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(63, 185, 80, .45); }
.members li.speaking > span:nth-child(2) { color: #fff; }

/* Lautstärke-Menü */
.volmenu {
  position: fixed; z-index: 30; width: 250px;
  padding: 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .5);
}
.volmenu .voltitle { font-weight: 600; margin-bottom: 8px; }
.volmenu .volrow { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.volmenu input[type="range"] { width: 100%; margin: 6px 0 10px; }
.volmenu .check { margin-bottom: 10px; font-size: 13px; }
.volmenu .volactions { display: flex; gap: 6px; flex-wrap: wrap; }
.headbtns { display: flex; gap: 6px; }
.btnlink {
  display: inline-block; text-decoration: none; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; font-size: 12px;
}
.btnlink:hover { background: var(--panel-2); }
.serverhead h2 { font-size: 16px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.headbtns { flex: none; }
.headbtns > * { white-space: nowrap; }
.headbtns .small { padding: 4px 8px; }
