/* ==========================================================================
   Schulplattform – Oberfläche
   Neutrales, ruhiges Design mit Lucide-Icons (public/icons.svg)
   ========================================================================== */

:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --hover: #f1f1f3;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-text: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .25);
  --ring: 0 0 0 3px rgba(79, 70, 229, .25);
  --sidebar-w: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090b;
    --surface: #131316;
    --surface-2: #1c1c20;
    --hover: #1f1f24;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --text-2: #d4d4d8;
    --muted: #a1a1aa;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-soft: rgba(129, 140, 248, .14);
    --primary-text: #0b0b12;
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .12);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, .12);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, .12);
    --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, .7);
    --ring: 0 0 0 3px rgba(129, 140, 248, .3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; font-weight: 650; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 1rem; font-weight: 600; margin: 0 0 1rem; letter-spacing: -.01em; }
h3 { font-size: .9rem; font-weight: 600; margin: 1rem 0 .5rem; }
p { margin: 0 0 .75rem; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: .05rem .35rem; border-radius: 5px; font-size: .85em;
}
code.secret { display: inline-block; font-size: 1.05rem; padding: .35rem .6rem; letter-spacing: .04em; user-select: all; }
code.wrap { word-break: break-all; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.error { color: var(--danger); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
::selection { background: var(--primary-soft); }

/* ---------- Icons ---------- */
.icon {
  width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -.25em;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }
.icon.filled { fill: currentColor; }
.icon-box {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius);
  background: var(--primary-soft); color: var(--primary);
}

/* ---------- App-Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: .5rem;
  padding: 1rem .75rem; background: var(--surface); border-right: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: .6rem; padding: .35rem .5rem .9rem; color: var(--text);
  font-weight: 650; letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--primary); color: var(--primary-text);
}
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .9rem .6rem .35rem; }
.nav a {
  display: flex; align-items: center; gap: .65rem; padding: .5rem .6rem; border-radius: 8px;
  color: var(--text-2); font-weight: 500;
}
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--hover); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a.active .icon { color: var(--primary); }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: .75rem; display: flex; align-items: center; gap: .5rem; }
.user-chip { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; padding: .35rem; border-radius: 8px; color: var(--text); }
.user-chip:hover { background: var(--hover); text-decoration: none; }
.user-chip.active { background: var(--primary-soft); }
.user-chip-text { min-width: 0; line-height: 1.25; }
.user-chip-text strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: .8rem; text-transform: uppercase;
}
.avatar.sm { width: 28px; height: 28px; font-size: .7rem; }

.main { min-width: 0; }
.content { max-width: 1120px; margin: 0 auto; padding: 2rem 2rem 3rem; }
.content.narrow { max-width: 680px; }
.content.wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head p { margin: .25rem 0 0; color: var(--muted); }

/* Minimaler Kopf (Login-Zwang, Passwortwechsel) */
.topbar-min { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--surface); }

/* ---------- Karten ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow-sm); margin-bottom: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.tile { display: flex; flex-direction: column; gap: .75rem; color: var(--text); transition: border-color .15s, box-shadow .15s, transform .15s; }
.tile:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.tile h2 { margin: 0; }
.tile p { margin: 0; }
.tile-foot { margin-top: auto; display: flex; align-items: center; gap: .25rem; color: var(--primary); font-weight: 500; font-size: .85rem; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar h2 { margin: 0; }
.actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }

/* ---------- Formulare ---------- */
label { display: block; margin-bottom: .9rem; font-weight: 500; font-size: .85rem; color: var(--text-2); }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; color: var(--text); }
input, select, textarea {
  display: block; width: 100%; margin-top: .35rem; padding: .55rem .75rem; font: inherit; font-size: .9rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input:not([type="checkbox"]), select { height: 38px; }
input[type="checkbox"] { width: 16px; height: 16px; display: inline-block; margin: 0; accent-color: var(--primary); box-shadow: none; }
textarea { resize: vertical; }
.search-field { position: relative; }
.search-field .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field input { margin: 0; padding-left: 2.2rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; align-items: end; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-actions { margin-bottom: .9rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form input { width: auto; flex: 1; min-width: 140px; margin: 0; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 1rem; padding: .75rem 1rem 0; }
legend { font-size: .8rem; color: var(--muted); padding: 0 .3rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; height: 38px; padding: 0 .9rem; margin: 0;
  font: inherit; font-size: .875rem; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.small { height: 30px; padding: 0 .65rem; font-size: .8rem; gap: .35rem; }
.btn.small .icon { width: 15px; height: 15px; }
.btn.icon-only { width: 32px; height: 32px; padding: 0; }
.btn.icon-only.small { width: 28px; height: 28px; }
.btn.block { width: 100%; }
button.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font: inherit; opacity: .85; }

/* ---------- Hinweise, Badges ---------- */
.notice { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; font-size: .875rem; }
.notice > .icon { margin-top: .1rem; }
.notice p { margin: 0 0 .4rem; }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--text); }
.notice.warn > .icon { color: var(--warn); }
.notice.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.notice.success > .icon { color: var(--success); }
.badge {
  display: inline-flex; align-items: center; gap: .25rem; height: 20px; padding: 0 .45rem; margin-left: .35rem;
  font-size: .72rem; font-weight: 600; border-radius: 999px; background: var(--primary-soft); color: var(--primary); vertical-align: middle;
}
.badge:empty { display: none; }
.badge .icon { width: 12px; height: 12px; }
.badge.solid { background: var(--primary); color: var(--primary-text); }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.muted { background: var(--surface-2); color: var(--muted); }
.role { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; }
.role::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.role-admin::before { background: var(--danger); }
.role-teacher::before { background: var(--success); }
.role-student::before { background: var(--primary); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--hover); }
.table tr.inactive td { opacity: .5; }
.table tr.clickable { cursor: pointer; }
.table.small th, .table.small td { padding: .45rem .5rem; }
.name-cell { display: flex; align-items: center; gap: .6rem; }
.name-cell .icon { color: var(--muted); }
.name-cell .icon.folder { color: var(--primary); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn { opacity: .7; }
tr:hover .row-actions .btn { opacity: 1; }

/* ---------- Tabs (Segment) ---------- */
.tabs { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 1.25rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .8rem; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); font: inherit; font-size: .85rem; font-weight: 500; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.module-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 1rem; align-items: center; padding: .9rem 0; border-bottom: 1px solid var(--border); }
.module-row:last-child { border-bottom: 0; }
.module-row h3 { margin: 0; }
.module-row p { margin: 0; }
.module-row .roles { display: flex; gap: 1rem; }
.module-row label { margin: 0; }

/* Schalter */
.switch { position: relative; display: inline-flex; align-items: center; gap: .5rem; margin: 0; cursor: pointer; font-weight: 500; color: var(--text); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: transform .15s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* ---------- Dialoge ---------- */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  padding: 1.5rem; width: min(560px, calc(100vw - 2rem)); box-shadow: var(--shadow-lg);
}
dialog.wide { width: min(820px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(9, 9, 11, .45); backdrop-filter: blur(2px); }
dialog h2 { font-size: 1.1rem; }
.dialog-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.dialog-actions.end { justify-content: flex-end; }
.dialog-actions + .dialog-actions { padding-top: 1rem; border-top: 1px solid var(--border); }

.plain-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .55rem .25rem; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }
.plain-list li > span:first-child { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.plain-list.selectable li { cursor: pointer; justify-content: flex-start; border-radius: 8px; border-bottom: 0; padding: .5rem .6rem; }
.plain-list.selectable li:hover, .plain-list.selectable li:focus { background: var(--hover); outline: none; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; height: 28px; padding: 0 .65rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: .8rem; color: var(--text);
}
a.chip:hover { border-color: var(--border-strong); text-decoration: none; }
.chip button { display: inline-grid; place-items: center; border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0; }
.chip button:hover { color: var(--danger); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 1.25rem; right: 1.25rem; display: flex; align-items: center; gap: .6rem;
  background: var(--text); color: var(--bg); padding: .75rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  font-size: .875rem; max-width: min(420px, calc(100vw - 2.5rem)); z-index: 100;
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }

/* ---------- Login ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(1200px 500px at 50% -10%, var(--primary-soft), transparent); }
.auth-card { width: min(400px, 100%); padding: 2rem; }
.auth-head { text-align: center; margin-bottom: 1.5rem; }
.auth-head .brand-mark { width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 1rem; }
.auth-head .brand-mark .icon { width: 26px; height: 26px; }
.auth-head h1 { font-size: 1.35rem; }
.auth-head p { margin: .35rem 0 0; color: var(--muted); }

/* ---------- Leere Zustände ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; color: var(--muted); text-align: center; padding: 3rem 1rem; margin: auto; }
.empty .icon { width: 36px; height: 36px; stroke-width: 1.4; opacity: .6; }

/* ---------- Dateien ---------- */
.usage { min-width: 220px; }
.usage-bar { height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin: .4rem 0 .25rem; }
.usage-bar > div { height: 100%; background: var(--primary); width: 0; transition: width .3s; }
.breadcrumbs { display: flex; align-items: center; gap: .25rem; font-weight: 500; flex-wrap: wrap; }
.breadcrumbs a { color: var(--text-2); padding: .15rem .35rem; border-radius: 6px; }
.breadcrumbs a:hover { background: var(--hover); text-decoration: none; }
.breadcrumbs a:last-child { color: var(--text); font-weight: 600; }
.breadcrumbs .icon { color: var(--muted); width: 14px; height: 14px; }
.dropzone {
  display: flex; align-items: center; justify-content: center; gap: .5rem; border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 1rem; color: var(--muted); margin-bottom: 1rem; font-size: .85rem; transition: border-color .15s, background .15s, color .15s;
}
.dropzone.over { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.progress { height: 4px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 1rem; }
.progress > div { height: 100%; background: var(--primary); width: 0; transition: width .2s; }

/* ---------- Nachrichten ---------- */
.chat { display: grid; grid-template-columns: 300px 1fr; gap: 1rem; height: calc(100vh - 4rem); min-height: 480px; }
.chat .card { margin: 0; display: flex; flex-direction: column; min-height: 0; padding: 1rem; }
.conv-list { list-style: none; margin: 0 -.5rem; padding: 0; overflow-y: auto; }
.conv-list li { display: flex; gap: .65rem; align-items: center; padding: .6rem .5rem; border-radius: 10px; cursor: pointer; }
.conv-list li:hover { background: var(--hover); }
.conv-list li.active { background: var(--primary-soft); }
.conv-body { min-width: 0; flex: 1; }
.conv-title { font-weight: 600; display: flex; align-items: center; gap: .3rem; }
.conv-title .badge { margin-left: auto; }
.chat-main { position: relative; }
#chat-view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
#chat-view.hidden { display: none; }
.chat-header { display: flex; justify-content: space-between; align-items: center; gap: .75rem; border-bottom: 1px solid var(--border); padding-bottom: .75rem; }
.chat-header > div:first-child { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.chat-header h2 { margin: 0; }
.chat-header p { margin: 0; }
.messages { flex: 1; overflow-y: auto; padding: 1rem .25rem; display: flex; flex-direction: column; gap: .4rem; }
.msg { max-width: min(75%, 560px); padding: .55rem .8rem; border-radius: 14px 14px 14px 4px; background: var(--surface-2); align-self: flex-start; }
.msg.mine { align-self: flex-end; background: var(--primary); color: var(--primary-text); border-radius: 14px 14px 4px 14px; }
.msg.deleted .msg-body { font-style: italic; opacity: .7; }
.msg-sender { font-size: .75rem; font-weight: 600; color: var(--primary); margin-bottom: .1rem; }
.msg-body { white-space: pre-wrap; word-wrap: break-word; }
.msg-meta { font-size: .7rem; opacity: .7; margin-top: .15rem; }
.send-form { display: flex; gap: .5rem; align-items: flex-end; border-top: 1px solid var(--border); padding-top: .75rem; }
.send-form textarea { margin: 0; min-height: 42px; }
.send-form .btn { height: 42px; }

/* ---------- E-Mail ---------- */
.mail { display: grid; grid-template-columns: 230px 360px 1fr; gap: 1rem; height: calc(100vh - 4rem); min-height: 480px; }
.mail .card { margin: 0; min-height: 0; padding: 1rem; }
.mail-sidebar { display: flex; flex-direction: column; gap: .75rem; }
.mail-address { word-break: break-all; margin: 0; }
.folder-list { list-style: none; margin: 0 -.25rem; padding: 0; flex: 1; }
.folder-list a { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.folder-list a .icon { color: var(--muted); }
.folder-list a .badge { margin-left: auto; }
.folder-list a:hover { background: var(--hover); text-decoration: none; }
.folder-list a.active { background: var(--primary-soft); color: var(--primary); }
.folder-list a.active .icon { color: var(--primary); }
.mail-sidebar .usage { min-width: 0; }
.mail-sidebar #mail-settings { justify-content: flex-start; }
.mail-list { display: flex; flex-direction: column; }
.mail-list .toolbar { margin-bottom: .5rem; }
.mail-list .search-field { flex: 1; }
.message-list { list-style: none; padding: 0; margin: 0 -1rem; overflow-y: auto; flex: 1; }
.message-list li { padding: .7rem 1rem; border-bottom: 1px solid var(--border); cursor: pointer; border-left: 3px solid transparent; }
.message-list li:hover { background: var(--hover); }
.message-list li.active { background: var(--primary-soft); }
.message-list li.unseen { border-left-color: var(--primary); }
.message-list li.unseen .from, .message-list li.unseen .subject { font-weight: 650; }
.message-list .row { display: flex; justify-content: space-between; gap: .5rem; }
.message-list .subject { display: flex; align-items: center; gap: .3rem; }
.message-list .subject .icon { width: 14px; height: 14px; color: var(--muted); }
.message-list .subject .icon.star { color: var(--warn); fill: var(--warn); }
.mail-view { overflow-y: auto; display: flex; flex-direction: column; }
.mail-actions { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: .35rem; padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.mail-actions .spacer { flex: 1; }
.mail-view h2 { font-size: 1.25rem; font-weight: 650; letter-spacing: -.01em; margin-bottom: .75rem; }
.mail-headers { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: 1rem; font-size: .875rem; }
.mail-headers > div { min-width: 0; }
.mail-text { white-space: pre-wrap; word-wrap: break-word; font-family: inherit; margin: 0; line-height: 1.6; }
.mail-html { width: 100%; flex: 1; min-height: 420px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }

/* ---------- Responsiv ---------- */
.mobile-bar { display: none; }
@media (max-width: 1100px) {
  .mail { grid-template-columns: 200px 1fr; height: auto; }
  .mail-view { grid-column: 1 / -1; min-height: 60vh; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 50; transform: translateX(-100%);
    transition: transform .2s, visibility .2s; visibility: hidden;
  }
  .shell.nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(9, 9, 11, .4); z-index: 40; }
  .mobile-bar {
    display: flex; align-items: center; gap: .6rem; position: sticky; top: 0; z-index: 30;
    padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); font-weight: 600;
  }
  .content { padding: 1.25rem 1rem 2rem; }
  .mail, .chat { grid-template-columns: 1fr; height: auto; }
  .mail-list, .mail-view { max-height: 75vh; }
  .chat-sidebar { max-height: 40vh; }
  .chat-main { height: 75vh; }
  .module-row { grid-template-columns: auto 1fr; }
  .module-row .roles { grid-column: 1 / -1; flex-wrap: wrap; }
}

/* Überschriften mit Icon */
.card-head h2, .toolbar h2 { display: flex; align-items: center; gap: .5rem; }
.card-head h2 .icon, .toolbar h2 .icon { color: var(--muted); }
.plain-list li .avatar { margin-right: .1rem; }
.plain-list.selectable li { gap: .55rem; }
.plain-list.selectable li .icon { color: var(--muted); }
#queue-status .badge { margin-left: 0; }

/* ---------- Administration: Module ---------- */
.notice.info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.notice.info > .icon { color: var(--primary); }
.modules-intro { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: start; margin-bottom: 1rem; }
.modules-intro h2 { display: flex; align-items: center; gap: .5rem; margin: 0 0 .25rem; }
.modules-intro h2 .icon { color: var(--muted); }
.modules-intro .notice { margin: 0; }
.modules-list { display: grid; gap: 1rem; }
.module-card { margin: 0; padding: 0; overflow: hidden; transition: border-color .15s; }
.module-card-head { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; padding: 1.1rem 1.25rem; }
.module-card-title h3 { display: flex; align-items: center; gap: .25rem; margin: 0 0 .15rem; font-size: 1rem; }
.module-card-title p { margin: 0; }
.module-card.is-disabled .module-card-head .icon-box { background: var(--surface-2); color: var(--muted); }
.module-card.is-disabled .module-card-title h3 { color: var(--muted); }
.module-section { border-top: 1px solid var(--border); padding: .9rem 1.25rem; }
.module-section-title { display: flex; align-items: center; gap: .4rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .6rem; }
.module-section .error { margin: .6rem 0 0; }
.role-toggles { display: flex; flex-wrap: wrap; gap: .4rem; }
.role-toggle {
  display: inline-flex; align-items: center; gap: .4rem; height: 32px; padding: 0 .8rem; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: .82rem; font-weight: 500; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong);
  transition: background .15s, color .15s, border-color .15s;
}
.role-toggle:hover { color: var(--text); border-color: var(--muted); }
.role-toggle.on { background: var(--primary-soft); color: var(--primary); border: 1px solid color-mix(in srgb, var(--primary) 40%, transparent); }
.role-toggle:focus-visible { outline: none; box-shadow: var(--ring); }
details.module-section { padding: 0; }
details.module-section > summary {
  display: flex; align-items: center; gap: .5rem; padding: .85rem 1.25rem; cursor: pointer; list-style: none; font-weight: 600; font-size: .875rem;
}
details.module-section > summary::-webkit-details-marker { display: none; }
details.module-section > summary:hover { background: var(--hover); }
details.module-section > summary .icon { color: var(--muted); }
details.module-section > summary .chevron { margin-left: auto; transition: transform .15s; }
details.module-section[open] > summary .chevron { transform: rotate(90deg); }
.module-settings { padding: .25rem 1.25rem 1.1rem; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.setting-row:last-of-type { border-bottom: 0; }
.setting-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.setting-text strong { font-weight: 500; }
.setting-input { display: flex; align-items: center; gap: .5rem; flex: none; }
.setting-input input { width: 130px; margin: 0; }
.setting-input select { margin: 0; min-width: 160px; }
@media (max-width: 860px) {
  .modules-intro { grid-template-columns: 1fr; }
  .setting-row { flex-direction: column; align-items: flex-start; gap: .5rem; }
}
.module-card.is-disabled .role-toggles { opacity: .55; }

/* Modul-Einstellungen im Menü (nur Admins) */
.nav-item { position: relative; display: flex; align-items: center; }
.nav-item > a:first-child { flex: 1; }
.nav-settings {
  position: absolute; right: .35rem; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px;
  color: var(--muted); opacity: 0; transition: opacity .15s;
}
.nav .nav-item a.nav-settings { padding: 0; }
.nav-item:hover .nav-settings, .nav-settings:focus-visible { opacity: 1; }
.nav .nav-item a.nav-settings:hover { background: var(--surface-2); color: var(--text); }

/* Modulübersicht und Detailseite */
.module-card-title h3 a { color: inherit; }
.module-card-foot {
  display: flex; align-items: center; gap: .5rem; padding: .8rem 1.25rem; border-top: 1px solid var(--border);
  color: var(--text); font-weight: 600; font-size: .875rem;
}
.module-card-foot:hover { background: var(--hover); text-decoration: none; }
.module-card-foot .icon { color: var(--muted); }
.module-card-foot .chevron { margin-left: auto; }
.content.narrow-wide { max-width: 860px; }
.back-link { margin-bottom: 1rem; }
.icon.flip { transform: rotate(180deg); }
.module-detail-title { display: flex; align-items: center; gap: .9rem; }
.module-detail-title h1 { display: flex; align-items: center; gap: .25rem; }
.module-detail-title .icon-box { width: 48px; height: 48px; }
.module-settings { padding: 0; }
.setting-input input.wide { width: 260px; }
#module-detail .module-card { margin-bottom: 1rem; }
