/* =====================================================================
   vindelis Cockpit – Design
   ---------------------------------------------------------------------
   1. Farben & Grössen (Hell / Dunkel)
   2. Grundlagen
   3. Gerüst: Sidebar, Topbar, Inhalt
   4. Bausteine: Knöpfe, Karten, Badges, Hinweise, Formulare …
   5. Seiten-spezifisch (Übersicht)
   6. Protokoll & Toasts
   7. Handy
   ===================================================================== */

/* ---------- 1. Farben & Grössen ---------- */
/* Design vom 28.10.2026 (Punkt 5, D1, "Entwurf 3"): Werkzeug-Stil wie Figma –
   ruhige Grautöne, feine Linien, EINE Akzentfarbe (Figma-Blau), kaum fett.
   Alle Farben stehen nur hier; der Rest des CSS benutzt die Namen. */
:root {
    --bg: #ffffff;
    --side: #f7f7f7;
    --surface: #ffffff;
    --surface-2: #f5f5f5;
    --surface-3: #ebebeb;
    --border: #e6e6e6;
    --border-strong: #d4d4d4;
    --text: #1e1e1e;
    --muted: #6b6b6b;
    --faint: #9a9a9a;

    --accent: #0d99ff;
    /* dunkleres Blau für Text und Links (auf Weiss besser lesbar) */
    --accent-strong: #0a7bd1;
    --accent-soft: #e5f4ff;
    --on-accent: #ffffff;

    --ok: #14804a;
    --ok-soft: #e6f5ec;
    --warn: #b25e00;
    --warn-soft: #fff3e0;
    --error: #d4361c;
    --error-soft: #fdece8;
    --info: #0a7bd1;
    --info-soft: #e5f4ff;
    --test: #b7791f;
    --test-soft: #fff5dc;

    /* Die drei Rollen */
    --role-black: #1e1e1e;
    --role-black-bg: #ebebeb;
    --role-red: #d4361c;
    --role-red-bg: #fdece8;
    --role-blue: #0a7bd1;
    --role-blue-bg: #e5f4ff;

    /* JSON-Farben */
    --j-key: #8a4bd6;
    --j-string: #14804a;
    --j-number: #b25e00;
    --j-bool: #0a7bd1;
    --j-null: #9a9a9a;

    --radius: 8px;
    --radius-s: 6px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-l: 0 16px 48px rgba(0, 0, 0, 0.16);
    --sidebar-w: 252px;
    --topbar-h: 52px;

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
    --logo-font: 'Pacifico', cursive;

    color-scheme: light;
}

/* Dunkel: automatisch nach Systemeinstellung … */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --bg: #2c2c2c;
        --side: #2c2c2c;
        --surface: #333333;
        --surface-2: #3a3a3a;
        --surface-3: #444444;
        --border: #3d3d3d;
        --border-strong: #4d4d4d;
        --text: #f2f2f2;
        --muted: #b3b3b3;
        --faint: #8c8c8c;
        --accent: #0d99ff;
        --accent-strong: #45b0ff;
        --accent-soft: rgba(13, 153, 255, 0.16);
        --on-accent: #ffffff;
        --ok: #3ccb7f;
        --ok-soft: rgba(20, 174, 92, 0.16);
        --warn: #ffb24d;
        --warn-soft: rgba(255, 166, 41, 0.14);
        --error: #ff7a5c;
        --error-soft: rgba(242, 72, 34, 0.16);
        --info: #45b0ff;
        --info-soft: rgba(13, 153, 255, 0.14);
        --test: #fbbf24;
        --test-soft: #3a3220;
        --role-black: #f2f2f2;
        --role-black-bg: #444444;
        --role-red: #ff7a5c;
        --role-red-bg: rgba(242, 72, 34, 0.18);
        --role-blue: #45b0ff;
        --role-blue-bg: rgba(13, 153, 255, 0.18);
        --j-key: #c9a6ff;
        --j-string: #7ee2a8;
        --j-number: #ffc285;
        --j-bool: #7cc4ff;
        --j-null: #8c8c8c;
        --shadow: none;
        --shadow-l: 0 20px 56px rgba(0, 0, 0, 0.5);
        color-scheme: dark;
    }
}
/* … oder von Hand gewählt (Knopf oben rechts) */
:root[data-theme='dark'] {
    --bg: #2c2c2c;
    --side: #2c2c2c;
    --surface: #333333;
    --surface-2: #3a3a3a;
    --surface-3: #444444;
    --border: #3d3d3d;
    --border-strong: #4d4d4d;
    --text: #f2f2f2;
    --muted: #b3b3b3;
    --faint: #8c8c8c;
    --accent: #0d99ff;
    --accent-strong: #45b0ff;
    --accent-soft: rgba(13, 153, 255, 0.16);
    --on-accent: #ffffff;
    --ok: #3ccb7f;
    --ok-soft: rgba(20, 174, 92, 0.16);
    --warn: #ffb24d;
    --warn-soft: rgba(255, 166, 41, 0.14);
    --error: #ff7a5c;
    --error-soft: rgba(242, 72, 34, 0.16);
    --info: #45b0ff;
    --info-soft: rgba(13, 153, 255, 0.14);
    --test: #fbbf24;
    --test-soft: #3a3220;
    --role-black: #f2f2f2;
    --role-black-bg: #444444;
    --role-red: #ff7a5c;
    --role-red-bg: rgba(242, 72, 34, 0.18);
    --role-blue: #45b0ff;
    --role-blue-bg: rgba(13, 153, 255, 0.18);
    --j-key: #c9a6ff;
    --j-string: #7ee2a8;
    --j-number: #ffc285;
    --j-bool: #7cc4ff;
    --j-null: #8c8c8c;
    --shadow: none;
    --shadow-l: 0 20px 56px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

/* ---------- 2. Grundlagen ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}
html,
body {
    margin: 0;
    height: 100%;
}
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a {
    color: var(--accent-strong);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}
h1,
h2,
h3,
h4 {
    margin: 0;
    line-height: 1.3;
    font-weight: 500;
}
p {
    margin: 0;
}
code,
.mono {
    font-family: var(--mono);
    font-size: 0.9em;
}
:not(pre) > code {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 5px;
    word-break: break-word;
}
.muted {
    color: var(--muted);
}
.small {
    font-size: 12.5px;
}
.nowrap {
    white-space: nowrap;
}
.pad {
    padding: 16px;
}
.row {
    display: flex;
    align-items: center;
}
.gap-s {
    gap: 8px;
}
[hidden] {
    display: none !important;
}
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}
.icon {
    flex-shrink: 0;
}

/* ---------- 3. Gerüst ---------- */
.shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: sticky;
    top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--side);
    border-right: 1px solid var(--border);
    padding: 14px 12px;
    overflow-y: auto;
    z-index: 30;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 8px 16px;
    color: var(--text);
    text-decoration: none !important;
}
/* Das Logo "vindelis" (Schreibschrift, js/core/intro.js) */
.brand-logo {
    width: 92px;
    height: 32px;
    display: flex;
    align-items: center;
}
.brand-logo.is-waiting {
    visibility: hidden; /* während des Auftritts fliegt die grosse Kopie hierher */
}
.logo-svg {
    width: 100%;
    height: auto;
    overflow: visible;
    display: block;
}
.logo-svg text {
    font-family: var(--logo-font);
    font-size: 120px;
    fill: var(--text);
}
.logo-dot {
    fill: var(--accent);
    transform-box: fill-box;
    transform-origin: center;
}
.brand-sub {
    margin-left: auto;
    font-size: 11px;
    color: var(--faint);
}

/* Auftritt beim Start: Logo gross zeichnen, dann nach oben links fliegen */
.intro-veil {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: color-mix(in srgb, var(--bg) 55%, transparent);
    transition: opacity 0.9s ease;
}
body.intro-on .shell {
    filter: blur(14px);
    opacity: 0.45;
    transform: scale(1.02);
}
body .shell {
    transition:
        filter 0.9s ease,
        opacity 0.9s ease,
        transform 0.9s ease;
}
body.intro-leaving .shell {
    filter: none;
    opacity: 1;
    transform: none;
}
body.intro-leaving .intro-veil {
    opacity: 0;
}
.intro-logo {
    position: fixed;
    z-index: 901;
    left: 50%;
    top: 50%;
    width: min(70vw, 760px);
    translate: -50% -50%;
    transform-origin: 0 0;
    pointer-events: none;
    transition:
        transform 1s cubic-bezier(0.65, 0, 0.25, 1),
        opacity 0.6s ease;
}
.intro-logo.fade {
    opacity: 0;
}
.intro-logo text {
    fill: transparent;
    stroke: var(--text);
    stroke-width: 1.6;
    stroke-dasharray: 1400;
    stroke-dashoffset: 1400;
}
.intro-logo .logo-dot {
    opacity: 0;
}
.intro-logo.draw text {
    animation:
        logo-draw 2.2s cubic-bezier(0.6, 0.1, 0.3, 1) forwards,
        logo-fill 0.7s ease 1.9s forwards;
}
.intro-logo.draw .logo-dot {
    animation: logo-pop 0.35s ease 2.4s forwards;
}
@keyframes logo-draw {
    to {
        stroke-dashoffset: 0;
    }
}
@keyframes logo-fill {
    to {
        fill: var(--text);
        stroke-width: 0;
    }
}
@keyframes logo-pop {
    0% {
        opacity: 0;
        transform: scale(0.2);
    }
    70% {
        opacity: 1;
        transform: scale(1.25);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}
.nav {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
}
.nav-group-title {
    font-size: 11px;
    letter-spacing: 0.02em;
    color: var(--faint);
    font-weight: 400;
    padding: 4px 10px 6px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 10px;
    border-radius: var(--radius-s);
    color: var(--muted);
    font-weight: 400;
    white-space: nowrap;
    text-decoration: none !important;
    transition:
        background 0.12s,
        color 0.12s;
}
.nav-link:hover {
    background: var(--surface-2);
    color: var(--text);
}
.nav-link.active {
    background: var(--accent-soft);
    color: var(--text);
}
.nav-link.active .nav-icon {
    color: var(--accent);
}
.nav-link.subtle {
    font-size: 13px;
}
.nav-icon {
    display: inline-flex;
}
.nav-soon {
    margin-left: auto;
    font-size: 10.5px;
    color: var(--faint);
    border: 1px dashed var(--border-strong);
    border-radius: 99px;
    padding: 0 7px;
}
.sidebar-foot {
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 10px;
}

/* --- Besitzer-Ansicht (Punkt 5, D2) --- */
/* Zahl bei "Wartet auf mich" */
.nav-badge {
    margin-left: auto;
    font-size: 11px;
    color: var(--accent-strong);
}
.nav-note {
    display: block;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--faint);
}
.nav-plus {
    width: 16px;
    text-align: center;
}
/* Websites als Baum */
.tree-row {
    padding: 0 6px 0 2px;
    gap: 2px;
}
.tree-twist {
    width: 18px;
    height: 26px;
    border: 0;
    background: none;
    color: var(--faint);
    font-size: 10px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}
.tree-twist:disabled {
    cursor: default;
}
.tree-label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    padding: 5px 4px;
    color: inherit;
    text-decoration: none !important;
}
.tree-name {
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Punkt: grün = öffentlich, blau = nur Angemeldete, grau = privat */
.tree-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--faint);
}
.tree-dot.public {
    background: var(--ok);
}
.tree-dot.members {
    background: var(--accent);
}
.tree-child {
    padding: 4px 10px 4px 46px;
    font-size: 12px;
}
.tree-child .mono {
    color: var(--faint);
}
/* Schalter Besitzer / Technik */
.view-switch {
    width: 100%;
    border: 0;
    background: none;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
}
.switch {
    margin-left: auto;
    width: 26px;
    height: 15px;
    border-radius: 99px;
    background: var(--surface-3);
    position: relative;
    flex-shrink: 0;
    transition: background 0.15s;
}
.switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.15s;
}
.switch.on {
    background: var(--accent);
}
.switch.on::after {
    transform: translateX(11px);
}
/* In der Besitzer-Ansicht keine Technik oben rechts (N4) */
body[data-view='besitzer'] #modeSwitch,
body[data-view='besitzer'] #logBtn {
    display: none !important;
}
.test-tag {
    display: none;
    font-size: 11px;
    color: var(--test);
    background: var(--test-soft);
    border-radius: 4px;
    padding: 1px 7px;
}
body[data-view='besitzer'][data-mode='test'] .test-tag {
    display: inline-block;
}
body[data-view='besitzer'][data-mode='test'] .topbar {
    border-bottom: 1px solid var(--border);
}
.sidebar-backdrop {
    display: none;
}

/* Hauptbereich */
.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
body[data-mode='test'] .topbar {
    border-bottom: 2px solid var(--test);
}
.topbar-title {
    flex: 1;
    min-width: 0;
}
.topbar-title h1 {
    font-size: 16.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
/* "Menü"-Knopf nur auf dem Handy (.topbar davor, sonst gewinnt .icon-btn weiter unten) */
.topbar .menu-btn {
    display: none;
}

/* Live/Test-Umschalter */
.mode-switch {
    display: inline-flex;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 99px;
}
.mode-switch button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 12.5px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 99px;
    cursor: pointer;
}
.mode-switch button.active[data-mode='live'] {
    background: var(--surface);
    color: var(--ok);
    box-shadow: var(--shadow);
}
.mode-switch button.active[data-mode='test'] {
    background: var(--test);
    color: #1b1400;
}
.mode-switch.pulse {
    animation: pulse 1.2s ease-in-out 3;
}
@keyframes pulse {
    50% {
        box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 35%, transparent);
    }
}

/* Wer bin ich */
.identity {
    display: flex;
    align-items: center;
    gap: 6px;
}
.identity-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 11px;
    border-radius: 99px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
    max-width: 200px;
}
.identity-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.identity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--faint);
}
.identity-dot.ok {
    background: var(--ok);
}
.identity-dot.warn {
    background: var(--warn);
}
.identity-dot.error {
    background: var(--error);
}

.mode-banner {
    padding: 12px 24px 0;
}
.mode-banner .callout {
    margin: 0;
}
.content {
    padding: 22px 24px 60px;
    outline: none;
    max-width: 1320px;
    width: 100%;
}
.page {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.page-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.page-intro {
    flex: 1;
    color: var(--muted);
    max-width: 780px;
    font-size: 14px;
}
.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- 4. Bausteine ---------- */

/* Knöpfe */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-s);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    font-size: 12.5px;
    cursor: pointer;
    text-decoration: none !important;
    white-space: nowrap;
    transition:
        background 0.12s,
        border-color 0.12s,
        transform 0.05s;
}
.btn:hover {
    background: var(--surface-2);
}
.btn:active {
    transform: translateY(1px);
}
.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}
.btn.primary:hover {
    background: var(--accent-strong);
}
.btn.danger {
    color: var(--error);
    border-color: color-mix(in srgb, var(--error) 40%, var(--border));
}
.btn.danger:hover {
    background: var(--error-soft);
}
.btn.ghost {
    border-color: transparent;
    background: transparent;
}
.btn.ghost:hover {
    background: var(--surface-2);
}
.btn.small {
    padding: 5px 10px;
    font-size: 12.5px;
}
.btn:disabled {
    opacity: 0.55;
    cursor: default;
}
.btn.is-busy .icon {
    animation: spin 0.8s linear infinite;
}
.icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-s);
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}
.icon-btn.small {
    width: 28px;
    height: 28px;
}
.dot-count {
    position: absolute;
    top: 3px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 99px;
    background: var(--error);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
}

/* Karten */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
}
.card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px 0;
}
.card-title {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.card-title h2 {
    font-size: 14px;
}
.card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    flex-shrink: 0;
}
.card-actions {
    display: flex;
    gap: 6px;
}
.card-body {
    padding: 14px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 18px;
}

/* Badges & Rollen */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 500;
    white-space: nowrap;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
}
.badge.ok {
    background: var(--ok-soft);
    color: var(--ok);
    border-color: transparent;
}
.badge.warn {
    background: var(--warn-soft);
    color: var(--warn);
    border-color: transparent;
}
.badge.error {
    background: var(--error-soft);
    color: var(--error);
    border-color: transparent;
}
.badge.test {
    background: var(--test-soft);
    color: var(--test);
    border-color: transparent;
}
.badge.accent {
    background: var(--accent-soft);
    color: var(--accent-strong);
    border-color: transparent;
}
.role {
    display: inline-block;
    padding: 0 7px;
    border-radius: 5px;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
}
.role.black {
    color: var(--role-black);
    background: var(--role-black-bg);
}
.role.red {
    color: var(--role-red);
    background: var(--role-red-bg);
}
.role.blue {
    color: var(--role-blue);
    background: var(--role-blue-bg);
}

/* Hinweis-Kästen */
.callout {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 14px;
    border-radius: var(--radius-s);
    border: 1px solid transparent;
    font-size: 12.5px;
}
.callout .icon {
    margin-top: 2px;
}
.callout.info {
    background: var(--info-soft);
    color: var(--text);
}
.callout.info .icon {
    color: var(--info);
}
.callout.ok {
    background: var(--ok-soft);
}
.callout.ok .icon {
    color: var(--ok);
}
.callout.warn {
    background: var(--warn-soft);
}
.callout.warn .icon {
    color: var(--warn);
}
.callout.error {
    background: var(--error-soft);
}
.callout.error .icon {
    color: var(--error);
}
.callout.test {
    background: var(--test-soft);
    border-color: color-mix(in srgb, var(--test) 35%, transparent);
}
.callout.test .icon {
    color: var(--test);
}

/* Laden & Leer */
.loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    padding: 14px 2px;
}
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 26px 16px;
}
.empty p {
    max-width: 420px;
}
.empty-icon {
    display: inline-flex;
    padding: 12px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--muted);
}

/* Code & JSON */
pre {
    margin: 0;
}
.json,
.code-block pre {
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.6;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    padding: 10px 12px;
    overflow: auto;
    white-space: pre;
}
.j-key {
    color: var(--j-key);
}
.j-string {
    color: var(--j-string);
}
.j-number {
    color: var(--j-number);
}
.j-bool {
    color: var(--j-bool);
}
.j-null {
    color: var(--j-null);
}
.code-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}
.result-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.result-line.ok .icon {
    color: var(--ok);
}
.result-line.error .icon {
    color: var(--error);
}
.id-line {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}

.checklist {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.checklist li {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.checklist .icon {
    color: var(--accent);
    margin-top: 3px;
}

/* ---------- 5. Übersicht ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    min-width: 0;
}
/* Zustand als kleiner Punkt vor dem Titel (früher ein farbiger Balken oben – zu laut) */
.stat.ok .stat-head::before,
.stat.warn .stat-head::before,
.stat.error .stat-head::before,
.stat.test .stat-head::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    order: 99;
    margin-left: auto;
}
.stat.ok .stat-head::before {
    background: var(--ok);
}
.stat.warn .stat-head::before {
    background: var(--warn);
}
.stat.error .stat-head::before {
    background: var(--error);
}
.stat.test .stat-head::before {
    background: var(--test);
}
.stat-head {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
}
.stat-icon {
    display: inline-flex;
}
.stat-value {
    font-size: 19.5px;
    font-weight: 600;
    margin: 6px 0 2px;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stat-detail {
    color: var(--muted);
    font-size: 12.5px;
}
/* Kachel "Dein Kontingent": eine Zeile pro Deckel mit kleinem Balken */
.quota-line {
    display: block;
    margin-top: 4px;
}
.quota-bar {
    display: block;
    height: 4px;
    margin-top: 3px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
}
.quota-bar > span {
    display: block;
    height: 100%;
    background: var(--ok);
}
.quota-bar.warn > span {
    background: var(--warn);
}
.quota-bar.error > span {
    background: var(--error);
}

.mini-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.mini-stats strong {
    font-size: 16.5px;
}
.object-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}
.object-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px;
    margin: 0 -8px;
    border-radius: var(--radius-s);
    color: var(--text);
    text-decoration: none !important;
}
.object-list a:hover {
    background: var(--surface-2);
}
.obj-icon {
    display: inline-flex;
    color: var(--accent);
}
.obj-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.obj-domain {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.obj-path {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.more-link {
    font-size: 13px;
    font-weight: 500;
}

.concepts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.concept {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    color: var(--text);
    text-decoration: none !important;
    transition:
        border-color 0.12s,
        transform 0.12s;
}
.concept:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}
.concept p {
    color: var(--muted);
    font-size: 13px;
}
.concept-icon {
    display: inline-flex;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.stages {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.stages li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.stage-n {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1.5px solid var(--border-strong);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}
.stages li.done .stage-n {
    background: var(--ok);
    border-color: var(--ok);
    color: #fff;
}

/* ---------- 6. Protokoll & Toasts ---------- */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(520px, 100vw);
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-l);
    z-index: 50;
    display: flex;
    flex-direction: column;
}
.drawer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
}
.drawer-head h2 {
    font-size: 14.5px;
}
.drawer-body {
    overflow-y: auto;
    flex: 1;
}
.log-entry {
    border-bottom: 1px solid var(--border);
}
.log-entry summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    cursor: pointer;
    list-style: none;
    font-size: 13px;
}
.log-entry summary::-webkit-details-marker {
    display: none;
}
.log-entry summary:hover {
    background: var(--surface-2);
}
.log-path {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
}
.method {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    width: 52px;
    flex-shrink: 0;
}
.m-get {
    color: var(--ok);
}
.m-post {
    color: var(--info);
}
.m-put {
    color: var(--warn);
}
.m-delete {
    color: var(--error);
}
.log-status {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 12px;
}
.log-status.ok {
    color: var(--ok);
}
.log-status.warn {
    color: var(--warn);
}
.log-status.error {
    color: var(--error);
}
.log-detail {
    padding: 4px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    word-break: break-all;
}
.log-detail h4 {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}

.toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 60;
}
.toast {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    box-shadow: var(--shadow-l);
    font-size: 12.5px;
    max-width: 380px;
    animation: toast-in 0.2s ease-out;
    transition:
        opacity 0.25s,
        transform 0.25s;
}
.toast.ok .icon {
    color: var(--ok);
}
.toast.error .icon {
    color: var(--error);
}
.toast.info .icon {
    color: var(--info);
}
.toast.leaving {
    opacity: 0;
    transform: translateY(6px);
}
@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* ---------- 7. Handy & kleinere Bildschirme ---------- */
@media (max-width: 1100px) {
    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .grid-2 {
        grid-template-columns: minmax(0, 1fr);
    }
    .concepts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow-l);
    }
    body.nav-open .sidebar {
        transform: none;
    }
    body.nav-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 25;
    }
    .topbar .menu-btn {
        display: inline-flex;
    }
    .topbar {
        padding: 0 12px;
        gap: 6px;
    }
    .content {
        padding: 16px 16px 60px;
    }
    .mode-banner {
        padding: 10px 16px 0;
    }
    .hide-s {
        display: none;
    }
    .identity-chip {
        max-width: 110px;
    }
    .page-head {
        flex-direction: column;
    }
}

@media (max-width: 560px) {
    .stats,
    .concepts {
        grid-template-columns: minmax(0, 1fr);
    }
    .topbar-title h1 {
        font-size: 14.5px;
    }
    #themeBtn {
        display: none;
    }
    .identity-chip {
        display: none;
    }
    .toasts {
        left: 16px;
        right: 16px;
    }
}

/* Sichtbarkeit (Objekt-Seite): drei Stufen als Auswahl */
.obj-vis {
    font-size: 12px;
    margin-left: 4px;
}
.vis-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 4px 0 12px;
}
.vis-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}
.vis-option.current {
    border-color: var(--border-strong);
}
.vis-option input {
    margin-top: 3px;
}
.block {
    display: block;
}
/* "Weitere (n)": Speicher und Werkzeugkästen eingeklappt (Punkt 5, D3) */
.tree-others {
    width: 100%;
    border: 0;
    background: none;
    font: inherit;
    cursor: pointer;
    text-align: left;
    color: var(--faint);
}
.tree-others .tree-twist {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* =====================================================================
   Suchen oder KI fragen – Strg K (Punkt 5, D5, js/core/search.js)
   ===================================================================== */
.search-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0 0 14px;
    padding: 7px 10px;
    border: 0;
    border-radius: var(--radius-s);
    background: var(--surface-2);
    color: var(--faint);
    font: inherit;
    font-size: 12.5px;
    white-space: nowrap;
    cursor: pointer;
}
.search-pill:hover {
    color: var(--muted);
}
.search-pill kbd {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--faint);
}
.k-overlay {
    position: fixed;
    inset: 0;
    z-index: 950;
    background: rgba(0, 0, 0, 0.4);
    display: grid;
    place-items: start center;
    padding-top: 14vh;
}
.k-box {
    width: min(600px, calc(100vw - 32px));
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-l);
}
.k-input {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    padding: 15px 18px;
    font: inherit;
    font-size: 14px;
    outline: none;
}
.k-list {
    max-height: 50vh;
    overflow: auto;
    padding: 4px 0;
}
.k-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    color: var(--muted);
    cursor: pointer;
}
.k-opt.on {
    background: var(--hover, var(--surface-2));
    color: var(--text);
}
.k-icon {
    display: inline-flex;
    color: var(--faint);
}
.k-opt.on .k-icon {
    color: var(--accent);
}
.k-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.k-opt small {
    margin-left: auto;
    color: var(--faint);
    white-space: nowrap;
}
.k-empty {
    padding: 12px 18px;
    color: var(--faint);
}
