:root {
    --bg: #6e2639;
    --bg-dark: #551d2c;
    --paper: #faf8f6;
    --ink: #2b2622;
    --muted: #8a8178;
    --line: #e7e1da;
    --card: #ffffff;
    --gold: #b8893f;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.55;
    /* Sticky-Footer-Layout: Body fuellt mindestens das Viewport aus,
       der Footer wird via "margin-top: auto" an den unteren Rand
       geschoben, wenn der Inhalt kuerzer ist. */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--bg-dark);
    color: #fff;
    padding: 14px 22px;
    /* Menuleiste bleibt beim Scrollen immer oben sichtbar. */
    position: sticky;
    top: 0;
    z-index: 50;
}

.brand { font-size: 17px; font-weight: 700; letter-spacing: 0.3px; }
.brand-thin { font-weight: 300; opacity: 0.85; }

.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 22px;
    box-sizing: border-box;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}

.welcome h1 { margin-top: 0; font-size: 24px; }
.welcome p { color: var(--muted); }

/* --- Formulare & Buttons --- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topnav { display: flex; align-items: center; gap: 14px; }
.topnav-user { font-size: 13px; opacity: 0.85; }
.inline-form { margin: 0; }
.linkbtn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    border-radius: 7px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
}

.auth-card { max-width: 420px; margin: 0 auto; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 13px; font-weight: 600; }
.field input,
.field select,
.field textarea {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 11px;
    font: inherit;
    background: #fff;
}

.btn-primary {
    background: var(--bg);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.auth-links { margin-top: 16px; font-size: 13px; }
.auth-links a { color: var(--bg); }

.flash {
    border-radius: 8px;
    padding: 11px 14px;
    margin-bottom: 18px;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.flash-text { flex: 1; }
.flash-close {
    appearance: none;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 0 4px;
    opacity: 0.55;
    transition: opacity 0.15s ease;
}
.flash-close:hover,
.flash-close:focus { opacity: 1; outline: none; }
.flash-success { background: #e8f2eb; color: #2f6b45; }
.flash-error { background: #f6e3e3; color: #9a3434; }

/* --- Portal-Layout --- */
.topnav a { color: rgba(255, 255, 255, 0.85); text-decoration: none; font-size: 13px; }
.topnav a:hover { color: #fff; }

.portal-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: calc(100vh - 56px);
}

.sidebar {
    background: #f3eee8;
    border-right: 1px solid var(--line);
    padding: 16px 12px;
    /* Oben klebend und auf Viewport-Hoehe gesetzt: sehr viele Themen lassen
       die Seitenleiste nicht ins Unendliche wachsen — die Liste scrollt intern,
       Kopf und Suchfeld bleiben sichtbar. Definite Hoehe (nicht nur max-height),
       damit der innere Scroll-Container (.scroll-shadow, flex-basis:0) nicht auf
       0px kollabiert. */
    position: sticky;
    /* Direkt unter der klebenden Menuleiste (56px hoch) andocken. */
    top: 56px;
    align-self: start;
    height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
}
.sidebar-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
.sidebar-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 10px;
}
.sidebar-topic {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    text-decoration: none;
    color: var(--ink);
    font-size: 13px;
    margin-bottom: 6px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sidebar-topic:hover { border-color: var(--bg); }
.sidebar-topic.is-active {
    border-color: var(--bg);
    box-shadow: inset 3px 0 0 var(--bg);
    font-weight: 600;
}
/* Lange Titel in der Seitenliste auf eine Zeile kuerzen (…); der volle Titel
   erscheint per title-Attribut beim Ueberfahren mit der Maus. */
.sidebar-topic-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.sidebar-topic .topic-badge-slot { flex-shrink: 0; }
.sidebar-empty { color: var(--muted); font-size: 12px; padding: 6px 4px; }

.portal-main { padding: 26px 28px; display: flex; flex-direction: column; min-width: 0; }

@media (max-width: 900px) {
    .portal-shell { grid-template-columns: minmax(0, 1fr); }
    /* min-width:0 hebt das implizite Grid-Minimum auf, sonst weitet ein langer
       Inhalt (z.B. ein langes Wort) die Spalte ueber die Viewport-Breite. */
    .sidebar,
    .portal-main { min-width: 0; }
    /* Auf Mobil steht die Seitenleiste ueber dem Inhalt — daher nicht klebend,
       und die Themenliste zeigt hoechstens ~4 Themen und scrollt sonst, damit
       eine lange Liste den eigentlichen Inhalt nicht weit nach unten schiebt. */
    .sidebar { position: static; height: auto; max-height: none; border-right: none; border-bottom: 1px solid var(--line); }
    .sidebar-list { max-height: 190px; }
    /* Auf dem Handy nur ausblenden, wenn KEIN Thema geoeffnet ist — die
       Themen-Liste dient dort als Navigation zwischen den Themen. Auf der
       Uebersicht und allen anderen Seiten verschwindet sie. */
    .sidebar { display: none; }
    .portal-shell.has-active-topic .sidebar { display: block; }
    /* Topbar: Marke oben, Navigation darunter — umbrechend statt ueberlaufend. */
    /* Auf Mobil/Tablet nicht kleben — die umgebrochene Leiste wuerde sonst zu
       viel Bildschirmhoehe dauerhaft belegen. Nur auf dem Desktop sticky. */
    .topbar { position: static; flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 16px; }
    .topnav { flex-wrap: wrap; gap: 9px 14px; width: 100%; }
    .topnav .topnav-user { margin-left: auto; }
    /* Engere Innenabstaende auf Mobil — 28px wuerden zu viel Platz fressen. */
    .portal-main { padding: 18px 14px; }
    .portal-main .card { padding: 18px 16px; }
    /* Grosse Seitenueberschriften auf Mobil daempfen, damit sie neben einer
       Aktion (z.B. „+ Neues Thema") nicht ueberlaufen. */
    .portal-main h1 { font-size: 24px; }
    /* Lange, ununterbrochene Zeichenketten (z.B. URLs, Kauderwelsch) duerfen
       Karten nicht horizontal aufweiten. */
    .portal-main .card { overflow-wrap: break-word; }
}

/* --- Tabellen (ohne Trennlinien, dezentes Zebra) --- */
/* Horizontaler Scroll-Container fuer breite Tabellen auf schmalen Schirmen,
   damit sie nicht die Seite aufweiten. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll .data-table { min-width: 480px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
    text-align: left;
    padding: 8px 12px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.data-table td { text-align: left; padding: 12px; vertical-align: middle; }
.data-table tbody tr { transition: background-color 0.15s ease; }
.data-table tbody tr:nth-child(even) { background: #faf8f6; }
.data-table tbody tr:hover { background: #f3eee8; }

/* --- Gemeinsamer Seitenkopf (Audit, Statistik) --- */
.page-head { margin-bottom: 16px; }
.page-head h1 { margin: 0 0 2px; }
.page-head .muted { margin: 0; font-size: 13px; }

/* --- Statistik: kompaktes Kachelraster --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
    align-items: start;
}
.stats-grid .card { padding: 15px 18px; }
.stats-grid h2 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #5b4a3d;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}
.stats-grid .muted { font-size: 11px; margin: -4px 0 8px; }
.stats-grid .data-table { font-size: 13px; }
.stats-grid .data-table th {
    padding: 4px 0;
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
    font-weight: 400;
    color: var(--ink);
}
.stats-grid .data-table td {
    padding: 4px 0;
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #2d2a26;
}
.stats-grid .data-table tr { background: transparent !important; }

/* --- Audit: Filterleiste + Ereignistabelle --- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
    padding: 14px 18px;
    margin-bottom: 16px;
}
.filter-field { display: flex; flex-direction: column; gap: 5px; min-width: 150px; }
.filter-field label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}
/* Einheitliche Steuerelement-Hoehe, damit Selects, Datumsfeld und Buttons
   in der Filterleiste exakt auf einer Linie sitzen. */
.filter-field select,
.filter-field input {
    height: 38px;
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 10px;
    font: inherit;
    font-size: 13px;
    background: #fff;
    color: var(--ink);
}
.filter-field select:focus,
.filter-field input:focus { outline: none; border-color: var(--bg); }
.filter-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 38px;
    margin-left: auto;
}
.filter-actions .btn-primary {
    height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 0 18px;
}

.audit-card { padding: 6px 6px 4px; overflow-x: auto; }
.audit-table { font-size: 13px; }
.audit-table thead th {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}
.audit-table td { padding: 9px 12px; }
.audit-when { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.audit-target { color: var(--muted); font-size: 12px; white-space: nowrap; }
.audit-summary { color: #3a342e; }
.audit-system { color: var(--muted); font-style: italic; }
.audit-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    padding: 2px 8px;
    border-radius: 12px;
    background: #ece8e3;
    color: #5b4a3d;
    white-space: nowrap;
}
/* Farbcodierung nach Ereignisgruppe (Praefix vor dem ersten "_"). */
.audit-tag-login,
.audit-tag-logout   { background: #e8f2eb; color: #2f6b45; }
.audit-tag-topic    { background: #e6e0f4; color: #4a3a7a; }
.audit-tag-document { background: #e2edf7; color: #2b5775; }
.audit-tag-user     { background: #fde7d6; color: #8a5316; }
.audit-tag-poll     { background: #fde4e4; color: #9a3434; }
.audit-tag-settings,
.audit-tag-maintenance,
.audit-tag-backup,
.audit-tag-announcement { background: #fff4dc; color: #7a5615; }

.btn-secondary {
    background: #fff;
    color: var(--bg);
    border: 1px solid var(--bg);
    border-radius: 8px;
    padding: 8px 14px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
}
.badge-active { background: #e8f2eb; color: #2f6b45; }
.badge-muted { background: #ece8e3; color: var(--muted); }
.badge-locked { background: #f6e3e3; color: #9a3434; }
.badge-super { background: #e6e0f4; color: #4a3a7a; margin-left: 6px; }
.text-muted { color: var(--muted); font-size: 13px; font-style: italic; }

.card-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 14px;
    margin-bottom: 16px;
}
.card-head h1 { margin: 0; }
.table-actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.table-actions .inline-form { display: contents; }
.field-static { font-size: 14px; color: var(--muted); }

.field-check {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
}
.field-check input { width: 16px; height: 16px; }

fieldset.field { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
fieldset.field legend { font-size: 13px; font-weight: 600; padding: 0 6px; }
.perm-table { margin: 4px 0; }
.topic-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topic-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 14px 0; }
.placeholder-panel {
    border: 1.5px dashed var(--line);
    border-radius: 10px;
    padding: 22px;
    color: var(--muted);
    text-align: center;
    margin-top: 16px;
}
/* --- Diskrete Text-Aktionen (Themenaktionen + Dokument-Aktionen) --- */
/* Label-Typografie (Versalien, gesperrt) signalisiert: hier steckt eine Aktion. */
.text-action {
    background: none;
    border: none;
    color: var(--bg);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    line-height: 1.4;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    display: inline-block;
    transition: color 0.15s ease;
}
.text-action:hover { color: var(--bg-dark); text-decoration: underline; }
/* Aktionsformulare loesen ihre Box auf, damit Links und Buttons exakt
   auf einer Linie sitzen. */
.topic-actions .inline-form,
.doc-tile-actions .inline-form { display: contents; }
.is-hidden { display: none !important; }
.search-empty { color: var(--muted); font-size: 13px; margin-top: 12px; }

/* --- Dokumente-Panel --- */
.doc-panel-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.doc-panel-head h2 { margin: 0; }
.upload-form { margin: 0; }
.upload-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}
.upload-trigger { cursor: pointer; }

.doc-list {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* --- Scroll-Indikatoren (Doku-Liste + Chat) --- */
.scroll-shadow {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.scroll-shadow > [data-scroll-target] {
    flex: 1 1 0;
    min-height: 0;
}
.scroll-indicator {
    position: absolute;
    /* Rechter Rand mit etwas Abstand zur Scrollbar, damit der Indikator
       sichtbar bleibt, ohne den Scroll-Track zu verdecken. */
    right: 12px;
    background: rgba(255, 255, 255, 0.96);
    color: #7a5615;
    border: 1px solid #f0d8a8;
    border-radius: 14px;
    padding: 1px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    pointer-events: none;
    z-index: 4;
    transition: opacity 0.15s ease;
}
.scroll-indicator.scroll-up   { top: 4px; }
.scroll-indicator.scroll-down { bottom: 4px; }
.doc-tile {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.doc-tile:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07); border-color: #d8cfc4; }
.doc-num {
    flex-shrink: 0;
    width: 18px;
    text-align: right;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.doc-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.doc-ext {
    flex-shrink: 0;
    width: 42px;
    height: 30px;
    background: var(--bg);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
}
.doc-name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.doc-size { font-size: 11px; color: var(--muted); }
.doc-remarks {
    font-size: 12px;
    color: #5b4a3d;
    line-height: 1.45;
    margin-top: 4px;
    padding: 4px 8px;
    background: #faf7f3;
    border-left: 2px solid #d8cfc4;
    border-radius: 4px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.doc-tile-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.doc-empty { color: var(--muted); font-size: 13px; }
.viewer-body { background: #2b2622; }
.viewer-main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 22px;
}
.viewer-title { color: #faf8f6; font-size: 18px; }
.viewer-frame {
    width: 100%;
    height: 80vh;
    border: none;
    border-radius: 8px;
    background: #fff;
}
.viewer-image {
    max-width: 100%;
    border-radius: 8px;
    display: block;
}
.viewer-doc {
    background: #fff;
    border-radius: 8px;
    padding: 28px;
    min-height: 60vh;
    overflow-x: auto;
}
.viewer-doc table { border-collapse: collapse; }
.viewer-doc td, .viewer-doc th { border: 1px solid var(--line); padding: 4px 8px; }
.viewer-error {
    background: #fff;
    border-radius: 8px;
    padding: 18px 22px;
    color: #5b4a3d;
    font-size: 14px;
}
.viewer-error a { color: var(--bg); }

/* --- Text-Viewer (txt/csv/json/xml) --- */
.viewer-text {
    background: #fff;
    border-radius: 8px;
    padding: 16px 20px;
    min-height: 40vh;
    overflow-x: auto;
}
/* Dokument-Viewer auf Mobil: weniger Rand, damit der Inhalt den Schirm fuellt;
   Frame-Hoehe an die echte Viewport-Hoehe (dvh) statt fix 80vh koppeln, damit
   auf flachen Schirmen nichts abgeschnitten wird. */
@media (max-width: 720px) {
    .viewer-main { padding: 12px; }
    .viewer-doc { padding: 16px 14px; }
    .viewer-text { padding: 12px 14px; }
    .viewer-frame { height: 78dvh; }
}
.viewer-code {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
    color: #2d2a26;
    white-space: pre;
    tab-size: 4;
}
.viewer-code .tok-key      { color: #8b3a62; font-weight: 600; }
.viewer-code .tok-string   { color: #2f6b45; }
.viewer-code .tok-number   { color: #b25e09; }
.viewer-code .tok-bool     { color: #3060a0; font-weight: 600; }
.viewer-code .tok-null     { color: #888; font-style: italic; }
.viewer-code .tok-tag      { color: #a32f4a; font-weight: 600; }
.viewer-code .tok-attr     { color: #8b6b00; }
.viewer-code .tok-punc     { color: #888; }
.viewer-code .tok-comment  { color: #777; font-style: italic; }

.viewer-csv {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
}
.viewer-csv th,
.viewer-csv td {
    border: 1px solid #d8d2cc;
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
}
.viewer-csv thead th {
    background: #f0ebe6;
    color: #3a322b;
    font-weight: 600;
    position: sticky;
    top: 0;
}
.viewer-csv tbody tr:nth-child(even) { background: #faf7f3; }

/* --- PowerPoint-Viewer --- */
.pptx-viewer {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.pptx-slide {
    background: #fff;
    border-radius: 8px;
    padding: 22px 26px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.pptx-slide-head {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #a08a78;
    margin-bottom: 10px;
}
.pptx-slide-title {
    margin: 0 0 12px 0;
    font-size: 20px;
    color: #2d2a26;
}
.pptx-slide-line {
    margin: 4px 0;
    color: #3a342e;
    font-size: 15px;
    line-height: 1.5;
}
.pptx-slide-empty {
    color: #aaa;
    font-style: italic;
    margin: 0;
}
.pptx-slide-notes {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px dashed #d8d2cc;
    font-size: 13px;
    color: #666;
}
.pptx-slide-notes summary { cursor: pointer; color: #5b4a3d; }
.chat-panel h2 { margin-top: 0; }
.chat-stream {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 6px 2px;
    background: linear-gradient(#fdfcfb, #faf8f6);
    border-radius: 8px;
}
.chat-msg { max-width: 78%; }
.chat-msg-mine { align-self: flex-end; }
.chat-who { font-size: 10px; color: var(--muted); margin: 0 0 3px 4px; }
.chat-msg-mine .chat-who { text-align: right; margin: 0 4px 3px 0; }
.chat-bubble {
    font-size: 13px;
    line-height: 1.45;
    padding: 8px 12px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-bottom-left-radius: 3px;
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-msg-mine .chat-bubble {
    background: var(--bg);
    color: #fff;
    border: none;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 3px;
}
.chat-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-top: 12px;
    position: relative;
}
.chat-input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 9px 11px;
    font: inherit;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
}
/* Schmale Schirme: das Eingabefeld bekommt eine eigene volle Zeile, die
   Aktions-Buttons rutschen darunter — sonst wird das Feld zu schmal und der
   Platzhalter „Nachricht schreiben …" bricht um bzw. wird abgeschnitten. */
@media (max-width: 560px) {
    .chat-form { flex-wrap: wrap; }
    .chat-input { order: -1; flex: 1 1 100%; }
    .chat-form > .btn-primary { margin-left: auto; }
}
.chat-link { color: inherit; text-decoration: underline; }
.emoji-button {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 9px;
    width: 38px;
    height: 38px;
    font-size: 18px;
    cursor: pointer;
}
.chat-closed { color: var(--muted); font-size: 13px; margin-top: 12px; }
.chat-panel-closed {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
    flex: 1.2 1 0;
}
.emoji-popover {
    position: absolute;
    bottom: 48px;
    left: 0;
    width: 280px;
    max-width: calc(100vw - 32px);
    max-height: 260px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
    padding: 8px;
    z-index: 20;
}
.emoji-cat {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
    margin: 8px 4px 4px;
}
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-item {
    border: none;
    background: none;
    font-size: 18px;
    padding: 4px 0;
    border-radius: 6px;
    cursor: pointer;
}
.emoji-item:hover { background: #f3eee8; }
.unread-badge {
    background: var(--bg);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 7px;
    flex-shrink: 0;
}
.badge-new {
    background: var(--gold);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: 10px;
    padding: 2px 7px;
    flex-shrink: 0;
}
.badge-changed {
    color: #c98a2b;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
    /* eingebettet als reiner Punkt, ohne Hintergrund */
}

/* --- Topic-Seite: Hinweisbanner "Es gab Aenderungen" --- */
.topic-changed-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff4dc;
    border: 1px solid #f0d8a8;
    border-left: 4px solid #c98a2b;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    color: #4a3520;
    font-size: 13px;
}
.topic-changed-icon { color: #c98a2b; font-size: 14px; flex-shrink: 0; }

/* --- Pro-Bereich-Markierung: Bemerkungen / Dokumente seit dem letzten Besuch geaendert --- */
.doc-new-badge {
    display: inline-block;
    background: var(--gold);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: 10px;
    padding: 1px 6px;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
}

.section-changed-badge {
    display: inline-block;
    margin-left: 8px;
    color: #c98a2b;
    font-size: 12px;
    vertical-align: middle;
    line-height: 1;
}
.section-changed {
    box-shadow: inset 3px 0 0 #c98a2b;
}
.topic-changed-text { flex: 1 1 auto; }
.topic-changed-close {
    appearance: none;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 0 4px;
    opacity: 0.55;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}
.topic-changed-close:hover,
.topic-changed-close:focus { opacity: 1; outline: none; }

/* --- Chat: Trennlinie "Neue Nachrichten" zwischen alten und neuen Posts --- */
.chat-unread-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #c98a2b;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 6px 0 2px 0;
}
.chat-unread-divider::before,
.chat-unread-divider::after {
    content: '';
    flex: 1 1 auto;
    height: 1px;
    background: #f0d8a8;
}

/* --- Themenseite: zweispaltiges Layout mit fester Hoehe --- */
.topic-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.topic-view .card { padding: 16px 20px; }
.topic-card { flex: 0 0 auto; }
.topic-card h1 { margin: 0; font-size: 20px; }
.topic-view .topic-actions { margin: 12px 0 0; }

.topic-body {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    gap: 14px;
}
.topic-col-left {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.chat-panel { flex: 1.2 1 0; }
.topic-remarks-panel { flex: 0 0 auto; }
.doc-panel { flex: 1 1 0; }
.topic-remarks-panel,
.doc-panel,
.chat-panel {
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.topic-view h2 { flex: 0 0 auto; margin: 0 0 10px; font-size: 15px; }
.chat-form,
.chat-closed { flex: 0 0 auto; }

/* Dokumente: Farbcodierung nach Dateityp */
/* Papierkorb wird innerhalb der Dokumentenliste angehaengt — kein
   eigener Card-Container. Optisch durch eine duenne Trennlinie und
   leicht eingerueckte Tiles abgesetzt. */
.doc-trash-section {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed #d8d2cc;
    /* Gleicher Tile-Abstand wie in der aktiven Dokumentenliste. */
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.doc-trash-head {
    margin-bottom: 0;
}
.doc-trash-head h3 {
    margin: 0;
    font-size: 14px;
    color: #6c5b4d;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.doc-trash-head .doc-count {
    font-weight: 400;
    color: var(--muted);
    font-size: 12px;
    margin-left: 6px;
}
.doc-trash-hint {
    color: #8a7d70;
    font-size: 12px;
    margin: 2px 0 10px 0;
    font-style: italic;
}
.doc-tile-trashed { opacity: 0.85; background: #faf7f3; }
.doc-force-delete-btn { color: #9a3434; }

.doc-ext-pdf { background: #c0392b; }
.doc-ext-word { background: #2b5797; }
.doc-ext-xls { background: #1e7145; }
.doc-ext-ppt { background: #d24726; }
.doc-ext-text { background: #5b6770; }
.doc-ext-img { background: #7a5ba6; }
.doc-ext-other { background: var(--muted); }
.doc-count { font-size: 12px; font-weight: 400; color: var(--muted); }

/* Bemerkungen-Panel (einklappbar) */
.topic-remarks-label {
    flex: 0 0 auto;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 4px;
}
.remarks-text {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}
.remarks-text.expanded {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
}
.remarks-toggle {
    align-self: flex-start;
    margin-top: 6px;
    background: none;
    border: none;
    padding: 0;
    color: var(--bg);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.remarks-toggle:hover { color: var(--bg-dark); }

/* Formatierungsleiste im Bemerkungen-Formular */
.remarks-toolbar { display: flex; flex-wrap: wrap; gap: 4px; }
.remarks-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.remarks-btn:hover { background: #f3eee8; }
.remarks-editor {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 11px;
    min-height: 110px;
    background: #fff;
    font: inherit;
    line-height: 1.5;
}
.remarks-editor:focus { outline: none; border-color: var(--bg); }
.remarks-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
}
.remarks-editor a { color: var(--bg); }

/* Link-Edit-Popover (Bearbeiten/Loeschen eines Links im Editor) */
.link-popover {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    /* Auf schmalen Schirmen nicht breiter als der Viewport (vorher fixe
       min-width:360px -> Ueberlauf unter ~392px). */
    width: min(520px, calc(100vw - 24px));
}
.link-popover-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.link-popover-error {
    font-size: 12px;
    padding: 4px 2px 0;
}
.link-popover-error-error { color: #9a3434; }
.link-popover-error-busy { color: var(--muted); font-style: italic; }
.link-popover[hidden] { display: none; }
.link-popover-label {
    flex-basis: 100%;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 2px;
}
.link-popover input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 7px 10px;
    font: inherit;
    background: #fff;
}
.link-popover input:focus { outline: none; border-color: var(--bg); }
.link-popover-save,
.link-popover-cancel {
    border: none;
    border-radius: 6px;
    padding: 7px 12px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.link-popover-save { background: var(--bg); color: #fff; }
.link-popover-save:hover { background: var(--bg-dark); }
.link-popover-cancel { background: #e7e1da; color: var(--ink); }
.link-popover-cancel:hover { background: #d8d0c5; }
.link-popover-delete {
    background: #f6e3e3;
    color: #9a3434;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.link-popover-delete:hover { background: #e9c6c6; }

/* Hover-Effekte fuer Buttons */
.btn-primary,
.btn-secondary,
.linkbtn,
.emoji-button { transition: background-color 0.15s ease, color 0.15s ease; }
.btn-primary:hover { background: var(--bg-dark); }
.btn-secondary:hover { background: var(--bg); color: #fff; }
.linkbtn:hover { background: rgba(255, 255, 255, 0.16); }
.emoji-button:hover { background: #f3eee8; }


/* Benutzerfarben */
.user-color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

.chat-author { font-weight: 600; }
.chat-function { color: var(--muted); }

/* --- Sidebar-Suche --- */
.sidebar-search {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: 12px;
    color: var(--ink);
}
.sidebar-search:focus {
    outline: none;
    border-color: var(--bg);
}
.sidebar-search::placeholder { color: var(--muted); }

/* --- Themen-/Archiv-Liste: Suche --- */
.topic-list-search {
    display: block;
    margin-bottom: 14px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    width: 100%;
    max-width: 360px;
}
.topic-list-search:focus {
    outline: none;
    border-color: var(--bg);
}
.topic-list-search::placeholder { color: var(--muted); }

/* --- Themen-Karten (gemeinsam fuer aktive Themen und Archiv) --- */
.topic-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}
.topic-tile {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 16px;
    background: #fff;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.topic-tile:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    border-color: #d8cfc4;
}
.topic-tile-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}
.topic-tile-title {
    flex: 1 1 auto;
    min-width: 0;
}
.topic-title-link {
    color: #2d2a26;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none;
}
.topic-title-link:hover { color: var(--bg); text-decoration: underline; }
.topic-tile-title .topic-badge-slot {
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}
.topic-tile-meta {
    flex-shrink: 0;
    display: flex;
    align-items: baseline;
    gap: 12px;
}
.topic-doc-count {
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.topic-date {
    color: var(--muted);
    font-size: 12px;
}

.topic-tile-remarks { margin-top: 6px; }
.topic-remarks {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    /* Standard: zwei Zeilen sichtbar, der Rest ist via Toggle ausklappbar. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.topic-remarks.expanded {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
}
.topic-remarks strong { color: #3a342e; font-weight: 600; }
.topic-remarks em { font-style: italic; }
.topic-remarks u { text-decoration: underline; }
.topic-remarks s { text-decoration: line-through; }
.topic-remarks a {
    color: var(--bg);
    text-decoration: underline;
}
.topic-remarks a:hover { color: #3a2a1a; }
.topic-remarks br { display: block; content: ''; margin-top: 2px; }
.topic-remarks-toggle {
    background: transparent;
    border: 0;
    padding: 2px 0;
    margin-top: 4px;
    color: var(--bg);
    font-size: 12px;
    cursor: pointer;
}
.topic-remarks-toggle:hover { text-decoration: underline; }

.topic-tile-actions {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    border-top: 1px solid #f0ebe6;
    padding-top: 8px;
}
.topic-tile-actions .inline-form { display: contents; }
.topic-force-delete-btn { color: #9a3434; }

/* --- Wichtige Meldung (Dashboard, ganz oben) --- */
.announcement-card {
    border-radius: 10px;
    padding: 14px 18px 16px 18px;
    margin-bottom: 18px;
    background: #fff7e6;
    border: 1px solid #f0d8a8;
    border-left: 4px solid #c98a2b;
    box-shadow: 0 1px 3px rgba(180, 130, 40, 0.08);
}
.announcement-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 6px;
}
.announcement-icon {
    background: #c98a2b;
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}
.announcement-label {
    font-size: 12px;
    font-weight: 600;
    color: #7a5615;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    flex: 1 1 auto;
}
.announcement-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 12px;
}
.announcement-actions .text-action { color: #7a5615; }
.announcement-actions .inline-form { display: contents; }
.announcement-body {
    color: #3a2a0d;
    font-size: 14px;
    line-height: 1.55;
}
.announcement-body strong { color: #2d2007; font-weight: 700; }
.announcement-body a {
    color: #7a5615;
    text-decoration: underline;
}
.announcement-empty {
    margin: 0 0 14px 0;
    font-size: 12px;
}
.form-actions {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-top: 18px;
}

/* --- Wartungsmodus --- */
/* Hinweis-Karte im Login-Bereich, wenn der Wartungsmodus aktiv ist. */
.login-maintenance-notice {
    max-width: 420px;
    margin: 0 auto 16px auto;
    background: #fff7e6;
    border-left: 4px solid #c98a2b;
    color: #4a3520;
}
.login-maintenance-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #7a5615;
    margin-bottom: 6px;
}
.login-maintenance-icon { color: #c98a2b; font-size: 14px; }
.login-maintenance-text {
    margin: 0;
    color: #3a2a0d;
    font-size: 14px;
    line-height: 1.55;
}

.maintenance-strip {
    background: #fde4cc;
    color: #6b3a05;
    text-align: center;
    padding: 8px 16px;
    font-size: 13px;
    border-bottom: 1px solid #e8c8a8;
}
.maintenance-strip a {
    color: #6b3a05;
    margin-left: 8px;
    text-decoration: underline;
}
.maintenance-card {
    max-width: 560px;
    /* Auf flachen/kleinen Schirmen nicht 160px vertikalen Rand verschwenden. */
    margin: clamp(24px, 8vh, 80px) auto;
    text-align: center;
}
.maintenance-title {
    margin: 0 0 12px 0;
    font-size: 22px;
    color: #4a3520;
}
.maintenance-icon {
    display: inline-block;
    color: #c98a2b;
    margin-right: 8px;
}
.maintenance-lead {
    color: #5b4a3d;
    font-size: 15px;
    margin: 0 0 14px 0;
}
.maintenance-message {
    background: #fff7e6;
    border-left: 3px solid #c98a2b;
    border-radius: 8px;
    padding: 12px 16px;
    text-align: left;
    color: #3a2a0d;
    font-size: 14px;
    line-height: 1.55;
    margin: 0 0 16px 0;
}
.topic-restore-target {
    color: var(--muted);
    font-weight: 400;
    font-size: 12px;
    margin-left: 2px;
    white-space: nowrap;
}
.topic-trashed-restore-hint {
    margin: 0 0 14px 0;
    color: #5b4a3d;
    font-size: 13px;
}
.topic-trashed-restore-hint strong { color: #3a342e; }

/* --- Trashed-Topic-Ansicht (Admin oeffnet ein Thema aus dem Papierkorb) --- */
.topic-trashed-card {
    background: #faf7f3;
    border: 1px dashed #d8d2cc;
}
.topic-trashed-head { margin-bottom: 14px; }
.topic-trashed-badge {
    display: inline-block;
    background: #ece8e3;
    color: #6c5b4d;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}
.topic-trashed-title {
    margin: 0;
    color: #4a3f33;
    font-size: 22px;
}
.topic-trashed-meta {
    margin: 4px 0 0 0;
    color: var(--muted);
    font-size: 12px;
}
.topic-trashed-hint {
    color: #6c5b4d;
    font-size: 13px;
    background: #fff;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 14px 0;
}
.topic-trashed-section { margin-top: 18px; }
.topic-trashed-section h2 {
    font-size: 14px;
    color: #5b4a3d;
    margin: 0 0 8px 0;
}
.topic-trashed-count {
    color: var(--muted);
    font-weight: 400;
    font-size: 12px;
    margin-left: 6px;
}
.topic-trashed-remarks {
    background: #fff;
    border-radius: 8px;
    padding: 10px 14px;
    color: #3a342e;
    font-size: 13px;
    line-height: 1.5;
}
.topic-trashed-remarks a {
    color: var(--bg);
    text-decoration: underline;
}
.topic-trashed-empty {
    color: var(--muted);
    font-style: italic;
    font-size: 13px;
    margin: 0;
}
.topic-trashed-doc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.topic-trashed-doc-list li {
    background: #fff;
    border: 1px solid #ece6df;
    border-radius: 8px;
    padding: 6px 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    font-size: 13px;
}
.topic-trashed-doc-name { flex: 1 1 auto; color: #3a342e; }
.topic-trashed-doc-size { color: var(--muted); font-size: 12px; }
.topic-trashed-doc-flag {
    color: #9a3434;
    font-size: 11px;
    font-style: italic;
}
.topic-trashed-actions {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid #e8e2db;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.topic-trashed-actions .inline-form { display: contents; }

/* --- Einstellungen-Seite: Sektionskarten --- */
/* Kompaktes, mehrspaltiges Layout statt rein untereinander – aber bewusst
   deterministisch ueber Flex/Grid-Spalten, NICHT ueber CSS-Mehrspalten-Fluss
   (columns/column-span). Letzterer erzeugte in WebKit/Blink Render-Artefakte
   (eine Karte erschien als "Geist" oberhalb der Trennlinie). */
.settings-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-width: 920px;
}
/* Persoenlicher Block (Profil + Passwort) und die System-Spalten teilen sich
   jeweils zwei gleich breite Spalten; Trennlinie, Intro, Flash und die
   "Ueber"-Karte sind direkte Flex-Kinder und damit automatisch volle Breite. */
.settings-pair,
.settings-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}
/* Jede System-Spalte stapelt ihre Karten dicht (fest verteilt, daher keine
   Luecken neben hohen Karten). */
.settings-column {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}
@media (max-width: 760px) {
    .settings-pair,
    .settings-columns { grid-template-columns: 1fr; }
}
.settings-section {
    margin: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px 20px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}
.settings-section-title {
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}
.settings-section .form { gap: 13px; }

/* --- Backup & Wiederherstellung --- */
.backup-warning {
    background: #fff4dc;
    border-left: 4px solid #c98a2b;
    color: #4a3520;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.55;
    margin-bottom: 18px;
}
.backup-warning strong { color: #2d2007; }
.backup-warning code {
    background: rgba(255, 255, 255, 0.65);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}
.backup-restore-form { margin-top: 22px; }
.backup-restore-btn { color: #9a3434; font-weight: 600; }

/* --- "Ueber"-Sektion am Ende der Einstellungen --- */
.settings-about-line {
    margin: 0 0 8px 0;
    color: #3a342e;
    font-size: 14px;
    line-height: 1.55;
}
.settings-about-line a { color: var(--bg); text-decoration: underline; }
.settings-about-contact { color: #6c5b4d; font-size: 13px; }

/* --- App-Footer (Auth + Portal) --- */
.app-footer {
    text-align: center;
    padding: 16px 20px;
    /* margin-top: auto schiebt den Footer ans untere Body-Ende, wenn
       Inhalt + Header die Viewport-Hoehe nicht ausfuellen. */
    margin-top: auto;
    color: var(--muted);
    font-size: 12px;
    border-top: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.02);
}
.app-footer-brand { color: #5b4a3d; font-weight: 600; }
.app-footer-sep   { margin: 0 8px; opacity: 0.6; }
.app-footer a {
    color: #5b4a3d;
    text-decoration: none;
    border-bottom: 1px dotted #5b4a3d;
}
.app-footer a:hover { color: var(--bg); border-bottom-color: var(--bg); }
.settings-section .field input {
    background: var(--paper);
}
.settings-section .field input:focus {
    outline: none;
    border-color: var(--bg);
    background: #fff;
}
.settings-section .field-check {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
}
.settings-section .btn-primary {
    align-self: flex-start;
    padding: 10px 22px;
}
.settings-divider {
    border: 0;
    border-top: 2px dashed #d8d2cc;
    margin: 6px 0;
}
.settings-system-intro {
    color: #6c5b4d;
    font-size: 13px;
    background: #faf7f3;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 0;
}
.settings-subhead {
    font-size: 13px;
    margin: 12px 0 4px 0;
    color: #5b4a3d;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.settings-mail-test {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #ece6df;
}
.field-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.field-row > .field { flex: 1 1 180px; min-width: 160px; }
.field-hint {
    margin: 4px 0 0 0;
    color: var(--muted);
    font-size: 12px;
}
.field-hint-inline { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 6px; }

/* Themenseite auf schmalen/mittleren Schirmen (inkl. Landscape-Phones und
   kleinen Tablets): natuerlicher Block-Fluss statt des hohen 2-Spalten-
   Layouts, das erst ab ~1024px genug Platz hat. */
@media (max-width: 900px) {
    .topic-view,
    .topic-body,
    .topic-col-left { display: block; }
    .topic-remarks-panel,
    .doc-panel,
    .chat-panel {
        display: block;
        margin-bottom: 14px;
    }
    /* Auf Mobil sind die Karten Block-Container ohne Flex-Hoehe — die
       Scroll-Wrapper duerfen den inneren Target nicht mehr auf flex:1
       kommandieren, sonst kollabiert er auf 0px Hoehe. Stattdessen
       greift das natuerliche Block-Layout, begrenzt durch max-height. */
    .scroll-shadow {
        display: block;
        flex: none;
        min-height: 0;
    }
    .scroll-shadow > [data-scroll-target] {
        flex: none;
    }
    .doc-list { max-height: 45vh; }
    .chat-stream { max-height: 55vh; }
}

/* --- Poll-Widget im Chat --- */
.poll-widget {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 12px 14px;
    max-width: 340px;
    font-size: 13px;
}
.poll-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 6px;
}
.poll-question {
    font-weight: 700;
    font-size: 14px;
    color: var(--ink);
    margin-bottom: 10px;
    line-height: 1.35;
}
.poll-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}
.poll-option {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    background: #faf8f6;
    text-align: left;
    font: inherit;
    width: 100%;
}
.poll-option:hover:not(:disabled) {
    border-color: var(--bg);
    background: #f3eee8;
}
.poll-option.poll-option-selected {
    border-color: var(--bg);
    background: var(--bg);
    color: #fff;
}
.poll-option:disabled {
    cursor: default;
}
.poll-option-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.poll-option-label {
    font-weight: 600;
    font-size: 13px;
}
.poll-option-count {
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}
.poll-option-selected .poll-option-count {
    color: rgba(255,255,255,0.85);
}
.poll-option-voters {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.3;
}
.poll-option-selected .poll-option-voters {
    color: rgba(255,255,255,0.75);
}
.poll-closed-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    background: #ece8e3;
    border-radius: 10px;
    padding: 2px 8px;
    margin-bottom: 8px;
}
.poll-close-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 6px 10px;
    background: none;
    border: 1px solid var(--bg);
    border-radius: 7px;
    color: var(--bg);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.poll-close-btn:hover {
    background: var(--bg);
    color: #fff;
}

/* --- Abstimmung-erstellen-Button und Formular --- */
.poll-create-btn {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 9px;
    width: 38px;
    height: 38px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    flex-shrink: 0;
}
.poll-create-btn:hover { background: #f3eee8; }

.poll-create-form {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #faf8f6;
    padding: 14px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.poll-create-form input[type="text"] {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 7px 10px;
    font: inherit;
    font-size: 13px;
    background: #fff;
    width: 100%;
}
.poll-create-form input[type="text"]:focus {
    outline: none;
    border-color: var(--bg);
}
.poll-create-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
    margin-bottom: 2px;
}
.poll-create-options {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.poll-create-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.poll-add-option-btn {
    background: none;
    border: 1px dashed var(--muted);
    border-radius: 7px;
    padding: 5px 10px;
    font: inherit;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.poll-add-option-btn:hover {
    border-color: var(--bg);
    color: var(--bg);
}
.poll-submit-btn {
    background: var(--bg);
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 7px 14px;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.poll-submit-btn:hover { background: var(--bg-dark); }
.poll-cancel-btn {
    background: none;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 7px 12px;
    font: inherit;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.poll-cancel-btn:hover {
    border-color: var(--muted);
    color: var(--ink);
}
