/* ==========================================================================
   PCX Forum – Drei-Bereich-Ansicht
   Farben als Tokens, Dunkelmodus automatisch oder per data-theme.
   ========================================================================== */

:root {
    --bg: #eef1f5;
    --surface: #ffffff;
    --surface-2: #f6f8fb;
    --text: #1b2230;
    --muted: #5d6779;
    --border: #d8dde6;
    --accent: #1f5fbf;
    --accent-text: #ffffff;
    --link: #1a56b0;
    --link-visited: #6b3fa8;
    --active: #e3edff;
    --active-border: #1f5fbf;
    --hover: #f1f5fc;
    --highlight: #b0430c;
    --quote-1: #2f7a4f;
    --quote-2: #9a5a00;
    --quote-3: #6b3fa8;
    --tree-line: #cfd6e2;
    --unread: #d9480f;
    --own-bg: #dff3e6;
    --error: #a61b1b;
    --error-bg: #fdecec;
    --shadow: 0 1px 2px rgb(16 24 40 / 6%);
    --backdrop: rgb(16 24 40 / 35%);
    /* Das alte Logo ist weiss: auf hellem Grund mit Kontur */
    --logo-filter: drop-shadow(0 0 1px rgb(0 0 0 / 60%)) drop-shadow(0 1px 2px rgb(0 0 0 / 25%));

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size: 14px;
    --indent: 14px;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f1216;
        --own-bg: #1f3a2a;
        --surface: #171b21;
        --logo-filter: none;
        --surface-2: #1c2129;
        --text: #e4e8ef;
        --muted: #98a2b3;
        --border: #2a313c;
        --accent: #5b8def;
        --accent-text: #0b0e12;
        --link: #8ab4ff;
        --link-visited: #c2a3f5;
        --active: #1e2b44;
        --active-border: #5b8def;
        --hover: #1f252e;
        --highlight: #ff9d5c;
        --quote-1: #6fcf97;
        --quote-2: #f2c063;
        --quote-3: #c2a3f5;
        --tree-line: #333b47;
        --unread: #ff8a4c;
        --error: #ffb4b4;
        --error-bg: #3a1d1d;
        --shadow: none;
        --backdrop: rgb(0 0 0 / 55%);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --backdrop: rgb(0 0 0 / 55%);
    --own-bg: #1f3a2a;
    --logo-filter: none;
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1c2129;
    --text: #e4e8ef;
    --muted: #98a2b3;
    --border: #2a313c;
    --accent: #5b8def;
    --accent-text: #0b0e12;
    --link: #8ab4ff;
    --link-visited: #c2a3f5;
    --active: #1e2b44;
    --active-border: #5b8def;
    --hover: #1f252e;
    --highlight: #ff9d5c;
    --quote-1: #6fcf97;
    --quote-2: #f2c063;
    --quote-3: #c2a3f5;
    --tree-line: #333b47;
    --unread: #ff8a4c;
    --error: #ffb4b4;
    --error-bg: #3a1d1d;
    --shadow: none;
    color-scheme: dark;
}

/* ---------- Grundlayout ---------- */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font: var(--font-size)/1.45 var(--font);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a[aria-disabled="true"] { color: var(--muted); cursor: not-allowed; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Kopfzeile ---------- */

.topbar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .45rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    min-width: 0;
}

.brand {
    flex: none;
    display: block;
    width: 2.5rem;
    height: 2.5rem;
    margin: -.15rem 0;
}
.brand img { display: block; width: 100%; height: 100%; }
.brand:hover { text-decoration: none; filter: brightness(1.08) drop-shadow(0 0 3px rgba(255, 255, 255, .25)); }

/* Nur die Beschreibung wird gekürzt; wird es enger als der Name, klappt die Navigation ins Menü */
.board-name { flex: 1 1 auto; display: flex; align-items: baseline; gap: .6rem; }
.board-name strong { font-size: 1.05rem; white-space: nowrap; }
.board-desc { flex: 1 1 0; min-width: 0; contain: inline-size; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topnav { display: flex; gap: 1.1rem; margin-left: auto; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 1.1rem;
    line-height: 1;
}
.icon-btn:hover { background: var(--hover); }

.btn-link {
    padding: .5rem 0;
    border: 0;
    background: none;
    color: var(--link);
    font: inherit;
    cursor: pointer;
}

/* ---------- Drei Bereiche ---------- */

/* Standard: übereinander. --s1 ist die Grösse der Threadliste, --s2 die des Baums
   (Höhe oder Breite, je nach Anordnung) – gesetzt von den Teilern. */
.panes {
    display: grid;
    grid-template-rows: var(--s1, 34%) 7px var(--s2, 26%) 7px minmax(0, 1fr);
    min-height: 0;
    padding: .5rem;
    gap: 0;
}

/* Weitere Anordnungen (nur Desktop), gewählt über die Kopfzeile: <html data-layout="…"> */
@media (min-width: 721px) and (min-height: 501px) {
    :root[data-layout] #pane-threads { grid-area: threads; }
    :root[data-layout] #pane-thread { grid-area: thread; }
    :root[data-layout] #pane-message { grid-area: message; }
    :root[data-layout] [data-splitter="threads"] { grid-area: s1; }
    :root[data-layout] [data-splitter="thread"] { grid-area: s2; }

    /* Liste links in voller Höhe, rechts Baum über Nachricht */
    :root[data-layout="left"] .panes {
        grid-template-columns: var(--s1, 38%) 7px minmax(0, 1fr);
        grid-template-rows: var(--s2, 32%) 7px minmax(0, 1fr);
        grid-template-areas: "threads s1 thread" "threads s1 s2" "threads s1 message";
    }
    /* Links Liste über Baum, rechts die Nachricht in voller Höhe */
    :root[data-layout="right"] .panes {
        grid-template-columns: var(--s2, 42%) 7px minmax(0, 1fr);
        grid-template-rows: var(--s1, 55%) 7px minmax(0, 1fr);
        grid-template-areas: "threads s2 message" "s1 s2 message" "thread s2 message";
    }
    /* Liste oben über die ganze Breite, darunter Baum neben Nachricht */
    :root[data-layout="top"] .panes {
        grid-template-columns: var(--s2, 36%) 7px minmax(0, 1fr);
        grid-template-rows: var(--s1, 34%) 7px minmax(0, 1fr);
        grid-template-areas: "threads threads threads" "s1 s1 s1" "thread s2 message";
    }
    /* Drei Spalten nebeneinander */
    :root[data-layout="columns"] .panes {
        grid-template-columns: var(--s1, 30%) 7px var(--s2, 26%) 7px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
        grid-template-areas: "threads s1 thread s2 message";
    }

    /* Senkrechte Teiler */
    :is(:root[data-layout="left"] [data-splitter="threads"],
        :root[data-layout="right"] [data-splitter="thread"],
        :root[data-layout="top"] [data-splitter="thread"],
        :root[data-layout="columns"] .splitter) {
        cursor: col-resize;
        --grip-w: 3px;
        --grip-h: 42px;
    }
}

.pane {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    scrollbar-gutter: stable;
}

.splitter {
    cursor: row-resize;
    position: relative;
    touch-action: none;
}
.splitter::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--grip-w, 42px);
    height: var(--grip-h, 3px);
    border-radius: 2px;
    background: var(--border);
    transform: translate(-50%, -50%);
}
.splitter:hover::after, .splitter:focus-visible::after { background: var(--accent); }

.pane-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: .6rem;
    min-height: 2.3rem;
    padding: .3rem .75rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.pane-title {
    margin: 0;
    font-size: .95rem;
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pane-sub { color: var(--muted); white-space: nowrap; margin-left: auto; font-size: .85rem; }
.pane-empty { margin: 0; padding: 1rem .9rem; color: var(--muted); }
.back { display: none; }

.is-highlight { color: var(--highlight); font-weight: 600; }

/* ---------- Threadliste ---------- */

/* Threadliste und Baum in Verdana wie im alten Forum. Eine Stufe kleiner als der Rest, weil Verdana
   bei gleicher Grösse grösser wirkt. Nur ganze Pixel (13/11, Handy 14/12): Verdana ist dafür gezeichnet
   und wirkt bei Zwischengrössen wie 13,65px unscharf und breiter */
.threadlist, .tree {
    --list-small: calc(var(--font-size) - 3px);
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: calc(var(--font-size) - 1px);
}

.threadlist {
    list-style: none;
    margin: 0;
    padding: .2rem 0;
}

.threadlist > li.t { border-left: 3px solid transparent; }
.threadlist > li.t:hover { background: var(--hover); }
.threadlist > li.t, .tree > li { cursor: pointer; }
/* Ganze Zeile ist der Link, die Markierung zeigt die Auswahl – kein Unterstreichen
   (auf dem Handy bliebe es nach dem Tippen hängen) */
.threadlist a:hover, .tree a:hover { text-decoration: none; }
.threadlist > li.is-active { background: var(--active); border-left-color: var(--active-border); }

.t-subject:visited { color: var(--link-visited); }
.t-date, .t-last { font-variant-numeric: tabular-nums; white-space: nowrap; }
.t-replies { font-variant-numeric: tabular-nums; }

.is-fixed .t-subject { font-weight: 650; }
.is-fixed .t-subject::before { content: "📌 "; }
.is-closed .t-subject::after { content: " 🔒"; font-size: .8em; }

.threadlist > li.more { padding: 0 .75rem; }

/* Fliesstext wie im alten Forum (Standard):
   «Betreff - Autor am Datum ( Views: 12 | Antworten: 3 | Letzte: Datum )».
   Bricht eine Zeile um, ist der Rest hängend eingerückt – so bleibt jeder Thread ein Block. */
:root:not([data-threadlist="table"]) .threadlist > li.t {
    padding: .1rem .75rem .1rem calc(.75rem + 1.2em);
    text-indent: -1.2em;
    line-height: 1.4;
}
/* nur die Zeile selbst einrücken – nicht Inline-Blöcke darin (📌 bei ungelesen) */
:root:not([data-threadlist="table"]) .threadlist > li.t > * { text-indent: 0; }
/* Titel grösser, der Rest kleiner – wie im alten Forum (10pt zu 8pt) */
:root:not([data-threadlist="table"]) .t-meta { color: var(--muted); font-size: var(--list-small); }
/* Wort und Wert zusammenhalten: kein Umbruch zwischen «Views:» und der Zahl, keine «)» allein */
:root:not([data-threadlist="table"]) .t-group { white-space: nowrap; }
:root:not([data-threadlist="table"]) .t-author { font-weight: 600; }
:root:not([data-threadlist="table"]) .t-author:not(.is-highlight) { color: var(--text); }
/* ohne Antworten: kein «Letzte» (nur die Tabelle zeigt dann das Datum) */
:root:not([data-threadlist="table"]) .t-meta > time.t-last { display: none; }
.t-last:visited { color: var(--link-visited); }

/* Tabelle mit Spalten (umschaltbar, im Browser gespeichert); die Köpfe (.tl-head) im selben Raster */
:root[data-threadlist="table"] .threadlist > li.t,
:root[data-threadlist="table"] .tl-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 9rem 6.8rem 3.6rem 3.2rem 6.8rem;
    align-items: baseline;
    gap: .75rem;
    padding: .1rem .75rem;
    line-height: 1.4;
}
:root[data-threadlist="table"] :is(.t-meta, .t-group) { display: contents; }
:root[data-threadlist="table"] .t-label { display: none; }
:root[data-threadlist="table"] .t-subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root[data-threadlist="table"] .t-author { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root[data-threadlist="table"] :is(.t-date, .t-last) { color: var(--muted); font-size: var(--list-small); }
:root[data-threadlist="table"] :is(.t-views, .t-replies) { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
/* Das Datum der letzten Antwort führt zu ihr – beim Überfahren als Link erkennbar */
@media (hover: hover) {
    :root[data-threadlist="table"] a.t-last:hover { color: var(--link); text-decoration: underline; }
}

/* Kopf mit den Spaltennamen, nur in der breiten Tabelle */
.tl-head { display: none; }
:root[data-threadlist="table"] .tl-head {
    position: sticky;
    top: 0;
    z-index: 1;
    border-left: 3px solid transparent; /* wie die Zeilen, damit die Spalten genau übereinander stehen */
    padding-block: .3rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: .8rem;
}
.tl-col { white-space: nowrap; }
:is(.tl-col-views, .tl-col-replies) { text-align: right; }

/* Schmale Liste (z. B. links oder in drei Spalten): zweizeilig wie auf dem Handy, Views und Antworten
   mit Zeichen statt eigener Spalte, ohne Spaltenköpfe */
#pane-threads { container: threads / inline-size; }
@container threads (max-width: 46rem) {
    :root[data-threadlist="table"] .threadlist > li.t {
        grid-template-columns: minmax(0, max-content) minmax(0, 1fr) auto;
        grid-template-areas: "subject subject replies" "author views last";
        gap: 0 .75rem;
        padding-block: .25rem;
        border-bottom: 1px solid var(--border);
    }
    :root[data-threadlist="table"] .t-subject { grid-area: subject; }
    :root[data-threadlist="table"] .t-replies { grid-area: replies; }
    :root[data-threadlist="table"] .t-author { grid-area: author; font-size: var(--list-small); }
    :root[data-threadlist="table"] .t-author:not(.is-highlight) { color: var(--muted); }
    :root[data-threadlist="table"] .t-views { grid-area: views; text-align: left; font-size: var(--list-small); }
    :root[data-threadlist="table"] .t-date { display: none; }
    :root[data-threadlist="table"] .t-last { grid-area: last; text-align: right; }
    :root[data-threadlist="table"] :is(.t-views, .t-replies)::before { content: ""; display: inline-block; width: 1.05em; height: 1.05em; margin-right: .25em; vertical-align: -.2em; background: currentColor; mask: var(--icon) center / contain no-repeat; }
    :root[data-threadlist="table"] .tl-head { display: none; }
}
.t-views { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
.t-replies { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8 8 0 0 1-11.8 7L4 20l1.1-4.6A8 8 0 1 1 21 12Z'/%3E%3C/svg%3E"); }

/* Fliesstext / Tabelle im Menü «Darstellung» der Kopfzeile */
.view-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.view-switch button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .4rem .5rem;
    border: 0;
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: .9rem;
    cursor: pointer;
}
.view-switch button + button { border-left: 1px solid var(--border); }
.view-switch button:hover { background: var(--hover); color: var(--text); }
/* Fokusrahmen nach innen – aussen schnitte ihn overflow: hidden ab */
.view-switch button:focus-visible { outline-offset: -2px; }
:root:not([data-threadlist="table"]) .view-switch [data-threadlist-choice="flow"],
:root[data-threadlist="table"] .view-switch [data-threadlist-choice="table"] { background: var(--active); color: var(--accent); }

/* ---------- Thread-Baum ---------- */

.tree {
    list-style: none;
    margin: 0;
    padding: .25rem 0 .5rem;
}

.tree > li {
    /* Einrückung begrenzen: sehr tiefe Ketten laufen nicht aus dem Bild */
    --i: calc(min(var(--d), 32) * var(--indent));
    padding: .12rem .75rem .12rem calc(.75rem + var(--i));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 3px solid transparent;
    /* Hilfslinien der Baumstruktur */
    background-image: repeating-linear-gradient(to right, var(--tree-line) 0 1px, transparent 1px var(--indent));
    background-position: calc(.75rem + 4px) 0;
    background-size: var(--i) 100%;
    background-repeat: no-repeat;
}
.tree > li:hover { background-color: var(--hover); }
.tree > li.is-active { background-color: var(--active); border-left-color: var(--active-border); }
.tree > li:first-child > a { font-weight: 650; }
.tree a:visited { color: var(--link-visited); }
.tree .n-author { margin-left: .35rem; }
.tree time { margin-left: .35rem; color: var(--muted); font-size: var(--list-small); font-variant-numeric: tabular-nums; }

/* ---------- Nachricht ---------- */

.msg { padding: .75rem 1rem 1rem; }
/* Kopf der Nachricht: Betreff, darunter Autor, Datum und «Antwort auf …» */
.msg-head { padding-block: .4rem; }
.msg-head-text { flex: 1; min-width: 0; }
.msg-meta { display: flex; flex-wrap: wrap; gap: 0 1rem; margin: .1rem 0 0; color: var(--muted); font-size: .85rem; }
.msg-author { color: var(--text); font-weight: 600; }
.msg-parent { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.msg-body {
    font-size: 15px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.msg-body img { max-width: 100%; height: auto; }
.msg-img { display: inline-block; max-width: 100%; margin: .25rem 0; }
/* Einzelbild im Beitrag als Vorschau; gross in der Bildansicht (Klick) */
.msg-img { --preview-h: min(60vh, 30rem); }
.msg-img img { display: block; max-height: var(--preview-h); border-radius: 4px; cursor: zoom-in; }
/* Mit Grösse (width/height, Platz vor dem Laden reserviert): die Breite begrenzen statt nur die Höhe –
   max-height allein kürzt die Höhe und lässt die Breite stehen, hohe Handyfotos würden verzerrt */
.msg-img img[style*="--ar"] { max-width: min(100%, calc(var(--preview-h) * var(--ar))); }
.msg-video { display: block; max-width: 100%; max-height: 60vh; margin: .25rem 0; }


.msg-steam {
    display: flex;
    max-width: 620px;
    margin: .35rem 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
}
.msg-steam:hover { border-color: var(--accent); text-decoration: none; }
.msg-steam img { flex: none; width: 230px; height: auto; aspect-ratio: 460 / 215; object-fit: cover; background: #1b2838; }
.msg-steam-body { display: flex; flex-direction: column; gap: .2rem; min-width: 0; padding: .55rem .75rem; }
.msg-steam-body strong { line-height: 1.3; }
.msg-steam-desc {
    display: -webkit-box;
    overflow: hidden;
    color: var(--muted);
    font-size: .85rem;
    line-height: 1.4;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}
.msg-steam-meta { margin-top: auto; color: var(--link); font-size: .82rem; font-weight: 600; }
@media (max-width: 560px) {
    .msg-steam { flex-direction: column; }
    .msg-steam img { width: 100%; }
}

.msg-yt {
    position: relative;
    display: inline-block;
    max-width: 480px;
    width: 100%;
    margin: .25rem 0;
    border-radius: 6px;
    overflow: hidden;
    background: #000;
}
.msg-yt img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; opacity: .9; }
.msg-yt-play {
    position: absolute;
    inset: 50% auto auto 50%;
    width: 64px;
    height: 44px;
    border-radius: 10px;
    background: #e00;
    transform: translate(-50%, -50%);
}
.msg-yt-play::after {
    content: "";
    position: absolute;
    inset: 50% auto auto 54%;
    border-style: solid;
    border-width: 9px 0 9px 15px;
    border-color: transparent transparent transparent #fff;
    transform: translate(-50%, -50%);
}
.msg-placeholder { color: var(--muted); font-style: italic; }

.msg-actions {
    display: flex;
    gap: 1.25rem;
    margin-top: 1.25rem;
    padding-top: .6rem;
    border-top: 1px solid var(--border);
}

/* ---------- Beitragsinhalt (Markdown) ---------- */

.msg-body > :first-child { margin-top: 0; }
.msg-body > :last-child { margin-bottom: 0; }
.msg-body p { margin: 0 0 .8em; }
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4, .msg-body h5, .msg-body h6 {
    margin: 1.1em 0 .4em;
    font-size: 1.05em;
    line-height: 1.3;
}
.msg-body h1 { font-size: 1.3em; }
.msg-body h2 { font-size: 1.18em; }
.msg-body ul, .msg-body ol { margin: 0 0 .8em; padding-left: 1.5em; }
.msg-body li > p { margin: 0; }
.msg-body hr { border: 0; border-top: 1px solid var(--border); margin: 1em 0; }
.msg-body code {
    padding: .1em .3em;
    border-radius: 4px;
    background: var(--surface-2);
    font: .9em ui-monospace, "Cascadia Code", Consolas, monospace;
}
.msg-body pre {
    margin: 0 0 .8em;
    padding: .6rem .8rem;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
}
.msg-body pre code { padding: 0; background: none; }
.msg-body blockquote {
    margin: 0 0 .8em;
    padding: .1em 0 .1em .8rem;
    border-left: 3px solid var(--quote-1);
    color: var(--quote-1);
}
.msg-body blockquote blockquote { border-left-color: var(--quote-2); color: var(--quote-2); }
.msg-body blockquote blockquote blockquote { border-left-color: var(--quote-3); color: var(--quote-3); }
.msg-body blockquote p { margin-bottom: .4em; }

.msg-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
    max-width: 640px;
    margin: 0 0 .8em;
}
.msg-gallery-item { display: block; aspect-ratio: 1; cursor: zoom-in; overflow: hidden; border-radius: 4px; background: var(--surface-2); }
.msg-gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .15s; }
.msg-gallery-item:hover img { transform: scale(1.04); }
/* Grosse Galerie: ab der 9. Kachel ausgeblendet, die 8. zeigt «+N» (GalleryRenderer, --more) */
.msg-gallery[style*="--more"] > .msg-gallery-item:nth-of-type(n+9) { display: none; }
.msg-gallery[style*="--more"] > .msg-gallery-item:nth-of-type(8) { position: relative; }
.msg-gallery[style*="--more"] > .msg-gallery-item:nth-of-type(8)::after {
    content: var(--more);
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgb(0 0 0 / 50%);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 600;
}

.msg-member {
    margin: 0 0 .8em;
    padding: .5rem .75rem;
    border: 1px dashed var(--accent);
    border-radius: 6px;
}
.msg-member > :last-child { margin-bottom: 0; }
.msg-spoiler {
    margin: 0 0 .8em;
    padding: .4rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
}
.msg-spoiler > summary { cursor: pointer; font-weight: 600; }
.msg-spoiler[open] > summary { margin-bottom: .4rem; }
.msg-giveaway {
    margin: 0 0 .8em;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
}
.msg-giveaway .giveaway-title { margin: 0 0 .3rem; font-weight: 650; }
.msg-giveaway ul { list-style: none; margin: 0; padding: 0; }
.msg-giveaway li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .2rem 0; }
.msg-giveaway li.is-claimed { color: var(--muted); }
.msg-giveaway .btn-small { margin-left: 0; }
.giveaway-by { font-size: .85rem; }
.msg-yt.is-playing { display: block; aspect-ratio: 16 / 9; }
.msg-yt iframe { display: block; width: 100%; height: 100%; border: 0; }

/* ---------- WYSIWYG-Editor ---------- */

.compose:not(.is-wysiwyg) [data-toolbar="wysiwyg"] { display: none; }
.compose.is-wysiwyg [data-toolbar="wysiwyg"] { display: flex; }
.compose.is-wysiwyg [data-toolbar="source"],
.compose.is-wysiwyg textarea[name="body"],
.compose.is-wysiwyg .compose-preview { display: none; }
.compose-toolbar button[aria-pressed="true"] { background: var(--active); color: var(--accent); }

.ed-content {
    min-height: 14rem;
    max-height: 60vh;
    overflow-y: auto;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    background: var(--surface);
    outline: none;
}
.ed-content:focus { box-shadow: 0 0 0 2px var(--accent); }
.ed-content p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    height: 0;
    color: var(--muted);
    pointer-events: none;
}
.ed-content img { max-width: 100%; max-height: 300px; border-radius: 4px; vertical-align: bottom; }
.ed-content img.ProseMirror-selectednode { outline: 3px solid var(--accent); }
.ed-content a { pointer-events: none; }
.ed-container {
    position: relative;
    margin: 0 0 .8em;
    padding: 1.5rem .75rem .5rem;
    border: 1px dashed var(--accent);
    border-radius: 6px;
}
.ed-container::before {
    content: attr(data-caption);
    position: absolute;
    top: .3rem;
    left: .75rem;
    color: var(--accent);
    font-size: .75rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.ed-container[data-container="spoiler"] { border-color: var(--muted); }
.ed-container[data-container="spoiler"]::before { color: var(--muted); }
.ed-embed, .ed-giveaway {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 0 0 .8em;
    padding: .5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    cursor: default;
}
.ed-embed img { width: 120px; height: auto; border-radius: 4px; }
.ed-embed-url { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.ed-giveaway { flex-direction: column; align-items: flex-start; gap: .25rem; }
.ed-giveaway ul { margin: 0; padding-left: 1.2rem; font-family: ui-monospace, Consolas, monospace; }
.ed-embed.ProseMirror-selectednode, .ed-giveaway.ProseMirror-selectednode { outline: 2px solid var(--accent); }
/* ---------- Suche ---------- */

/* Während der Suche bekommt die Liste mehr Platz (nur Desktop) */
@media (min-width: 721px) and (min-height: 501px) {
    :root:not([data-layout]) .panes:has(#pane-threads .search-form) {
        grid-template-rows: minmax(0, 52%) 7px minmax(0, 20%) 7px minmax(0, 1fr);
    }
    :root[data-layout="right"] .panes:has(#pane-threads .search-form) { grid-template-rows: minmax(0, 65%) 7px minmax(0, 1fr); }
    :root[data-layout="top"] .panes:has(#pane-threads .search-form) { grid-template-rows: minmax(0, 52%) 7px minmax(0, 1fr); }
}

.search-form { display: grid; gap: .5rem; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
.search-main { display: flex; gap: .5rem; }
.search-main input {
    flex: 1;
    min-width: 0;
    padding: .45rem .6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 15px;
}
.search-main input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.search-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; font-size: .85rem; color: var(--muted); }
.search-filters input[type="text"], .search-filters select {
    padding: .2rem .35rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
.search-filters .check { margin: 0; gap: .3rem; }
.search-summary { margin: 0; padding: .5rem .75rem 0; font-size: .85rem; }
.search-hits { list-style: none; margin: 0; padding: .25rem 0 .5rem; }
.search-hits li { padding: .45rem .75rem; border-bottom: 1px solid var(--border); }
.search-hits li:hover { background: var(--hover); }
.hit-subject { font-weight: 600; }
.hit-meta { display: block; color: var(--muted); font-size: .8rem; }
.hit-excerpt { margin: .2rem 0 0; font-size: .88rem; line-height: 1.45; }
.search-hits mark { background: color-mix(in srgb, var(--unread) 25%, transparent); color: inherit; border-radius: 2px; padding: 0 .1em; }
.search-pages { display: flex; justify-content: center; gap: 1.2rem; padding: .6rem; }
/* ---------- Bildansicht (PhotoSwipe, forum.js) ---------- */

.pswp__button--original {
    width: auto;
    padding: 0 .9rem;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: .85rem;
    text-decoration: none;
    opacity: .85;
}
.pswp__button--original:hover { opacity: 1; }
.pswp__caption {
    position: absolute;
    left: 50%;
    bottom: .75rem;
    transform: translateX(-50%);
    max-width: calc(100% - 2rem);
    padding: .3rem .7rem;
    border-radius: 4px;
    background: rgb(0 0 0 / 45%);
    color: #fff;
    font-size: .85rem;
    text-align: center;
    overflow-wrap: anywhere;
    pointer-events: none;
}
.pswp__caption:empty { display: none; }
.pswp--ui-visible .pswp__caption { opacity: 1; }
.pswp:not(.pswp--ui-visible) .pswp__caption { opacity: 0; }

/* ---------- Ungelesen ---------- */

.threadlist > li.is-unread .t-subject { font-weight: 650; }
.threadlist > li.is-unread .t-subject::before,
.tree > li.is-new > a::before {
    content: "";
    display: inline-block;
    width: .5em;
    height: .5em;
    margin-right: .4em;
    border-radius: 50%;
    background: var(--unread);
    vertical-align: .1em;
}
.threadlist > li.is-fixed.is-unread .t-subject::before { content: "📌 "; width: auto; height: auto; background: none; }
.tree > li.is-new > a { font-weight: 650; }
.new-count { color: var(--unread); font-weight: 600; }

/* Angemeldet: Die Linkfarbe zeigt gelesen/ungelesen, nicht den Verlauf des Browsers –
   sonst wäre ein Thread mit neuen Antworten noch «besucht» gefärbt */
.has-read-state .t-subject:visited,
.has-read-state .tree a:visited { color: var(--link); }
.has-read-state .threadlist > li.t:not(.is-unread) .t-subject,
.has-read-state .tree > li:not(.is-new) > a { color: var(--link-visited); }
/* «Letzte» im Fliesstext ebenso (in der Tabelle bleibt das Datum grau) */
:root:not([data-threadlist="table"]) .has-read-state .t-last:visited { color: var(--link); }
:root:not([data-threadlist="table"]) .has-read-state .threadlist > li.t:not(.is-unread) .t-last { color: var(--link-visited); }

/* ---------- Eigene Beiträge ---------- */

.threadlist > li.is-own .t-author,
.tree > li.is-own > .n-author,
.msg-head.is-own .msg-author { padding: 0 .35em; border-radius: 4px; background: var(--own-bg); }
.threadlist > li.is-own .t-author { justify-self: start; max-width: 100%; box-sizing: border-box; }

.btn-small {
    flex: none;
    margin-left: auto;
    padding: .2rem .55rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .8rem;
    cursor: pointer;
}
.btn-small:hover { background: var(--hover); }
.pane-sub + .btn-small { margin-left: 0; }

.user-name { font-weight: 600; }

/* ---------- Formulare (Login, Registrierung, Passwort) ---------- */

.page-center {
    display: grid;
    place-items: start center;
    padding: 3rem 16px;
    overflow: auto;
}
.card {
    width: min(100%, 24rem);
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.card h1 { margin: 0 0 1rem; font-size: 1.25rem; }
.field { display: grid; gap: .3rem; margin-bottom: .9rem; }
.field > span:first-child { font-weight: 600; font-size: .9rem; }
.field input {
    padding: .55rem .65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 16px; /* verhindert Zoom auf iOS */
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.check { display: flex; align-items: center; gap: .5rem; margin-bottom: 1.1rem; }
.btn {
    width: 100%;
    padding: .6rem 1rem;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: var(--accent-text);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.form-error {
    margin: 0 0 1rem;
    padding: .6rem .75rem;
    border-radius: 6px;
    background: var(--error-bg);
    color: var(--error);
}
.form-note { margin: 1rem 0 0; color: var(--muted); font-size: .85rem; }
.card p { margin: 0 0 1rem; line-height: 1.5; }
.card p.form-note { margin: 1rem 0 0; }
a.btn { display: block; box-sizing: border-box; text-align: center; text-decoration: none; }
.form-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; margin: 1rem 0 0 !important; font-size: .9rem; }
.field-hint { color: var(--muted); font-size: .8rem; }
.field-error { color: var(--error); font-size: .85rem; font-weight: 600; }
.field.has-error input { border-color: var(--error); }
/* Passwort mit «Anzeigen»-Knopf im Feld */
.password-input { position: relative; display: grid; }
.password-input input { padding-right: 5.5rem; }
.password-toggle {
    position: absolute;
    inset: 4px 4px 4px auto;
    padding: 0 .6rem;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: .8rem;
    cursor: pointer;
}
.password-toggle:hover { background: var(--hover); }
/* Falle für Bots: für Menschen unsichtbar, auch für Screenreader */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Schreiben ---------- */

/* Beim Schreiben legt sich der Nachrichtenbereich als Ebene über alle Bereiche (nur Desktop).
   Das Raster darunter bleibt, wie es ist – nach dem Schreiben verschiebt sich nichts. */
@media (min-width: 721px) and (min-height: 501px) {
    .panes { position: relative; }
    .panes:has(> #pane-message > form.compose)::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: 5;
        background: var(--backdrop);
    }
    /* grid-area: auto → die Ebene richtet sich am ganzen Raster aus, nicht an der Zelle.
       Sie wächst mit dem Text, höchstens bis zur Fensterhöhe; danach scrollt nur das Textfeld
       und Senden/Abbrechen bleiben sichtbar. */
    :root .panes > #pane-message:has(> form.compose) {
        position: absolute;
        inset: .75rem max(.75rem, calc((100% - 1100px) / 2)) auto;
        z-index: 6;
        grid-area: auto;
        display: flex;
        flex-direction: column;
        max-height: calc(100% - 1.5rem);
        overflow-y: auto; /* nur bei sehr niedrigem Fenster nötig */
        scrollbar-gutter: auto;
        box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
    }
    #pane-message > form.compose { display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; }
    #pane-message > form.compose > * { flex: none; }
    /* Textfeld schrumpft bis auf seine Mindesthöhe (plus Beschriftung und Leiste), nicht darunter */
    #pane-message > form.compose > .field:has(.compose-toolbar) {
        display: flex;
        flex-direction: column;
        flex: 0 1 auto;
        min-height: calc(min(14rem, 30vh) + 4rem);
    }
    #pane-message > form.compose .ed { display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; }
    #pane-message > form.compose .ed-content,
    #pane-message > form.compose textarea[name="body"] {
        flex: 0 1 auto;
        min-height: min(14rem, 30vh);
        max-height: none;
        resize: none;
        field-sizing: content;
    }
    /* Quelltext-Modus: zuerst wird die Vorschau kleiner (scrollt), dann erst das Textfeld */
    #pane-message > form.compose > .compose-preview { flex: 0 100 auto; min-height: 6rem; overflow: auto; }
}

.compose { display: grid; gap: .25rem; padding: .75rem 1rem 1.25rem; }
.compose .field { margin-bottom: .6rem; }
.compose textarea {
    width: 100%;
    min-height: 12rem;
    padding: .6rem .7rem;
    border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    background: var(--surface-2);
    color: var(--text);
    font: 15px/1.55 ui-monospace, "Cascadia Code", Consolas, monospace;
    resize: vertical;
}
.compose textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.compose-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 6px 6px 0 0;
    background: var(--surface);
}
.compose-toolbar button {
    min-width: 2rem;
    padding: .2rem .5rem;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
}
.compose-toolbar button:hover { background: var(--hover); }
.compose-toolbar .sep { width: 1px; margin: .2rem .25rem; background: var(--border); }
.compose-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.1rem; margin-top: .25rem; }
.compose-actions .hint { color: var(--muted); font-size: .8rem; }
.btn-inline { width: auto; padding-inline: 1.4rem; }
.btn:disabled { opacity: .6; cursor: progress; }
.form-error p { margin: 0; }
.form-error p + p { margin-top: .3rem; }
.draft-note {
    margin: 0 0 .5rem;
    padding: .45rem .7rem;
    border-radius: 6px;
    background: var(--active);
    font-size: .9rem;
}
.compose-preview { margin-top: 1rem; padding-top: .75rem; border-top: 1px dashed var(--border); }
.compose-preview h3 { margin: 0 0 .5rem; color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.preview-subject { margin: 0 0 .5rem; font-weight: 650; }
.muted { color: var(--muted); }

.toast {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    z-index: 10;
    max-width: min(90vw, 32rem);
    padding: .65rem 1rem;
    border-radius: 8px;
    background: var(--text);
    color: var(--surface);
    box-shadow: 0 6px 24px rgb(0 0 0 / 25%);
    transform: translateX(-50%);
}

/* Ziehen zum Aktualisieren (Mobile): Kreis mit Pfeil, der beim Ziehen mitkommt */
.ptr {
    position: fixed;
    z-index: 5;
    width: 2.25rem;
    height: 2.25rem;
    margin: -2.25rem 0 0 -1.125rem;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 2px 10px rgb(0 0 0 / 18%);
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(var(--pull, 0) * 1px + .5rem)) rotate(calc(var(--pull, 0) * 4deg));
}
.ptr::before {
    content: "↻";
    display: grid;
    place-items: center;
    height: 100%;
    color: var(--muted);
    font-size: 1.25rem;
    line-height: 1;
}
.ptr.is-visible { opacity: 1; }
.ptr.is-ready::before, .ptr.is-loading::before { color: var(--accent); }
.ptr.is-loading::before { animation: ptr-spin .8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ---------- Profile, Konto, Online-Liste ---------- */

.card-wide { width: min(100%, 44rem); }
.card.admin { width: min(100%, 84rem); }
.card h2 { margin: 0 0 .75rem; font-size: 1.05rem; }
.pane-page { padding: .9rem 1rem 1.5rem; }
.pane-page .profile-name { font-size: 1.2rem; }
.pane-page h2 { margin: 0 0 .6rem; font-size: 1.05rem; }
.pane-page p { margin: 0 0 .9rem; }

.user-link { color: inherit; font-weight: 600; }
.user-link:hover { color: var(--accent); }
.online-link .count {
    display: inline-block;
    min-width: 1.4em;
    padding: 0 .35em;
    border-radius: 999px;
    background: var(--active);
    font-size: .8rem;
    text-align: center;
}

.avatar { display: block; flex: none; border-radius: 12px; object-fit: cover; background: var(--surface-2); }
.avatar-empty {
    display: grid;
    place-items: center;
    width: var(--size, 96px);
    height: var(--size, 96px);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: calc(var(--size, 96px) * .42);
    font-weight: 700;
}

.profile-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.25rem; }
.profile-name { margin: 0 0 .4rem; font-size: 1.35rem; overflow-wrap: anywhere; }
.profile-stats { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; margin: 0; }
.profile-stats dt { color: var(--muted); font-size: .8rem; }
.profile-stats dd { margin: 0; font-weight: 600; }
.profile-fields { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: .45rem 1.2rem; margin: 0 0 1.25rem; }
.profile-fields > div { display: contents; }
.profile-fields dt { color: var(--muted); }
.profile-fields dd { margin: 0; overflow-wrap: anywhere; }
.profile-actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem 1.2rem; margin: 0; }
.badge { display: inline-block; margin: 0 0 .4rem; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; }
.badge-muted { background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.muted { color: var(--muted); }

.online-list, .member-list { display: flex; flex-wrap: wrap; gap: .35rem .9rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.member-list { display: grid; gap: .3rem; }
.online-search-title { margin-top: 1.5rem !important; }
.member-search input {
    width: min(100%, 20rem);
    padding: .5rem .65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 16px;
}
#member-results { margin-top: .75rem; }

.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin: 0 0 1.25rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.tabs a { padding: .3rem .7rem; border-radius: 6px; color: var(--text); }
.tabs a:hover { background: var(--hover); text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--active); font-weight: 600; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); align-items: start; gap: 0 1rem; margin-bottom: .5rem; }
.field-wide { grid-column: 1 / -1; }
.field textarea {
    padding: .55rem .65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    resize: vertical;
}
.field textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.avatar-field { display: flex; gap: 1rem; align-items: center; margin: 0 0 1.25rem; padding: 0; border: 0; }
.avatar-field legend { margin-bottom: .5rem; padding: 0; font-weight: 600; font-size: .9rem; }
.avatar-controls { display: grid; gap: .35rem; }
.avatar-controls .check { margin: .2rem 0 0; }
.settings-section { padding: 1rem 0 1.25rem; border-top: 1px solid var(--border); }
.settings-section:first-of-type { border-top: 0; padding-top: 0; }
.settings-section .field { max-width: 24rem; }

/* Menü-Knopf nur auf dem Handy */
.menu-btn { display: none; }

/* ---------- Private Nachrichten (Chat) ---------- */

.pm-link .count, .conversation .count {
    display: inline-block;
    min-width: 1.4em;
    padding: 0 .35em;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: .75rem;
    font-weight: 700;
    text-align: center;
}
.btn-small-inline { width: auto; padding: .35rem .9rem; font-size: .9rem; }

.messenger {
    display: grid;
    grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
    gap: .5rem;
    min-height: 0;
    padding: .5rem;
}
.conversations, .chat-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.conversations-head { padding: .75rem .75rem .5rem; border-bottom: 1px solid var(--border); }
.conversations-head h1 { margin: 0 0 .5rem; font-size: 1.1rem; }
.new-chat { position: relative; }
.new-chat input {
    box-sizing: border-box;
    width: 100%;
    padding: .45rem .6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 16px;
}
.new-chat-list {
    position: absolute;
    inset: calc(100% + 4px) 0 auto;
    z-index: 5;
    margin: 0;
    padding: .3rem;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
}
.new-chat-list a, .new-chat-list .muted { display: block; padding: .4rem .5rem; border-radius: 4px; }
.new-chat-list a:hover { background: var(--hover); text-decoration: none; }
.new-chat-list:empty { display: none; }

.conversation-list { flex: 1; min-height: 0; margin: 0; padding: .25rem; overflow: auto; list-style: none; overscroll-behavior: contain; }
.conversation {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem;
    border-radius: 8px;
    color: var(--text);
}
.conversation:hover { background: var(--hover); text-decoration: none; }
.conversation.is-active { background: var(--active); }
.conversation .avatar { border-radius: 50%; }
.conversation-text { display: grid; flex: 1; min-width: 0; }
.conversation-top { display: flex; justify-content: space-between; gap: .5rem; }
.conversation-top strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conversation-top time { flex: none; color: var(--muted); font-size: .8rem; }
.conversation-preview { overflow: hidden; color: var(--muted); font-size: .88rem; white-space: nowrap; text-overflow: ellipsis; }
.conversation.is-unread .conversation-preview { color: var(--text); font-weight: 600; }
.conversation-empty { padding: 1rem .75rem; color: var(--muted); }

.chat-placeholder { margin: auto; padding: 2rem; color: var(--muted); text-align: center; }
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border-bottom: 1px solid var(--border); }
.chat-head .avatar { border-radius: 50%; }
.chat-head .back { display: none; }
.chat-title { flex: 1; margin: 0; font-size: 1rem; }
.chat-delete { border: 0; background: none; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; }
.chat-delete:hover { color: var(--error); }

.chat-scroll { flex: 1; min-height: 0; padding: .75rem .9rem; overflow: auto; overscroll-behavior: contain; background: var(--bg); }
.chat-messages { display: flex; flex-direction: column; gap: .35rem; }
.chat-older { align-self: center; margin-bottom: .5rem; padding: .3rem .8rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; }
.chat-empty { margin: 2rem auto; color: var(--muted); }
.chat-day { align-self: center; margin: .75rem 0 .35rem; padding: .1rem .7rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .78rem; }

.bubble {
    position: relative;
    max-width: min(75%, 42rem);
    padding: .45rem .7rem .3rem;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow-wrap: anywhere;
}
.bubble.theirs { align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.mine { align-self: flex-end; border-bottom-right-radius: 4px; background: var(--active); border-color: transparent; }
.bubble-topic { margin: 0 0 .2rem; color: var(--muted); font-size: .78rem; font-weight: 600; }
.bubble-body { font-size: 15px; line-height: 1.5; }
.bubble-body > :first-child { margin-top: 0; }
.bubble-body > :last-child { margin-bottom: 0; }
.bubble-body p { margin: 0 0 .5em; }
.bubble-body blockquote { margin: .2em 0 .5em; padding: .1em .6em; border-left: 3px solid var(--border); color: var(--muted); }
.bubble-meta { display: flex; justify-content: flex-end; align-items: center; gap: .3rem; margin-top: .15rem; color: var(--muted); font-size: .72rem; }
.bubble-delete { padding: 0 .2rem; border: 0; background: none; color: inherit; font: inherit; font-size: .9rem; line-height: 1; cursor: pointer; opacity: 0; }
.bubble:hover .bubble-delete, .bubble-delete:focus-visible { opacity: 1; }
@media (hover: none) { .bubble-delete { opacity: .6; } }
.chat-seen { min-height: 1em; margin: .2rem 0 0; color: var(--muted); font-size: .75rem; text-align: right; }

.chat-composer { display: flex; align-items: flex-end; gap: .5rem; padding: .6rem .75rem .3rem; border-top: 1px solid var(--border); }
.chat-composer textarea {
    flex: 1;
    min-height: 2.4rem;
    max-height: 40vh;
    padding: .5rem .7rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    line-height: 1.4;
    resize: none;
}
.chat-composer textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.chat-composer .btn { border-radius: 18px; }
.chat-hint { margin: 0; padding: 0 .9rem .5rem; color: var(--muted); font-size: .75rem; }
.chat-readonly { padding: .75rem .9rem; border-top: 1px solid var(--border); }

@media (max-width: 720px) {
    .messenger { grid-template-columns: minmax(0, 1fr); padding: 0; }
    .conversations, .chat-pane { border: 0; border-radius: 0; }
    .messenger[data-view="list"] .chat-pane, .messenger[data-view="chat"] .conversations { display: none; }
    .chat-head .back { display: inline-grid; }
    .bubble { max-width: 85%; }
    .chat-hint { display: none; }
}

/* ---------- Moderation und Verwaltung ---------- */

.mod-menu { position: relative; display: inline-block; }
.mod-menu-toggle { padding: 0; border: 0; background: none; color: var(--link); font: inherit; cursor: pointer; }
.mod-menu-toggle::after { content: " ▾"; font-size: .75em; }
/* Popover: liegt über allen Bereichen, wird nicht abgeschnitten (Position setzt forum.js) */
.mod-menu-items {
    position: fixed;
    inset: auto;
    margin: 0;
    display: none;
    gap: 2px;
    min-width: 15rem;
    padding: .35rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.mod-menu-thread { margin-left: auto; font-size: .85rem; }
.mod-menu-items:popover-open { display: grid; }
.mod-menu-items button, .mod-menu-items a {
    display: block;
    padding: .45rem .6rem;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.mod-menu-items button:hover, .mod-menu-items a:hover { background: var(--hover); text-decoration: none; }
.mod-move { display: flex; align-items: center; gap: .4rem; padding: .3rem .6rem; }
.mod-move select { font: inherit; }
.danger, .mod-menu-items .danger { color: var(--error); }
.btn.danger { background: var(--error); color: #fff; }

.admin h2 { margin: 1.25rem 0 .6rem; font-size: 1.05rem; }
.admin .tabs .count, .pm-link .count { margin-left: .2rem; }
.tabs .count {
    display: inline-block;
    min-width: 1.3em;
    padding: 0 .3em;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: .72rem;
    text-align: center;
}
.admin-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.admin-list > li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.admin-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .5rem; }
.decline > summary { padding: .35rem .7rem; color: var(--error); cursor: pointer; }
.decline-form { display: grid; gap: .4rem; min-width: 16rem; margin-top: .4rem; }
.admin-log { margin: 0; padding: 0; list-style: none; font-size: .9rem; }
.admin-log li { padding: .35rem 0; border-top: 1px solid var(--border); }
.admin-log time { color: var(--muted); margin-right: .4rem; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .6rem; margin: 0 0 1rem; }
.stat-tiles > div { padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.stat-tiles dt { color: var(--muted); font-size: .8rem; }
.stat-tiles dd { margin: .2rem 0 0; font-size: 1.4rem; font-weight: 700; }
.notice { padding: .6rem .75rem; border-radius: 6px; background: var(--active); }
/* Verwaltung → System: Probleme, Zustand, Kennzahlen */
.notice.is-error { background: var(--error-bg); color: var(--error); }
.notice.is-warn { background: color-mix(in srgb, var(--quote-2) 16%, var(--surface)); }
.notice.is-ok { background: var(--own-bg); }
.notice + .notice { margin-top: .5rem; }
.tabs .count.is-error { background: var(--error); color: #fff; }
.system-list { display: grid; grid-template-columns: minmax(9rem, max-content) 1fr; gap: .45rem 1.25rem; margin: 0; font-size: .92rem; }
.system-list dt { color: var(--muted); }
.system-list dd { margin: 0; overflow-wrap: anywhere; }
.state { display: inline-block; padding: 0 .45rem; border-radius: 999px; font-size: .82rem; font-weight: 600; }
.state.is-ok { background: var(--own-bg); }
.state.is-warn { background: color-mix(in srgb, var(--quote-2) 18%, var(--surface)); }
.state.is-error { background: var(--error-bg); color: var(--error); }
.meter { display: inline-block; width: 6rem; height: .55rem; margin-right: .4rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); vertical-align: middle; overflow: hidden; }
.meter > span { display: block; width: var(--v); height: 100%; background: var(--accent); }
.meter > span.is-high { background: var(--error); }
.system-log { margin-top: .75rem; }
.system-log > summary { cursor: pointer; color: var(--muted); }
.system-log pre { max-height: 24rem; margin: .4rem 0 0; padding: .6rem .75rem; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); font-size: .8rem; white-space: pre-wrap; }
@media (max-width: 720px) {
    .system-list { grid-template-columns: 1fr; gap: .1rem; }
    .system-list dd { margin-bottom: .45rem; }
}
/* GoAccess-Bericht in der Verwaltung */
.stats-frame { display: block; width: 100%; height: max(36rem, calc(100dvh - 16rem)); border: 1px solid var(--border); border-radius: 6px; }
/* Forum-Statistik (Verwaltung) und eigene Statistik (Profil) */
.card-stats { width: min(100%, 60rem); }
.stat-tiles small { display: block; margin-top: .15rem; color: var(--muted); font-size: .78rem; }
.chart { display: grid; grid-template-columns: auto 1fr; gap: .4rem; }
.chart-axis { position: relative; height: 11rem; min-width: 2rem; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-tick { position: absolute; right: 0; bottom: var(--y); transform: translateY(50%); line-height: 1; white-space: nowrap; }
.chart-bars { position: relative; display: flex; align-items: stretch; gap: 3px; height: 11rem; margin-bottom: 1.3rem; border-bottom: 1px solid var(--border); }
.chart-bars.is-dense { gap: 1px; }
.chart-grid { position: absolute; left: 0; right: 0; bottom: var(--y); border-top: 1px dashed var(--border); pointer-events: none; }
.chart-col { position: relative; flex: 1 1 0; min-width: 0; display: flex; align-items: flex-end; }
.chart-col:hover .chart-bar { background: var(--highlight); }
.chart-bar { position: relative; display: block; width: 100%; height: var(--h); min-height: 1px; border-radius: 2px 2px 0 0; background: var(--accent); }
.chart-label { position: absolute; top: 100%; left: 0; padding-top: .2rem; color: var(--muted); font-size: .72rem; white-space: nowrap; }
/* Werte beim Überfahren sofort zeigen (statt des verzögerten title-Tooltips); bei Balken über dem Balken,
   ausgelöst von der ganzen Spalte (auch kleine Balken lassen sich so leicht treffen) */
[data-tip]:hover::after, .chart-col:hover > .chart-bar::after {
    content: attr(data-tip);
    position: absolute; z-index: 5; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
    padding: .25rem .5rem; border-radius: 4px; background: var(--text); color: var(--surface);
    font-size: .78rem; font-weight: 600; white-space: nowrap; pointer-events: none;
}
.tip-start[data-tip]:hover::after, .tip-start:hover > .chart-bar::after { left: 0; transform: none; }
.tip-end[data-tip]:hover::after, .tip-end:hover > .chart-bar::after { left: auto; right: 0; transform: none; }
.chart-heat { display: grid; grid-template-columns: 2rem repeat(24, minmax(0, 1fr)); gap: 2px; max-width: 44rem; font-size: .72rem; color: var(--muted); }
.chart-heat-hour { text-align: left; }
.chart-heat-cell { position: relative; aspect-ratio: 1; border-radius: 2px; background: color-mix(in srgb, var(--accent) var(--v), var(--hover)); }
.chart-heat-cell:hover { outline: 2px solid var(--highlight); }
.chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin: .5rem 0 0; font-size: .78rem; }
.chart-legend .chart-heat-cell { display: inline-block; width: .9rem; margin-left: .4rem; }
.chart-legend .chart-heat-cell:first-child { margin-left: 0; }
.stats-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 2rem; }
.stats-ranking { margin: 0; padding-left: 1.6rem; font-size: .9rem; }
.stats-ranking li { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; border-top: 1px solid var(--border); }
.stats-ranking li > a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-ranking li::marker { color: var(--muted); }
.stats-num { flex: none; font-variant-numeric: tabular-nums; }
.stats-table td { font-variant-numeric: tabular-nums; }
.admin-filter { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.admin-filter input, .admin-filter select, .admin select, .field select {
    padding: .45rem .6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
}
.admin-filter input { flex: 1; min-width: 12rem; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td { padding: .45rem .5rem; border-top: 1px solid var(--border); text-align: left; white-space: nowrap; }
.admin-table th { color: var(--muted); font-weight: 600; border-top: 0; }
.pager { display: flex; justify-content: space-between; margin-top: 1rem; }
.checks { margin: 0 0 1rem; padding: 0; border: 0; }
.checks legend { margin-bottom: .4rem; padding: 0; font-weight: 600; font-size: .9rem; }
.checks .check { margin-bottom: .35rem; }
.board-item > summary, .settings-section > summary { cursor: pointer; padding: .2rem 0; }
.board-form { margin-top: .75rem; }
.history { margin: 0; padding: 0; list-style: none; }
.history > li { padding: .75rem 0; border-top: 1px solid var(--border); }
.history-meta { margin: 0 0 .2rem; color: var(--muted); font-size: .85rem; }
.history-subject { margin: 0 0 .4rem; font-weight: 600; }

/* ---------- Benachrichtigungen, Abos, @-Vorschläge ---------- */

.bell-wrap { display: inline-flex; }
.bell { position: relative; }
.bell.has-unread { color: var(--accent); border-color: var(--accent); }
.bell-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 1.2rem;
    padding: 0 .25rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.2rem;
    text-align: center;
}
.notif-pop {
    position: fixed;
    inset: auto;
    width: min(24rem, calc(100vw - 16px));
    max-height: min(70vh, 32rem);
    margin: 0;
    padding: 0;
    overflow: auto;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
.notif-list { margin: 0; padding: .25rem; list-style: none; }
.notif-list a { display: grid; gap: .1rem; padding: .5rem .6rem; border-radius: 6px; color: var(--text); }
.notif-list a:hover { background: var(--hover); text-decoration: none; }
.notif-list .is-unread a { background: var(--active); }
.notif-title { overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.notif-list time { color: var(--muted); font-size: .78rem; }
.notif-empty { margin: 0; padding: 1rem .9rem; color: var(--muted); }
.notif-foot { margin: 0; padding: .45rem .75rem; border-top: 1px solid var(--border); font-size: .85rem; }
.notif-page .notif-head { padding: 0 0 .6rem; }

.subscribe.is-on { border-color: var(--accent); }

.mention-box {
    position: fixed;
    z-index: 50;
    min-width: 12rem;
    max-width: 20rem;
    margin: 0;
    padding: .25rem;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.mention-box li { padding: .35rem .55rem; border-radius: 5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-box li[aria-selected="true"], .mention-box li:hover { background: var(--active); }

/* ---------- Testsystem ---------- */

.env-badge {
    position: relative;
    flex: none;
    padding: .15rem .5rem;
    border-radius: 999px;
    background: #d97706;
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    cursor: help;
}
.env-badge-text {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 30;
    display: none;
    width: min(22rem, 80vw);
    padding: .6rem .75rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid #d97706;
    box-shadow: var(--shadow);
    color: var(--text);
    font-weight: 400;
    font-size: .85rem;
    line-height: 1.45;
}
.env-badge:hover .env-badge-text, .env-badge:focus .env-badge-text { display: block; }
.topbar:has(.env-badge) { border-bottom: 2px solid #d97706; }

/* ---------- Boards: Auswahl und Übersicht ---------- */

.board-switch { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .45rem; margin-left: -.45rem; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 1.05rem; cursor: pointer; }
.board-switch::after { content: "▾"; color: var(--muted); font-size: .8em; }
.board-switch:hover { background: var(--hover); }
.board-pop {
    position: fixed;
    inset: auto;
    margin: 0;
    width: min(22rem, calc(100vw - 16px));
    padding: .35rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.board-pop:popover-open { display: grid; gap: 2px; }
.board-pop a { display: grid; gap: .1rem; padding: .5rem .6rem; border-radius: 6px; color: var(--text); }
.board-pop a:hover { background: var(--hover); text-decoration: none; }
.board-pop a[aria-current="page"] { background: var(--active); }
.board-pop small { color: var(--muted); }
.board-pop.layout-pop { width: 14rem; }
.layout-pop-panes { display: grid; gap: 2px; margin-bottom: .3rem; }
.layout-pop-label { padding: .3rem .6rem .15rem; color: var(--muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
:is([data-layout-choice], .layout-pop-read) { display: flex; align-items: center; gap: .65rem; padding: .45rem .6rem; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
:is([data-layout-choice], .layout-pop-read):hover { background: var(--hover); }
[data-layout-choice][aria-pressed="true"] { background: var(--active); }
[data-layout-choice] svg { flex: none; color: var(--muted); }
[data-layout-choice][aria-pressed="true"] svg { color: var(--accent); }
.layout-pop .view-switch { margin: 0 .15rem; }
.layout-pop-read { margin-top: .4rem; border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; padding-top: .55rem; }
.board-pop .board-pop-all { margin-top: .2rem; border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; color: var(--link); font-size: .9rem; }

.boards-head { margin: 0 0 .75rem; line-height: 0; }
.boards-head img { max-width: 100%; height: auto; filter: var(--logo-filter); }
.brand img { filter: var(--logo-filter); }

.board-list { margin: 0; padding: 0; list-style: none; }
.board-list > li { display: grid; gap: .35rem; padding: .9rem 0; border-top: 1px solid var(--border); }
.board-list > li:first-child { border-top: 0; }
.board-link { display: grid; gap: .2rem; color: var(--text); }
.board-link:hover { text-decoration: none; }
.board-link:hover strong { color: var(--accent); }
.board-title { display: flex; align-items: center; gap: .6rem; font-size: 1.1rem; }
.board-title .count { padding: 0 .45rem; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: .75rem; font-weight: 700; }
.board-text { color: var(--muted); }
.board-stats { color: var(--muted); font-size: .88rem; }

/* ---------- Ladezustand ---------- */

.htmx-request.pane, .pane:has(> .htmx-request) { opacity: .75; transition: opacity .15s .1s; }

/* ---------- Kopfzeile zu schmal (Handy oder schmales Fenster): Navigation ins Menü ---------- */
/* .is-compact setzt das Skript in forum/_topbar.html.twig, sobald nicht mehr alles in eine Zeile passt */

.topnav > * { white-space: nowrap; }
.topbar.is-compact .menu-btn { display: inline-grid; margin-left: auto; }
.topbar.is-compact .topnav {
    display: none;
    position: absolute;
    top: 100%;
    right: 8px;
    z-index: 20;
    flex-direction: column;
    gap: 0;
    min-width: 12rem;
    padding: .35rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.topbar.is-compact .topnav a, .topbar.is-compact .topnav .user-name { padding: .55rem .7rem; border-radius: 6px; }
.topbar.is-compact[data-menu-open] .topnav { display: flex; }

/* ---------- Mobile: ein Bereich zur Zeit ---------- */

/* Schmal oder niedrig (Handy quer) – dieselbe Bedingung steht in forum.js und _topbar.html.twig */
@media (max-width: 720px), (max-height: 500px) {
    :root { --font-size: 15px; --indent: 10px; }

    .topbar { gap: .6rem; padding: .4rem 16px; }
    .board-desc { display: none; }
    .board-name { min-width: 0; }
    .board-name strong { overflow: hidden; text-overflow: ellipsis; }
    .layout-pop-panes { display: none; } /* die Anordnung gilt nur auf dem Desktop */
    .profile-fields { grid-template-columns: 1fr; gap: .1rem; }
    .profile-fields dd { margin-bottom: .5rem; }

    /* Erst die Threadliste; ist ein Thread gewählt, oben die Nachricht und unten der Baum
       (wie die alte Mobilseite). Schreiben und Seiten ohne Thread nutzen die ganze Höhe. */
    .panes { grid-template-rows: minmax(0, 1fr); grid-template-areas: "main"; padding: 0; }
    .splitter { display: none; }
    .pane { display: none; grid-area: main; border: 0; border-radius: 0; }
    .panes[data-view="threads"] #pane-threads,
    .panes[data-view="thread"] #pane-message,
    .panes[data-view="message"] #pane-message,
    .panes[data-view="compose"] #pane-message { display: block; }

    .panes:is([data-view="thread"], [data-view="message"]):has(#pane-thread .tree) {
        grid-template-rows: var(--h-msg-mobile, 58%) 16px minmax(0, 1fr);
        grid-template-areas: "main" "split" "tree";
    }
    .panes:is([data-view="thread"], [data-view="message"]):has(#pane-thread .tree) #pane-thread { display: block; grid-area: tree; }
    .panes:is([data-view="thread"], [data-view="message"]):has(#pane-thread .tree) [data-splitter="thread"] {
        display: block;
        grid-area: split;
        background: var(--surface-2);
        border-block: 1px solid var(--border);
    }
    .splitter::after { height: 4px; }

    .back { display: inline-grid; }
    /* Zurück führt immer zur Threadliste – einer reicht */
    .panes:has(#pane-message .back) #pane-thread .back { display: none; }

    .threadlist > li.t { border-bottom: 1px solid var(--border); }
    :root:not([data-threadlist="table"]) .threadlist > li.t { padding: .45rem 16px .45rem calc(16px + 1.2em); }
    /* wie die schmale Liste oben (Handy quer kann breiter sein als 46rem) */
    :root[data-threadlist="table"] .threadlist > li.t {
        grid-template-columns: minmax(0, max-content) minmax(0, 1fr) auto;
        grid-template-areas: "subject subject replies" "author views last";
        gap: 0 .75rem;
        padding: .45rem 16px;
    }
    :root[data-threadlist="table"] .t-subject { grid-area: subject; white-space: normal; }
    :root[data-threadlist="table"] .t-replies { grid-area: replies; }
    :root[data-threadlist="table"] .t-author { grid-area: author; font-size: var(--list-small); }
    :root[data-threadlist="table"] .t-author:not(.is-highlight) { color: var(--muted); }
    :root[data-threadlist="table"] .t-views { grid-area: views; text-align: left; font-size: var(--list-small); }
    :root[data-threadlist="table"] .t-date { display: none; }
    :root[data-threadlist="table"] .t-last { grid-area: last; text-align: right; }
    :root[data-threadlist="table"] :is(.t-views, .t-replies)::before { content: ""; display: inline-block; width: 1.05em; height: 1.05em; margin-right: .25em; vertical-align: -.2em; background: currentColor; mask: var(--icon) center / contain no-repeat; }
    :root[data-threadlist="table"] .tl-head { display: none; }

    .tree > li { padding-block: .5rem; border-bottom: 1px solid var(--border); white-space: normal; }
    .msg { padding: .75rem 16px 1.25rem; }
}

/* Handy quer: zu niedrig für übereinander – Baum links, Nachricht rechts, beide in voller Höhe */
@media (max-height: 500px) and (orientation: landscape) {
    .panes:is([data-view="thread"], [data-view="message"]):has(#pane-thread .tree) {
        grid-template-rows: minmax(0, 1fr);
        grid-template-columns: var(--w-tree-mobile, 38%) 16px minmax(0, 1fr);
        grid-template-areas: "tree split main";
    }
    .panes:is([data-view="thread"], [data-view="message"]):has(#pane-thread .tree) [data-splitter="thread"] {
        cursor: col-resize;
        border-block: 0;
        border-inline: 1px solid var(--border);
    }
    .splitter::after { width: 4px; height: 42px; }
}
