/* The World of Matrix – Design
   Alle Farben hängen an wenigen Variablen, die der Nutzer selbst wählt:
   --bg (Hintergrund) und --acc (Leuchtfarbe). */

:root {
  --bg: #050807;
  --acc: #00ff9c;
  --acc-rgb: 0, 255, 156;
  --fg: #e6efe9;
  --fg-rgb: 230, 239, 233;
  --muted: rgba(var(--fg-rgb), .55);
  --panel: rgba(var(--fg-rgb), .045);
  --panel-2: rgba(var(--fg-rgb), .08);
  --line: rgba(var(--acc-rgb), .22);
  --line-soft: rgba(var(--fg-rgb), .08);
  --bubble-me: rgba(var(--acc-rgb), .16);
  --bubble-other: rgba(var(--fg-rgb), .07);
  --on-acc: #03140c;
  --danger: #ff5a6e;
  --radius: 18px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
  --dim: .55;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { font-size: 16px; }
html.f-l { font-size: 18.5px; }
html.f-xl { font-size: 21px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.4;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.ic { width: 1.4rem; height: 1.4rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 1.05rem; height: 1.05rem; vertical-align: -3px; }

/* ---------- Hintergrund: Farbe, eigenes Bild, Matrix-Regen ---------- */
#backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 0; pointer-events: none; }
#bgimg { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background-size: cover; background-position: center; opacity: 0; transition: opacity .4s; }
#bgimg.on { opacity: 1; }
#bgimg::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: var(--bg); opacity: var(--dim); }
#rain { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; }

.screen { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1; display: flex; }
.screen.center { align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.screen.overlay { z-index: 5; flex-direction: column; background: var(--bg); }

/* ---------- Karten & Glas ---------- */
.card {
  background: rgba(var(--bg-rgb, 5, 8, 7), .72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25), 0 20px 60px rgba(0,0,0,.45), inset 0 1px 0 rgba(var(--fg-rgb), .04);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .card { -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
}

/* ---------- Logo ---------- */
.logo {
  position: relative; width: 104px; height: 104px; margin: 6px auto 18px;
  border-radius: 26px; border: 2px solid var(--acc); overflow: hidden;
  background: rgba(0,0,0,.55);
  box-shadow: 0 0 22px rgba(var(--acc-rgb), .45), inset 0 0 18px rgba(var(--acc-rgb), .18);
  display: flex; align-items: center; justify-content: center;
}
.logo canvas { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; }
.logo span {
  position: relative; font-family: var(--font); font-weight: 900; font-size: 70px; line-height: 1; transform: scaleX(.86);
  color: var(--acc); text-shadow: 0 0 14px rgba(var(--acc-rgb), .8), 0 0 2px #000;
}
.logo.rain-m span { visibility: hidden; } /* das M malt hier der Regen selbst (rain.js) */
.logo.rain-m { width: 120px; height: 120px; }
.logo.rain-m span { font-size: 100px; }
.logo.small { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 12px; }
.logo.small span { font-size: 38px; }

.brand { margin: 0; text-align: center; font-weight: 800; font-size: 1.75rem; letter-spacing: .01em; color: var(--acc); text-shadow: 0 0 18px rgba(var(--acc-rgb), .35); }
.sub { margin: 4px 0 24px; text-align: center; color: var(--muted); letter-spacing: .08em; font-size: .95rem; }
.hint { color: var(--muted); text-align: center; margin: 8px 0; }
.hint b { color: var(--fg); }

.login-card { width: 100%; max-width: 400px; padding: 28px 24px 22px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

/* ---------- Eingabefelder & Knöpfe ---------- */
.field { position: relative; display: flex; align-items: center; }
.field input {
  width: 100%; padding: 15px 48px 15px 16px; border-radius: 14px;
  background: rgba(0,0,0,.45); border: 1px solid var(--line); outline: none;
  font-size: 1.05rem; transition: border-color .2s, box-shadow .2s;
}
.field input::placeholder { color: var(--muted); }
.field input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(var(--acc-rgb), .15); }
#in-code { font-family: var(--mono); letter-spacing: .08em; }
.field > .ic { position: absolute; right: 14px; color: var(--muted); pointer-events: none; }
.field .eye { position: absolute; right: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--panel); font-weight: 600; transition: transform .1s, background .2s, border-color .2s;
}
.btn:active { transform: scale(.98); }
.btn:hover { border-color: var(--acc); }
.btn.primary { background: var(--acc); color: var(--on-acc); border-color: var(--acc); font-size: 1.1rem; font-weight: 800; box-shadow: 0 0 24px rgba(var(--acc-rgb), .35); }
.btn.ghost { background: transparent; border-color: var(--line-soft); color: var(--muted); width: 100%; margin-top: 10px; }
.btn.danger { color: var(--danger); border-color: rgba(255, 90, 110, .35); width: 100%; margin-top: 24px; background: rgba(255, 90, 110, .06); }
.link { background: none; border: 0; color: var(--muted); padding: 6px; text-decoration: underline; text-underline-offset: 3px; font-size: .92rem; }
.err { color: var(--danger); min-height: 1.2em; text-align: center; margin: 12px 0 0; font-size: .95rem; }

.ic-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--acc); flex: none;
}
.ic-btn:active { background: var(--panel-2); }

/* ---------- Layout der App ---------- */
#screen-app { flex-direction: row; }
.pane { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.list-pane { width: 100%; }
.chat-pane { display: none; flex: 1; }
#screen-app.in-chat .list-pane { display: none; }
#screen-app.in-chat .chat-pane { display: flex; }

@media (min-width: 900px) {
  .list-pane { width: 380px; flex: none; border-right: 1px solid var(--line-soft); display: flex !important; }
  .chat-pane { display: flex !important; }
  #btn-back { display: none; }
}

.bar {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: calc(8px + var(--safe-top)) 8px 8px 12px;
  background: rgba(var(--bg-rgb, 5, 8, 7), .82);
  border-bottom: 1px solid var(--line-soft);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .bar { -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
}
.bar-title { flex: 1; min-width: 0; }
.brand-sm { font-weight: 800; color: var(--acc); font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-name { font-weight: 700; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-sub { color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-sub.typing { color: var(--acc); }

/* ---------- Profilbilder (vorerst Anfangsbuchstaben) ---------- */
.av {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.05rem; color: #fff; position: relative;
  background: var(--av, #2a3b33); border: 1.5px solid rgba(var(--acc-rgb), .55);
  box-shadow: 0 0 10px rgba(var(--acc-rgb), .18);
}
.av.big { width: 64px; height: 64px; font-size: 1.5rem; }
.av.group { background: rgba(0,0,0,.6); color: var(--acc); font-family: var(--mono); font-weight: 800; font-size: 1.35rem; text-shadow: 0 0 8px rgba(var(--acc-rgb), .7); }
.av .dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--acc); border: 2px solid var(--bg); box-shadow: 0 0 6px var(--acc); }
.me-av { cursor: pointer; }

/* ---------- Chatliste ---------- */
.chatlist { flex: 1; overflow-y: auto; padding: 6px 0 calc(16px + var(--safe-bottom)); -webkit-overflow-scrolling: touch; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin: 2px 8px;
  border-radius: 16px; cursor: pointer; transition: background .15s;
}
.row:hover { background: var(--panel); }
.row:active, .row.active { background: var(--panel-2); }
.row-main { flex: 1; min-width: 0; }
.row-top, .row-bottom { display: flex; align-items: center; gap: 8px; }
.row-name { flex: 1; font-weight: 650; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { color: var(--muted); font-size: .78rem; }
.row-time.unread { color: var(--acc); }
.row-prev { flex: 1; color: var(--muted); font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.row-prev .ic { width: 1rem; height: 1rem; }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--acc); color: var(--on-acc); font-size: .78rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.pin { color: var(--muted); width: 1rem; height: 1rem; }
.list-label { color: var(--muted); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; padding: 14px 22px 4px; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; height: 100%; width: 100%; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.msgs { flex: 1; overflow-y: auto; padding: 10px 10px 6px; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; }

.day { align-self: center; margin: 12px 0 8px; padding: 4px 12px; border-radius: 10px; font-size: .78rem; color: var(--muted); background: rgba(var(--bg-rgb, 5, 8, 7), .85); border: 1px solid var(--line-soft); }

.msg {
  max-width: 78%; max-width: min(78%, 560px); margin: 2px 0; padding: 7px 10px 5px 11px;
  border-radius: 16px; position: relative; word-wrap: break-word; overflow-wrap: anywhere;
  background: var(--bubble-other); border: 1px solid var(--line-soft);
  -webkit-user-select: none; user-select: none;
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .msg { -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
}
.msg.me { align-self: flex-end; background: var(--bubble-me); border-color: rgba(var(--acc-rgb), .35); }
.msg.other { align-self: flex-start; }
.msg.first.me { border-top-right-radius: 5px; }
.msg.first.other { border-top-left-radius: 5px; }
.msg.first { margin-top: 8px; }
.msg .who { font-size: .8rem; font-weight: 700; margin-bottom: 1px; }
.msg .text { white-space: pre-wrap; }
.msg .meta { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 6px 0 -2px 10px; font-size: .7rem; color: var(--muted); }
.msg .meta .ic { width: 1rem; height: 1rem; stroke-width: 2; }
.msg .meta .read { color: var(--acc); filter: drop-shadow(0 0 3px rgba(var(--acc-rgb), .6)); }
.msg.deleted .text { font-style: italic; color: var(--muted); }
.msg.deleted .text > .ic { width: 1rem; height: 1rem; vertical-align: -3px; margin-right: 6px; }
.msg.pending { opacity: .6; }
.msg.flash { animation: flash .6s; }
@keyframes flash { 50% { box-shadow: 0 0 0 3px rgba(var(--acc-rgb), .4); } }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px calc(8px + var(--safe-bottom)); flex: none; }
.input-pill {
  flex: 1; display: flex; align-items: flex-end; min-width: 0;
  background: rgba(var(--bg-rgb, 5, 8, 7), .85); border: 1px solid var(--line); border-radius: 26px; padding: 2px 4px;
}
.input-pill textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: transparent;
  padding: 11px 4px; max-height: 140px; line-height: 1.35; font-size: 1.02rem;
}
.input-pill textarea::placeholder { color: var(--muted); }
.input-pill .ic-btn { color: var(--muted); }
.round-btn {
  width: 50px; height: 50px; border-radius: 50%; border: 0; flex: none;
  background: var(--acc); color: var(--on-acc); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 18px rgba(var(--acc-rgb), .45); transition: transform .1s;
}
.round-btn:active { transform: scale(.94); }

/* Sprachnachricht aufnehmen */
.rec-bar { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; height: 50px;
  background: rgba(var(--bg-rgb, 5, 8, 7), .85); border: 1px solid rgba(255, 90, 110, .55); border-radius: 26px; padding: 0 12px 0 4px; }
.rec-bar[hidden] { display: none; }
.rec-bar .ic-btn { color: var(--danger); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ff3b4f; box-shadow: 0 0 8px #ff3b4f; animation: recblink 1s ease-in-out infinite; flex: none; }
@keyframes recblink { 50% { opacity: .25; } }
.rec-time { font-family: var(--mono); font-variant-numeric: tabular-nums; min-width: 3.2em; }
.rec-wave { flex: 1; min-width: 0; height: 30px; }
.composer.recording .input-pill { display: none; }

/* Sprachnachricht im Chat */
.voice { display: flex; align-items: center; gap: 10px; padding: 8px 10px 2px; min-width: 230px; }
.voice .v-play { width: 42px; height: 42px; border-radius: 50%; border: 0; flex: none; background: var(--acc); color: var(--on-acc);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 0 12px rgba(var(--acc-rgb), .4); }
.voice .v-play .ic { width: 20px; height: 20px; }
.voice .v-main { flex: 1; min-width: 0; }
.voice .v-wave { display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; }
.voice .v-wave i { flex: 1; min-width: 2px; border-radius: 2px; background: rgba(var(--fg-rgb), .3); }
.voice .v-wave i.on { background: var(--acc); }
.voice .v-info { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.voice .v-speed { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 10px; font-size: .75rem; padding: 1px 7px; font-weight: 700; }
.round-btn .ic { stroke-width: 2; }

/* ---------- Einstellungen ---------- */
.settings { flex: 1; overflow-y: auto; padding: 12px 16px calc(28px + var(--safe-bottom)); max-width: 640px; width: 100%; margin: 0 auto; }
.settings h3 { display: flex; align-items: center; gap: 8px; margin: 24px 4px 10px; font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; color: var(--acc); }
.settings h3 .ic { width: 1.1rem; height: 1.1rem; }
.settings form { display: flex; flex-direction: column; gap: 10px; }
.profile-card { display: flex; align-items: center; gap: 14px; }
.profile-card > div:last-child { min-width: 0; }
.profile-card .bar-sub { white-space: normal; }
.label { margin: 16px 2px 8px; color: var(--muted); font-size: .9rem; }
.label:first-child { margin-top: 0; }
.muted { color: var(--muted); opacity: .8; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw {
  width: 42px; height: 42px; border-radius: 50%; border: 2px solid rgba(var(--fg-rgb), .18);
  position: relative; padding: 0; background: var(--c);
}
.sw.on { border-color: var(--fg); box-shadow: 0 0 0 3px rgba(var(--fg-rgb), .2); }
.sw.on::after { content: ""; position: absolute; top: 12px; right: 12px; bottom: 12px; left: 12px; border-radius: 50%; background: rgba(var(--fg-rgb), .9); mix-blend-mode: difference; }
.sw.custom { background: conic-gradient(#f43, #fd3, #3f6, #3cf, #63f, #f3c, #f43); overflow: hidden; }
.sw.custom input { position: absolute; top: 0; right: 0; bottom: 0; left: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.sw.glow { box-shadow: 0 0 10px var(--c); }
.seg { display: flex; gap: 6px; background: rgba(0,0,0,.3); padding: 4px; border-radius: 14px; border: 1px solid var(--line-soft); }
.seg button { flex: 1; padding: 10px 6px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--acc); color: var(--on-acc); }
.seg button:disabled { opacity: .35; }
.row2 { display: flex; gap: 10px; }
.row2 .btn { flex: 1; }
input[type=range] { width: 100%; accent-color: var(--acc); }
.version { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 18px; }

/* ---------- Menü von unten ---------- */
.sheet-wrap { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 20; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; margin: 0 8px calc(8px + var(--safe-bottom)); padding: 8px; border-radius: 22px; background: var(--bg); border: 1px solid var(--line); animation: up .18s ease-out; }
.sheet button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; border: 0; background: transparent; border-radius: 14px; font-size: 1.05rem; text-align: left; }
.sheet button:active { background: var(--panel-2); }
.sheet button .ic { color: var(--acc); }
.sheet button.danger, .sheet button.danger .ic { color: var(--danger); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }

/* ---------- Hinweise ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: all .25s;
  padding: 10px 18px; border-radius: 14px; max-width: 90vw; text-align: center;
  background: rgba(var(--bg-rgb, 5, 8, 7), .95); border: 1px solid var(--acc); box-shadow: 0 0 18px rgba(var(--acc-rgb), .3);
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#conn { position: fixed; top: calc(70px + var(--safe-top)); left: 50%; transform: translateX(-50%); z-index: 15; padding: 6px 14px; border-radius: 12px; font-size: .85rem; background: rgba(255, 180, 0, .15); border: 1px solid rgba(255, 180, 0, .5); color: #ffd36b; }

/* ---------- Profilbilder als Foto ---------- */
.av.img { background-size: cover; background-position: center; color: transparent; }
.av.huge { width: 150px; height: 150px; font-size: 3.6rem; margin: 10px auto 20px; border-width: 2.5px; box-shadow: 0 0 30px rgba(var(--acc-rgb), .35); }
.profile-card { width: 100%; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.profile-card > .ic { color: var(--acc); margin-left: auto; }
.profile-big { text-align: center; padding-top: 8px; }
.hint.left { text-align: left; margin: 0 2px; font-size: .88rem; }

/* ---------- Smiley-Auswahl ---------- */
.emoji-panel { flex: none; height: 290px; display: flex; flex-direction: column; border-top: 1px solid var(--line-soft); background: rgba(var(--bg-rgb, 5, 8, 7), .94); padding-bottom: var(--safe-bottom); }
.emoji-grid { flex: 1; overflow-y: auto; padding: 4px 6px; -webkit-overflow-scrolling: touch; }
.emoji-grid h4 { margin: 10px 6px 4px; font-size: .78rem; color: var(--muted); font-weight: 600; letter-spacing: .05em; }
.emoji-grid .e-row { display: flex; flex-wrap: wrap; }
.emoji-grid button { width: 12.5%; height: 44px; border: 0; background: none; font-size: 1.7rem; line-height: 1; padding: 0; border-radius: 10px; }
.emoji-grid button:active { background: var(--panel-2); }
.emoji-tabs { display: flex; border-top: 1px solid var(--line-soft); }
.emoji-tabs button { flex: 1; height: 42px; border: 0; background: none; font-size: 1.25rem; opacity: .5; border-bottom: 2px solid transparent; }
.emoji-tabs button.on { opacity: 1; border-bottom-color: var(--acc); }

/* ---------- Büroklammer-Menü ---------- */
.sheet.grid { display: flex; flex-wrap: wrap; padding: 18px 8px 10px; }
.sheet.grid button { width: 25%; flex-direction: column; gap: 8px; padding: 8px 2px; text-align: center; font-size: .9rem; color: var(--fg); }
.sheet.grid .bubble { width: 58px; height: 58px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(var(--c), .14); border: 1.5px solid rgba(var(--c), .7); box-shadow: 0 0 14px rgba(var(--c), .3); }
.sheet.grid .bubble .ic { color: rgb(var(--c)); width: 1.6rem; height: 1.6rem; }

/* ---------- Foto- und Datei-Nachrichten ---------- */
.msg.media { padding: 4px 4px 5px; }
.msg .photo { display: block; border-radius: 12px; overflow: hidden; background: rgba(0,0,0,.35); position: relative; cursor: zoom-in; width: 260px; max-width: 100%; }
.msg .photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.msg .photo .meta { position: absolute; right: 8px; bottom: 6px; margin: 0; color: #fff; text-shadow: 0 1px 3px #000; }
.msg .photo .meta .read { color: var(--acc); }
.msg.media .text { padding: 5px 6px 0; }
.msg .upl { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.4); }
.msg .upl i { display: block; height: 100%; width: 0; background: var(--acc); box-shadow: 0 0 8px var(--acc); transition: width .2s; }
.doc { display: flex; align-items: center; gap: 10px; padding: 8px 8px 4px; color: inherit; text-decoration: none; min-width: 210px; }
.doc .doc-ic { width: 42px; height: 42px; border-radius: 10px; flex: none; display: flex; align-items: center; justify-content: center; background: rgba(var(--acc-rgb), .14); color: var(--acc); }
.doc .doc-name { font-weight: 600; overflow-wrap: anywhere; }
.doc .doc-size { color: var(--muted); font-size: .8rem; }
.loc { display: block; text-decoration: none; color: inherit; min-width: 230px; }
.loc .loc-map { height: 110px; border-radius: 12px; position: relative; overflow: hidden;
  background:
    linear-gradient(rgba(var(--acc-rgb), .08) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(90deg, rgba(var(--acc-rgb), .08) 1px, transparent 1px) 0 0 / 22px 22px,
    radial-gradient(circle at 50% 55%, rgba(var(--acc-rgb), .25), transparent 60%), rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; }
.loc .loc-map .ic { width: 2.6rem; height: 2.6rem; color: var(--acc); filter: drop-shadow(0 0 8px var(--acc)); }
.loc .loc-txt { padding: 6px 6px 0; font-weight: 600; }
.loc .loc-sub { padding: 0 6px; color: var(--muted); font-size: .8rem; }

/* ---------- Vollbild: Kamera, Zuschneiden, Vorschau, Betrachter ---------- */
.screen.dark { z-index: 12; background: #000; flex-direction: column; color: #fff; }
.bar.clear { background: rgba(0,0,0,.5); border: 0; }
.ic-btn.light { color: #fff; }
#cam-video { flex: 1; width: 100%; min-height: 0; object-fit: cover; background: #000; }
#cam-video.mirror { transform: scaleX(-1); }
.cam-ring { position: absolute; left: 50%; top: 42%; width: 72vmin; height: 72vmin; transform: translate(-50%, -50%); border-radius: 50%; border: 2px dashed rgba(255,255,255,.55); pointer-events: none; }
.cam-bar { flex: none; display: flex; align-items: center; justify-content: space-around; padding: 18px 10px calc(22px + var(--safe-bottom)); background: #000; }
.shutter { width: 74px; height: 74px; border-radius: 50%; border: 4px solid #fff; background: var(--acc); box-shadow: 0 0 0 4px #000 inset, 0 0 20px rgba(var(--acc-rgb), .6); }
.shutter:active { transform: scale(.94); }
.crop-title { text-align: center; padding: calc(18px + var(--safe-top)) 10px 10px; color: rgba(255,255,255,.8); }
.crop-stage { position: relative; width: 92vmin; height: 92vmin; max-width: 460px; max-height: 460px; margin: 0 auto; touch-action: none; cursor: grab; overflow: hidden; border-radius: 12px; }
.crop-stage canvas { width: 100%; height: 100%; display: block; }
.crop-mask { position: absolute; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0,0,0,.62); border: 2px solid var(--acc); }
.crop-zoom { display: flex; align-items: center; gap: 12px; max-width: 460px; width: 92vmin; margin: 22px auto 0; color: #fff; }
.crop-btns { max-width: 460px; width: 92vmin; margin: 20px auto calc(20px + var(--safe-bottom)); }
.prev-img, .viewer-img { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px; }
.prev-img img, .viewer-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.prev-thumbs { display: flex; gap: 6px; justify-content: center; padding: 4px; flex: none; }
.prev-thumbs img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; opacity: .7; }
.prev-thumbs img.on { border-color: var(--acc); opacity: 1; }
#screen-preview .input-pill { background: rgba(255,255,255,.08); }
.viewer-cap { flex: none; text-align: center; padding: 10px 16px calc(16px + var(--safe-bottom)); white-space: pre-wrap; }
#view-dl { text-decoration: none; }

/* ---------- Plus-Knopf auf der Startseite ---------- */
.list-pane { position: relative; }
.fab {
  position: absolute; right: 18px; bottom: calc(20px + var(--safe-bottom)); z-index: 3;
  width: 58px; height: 58px; border-radius: 18px; border: 0;
  background: var(--acc); color: var(--on-acc); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 22px rgba(var(--acc-rgb), .5), 0 8px 20px rgba(0,0,0,.4); transition: transform .1s;
}
.fab:active { transform: scale(.93); }
.fab .ic { width: 1.7rem; height: 1.7rem; stroke-width: 2.2; }
.chatlist { padding-bottom: calc(90px + var(--safe-bottom)); }

/* ---------- Einstellungs-Menü ---------- */
.card.menu { padding: 6px; margin-top: 14px; }
.card.menu button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 10px; border: 0; background: transparent; border-radius: 14px; text-align: left; }
.card.menu button:active, .card.menu button:hover { background: var(--panel-2); }
.menu-ic { width: 42px; height: 42px; border-radius: 12px; flex: none; display: flex; align-items: center; justify-content: center; background: rgba(var(--acc-rgb), .13); color: var(--acc); border: 1px solid rgba(var(--acc-rgb), .3); }
.menu-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.menu-txt b { font-weight: 650; font-size: 1.05rem; }
.menu-txt small { color: var(--muted); font-size: .85rem; }
.chev { color: var(--muted); width: 1.2rem; height: 1.2rem; }
.settings > .card:first-child, .settings > h3:first-child { margin-top: 6px; }
.font-demo { display: flex; flex-direction: column; padding: 4px 0; }
.font-demo .msg { max-width: 85%; }
.btn.wide { width: 100%; }
.hint.small { font-size: .82rem; margin-top: 12px; }
.finger-btn { width: 100%; margin-top: 14px; }

/* ---------- Auswahlliste (Gruppen) ---------- */
.pick-list { padding: 6px; }
.pick { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 0; background: transparent; border-radius: 14px; text-align: left; }
.pick:active { background: var(--panel-2); }
.pick .pick-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick .tick { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; color: transparent; flex: none; }
.pick.on .tick { background: var(--acc); border-color: var(--acc); color: var(--on-acc); box-shadow: 0 0 10px rgba(var(--acc-rgb), .5); }
.pick .tick .ic { width: 1rem; height: 1rem; stroke-width: 3; }
.pick-list .empty { color: var(--muted); padding: 10px; }
.pick .pick-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick .pick-txt .pick-name { flex: none; }
.pick .pick-sub { color: var(--muted); font-size: .82rem; line-height: 1.3; }
.pick .pick-sub.warn { color: var(--acc); }
.pick .mini { flex: none; padding: 6px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--fg); font-weight: 650; font-size: .85rem; }
.pick .mini.ok { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.menu .badge { margin-right: 4px; }
.ic-btn.has-dot { position: relative; }
.ic-btn.has-dot::after { content: ''; position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 8px var(--acc); }

/* Einladung: Code + QR */
.code-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 18px 14px; }
.code-for { font-weight: 700; font-size: 1.1rem; }
.qr { width: 220px; height: 220px; max-width: 70vw; max-height: 70vw; border-radius: 14px; image-rendering: pixelated; background: #fff; box-shadow: 0 0 22px rgba(var(--acc-rgb), .35); }
.code-big { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.5rem; font-weight: 800; letter-spacing: .12em; color: var(--acc); user-select: all; }
.code-link { color: var(--muted); font-size: .8rem; word-break: break-all; user-select: all; }
#chat-title.click { cursor: pointer; }

/* ---------- Live-Standort: Uhr ---------- */
.live-pick { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.live-pick .seg { width: 100%; max-width: 360px; }
.live-pick .btn.primary { width: 100%; max-width: 360px; }
.clock { width: 250px; height: 250px; max-width: 76vw; max-height: 76vw; margin-top: 6px; overflow: visible; touch-action: none; cursor: pointer; -webkit-user-select: none; user-select: none; }
.clock.drag .hand, .clock.drag .arc { transition: none; }
.clock .mark.in circle { stroke: rgba(var(--acc-rgb), .7); }
.clock .face { fill: rgba(0,0,0,.35); stroke: var(--line); stroke-width: 1.5; }
html.light .clock .face { fill: rgba(255,255,255,.45); }
.clock .tick { stroke: rgba(var(--fg-rgb), .35); stroke-width: 2; stroke-linecap: round; }
.clock .tick.big { stroke: rgba(var(--fg-rgb), .7); stroke-width: 3; }
.clock .arc { fill: none; stroke: var(--acc); stroke-width: 12; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 110px 110px; filter: drop-shadow(0 0 6px rgba(var(--acc-rgb), .7)); transition: stroke-dasharray .45s ease; opacity: .9; }
.clock .mark { cursor: pointer; }
.clock .mark circle { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; transition: all .2s; }
.clock .mark text { fill: var(--fg); font-size: 13px; pointer-events: none; font-weight: 700; text-anchor: middle; dominant-baseline: central; font-family: var(--font); }
.clock .mark.on circle { fill: var(--acc); stroke: var(--acc); }
.clock .mark.on text { fill: var(--on-acc); }
.clock .hand { transform-origin: 110px 110px; transition: transform .45s ease; }
.clock .hand line { stroke: var(--acc); stroke-width: 3; stroke-linecap: round; }
.clock .hand circle, .clock .hub { fill: var(--acc); }
.clock-big { font-size: 2.6rem; font-weight: 800; color: var(--acc); line-height: 1; text-shadow: 0 0 16px rgba(var(--acc-rgb), .4); }
.clock-big small { font-size: 1.1rem; color: var(--muted); font-weight: 600; text-shadow: none; }

/* ---------- Live-Standort in der Nachricht ---------- */
.loc.live .loc-map::before { content: ""; position: absolute; width: 80px; height: 80px; border-radius: 50%; border: 2px solid var(--acc); top: 50%; left: 50%; margin: -40px 0 0 -40px; animation: ping 1.8s ease-out infinite; opacity: 0; }
@keyframes ping { 0% { transform: scale(.3); opacity: .9; } 100% { transform: scale(1.4); opacity: 0; } }
.loc.ended .loc-map { filter: grayscale(1); opacity: .6; }
.live-badge { display: inline-flex; align-items: center; gap: 5px; color: var(--acc); font-weight: 700; }
.live-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 6px var(--acc); }
.loc.ended .live-badge { color: var(--muted); }
.loc.ended .live-badge::before { background: var(--muted); box-shadow: none; }
.live-stop { display: flex; align-items: center; justify-content: center; gap: 6px; width: calc(100% - 8px); margin: 6px 4px 0; padding: 8px; border-radius: 10px; border: 1px solid rgba(255, 90, 110, .45); background: rgba(255, 90, 110, .08); color: var(--danger); font-weight: 600; font-size: .9rem; }

/* ---------- Eigenes Nachfrage-Fenster (statt weißem Browser-Fenster) ---------- */
.dlg-wrap { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(0,0,0,.55); opacity: 0; transition: opacity .18s ease; }
.dlg-wrap.on { opacity: 1; }
.dlg { width: 100%; max-width: 340px; text-align: center; padding: 22px 18px 16px; background: rgba(var(--bg-rgb), .94);
  border-color: rgba(var(--acc-rgb), .55); box-shadow: 0 0 28px rgba(var(--acc-rgb), .25), 0 20px 60px rgba(0,0,0,.5);
  transform: scale(.94); transition: transform .18s ease; }
.dlg-wrap.on .dlg { transform: scale(1); }
.dlg-ic { width: 52px; height: 52px; margin: 0 auto 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--acc); background: rgba(var(--acc-rgb), .12); border: 1px solid rgba(var(--acc-rgb), .45); box-shadow: 0 0 16px rgba(var(--acc-rgb), .3); }
.dlg-ic .ic { width: 26px; height: 26px; }
.dlg-ic.danger { color: var(--danger); background: rgba(255, 90, 110, .1); border-color: rgba(255, 90, 110, .45); box-shadow: 0 0 16px rgba(255, 90, 110, .25); }
.dlg-title { margin: 0 0 6px; font-size: 1.2rem; font-weight: 800; color: var(--fg); }
.dlg-text { margin: 0 0 18px; color: var(--muted); line-height: 1.4; }
.dlg-btns { display: flex; gap: 10px; }
.dlg-btns .btn { flex: 1; margin: 0; padding: 12px 8px; font-size: 1rem; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 800; box-shadow: 0 0 18px rgba(255, 90, 110, .35); }
.sheet button { -webkit-user-select: none; user-select: none; }

/* ---------- Anruf ---------- */
.screen.call { z-index: 50; flex-direction: column; justify-content: space-between; align-items: center; background: rgba(3, 6, 5, .96); color: #e8fff4;
  padding: calc(env(safe-area-inset-top, 0px) + 48px) 16px calc(env(safe-area-inset-bottom, 0px) + 36px); overflow: hidden; }
#call-remote { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s; background: #000; }
.screen.call.remote-video #call-remote { opacity: 1; }
#call-local { position: absolute; right: 14px; top: calc(env(safe-area-inset-top, 0px) + 14px); width: 28vw; max-width: 150px; height: 37vw; max-height: 200px;
  object-fit: cover; border-radius: 14px; border: 2px solid var(--acc); box-shadow: 0 0 16px rgba(var(--acc-rgb), .5); z-index: 2; background: #000; }
#call-local.mirror { transform: scaleX(-1); }
.call-top { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.screen.call.remote-video .call-top { flex-direction: row; gap: 10px; align-self: flex-start; background: rgba(0,0,0,.45); padding: 6px 14px 6px 6px; border-radius: 30px; }
.call-av-wrap { position: relative; width: 140px; height: 140px; }
.call-av-wrap .av { width: 140px; height: 140px; font-size: 3.6rem; border: 2px solid var(--acc); box-shadow: 0 0 30px rgba(var(--acc-rgb), .45); }
.call-ring { position: absolute; top: -10px; left: -10px; right: -10px; bottom: -10px; border-radius: 50%; border: 2px solid var(--acc); opacity: 0; }
.screen.call.ringing .call-ring { animation: callping 1.6s ease-out infinite; }
@keyframes callping { 0% { transform: scale(.85); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }
.screen.call.remote-video .call-av-wrap, .screen.call.remote-video .call-av-wrap .av { width: 40px; height: 40px; font-size: 1.1rem; box-shadow: none; }
.screen.call.remote-video .call-ring { display: none; }
.call-name { font-size: 1.7rem; font-weight: 800; color: #fff; text-shadow: 0 0 18px rgba(var(--acc-rgb), .5); }
.call-status { color: var(--acc); font-family: var(--mono); letter-spacing: .06em; }
.screen.call.remote-video .call-name { font-size: 1rem; }
.screen.call.remote-video .call-status { font-size: .85rem; }
.call-btns { position: relative; z-index: 1; display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; width: 100%; max-width: 420px; }
#call-btns-in { gap: 70px; }
.call-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; color: #e8fff4; font-size: .8rem; padding: 0; }
.call-btn .ic { width: 62px; height: 62px; padding: 17px; border-radius: 50%; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-sizing: border-box; }
.call-btn.on .ic { background: #fff; color: #03140c; }
.call-btn.red .ic { background: #e5394d; border-color: #e5394d; color: #fff; box-shadow: 0 0 22px rgba(229, 57, 77, .55); }
.call-btn.green .ic { background: #14c46a; border-color: #14c46a; color: #fff; box-shadow: 0 0 22px rgba(20, 196, 106, .55); animation: wiggle 1.2s ease-in-out infinite; }
#call-decline .ic { width: 70px; height: 70px; padding: 19px; } #call-accept .ic { width: 70px; height: 70px; padding: 19px; }
@keyframes wiggle { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-14deg); } 80% { transform: rotate(14deg); } 90% { transform: rotate(-8deg); } }

/* Gruppenanruf: Kacheln */
#call-grid { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: none; padding: calc(env(safe-area-inset-top, 0px) + 70px) 8px 150px;
  grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 8px; }
.screen.call.group #call-grid { display: grid; }
.screen.call.group.n1 #call-grid, .screen.call.group.n2 #call-grid { grid-template-columns: 1fr; }
.screen.call.group .call-top { flex-direction: row; gap: 10px; align-self: flex-start; background: rgba(0,0,0,.45); padding: 6px 14px 6px 6px; border-radius: 30px; }
.screen.call.group .call-av-wrap, .screen.call.group .call-av-wrap .av { width: 40px; height: 40px; font-size: 1.1rem; box-shadow: none; }
.screen.call.group .call-ring { display: none; }
.screen.call.group .call-name { font-size: 1rem; }
.screen.call.group .call-status { font-size: .85rem; }
.screen.call.group #call-remote { display: none; }
.tile { position: relative; border-radius: 16px; overflow: hidden; background: rgba(0,0,0,.55); border: 1px solid rgba(var(--acc-rgb), .35); min-height: 0;
  display: flex; align-items: center; justify-content: center; }
.tile video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s; }
.tile.cam video { opacity: 1; }
.tile .av { width: 72px; height: 72px; font-size: 1.9rem; }
.tile.cam .av { display: none; }
.tile .tile-name { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: .8rem; padding: 3px 9px; border-radius: 10px; }
.tile.wait { opacity: .55; }

/* Laufender Gruppenanruf im Chat: Beitreten-Leiste */
.call-bar { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line-soft);
  background: rgba(20, 196, 106, .16); color: var(--fg); font-size: .92rem; }
.call-bar .ic { color: #14c46a; }
.call-bar b { margin-left: auto; color: #fff; background: #14c46a; padding: 4px 12px; border-radius: 14px; }
.call-bar[hidden] { display: none; }

/* Anruf-Kärtchen im Chat */
.callcard { display: flex; align-items: center; gap: 10px; padding: 8px 10px 4px; min-width: 210px; cursor: pointer; }
.callcard .cc-ic { width: 40px; height: 40px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  background: rgba(var(--acc-rgb), .14); color: var(--acc); }
.callcard.missed .cc-ic { background: rgba(255, 90, 110, .14); color: var(--danger); }
.callcard .cc-t { font-weight: 700; }
.callcard.missed .cc-t { color: var(--danger); }
.callcard .cc-s { font-size: .85rem; color: var(--muted); }

/* ---------- Sperrbildschirm ---------- */
.screen.lock { z-index: 40; background: var(--bg); }
.screen.lock .btn.primary { width: 100%; margin-top: 10px; }
.screen.lock .link { display: block; margin: 12px auto 0; }
#form-lockpw { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

/* ---------- Zuschneiden: Rechteck für Hintergrundbild ---------- */
.crop-mask.rect { border-radius: 10px; box-shadow: none; }

/* ---------- Helles Design (wenn Hintergrund hell gewählt) ---------- */
html.light { --fg: #0c1410; --fg-rgb: 12, 20, 16; }
html.light .field input, html.light .seg { background: rgba(255,255,255,.6); }
/* Grelle Leuchtfarbe bleibt grell – eine feine dunkle Kontur macht sie auf Beige/Creme lesbar */
html.light .brand, html.light .brand-sm, html.light .bar-sub.typing, html.light .row-time.unread,
html.light .settings h3, html.light .clock-big, html.light .live-badge, html.light .av.group {
  text-shadow: 0 0 1px rgba(0,0,0,.9), 0 0 1px rgba(0,0,0,.9), 0 0 10px rgba(var(--acc-rgb), .55);
}
html.light .clock-big small { text-shadow: none; }
html.light .ic-btn .ic, html.light .sheet button .ic, html.light .profile-card > .ic, html.light .menu-ic .ic,
html.light .doc .doc-ic .ic, html.light .loc .loc-map .ic, html.light .msg .meta .read, html.light .dlg-ic .ic,
html.light .clock .arc, html.light .clock .hand, html.light .clock .hub {
  filter: drop-shadow(0 0 .7px rgba(0,0,0,.95)) drop-shadow(0 0 .7px rgba(0,0,0,.95));
}
html.light .sheet button.danger .ic { filter: none; }
html.light .btn.primary, html.light .seg button.on, html.light .pick.on .tick, html.light .clock .mark.on circle {
  box-shadow: 0 0 0 1px rgba(0,0,0,.45), 0 0 18px rgba(var(--acc-rgb), .7);
}
html.light .clock .mark.on circle { stroke: rgba(0,0,0,.5); }
html.light .field input:focus { border-color: rgba(0,0,0,.45); box-shadow: 0 0 0 3px rgba(var(--acc-rgb), .55); }
html.light .card { border-color: rgba(0,0,0,.18); }
/* Logo bleibt auch im hellen Design dunkel – so leuchtet das M wie im Original */
html.light .logo { background: #050807; border-color: var(--acc); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
