:root {
    --bg: #f5f6f8;
    --fg: #1a1a2e;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff3ff;
    --border: #dde1e7;
    --card-bg: #fff;
    --nav-bg: #1e293b;
    --nav-fg: #e2e8f0;
    --sidebar-bg: #fff;
    --sidebar-w: 320px;
    --badge-bg: #6366f1;
    --badge-fg: #fff;
    --current-bg: #dbeafe;
    --current-border: #2563eb;
    --muted: #64748b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.55;
    font-size: 14px;
}

/* ---- Header ---- */
header {
    background: var(--nav-bg);
    color: var(--nav-fg);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0 1rem;
    max-width: 100%;
}
.logo {
    color: var(--nav-fg);
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.7rem 0;
    white-space: nowrap;
}
.header-tabs {
    display: flex;
    gap: 0;
}
.tab {
    color: var(--nav-fg);
    text-decoration: none;
    padding: 0.7rem 1rem;
    opacity: 0.7;
    border-bottom: 2px solid transparent;
    font-size: 0.85rem;
    transition: opacity 0.15s, border-color 0.15s;
}
.tab:hover { opacity: 1; }
.tab.active { opacity: 1; border-bottom-color: var(--accent); }

/* ---- Layout: sidebar + content ---- */
.layout {
    display: flex;
    min-height: calc(100vh - 42px);
}

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 42px;
    height: calc(100vh - 42px);
    overflow: hidden;
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.sidebar-title {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}
.sidebar-actions {
    display: flex;
    gap: 0.25rem;
}
.sidebar-actions button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-actions button:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}
.sidebar-tree {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem 0;
}

.content {
    flex: 1;
    padding: 1.5rem 2rem;
    max-width: 900px;
    min-width: 0;
}

/* ---- Tree ---- */
.tree, .tree ul {
    list-style: none;
    padding-left: 0;
}
.tree ul { padding-left: 1rem; }
.tree li {
    margin: 0;
    position: relative;
}
.tree-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    padding: 0.6rem 0.75rem 0.2rem;
    font-weight: 600;
}

.tree details > summary {
    cursor: pointer;
    list-style: none;
    padding: 0.2rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 4px;
    font-size: 0.82rem;
}
.tree details > summary::-webkit-details-marker { display: none; }
.tree details > summary::before {
    content: "\25B6";
    font-size: 0.55rem;
    color: var(--muted);
    transition: transform 0.15s;
    flex-shrink: 0;
    width: 12px;
}
.tree details[open] > summary::before {
    transform: rotate(90deg);
}
.tree details > summary:hover { background: var(--accent-light); }

.tree-link {
    color: var(--fg);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex: 1;
    min-width: 0;
}
.tree-link:hover { color: var(--accent); }
.tree-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Leaf nodes (no details) */
.tree li > .tree-link {
    padding: 0.2rem 0.75rem 0.2rem 1.5rem;
    font-size: 0.82rem;
    border-radius: 4px;
}
.tree li > .tree-link:hover { background: var(--accent-light); }

/* Current / active node */
.tree-link.current,
.tree li.active > .tree-link,
.tree li.active > details > summary {
    background: var(--current-bg);
    border-left: 3px solid var(--current-border);
    font-weight: 600;
}
.tree-link.current { color: var(--accent); }

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--badge-bg);
    color: var(--badge-fg);
    font-size: 0.65rem;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    flex-shrink: 0;
    margin-left: auto;
}

/* ---- Content styles ---- */
h1 { font-size: 1.5rem; margin-bottom: 0.4rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.6rem; color: var(--fg); }
.subtitle { color: var(--muted); margin-bottom: 1.5rem; font-size: 0.9rem; }
.doc-count { color: var(--muted); margin-bottom: 0.75rem; }
.empty { color: var(--muted); font-style: italic; }

/* Stats bar */
.stats-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.stat {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.stat strong { color: var(--accent); font-size: 1.3rem; line-height: 1; }
.stat span { font-size: 0.75rem; color: var(--muted); }

/* University grid */
.uni-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.uni-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.8rem;
    text-decoration: none;
    color: var(--fg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    transition: border-color 0.15s;
}
.uni-card:hover { border-color: var(--accent); }
.uni-card strong { font-weight: 500; }

/* Breadcrumb */
.breadcrumb {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 1rem;
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    font-size: 0.85rem;
}
th, td { padding: 0.45rem 0.65rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; font-size: 0.8rem; color: var(--muted); }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
code { background: var(--bg); padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.8rem; }

.meta-table { max-width: 550px; }
.meta-table th { width: 120px; }

/* Buttons */
.btn, .btn-sm {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 0.45rem 0.9rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
}
.btn-sm { padding: 0.2rem 0.55rem; font-size: 0.78rem; }
.btn:hover, .btn-sm:hover { background: var(--accent-hover); }

/* Type icon column */
.type-icon { font-size: 1rem; text-align: center; width: 30px; }

/* Doc preview (text notes) */
.doc-preview {
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 0.15rem;
    line-height: 1.4;
}

/* Commentary section */
.commentary {
    margin-top: 2rem;
}
.commentary details {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.commentary details + details {
    border-top: 1px solid var(--border);
}
.commentary summary {
    cursor: pointer;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    font-size: 0.85rem;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.commentary summary::-webkit-details-marker { display: none; }
.commentary summary::before {
    content: "\25B6";
    font-size: 0.55rem;
    color: var(--muted);
    transition: transform 0.15s;
}
.commentary details[open] > summary::before {
    transform: rotate(90deg);
}
.commentary summary:hover { background: var(--accent-light); }
.commentary-body {
    padding: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--fg);
}

/* Inline content cards */
.inline-content {
    margin-top: 2rem;
}
.content-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}
.content-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
}
.content-card-header strong { font-weight: 600; }
.content-date {
    margin-left: auto;
    color: var(--muted);
    font-size: 0.75rem;
}
.content-card-body {
    padding: 0.75rem;
    font-size: 0.88rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Contribute hint box */
.contribute-hint {
    margin-top: 2rem;
    padding: 1rem 1.25rem;
    background: var(--accent-light);
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    font-size: 0.85rem;
}
.contribute-hint strong {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--accent);
}
.contribute-hint p {
    margin: 0.25rem 0;
    color: var(--fg);
}
.contribute-hint a { color: var(--accent); }
.contribute-hint code {
    background: #fff;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.8rem;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .sidebar { width: 260px; min-width: 260px; }
    .content { padding: 1rem; }
}
@media (max-width: 700px) {
    .layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        max-height: 50vh;
        position: relative;
        top: 0;
    }
    .content { max-width: 100%; }
}

.rating { white-space: nowrap; }

/* ---- Tabelle (Bedienung wie acc-peering-webansicht-1) ---- */
.leise { color: var(--muted); }
.filterrad { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; margin: 0.8rem 0; }
.filterrad .filter { display: flex; flex-direction: column; font-size: 0.85em; gap: 0.15rem; }
.filterrad input, .filterrad select { font: inherit; padding: 0.3rem 0.4rem; border: 1px solid var(--border); border-radius: 4px; min-width: 10rem; }
button.klein { font: inherit; font-size: 0.85em; padding: 0.15rem 0.6rem; border: 1px solid var(--border); border-radius: 4px; background: var(--card-bg); color: var(--accent); cursor: pointer; }
button.klein:hover { border-color: var(--accent); }
button.klein:disabled { color: var(--muted); cursor: default; }
button.sort { padding: 0 0.35rem; }
.spalten-wahl > summary { cursor: pointer; color: var(--accent); margin: 0.4rem 0; }
.spalten-block { margin-top: 0.4rem; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); }
.spalten-knoepfe { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
input.spalten-suche { margin: 0.4rem 0; width: 16rem; max-width: 100%; font: inherit; padding: 0.3rem 0.4rem; border: 1px solid var(--border); border-radius: 4px; }
.spalten-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 0.15rem 1rem; font-size: 0.9em; }
.spalten-raster label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.spalten-ordnung { margin-top: 0.6rem; display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; font-size: 0.85em; }
.spalten-chip { display: inline-flex; align-items: center; gap: 0.1rem; padding: 0 0.2rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); }
.spalten-chip button { padding: 0 0.25rem; }
button.chip-weg { margin-left: 0.2em; padding: 0 0.35em; color: #b91c1c; }
.tabell-ram { overflow-x: auto; }
table.tabell th { white-space: nowrap; }
table.tabell .filterzeile input { width: 100%; min-width: 5rem; font: inherit; font-size: 0.85em; padding: 0.2rem 0.3rem; border: 1px solid var(--border); border-radius: 4px; }
img.tumme { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; display: block; }

/* ---- Suche im Kopf (wie die Webansicht) ---- */
.header-inner { display: flex; align-items: center; }
.sok { position: relative; margin-left: auto; }
.sok input { font: inherit; font-size: 0.85rem; width: 16rem; max-width: 40vw; padding: 0.3rem 0.5rem; border: 1px solid var(--border); border-radius: 4px; }
#sok-lista { position: absolute; right: 0; top: 2.1rem; z-index: 20; min-width: 22rem; max-width: 80vw; margin: 0; padding: 0.2rem 0; list-style: none; background: var(--card-bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
#sok-lista li { padding: 0.3rem 0.7rem; cursor: pointer; font-size: 0.88rem; }
#sok-lista li.aktiv, #sok-lista li:hover { background: var(--accent-light); }
#sok-lista li.fritext { border-top: 1px solid var(--border); color: var(--accent); }

/* ---- Svar i tabellen ---- */
.rad-knappar { display: flex; gap: 0.5rem; align-items: center; margin: 0.4rem 0; }
.rad-knappar .doc-count { margin: 0 0.5rem 0 0; }
button.fäll { border: none; background: none; color: var(--accent); cursor: pointer; padding: 0 0.3rem 0 0; font-size: 0.9em; }
span.fäll.tom { display: inline-block; width: 1em; }
a.svara { font-size: 0.8em; white-space: nowrap; }
tr.detaljrad > td { background: var(--bg); }
ul.svarstrad { list-style: none; margin: 0.2rem 0 0.2rem 0.6rem; padding-left: 0.8rem; border-left: 2px solid var(--border); }
ul.svarstrad li { margin: 0.35rem 0; }
.svar-huvud { font-size: 0.85em; }
.svar-text { margin: 0.15rem 0; white-space: pre-wrap; }
ul.svarstrad summary { cursor: pointer; }
table.tabell code { white-space: nowrap; }

/* ---- Flyouts an Links (wie die Webansicht) ---- */
.flyout { position: absolute; z-index: 60; width: 23rem; max-width: calc(100vw - 16px); padding: 0.6rem 0.8rem; background: var(--card-bg); color: var(--fg);
    border: 1px solid var(--accent); border-radius: 6px; box-shadow: 0 6px 22px rgba(0,0,0,0.18); font-size: 0.85rem; line-height: 1.4; text-align: left; }
.flyout-titel { font-weight: 600; margin-bottom: 0.25rem; }
.flyout-text { color: var(--muted); margin-bottom: 0.3rem; }
.flyout ul { margin: 0.1rem 0 0; padding-left: 1.1rem; }
.flyout-poster { max-height: 22rem; overflow-y: auto; margin-bottom: 0.3rem; }
.flyout-post { display: flex; gap: 0.5rem; padding: 0.3rem 0; border-top: 1px solid var(--border); }
.flyout-post img { width: 40px; height: 40px; object-fit: cover; border-radius: 3px; flex: none; }
.flyout-post-huvud { font-size: 0.85em; }
span.svar-antal { cursor: help; border-bottom: 1px dotted var(--muted); padding: 0 0.2rem; }
.flyout-bild-stor { display: block; max-width: 100%; max-height: 20rem; margin: 0.2rem auto 0.4rem; border-radius: 4px; }
.flyout-bild { float: right; width: 72px; height: 72px; object-fit: cover; border-radius: 4px; margin: 0 0 0.3rem 0.5rem; }
.flyout-fakta { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.6rem; margin: 0.2rem 0 0.4rem; }
.flyout-fakta dt { color: var(--muted); }
.flyout-fakta dd { margin: 0; }
.flyout ul { clear: both; }
/* Spalten ziehen und einzeilig (wie die Webansicht) */
th.ziehbar { cursor: grab; }
th.ziehbar:hover::before { content: "⠿ "; color: var(--muted); }
th.zieht { opacity: 0.5; }
th.ziel-links { box-shadow: inset 3px 0 0 var(--accent); }
th.ziel-rechts { box-shadow: inset -3px 0 0 var(--accent); }
button.spalte-knopf[aria-pressed="true"], .rad-knappar button[aria-pressed="true"] { background: var(--accent-light); }
table.tabell td.spalte-zu { max-width: 14rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: zoom-in; }
.flyout-avsnitt { margin: 0.2rem 0 0.4rem; max-height: 16rem; overflow-y: auto; }
.flyout-avsnitt ul { margin: 0.1rem 0 0; padding-left: 1.1rem; }
.flyout-lankar a .leise { text-decoration: none; }
.botmarker { margin: 0; color: var(--muted); font-size: 0.85em; }
footer.botfot { margin: 2rem 0 1rem; padding-top: 0.6rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.8rem; }
/* Testbetrieb und Security-Advice (wie Webansicht und openCode) */
a.testbetrieb { text-decoration: none; margin-right: 0.6rem; font-size: 1.05rem; }
p.hinweis { margin: 0 0 1rem; padding: 0.45rem 0.7rem; background: #fff7e6; border: 1px solid #f0c36d; border-radius: 6px; color: var(--fg); font-size: 0.85rem; }
