:root {
    /* Lokale Defaults. Vom Studio auf <html> injizierte Inline-Tokens haben
       weiterhin Vorrang; selbstreferenzielle var()-Fallbacks wären dagegen
       außerhalb des Studios ungültig und ließen Primärbuttons transparent. */
    --primary: #000000;
    --accent: #C05BDB;
    --success: #37AB8A;
    --highlight: #FFDD00;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #F2F9F7;
    --text: #000000;
    --muted: #595959;
    --radius: 8px;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
    --font: "Poppins", system-ui, -apple-system, sans-serif;
    --heading-font: "Poppins", system-ui, sans-serif;
    --border: color-mix(in srgb, var(--text) 12%, transparent);
    --bg-soft: color-mix(in srgb, var(--bg) 78%, var(--surface) 22%);
    --sidebar-footer-bg: linear-gradient(180deg, rgba(12, 18, 26, 0) 0%, rgba(12, 18, 26, 0.96) 24%);
    --user-chip-border: rgba(255, 255, 255, 0.07);
    --user-chip-bg: rgba(255, 255, 255, 0.035);
    --user-chip-hover-bg: rgba(255, 255, 255, 0.07);
    --user-chip-open-bg: color-mix(in srgb, var(--primary) 14%, transparent);
    --user-chip-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
    --user-chip-open-shadow: 0 18px 36px rgba(0, 0, 0, 0.34);
    --avatar-gradient: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 64%, #0f172a 36%));
    --avatar-inset: inset 0 1px 0 rgba(255, 255, 255, 0.12);
    --menu-panel-border: rgba(255, 255, 255, 0.08);
    --menu-panel-bg: rgba(19, 28, 40, 0.98);
    --menu-panel-shadow: 0 24px 48px rgba(0, 0, 0, 0.38);
    --menu-divider: rgba(255, 255, 255, 0.08);
    --menu-control-border: rgba(255, 255, 255, 0.08);
    --menu-control-bg: rgba(255, 255, 255, 0.03);
    --menu-option-hover: color-mix(in srgb, var(--primary) 14%, transparent);
    --menu-option-active-text: #081018;
    --menu-option-active-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 28%, transparent);
    --topbar-bg: rgba(12, 18, 26, 0.88);
    --topbar-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
    --code-bg: #0a1017;
    --code-text: var(--text);
    --send-btn-bg: var(--primary);
    --send-btn-hover-bg: color-mix(in srgb, var(--primary) 88%, black 12%);
    --send-btn-text: #ffffff;
    --admin-panel-bg: radial-gradient(circle at top right, color-mix(in srgb, var(--primary) 18%, transparent), transparent 24%), linear-gradient(180deg, rgba(19, 28, 40, 0.98), rgba(12, 18, 26, 1));
    --table-card-bg: linear-gradient(180deg, rgba(19, 28, 40, 0.96), rgba(14, 22, 34, 0.98));
    --table-card-header-bg: rgba(255, 255, 255, 0.02);
    --table-head-bg: rgba(255, 255, 255, 0.03);
    --table-row-hover: color-mix(in srgb, var(--primary) 10%, transparent);
    --status-badge-bg: rgba(156, 170, 188, 0.16);
    --status-badge-text: #d8e3ef;
    --status-badge-border: rgba(156, 170, 188, 0.2);
    --status-success-bg: rgba(52, 211, 153, 0.14);
    --status-success-text: #a7f3d0;
    --status-success-border: rgba(52, 211, 153, 0.18);
    --mini-action-border: rgba(156, 170, 188, 0.22);
    --mini-action-bg: rgba(255, 255, 255, 0.03);
    --mini-action-hover-text: #eff6ff;
    --mini-action-danger-text: #fecaca;
    --group-card-bg: linear-gradient(180deg, rgba(22, 31, 45, 0.94), rgba(19, 28, 40, 0.98));
    --group-card-border: rgba(156, 170, 188, 0.18);
    --group-card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

:root[data-theme="light"],
body[data-theme="light"],
.app[data-theme="light"],
[data-theme="light"] .app {
    /* Light-Mode-Variablen werden zusätzlich auf dem .app-Wrapper deklariert.
       Grund: Die Studio-Runtime injiziert die dunklen Theme-Variablen inline
       auf <html> (teils mit !important), wodurch :root[data-theme="light"]
       nicht zuverlässig greift. Eine eigene Deklaration auf dem tieferliegenden
       .app-Element überschreibt den vererbten Wert für den gesamten App-Subtree
       unabhängig von Inline-Styles auf <html>. */
    --primary: #000000 !important;
    --accent: #C05BDB !important;
    --success: #37AB8A !important;
    --highlight: #FFDD00 !important;
    --bg: #ffffff !important;
    --surface: #ffffff !important;
    --surface-2: #F2F9F7 !important;
    --text: #000000 !important;
    --muted: #595959 !important;
    --border: rgba(0, 0, 0, 0.14) !important;
    --bg-soft: #F2F9F7 !important;
    --sidebar-footer-bg: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.96) 24%);
    --user-chip-border: rgba(0, 0, 0, 0.14);
    --user-chip-bg: rgba(0, 0, 0, 0.035);
    --user-chip-hover-bg: rgba(192, 91, 219, 0.10);
    --user-chip-open-bg: color-mix(in srgb, var(--primary) 12%, transparent);
    --user-chip-shadow: 0 10px 24px rgba(31, 52, 74, 0.08);
    --user-chip-open-shadow: 0 18px 36px rgba(31, 52, 74, 0.12);
    --avatar-gradient: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, white 30%));
    --avatar-inset: inset 0 1px 0 rgba(255, 255, 255, 0.65);
    --menu-panel-border: rgba(0, 0, 0, 0.14);
    --menu-panel-bg: rgba(255, 255, 255, 0.98);
    --menu-panel-shadow: 0 24px 48px rgba(31, 52, 74, 0.14);
    --menu-divider: rgba(0, 0, 0, 0.10);
    --menu-control-border: rgba(0, 0, 0, 0.14);
    --menu-control-bg: rgba(0, 0, 0, 0.035);
    --menu-option-hover: color-mix(in srgb, var(--primary) 10%, white);
    --menu-option-active-text: #ffffff;
    --menu-option-active-shadow: 0 10px 24px rgba(70, 130, 180, 0.2);
    --topbar-bg: rgba(244, 248, 252, 0.88);
    --topbar-shadow: 0 10px 28px rgba(31, 52, 74, 0.08);
    --code-bg: #eef4fa;
    --code-text: #162230;
    --send-btn-bg: var(--primary);
    --send-btn-hover-bg: color-mix(in srgb, var(--primary) 90%, black 10%);
    --send-btn-text: #ffffff;
    --admin-panel-bg: radial-gradient(circle at top right, rgba(192, 91, 219, 0.12), transparent 24%), linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(242, 249, 247, 1)) !important;
    --table-card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(242, 249, 247, 1)) !important;
    --table-card-header-bg: rgba(192, 91, 219, 0.05) !important;
    --table-head-bg: rgba(192, 91, 219, 0.08) !important;
    --table-row-hover: color-mix(in srgb, var(--primary) 8%, white);
    --status-badge-bg: rgba(95, 111, 130, 0.12);
    --status-badge-text: #314154;
    --status-badge-border: rgba(95, 111, 130, 0.16);
    --status-success-bg: rgba(55, 171, 138, 0.14);
    --status-success-text: #16745a;
    --status-success-border: rgba(55, 171, 138, 0.20);
    --mini-action-border: rgba(95, 111, 130, 0.18);
    --mini-action-bg: rgba(255, 255, 255, 0.88);
    --mini-action-hover-text: #162230;
    --mini-action-danger-text: #b91c1c;
    --group-card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 248, 252, 1)) !important;
    --group-card-border: rgba(95, 111, 130, 0.14) !important;
    --group-card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.72) !important;
}

:root[data-theme="dark"],
body[data-theme="dark"],
.app[data-theme="dark"],
[data-theme="dark"] .app {
    --primary: #ffffff !important;
    --accent: #C05BDB !important;
    --success: #54B496 !important;
    --highlight: #FFDD00 !important;
    --bg: #000000 !important;
    --surface: #101010 !important;
    --surface-2: #1C1C1C !important;
    --text: #ffffff !important;
    --muted: #B3B3B3 !important;
    --border: rgba(255, 255, 255, 0.14) !important;
    --bg-soft: #151515 !important;
    --sidebar-footer-bg: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.96) 24%);
    --user-chip-border: rgba(255, 255, 255, 0.12);
    --user-chip-bg: rgba(255, 255, 255, 0.04);
    --user-chip-hover-bg: rgba(192, 91, 219, 0.14);
    --user-chip-open-bg: rgba(192, 91, 219, 0.16);
    --user-chip-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    --user-chip-open-shadow: 0 18px 36px rgba(0, 0, 0, 0.38);
    --avatar-gradient: linear-gradient(135deg, #C05BDB, #643FBF);
    --avatar-inset: inset 0 1px 0 rgba(255, 255, 255, 0.12);
    --menu-panel-border: rgba(255, 255, 255, 0.12);
    --menu-panel-bg: rgba(16, 16, 16, 0.98);
    --menu-panel-shadow: 0 24px 48px rgba(0, 0, 0, 0.42);
    --menu-divider: rgba(255, 255, 255, 0.10);
    --menu-control-border: rgba(255, 255, 255, 0.12);
    --menu-control-bg: rgba(255, 255, 255, 0.04);
    --menu-option-hover: rgba(192, 91, 219, 0.14);
    --menu-option-active-text: #000000;
    --menu-option-active-shadow: 0 10px 24px rgba(192, 91, 219, 0.26);
    --topbar-bg: rgba(0, 0, 0, 0.88);
    --topbar-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
    --code-bg: #181818;
    --code-text: #ffffff;
    --send-btn-bg: #ffffff;
    --send-btn-hover-bg: #E6E6E6;
    --send-btn-text: #000000;
    --admin-panel-bg: radial-gradient(circle at top right, rgba(192, 91, 219, 0.16), transparent 24%), linear-gradient(180deg, #151515, #000000);
    --table-card-bg: linear-gradient(180deg, #151515, #101010);
    --table-card-header-bg: rgba(255, 255, 255, 0.04);
    --table-head-bg: rgba(255, 255, 255, 0.06);
    --table-row-hover: rgba(192, 91, 219, 0.10);
    --status-badge-bg: rgba(255, 255, 255, 0.12);
    --status-badge-text: #E6E6E6;
    --status-badge-border: rgba(255, 255, 255, 0.16);
    --status-success-bg: rgba(84, 180, 150, 0.16);
    --status-success-text: #BFE6D8;
    --status-success-border: rgba(84, 180, 150, 0.22);
    --mini-action-border: rgba(255, 255, 255, 0.16);
    --mini-action-bg: rgba(255, 255, 255, 0.04);
    --mini-action-hover-text: #ffffff;
    --mini-action-danger-text: #FECACA;
    --group-card-bg: linear-gradient(180deg, #181818, #101010);
    --group-card-border: rgba(255, 255, 255, 0.14);
    --group-card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

:root[data-theme="light"] .documents-eyebrow,
.app[data-theme="light"] .documents-eyebrow {
    color: #643FBF;
}

:root[data-theme="light"] .library-status.pending,
:root[data-theme="light"] .library-status.indexing,
.app[data-theme="light"] .library-status.pending,
.app[data-theme="light"] .library-status.indexing {
    border-color: rgba(146, 64, 14, 0.24);
    background: rgba(245, 158, 11, 0.14);
    color: #92400e;
}

:root[data-theme="light"] .library-status.failed,
.app[data-theme="light"] .library-status.failed {
    border-color: rgba(185, 28, 28, 0.22);
    background: rgba(239, 68, 68, 0.10);
    color: #b91c1c;
}

:root[data-theme="light"] .library-row.folder .library-item-icon,
.app[data-theme="light"] .library-row.folder .library-item-icon {
    color: #643FBF;
}

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

/* Material Symbols – Basis */
.material-symbols-outlined {
    font-family: "Material Symbols Outlined";
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-feature-settings: "liga";
    font-feature-settings: "liga";
    -moz-font-feature-settings: "liga";
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
    vertical-align: middle;
    user-select: none;
    /* Verhindert, dass roher Text (z. B. "delete") sichtbar bleibt,
       bevor/falls die Icon-Schrift greift */
    overflow: hidden;
    max-width: 1.2em;
}

/* Inline-Icon innerhalb von Fließtext (z. B. Fehlermeldungen) */
.material-symbols-outlined.inline-ico {
    font-size: 1.15em;
    margin-right: 0.3em;
    transform: translateY(0.12em);
}
.material-symbols-outlined.error-ico {
    color: #ff6b6b;
}

html,
body {
    height: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.dialog-checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    color: var(--text);
    font-size: 14px;
}

.dialog-checkbox-row input {
    accent-color: var(--primary);
}

.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width, 280px);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.25s ease;
    z-index: 40;
    position: relative;
}

/* Ziehbarer Griff zum Verändern der Sidebar-Breite */
.sidebar-resizer {
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 50;
    background: transparent;
    transition: background 0.15s;
    touch-action: none;
}
.sidebar-resizer::after {
    content: "";
    position: absolute;
    top: 0;
    left: 2px;
    width: 2px;
    height: 100%;
    background: transparent;
    transition: background 0.15s;
}
.sidebar-resizer:hover::after,
.sidebar-resizer.resizing::after {
    background: var(--primary);
}
body.sidebar-resizing {
    cursor: col-resize;
    user-select: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px 12px;
}

.brand {
    display: flex;
    align-items: center;
    min-width: 0;
}

.brand-logo {
    display: block;
    width: min(188px, 100%);
    height: 42px;
    object-fit: contain;
    object-position: left center;
}

:root[data-theme="dark"] .brand-logo,
.app[data-theme="dark"] .brand-logo,
:root[data-theme="dark"] .welcome-brand-logo,
.app[data-theme="dark"] .welcome-brand-logo {
    filter: invert(1);
}

.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
}

.brand-name {
    display: inline-flex;
    align-items: baseline;
    gap: 0;
}

.brand-accent {
    color: var(--accent);
}

.sidebar-actions {
    display: flex;
    gap: 8px;
    margin: 4px 16px 14px;
}

.sidebar-nav {
    display: grid;
    align-content: start;
    gap: 4px;
    padding: 0 10px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
    /* Nav endet direkt am Inhalt – die Chat-Elemente liegen jetzt in der
       rechten Kontextspalte, daher hier KEIN flex:1-Streckraum mehr. */
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* Fachmenüs werden ausschließlich über die effektiven Gruppenrechte gesteuert.
   Diese Regel ist nötig, weil die flex-Deklaration unten die Browser-Standardregel
   für das HTML-Attribut `hidden` sonst übersteuert und gesperrte Punkte sichtbar macht. */
.sidebar-nav-item[hidden],
.nav-group[hidden],
.sidebar-nav-bottom[hidden] {
    display: none;
}

.sidebar-nav-item {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.sidebar-nav-item:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.sidebar-nav-item.active,
.sidebar-nav-item[aria-current="page"] {
    color: var(--text);
    border-color: color-mix(in srgb, var(--primary) 28%, transparent);
    background: color-mix(in srgb, var(--primary) 16%, transparent);
}

.sidebar-nav-item.active .material-symbols-outlined,
.sidebar-nav-item[aria-current="page"] .material-symbols-outlined {
    color: var(--accent);
    font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
}

.sidebar-nav-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.sidebar-nav-label {
    margin: 10px 12px 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sage-nav-item {
    min-height: 35px;
    padding-block: 6px;
}

/* ---------- Auf-/zuklappbare Nav-Gruppe (Reporting) ---------- */
.nav-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
}

.nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    margin: 2px 0;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: normal;
    text-transform: none;
    text-align: left;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.nav-group-toggle:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.nav-group-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.nav-group-icon {
    flex-shrink: 0;
    font-size: 20px;
    color: var(--muted);
}

.nav-group-toggle:hover .nav-group-icon {
    color: var(--accent);
}

.nav-group-caret {
    flex-shrink: 0;
    margin-left: auto;
    font-size: 18px;
    color: var(--muted);
    transition: transform 0.18s ease;
}

.nav-group-title {
    flex: 1;
    min-width: 0;
    font-size: inherit;
    font-weight: inherit;
    line-height: 1.2;
    letter-spacing: inherit;
    text-transform: none;
}

.nav-group-count {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0;
    color: var(--muted);
    background: var(--surface-2);
    border-radius: 10px;
    padding: 1px 7px;
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.nav-group.is-collapsed .nav-group-caret {
    transform: rotate(-90deg);
}

.nav-group.is-collapsed .nav-group-items {
    display: none;
}

.new-folder-btn {
    flex-shrink: 0;
    width: 44px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, background 0.12s, box-shadow 0.15s;
    box-shadow: var(--shadow);
}
.new-folder-btn:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--surface-2) 72%, var(--primary) 28%);
}

.new-chat-btn {
    flex: 1;
    padding: 12px 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
    box-shadow: 0 12px 28px color-mix(in srgb, var(--primary) 30%, transparent);
}

.new-chat-btn:hover {
    background: color-mix(in srgb, var(--primary) 88%, white 12%);
}

:root[data-theme="dark"] .new-chat-btn,
.app[data-theme="dark"] .new-chat-btn {
    background: #C05BDB;
    color: #ffffff;
}

:root[data-theme="dark"] .new-chat-btn:hover,
.app[data-theme="dark"] .new-chat-btn:hover {
    background: #914ECD;
}
.new-chat-btn:active {
    transform: scale(0.98);
}
.new-chat-btn .plus {
    font-size: 18px;
    line-height: 1;
}

.sidebar-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar-actions[hidden],
.conversations[hidden],
.agents-section[hidden],
.sage-sidebar-context[hidden] {
    display: none !important;
}

.conversations {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0 10px;
}

.sage-sidebar-context {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0;
}

.sage-saved-head {
    cursor: default;
}

.sage-saved-head:hover {
    color: var(--muted);
    background: transparent;
}

.sage-saved-head-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sage-live-status {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 7px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--success) 14%, transparent);
    color: var(--success);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sage-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 14%, transparent);
}

.sage-saved-list {
    display: grid;
    gap: 2px;
    padding-left: 18px;
}

.sage-saved-list .saved-view {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    border-radius: var(--radius);
}

.sage-saved-list .saved-view:hover {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.sage-saved-list .saved-open,
.sage-saved-list .saved-delete {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.sage-saved-list .saved-open {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 8px;
    text-align: left;
}

.sage-saved-list .saved-open span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sage-saved-list .saved-open .material-symbols-outlined,
.sage-saved-list .saved-delete .material-symbols-outlined {
    font-size: 18px;
}

.sage-saved-list .saved-delete {
    padding: 8px;
    opacity: 0;
}

.sage-saved-list .saved-view:hover .saved-delete,
.sage-saved-list .saved-delete:focus-visible {
    opacity: 1;
}

.sage-saved-list .saved-empty {
    margin: 0;
    padding: 8px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

/* ---- Prompt-Agenten mit 46 px Abstand zum unteren Rand der Chat-Kontextspalte ---- */
.agents-section {
    margin-bottom: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--user-chip-bg, var(--surface-2));
    overflow: hidden;
}
.agents-head {
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text);
    font-family: var(--font);
    text-align: left;
}
.agents-head:hover {
    background: color-mix(in srgb, var(--surface-2) 70%, var(--primary) 30%);
}
.agents-head-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.agents-head-title .material-symbols-outlined {
    font-size: 18px;
    color: var(--accent);
}
.agents-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.agents-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}
.agents-add-btn .material-symbols-outlined {
    font-size: 18px;
}
.agents-add-btn:hover {
    background: color-mix(in srgb, var(--primary) 86%, white 14%);
}
.agents-caret {
    font-size: 20px;
    color: var(--muted);
    transition: transform 0.18s ease;
}
.agents-section.collapsed .agents-caret {
    transform: rotate(180deg);
}
.agents-list {
    max-height: 38vh;
    overflow-y: auto;
    padding: 4px 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.agents-section.collapsed .agents-list {
    display: none;
}
.agents-empty {
    color: var(--muted);
    font-size: 12px;
    padding: 6px 6px 4px;
    margin: 0;
}
.agents-group-label {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 6px 6px 2px;
}
.agent-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.12s, border-color 0.12s;
}
.agent-item:hover {
    background: color-mix(in srgb, var(--surface-2) 60%, var(--primary) 40%);
}
.agent-item.active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--primary) 22%, transparent);
}
.agent-item-ico {
    font-size: 18px;
    /* Mittlere Stärke: ~50% zurückgenommen zwischen kräftigem Dunkelgrün und Akzentton. */
    color: #8eaf04;
    font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
    opacity: 1;
    flex-shrink: 0;
}
.agent-item.active .agent-item-ico {
    color: #86a305;
}
.agent-item-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}
.agent-item-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.agent-item-desc {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.agent-item-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.agent-active-badge {
    font-size: 10px;
    font-weight: 700;
    /* ~50% zurückgenommen: dunkler Text auf mittelgrünem Hintergrund — weiterhin gut lesbar (WCAG AA). */
    color: #243a00;
    background: #aacb2a;
    padding: 2px 7px;
    border-radius: 999px;
    letter-spacing: 0.2px;
}
.agent-item-del,
.agent-item-edit,
.agent-item-share,
.agent-item-adopt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s, background 0.12s;
}
.agent-item:hover .agent-item-del,
.agent-item:hover .agent-item-edit,
.agent-item:hover .agent-item-share,
.agent-item:hover .agent-item-adopt {
    opacity: 1;
}
.agent-item-del:hover {
    color: #ff6b6b;
    background: color-mix(in srgb, #ff6b6b 16%, transparent);
}
.agent-item-edit:hover,
.agent-item-share:hover,
.agent-item-adopt:hover {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 18%, transparent);
}
.agent-item-del .material-symbols-outlined,
.agent-item-edit .material-symbols-outlined,
.agent-item-share .material-symbols-outlined,
.agent-item-adopt .material-symbols-outlined {
    font-size: 16px;
}

/* Benutzerbereich ans Sidebar-Ende setzen.
   46 px Abstand der User-Box zur unteren Viewport-Kante. */
.sidebar-footer {
    margin-top: auto;
    padding: 14px 20px 46px;
}

/* User-Chip-Box auf exakt gleiche Höhe wie die Composer-Eingabeleiste bringen.
   Composer-Form: Buttons 40px + 2×6px Padding + 2×1px Border = 54px Außenhöhe.
   → identische min-height inkl. Border, damit beide Boxen auf gleicher Linie sitzen.
   Hintergrund bewusst sehr leicht (halbtransparent über der Sidebar) statt schwerem Grau. */
.sidebar-footer .user-chip {
    min-height: 54px;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid var(--user-chip-border);
    background: var(--user-chip-bg);
    border-radius: var(--radius);
    box-shadow: none;
}
.sidebar-footer .user-chip:hover {
    border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}


.empty-hint {
    color: var(--muted);
    font-size: 13px;
    padding: 12px 8px;
}

.conv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text);
    transition: background 0.12s;
    margin-bottom: 2px;
}

.conv-item:hover {
    background: var(--surface-2);
}

.conv-item.active {
    background: var(--surface-2);
    box-shadow: inset 3px 0 0 var(--accent);
}

.conv-title {
    flex: 1;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-del {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    opacity: 0;
    font-size: 14px;
    transition: opacity 0.12s, color 0.12s;
}

.conv-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.conv-del,
.conv-rename,
.conv-move {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    opacity: 0;
    font-size: 13px;
    padding: 2px 4px;
    border-radius: 5px;
    transition: opacity 0.12s, color 0.12s, background 0.12s;
}

.conv-item:hover .conv-del,
.conv-item:hover .conv-rename,
.conv-item:hover .conv-move {
    opacity: 1;
}
.conv-del:hover {
    color: #ff6b6b;
}
.conv-rename:hover,
.conv-move:hover {
    color: var(--accent);
    background: var(--surface);
}

.conv-item.dragging {
    opacity: 0.5;
}

/* ---------- Ordner ---------- */
.folder-group {
    margin-bottom: 4px;
}

.folder-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text);
    transition: background 0.12s, box-shadow 0.12s;
}
.folder-header:hover {
    background: var(--surface-2);
}
.folder-header:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}
.folder-header.drop-target {
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.folder-caret {
    font-size: 11px;
    color: var(--muted);
    width: 12px;
    flex-shrink: 0;
}

.folder-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-count {
    font-size: 11px;
    color: var(--muted);
    background: var(--surface-2);
    border-radius: 10px;
    padding: 1px 7px;
    flex-shrink: 0;
}

.folder-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.folder-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    opacity: 0;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 5px;
    transition: opacity 0.12s, color 0.12s, background 0.12s;
}
.folder-header:hover .folder-btn {
    opacity: 1;
}
.folder-btn:hover {
    color: var(--accent);
    background: var(--surface);
}

.folder-body {
    margin: 2px 0 4px 14px;
    padding-left: 8px;
    border-left: 1px solid var(--border);
}

.folder-empty {
    font-size: 12px;
    color: var(--muted);
    padding: 8px 12px;
    font-style: italic;
}

.root-zone {
    border-radius: var(--radius);
    transition: box-shadow 0.12s, background 0.12s;
    padding-bottom: 2px;
}
.root-zone.drop-target {
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.root-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    padding: 10px 12px 4px;
    font-weight: 600;
}

/* ---------- Verschieben-Menü ---------- */
.move-menu {
    position: fixed;
    z-index: 120;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 6px;
    min-width: 180px;
    max-height: 320px;
    overflow-y: auto;
}

.move-option {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.12s;
}
.move-option:hover {
    background: var(--surface-2);
}
.move-option.current {
    color: var(--accent);
    font-weight: 600;
}


.user-menu-shell {
    position: relative;
}

.user-chip {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: none;
    outline: none;
    appearance: none;
    border-radius: calc(var(--radius) + 4px);
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.12s ease;
    text-align: left;
    color: var(--text);
}

.user-chip:hover {
    background: var(--user-chip-hover-bg);
}

.user-chip.open {
    background: var(--user-chip-open-bg);
    box-shadow: none;
}

.user-chip:focus-visible,
.user-menu-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--avatar-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    box-shadow: var(--avatar-inset);
}

.user-meta {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    line-height: 1.25;
    text-align: left;
}
.user-name,
.user-role {
    display: block;
    width: 100%;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-name {
    font-size: 14px;
    font-weight: 600;
}
.user-role {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

.user-menu-caret {
    margin-left: auto;
    color: var(--muted);
    transition: transform 0.18s ease, color 0.18s ease;
}

.user-chip.open .user-menu-caret {
    transform: rotate(180deg);
    color: var(--text);
}

.user-menu {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 10px);
    z-index: 60;
}

.user-menu-panel {
    border: 1px solid var(--menu-panel-border);
    border-radius: 12px;
    background: var(--menu-panel-bg);
    backdrop-filter: blur(14px);
    box-shadow: var(--menu-panel-shadow);
    overflow: hidden;
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
}

.user-menu-avatar {
    width: 44px;
    height: 44px;
}

.user-menu-meta {
    gap: 2px;
}

.user-menu-divider {
    height: 1px;
    background: var(--menu-divider);
}

.user-menu-actions {
    padding: 8px;
}

.menu-control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 4px 12px;
}

.menu-control-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.language-switch,
.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    max-width: 100%;
    padding: 4px;
    border: 1px solid var(--menu-control-border);
    border-radius: 999px;
    background: var(--menu-control-bg);
}

.language-option,
.theme-option {
    min-width: 42px;
    padding: 8px 14px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.theme-option .material-symbols-outlined {
    font-size: 16px;
}

.language-option:hover,
.theme-option:hover {
    color: var(--text);
    background: var(--menu-option-hover);
}

.language-option.active,
.theme-option.active {
    color: var(--menu-option-active-text);
    background: var(--primary);
    box-shadow: var(--menu-option-active-shadow);
}

.language-option:focus-visible,
.theme-option:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.user-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
}

.user-menu-item:hover {
    background: rgba(59, 130, 246, 0.12);
}

.user-menu-item .material-symbols-outlined {
    font-size: 19px;
    color: var(--muted);
}

.user-menu-item.logout {
    color: #fca5a5;
}

.user-menu-item.logout .material-symbols-outlined {
    color: #fca5a5;
}

.user-menu-item.logout:hover {
    background: rgba(239, 68, 68, 0.12);
}

/* ---------- Rechte Chat-Kontextspalte ---------- */
.chat-context {
    position: relative;
    width: var(--chat-context-width, 320px);
    min-width: var(--chat-context-width, 320px);
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
    z-index: 20;
}

.chat-context[hidden] {
    display: none;
}

.chat-context-resizer {
    position: absolute;
    z-index: 2;
    top: 0;
    left: -4px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    touch-action: none;
}

.chat-context-resizer::after {
    content: "";
    position: absolute;
    top: 0;
    left: 3px;
    width: 2px;
    height: 100%;
    background: transparent;
    transition: background 0.15s ease;
}

.chat-context-resizer:hover::after,
.chat-context-resizer.resizing::after {
    background: var(--primary);
}

body.chat-context-resizing {
    cursor: col-resize;
    user-select: none;
}

.chat-context-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 67px;
    padding: 14px 16px;
    border-bottom: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
}

.chat-context-heading {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
}

.chat-context-heading > .material-symbols-outlined {
    flex: 0 0 auto;
    color: var(--primary);
    font-size: 20px;
}

.chat-context-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--heading-font);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text);
}

.chat-context-close {
    flex: 0 0 auto;
}

.chat-context .sidebar-actions {
    margin: 14px 16px;
}

.chat-context-scroll {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
}

.chat-context .conversations {
    min-height: 100%;
}

.chat-context-footer {
    flex: 0 0 auto;
    padding: 0 16px 46px;
    background: color-mix(in srgb, var(--surface) 92%, var(--bg) 8%);
}

/* ---------- Main ---------- */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    background: var(--bg);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--topbar-bg);
    box-shadow: var(--topbar-shadow);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
    /* Der Header ist ein eigener Flex-Sibling des Scrollbereichs. Nicht sticky,
       damit er beim Laden einer Unterhaltung keine erste Nachricht überdeckt. */
    position: relative;
    z-index: 10;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
}
.icon-btn:hover {
    background: var(--surface-2);
}

.menu-btn {
    display: none;
}
.close-sidebar {
    display: none;
}

/* ---------- Chat area ---------- */
.chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.sage-view {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    background: var(--bg);
}

.sage-workspace-host {
    display: block;
    min-height: 100%;
}

/* Drag & Drop Overlay */
.drop-overlay {
    position: absolute;
    inset: 12px;
    z-index: 40;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: 2px dashed var(--primary);
    background: var(--surface);
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: blur(2px);
    pointer-events: none;
}

.chat-view.drag-over .drop-overlay {
    display: flex;
}

.drop-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--primary);
    font-weight: 600;
    pointer-events: none;
}

.drop-overlay-ico {
    font-size: 52px;
}

.drop-overlay-text {
    font-size: 15px;
    color: var(--text);
}

.chat-area {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px 0;
    position: relative;
}

/* Die Antwortbreite wird dezent über das Icon unter fertigen Assistentenantworten angepasst. */
body.answer-width-resizing {
    cursor: col-resize;
    user-select: none;
}

.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    padding: 20px;
    gap: 8px;
}

.welcome-logo {
    font-size: 56px;
    margin-bottom: 8px;
}

.welcome-brand-logo {
    display: block;
    width: min(220px, 74vw);
    height: auto;
    margin: 0 auto 14px;
}

.welcome h2 {
    font-size: 26px;
    font-weight: 700;
}
.welcome p {
    color: var(--muted);
    margin-bottom: 18px;
}

.suggestions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    max-width: 620px;
    width: 100%;
}

.suggestion {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    font-family: var(--font);
    transition: border-color 0.15s, transform 0.05s;
}
.suggestion:hover {
    border-color: var(--primary);
}
.suggestion:active {
    transform: scale(0.99);
}

.messages {
    width: min(100%, var(--answer-width, 820px));
    max-width: 100%;
    min-width: 0;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.msg {
    display: flex;
    min-width: 0;
    max-width: 100%;
    gap: 14px;
    align-items: flex-start;
}

.msg-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    max-width: 100%;
}

.msg-actions {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 0 2px;
    opacity: 0;
    transition: opacity 0.15s;
}

.msg:hover .msg-actions,
.msg-actions:focus-within {
    opacity: 1;
}

.msg-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.msg-action-btn .material-symbols-outlined {
    font-size: 18px;
}

.msg-action-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}

.msg-action-btn.copied {
    color: var(--accent);
}

.answer-width-action {
    cursor: col-resize;
    touch-action: none;
}

.answer-width-action.resizing {
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    color: var(--primary);
}

.msg-avatar {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.msg-user .msg-avatar {
    background: var(--surface-2);
    color: var(--accent);
}
.msg-assistant .msg-avatar {
    background: linear-gradient(135deg, #643FBF, #C05BDB);
    color: #fff;
}

.msg-bubble {
    width: 100%;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    line-height: 1.6;
    font-size: 15px;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.msg-user .msg-bubble {
    background: var(--surface-2);
}

.msg-bubble code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: "SFMono-Regular", Consolas, monospace;
}

.msg-bubble .msg-link {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 2px;
    font-weight: 500;
    word-break: break-word;
}

.msg-bubble .msg-link:hover,
.msg-bubble .msg-link:focus-visible {
    color: color-mix(in srgb, var(--accent) 82%, white 18%);
    text-decoration-thickness: 2px;
}

.msg-bubble .msg-link:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--accent) 70%, white 30%);
    outline-offset: 2px;
    border-radius: 4px;
}

.msg-bubble pre {
    background: var(--code-bg);
    color: var(--code-text);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 8px 0;
}
.msg-bubble pre code {
    background: none;
    padding: 0;
}

/* Markdown-Tabellen + Excel-Export */
.md-table-wrap {
    margin: 10px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}
.md-table-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--primary) 6%, transparent);
}
.md-table-export {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    padding: 6px 12px;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: opacity 0.15s ease, filter 0.15s ease;
}
.md-table-export:hover {
    filter: brightness(1.06);
}
.md-table-export:disabled {
    opacity: 0.6;
    cursor: default;
}
.md-table-export .material-symbols-outlined {
    font-size: 18px;
}
.md-table-scroll {
    overflow-x: auto;
}
.md-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13.5px;
}
.md-table th,
.md-table td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
}
.md-table th {
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    font-weight: 600;
    color: var(--text);
}
.md-table tbody tr:nth-child(even),
.md-table tbody tr:nth-child(even) {
    background: color-mix(in srgb, var(--text) 3%, transparent);
}

/* Tabellenanalyse: clientseitige Charts und KPIs */
.md-table-toolbar {
    gap: 8px;
}
.md-table-analysis-toggle,
.md-table-analysis-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease, filter 0.15s ease;
}
.md-table-analysis-toggle {
    font-size: 12.5px;
    line-height: 1;
    padding: 6px 12px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--bg);
}
.md-table-analysis-toggle:hover,
.md-table-analysis-close:hover {
    filter: brightness(1.06);
}
.md-table-analysis-toggle .material-symbols-outlined,
.md-table-analysis-close .material-symbols-outlined {
    font-size: 18px;
}
.md-table-analysis {
    padding: 14px;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--primary) 5%, transparent);
}
.md-table-analysis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    color: var(--text);
}
.md-table-analysis-header > div {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.md-table-analysis-header .material-symbols-outlined {
    color: var(--accent);
}
.md-table-analysis-close {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}
.md-table-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.md-table-kpi {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.md-table-kpi span,
.md-table-kpi small {
    color: var(--muted);
    font-size: 11px;
}
.md-table-kpi strong {
    color: var(--text);
    font-size: 15px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.md-table-kpi small {
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.md-table-chart {
    width: 100%;
    padding: 12px 0 0;
    border-top: 1px solid var(--border);
    overflow-x: auto;
}
.md-table-chart canvas {
    display: block;
    width: 100%;
    min-width: 320px;
    max-width: none;
}
@media (max-width: 640px) {
    .md-table-toolbar {
        flex-wrap: wrap;
    }
    .md-table-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* typing indicator */
.typing {
    display: flex;
    gap: 5px;
    align-items: center;
    min-height: 12px;
}
.typing span {
    width: 8px;
    height: 8px;
    background: var(--text);
    border-radius: 50%;
    opacity: 0.7;
    animation: typing-wave 1.3s ease-in-out infinite;
}
.typing span:nth-child(2) {
    animation-delay: 0.18s;
}
.typing span:nth-child(3) {
    animation-delay: 0.36s;
}
@keyframes typing-wave {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.45;
    }
    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* streaming indicator: animated three-dot wave in the current text color */
.stream-cursor {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    margin-left: 4px;
    vertical-align: middle;
    min-height: 8px;
}
.stream-cursor span {
    width: 7px;
    height: 7px;
    background: var(--text);
    border-radius: 50%;
    opacity: 0.7;
    animation: typing-wave 1.3s ease-in-out infinite;
}
.stream-cursor span:nth-child(2) {
    animation-delay: 0.18s;
}
.stream-cursor span:nth-child(3) {
    animation-delay: 0.36s;
}
.stream-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.92em;
}
.stream-status-icon {
    font-size: 18px;
    color: var(--primary);
    animation: stream-status-pulse 1.25s ease-in-out infinite;
}
@keyframes stream-status-pulse {
    0%, 100% { opacity: 0.55; transform: scale(0.92); }
    50% { opacity: 1; transform: scale(1); }
}

/* ---------- Composer ---------- */
.composer {
    padding: 14px 20px 18px;
    background: var(--bg);
}

.composer-options {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
    min-height: 30px;
    margin-bottom: 6px;
}

.context-switch {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 30px;
    padding: 3px 7px 3px 5px;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.context-switch:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.context-switch:has(input:disabled) {
    cursor: default;
    opacity: 0.82;
}

.context-switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.context-switch-track {
    position: relative;
    display: inline-flex;
    width: 36px;
    height: 20px;
    flex: 0 0 auto;
    border: 1px solid color-mix(in srgb, var(--muted) 48%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted) 18%, transparent);
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.context-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.18s ease, background 0.18s ease;
}

.context-switch input:checked + .context-switch-track {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 48%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
}

.context-switch input:checked + .context-switch-track .context-switch-thumb {
    transform: translateX(16px);
    background: var(--accent);
}

.context-switch input:focus-visible + .context-switch-track {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.context-switch-copy {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    line-height: 1.2;
}

.context-switch-label {
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
}

.context-switch-status {
    color: var(--muted);
    font-size: 11px;
}

.context-switch input:checked ~ .context-switch-copy .context-switch-status {
    color: color-mix(in srgb, var(--accent) 82%, var(--text) 18%);
}

.composer-form {
    max-width: 100%;
    margin: 0;
    display: flex;
    /* Buttons unten bündig — sieht bei ein- wie mehrzeiligen Prompts sauber aus */
    align-items: flex-end;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 8px 6px 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow);
}

/* Datei-Upload-Button — nahtlos in die Eingabeleiste integriert */
.doc-file-input {
    display: none;
}
.attach-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease, transform 0.05s, box-shadow 0.15s ease;
}
.attach-btn .material-symbols-outlined {
    font-size: 22px;
    transition: color 0.15s ease, font-variation-settings 0.15s ease;
}
.doc-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.doc-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 10px;
    font-size: 11.5px;
    line-height: 1.3;
    color: var(--muted);
    background: color-mix(in srgb, var(--surface) 60%, transparent);
    border: 1px solid color-mix(in srgb, var(--muted) 22%, transparent);
    border-radius: 999px;
}
.doc-chip-ico {
    font-size: 15px;
    flex: 0 0 auto;
    color: var(--muted);
}
.doc-chip-name {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    color: var(--text);
}
.doc-chip-size {
    flex: 0 0 auto;
    font-size: 10.5px;
    color: var(--muted);
    opacity: 0.85;
}
.doc-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    line-height: 1;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 6px;
    flex: 0 0 auto;
    transition: background 0.15s ease, color 0.15s ease;
}
.doc-chip-remove:hover {
    background: color-mix(in srgb, var(--primary) 16%, transparent);
    color: var(--text);
}

.doc-chip.library-context {
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
    background: color-mix(in srgb, var(--primary) 9%, var(--surface-2));
}

.doc-chip-library {
    color: var(--primary);
    font-size: 15px;
}
.doc-chip-remove .material-symbols-outlined {
    font-size: 13px;
}
.attach-btn:hover {
    background: color-mix(in srgb, var(--primary) 16%, transparent);
    color: var(--text);
}
.attach-btn:active {
    transform: scale(0.92);
}
.attach-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.web-search-btn {
    margin-left: -6px;
}
.web-search-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 32%, transparent);
}
.web-search-btn.active .material-symbols-outlined {
    color: #ffffff;
    font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
}
.web-search-btn.active:hover {
    background: color-mix(in srgb, var(--primary) 88%, white 12%);
    color: #ffffff;
}
.agent-btn {
    margin-left: -6px;
}
.agent-btn:hover {
    background: color-mix(in srgb, var(--accent) 20%, transparent);
    color: var(--text);
}
.agent-btn:hover .material-symbols-outlined {
    color: color-mix(in srgb, var(--accent) 75%, var(--text) 25%);
}
.agent-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
/* Aktiver Zustand: ein Prompt-Agent ist im Chat ausgewählt — analog zur Sidebar (Akzentfarbe). */
.agent-btn.active {
    position: relative;
    background: color-mix(in srgb, var(--accent) 22%, transparent);
    box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 26%, transparent);
}
.agent-btn.active .material-symbols-outlined {
    /* Identische Icon-Stärke wie in der Sidebar-Karte: mittleres Grün, gefüllt. */
    color: #86a305;
    opacity: 1;
    font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
}
.agent-btn.active:hover {
    background: color-mix(in srgb, var(--accent) 32%, transparent);
}
.agent-btn.active:hover .material-symbols-outlined {
    color: #7e9605;
}
/* Kleiner Statuspunkt als zusätzlicher Aktiv-Indikator. */
.agent-btn.active::after {
    content: "";
    position: absolute;
    top: 5px;
    right: 5px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--surface);
}
.composer-form:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 42%, transparent), var(--shadow);
}

.chat-input {
    flex: 1;
    margin-left: 5px;
    resize: none;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    /* bis zu ~10 Zeilen, danach scrollt das Feld intern */
    max-height: 256px;
    padding: 8px 0;
    overflow-y: hidden;
}
.chat-input::placeholder {
    color: var(--muted);
}

.send-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius);
    background: var(--send-btn-bg);
    color: var(--send-btn-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 28%, transparent);
    transition: transform 0.05s, background 0.15s ease, opacity 0.15s, box-shadow 0.15s;
}
.send-btn:hover {
    background: var(--send-btn-hover-bg);
}
.send-btn:active {
    transform: scale(0.95);
}
.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.disclaimer {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin-top: 10px;
}

/* ---------- Global document library ---------- */
.documents-view {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--primary) 10%, transparent), transparent 26%),
        var(--bg);
    color: var(--text);
}

.documents-shell {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 30px 24px;
}

.documents-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.documents-heading h2 {
    margin: 3px 0 6px;
    color: var(--text);
    font-family: var(--heading-font);
    font-size: clamp(24px, 3vw, 32px);
    line-height: 1.2;
}

.documents-heading p:not(.documents-eyebrow) {
    max-width: 650px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.documents-eyebrow {
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.documents-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
}

.library-btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.library-btn .material-symbols-outlined {
    font-size: 18px;
}

.library-btn.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 24%, transparent);
}

.library-btn.primary:hover {
    background: color-mix(in srgb, var(--primary) 88%, white 12%);
}

.library-btn.secondary {
    background: var(--surface);
    color: var(--text);
}

.library-btn.secondary:hover {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--surface) 86%, var(--primary) 14%);
}

.library-btn.danger {
    border-color: color-mix(in srgb, #ef4444 48%, transparent);
    background: #b91c1c;
    color: #fff;
}

.library-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.library-btn:focus-visible,
.library-action:focus-visible,
.library-breadcrumb:focus-visible,
.library-alert-close:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.library-breadcrumbs {
    min-height: 42px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.library-breadcrumb {
    max-width: 260px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-family: var(--font);
    font-size: 12px;
    cursor: pointer;
}

.library-breadcrumb:hover {
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--text);
}

.library-breadcrumb.current {
    color: var(--text);
    font-weight: 600;
    cursor: default;
}

.library-breadcrumb-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-breadcrumb-separator {
    color: var(--muted);
    opacity: 0.65;
    font-size: 16px;
}

.library-alert {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 12px 0;
    padding: 9px 10px 9px 12px;
    border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--border));
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--primary) 9%, var(--surface) 91%);
    color: var(--text);
    font-size: 12px;
}

.library-alert[hidden] {
    display: none !important;
}

.library-alert.error {
    border-color: color-mix(in srgb, #ef4444 46%, var(--border));
    background: color-mix(in srgb, #ef4444 9%, var(--surface) 91%);
}

.library-alert.success {
    border-color: color-mix(in srgb, #10b981 42%, var(--border));
    background: color-mix(in srgb, #10b981 8%, var(--surface) 92%);
}

.library-alert-icon {
    flex: 0 0 auto;
    color: var(--primary);
    font-size: 19px;
}

.library-alert.error .library-alert-icon {
    color: #f87171;
}

.library-alert.success .library-alert-icon {
    color: #34d399;
}

.library-alert #libraryAlertText {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.library-alert-close {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.library-alert-close:hover {
    background: color-mix(in srgb, var(--text) 8%, transparent);
    color: var(--text);
}

.library-alert-close .material-symbols-outlined {
    font-size: 17px;
}

.library-dropzone {
    position: relative;
    min-height: 300px;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.library-drop-overlay {
    position: absolute;
    inset: 8px;
    z-index: 8;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 9px;
    border: 2px dashed var(--primary);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    color: var(--text);
    pointer-events: none;
}

.library-drop-overlay .material-symbols-outlined {
    color: var(--primary);
    font-size: 40px;
}

.library-drop-overlay strong {
    font-size: 13px;
}

.library-dropzone.drag-over .library-drop-overlay {
    display: flex;
}

.library-selection-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--primary) 32%, var(--border));
    background: color-mix(in srgb, var(--primary) 9%, var(--surface));
}

.library-selection-bar[hidden] {
    display: none;
}

.library-selection-count {
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
}

.library-list-header,
.library-row {
    display: grid;
    grid-template-columns: minmax(220px, 2.2fr) minmax(112px, 0.8fr) minmax(82px, 0.65fr) minmax(80px, 0.55fr) minmax(120px, 0.9fr) minmax(174px, auto);
    align-items: center;
    gap: 12px;
}

.library-list-header {
    min-height: 38px;
    padding: 7px 14px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--text) 3%, transparent);
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.library-list {
    display: flex;
    flex-direction: column;
}

.library-row {
    min-height: 54px;
    padding: 7px 14px;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
    color: var(--text);
    font-size: 12px;
    transition: background 0.12s ease;
}

.library-row:last-child {
    border-bottom: none;
}

.library-row:hover,
.library-row:focus-within {
    background: color-mix(in srgb, var(--primary) 7%, transparent);
}

.library-row.is-selected {
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.library-name-cell {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.library-select {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    accent-color: var(--primary);
    cursor: pointer;
}

.library-select:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.library-item-open {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.library-item-open:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 4px;
}

.library-item-icon {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
}

.library-row.folder .library-item-icon {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: color-mix(in srgb, var(--accent) 78%, var(--text) 22%);
}

.library-item-icon .material-symbols-outlined {
    font-size: 20px;
}

.library-item-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.library-item-name {
    overflow: hidden;
    color: var(--text);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-item-detail {
    overflow: hidden;
    color: var(--muted);
    font-size: 10.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-cell {
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    max-width: 100%;
    padding: 3px 8px;
    border: 1px solid var(--status-badge-border);
    border-radius: 999px;
    background: var(--status-badge-bg);
    color: var(--status-badge-text);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.4;
}

.library-status::before {
    content: "";
    width: 6px;
    height: 6px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: currentColor;
}

.library-status.ready {
    border-color: var(--status-success-border);
    background: var(--status-success-bg);
    color: var(--status-success-text);
}

.library-status.pending,
.library-status.indexing {
    border-color: color-mix(in srgb, #f59e0b 28%, transparent);
    background: color-mix(in srgb, #f59e0b 12%, transparent);
    color: #fbbf24;
}

.library-status.indexing::before {
    animation: library-pulse 1s ease-in-out infinite;
}

.library-status.failed {
    border-color: color-mix(in srgb, #ef4444 28%, transparent);
    background: color-mix(in srgb, #ef4444 12%, transparent);
    color: #f87171;
}

@keyframes library-pulse {
    50% {
        opacity: 0.35;
        transform: scale(0.75);
    }
}

.library-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
}

.library-action {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.library-action:hover {
    border-color: var(--border);
    background: var(--surface-2);
    color: var(--text);
}

.library-action.danger:hover {
    border-color: color-mix(in srgb, #ef4444 32%, transparent);
    background: color-mix(in srgb, #ef4444 10%, transparent);
    color: #f87171;
}

.library-action .material-symbols-outlined {
    font-size: 17px;
}

.library-empty,
.library-loading {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    padding: 36px 20px;
    color: var(--muted);
    text-align: center;
}

.library-empty[hidden],
.library-loading[hidden] {
    display: none !important;
}

.library-empty .material-symbols-outlined {
    margin-bottom: 4px;
    color: var(--primary);
    font-size: 42px;
}

.library-empty h3 {
    color: var(--text);
    font-size: 15px;
}

.library-empty p,
.library-loading {
    font-size: 12px;
}

.library-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid color-mix(in srgb, var(--muted) 32%, transparent);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: library-spin 0.75s linear infinite;
}

@keyframes library-spin {
    to {
        transform: rotate(360deg);
    }
}

.library-footnote {
    margin-top: 12px;
    color: var(--muted);
    font-size: 10.5px;
    line-height: 1.5;
}

.library-dialog {
    width: min(460px, calc(100vw - 28px));
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 2px);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
}

.library-dialog::backdrop {
    background: rgba(3, 8, 15, 0.68);
    backdrop-filter: blur(3px);
}

.library-dialog form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}

.library-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.library-dialog-head h2 {
    font-family: var(--heading-font);
    font-size: 19px;
    line-height: 1.3;
}

.library-dialog-message {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.library-dialog-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
}

.library-dialog [hidden] {
    display: none !important;
}

.library-dialog-input {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    background: var(--bg);
    color: var(--text);
    font: 400 13px/1.35 var(--font);
}

.library-dialog-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 20%, transparent);
}

.library-dialog-error {
    margin-top: -7px;
    color: #f87171;
    font-size: 11px;
}

.library-dialog-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 2px;
}

/* ---------- Dateivorschau ---------- */
.library-preview {
    width: min(1080px, calc(100vw - 32px));
    height: min(860px, calc(100vh - 40px));
    max-width: none;
    max-height: none;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 2px);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.library-preview[open] {
    display: flex;
    flex-direction: column;
}

.library-preview::backdrop {
    background: rgba(3, 8, 15, 0.68);
    backdrop-filter: blur(3px);
}

.library-preview [hidden] {
    display: none !important;
}

.library-preview-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.library-preview-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
}

.library-preview-icon .material-symbols-outlined {
    font-size: 20px;
}

.library-preview-headings {
    flex: 1 1 auto;
    min-width: 0;
}

.library-preview-headings h2 {
    font-family: var(--heading-font);
    font-size: 17px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-preview-meta {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11.5px;
}

.library-preview-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 16px;
    background: var(--bg);
}

.library-preview-note {
    flex: 0 0 auto;
    padding: 9px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.5;
}

.library-preview-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 220px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.library-preview-frame {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 520px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.library-preview-image {
    display: block;
    max-width: 100%;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.library-preview-text {
    margin: 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.library-preview-markdown,
.library-preview-segments {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.library-preview-heading {
    font-family: var(--heading-font);
    font-size: 15px;
    line-height: 1.35;
    color: var(--text);
}

.library-preview-paragraph {
    color: var(--text);
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.library-preview-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 20px;
    color: var(--text);
    font-size: 13px;
    line-height: 1.6;
    list-style: disc;
}

.library-preview-segment {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.library-preview-segment-meta {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.library-preview-tableshell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.library-preview-tablewrap {
    width: 100%;
    max-height: 620px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.library-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.library-preview-table th,
.library-preview-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    color: var(--text);
    text-align: left;
    vertical-align: top;
    white-space: pre-wrap;
    word-break: break-word;
}

.library-preview-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: color-mix(in srgb, var(--primary) 12%, var(--surface));
    font-weight: 700;
}

.library-preview-table tbody tr:nth-child(even) {
    background: color-mix(in srgb, var(--text) 4%, transparent);
}

.library-preview-more {
    align-self: center;
}

@media (max-width: 720px) {
    .library-preview {
        width: 100vw;
        height: 100vh;
        border: none;
        border-radius: 0;
    }

    .library-preview-head {
        flex-wrap: wrap;
    }
}

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

/* ---------- Handbuch & Feedback ---------- */
.info-panel {
    flex: 1;
    overflow-y: auto;
    padding: 28px 28px 32px;
    background: linear-gradient(155deg, color-mix(in srgb, var(--primary) 12%, var(--bg)), var(--bg) 34%, var(--surface));
    color: var(--text);
}

.info-panel[hidden] {
    display: none;
}

.info-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    max-width: 1120px;
    margin: 0 auto 24px;
}

.info-eyebrow {
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.info-panel-header h2 {
    margin-bottom: 8px;
    font-family: var(--heading-font);
    font-size: 32px;
    line-height: 1.18;
    color: var(--text);
}

.info-panel-header p:not(.info-eyebrow) {
    max-width: 700px;
    color: var(--muted);
    line-height: 1.55;
}

.info-close-btn {
    flex: 0 0 auto;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.info-close-btn:hover {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}

.info-content {
    width: min(1120px, 100%);
    margin: 0 auto;
}

.info-card {
    display: flex;
    gap: 16px;
    padding: 18px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.info-card > .material-symbols-outlined {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    color: var(--primary);
}

.info-card h3, .feedback-form h3, .feedback-list-head h3, .feedback-item h3 {
    color: var(--text);
    font-family: var(--heading-font);
}

.info-card p, .feedback-form-heading p, .feedback-list-head p {
    margin-top: 4px;
    color: var(--muted);
    line-height: 1.5;
}

/* Persönliches, berechtigungsgefiltertes Benutzerhandbuch */
.handbook-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 28px;
    margin-bottom: 18px;
    border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--border));
    border-radius: var(--radius);
    background: linear-gradient(130deg, color-mix(in srgb, var(--primary) 18%, var(--surface)), var(--surface));
    box-shadow: var(--shadow);
}

.handbook-hero h3, .handbook-section h3 {
    color: var(--text);
    font-family: var(--heading-font);
}

.handbook-hero h3 {
    max-width: 680px;
    font-size: 24px;
    line-height: 1.25;
}

.handbook-hero p:not(.info-eyebrow) {
    max-width: 720px;
    margin-top: 10px;
    color: var(--muted);
    line-height: 1.6;
}

.handbook-hero-stat {
    display: grid;
    place-items: center;
    min-width: 150px;
    padding: 16px;
    border: 1px solid color-mix(in srgb, var(--accent) 44%, var(--border));
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    text-align: center;
}

.handbook-hero-stat .material-symbols-outlined { color: var(--accent); }
.handbook-hero-stat b { margin-top: 2px; color: var(--text); font-size: 28px; line-height: 1; }
.handbook-hero-stat small { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.3; }

.handbook-jump-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 18px;
}

.handbook-jump-nav a {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.handbook-jump-nav a:hover, .handbook-jump-nav a:focus-visible {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, var(--surface));
    color: var(--primary);
    outline: none;
}

.handbook-sections { display: grid; gap: 18px; }

.handbook-section {
    scroll-margin-top: 18px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.handbook-section-heading { display: flex; align-items: flex-start; gap: 15px; }
.handbook-section-icon {
    display: inline-grid;
    place-items: center;
    width: 45px;
    height: 45px;
    flex: 0 0 auto;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    color: var(--primary);
}
.handbook-kicker { color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.handbook-section h3 { margin-top: 3px; font-size: 21px; line-height: 1.28; }
.handbook-section-heading div > p:last-child { margin-top: 7px; color: var(--muted); line-height: 1.6; }
.handbook-section-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, .9fr); gap: 24px; align-items: start; margin-top: 22px; }
.handbook-steps { display: grid; gap: 13px; padding: 0; margin: 0; list-style: none; }
.handbook-steps li { display: flex; gap: 11px; align-items: flex-start; }
.handbook-steps li > span { display: inline-grid; place-items: center; width: 24px; height: 24px; flex: 0 0 auto; border-radius: 999px; background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); font-size: 12px; font-weight: 800; }
.handbook-steps p { padding-top: 2px; color: var(--text); line-height: 1.55; }
.handbook-tip { display: flex; gap: 9px; align-items: flex-start; margin-top: 20px; padding: 13px 14px; border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.handbook-tip .material-symbols-outlined { color: var(--accent); font-size: 20px; }
.handbook-tip p { color: var(--text); font-size: 13px; line-height: 1.55; }

.handbook-shot { overflow: hidden; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.handbook-shot figcaption { display: flex; align-items: center; gap: 7px; padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 700; }
.handbook-shot figcaption .material-symbols-outlined { color: var(--primary); font-size: 17px; }
.shot-appbar { display: flex; align-items: center; gap: 5px; min-height: 31px; padding: 0 10px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--text) 5%, var(--surface)); color: var(--muted); font-size: 11px; }
.shot-appbar > span { width: 7px; height: 7px; border-radius: 999px; background: var(--border); }
.shot-appbar b { margin-left: 6px; color: var(--text); font-size: 11px; }
.shot-chat, .shot-files, .shot-report, .shot-live, .shot-feedback { padding: 14px; }
.shot-user, .shot-answer { max-width: 88%; padding: 9px 10px; margin-bottom: 10px; border-radius: var(--radius); font-size: 11px; line-height: 1.45; }
.shot-user { margin-left: auto; background: var(--primary); color: var(--surface); }
.shot-answer { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.shot-answer strong { display: block; margin-bottom: 3px; color: var(--primary); }
.shot-input { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: 11px; }
.shot-input .material-symbols-outlined { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 999px; background: var(--primary); color: var(--surface); font-size: 14px; }
.shot-files { display: grid; gap: 8px; }
.shot-files p { display: grid; grid-template-columns: 22px 1fr; column-gap: 8px; align-items: center; padding: 9px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.shot-files p > .material-symbols-outlined { grid-row: span 2; color: var(--primary); font-size: 19px; }
.shot-files b { color: var(--text); font-size: 11px; }
.shot-files small { color: var(--muted); font-size: 10px; }
.shot-files button, .shot-feedback button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 29px; padding: 0 9px; border: 1px solid var(--primary); border-radius: var(--radius); background: var(--primary); color: var(--surface); font: 700 11px var(--font); }
.shot-files button .material-symbols-outlined { font-size: 15px; }
.shot-report-filter { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; padding: 9px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: 10px; }
.shot-report-filter b { color: var(--text); font-size: 11px; }
.shot-report-filter .material-symbols-outlined { grid-row: span 2; color: var(--primary); font-size: 17px; }
.shot-bars { display: flex; align-items: end; gap: 8px; height: 92px; padding: 15px 8px 0; border-bottom: 1px solid var(--border); }
.shot-bars i { display: block; flex: 1; border-radius: var(--radius) var(--radius) 0 0; background: color-mix(in srgb, var(--primary) 70%, var(--accent)); }
.shot-bars i:nth-child(1) { height: 40%; }.shot-bars i:nth-child(2) { height: 65%; }.shot-bars i:nth-child(3) { height: 52%; }.shot-bars i:nth-child(4) { height: 85%; }.shot-bars i:nth-child(5) { height: 72%; }
.shot-report > p { margin-top: 8px; color: var(--muted); font-size: 10px; text-align: center; }
.shot-live > div { display: flex; align-items: center; gap: 7px; padding: 9px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: 11px; }.shot-live > div .material-symbols-outlined { color: var(--primary); font-size: 17px; }.shot-live > p { margin-top: 11px; color: var(--muted); font-size: 11px; }.shot-live p b { color: var(--text); }.shot-live em { float: right; color: var(--accent); font-style: normal; font-weight: 700; }.shot-live-result { display: flex; align-items: center; gap: 7px; padding: 9px; border-radius: var(--radius); background: color-mix(in srgb, var(--primary) 10%, transparent); }.shot-live-result .material-symbols-outlined { color: var(--primary); font-size: 17px; }
.shot-feedback { display: grid; gap: 8px; }.shot-feedback p { display: grid; gap: 3px; padding: 8px 9px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }.shot-feedback p span { color: var(--muted); font-size: 9px; }.shot-feedback p b { color: var(--text); font-size: 11px; }.shot-feedback > div { min-height: 45px; padding: 9px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: 10px; }.shot-feedback button { justify-self: end; }
.shot-welcome { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px; }.shot-welcome > div { display: grid; gap: 3px; min-height: 87px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }.shot-welcome .material-symbols-outlined { color: var(--primary); font-size: 21px; }.shot-welcome b { color: var(--text); font-size: 11px; }.shot-welcome small { color: var(--muted); font-size: 9px; line-height: 1.3; }

.feedback-content { display: grid; gap: 24px; }

.feedback-form, .feedback-item, .feedback-empty, .feedback-loading {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.feedback-form { padding: 22px; }
.feedback-form-heading { display: flex; gap: 14px; margin-bottom: 20px; }
.feedback-form-heading > .material-symbols-outlined { color: var(--accent); font-size: 28px; }
.feedback-form-grid { display: grid; grid-template-columns: minmax(180px, .7fr) minmax(0, 1.3fr); gap: 14px; }
.feedback-field, .feedback-status-control, .feedback-comment-form label { display: grid; gap: 7px; color: var(--text); font-size: 13px; font-weight: 700; }
.feedback-field > span, .feedback-status-control > span, .feedback-comment-form label > span { color: var(--muted); }
.feedback-field input, .feedback-field select, .feedback-field textarea, .feedback-status-control select, .feedback-comment-form textarea {
    width: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); font: inherit; line-height: 1.45;
}
.feedback-field input, .feedback-field select, .feedback-status-control select { min-height: 42px; padding: 0 12px; }
.feedback-field textarea, .feedback-comment-form textarea { min-height: 124px; padding: 11px 12px; resize: vertical; }
.feedback-comment-form textarea { min-height: 84px; }
.feedback-field input:focus, .feedback-field select:focus, .feedback-field textarea:focus, .feedback-status-control select:focus, .feedback-comment-form textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 42%, transparent); outline-offset: 1px; border-color: var(--primary); }
.feedback-form-actions, .feedback-list-head, .feedback-item-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.feedback-form-actions { margin-top: 16px; }
.feedback-form-note { min-height: 20px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.feedback-submit, .feedback-comment-submit { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border: 1px solid var(--primary); border-radius: var(--radius); background: var(--primary); color: var(--surface); font-family: var(--font); font-weight: 700; cursor: pointer; box-shadow: var(--shadow); }
.feedback-submit:hover:not(:disabled), .feedback-comment-submit:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 84%, var(--accent)); }
.feedback-submit:disabled, .feedback-comment-submit:disabled { cursor: wait; opacity: .65; }
.feedback-list-head { align-items: center; }
.feedback-list { display: grid; gap: 14px; }
.feedback-item { padding: 20px; }
.feedback-item-head { align-items: flex-start; }
.feedback-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.feedback-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--text); font-size: 12px; font-weight: 700; }
.feedback-badge.status-erledigt { background: color-mix(in srgb, var(--success) 20%, transparent); }
.feedback-badge.status-abgelehnt, .feedback-badge.category-fehler { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.feedback-meta { margin-top: 5px; color: var(--muted); font-size: 13px; }
.feedback-message { margin-top: 16px; color: var(--text); line-height: 1.6; overflow-wrap: anywhere; }
.feedback-comments { display: grid; gap: 10px; margin-top: 18px; padding: 0; list-style: none; }
.feedback-comment { padding: 13px 14px; border-left: 3px solid var(--primary); border-radius: 0 var(--radius) var(--radius) 0; background: color-mix(in srgb, var(--primary) 8%, transparent); }
.feedback-comment > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--text); font-size: 13px; }
.feedback-comment time { color: var(--muted); font-size: 12px; }
.feedback-comment p { margin-top: 7px; color: var(--text); line-height: 1.5; overflow-wrap: anywhere; }
.feedback-comment-form { display: grid; gap: 12px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.feedback-comment-submit { justify-self: end; min-height: 38px; }
.feedback-empty, .feedback-loading { display: grid; place-items: center; gap: 8px; min-height: 190px; padding: 24px; text-align: center; color: var(--muted); }
.feedback-empty .material-symbols-outlined, .feedback-loading .material-symbols-outlined { color: var(--primary); font-size: 32px; }
.feedback-empty h3 { color: var(--text); font-family: var(--heading-font); }
.feedback-empty p { max-width: 440px; line-height: 1.5; }

@media (max-width: 700px) {
    .info-panel { padding: 20px 16px 24px; }
    .info-panel-header h2 { font-size: 26px; }
    .handbook-hero { align-items: stretch; flex-direction: column; padding: 20px; }
    .handbook-hero-stat { grid-template-columns: auto 1fr; gap: 5px 10px; text-align: left; }
    .handbook-hero-stat .material-symbols-outlined { grid-row: span 2; }
    .handbook-hero-stat b, .handbook-hero-stat small { margin: 0; }
    .handbook-section { padding: 18px; }
    .handbook-section-body { grid-template-columns: 1fr; gap: 18px; }
    .handbook-section h3 { font-size: 19px; }
    .feedback-form-grid { grid-template-columns: 1fr; }
    .feedback-form-actions, .feedback-list-head, .feedback-item-head { align-items: stretch; flex-direction: column; }
    .feedback-submit, .feedback-comment-submit, .feedback-list-head .mini-action { width: 100%; }
    .feedback-status-control { width: 100%; }
}

/* ---------- Admin panel ---------- */
.admin-panel {
    flex: 1;
    overflow-y: auto;
    padding: 28px 28px 32px;
    background: var(--admin-panel-bg);
    color: var(--text);
}

.admin-panel[hidden],
.chat-view[hidden],
.sage-view[hidden],
.documents-view[hidden],
.topbar[hidden] {
    display: none !important;
}

.admin-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.admin-eyebrow {
    font-size: 13px;
    line-height: 1.4;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 8px;
}

.admin-panel-header h2 {
    font-family: var(--heading-font);
    font-size: 32px;
    line-height: 1.2;
    font-weight: 700;
    color: var(--text);
}

.admin-close-btn {
    color: var(--muted);
    border: 1px solid var(--border);
    background: var(--surface);
}

.admin-close-btn:hover {
    background: var(--surface);
    color: var(--text);
    border-color: var(--primary);
}

.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

/* ---- Admin Tabs (Benutzer / Gruppen) ---- */
.admin-tabs {
    display: flex;
    gap: 6px;
    width: 100%;
    margin-bottom: 24px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    box-shadow: var(--shadow);
}

.admin-tab {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.admin-tab .material-symbols-outlined {
    font-size: 20px;
}

.admin-tab:hover {
    color: var(--text);
}

.admin-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 20px rgba(70, 130, 180, 0.28);
}

.admin-tab-panel {
    width: 100%;
}

.admin-tab-panel[hidden] {
    display: none;
}

/* Badge am "Freigaben"-Tab: Anzahl offener Anfragen */
.admin-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    color: #1a2b00;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}
.admin-tab.active .admin-tab-badge {
    background: #fff;
    color: var(--primary);
}
.admin-tab-badge[hidden] {
    display: none;
}

.admin-refresh-btn .material-symbols-outlined {
    font-size: 20px;
}

/* ===== Freigaben-Verwaltung (Admin-Tab "Freigaben") ===== */
.share-admin-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px;
}

.share-admin-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 2px);
    background: var(--bg);
    transition: box-shadow 0.15s, border-color 0.15s, opacity 0.2s, transform 0.2s;
}
.share-admin-row:hover {
    border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}
.share-admin-row.is-deciding {
    opacity: 0.6;
    pointer-events: none;
}
.share-admin-row.is-removed {
    opacity: 0;
    transform: translateX(12px);
}

.share-admin-avatar {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    color: var(--primary);
}
.share-admin-avatar .material-symbols-outlined {
    font-size: 24px;
}

.share-admin-info {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.share-admin-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.share-admin-sub {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.share-admin-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
}
.share-admin-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.share-admin-btn .material-symbols-outlined {
    font-size: 18px;
}
.share-admin-btn:disabled {
    cursor: default;
    opacity: 0.6;
}
.share-admin-approve {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(70, 130, 180, 0.28);
}
.share-admin-approve:hover:not(:disabled) {
    background: color-mix(in srgb, var(--primary) 88%, #000);
}
.share-admin-reject {
    background: transparent;
    color: #c0392b;
    border-color: color-mix(in srgb, #c0392b 45%, var(--border));
}
.share-admin-reject:hover:not(:disabled) {
    background: color-mix(in srgb, #c0392b 10%, transparent);
    border-color: #c0392b;
}

.share-admin-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 48px 20px;
    color: var(--muted);
    text-align: center;
}
.share-admin-empty .material-symbols-outlined {
    font-size: 44px;
    color: color-mix(in srgb, var(--primary) 55%, var(--muted));
}
.share-admin-empty p {
    margin: 0;
    font-size: 15px;
}

.share-admin-skeleton {
    height: 70px;
    border-radius: calc(var(--radius) + 2px);
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--muted) 10%, transparent) 25%,
        color-mix(in srgb, var(--muted) 18%, transparent) 37%,
        color-mix(in srgb, var(--muted) 10%, transparent) 63%);
    background-size: 400% 100%;
    animation: shareAdminShimmer 1.4s ease infinite;
}
@keyframes shareAdminShimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

@media (max-width: 640px) {
    .share-admin-row {
        flex-wrap: wrap;
    }
    .share-admin-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Toolbar im Tab-Header: Überschrift links, Suche + Anlegen rechts */
.admin-card-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-toolbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-search {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.admin-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(70, 130, 180, 0.18);
}

.admin-search .material-symbols-outlined {
    font-size: 20px;
    color: var(--muted);
}

.admin-search-input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    width: 220px;
    max-width: 40vw;
}

.admin-search-input::placeholder {
    color: var(--muted);
}

.admin-empty-hint {
    padding: 18px 20px;
    color: var(--muted);
    font-size: 14px;
}

.admin-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(59, 130, 246, 0.22);
    transition: opacity 0.15s, transform 0.05s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.admin-action-btn:hover {
    opacity: 0.96;
    box-shadow: 0 14px 28px rgba(59, 130, 246, 0.28);
}

.admin-action-btn:active {
    transform: scale(0.98);
}

.admin-action-btn:disabled,
.admin-action-btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.admin-action-btn:disabled:hover,
.admin-action-btn[disabled]:hover {
    opacity: 0.45;
    box-shadow: none;
}

.admin-action-btn .material-symbols-outlined.spin {
    animation: btn-spin 0.8s linear infinite;
}

@keyframes btn-spin {
    to {
        transform: rotate(360deg);
    }
}

.admin-action-btn.secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
    box-shadow: none;
}

.admin-action-btn.secondary:hover {
    background: var(--surface);
    border-color: var(--primary);
}

.admin-action-btn.small {
    min-height: 36px;
    padding: 0 14px;
    font-size: 13px;
}

.admin-section + .admin-section {
    margin-top: 24px;
}

.table-card {
    background: var(--table-card-bg);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-card-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--table-card-header-bg);
}

.table-card-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 960px;
}

.admin-table th,
.admin-table td {
    padding: 14px 20px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text);
}

.admin-table th {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--table-head-bg);
}

.admin-table tbody tr:hover {
    background: var(--table-row-hover);
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--status-badge-bg);
    color: var(--status-badge-text);
    border: 1px solid var(--status-badge-border);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge.success {
    background: var(--status-success-bg);
    color: var(--status-success-text);
    border-color: var(--status-success-border);
}

.status-badge.muted {
    background: var(--status-badge-bg);
    color: var(--status-badge-text);
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.mini-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--mini-action-border);
    border-radius: 999px;
    background: var(--mini-action-bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.mini-action:hover {
    background: var(--table-row-hover);
    border-color: var(--primary);
    color: var(--mini-action-hover-text);
}

.mini-action.danger:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.45);
    color: var(--mini-action-danger-text);
}

.group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    padding: 20px;
}

.group-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--group-card-border);
    border-radius: var(--radius);
    background: var(--group-card-bg);
    box-shadow: var(--group-card-inset);
    color: var(--text);
}

/* Explizite Light-Mode-Regeln für die Gruppen-Karten, damit sie NIE auf
   die dunklen Default-Werte zurückfallen (z. B. wenn zur Laufzeit injizierte
   Dark-Tokens die Variablen-Vererbung überschreiben). Höhere Spezifität +
   !important garantieren Konsistenz mit der User-Tabelle. */
[data-theme="light"] .group-card {
    background: var(--group-card-bg) !important;
    border-color: var(--group-card-border) !important;
    box-shadow: var(--group-card-inset) !important;
    color: var(--text) !important;
}

[data-theme="light"] .group-card .group-card-head h4,
[data-theme="light"] .group-card .member-check {
    color: var(--text) !important;
}

[data-theme="light"] .group-card .group-card-head p,
[data-theme="light"] .group-card .member-check small {
    color: var(--muted) !important;
}

.group-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.group-card-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.group-card-head h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.group-card-head p {
    font-size: 13px;
    color: var(--muted);
}

.member-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.member-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    color: var(--text);
}

.member-check input {
    margin-top: 3px;
    accent-color: var(--primary);
}

.member-check small {
    display: block;
    color: var(--muted);
    margin-top: 2px;
}

.group-card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.group-save-hint {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    margin-right: auto;
    display: inline-flex;
    align-items: center;
}

.group-save-hint.saved {
    color: #4ade80;
}

.group-card.has-changes {
    border-color: var(--accent);
}

/* ---------- Overlay ---------- */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 30;
}
.overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* ---------- Bestätigungs-Dialog ---------- */
.confirm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: confirm-fade 0.12s ease;
}
@keyframes confirm-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.confirm-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    width: 100%;
    max-width: 360px;
}

.confirm-box-wide {
    max-width: 640px;
}

/* ---------- Freigabe-Status-Dialog ---------- */
.share-status-box {
    max-width: 440px;
    padding: 26px 26px 22px;
    animation: share-status-pop 0.16s ease;
}
@keyframes share-status-pop {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.share-status-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.share-status-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.share-status-body {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    margin: 0 0 6px;
}

.share-status-sub {
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
    margin: 0 0 6px;
}

.share-status-actions {
    margin-top: 22px;
    gap: 12px;
}

.share-status-actions button {
    min-width: 120px;
    padding: 11px 18px;
    white-space: nowrap;
}

/* Widerrufen dezenter statt dominant rot: Outline-Stil */
.share-status-actions .confirm-ok.danger,
.share-status-actions .confirm-ok.danger:not(.confirm-ok-blue) {
    background: transparent;
    border-color: color-mix(in srgb, #dc4747 55%, transparent);
    color: #e06a6a;
    box-shadow: none;
}
.share-status-actions .confirm-ok.danger:hover,
.share-status-actions .confirm-ok.danger:not(.confirm-ok-blue):hover {
    background: rgba(220, 71, 71, 0.14);
    border-color: #dc4747;
    color: #f08585;
}
.share-status-actions .confirm-ok.danger:disabled {
    opacity: 0.55;
    cursor: default;
}

.agent-select-box {
    max-width: 420px;
}

.agent-select-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.agent-select-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.agent-select-item:hover {
    border-color: var(--primary);
    background: rgba(70, 130, 180, 0.12);
}

.agent-select-item.active {
    border-color: var(--primary);
    background: rgba(70, 130, 180, 0.18);
}

.agent-select-item .material-symbols-outlined {
    color: var(--primary);
    font-size: 20px;
}

.agent-select-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.agent-select-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.agent-select-desc {
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-select-check {
    color: var(--accent) !important;
    margin-left: auto;
}

.confirm-text {
    font-size: 15px;
    color: var(--text);
    margin-bottom: 16px;
}

.confirm-input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    padding: 10px 12px;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.15s;
}
.confirm-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}

/* ---------- Dialog: Titel & Aktionen ---------- */
.confirm-text {
    font-weight: 500;
    line-height: 1.45;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.confirm-actions button {
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
        box-shadow 0.15s ease, transform 0.06s ease;
    outline: none;
}
.confirm-actions button:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 32%, transparent);
}
.confirm-actions button:active {
    transform: translateY(1px);
}

/* Sekundär / Abbrechen */
.confirm-cancel {
    background: transparent;
    border-color: var(--border);
    color: var(--muted);
}
.confirm-cancel:hover {
    background: color-mix(in srgb, var(--text) 8%, transparent);
    color: var(--text);
}

/* Primär (gefüllt, Volltonfarbe) */
.confirm-ok {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 26%, transparent);
}
.confirm-ok:hover {
    background: color-mix(in srgb, var(--primary) 88%, black 12%);
}

/* Destruktiv (Standard-.confirm-ok ohne -blue = z.B. Löschen) */
.confirm-ok:not(.confirm-ok-blue) {
    background: #dc4747;
    box-shadow: 0 6px 16px rgba(220, 71, 71, 0.28);
}
.confirm-ok:not(.confirm-ok-blue):hover {
    background: #c53c3c;
}

.confirm-ok-blue {
    background: var(--primary);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 26%, transparent);
}
.confirm-ok-blue:hover {
    background: color-mix(in srgb, var(--primary) 88%, black 12%);
}

/* ---------- Dialog: Radio-Auswahlliste ---------- */
.confirm-select-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 22px;
    max-height: 320px;
    overflow-y: auto;
}

.confirm-select-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.confirm-select-row:hover {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.confirm-select-row:has(input:checked) {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 18%, transparent);
}

.confirm-select-row input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    flex: none;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 2px solid var(--muted);
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: border-color 0.15s ease;
}
.confirm-select-row input[type="radio"]:checked {
    border-color: var(--primary);
}
.confirm-select-row input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--primary);
}
.confirm-select-row span {
    flex: 1;
    min-width: 0;
}

/* Durchsuchbares Zeitzonen-Dropdown */
.timezone-field {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}
.timezone-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.timezone-search-icon {
    position: absolute;
    left: 10px;
    color: var(--muted);
    font-size: 20px;
    pointer-events: none;
}
.timezone-toggle-icon {
    position: absolute;
    right: 8px;
    color: var(--muted);
    font-size: 22px;
    pointer-events: none;
    transition: transform 0.15s ease;
}
.timezone-field.is-open .timezone-toggle-icon {
    transform: rotate(180deg);
}
.timezone-field .timezone-search {
    margin-bottom: 0;
    padding-left: 38px;
    padding-right: 36px;
    cursor: pointer;
}
.timezone-field .timezone-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 30;
    margin: 4px 0 0;
    padding: 4px;
    list-style: none;
    max-height: 220px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.timezone-field .timezone-option {
    padding: 8px 12px;
    border-radius: calc(var(--radius) - 4px);
    color: var(--text);
    cursor: pointer;
    font-size: 0.92rem;
}
.timezone-field .timezone-option[hidden] {
    display: none;
}
.timezone-field .timezone-option:hover {
    background: color-mix(in srgb, var(--primary) 18%, transparent);
}
.timezone-field .timezone-option.is-selected {
    background: var(--primary);
    color: #fff;
}
.timezone-field .timezone-empty-hint {
    color: var(--muted);
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-actions button {
    border: none;
    border-radius: var(--radius);
    padding: 10px 16px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s;
}

.confirm-cancel {
    background: var(--surface-2);
    color: var(--text);
}
.confirm-cancel:hover {
    background: #2a3550;
}

.confirm-ok {
    background: #ff5b5b;
    color: #fff;
}
.confirm-ok:hover {
    opacity: 0.9;
}
.confirm-ok.confirm-ok-blue {
    background: var(--primary);
    color: #fff;
}

.dialog-header {
    margin-bottom: 18px;
}

.dialog-header h3 {
    font-family: var(--heading-font);
    font-size: 22px;
    margin-bottom: 6px;
}

.dialog-help {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.user-create-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.user-create-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.agent-create-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.agent-create-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.agent-config-input {
    resize: vertical;
    min-height: 110px;
    line-height: 1.5;
    font-family: inherit;
}

.dialog-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dialog-field > span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.dialog-hint {
    color: var(--muted);
    font-size: 12px;
}

.dialog-status-note {
    border: 1px solid rgba(59, 130, 246, 0.25);
    background: rgba(59, 130, 246, 0.12);
    color: var(--text);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 13px;
}

.dialog-error {
    color: #ff7b7b;
    font-size: 13px;
    min-height: 18px;
}

.user-create-group-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 12px;
}

.user-create-group-option {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text);
}

.user-create-group-option input {
    accent-color: var(--accent);
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar {
    width: 9px;
}
::-webkit-scrollbar-thumb {
    background: var(--surface-2);
    border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
    background: #2a3550;
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
    .welcome {
        justify-content: flex-start;
        min-height: 100%;
        padding-top: 28px;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: min(var(--sidebar-width, 280px), 86vw);
        transform: translateX(-100%);
        box-shadow: var(--shadow);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-resizer,
    .chat-context-resizer {
        display: none;
    }
    .chat-context {
        position: fixed;
        top: 0;
        right: 0;
        width: min(var(--chat-context-width, 320px), 88vw);
        min-width: 0;
        transform: translateX(100%);
        transition: transform 0.25s ease;
    }
    .chat-context.is-open {
        transform: translateX(0);
    }
    .menu-btn {
        display: flex;
    }
    .close-sidebar {
        display: flex;
    }
    .suggestions {
        grid-template-columns: 1fr;
    }
    .admin-panel {
        padding: 20px 16px 24px;
    }
    .admin-panel-header {
        align-items: center;
    }
    .admin-panel-header h2 {
        font-size: 26px;
    }
    .admin-table th,
    .admin-table td {
        padding: 12px 14px;
    }
    .group-grid {
        padding: 16px;
        grid-template-columns: 1fr;
    }
    .user-create-grid,
    .user-create-group-list,
    .agent-create-grid {
        grid-template-columns: 1fr;
    }
}

/* Kein-Zugang-Overlay (eingeloggt, aber nicht freigeschaltet) */
.no-access-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: color-mix(in srgb, var(--bg) 88%, black 12%);
    backdrop-filter: blur(4px);
}

.no-access-card {
    width: 100%;
    max-width: 420px;
    text-align: center;
    padding: 36px 28px;
    background: var(--surface);
    border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text);
}

.no-access-icon {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 8px;
}

.no-access-card h2 {
    margin: 0 0 10px;
    font-family: var(--heading-font, var(--font));
    color: var(--text);
}

.no-access-card p {
    margin: 0 0 22px;
    color: var(--muted);
    line-height: 1.5;
}

.no-access-logout {
    appearance: none;
    border: none;
    cursor: pointer;
    padding: 11px 22px;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-family: var(--font);
    font-weight: 600;
    box-shadow: var(--shadow);
}

.no-access-logout:hover {
    filter: brightness(1.05);
}

@media (max-width: 1180px) {
    .library-list-header,
    .library-row {
        grid-template-columns: minmax(210px, 2fr) minmax(104px, 0.8fr) minmax(76px, 0.55fr) minmax(110px, 0.8fr) minmax(166px, auto);
    }

    .library-list-header > :nth-child(4),
    .library-row > :nth-child(4) {
        display: none;
    }
}

@media (max-width: 920px) {
    .library-list-header,
    .library-row {
        grid-template-columns: minmax(190px, 2fr) minmax(104px, 0.8fr) minmax(100px, 0.75fr) minmax(160px, auto);
    }

    .library-list-header > :nth-child(3),
    .library-row > :nth-child(3) {
        display: none;
    }
}

@media (max-width: 820px) {
    .documents-shell {
        padding: 20px 16px;
    }

    .documents-heading {
        gap: 16px;
    }

    .library-breadcrumbs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .library-breadcrumb {
        flex: 0 0 auto;
    }
}

@media (max-width: 700px) {
    .library-selection-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .library-selection-bar .library-btn {
        width: 100%;
    }

    .documents-heading {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 18px;
    }

    .documents-toolbar {
        justify-content: stretch;
    }

    .documents-toolbar .library-btn {
        flex: 1 1 0;
    }

    .library-list-header {
        display: none;
    }

    .library-dropzone {
        min-height: 280px;
    }

    .library-row {
        position: relative;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 12px;
        min-height: 76px;
        padding: 11px 10px;
    }

    .library-row > :nth-child(2),
    .library-row > :nth-child(3),
    .library-row > :nth-child(4),
    .library-row > :nth-child(5) {
        display: none;
    }

    .library-row.document > .library-mobile-status {
        display: flex;
        grid-column: 1;
        padding-left: 71px;
    }

    .library-name-cell {
        grid-column: 1;
    }

    .library-actions {
        grid-column: 2;
    }

    .library-action {
        width: 32px;
        height: 32px;
    }

    .library-item-icon {
        width: 34px;
        height: 34px;
    }

    .context-switch-copy {
        gap: 4px;
    }

    .context-switch-status {
        display: none;
    }
}

@media (max-width: 440px) {
    .documents-toolbar {
        flex-direction: column;
    }

    .documents-toolbar .library-btn {
        width: 100%;
    }

    .library-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .library-actions {
        grid-column: 1;
        justify-content: flex-start;
        padding-left: 44px;
    }

    .composer {
        padding-inline: 12px;
    }

    .composer-options {
        justify-content: flex-start;
    }
}
