:root {
  --bordeaux: #7A2A3C;
  --cream: #F8F2EE;
  --blush: #F5E5E4;
  --line: #EADCD8;
  --text: #1A1A1A;
  --body: #6B6460;
  --meta: #A2948D;
  --bg: #ffffff;
  --panel: #ffffff;
  --bubble-op: #7A2A3C;
  --bubble-c: #ffffff;
  --green: #2FA86B;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --cream: #1d1a19;
    --blush: #3a2a2d;
    --line: #3a3230;
    --text: #f2ecea;
    --body: #c7bcb8;
    --meta: #8f837e;
    --bg: #141212;
    --panel: #1a1717;
    --bubble-op: #8e3a4e;
    --bubble-c: #2a2525;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

/* Login */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; background: var(--cream); padding: 24px; }
.login form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.logo { width: 64px; height: 64px; margin: 0 auto; border-radius: 18px; background: var(--bordeaux); color: #fff; font-size: 30px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.login h1 { font-size: 20px; margin: 4px 0 8px; }
.login input { font: inherit; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.login button { padding: 12px; border-radius: 12px; border: 0; background: var(--bordeaux); color: #fff; font-weight: 600; }
.err { color: #c0392b; min-height: 1.4em; margin: 0; font-size: 14px; }

/* Layout */
.app { display: flex; height: 100dvh; }
.side { width: 360px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--panel); min-height: 0; }
.chat { flex: 1; display: flex; flex-direction: column; background: var(--cream); min-width: 0; min-height: 0; }
@media (max-width: 799px) {
  .side { width: 100%; border-right: 0; }
  .chat { display: none; }
  .app.in-chat .side { display: none; }
  .app.in-chat .chat { display: flex; }
}
@media (min-width: 800px) { .back { display: none; } }

.bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  min-height: 56px;
}
.brand { font-weight: 700; font-size: 18px; flex: 1; }
.icon { background: none; border: 0; color: var(--text); font-size: 22px; width: 38px; height: 38px; border-radius: 10px; line-height: 1; }
.icon:hover { background: var(--blush); }

/* Online-Schalter */
.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track { width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; transition: background .15s; }
.knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track .knob { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--bordeaux); outline-offset: 2px; }
.lbl { font-size: 14px; font-weight: 600; min-width: 48px; }

.menu { border-bottom: 1px solid var(--line); padding: 6px 14px; background: var(--cream); }
.mrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; font-size: 14px; }
.mrow + .mrow { border-top: 1px solid var(--line); }
.mrow button { border: 1px solid var(--bordeaux); background: var(--bordeaux); color: #fff; border-radius: 10px; padding: 6px 12px; font-size: 14px; flex: none; }
.mrow button.ghost { background: none; color: var(--bordeaux); }
.mrow button:disabled { opacity: .5; }
.sub { color: var(--body); font-size: 13px; }
.hint { margin: 10px 14px 0; padding: 10px 12px; border-radius: 10px; background: var(--blush); font-size: 13.5px; }
.status { margin: 10px 14px 0; font-size: 13px; color: var(--body); }
.status.bad { color: #c0392b; }

/* Liste */
.convs { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.convs li { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: flex-start; }
.convs li:hover { background: var(--cream); }
.convs li.active { background: var(--blush); }
.ava { position: relative; width: 42px; height: 42px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 16px; }
.ava.bundle { background: #7A2A3C; } .ava.advent { background: #2F6B4F; } .ava.product { background: #3E4C8A; }
.live { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--green); border: 2px solid var(--panel); }
.ci { flex: 1; min-width: 0; }
.cl1 { display: flex; gap: 8px; align-items: baseline; }
.cn { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct { font-size: 12px; color: var(--meta); flex: none; }
.cl2 { display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.cp { flex: 1; min-width: 0; color: var(--body); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread .cn, .unread .cp { color: var(--text); font-weight: 650; }
.cnt { background: var(--bordeaux); color: #fff; border-radius: 10px; min-width: 20px; height: 20px; font-size: 12px; font-weight: 700; padding: 0 6px; line-height: 20px; text-align: center; flex: none; }
.tag { font-size: 11px; color: var(--meta); margin-top: 2px; }
.empty { color: var(--body); padding: 24px 18px; font-size: 14px; }

/* Chat */
.placeholder { margin: auto; color: var(--meta); }
.chead { background: var(--panel); }
.who { flex: 1; min-width: 0; }
.wname { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wsub { font-size: 12.5px; color: var(--body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wsub a { color: inherit; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 6px; }
.m { max-width: 78%; padding: 9px 12px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.m a { color: inherit; }
.m.c { align-self: flex-start; background: var(--bubble-c); border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.m.op { align-self: flex-end; background: var(--bubble-op); color: #fff; border-bottom-right-radius: 4px; }
.mt { font-size: 11px; color: var(--meta); margin: 0 4px 6px; }
.mt.c { align-self: flex-start; } .mt.op { align-self: flex-end; }
.day { align-self: center; font-size: 12px; color: var(--meta); margin: 10px 0 4px; }
.composer { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); align-items: flex-end; }
.composer textarea { flex: 1; font: inherit; resize: none; border: 1px solid var(--line); border-radius: 18px; padding: 9px 14px; max-height: 160px; background: var(--bg); color: var(--text); outline: 0; }
.composer textarea:focus { border-color: var(--bordeaux); }
.composer button { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--bordeaux); color: #fff; font-size: 17px; flex: none; }
.composer button:disabled { opacity: .4; }
.composer .att { background: transparent; color: var(--text); border: 1px solid var(--line); font-size: 18px; cursor: pointer; }
.m.pic { padding: 4px; }
.m.pic .cap { padding: 5px 8px 4px; }
.m img { display: block; max-width: 100%; max-height: 320px; min-width: 48px; min-height: 48px; border-radius: 12px; background: rgba(0,0,0,.06); cursor: zoom-in; }
.msgs.drop { outline: 2px dashed var(--bordeaux); outline-offset: -8px; }
.preview { position: relative; align-self: flex-start; margin: 10px 12px 0; }
.preview[hidden] { display: none; }
.preview img { display: block; max-height: 140px; max-width: 260px; border-radius: 12px; border: 1px solid var(--line); }
.preview.busy img { opacity: .5; }
.preview button { position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); font-size: 16px; line-height: 26px; padding: 0; cursor: pointer; }
.upl { align-self: center; font-size: 12px; color: var(--meta); }
.upl.err { color: #D82C0D; }
