:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-2: #ec4899;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, white);
  --mine: var(--accent);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --theirs: #ffffff;
  --border: #e3e5ea;
  --green: #22c55e;
  --red: #dc2626;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); transition: opacity .4s; }
body.preload { opacity: 0; }
.config-error { position: fixed; z-index: 1000; left: 0; right: 0; top: 0; background: var(--red); color: #fff; padding: 10px 16px; font-weight: 600; font-size: .9rem; }
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; }

.primary { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 600; }
.primary:disabled { opacity: .6; }
.link { background: none; border: 0; color: var(--accent); padding: 0; }
.error { color: var(--red); min-height: 1.2em; margin: 0; font-size: .9rem; }
.hint { color: var(--muted); font-size: .9rem; text-align: center; padding: 12px; }

/* ---------- Anmeldeseite ---------- */
.auth-page { display: grid; place-items: center; padding: 16px; }
.auth-card { background: var(--card); width: 100%; max-width: 380px; padding: 32px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.auth-logo { width: 64px; height: 64px; object-fit: contain; border-radius: 14px; margin-bottom: 12px; }
.back-home { display: inline-block; margin-top: 18px; color: var(--muted); font-size: .9rem; }
.auth-card h1 { margin: 0; font-size: 1.7rem; }
.subtitle { color: var(--muted); margin: 4px 0 24px; }
.tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.tab { flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px; color: var(--muted); }
.tab.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
#auth-form { display: flex; flex-direction: column; gap: 14px; }
#auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); }
#auth-form input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); }
#auth-form input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* ---------- Chat ---------- */
.chat-page { display: flex; }
.sidebar { width: 280px; background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; padding: 16px 16px 8px; font-weight: 700; font-size: 1.05rem; }
.brand img { width: 36px; height: 36px; object-fit: contain; border-radius: 9px; }
.me { padding: 8px 16px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .9rem; }
.nav-item { margin: 10px 8px 0; padding: 10px; border: 0; border-radius: 8px; background: none; text-align: left; font-weight: 600; }
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.section-title { padding: 16px 18px 0; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
#search { margin: 8px 12px 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; }
#user-list { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; flex: 1; }
#user-list li { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; cursor: pointer; }
#user-list li:hover { background: var(--bg); }
#user-list li.active { background: var(--accent-soft); }
#user-list li.hint { cursor: default; }
.name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #cbd0d8; flex-shrink: 0; }
.dot.on { background: var(--green); }
.badge { background: var(--accent); color: #fff; font-size: .75rem; border-radius: 999px; padding: 1px 7px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; }
.view { display: flex; flex-direction: column; height: 100%; }
.view[hidden] { display: none; }

/* ---------- Willkommens-Seite ---------- */
.feed-scroll { overflow-y: auto; height: 100%; }
.banner { position: relative; color: #fff; padding: 48px 32px; background: linear-gradient(120deg, var(--accent), var(--accent-2)) center / cover no-repeat; }
.banner::before { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent, rgba(0,0,0,.35)); }
.banner > * { position: relative; }
.banner h2 { margin: 0 0 6px; font-size: 1.8rem; }
.banner p { margin: 0; opacity: .9; }
.banner .back { color: #fff; margin-bottom: 8px; }
.feed { max-width: 640px; margin: 0 auto; padding: 20px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
#post-input { width: 100%; resize: vertical; border: 0; outline: 0; min-height: 60px; }
.post-form-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
#posts { display: flex; flex-direction: column; gap: 14px; }
.post-head { display: flex; align-items: baseline; gap: 10px; }
.post-head .time { color: var(--muted); font-size: .8rem; }
.post-head .delete { margin-left: auto; font-size: .8rem; color: var(--muted); }
.post-head .delete:hover { color: var(--red); }
.post-body { margin: 8px 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dislike { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--card); border-radius: 999px; padding: 4px 12px; }
.dislike:hover { background: var(--bg); }
.dislike.active { background: #fee2e2; border-color: #fca5a5; color: var(--red); font-weight: 600; }
.more { align-self: center; border: 1px solid var(--border); background: var(--card); border-radius: 8px; padding: 8px 14px; }
.chat-header { padding: 16px 20px; background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; font-weight: 600; }
.status { font-weight: 400; font-size: .85rem; color: var(--muted); }
.status.on { color: var(--green); }
.back { display: none; font-size: 1.3rem; }
#messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 70%; padding: 8px 12px; border-radius: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.msg.mine { align-self: flex-end; background: var(--mine); color: #fff; border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: var(--theirs); border-bottom-left-radius: 4px; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg .time { font-size: .7rem; opacity: .7; margin-top: 2px; text-align: right; }
.hint.error { color: var(--red); }
#send-form { display: flex; gap: 8px; padding: 12px; background: var(--card); border-top: 1px solid var(--border); align-items: flex-end; }
#input { flex: 1; resize: none; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; max-height: 140px; }

/* ---------- Handy ---------- */
@media (max-width: 700px) {
  .sidebar { width: 100%; border-right: 0; }
  .main { display: none; }
  body.in-main .sidebar { display: none; }
  body.in-main .main { display: flex; }
  .banner { padding: 24px 20px; }
  .back { display: inline; }
}

/* ---------- Impressum & Datenschutz ---------- */
.legal { max-width: 760px; margin: 0 auto; padding: 40px 24px 80px; line-height: 1.65; }
.legal h1 { margin-top: 20px; }
.legal h2 { font-size: 1.15rem; margin-top: 30px; }
.legal .note { background: #fff7ed; border: 1px solid #fed7aa; padding: 10px 14px; border-radius: 10px; color: #9a3412; }
.legal .back-home { margin-top: 0; }
