/* Splash Squad Elite: schwarz, Neongrün, Lila, Orange-Rot */
:root {
  color-scheme: dark;
  --bg: #07070b; --panel: #101018; --text: #eef0f4; --muted: #8d92a8; --line: #25253a;
  --accent: #2af810; --accent-text: #04120a; --mine: #3a2a72; --theirs: #1b1b28; --danger: #ff6a3d;
  --purple: #6b4fb3;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); }
button.icon { border: 0; background: none; font-size: 20px; padding: 8px 10px; line-height: 1; }
button.round { border-radius: 50%; width: 44px; height: 44px; padding: 0; flex: none; }
input, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }
.empty { color: var(--muted); text-align: center; padding: 40px 20px; }
.spacer { flex: 1; }

/* Anmeldung */
#auth { background: #000; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
#auth-form { width: 100%; max-width: 340px; display: grid; gap: 12px; text-align: center; }
#auth-form img { margin: 0 auto; width: min(70vw, 260px); height: auto; }
#auth-form h1 { margin: 0 0 8px; font-size: 22px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
#auth-form input:focus, #composer textarea:focus { outline-color: var(--purple); }
.brand { width: 36px; height: 36px; border-radius: 8px; margin-left: 4px; flex: none; }
header { border-bottom-color: var(--purple); }

/* App-Layout */
#app { height: 100dvh; display: grid; grid-template-columns: 340px 1fr; }
#list-pane, #chat-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
#list-pane { border-right: 1px solid var(--line); }
header { display: flex; align-items: center; gap: 4px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--panel); min-height: 56px; }
header h2 { margin: 0 0 0 6px; font-size: 20px; }
.conn { background: #b7791f; color: #fff; text-align: center; font-size: 13px; padding: 4px; }

#chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#chat-list li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
#chat-list li:hover, #chat-list li.active { background: var(--bg); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; flex: none; }
.avatar.group { border-radius: 14px; }
.li-main { flex: 1; min-width: 0; }
.li-top { display: flex; justify-content: space-between; gap: 8px; }
.li-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-time { color: var(--muted); font-size: 12px; flex: none; }
.li-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.li-last { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }

#chat-pane { background: var(--bg); }
#chat-view { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.title-btn { border: 0; background: none; text-align: left; flex: 1; min-width: 0; padding: 4px 8px; }
.title-btn span { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-btn small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-back { display: none; }

#messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; color: var(--muted); font-size: 12px; margin: 10px 0 4px; }
.msg { max-width: min(80%, 560px); padding: 7px 10px; border-radius: 14px; background: var(--theirs); border: 1px solid var(--line); align-self: flex-start; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.mine { background: var(--mine); align-self: flex-end; }
.msg .who { font-size: 12px; font-weight: 700; color: var(--accent); }
.msg.mine { border-color: var(--purple); }
.msg .body { white-space: pre-wrap; }
.msg img { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; cursor: zoom-in; margin-top: 2px; }
.msg .time { color: var(--muted); font-size: 11px; text-align: right; margin-top: 2px; }
.msg.pending { opacity: .6; }

#composer { display: flex; gap: 6px; align-items: flex-end; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
#text { resize: none; max-height: 140px; border-radius: 22px; padding: 10px 14px; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); width: min(92vw, 400px); padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h3 { margin: 0 0 10px; }
dialog form, dialog > * { display: block; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; }
.tabs button.active { background: var(--accent); color: var(--accent-text); border-color: transparent; }
#dlg-name { margin-bottom: 8px; }
#dlg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 14px; cursor: pointer; }
#dlg-results, #info-members { list-style: none; margin: 8px 0; padding: 0; max-height: 36vh; overflow-y: auto; }
#dlg-results li, #info-members li { padding: 10px 8px; border-bottom: 1px solid var(--line); }
#dlg-results li { cursor: pointer; }
#dlg-results li:hover { background: var(--bg); }
.row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }

#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: grid; place-items: center; z-index: 50; cursor: zoom-out; }
#lightbox img { max-width: 96vw; max-height: 96dvh; }

/* Smartphone: Liste und Chat nacheinander */
@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; }
  #chat-pane { display: none; }
  body.chat-open #list-pane { display: none; }
  body.chat-open #chat-pane { display: flex; }
  #btn-back { display: block; }
  #chat-placeholder { display: none; }
}
