/* Team-Chat – ruhige Arbeitsoberfläche, Firmenfarbe als einziger Akzent */
:root {
  --acc: #1f2942;
  --bg: #e9edf1;
  --panel: #ffffff;
  --panel2: #f5f7f9;
  --line: #dde3e9;
  --ink: #162031;
  --muted: #5f6b7a;
  --mine: #dce9fb;
  --them: #ffffff;
  --ok: #1a9b5b;
  --bad: #d23b35;
  --read: #1f8fe0;
  --shadow: 0 1px 1px rgba(22, 32, 49, .08);
  --r: 14px;
  --side: 360px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@supports (color: color-mix(in srgb, red 50%, white)) {
  :root { --mine: color-mix(in srgb, var(--acc) 15%, #ffffff); }
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b; --panel: #171e27; --panel2: #1d2530; --line: #2a3441; --ink: #e7ecf2; --muted: #95a1b0;
    --them: #1f2833; --mine: #1d3552; --shadow: none;
  }
  @supports (color: color-mix(in srgb, red 50%, white)) { :root { --mine: color-mix(in srgb, var(--acc) 40%, #16202b); } }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Grundelemente ---------- */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 10px 16px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { width: 42px; height: 42px; border: 0; background: transparent; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--panel2); color: var(--ink); }
.icon-btn.send { background: var(--acc); color: #fff; }
.icon-btn.send:hover { background: var(--acc); filter: brightness(1.08); }
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 12px; }
label input, label select, label textarea { display: block; width: 100%; margin-top: 5px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-weight: 400; font-size: 15px; color: var(--ink); }
input[type=color] { padding: 3px; height: 44px; }
.av { width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; color: #fff; flex: none; position: relative; letter-spacing: .02em; }
.av.sm { width: 34px; height: 34px; font-size: 13px; }
.av.big { width: 112px; height: 112px; font-size: 40px; }
.av.grp { background: #6b7a8c; }
.av .dot { position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid var(--panel); }
.c0 { background: #2f6fb3; } .c1 { background: #b35a2f; } .c2 { background: #2f8f6e; } .c3 { background: #7a4bb0; }
.c4 { background: #b0405e; } .c5 { background: #4b6b2f; } .c6 { background: #2f7f99; } .c7 { background: #8a6b1f; }
.tc0 { color: #2f6fb3; } .tc1 { color: #b35a2f; } .tc2 { color: #2f8f6e; } .tc3 { color: #7a4bb0; }
.tc4 { color: #b0405e; } .tc5 { color: #5d7f3a; } .tc6 { color: #2f7f99; } .tc7 { color: #8a6b1f; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); background: #1c2533; color: #fff; padding: 11px 16px; border-radius: 10px; z-index: 90; max-width: min(92vw, 460px); box-shadow: 0 6px 24px rgba(0,0,0,.25); }

/* ---------- Anmeldung ---------- */
body[data-view=login] { overflow: auto; }
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--acc); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 18px; padding: 30px 26px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card h1 { margin: 14px 0 2px; font-size: 22px; }
.login-sub { margin: 0 0 22px; color: var(--muted); }
.login-mark, .empty-mark { width: 52px; height: 52px; border-radius: 16px 16px 16px 5px; background: var(--acc); position: relative; }
.login-mark::after, .empty-mark::after { content: ""; position: absolute; left: 13px; right: 13px; top: 18px; height: 3px; border-radius: 2px; background: #fff; box-shadow: 0 8px 0 #fff; opacity: .95; }
.login-err { color: var(--bad); font-weight: 600; margin: 0 0 12px; }
.login-note { color: var(--muted); font-size: 13px; text-align: center; margin: 14px 0 0; }

/* ---------- Aufbau ---------- */
.app { display: flex; height: 100%; height: 100dvh; }
.side { width: var(--side); flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; gap: 6px; padding: calc(10px + var(--safe-t)) 10px 10px 12px; border-top: 4px solid var(--acc); }
.me-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 4px; border-radius: 12px; text-align: left; }
.me-btn:hover { background: var(--panel2); }
.side-title { min-width: 0; display: flex; flex-direction: column; }
.side-title b, .side-title small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-title small { color: var(--muted); }
.side-search { padding: 0 12px 10px; }
.side-search input { width: 100%; border: 0; background: var(--panel2); border-radius: 10px; padding: 10px 12px; }
.hint { margin: 0 12px 10px; padding: 12px; border-radius: 12px; background: var(--panel2); font-size: 14px; }
.hint p { margin: 0 0 8px; }
.list { flex: 1; overflow-y: auto; min-height: 0; padding-bottom: var(--safe-b); }
.list-lbl { padding: 12px 16px 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; width: 100%; border: 0; background: none; padding: 10px 14px; text-align: left; }
.row:hover { background: var(--panel2); }
.row.on { background: var(--panel2); box-shadow: inset 3px 0 0 var(--acc); }
.row-main { flex: 1; min-width: 0; }
.row-top, .row-bot { display: flex; align-items: baseline; gap: 8px; }
.row-top b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 650; }
.row-top time { font-size: 12px; color: var(--muted); flex: none; }
.row-bot span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 14px; }
.row-bot .typing { color: var(--ok); }
.badge { background: var(--acc); color: #fff; font-size: 12px; font-weight: 700; min-width: 21px; height: 21px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; flex: none; }
.badge.muted { background: #9aa5b1; }
.row.unread time { color: var(--acc); font-weight: 700; }
.row .chk { width: 22px; height: 22px; accent-color: var(--acc); }
.empty-list { padding: 30px 20px; color: var(--muted); text-align: center; }

.main { flex: 1; min-width: 0; display: flex; position: relative; }
.empty { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); padding: 24px; }
.empty-in { max-width: 320px; }
.empty-mark { margin: 0 auto 16px; }
.empty h2 { color: var(--ink); margin: 0 0 6px; font-size: 19px; }
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.chat-head { display: flex; align-items: center; gap: 4px; padding: calc(8px + var(--safe-t)) 8px 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.chat-head .back { display: none; }
.chat-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 4px; border-radius: 12px; text-align: left; }
.chat-who span:last-child { min-width: 0; display: flex; flex-direction: column; }
.chat-who b, .chat-who small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-who small { color: var(--muted); font-size: 13px; }
.chat-who small.live { color: var(--ok); }

/* ---------- Nachrichten ---------- */
.msgs { flex: 1; overflow-y: auto; min-height: 0; padding: 12px clamp(10px, 4vw, 48px) 8px; overscroll-behavior: contain; }
.msgs-in { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; }
.more { align-self: center; margin: 6px 0 12px; }
.day { align-self: center; margin: 12px 0 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--panel); padding: 4px 12px; border-radius: 9px; box-shadow: var(--shadow); }
.sys { align-self: center; text-align: center; margin: 6px 0; font-size: 13px; color: var(--muted); max-width: 90%; }
.sys.call { display: inline-flex; gap: 6px; align-items: center; background: var(--panel); padding: 6px 12px; border-radius: 10px; box-shadow: var(--shadow); color: var(--ink); }
.sys.call.missed { color: var(--bad); }
.sys.call svg { width: 17px; height: 17px; }
.m { display: flex; margin: 1px 0; }
.m.first { margin-top: 7px; }
.m.me { justify-content: flex-end; }
.bub { position: relative; max-width: min(78%, 560px); background: var(--them); border-radius: var(--r); padding: 6px 9px 6px 10px; box-shadow: var(--shadow); min-width: 64px; overflow-wrap: anywhere; }
.m.me .bub { background: var(--mine); }
.m.first.them .bub { border-top-left-radius: 4px; }
.m.first.me .bub { border-top-right-radius: 4px; }
.m.hl .bub { outline: 2px solid var(--acc); }
.who { font-size: 13px; font-weight: 700; margin-bottom: 1px; }
.tx { white-space: pre-wrap; }
.tx a { color: var(--read); }
.tx.big { font-size: 34px; line-height: 1.15; }
.meta { float: right; margin: 6px 0 -4px 10px; font-size: 11.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; line-height: 1; position: relative; top: 2px; }
.meta svg { width: 16px; height: 16px; }
.meta .read { color: var(--read); }
.bub.media { padding: 3px; }
.bub.media .meta { position: absolute; right: 8px; bottom: 7px; float: none; margin: 0; background: rgba(0,0,0,.45); color: #fff; padding: 3px 6px; border-radius: 8px; top: auto; }
.bub.media .meta .read { color: #9fd3ff; }
.bub.media .who, .bub.media .rq { margin: 4px 6px; }
.img { display: block; max-width: 100%; width: 330px; max-height: 420px; object-fit: cover; border-radius: 11px; cursor: zoom-in; background: var(--panel2); min-height: 120px; }
.vid { display: block; max-width: 100%; width: 330px; max-height: 420px; border-radius: 11px; background: #000; }
.aud { display: flex; align-items: center; gap: 8px; min-width: 230px; }
.aud audio { width: 100%; height: 38px; min-width: 200px; }
.fc { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; background: rgba(0,0,0,.05); border-radius: 10px; padding: 10px; min-width: 220px; }
.fc svg { width: 30px; height: 30px; color: var(--acc); }
.fc span { min-width: 0; display: flex; flex-direction: column; }
.fc b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.fc small { color: var(--muted); }
.deleted { color: var(--muted); font-style: italic; }
.rq { border-left: 3px solid var(--acc); background: rgba(0,0,0,.05); border-radius: 7px; padding: 5px 8px; margin: 2px 0 5px; font-size: 13.5px; cursor: pointer; display: flex; flex-direction: column; min-width: 0; }
.rq b { font-size: 13px; }
.rq span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mact { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--panel2); color: var(--muted); display: none; align-items: center; justify-content: center; padding: 0; }
.mact svg { width: 18px; height: 18px; }
@media (hover: hover) { .bub:hover .mact { display: inline-flex; } }
.pending .bub { opacity: .75; }
.prog { height: 4px; border-radius: 2px; background: var(--line); margin-top: 6px; overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: var(--acc); transition: width .2s; }
.to-bottom { position: absolute; right: 18px; bottom: calc(76px + var(--safe-b)); width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.to-bottom .badge { position: absolute; top: -6px; right: -4px; }
.dropzone { position: absolute; inset: 64px 12px 72px; border: 3px dashed var(--acc); border-radius: 16px; background: rgba(255,255,255,.85); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; color: var(--acc); z-index: 5; pointer-events: none; }

.replybar { display: flex; align-items: center; gap: 6px; padding: 6px 8px 0 12px; background: var(--panel); border-top: 1px solid var(--line); }
.replybar .rq { flex: 1; margin: 0; }
.composer, .recbar { display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px calc(8px + var(--safe-b)); background: var(--panel); border-top: 1px solid var(--line); }
.replybar:not([hidden]) + .composer { border-top: 0; }
.composer textarea { flex: 1; resize: none; border: 0; background: var(--panel2); border-radius: 21px; padding: 10px 14px; max-height: 160px; min-height: 42px; line-height: 1.4; outline-offset: 0; }
.recbar { align-items: center; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); margin-left: 6px; animation: blink 1s infinite; }
#recTime { font-variant-numeric: tabular-nums; font-weight: 700; }
.rec-lbl { flex: 1; color: var(--muted); }
@keyframes blink { 50% { opacity: .25; } }
.menu { position: absolute; left: 10px; bottom: calc(62px + var(--safe-b)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.16); padding: 6px; z-index: 20; display: flex; flex-direction: column; min-width: 200px; }
.menu button { border: 0; background: none; text-align: left; padding: 11px 14px; border-radius: 9px; display: flex; gap: 10px; align-items: center; }
.menu button:hover { background: var(--panel2); }
.menu button.danger { color: var(--bad); }
.menu.float { position: fixed; bottom: auto; left: auto; z-index: 60; }

/* ---------- Dialog ---------- */
.sheet-wrap { position: fixed; inset: 0; background: rgba(12, 18, 28, .45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet { width: 100%; max-width: 460px; max-height: min(88vh, 760px); background: var(--panel); border-radius: 18px; display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.sheet.wide { max-width: 760px; }
.sheet header { display: flex; align-items: center; padding: 12px 8px 8px 20px; }
.sheet h2 { flex: 1; font-size: 18px; margin: 0; }
.sheet-body { overflow-y: auto; padding: 4px 20px 20px; }
.sheet-body .row { padding: 9px 4px; }
.sheet-body h3 { font-size: 14px; color: var(--muted); margin: 18px 0 8px; }
.sheet-body .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sheet-body .note { color: var(--muted); font-size: 13.5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 8px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 14px; }
.tabs button { border: 1px solid var(--line); background: var(--panel); border-radius: 20px; padding: 7px 14px; font-weight: 600; }
.tabs button.on { background: var(--acc); border-color: var(--acc); color: #fff; }
.utable { width: 100%; border-collapse: collapse; font-size: 14px; }
.utable td, .utable th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.utable th { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.utable tr.off td { color: var(--muted); text-decoration: line-through; }
.utable button { border: 0; background: none; color: var(--acc); font-weight: 600; padding: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-weight: 500; font-size: 15px; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--acc); }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--panel2); color: var(--muted); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

/* ---------- Anruf ---------- */
.callv { position: fixed; inset: 0; z-index: 70; background: #0c121b; color: #fff; display: flex; flex-direction: column; }
.call-top { padding: calc(16px + var(--safe-t)) 20px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; z-index: 2; }
.call-top b { font-size: 19px; }
.call-top span { opacity: .75; font-variant-numeric: tabular-nums; }
.tiles { flex: 1; min-height: 0; display: grid; gap: 8px; padding: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); grid-auto-rows: 1fr; }
.tile { position: relative; background: #18212d; border-radius: 16px; overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 160px; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile.nocam video { opacity: 0; }
.tile .av { position: relative; z-index: 1; }
.tile:not(.nocam) .av { display: none; }
.tile .tname { position: absolute; left: 10px; bottom: 10px; z-index: 2; background: rgba(0,0,0,.45); padding: 3px 9px; border-radius: 8px; font-size: 13px; display: flex; gap: 6px; align-items: center; }
.tile .tname svg { width: 15px; height: 15px; }
.tiles.one .tile { border-radius: 0; }
.tiles.one { padding: 0; }
.selfv { position: absolute; right: 14px; top: calc(80px + var(--safe-t)); width: min(28vw, 180px); aspect-ratio: 3/4; object-fit: cover; border-radius: 14px; z-index: 3; background: #222; box-shadow: 0 6px 20px rgba(0,0,0,.4); transform: scaleX(-1); }
.selfv.env { transform: none; }
.call-bar { display: flex; justify-content: center; gap: 18px; padding: 16px 16px calc(22px + var(--safe-b)); z-index: 2; }
.cbtn { width: 60px; height: 60px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.cbtn svg { width: 26px; height: 26px; }
.cbtn.off { background: #fff; color: #0c121b; }
.cbtn.end { background: var(--bad); }
.cbtn.end svg { transform: rotate(135deg); }
.cbtn.ok { background: var(--ok); }

/* Eingehender Anruf: das einzige laute Element der Oberfläche */
.incoming { position: fixed; inset: 0; z-index: 80; background: var(--acc); color: #fff; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.inc-in { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.inc-in b { font-size: 26px; margin-top: 18px; }
.inc-in #incKind { opacity: .85; }
.inc-in .av.big { box-shadow: 0 0 0 0 rgba(255,255,255,.5); animation: ringpulse 1.6s infinite; border: 3px solid rgba(255,255,255,.9); }
.inc-bar { display: flex; gap: 28px; margin-top: 56px; }
.inc-bar .cbtn { width: 70px; height: 70px; }
@keyframes ringpulse { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.45); } 100% { box-shadow: 0 0 0 34px rgba(255,255,255,0); } }
@media (prefers-reduced-motion: reduce) { .inc-in .av.big, .rec-dot { animation: none; } }

.lightbox { position: fixed; inset: 0; z-index: 75; background: rgba(5,8,12,.94); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: calc(100% - 80px); object-fit: contain; border-radius: 6px; }
.lb-bar { display: flex; gap: 10px; margin-top: 14px; padding-bottom: var(--safe-b); }

/* ---------- Handy ---------- */
@media (max-width: 820px) {
  .side { width: 100%; border-right: 0; }
  .main { position: fixed; inset: 0; z-index: 10; background: var(--bg); transform: translateX(100%); transition: transform .22s ease; }
  .app.show-chat .main { transform: none; }
  .app:not(.show-chat) .main .chat { visibility: hidden; }
  .chat-head .back { display: inline-flex; }
  .empty { display: none; }
  .bub { max-width: 86%; }
  .sheet-wrap { align-items: flex-end; padding: 0; }
  .sheet { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: var(--safe-b); }
  .grid2 { grid-template-columns: 1fr; }
  .composer textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { .main { transition: none; } }
