/* Mindmap – Stylesheet */

:root {
    color-scheme: light dark;
    --canvas: #e9edf0;
    --grid: #c5ced6;
    --surface: #ffffff;
    --surface-2: #f3f6f8;
    --ink: #17212b;
    --muted: #586573;
    --line: #d3dae0;
    --line-strong: #8b98a5;
    --accent: #0b6e79;
    --accent-ink: #ffffff;
    --danger: #b3261e;
    --shadow: 0 1px 2px rgba(23, 33, 43, .08), 0 6px 18px rgba(23, 33, 43, .08);
    --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

/* Dunkles Erscheinungsbild: wenn das System es verlangt und nicht «hell» gewählt ist ... */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --canvas: #141a20;
        --grid: #2a343e;
        --surface: #1e262e;
        --surface-2: #26303a;
        --ink: #e6ebef;
        --muted: #98a5b1;
        --line: #303b46;
        --line-strong: #6f7d8a;
        --accent: #53c1cc;
        --accent-ink: #0c1a1d;
        --danger: #ff8a80;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
    }
}
/* ... oder wenn es ausdrücklich gewählt ist. */
:root[data-theme="dark"] {
    --canvas: #141a20;
    --grid: #2a343e;
    --surface: #1e262e;
    --surface-2: #26303a;
    --ink: #e6ebef;
    --muted: #98a5b1;
    --line: #303b46;
    --line-strong: #6f7d8a;
    --accent: #53c1cc;
    --accent-ink: #0c1a1d;
    --danger: #ff8a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
    color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
    font: 15px/1.45 var(--font);
    color: var(--ink);
    background: var(--canvas);
    overflow: hidden;
}

button, input, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Schaltflächen und Felder ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--line-strong); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover:not(:disabled) { border-color: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-icon { width: 34px; padding: 0; font-size: 18px; line-height: 1; }

input[type="text"], input[type="url"], textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}
textarea { resize: vertical; min-height: 64px; }

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

.app {
    display: grid;
    grid-template-columns: clamp(300px, 32vw, 480px) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
}

.toolbar {
    grid-row: 1;
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.brand { margin-right: 6px; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.toolbar-space { flex: 1; }
.zoom { display: inline-flex; align-items: center; gap: 4px; }
.zoom-label { min-width: 52px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.status { min-width: 96px; text-align: right; color: var(--muted); font-size: 13px; }
.status.is-error { color: var(--danger); font-weight: 600; }

select {
    min-height: 34px;
    max-width: 240px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    font: inherit;
    color: inherit;
}

/* ---------- Gliederung ---------- */

.outline {
    grid-row: 3;
    grid-column: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border-right: 1px solid var(--line);
}
#outline {
    flex: 1;
    min-height: 0;
    padding: 14px 16px;
    border: 0;
    border-radius: 0;
    resize: none;
    background: var(--surface);
    font-size: 15px;
    line-height: 24px;
    tab-size: 4;
    -moz-tab-size: 4;
    white-space: pre;
    overflow: auto;
}
#outline:focus-visible { outline-offset: -2px; }
.outline-help {
    margin: 0;
    padding: 10px 16px 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.5;
}
.outline-help kbd {
    padding: 0 5px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface-2);
    font: inherit;
}
body.is-dropping #outline, body.is-dropping .viewport { box-shadow: inset 0 0 0 3px var(--accent); }

/* ---------- Zeichenfläche ---------- */

.viewport {
    grid-row: 3;
    grid-column: 2;
    position: relative;
    min-height: 0;
    overflow: hidden;
    overflow: clip; /* kein Scroll-Container: Fokuswechsel verschiebt die Fläche nicht */
    background-color: var(--canvas);
    background-image: radial-gradient(circle, var(--grid) 1.2px, transparent 1.4px);
    background-size: 24px 24px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
body.is-panning .viewport { cursor: grabbing; }
/* Solange gezogen wird, dürfen eingebettete Videos keine Mausereignisse abfangen. */
body.is-panning iframe { pointer-events: none; }

.world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; }

.edges { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.edges path { fill: none; stroke: var(--line-strong); stroke-width: 2.5; stroke-linecap: round; }

.node {
    --node-color: var(--line-strong);
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: max-content;
    max-width: 260px;
    padding: 8px 14px;
    background: var(--surface);
    border: 2px solid var(--node-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    text-align: center;
}
.node.has-video { max-width: none; }
.node.is-root {
    padding: 12px 20px;
    border-radius: 18px;
    border-color: var(--ink);
    background: var(--ink);
    color: var(--surface);
    font-size: 18px;
    font-weight: 700;
}
.node.is-selected { outline: 3px solid var(--accent); outline-offset: 3px; }

.node-slot { max-width: 100%; }
.node-slot:empty { display: none; }
.node-text { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
.node-text:empty::before { content: "Ohne Text"; color: var(--muted); font-style: italic; }
.node.is-root .node-text:empty::before { color: inherit; opacity: .7; }

.node-image {
    display: block;
    max-width: 220px;
    max-height: 160px;
    border-radius: 8px;
    cursor: zoom-in;
    -webkit-user-drag: none;
}

.node-video {
    position: relative;
    width: 288px;
    height: 162px;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}
.node-video img, .node-video iframe { display: block; width: 100%; height: 100%; border: 0; }
.node-video img { object-fit: cover; -webkit-user-drag: none; }
.video-play {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border: 0;
    background: rgba(0, 0, 0, .18);
    cursor: pointer;
}
.video-play span {
    display: grid;
    place-items: center;
    width: 58px;
    height: 40px;
    border-radius: 10px;
    background: #d91c1c;
    color: #fff;
    font-size: 18px;
}
.video-play:hover span { background: #f02929; }
.video-play:focus-visible { outline-offset: -4px; outline-color: #fff; }

.node-link {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.node.is-root .node-link { color: inherit; }

.empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 24px;
    text-align: center;
    cursor: default;
}
.empty h1 { margin: 0; font-size: 26px; letter-spacing: -.01em; }
.empty p { margin: 0 0 12px; max-width: 46ch; color: var(--muted); }

/* ---------- Bildansicht und Meldungen ---------- */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    background: rgba(10, 14, 18, .88);
    cursor: zoom-out;
}
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 6px; }
.lightbox .btn { position: absolute; top: 14px; right: 14px; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    z-index: 60;
    transform: translateX(-50%);
    max-width: min(92vw, 560px);
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--ink);
    color: var(--surface);
    box-shadow: var(--shadow);
}

.setup-note { max-width: 60ch; margin: 12vh auto; padding: 0 20px; }
.setup-note code { padding: 1px 5px; border-radius: 4px; background: var(--surface); }

/* ---------- Menü, Mitbearbeiter, Hinweise ---------- */

.menu { position: relative; }
.menu-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 40;
    min-width: 250px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.menu-list hr { margin: 6px 0; border: 0; border-top: 1px solid var(--line); }
.menu-item {
    display: block;
    width: 100%;
    padding: 7px 10px;
    border: 0;
    border-radius: 6px;
    background: none;
    text-align: left;
    cursor: pointer;
}
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--surface-2); }
.menu-item:disabled { opacity: .5; cursor: default; }
.menu-danger { color: var(--danger); }
.menu-field { display: flex; flex-direction: column; gap: 4px; padding: 4px 10px 8px; }
.menu-field span { font-size: 12.5px; color: var(--muted); }

.peers { display: inline-flex; align-items: center; }
.peer {
    --peer-color: var(--muted);
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    margin-left: -6px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--peer-color);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: default;
}
.peer:first-child { margin-left: 0; }

.node-peers {
    position: absolute;
    right: 8px;
    bottom: 100%;
    display: flex;
    gap: 3px;
    margin-bottom: 1px;
    pointer-events: none;
}
.node-peer {
    --peer-color: var(--muted);
    max-width: 120px;
    padding: 0 7px;
    overflow: hidden;
    border-radius: 6px 6px 0 0;
    background: var(--peer-color);
    color: #fff;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notices { grid-row: 2; grid-column: 1 / -1; }
.notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0;
    padding: 8px 12px;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
}
.notice-info { background: var(--surface-2); color: var(--ink); border-bottom: 1px solid var(--line); font-weight: 500; }
.version { display: block; margin-top: 4px; opacity: .8; }
body.is-busy, body.is-busy .viewport { cursor: progress; }

/* ---------- Suche, Äste einklappen, Aufgaben, Verlauf ---------- */

.search { display: inline-flex; align-items: center; gap: 6px; }
#f-search { width: 170px; min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.search-count { min-width: 34px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.world.is-searching .node:not(.is-match) { opacity: .3; }
.world.is-searching .edges { opacity: .3; }
.node.is-match { box-shadow: 0 0 0 4px rgba(255, 196, 0, .55), var(--shadow); }

.node-toggle {
    position: absolute;
    top: 50%;
    left: calc(100% + 3px);
    display: grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    transform: translateY(-50%);
    border: 2px solid var(--node-color);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}
.node.is-left .node-toggle { left: auto; right: calc(100% + 3px); }
.node-toggle:hover { background: var(--surface-2); }

.node-task {
    position: relative;
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-right: 6px;
    border: 2px solid currentColor;
    border-radius: 4px;
    vertical-align: -2px;
    cursor: pointer;
}
.node.is-done .node-task { background: currentColor; }
.node.is-done .node-task::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 0;
    width: 4px;
    height: 8px;
    border: solid var(--surface);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.node.is-done .node-text { color: var(--muted); text-decoration: line-through; }

.dialog {
    width: min(92vw, 520px);
    max-height: min(84vh, 640px);
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(10, 14, 18, .5); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 19px; }
.dialog-note { margin: 8px 0 12px; color: var(--muted); font-size: 13.5px; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-top: 1px solid var(--line);
}
.history-list small { display: block; color: var(--muted); }
.history-empty { color: var(--muted); }

/* ---------- Anmeldung, Konto, Neuigkeiten, Hilfe ---------- */

input[type="email"], input[type="password"], .dialog input[type="text"], .auth input[type="text"] {
    width: 100%;
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
}

.auth {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 20px;
    overflow: auto;
    background: var(--canvas);
}
.auth-card {
    width: min(100%, 400px);
    padding: 28px 28px 22px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 18px; font-size: 26px; letter-spacing: -.01em; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form h2 { margin: 0; font-size: 18px; }
.auth-form p { margin: 0; color: var(--muted); }
.auth-form label, .dialog-form label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; }
.auth-form small { font-weight: 400; color: var(--muted); }
.auth-form .check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.auth-form .btn { min-height: 40px; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; }
.auth-message, .dialog-message {
    margin: 0 0 14px;
    padding: 9px 12px;
    border-radius: 8px;
    background: var(--surface-2);
    border-left: 4px solid var(--accent);
}
.auth-message.is-error, .dialog-message.is-error { border-left-color: var(--danger); }

.link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.btn-account {
    width: 34px;
    padding: 0;
    border-radius: 50%;
    background: var(--ink);
    border-color: var(--ink);
    color: var(--surface);
    font-size: 12px;
    font-weight: 700;
}

.dialog-form { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); }
.dialog-form label { width: 100%; }
.dialog-form h3 { margin: 0; font-size: 16px; }
.dialog-form p { margin: 0; }
.dialog-form form { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; width: 100%; }
#totp-setup { display: flex; flex-direction: column; gap: 10px; }
#totp-qr { align-self: center; width: 200px; height: 200px; border-radius: 8px; }
#totp-secret { padding: 2px 6px; border-radius: 5px; background: var(--surface-2); font-size: 14px; letter-spacing: .06em; overflow-wrap: anywhere; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }

.badge { margin-left: 6px; padding: 1px 7px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11.5px; font-weight: 700; }
.menu-field select { width: 100%; max-width: none; }

.notes h3 { margin: 16px 0 4px; font-size: 16px; }
.notes h3 small { margin-left: 6px; font-weight: 400; color: var(--muted); }
.notes ul, .tips { margin: 6px 0 0; padding-left: 20px; }
.notes li, .tips li { margin: 5px 0; }

.keys { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.keys th { width: 42%; padding: 6px 10px 6px 0; text-align: left; font-weight: 400; white-space: nowrap; vertical-align: top; }
.keys td { padding: 6px 0; }
.keys tr + tr { border-top: 1px solid var(--line); }
kbd { padding: 0 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2); font: inherit; }

.slot-progress { font-size: 12px; font-weight: 600; color: var(--muted); }
.slot-progress.is-complete { color: var(--accent); }
.node.is-root .slot-progress { color: inherit; opacity: .8; }

/* ---------- Freigaben, Verwaltung ---------- */

.readonly-note { margin: 0; padding: 8px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 13.5px; font-weight: 600; }
#outline[readonly] { color: var(--muted); }
.clock-note { padding: 8px 12px; border-left: 4px solid var(--danger); border-radius: 8px; background: var(--surface-2); color: var(--ink) !important; }
.codes { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.codes pre { margin: 0; font-size: 15px; line-height: 1.7; columns: 2; column-gap: 28px; }

.dialog select, .dialog input[type="search"] { width: 100%; max-width: none; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.share-people { width: 100%; margin: 0; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 10px; }
.share-people legend { padding: 0 6px; font-size: 14px; font-weight: 600; }
.share-list { list-style: none; max-height: 220px; margin: 8px 0 0; padding: 0; overflow-y: auto; }
.share-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.share-list small { display: block; color: var(--muted); }
.share-list select { width: auto; min-height: 32px; padding: 3px 8px; }

.dialog-wide { width: min(96vw, 980px); }
.tabs { display: flex; gap: 4px; margin: 12px 0; border-bottom: 1px solid var(--line); }
.tab { padding: 8px 14px; border: 0; border-bottom: 3px solid transparent; background: none; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.admin-create { display: grid; grid-template-columns: 1fr 1.4fr auto auto; gap: 8px; margin-bottom: 12px; }
.admin-create select { width: auto; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { padding: 6px 8px; text-align: left; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
.admin-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table small { display: block; color: var(--muted); }
.admin-table select { width: auto; min-height: 32px; padding: 3px 8px; }
.admin-table .actions { display: flex; flex-wrap: wrap; gap: 4px; }
.admin-table .btn { min-height: 28px; padding: 0 8px; font-size: 13px; }
.tag { display: inline-block; margin: 0 4px 2px 0; padding: 1px 7px; border-radius: 9px; background: var(--surface-2); font-size: 12px; white-space: nowrap; }
.tag.is-bad { background: var(--danger); color: var(--surface); }
.tag.is-good { background: var(--accent); color: var(--accent-ink); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------- Lernen: Markierungen, Erklärungen, Lernmodus ---------- */

.node.has-fill { border-color: var(--fill); background: color-mix(in srgb, var(--fill) 20%, var(--surface)); }
.node.is-root.has-fill { background: var(--fill); border-color: var(--fill); color: #fff; }
.node.is-important { border-width: 4px; font-weight: 700; }
.node.is-question { border-style: dashed; }
.slot-marks { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.node-mark {
    padding: 0 7px;
    border-radius: 9px;
    background: var(--ink);
    color: var(--surface);
    font-size: 11px;
    font-weight: 700;
    line-height: 17px;
    white-space: nowrap;
}
.node.is-root .node-mark { background: var(--surface); color: var(--ink); }
.node-note { max-width: 100%; font-size: 12.5px; font-weight: 400; line-height: 1.35; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.node.is-root .node-note { color: inherit; opacity: .85; }

.mark-icon { display: inline-block; min-width: 34px; font-weight: 700; }
.fill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.fill-swatch { width: 28px; height: 28px; padding: 0; border: 2px solid var(--surface); border-radius: 50%; box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; }
.fill-swatch.is-none { background: linear-gradient(135deg, var(--surface) 46%, var(--danger) 46%, var(--danger) 54%, var(--surface) 54%); }

/* Lernmodus: nur die Mindmap, Verdecktes zeigt ein Fragezeichen */
.app.is-learning .outline { display: none; }
.app.is-learning .viewport { grid-column: 1 / -1; }
.app.is-learning .node-toggle, .app.is-learning .node-peers { display: none; }
.notice-learn { flex-wrap: wrap; background: var(--ink); color: var(--surface); }
.notice-learn .btn:not(.btn-primary) { color: var(--ink); }
.node.is-masked > :not(.node-toggle):not(.node-peers) { visibility: hidden; }
.node.is-masked, .node.is-masked-note { cursor: help; }
.node.is-masked::after {
    content: "?";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--muted);
}
.node.is-masked-note .node-note { visibility: hidden; position: relative; }
.node.is-masked-note .slot-note { position: relative; }
.node.is-masked-note .slot-note::after { content: "?"; font-weight: 700; position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 6px; }
.node.is-hard { outline: 3px solid var(--danger); outline-offset: 3px; }
.node.is-hard::before { content: "nochmal"; position: absolute; left: 8px; bottom: 100%; padding: 0 7px; border-radius: 6px 6px 0 0; background: var(--danger); color: var(--surface); font-size: 11px; font-weight: 700; line-height: 17px; }

/* Ast hervorheben */
.node.is-dimmed { opacity: .22; }

/* ---------- Menüs, Befehlssuche, Einstellungen, Geräte ---------- */

.menu-right .menu-list { left: auto; right: 0; }
.menu-head { margin: 0; padding: 6px 10px 8px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.menu-head strong { display: block; font-size: 15px; color: var(--ink); }
.menu-item kbd { margin-left: 6px; font-size: 12px; }

.palette { width: min(94vw, 560px); padding: 10px; margin-top: 12vh; }
.palette input { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); font-size: 16px; }
.palette-list { list-style: none; max-height: 52vh; margin: 8px 0 0; padding: 0; overflow-y: auto; }
.palette-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.palette-list li.is-active { background: var(--accent); color: var(--accent-ink); }
.palette-list small { opacity: .75; white-space: nowrap; }
.palette-empty { padding: 12px; color: var(--muted); }

.share-add { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin: 8px 0; }
.share-add select { width: auto; }
.share-list .btn { min-height: 30px; padding: 0 8px; }
.share-list span { overflow-wrap: anywhere; }
.share-transfer { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.share-transfer summary { cursor: pointer; font-weight: 600; }
.share-transfer label { margin-top: 10px; }
.check { display: flex; flex-direction: row !important; align-items: center; gap: 8px; font-weight: 400 !important; }

.admin-filter { margin-bottom: 10px; }
.admin-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.admin-tools .admin-filter { flex: 1 1 240px; margin: 0; }
.admin-table input[type="text"], .admin-table input[type="email"] { min-height: 32px; padding: 4px 8px; margin-bottom: 4px; }
.settings-form { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding-bottom: 16px; }
.settings-form h3 { margin: 10px 0 0; font-size: 16px; }
.settings-form label { display: flex; flex-direction: column; gap: 5px; width: 100%; font-size: 14px; font-weight: 600; }
.settings-form p { margin: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; width: 100%; }
.dialog input[type="number"] { width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }

.session-list { list-style: none; width: 100%; margin: 0; padding: 0; }
.session-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.session-list small { display: block; color: var(--muted); }
.session-list .btn { min-height: 30px; padding: 0 8px; }

/* Bearbeitungsleiste: ersetzt auf Geräten ohne Tabulatortaste die Tastenkürzel */
.edit-bar { display: none; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); overflow-x: auto; }
.edit-bar button {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 40px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    font-size: 17px;
    cursor: pointer;
}
.view-switch { display: none; }

@media (pointer: coarse) {
    .edit-bar { display: flex; }
    .btn, select, .menu-item { min-height: 40px; }
    .btn-icon, .btn-account { width: 40px; }
    .node-toggle { min-width: 26px; height: 26px; border-radius: 13px; font-size: 12px; }
    .node-task { width: 20px; height: 20px; }
}

/* ---------- Kleine Bildschirme ---------- */

@media (max-width: 860px) {
    .app {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto minmax(150px, 40%) minmax(0, 1fr);
    }
    .app.view-outline { grid-template-rows: auto auto minmax(0, 1fr); }
    .app.view-map { grid-template-rows: auto auto minmax(0, 1fr); }
    .app.view-outline .viewport, .app.view-map .outline { display: none; }
    .app.is-learning { grid-template-rows: auto auto minmax(0, 1fr); }
    .app.is-learning .viewport { grid-row: 3; display: block; }
    .app.is-learning .view-switch { display: none; }
    .outline { border-right: 0; border-bottom: 1px solid var(--line); }
    .viewport { grid-row: 4; grid-column: 1; }
    .app.view-map .viewport { grid-row: 3; }
    .outline-help { display: none; }
    .edit-bar { display: flex; }

    /* Werkzeugleiste: erste Zeile Mindmap-Auswahl und Konto, darunter der Rest */
    .toolbar { gap: 6px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); }
    .brand, .toolbar-space, .zoom-label { display: none; }
    #map-select { order: 1; flex: 1 1 60%; min-width: 0; max-width: none; }
    .toolbar > * { order: 3; }
    .toolbar > .menu:first-of-type, .toolbar > .menu-right { order: 2; }
    .zoom { display: none; } /* auf dem Handy: zwei Finger; «Alles zeigen» steht unter Ansicht */
    .search { flex: 1 1 120px; }
    #f-search { width: 100%; }
    .status { min-width: 0; flex: 1 1 100%; text-align: left; }
    .status:empty { display: none; }

    /* Menüs klappen als Blatt von unten auf */
    .menu-list, .menu-right .menu-list {
        position: fixed;
        inset: auto 0 0 0;
        max-height: 72vh;
        padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, .25);
    }
    .menu-item { padding: 12px; }

    .view-switch { display: flex; gap: 0; padding: 6px 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
    .view-switch button { flex: 1; min-height: 36px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
    .view-switch button:first-child { border-radius: 8px 0 0 8px; }
    .view-switch button:last-child { border-radius: 0 8px 8px 0; }
    .view-switch button.is-active { background: var(--ink); border-color: var(--ink); color: var(--surface); font-weight: 600; }

    /* Schrift in Eingabefeldern mindestens 16px: sonst zoomt iOS beim Antippen hinein */
    input, textarea, select { font-size: 16px !important; }
    .dialog { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; padding: 16px; border-radius: 16px 16px 0 0; }
    .dialog-wide { width: 100vw; }
    .palette { margin-top: 0; }
    .admin-create, .share-add { grid-template-columns: 1fr; }
    .facts { grid-template-columns: 1fr; gap: 2px 0; }
    .facts dd { margin-bottom: 8px; }
    .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
}
