:root {
  --bg: #f6f7f5;
  --panel: #ffffff;
  --rail: #13302c;
  --rail-fg: #cfe3df;
  --ink: #1c2321;
  --muted: #69736f;
  --line: #e4e7e3;
  --soft: #eef2ef;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e0f0ed;
  --danger: #c2410c;
  --warn: #b45309;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 22, .06), 0 8px 24px rgba(16, 24, 22, .08);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Buttons & Inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--soft); }
.btn.icon { padding: 6px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.field { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
label.field > span { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.role-badge { color: #fff; }
.count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, #d6ebe6 0, transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.login-card h1 { margin: 12px 0 4px; font-size: 22px; }
.logo { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; }
.logo svg { width: 22px; height: 22px; }
.demo-users { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.demo-users button { display: flex; width: 100%; justify-content: space-between; border: 0; background: none; padding: 6px 4px;
  border-radius: 6px; cursor: pointer; text-align: left; }
.demo-users button:hover { background: var(--soft); }
.error { color: var(--danger); font-size: 13px; }

/* Shell */
.shell { display: grid; grid-template-columns: 76px 1fr; height: 100vh; }
.rail { background: var(--rail); color: var(--rail-fg); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 4px; }
.rail .org-btn { width: 48px; height: 48px; border-radius: 14px; border: 0; cursor: pointer; font-weight: 700; color: #fff;
  font-size: 15px; margin-bottom: 10px; position: relative; }
.rail .org-btn::after { content: ""; position: absolute; right: -4px; bottom: -4px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--rail) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23cfe3df' stroke-width='3'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center/10px no-repeat; }
.rail .nav { width: 64px; padding: 8px 0 6px; border: 0; background: transparent; color: var(--rail-fg); border-radius: 10px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; position: relative; }
.rail .nav svg { width: 22px; height: 22px; }
.rail .nav:hover { background: rgba(255,255,255,.07); }
.rail .nav.active { background: rgba(255,255,255,.14); color: #fff; }
.rail .nav .count { position: absolute; top: 2px; right: 8px; background: #f97316; }
.rail .spacer { flex: 1; }
.rail .me { width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); cursor: pointer; padding: 0; }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; display: flex; }
.page { flex: 1; overflow: auto; padding: 24px 32px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; }

/* Popover menu */
.menu { position: fixed; z-index: 50; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line);
  min-width: 240px; padding: 6px; }
.menu .item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; text-align: left; }
.menu .item:hover { background: var(--soft); }
.menu .item.active { background: var(--accent-soft); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu .label { padding: 6px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* Avatar */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 600;
  font-size: 12px; flex-shrink: 0; position: relative; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; background: #9ca3af; }
.avatar .dot.on { background: #16a34a; }

/* Modal */
.backdrop { position: fixed; inset: 0; background: rgba(16, 24, 22, .4); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal.wide { max-width: 860px; }
.modal header { padding: 18px 20px 0; font-size: 17px; font-weight: 600; display: flex; align-items: center; }
.modal .body { padding: 16px 20px; overflow: auto; }
.modal footer { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }

/* Toast */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #1c2321; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 360px; animation: pop .15s ease-out; }
.toast.error { background: var(--danger); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }

/* Two-column module layout (Chat) */
.side { width: 260px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 16px 16px 8px; }
.side-head .org-name { font-weight: 700; font-size: 16px; }
.side-scroll { overflow: auto; flex: 1; padding: 0 8px 16px; }
.side-section { display: flex; align-items: center; justify-content: space-between; padding: 14px 8px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.side-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--ink); text-decoration: none; }
.side-item:hover { background: var(--soft); }
.side-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-item.unread { font-weight: 700; }
.side-item svg { width: 15px; height: 15px; color: var(--muted); flex-shrink: 0; }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--panel); }
.chat-head { padding: 12px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat-head .title { font-weight: 700; font-size: 16px; }
.messages { flex: 1; overflow: auto; padding: 12px 20px; }
.day { text-align: center; margin: 16px 0 8px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 12px; }
.day::before, .day::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.msg { display: flex; gap: 10px; padding: 4px 8px; margin: 0 -8px; border-radius: 8px; position: relative; }
.msg:hover { background: #fafbfa; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; }
.msg .name { font-weight: 700; }
.msg .time { font-size: 11px; color: var(--muted); }
.msg .text { white-space: pre-wrap; word-wrap: break-word; line-height: 1.45; }
.msg.cont { padding-top: 0; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg .tools { position: absolute; right: 8px; top: 2px; display: none; }
.msg:hover .tools { display: block; }
.msg .deleted { color: var(--muted); font-style: italic; }
.attach { margin-top: 6px; display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; text-decoration: none; color: var(--ink); max-width: 360px; }
.attach:hover { background: var(--soft); }
.attach-img { margin-top: 6px; display: block; max-width: 360px; max-height: 260px; border-radius: 10px; border: 1px solid var(--line); }
.typing { height: 20px; padding: 0 20px; font-size: 12px; color: var(--muted); }
.composer { padding: 0 20px 16px; }
.composer-box { border: 1px solid var(--line); border-radius: 12px; display: flex; align-items: flex-end; gap: 6px; padding: 6px; }
.composer-box:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; border: 0; resize: none; outline: none; padding: 6px; max-height: 160px; min-height: 22px; background: transparent; }
.readonly-note { padding: 12px 20px 16px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.empty { padding: 48px; text-align: center; color: var(--muted); }

/* Tabelle (Ablage, Admin) */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfa; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #fafbfa; }
.file-ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--soft); color: var(--muted); flex-shrink: 0; }
.file-ico.folder { background: #fdf3d7; color: #b7791f; }
.file-ico svg { width: 18px; height: 18px; }
.crumbs { display: flex; align-items: center; gap: 4px; font-size: 18px; font-weight: 600; flex-wrap: wrap; }
.crumbs a { color: var(--muted); text-decoration: none; cursor: pointer; }
.crumbs a:hover { color: var(--ink); }
.dropzone { position: fixed; inset: 0; background: rgba(15, 118, 110, .12); border: 3px dashed var(--accent); z-index: 90; display: grid; place-items: center; font-size: 18px; font-weight: 600; color: var(--accent); pointer-events: none; }
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
.preview-text { white-space: pre-wrap; background: #fafbfa; border: 1px solid var(--line); padding: 12px; border-radius: 8px; max-height: 70vh; overflow: auto; font-family: ui-monospace, monospace; font-size: 13px; }
.progress { height: 4px; background: var(--soft); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: #5eead4; width: 0; transition: width .2s; }

/* Karten (Video, Übersicht) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.card h3 { margin: 0; font-size: 16px; }
.stat { font-size: 26px; font-weight: 700; }

/* Video */
.call { flex: 1; display: flex; flex-direction: column; background: #0d1715; color: #fff; min-height: 0; }
.call-head { padding: 12px 20px; display: flex; align-items: center; gap: 12px; }
.tiles { flex: 1; display: grid; gap: 10px; padding: 10px 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-content: center; overflow: auto; }
.tile { position: relative; background: #1d2b28; border-radius: 12px; aspect-ratio: 16/9; overflow: hidden; display: grid; place-items: center; }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile .who { position: absolute; left: 10px; bottom: 8px; background: rgba(0,0,0,.5); padding: 3px 8px; border-radius: 6px; font-size: 12px; }
.tile .placeholder { position: absolute; inset: 0; display: grid; place-items: center; }
.call-bar { display: flex; justify-content: center; gap: 12px; padding: 16px; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 0; background: #2b3b37; color: #fff; display: grid; place-items: center; cursor: pointer; }
.round svg { width: 22px; height: 22px; }
.round.off { background: #fff; color: #0d1715; }
.round.leave { background: #dc2626; }
.jitsi { flex: 1; border: 0; width: 100%; }

/* Rechte-Matrix */
.matrix { border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.matrix th, .matrix td { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.matrix thead th { position: sticky; top: 0; background: #fafbfa; z-index: 1; font-size: 12px; text-align: center; }
.matrix td.c { text-align: center; }
.matrix tr.group td { background: #f4f6f4; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.matrix code { font-size: 11px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab { padding: 10px 14px; border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tab.active { color: var(--accent); border-color: var(--accent); }
.audit-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mono { font-family: ui-monospace, monospace; font-size: 12px; }
.secret { font-family: ui-monospace, monospace; font-size: 16px; background: var(--soft); padding: 10px; border-radius: 8px; text-align: center; letter-spacing: .05em; user-select: all; }

.back-mobile { display: none !important; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr 64px; }
  .rail { order: 2; flex-direction: row; justify-content: space-around; padding: 4px 8px; }
  .rail .org-btn { width: 40px; height: 40px; margin: 0; }
  .rail .spacer { display: none; }
  .side { width: 100%; }
  .view.has-active .side { display: none; }
  .view:not(.has-active) .chat { display: none; }
  .page { padding: 16px; }
  .back-mobile { display: inline-flex !important; }
}

/* Zweisprachigkeit */
.lang-tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 5px; border-radius: 4px; background: var(--soft); color: var(--muted); }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.lang-switch button { border: 0; background: transparent; padding: 5px 9px; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--muted); }
.lang-switch button.on { background: var(--accent); color: #fff; }
.rail .lang-switch.rail-lang { border-color: rgba(255,255,255,.2); margin-bottom: 10px; }
.rail .lang-switch.rail-lang button { color: var(--rail-fg); padding: 4px 7px; font-size: 11px; }
.rail .lang-switch.rail-lang button.on { background: #fff; color: var(--rail); }
.rail .org-btn.long { font-size: 12px; letter-spacing: -.02em; }
.bi { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bi-col { display: flex; align-items: center; gap: 6px; }
.bi-col .lang-tag { flex-shrink: 0; }
.msg .translation { margin-top: 4px; padding: 6px 10px; border-left: 3px solid var(--accent-soft); background: #f7faf9; border-radius: 0 8px 8px 0; color: #34403c; white-space: pre-wrap; }
.msg .tr-link { border: 0; background: none; padding: 0; margin-top: 2px; font-size: 12px; color: var(--accent); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.msg .tr-link:hover { text-decoration: underline; }
.affil { font-size: 12px; color: var(--muted); }
@media (max-width: 760px) {
  .rail .lang-switch.rail-lang { margin: 0; }
  .bi { grid-template-columns: 1fr; }
}

/* Logo des Verbands */
.brand-slot { display: inline-flex; align-items: center; }
.login-logo { height: 46px; width: auto; display: block; margin-bottom: 4px; }
.topbar { height: 48px; flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top-logo { height: 26px; width: auto; display: block; }
.top-sep { width: 1px; height: 22px; background: var(--line); }
.top-title { font-size: 13px; color: var(--muted); }
.view-host { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view-host > .view { flex: 1; min-height: 0; }
@media (max-width: 760px) { .top-sep, .top-title { display: none; } .topbar { height: 44px; padding: 0 14px; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { overflow-x: auto; gap: 2px; }
  .rail .nav { width: auto; min-width: 58px; padding: 6px 6px; font-size: 10px; }
  .rail .lang-switch.rail-lang { display: none; } /* Sprache auf dem Handy über das Profilmenü */
  .rail .me { flex-shrink: 0; }
}
.login { grid-template-rows: 1fr auto; }
.login-card { align-self: center; justify-self: center; }
.login-sub { margin-top: 10px; }
.login-foot { justify-self: center; padding: 16px 0 4px; font-size: 12px; color: var(--muted); letter-spacing: .04em; }

/* Emoji-Auswahl */
.composer-box { position: relative; }
.emoji-btn { font-size: 18px; line-height: 1; width: 32px; height: 32px; justify-content: center; filter: grayscale(.3); }
.emoji-btn:hover { filter: none; }
.emoji-pop { position: absolute; bottom: calc(100% + 8px); right: 44px; width: min(340px, calc(100vw - 32px)); background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 30; display: flex; flex-direction: column; }
.emoji-tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); }
.emoji-tabs button { border: 0; background: none; font-size: 18px; border-radius: 6px; padding: 4px 6px; cursor: pointer; }
.emoji-tabs button:hover { background: var(--soft); }
.emoji-scroll { max-height: 260px; overflow-y: auto; padding: 4px 8px 8px; }
.emoji-cat { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 2px 4px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); }
.emoji-grid button { border: 0; background: none; font-size: 22px; line-height: 1; padding: 5px 0; border-radius: 6px; cursor: pointer; }
.emoji-grid button:hover { background: var(--soft); transform: scale(1.15); }
@media (max-width: 760px) { .emoji-pop { right: 0; } }
