/* =========================================================================
   Aufsicht+ — UI 2.0
   Design-System + responsives App-Shell-Layout (Mobile / Tablet / Desktop)
   ========================================================================= */

/* App-Gefühl: kein Doppeltipp-Zoom (Pinch-Zoom bleibt erhalten) */
html, body, * { touch-action: manipulation; }

/* -------------------------------------------------------------------------
   1. DESIGN TOKENS
   ------------------------------------------------------------------------- */

:root {
    color-scheme: light;

    /* Farben — Basis */
    --c-bg: #f4f6f9;
    --c-bg-soft: #eef1f6;
    --c-surface: #ffffff;
    --c-surface-2: #f7f9fc;
    --c-surface-3: #eef2f7;
    --c-border: #e2e8f0;
    --c-border-strong: #cbd5e1;

    /* Farben — Text */
    --c-text: #0f172a;
    --c-text-2: #475569;
    --c-text-3: #7c8aa0;

    /* Farben — Akzent */
    --c-accent: #0369a1;
    --c-accent-hover: #075985;
    --c-accent-fg: #ffffff;
    --c-accent-soft: #e0f2fe;
    --c-accent-soft-2: #f0f9ff;
    --c-accent-ring: rgba(3, 105, 161, 0.25);

    /* Farben — Status */
    --c-success: #15803d;
    --c-success-soft: #dcfce7;
    --c-danger: #dc2626;
    --c-danger-soft: #fee2e2;
    --c-warn: #b45309;
    --c-warn-soft: #fef3c7;

    /* Radien */
    --r-xs: 6px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 24px;
    --r-full: 999px;

    /* Schatten */
    --sh-xs: 0 1px 2px rgba(15, 23, 42, .06);
    --sh-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --sh-md: 0 4px 16px rgba(15, 23, 42, .08);
    --sh-lg: 0 12px 32px rgba(15, 23, 42, .14);
    --sh-xl: 0 24px 60px rgba(15, 23, 42, .22);

    /* Abstände */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;

    /* Layout-Maße */
    --header-h: 56px;
    --nav-h: 64px;
    --sidebar-w: 300px;
    --draft-w: 400px;
    --content-max: 900px;

    /* Typografie */
    --font: "Inter", "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --fs-xs: 0.75rem;
    --fs-sm: 0.8125rem;
    --fs-base: 0.9375rem;
    --fs-md: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.375rem;

    /* Motion */
    --ease: cubic-bezier(.32, .72, 0, 1);
    --dur: .22s;

    /* Ebenen */
    --z-header: 60;
    --z-nav: 70;
    --z-scrim: 80;
    --z-panel: 90;
    --z-modal: 100;
    --z-toast: 120;
}

[data-theme="dark"] {
    color-scheme: dark;

    --c-bg: #0b1120;
    --c-bg-soft: #0f172a;
    --c-surface: #131c2e;
    --c-surface-2: #182338;
    --c-surface-3: #1e2a41;
    --c-border: #253248;
    --c-border-strong: #33425e;

    --c-text: #eef2f8;
    --c-text-2: #a6b3c6;
    --c-text-3: #7d8ba1;

    --c-accent: #38bdf8;
    --c-accent-hover: #7dd3fc;
    --c-accent-fg: #04293c;
    --c-accent-soft: rgba(56, 189, 248, .14);
    --c-accent-soft-2: rgba(56, 189, 248, .07);
    --c-accent-ring: rgba(56, 189, 248, .35);

    --c-success: #4ade80;
    --c-success-soft: rgba(74, 222, 128, .14);
    --c-danger: #f87171;
    --c-danger-soft: rgba(248, 113, 113, .14);
    --c-warn: #fbbf24;
    --c-warn-soft: rgba(251, 191, 36, .14);

    --sh-xs: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-sm: 0 1px 3px rgba(0, 0, 0, .5);
    --sh-md: 0 4px 16px rgba(0, 0, 0, .45);
    --sh-lg: 0 12px 32px rgba(0, 0, 0, .55);
    --sh-xl: 0 24px 60px rgba(0, 0, 0, .7);
}

/* -------------------------------------------------------------------------
   2. RESET & BASIS
   ------------------------------------------------------------------------- */

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Schriftgröße (Einstellungen) — skaliert alle rem-basierten Größen */
html[data-fontsize="small"] { font-size: 93.75%; }
html[data-fontsize="large"] { font-size: 112.5%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: 1.55;
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: none;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; }
p { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
    outline: 2px solid var(--c-accent);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

::selection { background: var(--c-accent-ring); }

[hidden], .is-hidden { display: none !important; }

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    top: var(--sp-2);
    left: var(--sp-2);
    z-index: var(--z-toast);
    padding: var(--sp-2) var(--sp-4);
    background: var(--c-accent);
    color: var(--c-accent-fg);
    border-radius: var(--r-sm);
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-200%);
    transition: transform var(--dur) var(--ease);
}
.skip-link:focus { transform: translateY(0); }

/* Scrollbars */
.scroll-area { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.scroll-area::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll-area::-webkit-scrollbar-thumb {
    background: var(--c-border-strong);
    border: 3px solid transparent;
    background-clip: padding-box;
    border-radius: var(--r-full);
}
.scroll-area::-webkit-scrollbar-thumb:hover { background: var(--c-text-3); background-clip: padding-box; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }

.icon-svg { display: block; flex: 0 0 auto; }

/* -------------------------------------------------------------------------
   3. APP-SHELL LAYOUT
   ------------------------------------------------------------------------- */

.app-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
        "header"
        "main"
        "nav";
    height: 100vh;
    height: 100dvh;
    width: 100%;
}

.app-header  { grid-area: header; }
.app-main    { grid-area: main; min-height: 0; position: relative; }
.bottom-nav  { grid-area: nav; }
.filter-panel { grid-area: filters; }

/* --- Header --- */

.app-header {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    height: calc(var(--header-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(var(--sp-3), env(safe-area-inset-left)) 0 max(var(--sp-3), env(safe-area-inset-right));
    background: color-mix(in srgb, var(--c-surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--c-border);
    z-index: var(--z-header);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-width: 0;
    margin-right: auto;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 32px; height: 32px;
    flex: 0 0 auto;
    border-radius: 10px;
    background: linear-gradient(140deg, var(--c-accent), color-mix(in srgb, var(--c-accent) 55%, #6366f1));
    color: #fff;
    font-size: var(--fs-sm);
    font-weight: 800;
    letter-spacing: -.02em;
}

.brand-name {
    font-size: var(--fs-md);
    font-weight: 800;
    letter-spacing: -.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

/* --- Icon Button --- */

.icon-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 40px; height: 40px;
    flex: 0 0 auto;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--c-text-2);
    transition: background var(--dur), color var(--dur), border-color var(--dur), transform .12s;
}
.icon-btn:hover { background: var(--c-surface-3); color: var(--c-text); }
.icon-btn:active { transform: scale(.93); }
.icon-btn[aria-pressed="true"], .icon-btn.is-active {
    background: var(--c-accent-soft);
    color: var(--c-accent);
    border-color: color-mix(in srgb, var(--c-accent) 30%, transparent);
}

.icon-btn .count-badge {
    position: absolute;
    top: 2px; right: 2px;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    border-radius: var(--r-full);
    background: var(--c-accent);
    color: var(--c-accent-fg);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    border: 2px solid var(--c-surface);
}
.icon-btn .count-badge[data-count="0"] { display: none; }

/* Status-Punkt */
.status-dot {
    position: absolute;
    right: 5px; bottom: 5px;
    width: 9px; height: 9px;
    border-radius: var(--r-full);
    background: var(--c-warn);
    border: 2px solid var(--c-surface);
}
.status-dot[data-status="ok"] { background: var(--c-success); }
.status-dot[data-status="demo"] { background: var(--c-warn); }
.status-dot[data-status="error"] { background: var(--c-danger); }

/* --- Main / Screens --- */

.app-main {
    display: grid;
    grid-template-areas: "screens";
}

.app-screen {
    grid-area: screens;
    min-height: 0;
    display: none;
    flex-direction: column;
}
.app-screen.is-active { display: flex; }

@media (prefers-reduced-motion: no-preference) {
    .app-screen.is-active { animation: screen-in .26s var(--ease); }
    @keyframes screen-in {
        from { opacity: 0; transform: translateY(8px); }
        to   { opacity: 1; transform: none; }
    }
}

/* --- Bottom Nav (Mobile) --- */

.bottom-nav {
    display: flex;
    align-items: stretch;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--c-surface) 92%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--c-border);
    z-index: var(--z-nav);
}

.nav-item {
    position: relative;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    padding: var(--sp-2) var(--sp-1);
    border: 0;
    background: none;
    color: var(--c-text-3);
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: .01em;
    transition: color var(--dur);
    -webkit-tap-highlight-color: transparent;
}
.nav-item .nav-icon {
    display: grid;
    place-items: center;
    width: 46px; height: 28px;
    border-radius: var(--r-full);
    transition: background var(--dur), color var(--dur);
}
.nav-item.is-active { color: var(--c-accent); }
.nav-item.is-active .nav-icon { background: var(--c-accent-soft); }
.nav-item:active .nav-icon { transform: scale(.92); }

.nav-item .count-badge {
    position: absolute;
    top: 4px;
    left: 50%;
    margin-left: 6px;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    display: grid; place-items: center;
    border-radius: var(--r-full);
    background: var(--c-accent);
    color: var(--c-accent-fg);
    font-size: 11px; font-weight: 800; line-height: 1;
}
.nav-item .count-badge[data-count="0"] { display: none; }

/* -------------------------------------------------------------------------
   4. FILTER-PANEL (Mobile: Bottom-Sheet / Desktop: Sidebar)
   ------------------------------------------------------------------------- */

.scrim {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, .45);
    backdrop-filter: blur(2px);
    z-index: var(--z-scrim);
    opacity: 0;
    animation: fade-in var(--dur) var(--ease) forwards;
}
@keyframes fade-in { to { opacity: 1; } }

.filter-panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: var(--z-panel);
    max-height: 88dvh;
    display: flex;
    flex-direction: column;
    background: var(--c-surface);
    border-top-left-radius: var(--r-xl);
    border-top-right-radius: var(--r-xl);
    box-shadow: var(--sh-xl);
    transform: translateY(101%);
    transition: transform .3s var(--ease);
    padding-bottom: env(safe-area-inset-bottom);
}
.filter-panel.is-open { transform: none; }

.sheet-grabber {
    width: 40px; height: 4px;
    margin: var(--sp-3) auto var(--sp-1);
    border-radius: var(--r-full);
    background: var(--c-border-strong);
    flex: 0 0 auto;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    flex: 0 0 auto;
}
.panel-head h2 {
    font-size: var(--fs-md);
    font-weight: 800;
    letter-spacing: -.01em;
}

.panel-body {
    padding: 0 var(--sp-4) var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    min-height: 0;
    overflow-y: auto;
}

.panel-foot {
    flex: 0 0 auto;
    display: flex;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4) var(--sp-4);
    border-top: 1px solid var(--c-border);
    background: var(--c-surface);
}

/* -------------------------------------------------------------------------
   5. FORMULARE
   ------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field-label {
    font-size: var(--fs-xs);
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--c-text-3);
}

.input, .select {
    width: 100%;
    min-height: 46px;
    padding: 11px var(--sp-3);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    background: var(--c-surface-2);
    color: var(--c-text);
    font-size: var(--fs-base);
    transition: border-color var(--dur), box-shadow var(--dur), background var(--dur);
    -webkit-appearance: none;
    appearance: none;
}
.input::placeholder { color: var(--c-text-3); }
.input:hover:not(:disabled), .select:hover:not(:disabled) { border-color: var(--c-border-strong); }
.input:focus, .select:focus {
    outline: none;
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px var(--c-accent-ring);
    background: var(--c-surface);
}
.select:disabled, .input:disabled { opacity: .55; cursor: not-allowed; }

.select {
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%237c8aa0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    text-overflow: ellipsis;
}
[data-theme="dark"] .select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23a6b3c6' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* Suchfeld mit Icons */
.search-field { position: relative; display: flex; align-items: center; }
.search-field .search-icon {
    position: absolute;
    left: 12px;
    display: grid; place-items: center;
    color: var(--c-text-3);
    pointer-events: none;
}
.search-field .input { padding-left: 42px; padding-right: 40px; }
.search-clear {
    position: absolute;
    right: 6px;
    display: grid; place-items: center;
    width: 32px; height: 32px;
    border: 0; border-radius: var(--r-full);
    background: var(--c-surface-3);
    color: var(--c-text-2);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur);
}
.search-field.has-value .search-clear { opacity: 1; pointer-events: auto; }
.search-clear:hover { color: var(--c-text); }
.search-field input[type="search"]::-webkit-search-cancel-button,
.search-field input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; display: none; }

/* Switch */
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    background: var(--c-surface-2);
    cursor: pointer;
    user-select: none;
}
.switch-row:hover { border-color: var(--c-border-strong); }
.switch-row:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.switch input:disabled { cursor: not-allowed; }
.switch-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.switch-title { font-weight: 650; font-size: var(--fs-base); }
.switch-hint { font-size: var(--fs-xs); color: var(--c-text-3); }
.switch-hint.is-warn { color: var(--c-danger); font-weight: 600; }

.switch { position: relative; flex: 0 0 auto; width: 44px; height: 26px; }
.switch input {
    position: absolute; inset: 0;
    opacity: 0; margin: 0;
    width: 100%; height: 100%;
    cursor: pointer;
}
.switch .track {
    display: block;
    width: 100%; height: 100%;
    border-radius: var(--r-full);
    background: var(--c-border-strong);
    transition: background var(--dur);
}
.switch .track::after {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    border-radius: var(--r-full);
    background: #fff;
    box-shadow: var(--sh-sm);
    transition: transform var(--dur) var(--ease);
}
.switch input:checked + .track { background: var(--c-accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--c-accent-ring); }

/* -------------------------------------------------------------------------
   6. BUTTONS
   ------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: 44px;
    padding: 10px var(--sp-4);
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: var(--c-surface-3);
    color: var(--c-text);
    font-size: var(--fs-base);
    font-weight: 650;
    white-space: nowrap;
    transition: background var(--dur), color var(--dur), border-color var(--dur), transform .12s, opacity var(--dur);
}
.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--c-accent); color: var(--c-accent-fg); }
.btn--primary:hover:not(:disabled) { background: var(--c-accent-hover); }

.btn--ghost { background: transparent; border-color: var(--c-border); color: var(--c-text-2); }
.btn--ghost:hover:not(:disabled) { background: var(--c-surface-3); color: var(--c-text); }

.btn--danger { background: transparent; border-color: var(--c-border); color: var(--c-danger); }
.btn--danger:hover:not(:disabled) { background: var(--c-danger-soft); border-color: transparent; }

.btn--added {
    background: var(--c-success-soft);
    color: var(--c-success);
    border-color: color-mix(in srgb, var(--c-success) 30%, transparent);
}
.btn--added:hover:not(:disabled) { background: color-mix(in srgb, var(--c-success) 18%, transparent); }

.btn--sm { min-height: 36px; padding: 6px var(--sp-3); font-size: var(--fs-sm); border-radius: var(--r-xs); }
.btn--block { width: 100%; }
.btn--grow { flex: 1 1 auto; }

/* Chip / Pill */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--r-full);
    background: var(--c-surface-3);
    color: var(--c-text-2);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: .01em;
    white-space: nowrap;
}
.chip--accent { background: var(--c-accent-soft); color: var(--c-accent); }

/* -------------------------------------------------------------------------
   7. SUCHE / ERGEBNISSE
   ------------------------------------------------------------------------- */

.results-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    background: color-mix(in srgb, var(--c-bg) 88%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--c-border);
}
.results-toolbar .search-field { flex: 1 1 auto; min-width: 0; }

.filter-trigger { position: relative; }
.filter-trigger .count-badge { top: 0; right: 0; }

.results-meta {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    border-bottom: 1px solid var(--c-border);
    background: var(--c-bg-soft);
    font-size: var(--fs-sm);
    color: var(--c-text-2);
    min-height: 40px;
}
.results-meta.is-hidden { display: none !important; }
.results-meta-tags { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.link-btn {
    border: 0;
    background: none;
    padding: 4px 6px;
    color: var(--c-accent);
    font-size: var(--fs-sm);
    font-weight: 700;
    border-radius: var(--r-xs);
    white-space: nowrap;
}
.link-btn:hover { background: var(--c-accent-soft); }

.results-scroll {
    flex: 1 1 auto;
    min-height: 0;
    padding: var(--sp-4);
    padding-bottom: var(--sp-10);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    max-width: var(--content-max);
    margin: 0 auto;
    width: 100%;
}

/* --- Gesetzeskarte --- */

.law-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    overflow: hidden;
}

.law-card-head {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    padding: var(--sp-4) var(--sp-4) var(--sp-3);
    border-bottom: 1px solid var(--c-border);
    background: var(--c-surface-2);
}
.law-card-tags { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.law-card-name { font-size: var(--fs-xs); color: var(--c-text-3); font-weight: 600; }
.law-card-title {
    font-size: var(--fs-lg);
    font-weight: 800;
    letter-spacing: -.015em;
    color: var(--c-text);
}

.norm-item { padding: var(--sp-4); }
.norm-item + .norm-item { border-top: 1px dashed var(--c-border); }

.norm-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    flex-wrap: wrap;
    margin-bottom: var(--sp-3);
}
.norm-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.norm-text {
    font-size: var(--fs-base);
    color: var(--c-text-2);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.clamp {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
[data-density="compact"] .clamp { -webkit-line-clamp: 2; line-clamp: 2; }

.toggle-more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: var(--sp-2);
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--c-accent);
    font-size: var(--fs-sm);
    font-weight: 700;
}
.toggle-more:hover { text-decoration: underline; }
.toggle-more.is-hidden { display: none; }

.baustein-box {
    margin-top: var(--sp-3);
    padding: var(--sp-3);
    border-radius: var(--r-md);
    background: var(--c-accent-soft-2);
    border: 1px solid color-mix(in srgb, var(--c-accent) 18%, transparent);
}
[data-density="compact"] .baustein-box { display: none; }
.baustein-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-2); }
.baustein-head .btn { margin-top: -4px; flex-shrink: 0; }
.baustein-eigen { font-size: 10px; letter-spacing: 0; text-transform: none; }
.baustein-form { display: flex; flex-direction: column; gap: var(--sp-2); }
.baustein-form textarea { resize: vertical; min-height: 4.5em; }
.baustein-hinweis { margin: 0; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md); background: var(--c-accent-soft-2); font-size: var(--fs-sm, .875rem); }
.baustein-foot { display: flex; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; }
.baustein-neu { margin-top: var(--sp-2); }
[data-density="compact"] .baustein-neu { display: none; }
.eigene-neu { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3); border-radius: var(--r-md); background: var(--c-accent-soft-2); }
.eigene-neu[hidden] { display: none; }
.eigene-neu-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); }
.eigene-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.eigene-item { display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-3); border: 1px solid var(--c-border); border-radius: var(--r-md); }
.eigene-item-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; font-weight: 700; }
.eigene-item-text { margin: 0; color: var(--c-text-2); font-size: var(--fs-sm, .875rem); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.eigene-item-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); flex-wrap: wrap; }
.eigene-leer { margin: 0; text-align: center; color: var(--c-text-2); }

.baustein-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--c-accent);
}
.baustein-text {
    font-size: var(--fs-sm);
    color: var(--c-text-2);
    white-space: pre-wrap;
    line-height: 1.6;
}

mark.hl {
    background: color-mix(in srgb, var(--c-accent) 28%, transparent);
    color: inherit;
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 650;
}

.norm-item.is-added { background: color-mix(in srgb, var(--c-success) 6%, transparent); }

@media (prefers-reduced-motion: no-preference) {
    .pulse { animation: pulse-add .6s var(--ease); }
    @keyframes pulse-add {
        0%   { background: var(--c-success-soft); }
        100% { background: transparent; }
    }
}

/* --- Leer-/Ladezustände --- */

.state-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--sp-3);
    padding: var(--sp-10) var(--sp-5);
    max-width: 420px;
    margin: var(--sp-6) auto;
    color: var(--c-text-2);
}
.state-icon {
    display: grid; place-items: center;
    width: 56px; height: 56px;
    border-radius: var(--r-full);
    background: var(--c-surface-3);
    color: var(--c-text-3);
}
.state-title { font-size: var(--fs-md); font-weight: 750; color: var(--c-text); }
.state-text { font-size: var(--fs-sm); }

/* Startfehler (js/boot.js, js/recovery.js): überdeckt die nicht gestartete Oberfläche */
.boot-overlay {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-toast) + 10);
    display: grid;
    place-items: center;
    overflow-y: auto;
    padding: env(safe-area-inset-top) var(--sp-4) env(safe-area-inset-bottom);
    background: var(--c-bg);
}
.boot-overlay .btn { min-width: 220px; }

.skeleton-card {
    height: 140px;
    border-radius: var(--r-lg);
    background: linear-gradient(90deg, var(--c-surface) 25%, var(--c-surface-3) 37%, var(--c-surface) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border: 1px solid var(--c-border);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton-card { animation: none; } }

/* -------------------------------------------------------------------------
   8. ENTWURF (Dokument)
   ------------------------------------------------------------------------- */

.draft-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--c-border);
    background: color-mix(in srgb, var(--c-bg) 88%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.draft-head-titles { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.draft-head h2 { font-size: var(--fs-md); font-weight: 800; letter-spacing: -.01em; }
.draft-head-actions { display: flex; gap: var(--sp-1); }

.draft-hint {
    flex: 0 0 auto;
    margin: 0;
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--fs-xs);
    color: var(--c-text-3);
    background: var(--c-surface-2);
    border-bottom: 1px solid var(--c-border);
}

.draft-scroll {
    flex: 1 1 auto;
    min-height: 0;
    padding: var(--sp-4);
    padding-bottom: var(--sp-10);
}

.draft-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
}

.draft-item {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    box-shadow: var(--sh-xs);
    overflow: hidden;
    transition: box-shadow var(--dur), border-color var(--dur);
}
.draft-item:focus-within { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-ring); }

.draft-item-head {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--c-border);
    background: var(--c-surface-2);
}
.draft-num {
    flex: 0 0 auto;
    display: grid; place-items: center;
    min-width: 24px; height: 24px;
    padding: 0 6px;
    border-radius: var(--r-xs);
    background: var(--c-accent-soft);
    color: var(--c-accent);
    font-size: var(--fs-xs);
    font-weight: 800;
}
.draft-title-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px var(--sp-2);
    border: 1px solid transparent;
    border-radius: var(--r-xs);
    background: transparent;
    font-size: var(--fs-base);
    font-weight: 700;
    color: var(--c-text);
}
.draft-title-input:hover { background: var(--c-surface-3); }
.draft-title-input:focus {
    outline: none;
    background: var(--c-surface);
    border-color: var(--c-accent);
}
.draft-item-tools { display: flex; gap: 2px; flex: 0 0 auto; }
.tool-btn {
    display: grid; place-items: center;
    width: 34px; height: 34px;
    border: 0; border-radius: var(--r-xs);
    background: transparent;
    color: var(--c-text-3);
    transition: background var(--dur), color var(--dur);
}
.tool-btn:hover { background: var(--c-surface-3); color: var(--c-text); }
.tool-btn:disabled { opacity: .35; cursor: not-allowed; }
.tool-btn.is-danger:hover { background: var(--c-danger-soft); color: var(--c-danger); }

.draft-textarea {
    display: block;
    width: 100%;
    min-height: 120px;
    padding: var(--sp-3);
    border: 0;
    background: transparent;
    color: var(--c-text-2);
    font-size: var(--fs-base);
    line-height: 1.65;
    resize: none;
    overflow: hidden;
}
.draft-textarea:focus { outline: none; background: var(--c-surface-2); }

.draft-foot {
    flex: 0 0 auto;
    display: flex;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    padding-bottom: max(var(--sp-3), env(safe-area-inset-bottom));
    border-top: 1px solid var(--c-border);
    background: var(--c-surface);
}

/* -------------------------------------------------------------------------
   9. MODALS
   ------------------------------------------------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: grid;
    place-items: end center;
    padding: 0;
    background: rgba(2, 6, 23, .5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }

.modal-card {
    width: 100%;
    max-width: 520px;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    background: var(--c-surface);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: var(--sh-xl);
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheet-up .28s var(--ease);
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal-card { animation: none; } }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: var(--sp-4);
    border-bottom: 1px solid var(--c-border);
}
.modal-head h2 { font-size: var(--fs-md); font-weight: 800; }

.modal-body {
    padding: var(--sp-4);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}
.modal-foot {
    padding: var(--sp-3) var(--sp-4) var(--sp-4);
    border-top: 1px solid var(--c-border);
    display: flex;
    gap: var(--sp-2);
}

.settings-group { display: flex; flex-direction: column; gap: var(--sp-2); }
.settings-group-title {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--c-text-3);
    padding-left: 2px;
}
.settings-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    width: 100%;
    padding: var(--sp-3);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    background: var(--c-surface-2);
    color: var(--c-text);
    text-align: left;
    font-size: var(--fs-base);
    font-weight: 600;
    transition: border-color var(--dur), background var(--dur);
}
a.settings-row { text-decoration: none; }
a.settings-row:hover,
button.settings-row:hover { border-color: var(--c-border-strong); background: var(--c-surface-3); }
.settings-row .icon-svg { color: var(--c-text-3); }
.settings-row.is-danger { color: var(--c-danger); }
.settings-row.is-danger .icon-svg { color: var(--c-danger); }
.settings-row-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.settings-row-sub { font-size: var(--fs-xs); font-weight: 500; color: var(--c-text-3); }
.settings-row-sub kbd {
    display: inline-block;
    padding: 1px 5px;
    border: 1px solid var(--c-border-strong);
    border-radius: 4px;
    background: var(--c-surface);
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
}

.legal-body { font-size: var(--fs-base); color: var(--c-text-2); }
.legal-body ul { margin: 0 0 var(--sp-3); padding-left: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); }
.legal-body strong { color: var(--c-text); }
.legal-body h4 { font-size: var(--fs-sm); color: var(--c-text); margin-bottom: var(--sp-1); }
.legal-body code { font-size: .92em; background: var(--c-surface-2); padding: 0 4px; border-radius: var(--r-xs, 4px); }
.legal-body section.settings-group:not(:first-child) { padding-top: var(--sp-4); border-top: 1px solid var(--c-border); }

.app-version {
    text-align: center;
    font-size: var(--fs-xs);
    color: var(--c-text-3);
}

/* Segmented control (Theme) */
.segmented {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 2px;
    padding: 3px;
    border-radius: var(--r-sm);
    background: var(--c-surface-3);
}
.segmented button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    border: 0;
    border-radius: calc(var(--r-sm) - 3px);
    background: transparent;
    color: var(--c-text-2);
    font-size: var(--fs-sm);
    font-weight: 700;
    transition: background var(--dur), color var(--dur);
}
.segmented button[aria-pressed="true"] {
    background: var(--c-surface);
    color: var(--c-text);
    box-shadow: var(--sh-xs);
}

/* -------------------------------------------------------------------------
   10. TOAST / BANNER
   ------------------------------------------------------------------------- */

.toast-stack {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--sp-3));
    transform: translateX(-50%);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    width: min(440px, calc(100vw - 2 * var(--sp-4)));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    background: #111827;
    color: #f8fafc;
    font-size: var(--fs-sm);
    font-weight: 600;
    box-shadow: var(--sh-lg);
    animation: toast-in .28s var(--ease);
    pointer-events: auto;
}
[data-theme="dark"] .toast { background: #f8fafc; color: #0f172a; }
.toast--success { background: var(--c-success); color: #fff; }
.toast--error { background: var(--c-danger); color: #fff; }
.toast.is-leaving { animation: toast-out .22s var(--ease) forwards; }

@keyframes toast-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(8px); opacity: 0; } }

.update-banner {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--sp-3));
    z-index: var(--z-toast);
    width: min(440px, calc(100vw - 2 * var(--sp-4)));
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    background: var(--c-accent);
    color: var(--c-accent-fg);
    font-size: var(--fs-sm);
    font-weight: 700;
    box-shadow: var(--sh-lg);
}
.update-banner[hidden] { display: none; }
.update-banner span { flex: 1 1 auto; }
.update-banner .btn {
    background: color-mix(in srgb, var(--c-accent-fg) 90%, transparent);
    color: var(--c-accent);
}
.update-banner .btn--ghost {
    background: transparent;
    border-color: color-mix(in srgb, var(--c-accent-fg) 60%, transparent);
    color: var(--c-accent-fg);
}

/* -------------------------------------------------------------------------
   10b. RECHTLICHE SEITEN (datenschutz.html, impressum.html)
   ------------------------------------------------------------------------- */

.legal-page .app-header { position: sticky; top: 0; }
.legal-page .brand-name { display: block; }

.legal-main {
    max-width: 760px;
    margin: 0 auto;
    padding: var(--sp-6) max(var(--sp-4), env(safe-area-inset-right)) var(--sp-8) max(var(--sp-4), env(safe-area-inset-left));
}

.legal-doc { display: flex; flex-direction: column; gap: var(--sp-6); color: var(--c-text-2); }
.legal-doc h1 { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.01em; color: var(--c-text); }
.legal-doc h2 { margin-bottom: var(--sp-2); font-size: var(--fs-md); color: var(--c-text); }
.legal-doc strong { color: var(--c-text); }
.legal-doc ul { margin: 0 0 var(--sp-3); padding-left: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); }
.legal-doc code { font-size: .92em; background: var(--c-surface-3); padding: 0 4px; border-radius: var(--r-xs); }
.legal-stand { margin-top: var(--sp-1); font-size: var(--fs-sm); color: var(--c-text-3); }

.legal-doc a, .legal-links a { color: var(--c-accent); font-weight: 600; }
.legal-links { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); }

.legal-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--sp-2) var(--sp-5);
    padding: var(--sp-4) var(--sp-4) max(var(--sp-6), env(safe-area-inset-bottom));
    border-top: 1px solid var(--c-border);
    font-size: var(--fs-sm);
}
.legal-foot a { color: var(--c-text-2); font-weight: 600; }
.legal-foot a:hover { color: var(--c-accent); }
.legal-foot > span { flex-basis: 100%; text-align: center; color: var(--c-text-2); }

/* -------------------------------------------------------------------------
   11. RESPONSIVE — KLEINE PHONES (< 480px)
   ------------------------------------------------------------------------- */

@media (max-width: 479.98px) {
    .results-scroll, .draft-scroll { padding: var(--sp-3); }
    .results-toolbar, .results-meta, .draft-head, .draft-foot, .draft-hint { padding-left: var(--sp-3); padding-right: var(--sp-3); }
    .law-card-head, .norm-item { padding-left: var(--sp-3); padding-right: var(--sp-3); }

    /* Absatz-Chip und Aktionen teilen sich eine Zeile; bei langem Chip rutschen die Aktionen darunter. */
    .norm-head { margin-bottom: var(--sp-2); }
    .norm-actions { flex: 1 1 220px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--sp-2); }
    .norm-actions .btn { min-height: 40px; padding-left: var(--sp-2); padding-right: var(--sp-2); }

    .quick-start-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Sehr schmale Phones (iPhone SE 1. Gen.): Aktionen ohne Symbole, damit sie neben den Absatz-Chip passen */
@media (max-width: 359.98px) {
    .norm-actions .btn .icon-svg { display: none; }
    .law-card-title { font-size: var(--fs-md); }

    /* Titel des Entwurfspunkts bekommt eine eigene Zeile */
    .draft-item-head { flex-wrap: wrap; }
    .draft-item-tools { margin-left: auto; }
    .draft-title-input { flex: 1 0 100%; order: 3; margin-top: 2px; }
}

/* -------------------------------------------------------------------------
   11a. RESPONSIVE — MOBIL & TABLET (< 1024px, Bottom-Nav aktiv)
   ------------------------------------------------------------------------- */

@media (max-width: 1023.98px) {
    /* Header entschlacken: Upload, Design und Revisionsbogen liegen in Einstellungen bzw. Bottom-Nav */
    .hide-mobile { display: none !important; }
    /* Datenbank-Status nur zeigen, wenn etwas nicht stimmt */
    #statusBtn:has(.status-dot[data-status="ok"]) { display: none; }

    /* Filter-Knopf als gleich hohes Gegenstück zum Suchfeld */
    .results-toolbar .filter-trigger {
        width: 46px; height: 46px;
        border-color: var(--c-border);
        background: var(--c-surface-2);
    }
    .results-toolbar .filter-trigger.is-active {
        background: var(--c-accent-soft);
        border-color: color-mix(in srgb, var(--c-accent) 40%, transparent);
    }

    /* Startzustand kompakter: Schnellstart rückt nach oben */
    .state-box { padding: var(--sp-5) var(--sp-4) var(--sp-1); margin: 0 auto; gap: var(--sp-2); }
    .state-icon { width: 44px; height: 44px; }

    /* Bottom-Nav deckt den unteren Safe-Area-Bereich bereits ab */
    .draft-foot { padding-bottom: var(--sp-3); }

    /* Meldungen im Entwurf oberhalb der Kopieren-Leiste */
    body[data-route="#document"] .toast-stack,
    body[data-route="#document"] .update-banner {
        bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 68px + var(--sp-3));
    }
}

/* Touch-Geräte: Eingabefelder ≥ 16px, sonst zoomt iOS beim Fokussieren */
@media (pointer: coarse) {
    .input, .select, .draft-textarea, .draft-title-input { font-size: max(16px, var(--fs-base)); }
}

/* -------------------------------------------------------------------------
   11b. RESPONSIVE — TABLET (>= 768px)
   ------------------------------------------------------------------------- */

@media (min-width: 768px) {
    :root { --header-h: 60px; }

    .modal { place-items: center; padding: var(--sp-5); }
    .modal-card { border-radius: var(--r-xl); }

    .results-scroll, .draft-scroll { padding: var(--sp-5); }
    .results-toolbar, .results-meta, .draft-head, .draft-hint { padding-left: var(--sp-5); padding-right: var(--sp-5); }
}

/* -------------------------------------------------------------------------
   12. RESPONSIVE — DESKTOP (>= 1024px): Sidebar statt Bottom-Sheet
   ------------------------------------------------------------------------- */

@media (min-width: 1024px) {
    .app-shell {
        grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        grid-template-areas:
            "header  header"
            "filters main";
    }

    /* Bottom-Nav und Sheet-Elemente entfallen */
    .bottom-nav,
    .sheet-grabber,
    .panel-foot,
    .filter-panel-close,
    .filter-trigger,
    .scrim { display: none !important; }

    .filter-panel {
        position: static;
        transform: none;
        max-height: none;
        min-height: 0;
        border-radius: 0;
        box-shadow: none;
        border-right: 1px solid var(--c-border);
        background: var(--c-surface);
        padding-bottom: 0;
        overflow: hidden;
    }
    .panel-body { overflow-y: auto; padding: var(--sp-4); padding-bottom: var(--sp-8); }

    /* Beide Screens gleichzeitig sichtbar */
    .app-main {
        grid-template-areas: "screens";
    }
    .app-screen { display: flex !important; animation: none; }

    #screen-search {
        border-right: 1px solid var(--c-border);
    }

    .toast-stack, .update-banner { bottom: var(--sp-5); }
}

/* Desktop-Split: Ergebnisse + Entwurf nebeneinander (>= 1280px) */
@media (min-width: 1280px) {
    .app-main {
        grid-template-columns: minmax(0, 1fr) var(--draft-w);
        grid-template-areas: "results draft";
    }
    #screen-search { grid-area: results; }
    #screen-document { grid-area: draft; }
    #screen-document { background: var(--c-surface); border-left: 1px solid var(--c-border); }
    #screen-document .draft-head { background: var(--c-surface-2); backdrop-filter: none; }
    #screen-document .draft-scroll { padding: var(--sp-4); }
    .draft-toggle { display: none !important; }
}

/* Zwischenbereich 1024–1279px: Entwurf als Slide-Over */
@media (min-width: 1024px) and (max-width: 1279.98px) {
    #screen-document {
        position: fixed;
        top: calc(var(--header-h) + env(safe-area-inset-top));
        right: 0;
        bottom: 0;
        width: min(440px, 92vw);
        z-index: var(--z-panel);
        background: var(--c-surface);
        border-left: 1px solid var(--c-border);
        box-shadow: var(--sh-xl);
        transform: translateX(101%);
        transition: transform .3s var(--ease);
    }
    #screen-document.is-open { transform: none; }
}

@media (max-width: 1023.98px) {
    .draft-toggle { display: none !important; }
}

@media (min-width: 1600px) {
    :root { --draft-w: 460px; --sidebar-w: 330px; }
}

/* -------------------------------------------------------------------------
   13. SONSTIGES
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

@media print {
    .app-header, .bottom-nav, .filter-panel, .results-toolbar,
    .results-meta, .draft-head-actions, .draft-foot, .draft-hint, .toast-stack { display: none !important; }
    .app-shell { height: auto; display: block; }
    .app-screen { display: block !important; }
    #screen-search { display: none !important; }
    body { background: #fff; }
}

/* --- Toast-Aktion (Rückgängig) --- */
.toast span { flex: 1 1 auto; }
.toast-action {
    flex: none;
    min-height: 32px;
    padding: 0 var(--sp-3);
    border: 0;
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, .16);
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.toast-action:hover, .toast-action:focus-visible { background: rgba(255, 255, 255, .28); }

/* --- Bestätigungsdialog --- */
.confirm-dialog { place-items: center; padding: var(--sp-4); }
.confirm-dialog .modal-card { max-width: 420px; border-radius: var(--r-xl); }
.confirm-dialog .modal-foot { justify-content: flex-end; border-top: 0; }
.confirm-text { white-space: pre-line; color: var(--c-text-3); line-height: 1.5; }
.btn--danger-solid { background: var(--c-danger); border-color: transparent; color: #fff; }
.btn--danger-solid:hover:not(:disabled) { filter: brightness(.92); }

/* --- Nachladen der Trefferliste --- */
.results-sentinel { height: 1px; }

/* --- Speicherstatus im Entwurf --- */
.save-status { font-size: var(--fs-xs, .75rem); color: var(--c-text-3); opacity: 0; transition: opacity .25s var(--ease); }
.save-status.is-visible { opacity: 1; }

/* --- Weiche Seitenwechsel (Hauptseite ↔ Revisionsbogen) --- */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
}

/* --- Schnellstart im Startzustand --- */
.quick-start { display: flex; flex-direction: column; gap: var(--sp-2); width: 100%; max-width: 600px; margin: 0 auto; }
.quick-start-title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text-3); padding-left: 2px; }
.quick-start-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--sp-2); }
.quick-tile {
    display: flex; align-items: center; gap: var(--sp-2);
    min-width: 0; min-height: 56px; padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--c-border); border-radius: var(--r-md);
    background: var(--c-surface); color: var(--c-text); box-shadow: var(--sh-xs);
    font: inherit; text-align: left; cursor: pointer;
    transition: border-color .15s var(--ease), background .15s var(--ease), transform .12s;
    -webkit-tap-highlight-color: transparent;
}
.quick-tile:hover, .quick-tile:focus-visible { border-color: var(--c-accent); }
.quick-tile:active { transform: scale(.98); }
.quick-tile-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; line-height: 1.3; }
.quick-tile-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-width: 0; }
.quick-tile-title { font-weight: 800; font-size: var(--fs-base); letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-tile-sub { font-size: var(--fs-xs); color: var(--c-text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-tile-count {
    flex: 0 0 auto; padding: 1px 7px; border-radius: var(--r-full);
    background: var(--c-surface-3); color: var(--c-text-2);
    font-size: 11px; font-weight: 750; font-variant-numeric: tabular-nums;
}
.quick-tile-icon {
    flex: 0 0 auto; display: grid; place-items: center;
    width: 36px; height: 36px; border-radius: var(--r-sm);
    background: var(--c-accent); color: var(--c-accent-fg);
}
.quick-tile--accent { grid-column: 1 / -1; background: var(--c-accent-soft-2); border-color: color-mix(in srgb, var(--c-accent) 35%, transparent); }
.quick-tile--accent .quick-tile-count { background: var(--c-accent-soft); color: var(--c-accent); }

/* --- Sortieren per Ziehen --- */
.drag-handle {
    display: inline-flex; padding: 0; border: 0; background: none;
    cursor: grab; touch-action: none; border-radius: var(--r-sm);
    min-width: 36px; min-height: 36px; align-items: center; justify-content: center;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.draft-list.is-sorting { user-select: none; }
.draft-item.is-dragging { opacity: .9; box-shadow: var(--sh-lg); position: relative; z-index: 2; outline: 2px solid var(--c-accent); }

/* Update erfolgreich */
.update-done-card { max-width: 380px; }
.update-done-body { text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding-top: var(--sp-6); }
.update-done-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--c-success-soft); color: var(--c-success); }
.update-done-icon svg { width: 28px; height: 28px; }
.update-done-hint { font-size: var(--fs-sm); color: var(--c-text-2); }
