/* OpenChat — Styles (Light/Dark, beerige Farbwelt) */
:root, [data-theme="light"] {
  --color-primary: #c2255c; --color-primary-dark: #a61e4d; --color-primary-contrast: #ffffff;
  --color-bg: #faf7f8; --color-surface: #ffffff; --color-text: #2b242a; --color-text-muted: #8a7f88;
  --color-border: #e9e2e6; --color-accent-soft: #f8e1ec; --color-accent-softer: #fdeef3; --color-accent-border: #f1b8cd;
  --color-success: #2f9e44; --color-warning: #f08c00; --color-danger: #e03131; --color-badge: #c2255c;
  --color-on-online-halo: #d3f0da; --color-on-grace-halo: #ffe9b8; --color-on-off-halo: #ffd0d0;
  --color-tooltip-bg: #332d33; --color-tooltip-text: #f4eef2; --color-toast-bg: #332d33;
  --color-banner-bg: #fff4d6; --color-banner-text: #8a5a00; --color-banner-border: #ffe08a;
  --color-notice-bg: #fff0f0; --color-notice-border: #ffc9c9; --color-notice-text: #c92a2a;
  --color-info-bg: #e9f3ff; --color-info-border: #a9d0ff;
  --shadow-sm: 0 1px 3px rgba(60,30,45,.07); --shadow-md: 0 6px 20px rgba(60,30,45,.12); --overlay: rgba(30,20,28,.5);
}
[data-theme="dark"] {
  --color-primary: #f783ac; --color-primary-dark: #e64980; --color-primary-contrast: #241219;
  --color-bg: #141118; --color-surface: #1e1924; --color-text: #efe9ef; --color-text-muted: #a89eaa;
  --color-border: #342b3a; --color-accent-soft: #3a2430; --color-accent-softer: #2a1b25; --color-accent-border: #5c3049;
  --color-success: #51cf66; --color-warning: #ffd43b; --color-danger: #ff6b6b; --color-badge: #f783ac;
  --color-on-online-halo: rgba(81,207,102,.18); --color-on-grace-halo: rgba(255,212,59,.18); --color-on-off-halo: rgba(255,107,107,.18);
  --color-tooltip-bg: #efe9ef; --color-tooltip-text: #241d29; --color-toast-bg: #2c2431;
  --color-banner-bg: #3a2f14; --color-banner-text: #ffd97a; --color-banner-border: #6b541f;
  --color-notice-bg: #33191d; --color-notice-border: #6e2a30; --color-notice-text: #ff9b9b;
  --color-info-bg: #16222e; --color-info-border: #2c4a63;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4); --shadow-md: 0 8px 24px rgba(0,0,0,.5); --overlay: rgba(0,0,0,.6);
}
:root { --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; --font-size-base: 16px; --radius: 8px; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font-family-base); font-size: var(--font-size-base); background: var(--color-bg); color: var(--color-text); line-height: 1.5; transition: background .25s, color .25s; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
::placeholder { color: var(--color-text-muted); opacity: .8; }
a { color: var(--color-primary); }

.demo-banner { background: var(--color-banner-bg); color: var(--color-banner-text); border-bottom: 1px solid var(--color-banner-border); text-align: center; padding: 6px 12px; font-size: .85rem; }

.topbar { position: sticky; top: 0; z-index: 50; background: var(--color-surface); border-bottom: 1px solid var(--color-border); box-shadow: var(--shadow-sm); }
.topbar-inner { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 60px; }
.logo { font-weight: 700; font-size: 1.25rem; color: var(--color-primary); letter-spacing: -.5px; }
.logo span { color: var(--color-text); font-weight: 400; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav-btn { position: relative; background: none; border: none; padding: 8px 14px; border-radius: var(--radius); font-size: .95rem; color: var(--color-text); transition: background .15s; }
.nav-btn:hover { background: var(--color-bg); }
.nav-btn.active { background: var(--color-accent-soft); color: var(--color-primary); font-weight: 600; }
.badge { position: absolute; top: 2px; right: 4px; background: var(--color-badge); color: #fff; font-size: .7rem; font-weight: 700; min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; text-align: center; padding: 0 4px; }
.badge.hidden { display: none; }

.theme-toggle { background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text); border-radius: 999px; padding: 7px 14px; font-size: .85rem; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; transition: background .15s, border-color .15s; }
.theme-toggle:hover { border-color: var(--color-primary); }
.theme-toggle .ico { font-size: 1rem; line-height: 1; }

.container { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }
.screen { display: none; }
.screen.visible { display: block; }
h1 { font-size: 1.6rem; margin-bottom: 4px; }
h2 { font-size: 1.15rem; margin-bottom: 12px; }
.sub { color: var(--color-text-muted); margin-bottom: 24px; }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 28px; }
.login-wrap { max-width: 520px; margin: 40px auto; }
.login-tabs { display: flex; gap: 0; margin-bottom: 24px; border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; }
.login-tabs button { flex: 1; padding: 12px; border: none; background: var(--color-bg); font-size: .95rem; color: var(--color-text-muted); }
.login-tabs button.active { background: var(--color-surface); color: var(--color-primary); font-weight: 600; }
.field { margin-bottom: 16px; position: relative; }
.field label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 5px; }
.field label .opt { font-weight: 400; color: var(--color-text-muted); }
.field input[type=text], .field input[type=password], .field input[type=email], .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); color: var(--color-text); }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--color-accent-border); border-color: var(--color-primary); }
.field .hint { font-size: .78rem; color: var(--color-text-muted); margin-top: 4px; }
.field .error { font-size: .82rem; color: var(--color-danger); margin-top: 4px; display: none; }
.field.invalid input, .field.invalid select { border-color: var(--color-danger); }
.field.invalid .error { display: block; }
.radio-row, .check-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.radio-row label, .check-row label { display: flex; gap: 6px; align-items: center; font-weight: 400; font-size: .95rem; }
input[type=radio], input[type=checkbox] { accent-color: var(--color-primary); }

.btn { display: inline-block; border: none; border-radius: var(--radius); padding: 11px 20px; font-size: .95rem; font-weight: 600; background: var(--color-primary); color: var(--color-primary-contrast); transition: background .15s; }
.btn:hover { background: var(--color-primary-dark); }
.btn:disabled { background: var(--color-border); color: var(--color-text-muted); cursor: not-allowed; }
.btn.secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn.secondary:hover { background: var(--color-bg); }
.btn.danger { background: var(--color-danger); }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.link { color: var(--color-primary); background: none; border: none; font-size: .88rem; text-decoration: underline; padding: 0; }

.ac-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow-md); max-height: 220px; overflow-y: auto; }
.ac-item { padding: 9px 12px; cursor: pointer; font-size: .92rem; }
.ac-item:hover { background: var(--color-accent-soft); }
.ac-item .cc { color: var(--color-text-muted); font-size: .78rem; }

.segment { display: inline-flex; border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; background: var(--color-surface); }
.segment button { padding: 8px 18px; border: none; background: var(--color-surface); font-size: .9rem; color: var(--color-text-muted); }
.segment button.active { background: var(--color-primary); color: var(--color-primary-contrast); font-weight: 600; }

.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0 20px; }
.filter-bar .field { margin-bottom: 0; min-width: 140px; flex: 1; }
.filter-bar label { font-size: .76rem; }
.filter-toggle { background: none; border: none; color: var(--color-primary); font-size: .9rem; font-weight: 600; padding: 6px 0; display: inline-flex; align-items: center; gap: 6px; }
.filter-toggle:hover { text-decoration: underline; }
.legend-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 4px 0 14px; font-size: .82rem; color: var(--color-text-muted); }

.chatter-list { display: flex; flex-direction: column; gap: 8px; }
.chatter-row { display: flex; align-items: center; gap: 12px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px 16px; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.chatter-row:hover { box-shadow: var(--shadow-md); border-color: var(--color-accent-border); }
.chatter-main { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; flex-wrap: nowrap; }
.chatter-nick { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatter-meta { color: var(--color-text-muted); font-size: .85rem; white-space: nowrap; }
.chatter-gender { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--color-bg); color: var(--color-text-muted); flex-shrink: 0; }

.ampel { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--color-text-muted); }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.online { background: var(--color-success); box-shadow: 0 0 0 3px var(--color-on-online-halo); }
.dot.grace { background: var(--color-warning); box-shadow: 0 0 0 3px var(--color-on-grace-halo); }
.dot.offline { background: var(--color-danger); box-shadow: 0 0 0 3px var(--color-on-off-halo); }

.tt-btn { background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text-muted); border-radius: 50%; width: 20px; height: 20px; font-size: .72rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; margin-left: 7px; vertical-align: 2px; }
.tt-btn:hover, .tt-btn.active { background: var(--color-primary); color: var(--color-primary-contrast); border-color: var(--color-primary); }

.tooltip { position: absolute; z-index: 100; background: var(--color-tooltip-bg); color: var(--color-tooltip-text); padding: 10px 14px; border-radius: var(--radius); font-size: .85rem; max-width: 280px; line-height: 1.4; box-shadow: var(--shadow-md); }
.tooltip .tt-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; opacity: .7; margin-bottom: 4px; }

.conv-row { position: relative; display: flex; align-items: center; gap: 14px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 14px 18px; cursor: pointer; }
/* Herz oben rechts in der Ecke des Kastens, unabhaengig vom Flex-Inhalt.
   Weiss/Kontur = kein Herz gesetzt, rot/gefuellt = von MIR gesetzt -- sagt
   nichts darueber aus, ob der andere ebenfalls geherzt hat (siehe inc/friends.php). */
.conv-heart { position: absolute; top: 8px; right: 10px; font-size: 1.05rem; line-height: 1; cursor: pointer; user-select: none; opacity: .55; transition: opacity .15s, transform .1s; }
.conv-heart:hover { opacity: 1; transform: scale(1.15); }
.conv-heart.liked { opacity: 1; }
.conv-row:hover { box-shadow: var(--shadow-md); border-color: var(--color-accent-border); }
.conv-row.unread { border-left: 4px solid var(--color-primary); }
/* Gleiches Prinzip wie .unread (links, Akzentfarbe, "Aktion noetig"), aber
   rechts und in der gedeckten Muted-Farbe: "der andere hat's noch nicht
   gelesen" ist reine Info, kein Handlungsbedarf -- siehe .sent-pending-dot. */
.conv-row.sent-pending { border-right: 4px solid var(--color-text-muted); }
.conv-body { flex: 1; min-width: 0; }
.conv-nick { font-weight: 600; }
.conv-nick .unread-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--color-primary); margin-left: 7px; }
.conv-last { color: var(--color-text-muted); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { color: var(--color-text-muted); font-size: .8rem; white-space: nowrap; display: flex; align-items: center; }
/* Kontur statt Fuellung + gedeckte statt Akzentfarbe: bewusst anders als
   .unread-dot, damit "der andere hat noch nicht gelesen" (Info) nicht mit
   "du hast was Neues" (Aktion noetig) verwechselt wird. */
.sent-pending-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--color-text-muted); box-sizing: border-box; }
.offline-tag { font-size: .74rem; font-weight: 600; color: var(--color-notice-text); background: var(--color-notice-bg); border: 1px solid var(--color-notice-border); border-radius: 10px; padding: 2px 8px; }

.chat-head { display: flex; align-items: center; gap: 12px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 14px; }
.chat-head .who { flex: 1; }
.chat-head .nick { font-weight: 700; font-size: 1.05rem; }
.back-link { background: none; border: none; color: var(--color-text-muted); font-size: 1.2rem; padding: 4px 8px; }
.back-link:hover { color: var(--color-primary); }
.chat-notice { background: var(--color-notice-bg); border: 1px solid var(--color-notice-border); color: var(--color-notice-text); border-radius: var(--radius); padding: 10px 16px; font-size: .88rem; margin-bottom: 14px; }
.composer { display: flex; gap: 10px; align-items: center; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.composer input[type=text] { flex: 1; border: none; outline: none; font-size: .95rem; background: transparent; color: var(--color-text); }
.composer.disabled { background: var(--color-bg); }
.composer.disabled input { color: var(--color-text-muted); }
.icon-btn { background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text); border-radius: var(--radius); width: 38px; height: 38px; font-size: 1.05rem; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--color-accent-soft); border-color: var(--color-accent-border); }
.msg-list { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 62%; }
.msg.mine { align-self: flex-end; }
.msg .bubble { padding: 10px 14px; border-radius: 14px; font-size: .94rem; background: var(--color-surface); border: 1px solid var(--color-border); }
.msg.mine .bubble { background: var(--color-accent-soft); border-color: var(--color-accent-border); }
.msg .meta { font-size: .72rem; color: var(--color-text-muted); margin-top: 3px; padding: 0 6px; }
.msg.mine .meta { text-align: right; }
.msg .bubble img { max-width: 260px; border-radius: var(--radius); display: block; }
.msg .filtered-note { font-size: .72rem; color: var(--color-warning); margin-top: 3px; padding: 0 6px; }
/* System-Ereignis (Freundschaft geschlossen, Freund online) -- bewusst
   neutral/zentriert statt als Sprechblase einer Seite, sonst wirkt "X ist
   jetzt online" wie eine echte, von jemandem getippte Nachricht. */
.msg.system { max-width: 100%; align-self: center; text-align: center; }
.msg.system .bubble { display: inline-block; background: transparent; border: none; color: var(--color-text-muted); font-size: .82rem; padding: 2px 10px; }

.faq-item { border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); margin-bottom: 10px; overflow: hidden; }
.faq-q { width: 100%; text-align: left; background: none; border: none; color: var(--color-text); padding: 14px 18px; font-size: .95rem; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.faq-q:hover { color: var(--color-primary); }
.faq-a { display: none; padding: 0 18px 14px; color: var(--color-text-muted); font-size: .9rem; }
.faq-item.open .faq-a { display: block; }
.faq-item.open .faq-q { color: var(--color-primary); }

.modal-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 200; display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-md); width: 420px; max-width: 92vw; padding: 26px; }
.modal h3 { margin-bottom: 14px; font-size: 1.1rem; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.modal .radio-col { display: flex; flex-direction: column; gap: 10px; }
.modal .radio-col label { display: flex; gap: 8px; align-items: center; font-size: .95rem; }

.toast { position: fixed; bottom: 28px; right: 28px; z-index: 300; background: var(--color-toast-bg); color: var(--color-tooltip-text); padding: 13px 20px; border-radius: var(--radius); box-shadow: var(--shadow-md); font-size: .9rem; opacity: 0; transform: translateY(12px); transition: opacity .25s, transform .25s; pointer-events: none; max-width: 340px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--color-success); color: #10210f; }
.toast.error { background: var(--color-danger); color: #2a0f0f; }
[data-theme="dark"] .toast.success, [data-theme="dark"] .toast.error { color: #141118; }

.empty { text-align: center; color: var(--color-text-muted); padding: 48px 20px; background: var(--color-surface); border: 1px dashed var(--color-border); border-radius: var(--radius); }
.info-note { font-size: .82rem; color: var(--color-text-muted); background: var(--color-info-bg); border: 1px solid var(--color-info-border); border-radius: var(--radius); padding: 9px 14px; margin-bottom: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }

/* Versions-Anzeige (dezent, unten rechts) */
.version-tag { position: fixed; right: 12px; bottom: 10px; z-index: 60; font-size: .72rem; color: var(--color-text-muted); opacity: .8; pointer-events: none; }
@media (max-width: 860px) { .version-tag { bottom: 76px; } } /* über Bottom-Nav */

/* ==================== Topbar (fixiert) + Burger-Menü ==================== */
.topbar { position: sticky; top: 0; z-index: 120; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-badge { position: static; }

/* View-Toggle (Chatter ↔ Nachrichten) */
.view-toggle {
  background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text);
  border-radius: var(--radius); width: 40px; height: 40px; font-size: 1.1rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s;
}
.view-toggle:hover { border-color: var(--color-primary); background: var(--color-accent-soft); }

/* Klickbarer Ungelesen-Badge in der Topbar */
.badge-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--color-accent-soft); border: 1px solid var(--color-accent-border);
  color: var(--color-primary); border-radius: 999px; padding: 7px 12px;
  font-size: .9rem; font-weight: 600;
}
.badge-btn:hover { border-color: var(--color-primary); }
.badge-btn .badge { position: static; }

/* Burger-Button */
.burger {
  display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
  width: 44px; height: 44px; padding: 10px;
  background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius);
}
.burger span { display: block; height: 2px; width: 100%; background: var(--color-text); border-radius: 2px; transition: transform .2s, opacity .2s; }
.burger:hover { border-color: var(--color-primary); }
.burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Menü-Panel (Dropdown unter Topbar, fixiert) */
.menu-panel {
  position: fixed; top: 60px; right: 12px; z-index: 115;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 12px; box-shadow: var(--shadow-md);
  min-width: 240px; overflow: hidden;
  display: none;
}
.menu-panel.open { display: block; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; padding: 14px 18px; font-size: .97rem; color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}
.menu-item:last-child { border-bottom: none; }
.menu-item:hover, .menu-item.active { background: var(--color-accent-soft); color: var(--color-primary); }
.menu-item.accent { color: var(--color-primary); font-weight: 600; }
.menu-item.danger { color: var(--color-danger); }
.menu-badge { position: static; margin-left: auto; }

@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
  .msg { max-width: 85%; }
  .topbar-inner { gap: 10px; padding: 0 12px; }
  .menu-panel { left: 12px; right: 12px; min-width: 0; top: 64px; }
}
