/* Tresor-Look: tiefes Petrol, Messing als Siegel- und Akzentfarbe */
:root {
  --bg: #0d2128;
  --panel: #122c34;
  --panel-2: #183842;
  --line: #24505c;
  --text: #e7efed;
  --muted: #8eaeb1;
  --brass: #dcae52;
  --brass-ink: #2a1c03;
  --mine: #dcae52;
  --mine-ink: #241802;
  --theirs: #1b404b;
  --danger: #ef7a6c;
  --warn: #f2c66d;
  --focus: #f4d48e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #e4ecea;
    --panel: #f6f9f8;
    --panel-2: #e9f0ee;
    --line: #c3d3d1;
    --text: #0f2a31;
    --muted: #557378;
    --brass: #8f6410;
    --brass-ink: #ffffff;
    --mine: #f0d38d;
    --mine-ink: #2a1c03;
    --theirs: #ffffff;
    --danger: #b3392b;
    --warn: #8a5a00;
    --focus: #8f6410;
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h3 { font-size: 15px; margin: 22px 0 8px; }
small { color: var(--muted); }

/* Siegel: das wiedererkennbare Element */
.seal {
  --s: 38px;
  width: var(--s); height: var(--s);
  flex: none;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, var(--brass-ink) 0 13%, transparent 14%),
    linear-gradient(var(--brass-ink), var(--brass-ink)) 50% 62% / 10% 26% no-repeat,
    radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--brass) 70%, #fff) 0, var(--brass) 55%, color-mix(in srgb, var(--brass) 75%, #000) 100%);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--brass) 80%, #000), inset 0 0 0 5px color-mix(in srgb, var(--brass) 60%, #fff);
}
.seal.big { --s: 72px; }
.seal.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; transform: scale(.94); } }

.boot { height: 100%; display: grid; place-items: center; }

/* ------------------------------------------------------------ Buttons & Formulare */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brass); color: var(--brass-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.sm { padding: 6px 11px; font-size: 13.5px; border-radius: 8px; }
.btn.block { width: 100%; }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--brass); box-shadow: 0 0 0 2px var(--panel); }

.mini {
  border: 0; background: transparent; color: var(--muted);
  font-size: 12.5px; padding: 2px 6px; border-radius: 6px; cursor: pointer;
}
.mini:hover { color: var(--text); background: var(--panel-2); }
.mini.danger:hover { color: var(--danger); }

label { display: grid; gap: 5px; font-size: 13.5px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
}
input:focus, textarea:focus { outline: none; border-color: var(--brass); }
input[type=file] { font-size: 13.5px; color: var(--muted); }
.stack { display: grid; gap: 14px; }
.inline { display: flex; gap: 8px; align-items: end; margin-top: 18px; }
.grow { flex: 1; min-width: 0; }
.hint { color: var(--muted); font-size: 13.5px; margin: 0; }
.err, .hint.err { color: var(--danger); }
.warn { color: var(--warn); border-left: 3px solid var(--warn); padding: 6px 0 6px 12px; margin: 0 0 12px; }
.label { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; margin: 0; }

/* ------------------------------------------------------------ Anmeldung */
.check-inline { display: flex; flex-direction: row; align-items: center; gap: 9px; color: var(--text); font-size: 14px; cursor: pointer; }
.check-inline input { accent-color: var(--brass); width: 17px; height: 17px; margin: 0; }
.auth { min-height: 100%; display: grid; place-items: center; padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 28px 24px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { font-family: var(--serif); font-size: 27px; letter-spacing: .2px; }
.auth-sub { color: var(--muted); margin: 12px 0 22px; }
.verify-title { font-family: var(--serif); font-size: 21px; margin-top: 22px; }
.auth-msg { min-height: 1.5em; margin: 16px 0 0; font-size: 14px; color: var(--muted); }
.auth-msg.err { color: var(--danger); }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg); border-radius: 12px; margin-bottom: 18px; }
.tab { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tab.active { background: var(--panel-2); color: var(--text); }

/* ------------------------------------------------------------ App-Layout */
.app { display: grid; grid-template-columns: 340px 1fr; grid-template-rows: minmax(0, 1fr); height: 100dvh; padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.sidebar { padding-bottom: env(safe-area-inset-bottom); display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 10px 16px; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me-text { display: grid; line-height: 1.25; min-width: 0; }
.me-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { font-size: 12px; }
.side-actions { display: flex; }
.side-new { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 4px 16px 12px; border-bottom: 1px solid var(--line); }
.side-new .btn { padding: 8px 10px; font-size: 13.5px; }
.side-empty { padding: 28px 22px; }
.side-empty p { margin: 0 0 6px; }

.avatar {
  --h: 180;
  flex: none;
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: hsl(var(--h) 38% 34%);
  color: hsl(var(--h) 60% 92%);
  font-size: 14px; font-weight: 600; letter-spacing: .3px;
}
.avatar.group { border-radius: 12px; }
@media (prefers-color-scheme: light) {
  .avatar { background: hsl(var(--h) 45% 82%); color: hsl(var(--h) 55% 22%); }
}

.conv-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 12px; cursor: pointer; }
.conv:hover { background: var(--panel-2); }
.conv.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--brass); }
.conv-main { flex: 1; min-width: 0; }
.conv-top, .conv-bottom { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.conv-top time { font-size: 12px; color: var(--muted); flex: none; }
.conv-prev { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.has-unread .conv-prev { color: var(--text); }
.count { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brass); color: var(--brass-ink); font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }

.chat { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-placeholder { flex: 1; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.chat-placeholder p { margin: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.chat-head .back { display: none; }
.chat-title { flex: 1; display: grid; line-height: 1.25; min-width: 0; }
.chat-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.chat-title small { font-size: 12.5px; }
.warn-text { color: var(--warn) !important; }

/* ------------------------------------------------------------ Nachrichten */
.messages {
  flex: 1; overflow-y: auto;
  padding: 18px clamp(12px, 4vw, 48px) 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.load-more { align-self: center; margin-bottom: 10px; }
.day { align-self: center; font-size: 12.5px; color: var(--muted); padding: 14px 0 8px; }

.msg { display: flex; align-items: center; gap: 6px; margin-top: 8px; max-width: 100%; }
.msg.cont { margin-top: 2px; }
.msg.mine { flex-direction: row-reverse; }
.bubble {
  position: relative;
  max-width: min(72%, 640px);
  padding: 7px 11px 6px;
  border-radius: 16px;
  background: var(--theirs);
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  overflow-wrap: anywhere;
}
.msg:not(.mine):not(.cont) .bubble { border-top-left-radius: 5px; }
.msg.mine .bubble { background: var(--mine); color: var(--mine-ink); border-color: transparent; }
.msg.mine:not(.cont) .bubble { border-top-right-radius: 5px; }
.who { --h: 180; font-size: 12.5px; font-weight: 600; color: hsl(var(--h) 55% 70%); margin-bottom: 2px; }
@media (prefers-color-scheme: light) { .who { color: hsl(var(--h) 55% 32%); } }
.text { white-space: pre-wrap; }
.text.muted { font-style: italic; opacity: .7; }
.text.big .emo { width: 56px; height: 56px; }
.bubble time { display: block; text-align: right; font-size: 11px; opacity: .65; margin-top: 1px; }
.emo { width: 22px; height: 22px; vertical-align: -5px; object-fit: contain; }

.quote {
  display: grid; gap: 1px; width: 100%;
  text-align: left; cursor: pointer;
  border: 0; border-left: 3px solid currentColor;
  background: color-mix(in srgb, currentColor 10%, transparent);
  border-radius: 6px;
  padding: 4px 8px; margin: 2px 0 5px;
  font-size: 13px;
}
.quote small { color: inherit; font-weight: 600; opacity: .85; }
.quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .8; }

.msg-actions { display: flex; opacity: 0; transition: opacity .12s; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: 1; } .msg-actions .mini { font-size: 12px; } }
.msg.flash .bubble { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px var(--focus); } 100% { box-shadow: 0 0 0 3px transparent; } }

.reply-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.reply-inner { flex: 1; min-width: 0; display: grid; border-left: 3px solid var(--brass); padding-left: 10px; }
.reply-inner small { color: var(--brass); font-weight: 600; }
.reply-inner span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13.5px; }

.composer {
  position: relative;
  display: flex; align-items: flex-end; gap: 6px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.composer textarea { resize: none; max-height: 180px; border-radius: 20px; padding: 9px 14px; line-height: 1.4; }
.send {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: var(--brass); color: var(--brass-ink); cursor: pointer;
}
.send svg { width: 20px; height: 20px; }
.emoji-pop {
  position: absolute; bottom: calc(100% + 6px); left: 10px;
  width: min(340px, calc(100vw - 20px)); max-height: 260px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px;
  padding: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 30px rgb(0 0 0 / .28);
  z-index: 5;
}
.emoji-pop .hint { grid-column: 1 / -1; }
.emo-btn { border: 0; background: transparent; border-radius: 8px; padding: 5px; cursor: pointer; }
.emo-btn:hover { background: var(--panel-2); }
.emo-btn img { width: 28px; height: 28px; display: block; margin: auto; object-fit: contain; }

/* ------------------------------------------------------------ Dialoge */
dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
}
dialog::backdrop { background: rgb(4 14 17 / .6); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 6px 22px; }
.dlg-head h2 { font-family: var(--serif); font-size: 21px; }
.dlg-body { padding: 8px 22px 22px; overflow-y: auto; max-height: calc(100dvh - 120px); }
.dlg-body > .tabs { margin-top: 4px; }
.dlg-foot { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.row:last-child { border-bottom: 0; }
.row .grow { display: grid; line-height: 1.3; }
.row .grow small { overflow: hidden; text-overflow: ellipsis; }
.fp { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: .3px; }
.fp.big { display: block; font-size: 15px; color: var(--text); background: var(--bg); border-radius: 10px; padding: 10px 12px; margin: 6px 0 4px; }
.tag { justify-self: start; font-size: 11.5px; padding: 1px 8px; border-radius: 6px; background: var(--panel-2); color: var(--muted); margin-top: 2px; }
.tag.pending { background: color-mix(in srgb, var(--brass) 22%, transparent); color: var(--brass); }
.tag.blocked { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }

.checklist { display: grid; gap: 2px; max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.check { display: flex; flex-direction: row; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; color: var(--text); font-size: 14.5px; cursor: pointer; }
.check:hover { background: var(--panel-2); }
.check input { accent-color: var(--brass); width: 17px; height: 17px; }
.check .avatar { width: 30px; height: 30px; font-size: 12px; }

.file-row { display: flex; align-items: center; gap: 12px; }
.emo-preview { width: 48px; height: 48px; object-fit: contain; background: var(--bg); border-radius: 10px; padding: 4px; }
.emo-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.emo-item { display: grid; justify-items: center; gap: 4px; padding: 10px 6px 6px; background: var(--bg); border-radius: 12px; }
.emo-item img { width: 36px; height: 36px; object-fit: contain; }
.emo-item code { font-family: var(--mono); font-size: 12px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: min(460px, calc(100vw - 32px));
  padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg);
  font-size: 14px; z-index: 100;
  box-shadow: 0 10px 28px rgb(0 0 0 / .3);
}
.toast.err { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------ Mobil */
@media (max-width: 799px) {
  .app { grid-template-columns: 1fr; }
  .chat { display: none; }
  body.show-chat .sidebar { display: none; }
  body.show-chat .chat { display: flex; }
  .chat-head .back { display: inline-grid; }
  .bubble { max-width: 84%; }
}

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