/* the MOST Messenger – dunkles Design mit türkisem Akzent */
:root {
  color-scheme: dark;
  --accent: #2ee6c5;
  --accent-2: #12b5a0;
  --accent-text: #03231e;
  --accent-glow: rgb(46 230 197 / .35);
  --bg: #07090c;
  --panel: #0e1217;
  --panel-2: #141920;
  --text: #e8edf2;
  --muted: #7d8894;
  --line: #1d242c;
  --mine: #0f3a35;
  --theirs: #151b22;
  --danger: #ff6b6b;
  --chat-bg: #090c10;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent); color: var(--accent-text); }

.screen { height: 100dvh; }

/* ---------- Anmeldung ---------- */
#auth {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 24px) 16px calc(env(safe-area-inset-bottom) + 24px);
  background:
    linear-gradient(rgb(255 255 255 / .025) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgb(255 255 255 / .025) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg);
  overflow-y: auto;
}
.auth-glow {
  position: absolute; width: 640px; height: 640px; left: 50%; top: 38%;
  transform: translate(-50%, -50%); pointer-events: none;
  background: radial-gradient(circle, rgb(46 230 197 / .18), rgb(46 230 197 / .05) 40%, transparent 70%);
  filter: blur(10px);
  animation: breathe 8s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .6; transform: translate(-50%, -50%) scale(1.08); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.auth-box {
  position: relative; width: 100%; max-width: 380px; margin: auto;
  background: linear-gradient(180deg, rgb(20 25 32 / .85), rgb(12 15 20 / .9));
  border: 1px solid rgb(255 255 255 / .07);
  border-radius: 22px; padding: 32px 26px 22px;
  box-shadow: 0 30px 80px rgb(0 0 0 / .6), inset 0 1px 0 rgb(255 255 255 / .05);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: rise .6s cubic-bezier(.2, .8, .2, 1) both;
}
.brand { text-align: center; margin-bottom: 26px; }
.auth-logo {
  width: 68px; height: 68px; border-radius: 18px; display: block; margin: 0 auto 14px;
  box-shadow: 0 0 0 1px rgb(46 230 197 / .25), 0 10px 40px var(--accent-glow);
}
.wordmark { font-size: 2rem; font-weight: 800; letter-spacing: .02em; line-height: 1; }
.wordmark .the { font-weight: 300; color: var(--accent); letter-spacing: 0; }
.tagline {
  margin-top: 8px; font-size: .7rem; letter-spacing: .45em; text-transform: uppercase;
  color: var(--muted); padding-left: .45em;
}

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 6px 2px;
}
.input-wrap {
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: rgb(0 0 0 / .35); border: 1px solid var(--line); border-radius: 12px;
  transition: border-color .2s, box-shadow .2s;
}
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgb(46 230 197 / .12); }
.input-wrap > svg, .reveal svg {
  width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: var(--muted);
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: stroke .2s;
}
.input-wrap:focus-within > svg { stroke: var(--accent); }
.input-wrap input {
  flex: 1; min-width: 0; border: 0; background: none; padding: 13px 0; outline: none;
}
.input-wrap input::placeholder { color: #4a535d; }
.input-wrap input:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 40px #0b0f13 inset;
  caret-color: var(--text);
}
.reveal { border: 0; background: none; padding: 6px; margin-right: -6px; border-radius: 8px; display: flex; }
.reveal:hover svg, .reveal.on svg { stroke: var(--accent); }

.primary {
  width: 100%; border: 0; border-radius: 12px; padding: 14px 16px; margin-top: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text); font-weight: 700; letter-spacing: .03em;
  box-shadow: 0 8px 28px var(--accent-glow);
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.primary:hover { filter: brightness(1.08); box-shadow: 0 10px 36px rgb(46 230 197 / .5); }
.primary:active { transform: translateY(1px) scale(.99); }
.primary:disabled { opacity: .55; box-shadow: none; }
.error {
  color: var(--danger); font-size: .88rem; margin: 2px 0 12px; padding: 9px 12px;
  background: rgb(255 107 107 / .08); border: 1px solid rgb(255 107 107 / .25); border-radius: 10px;
}
.auth-foot { text-align: center; color: #4f5963; font-size: .72rem; letter-spacing: .06em; margin: 20px 0 0; }

.tabs {
  position: relative; display: flex; gap: 4px; padding: 4px; margin-bottom: 20px;
  background: rgb(0 0 0 / .35); border: 1px solid var(--line); border-radius: 12px;
}
.tabs button {
  flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px;
  color: var(--muted); font-weight: 500; transition: color .2s, background .2s;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--panel-2); color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1px rgb(46 230 197 / .25); }

dialog input {
  display: block; width: 100%; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: rgb(0 0 0 / .35);
}
input:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); }

/* Layout */
#main { display: flex; }
#list-pane { width: 340px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
#chat-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--chat-bg); }
#chat-view { display: flex; flex-direction: column; height: 100%; }

.bar {
  display: flex; align-items: center; gap: 4px;
  padding: calc(env(safe-area-inset-top) + 8px) 8px 8px 16px;
  min-height: 56px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 1.25rem; margin: 0; flex: 1; }
#chat-view .bar { padding-left: 4px; }
.chat-title { flex: 1; min-width: 0; cursor: pointer; }
.chat-title h2 { font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon { width: 40px; height: 40px; border: 0; background: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon:hover { background: var(--panel-2); color: var(--accent); }
.icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#btn-menu svg circle { fill: currentColor; stroke: none; }

.banner { background: #2a2410; color: #f0d78a; padding: 6px 16px; font-size: .85rem; border-bottom: 1px solid #3d3416; }

/* Chatliste */
#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: 10px 16px; cursor: pointer; }
#chat-list li:hover { background: var(--panel-2); }
#chat-list li.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; color: #fff; font-weight: 600;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.avatar.small { width: 36px; height: 36px; font-size: .9rem; }
.chat-meta { flex: 1; min-width: 0; }
.chat-meta .row { display: flex; gap: 8px; align-items: baseline; }
.chat-meta .name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta time { color: var(--muted); font-size: .8rem; }
.chat-meta .preview { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 10px; min-width: 20px; padding: 0 6px; font-size: .75rem; line-height: 20px; text-align: center; font-weight: 600; }
.empty { color: var(--muted); padding: 24px 16px; text-align: center; }
.empty.center { margin: auto; }

/* Nachrichten */
#messages { flex: 1; overflow-y: auto; padding: 12px 12px 4px; display: flex; flex-direction: column; gap: 2px; }
.day { align-self: center; background: var(--panel); color: var(--muted); font-size: .78rem; padding: 2px 10px; border-radius: 10px; margin: 10px 0 6px; }
.msg { max-width: min(78%, 520px); padding: 6px 10px 4px; border-radius: 14px; background: var(--theirs); align-self: flex-start; border: 1px solid rgb(255 255 255 / .04); overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; background: var(--mine); border-color: rgb(46 230 197 / .14); }
.msg + .msg:not(.cont) { margin-top: 6px; }
.msg .sender { font-size: .8rem; font-weight: 600; margin-bottom: 2px; }
.msg .text { white-space: pre-wrap; }
.msg .text a { color: var(--accent); }
.msg time { display: block; text-align: right; font-size: .7rem; color: var(--muted); margin-top: 2px; }
.msg img { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; margin: 2px 0; cursor: zoom-in; background: var(--line); }
.msg.pending { opacity: .6; }
.msg.failed time { color: var(--danger); }
.load-more { align-self: center; border: 0; background: var(--panel); color: var(--accent); padding: 4px 12px; border-radius: 12px; margin-bottom: 8px; font-size: .85rem; }

#composer {
  display: flex; align-items: flex-end; gap: 4px; background: var(--panel); border-top: 1px solid var(--line);
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px);
}
#text-input {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 20px; padding: 9px 14px;
  background: var(--bg); max-height: 140px; line-height: 1.35;
}
.send { color: var(--accent); }
.attach { color: var(--muted); cursor: pointer; }

/* Dialoge */
dialog {
  border: 1px solid var(--line); border-radius: 18px; padding: 20px; width: min(420px, calc(100vw - 32px));
  background: var(--panel); color: var(--text); box-shadow: 0 30px 80px rgb(0 0 0 / .6);
}
dialog::backdrop { background: rgb(0 0 0 / .65); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 14px; }
#menu button:not(.close) { display: block; width: 100%; text-align: left; border: 0; background: var(--bg); padding: 12px 14px; border-radius: 10px; margin-bottom: 8px; }
.danger { color: var(--danger); }
.close { display: block; margin: 8px auto 0; border: 0; background: none; color: var(--muted); padding: 8px; }
.hint { color: var(--muted); font-size: .85rem; }
dialog input { margin: 0 0 10px; }
#user-results, #info-members { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; }
#user-results li, #info-members li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-radius: 10px; cursor: pointer; }
#info-members li { cursor: default; }
#user-results li:hover { background: var(--bg); }
#user-results li .who, #info-members li .who { flex: 1; min-width: 0; }
.who small { display: block; color: var(--muted); }
#user-results input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.dialog-actions { display: flex; gap: 8px; margin-top: 14px; }
.dialog-actions button { flex: 1; border: 0; background: var(--bg); padding: 11px; border-radius: 10px; }
.dialog-actions .primary { margin-top: 0; box-shadow: none; }

#lightbox { position: fixed; inset: 0; background: rgb(0 0 0 / .9); display: flex; align-items: center; justify-content: center; z-index: 10; cursor: zoom-out; }
#lightbox img { max-width: 100%; max-height: 100%; }

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 80px); transform: translateX(-50%);
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); box-shadow: 0 10px 30px rgb(0 0 0 / .5); padding: 10px 16px; border-radius: 12px; font-size: .9rem; z-index: 20;
  max-width: calc(100vw - 32px);
}

/* Handy: eine Spalte */
@media (max-width: 760px) {
  #list-pane { width: 100%; border-right: 0; }
  #chat-pane { display: none; }
  #main.in-chat #list-pane { display: none; }
  #main.in-chat #chat-pane { display: flex; }
}
@media (min-width: 761px) {
  #btn-back { display: none; }
  #chat-view .bar { padding-left: 16px; }
}

/* ---------- Profilbilder ---------- */
.avatar { overflow: hidden; position: relative; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.has-img { background: var(--panel-2) !important; }
.header-avatar {
  width: 40px; height: 40px; padding: 0; border: 0; background: none; border-radius: 50%; flex-shrink: 0;
  margin-right: 4px;
}
.header-avatar .avatar { width: 40px; height: 40px; font-size: .95rem; box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px rgb(46 230 197 / .5); }
.profile { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.profile .avatar { width: 64px; height: 64px; font-size: 1.4rem; box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.profile-text { min-width: 0; }
.profile-text h3 { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-text small { color: var(--muted); }
#menu .menu-item, #menu button:not(.close), #info .menu-item {
  display: block; width: 100%; text-align: left; border: 0; background: var(--panel-2);
  padding: 12px 14px; border-radius: 10px; margin-bottom: 8px; cursor: pointer; font-size: 1rem; color: var(--text);
}
#menu .menu-item:hover, #menu button:not(.close):hover, #info .menu-item:hover { color: var(--accent); }
#info .danger { color: var(--danger) !important; }
.section-title { margin: 14px 2px 6px; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
#info-members { margin-bottom: 10px; }
#btn-chat-menu { margin-left: -4px; }
#menu .danger { color: var(--danger) !important; }
#menu button:disabled { opacity: .5; cursor: default; }
