:root {
    --gray-0: oklch(1.0 0 0);
    --gray-25: oklch(0.985 0 0);
    --gray-50: oklch(0.969 0 0);
    --gray-100: oklch(0.939 0 0);
    --gray-200: oklch(0.885 0 0);
    --gray-400: oklch(0.555 0 0);
    --gray-900: oklch(0.27 0 0);

    --brand: oklch(0.559 0.102 221);
    --brand-light: oklch(0.459 0.102 221);
    --brand-destructive: oklch(0.636 0.208 25);

    --success: oklch(0.52 0.17 142);
    --warning: oklch(0.65 0.16 85);
    --error: oklch(0.55 0.22 25);
    --info: oklch(0.55 0.14 240);

    --surface-base: var(--gray-0);
    --surface-elevated: var(--gray-50);
    --sidebar: var(--gray-50);
    --sidebar-border: var(--gray-200);
    --panel-inspector: var(--gray-25);
    --text-primary: var(--gray-900);
    --text-muted: var(--gray-400);
    --border: var(--gray-200);

    --elevate-1: rgba(0,0,0,0.03);
    --elevate-2: rgba(0,0,0,0.08);

    --shadow-toast: 0 4px 16px oklch(0 0 0 / 0.12);
    --modal-backdrop: oklch(0 0 0 / 0.3);
    --scrollbar-thumb: oklch(0.555 0 0 / 0.35);
    --scrollbar-thumb-hover: oklch(0.555 0 0 / 0.5);
    --brand-badge-bg: oklch(0.559 0.102 221 / 0.1);
    --proto-border: oklch(0.885 0 0 / 0.5);
    --article-border: oklch(0.885 0 0 / 0.5);
    --overlay-backdrop: oklch(0 0 0 / 0.55);
    --overlay-header-bg: var(--gray-50);
    --overlay-body-bg: var(--gray-0);
    --overlay-shadow: 0 20px 60px oklch(0 0 0 / 0.25);
    --surface-card: var(--gray-0);

    --radius: 0.5rem;
    --rail-width: 50px;
    --drawer-width: 220px;
    --toolbar-height: 56px;

    --text-xs: 0.625rem;
    --text-sm: 0.75rem;
    --text-md: 0.875rem;
    --text-lg: 1rem;
    --text-xl: 1.125rem;

    --ai-accent: oklch(0.75 0.06 221);
    --ai-accent-bg: oklch(0.97 0.01 221);
    --ai-accent-border: oklch(0.90 0.025 221);
    --ai-icon-color: oklch(0.65 0 0);
}


@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Display:wght@400;500;600;700&display=swap');

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

body {
    font-family: 'Noto Sans Display', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--surface-base);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: var(--text-md);
    -webkit-font-smoothing: antialiased;
}

.root {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    display: flex;
    z-index: 50;
}

.app-rail {
    width: var(--rail-width);
    height: 100%;
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid var(--sidebar-border);
    z-index: 2;
}

.rail-top {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 56px;
    flex-shrink: 0;
}

.rail-logo {
    width: 44px;
    height: 28px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0;
    position: relative;
}

.rail-logo svg { width: 24px; height: 24px; flex-shrink: 0; }

.rail-logo-vc {
    font-size: 7px;
    font-weight: 700;
    color: var(--brand);
    align-self: flex-start;
    margin-top: 2px;
    line-height: 1;
    letter-spacing: 0;
}

.rail-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
}

.rail-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 0 12px;
}

.rail-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    position: relative;
}

.rail-btn:hover {
    background: var(--elevate-1);
    color: var(--text-primary);
}

.rail-btn.active {
    background: var(--gray-100);
    color: var(--brand-light);
}

.rail-btn svg { width: 20px; height: 20px; }

.rail-crawl {
    color: var(--brand);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.rail-crawl:hover {
    background: var(--brand-badge-bg);
    color: var(--brand-light);
}

.rail-crawl.crawling {
    color: var(--warning);
    animation: pulse-crawl 1.5s ease-in-out infinite;
}

.rail-crawl.crawling:hover {
    background: oklch(0.85 0.08 85 / 0.15);
    color: var(--warning);
}

.crawl-status-label {
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
}

@keyframes pulse-crawl {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.app-drawer {
    position: absolute;
    left: var(--rail-width);
    top: 0;
    height: 100%;
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.08);
}

.app-drawer.expanded {
    width: var(--drawer-width);
    border-right: 1px solid var(--sidebar-border);
}

.app-drawer.collapsed {
    width: 0;
    box-shadow: none;
}

.app-drawer.pinned {
    position: relative;
    left: 0;
    box-shadow: none;
}

.drawer-header {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 12px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--sidebar-border);
    white-space: nowrap;
    overflow: hidden;
}

.drawer-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.drawer-logo-svg {
    height: 18px;
    width: auto;
    color: var(--brand);
    flex-shrink: 0;
}

.drawer-logo-vc {
    font-size: 9px;
    font-weight: 700;
    color: var(--brand);
    display: inline-block;
    align-self: flex-start;
    margin-top: 3px;
    letter-spacing: 0;
    line-height: 1;
    white-space: nowrap;
}

.drawer-pin {
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: auto;
    transition: color 0.15s, background 0.15s;
}

.drawer-pin:hover {
    background: var(--elevate-1);
    color: var(--text-primary);
}

.drawer-pin.pinned {
    color: var(--brand-light);
    background: var(--brand-badge-bg);
}

.drawer-pin svg { width: 16px; height: 16px; }

.drawer-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: var(--drawer-width);
}

.drawer-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.drawer-view.hidden { display: none; }

.drawer-section-title {
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 12px 14px 6px;
    flex-shrink: 0;
}

.drawer-search {
    margin: 4px 10px 8px;
    padding: 6px 10px;
    background: var(--gray-100);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.drawer-search:focus {
    border-color: var(--brand);
}

.drawer-search::placeholder {
    color: var(--text-muted);
}

.drawer-sort-select {
    margin: 0 10px 8px;
    padding: 5px 8px;
    background: var(--gray-100);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 11px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    width: calc(100% - 20px);
    transition: border-color 0.15s;
}
.drawer-sort-select:focus {
    border-color: var(--brand);
}

.drawer-list {
    flex: 1;
    overflow-y: auto;
}

.drawer-item {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    gap: 10px;
    cursor: pointer;
    transition: background 0.1s;
    position: relative;
    border-left: 2px solid transparent;
}

.drawer-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 0;
    opacity: 0;
    background: var(--elevate-1);
    transition: opacity 0.1s;
    pointer-events: none;
}

.drawer-item:hover::before { opacity: 1; }

.drawer-item.active {
    border-left-color: var(--brand-light);
    background: var(--elevate-2);
}

.drawer-item-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-xs);
    color: var(--brand-light);
    flex-shrink: 0;
}

.drawer-item-info {
    flex: 1;
    min-width: 0;
}

.drawer-item-title {
    font-size: var(--text-sm);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer-item-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer-item-badge {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--brand-light);
    flex-shrink: 0;
}

.drawer-item-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-success { background: var(--success); }
.dot-error { background: var(--error); }
.dot-warning { background: var(--warning); }

.drawer-detect-form {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drawer-detect-input {
    padding: 7px 10px;
    background: var(--gray-100);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: inherit;
    outline: none;
}

.drawer-detect-input:focus { border-color: var(--brand); }

.drawer-detect-input::placeholder { color: var(--text-muted); }

#detect-result-drawer {
    font-size: var(--text-sm);
    padding: 8px 10px;
    background: var(--gray-100);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    word-break: break-all;
}

#detect-result-drawer.hidden { display: none; }

.sidebar-spacer {
    flex-shrink: 0;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-spacer.drawer-open {
    width: calc(var(--rail-width) + var(--drawer-width));
}

.sidebar-spacer.drawer-closed {
    width: var(--rail-width);
}

.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    min-width: 0;
}

.toolbar {
    height: var(--toolbar-height);
    flex-shrink: 0;
    background: var(--surface-base);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
}

.toolbar-title {
    font-size: var(--text-lg);
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.toolbar-mode-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 2px;
}

.toolbar-mode-badge.hidden { display: none; }

.toolbar-mode-badge.mode-rag {
    background: color-mix(in srgb, var(--brand) 12%, transparent);
    color: var(--brand);
    border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
    font-size: 20px;
}

.toolbar-mode-badge.mode-article {
    background: color-mix(in srgb, var(--brand) 12%, transparent);
    color: var(--brand);
    border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
    font-size: 20px;
}

.toolbar-mode-badge.mode-pdf {
    background: color-mix(in srgb, var(--warning) 12%, transparent);
    color: oklch(0.5 0.14 75);
    border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
}

.toolbar-stats {
    display: flex;
    gap: 16px;
    flex: 1;
    justify-content: center;
}

.toolbar-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--text-sm);
    white-space: nowrap;
}

.toolbar-stat-value {
    font-weight: 700;
    color: var(--brand-light);
}

.toolbar-stat-label {
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.toolbar-stat-update {
    margin-left: auto;
}

.toolbar-stat-update .toolbar-stat-label {
    text-transform: none;
    font-size: var(--text-xs);
}

.toolbar-stat-update .toolbar-stat-value {
    font-weight: 500;
    font-size: var(--text-xs);
}

.toolbar-stat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.toolbar-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn {
    padding: 6px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text-primary);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn:hover { background: var(--gray-100); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
    background: var(--brand);
    color: var(--gray-0);
    border-color: var(--brand);
    font-weight: 600;
}

.btn-primary:hover { background: var(--brand-light); }

.btn-sm {
    padding: 4px 10px;
    font-size: var(--text-xs);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--elevate-1);
    color: var(--text-primary);
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-icon:hover {
    background: var(--elevate-1);
    color: var(--text-primary);
}

.btn-icon.active {
    background: var(--gray-100);
    color: var(--brand-light);
    border-color: var(--border);
}

.btn-icon svg { width: 18px; height: 18px; }

.workspace-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.content-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface-base);
    min-width: 0;
}

.view-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.view-content.hidden { display: none; }

.stage-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.stage-toolbar.stage-toolbar-2row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px 20px;
}
.toolbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.toolbar-row-search {
    width: 100%;
}
.dashboard-search-wrap.dashboard-search-half {
    flex: 1 1 50%;
    min-width: 280px;
    max-width: 50%;
}
.dashboard-search-half input {
    padding: 7px 28px 7px 12px;
    font-size: var(--text-base);
}

.stage-toolbar select {
    padding: 5px 10px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: inherit;
    cursor: pointer;
}

.select-wrap {
    position: relative;
    display: inline-flex;
}

.select-wrap select {
    width: 100%;
}

.toolbar-row-filters > select,
.toolbar-row-filters > .select-wrap {
    flex: 1 1 0;
    min-width: 0;
}

.rag-filters-bar .select-wrap {
    flex: 1 1 auto;
    max-width: 180px;
    min-width: 0;
}

.select-badge {
    display: none;
    position: absolute;
    top: -4px;
    right: -4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand);
    border: 1.5px solid var(--surface-base);
    pointer-events: none;
    z-index: 1;
}

.select-wrap.filter-active .select-badge {
    display: block;
}

.stage-scroll {
    flex: 1;
    overflow-y: auto;
}

.inspector {
    width: 40%;
    min-width: 280px;
    max-width: 60%;
    background: var(--panel-inspector);
    display: flex;
    flex-direction: column;
    height: 100%;
    border-left: 1px solid var(--border);
    position: relative;
    flex-shrink: 0;
}

.inspector.hidden { display: none; }

.inspector-resize {
    position: absolute;
    left: -3px;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 10;
}

.inspector-resize:hover,
.inspector-resize.dragging {
    background: var(--brand);
    opacity: 0.4;
}

.inspector-header {
    height: var(--toolbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 8px;
}

.inspector-title {
    font-size: var(--text-md);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.inspector-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.inspector-nav-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text-primary);
    font-size: var(--text-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.inspector-nav-btn:hover:not(:disabled) {
    border-color: var(--brand);
    color: var(--brand-light);
}

.inspector-nav-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.inspector-nav-counter {
    font-size: var(--text-xs);
    color: var(--text-muted);
    min-width: 48px;
    text-align: center;
}

.inspector-close {
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.inspector-close:hover {
    background: var(--elevate-1);
    color: var(--text-primary);
}

.inspector-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.detail-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.detail-badge {
    font-size: var(--text-xs);
    padding: 2px 10px;
    border-radius: 10px;
    background: var(--brand-badge-bg);
    color: var(--brand-light);
    font-weight: 600;
}

.detail-ext-link {
    color: var(--brand-light);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: color 0.15s;
}

.detail-ext-link:hover { text-decoration: underline; }

.detail-transfer-bar {
    margin-bottom: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.detail-transfer-btn {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 6px 14px;
    font-size: var(--text-sm);
    font-weight: 600;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.detail-transfer-btn:hover {
    background: var(--brand-light);
}

.detail-transfer-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.detail-transfer-btn-chat {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 6px 14px;
    font-size: var(--text-sm);
    font-weight: 600;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    border: 1px solid var(--brand);
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.detail-transfer-btn-chat:hover {
    background: var(--brand-light);
}

.rag-context-panel { margin-bottom: 6px; }
.rag-context-panel.hidden { display: none; }

.rag-ctx-collapsible {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.rag-ctx-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.rag-ctx-toggle:hover {
    background: var(--hover);
}
.rag-ctx-toggle-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--text-muted);
}
.rag-ctx-toggle-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}
.rag-ctx-toggle-chevron {
    width: 14px;
    height: 14px;
    margin-left: auto;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}
.rag-ctx-collapsible.collapsed .rag-ctx-toggle {
    border-bottom: none;
}
.rag-ctx-collapsible.collapsed .rag-ctx-toggle-chevron {
    transform: rotate(-90deg);
}
.rag-ctx-collapsible.collapsed .rag-ctx-collapse-body {
    display: none;
}
.rag-ctx-article-row {
    padding: 0;
}
.rag-ctx-article-row .article-item {
    border-bottom: none;
    border-radius: 0;
    margin: 0;
}
.rag-ctx-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: var(--text-sm);
}

.rag-ctx-article {
    background: color-mix(in srgb, var(--brand) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
}

.rag-ctx-pdf {
    background: color-mix(in srgb, var(--warning) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
}

.rag-ctx-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rag-ctx-card-icon {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.rag-ctx-article .rag-ctx-card-icon { color: var(--brand); }
.rag-ctx-pdf .rag-ctx-card-icon { color: var(--warning); }

.rag-ctx-card-type {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
}

.rag-ctx-card-id {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-family: monospace;
}

.rag-ctx-card-title {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rag-ctx-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: var(--text-xs);
    margin-top: 2px;
}

.rag-ctx-row-wrap {
    flex-wrap: wrap;
    align-items: flex-start;
}

.rag-ctx-label {
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 72px;
}

.rag-ctx-value {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rag-ctx-row-wrap .rag-ctx-value {
    white-space: normal;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.rag-ctx-ai {
    color: var(--violet, oklch(0.5 0.18 300));
    font-weight: 500;
}

.rag-ctx-tag {
    display: inline-block;
    background: color-mix(in srgb, var(--brand) 12%, transparent);
    color: var(--brand);
    border-radius: 3px;
    padding: 0 5px;
    font-size: var(--text-xs);
    line-height: 1.5;
}

.rag-ctx-summary-details {
    margin-top: 4px;
    font-size: var(--text-xs);
}

.rag-ctx-summary-toggle {
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.rag-ctx-summary-toggle::-webkit-details-marker { display: none; }
.rag-ctx-summary-toggle::before {
    content: '▶';
    font-size: 8px;
    transition: transform 0.15s;
}
details[open] .rag-ctx-summary-toggle::before { transform: rotate(90deg); }

.rag-ctx-summary-body {
    margin-top: 4px;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: pre-wrap;
}

.rag-session-mode-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.rag-session-mode-rag { color: var(--brand); }
.rag-session-mode-article { color: var(--brand-light); }
.rag-session-mode-pdf { color: var(--warning); }

.rag-transfer-bar {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border, #e5e7eb);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.rag-undo-btn {
    color: var(--text-muted, #6b7280);
    border: 1px solid var(--border, #e5e7eb);
    background: transparent;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
.rag-undo-btn:hover {
    color: var(--text, #1f2937);
    border-color: var(--text-muted, #9ca3af);
    background: var(--bg-hover, #f3f4f6);
}

.detail-subtitle {
    font-size: var(--text-md);
    color: var(--text-muted);
    margin-bottom: 14px;
    font-style: italic;
}

.detail-meta-collapse {
    margin-bottom: 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
}
.detail-meta-collapse summary {
    padding: 10px 14px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.detail-meta-collapse summary:hover {
    color: var(--text-primary);
}
.detail-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 0 14px 14px;
    background: var(--gray-0);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.detail-meta-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.detail-meta-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.detail-meta-value {
    font-size: var(--text-sm);
    font-weight: 500;
    word-break: break-all;
}

.detail-hash {
    font-family: ui-monospace, 'Courier New', monospace;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.detail-section {
    margin-bottom: 16px;
}

.detail-section h4 {
    font-size: var(--text-xs);
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.4px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.detail-lead {
    font-size: var(--text-md);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 10px 14px;
    background: var(--gray-0);
    border-radius: var(--radius);
    border-left: 3px solid var(--brand);
}

.detail-body-text {
    font-size: var(--text-base);
    color: var(--text-primary);
    line-height: 1.75;
    max-width: 72ch;
}

.detail-body-text p {
    margin-bottom: 1em;
}

.detail-body-text p:last-child {
    margin-bottom: 0;
}

.detail-body-text .body-link {
    color: var(--brand);
    text-decoration: none;
    word-break: break-all;
}

.detail-body-text .body-link:hover {
    text-decoration: underline;
}

.detail-body-text .body-contact {
    white-space: nowrap;
}

.body-boilerplate {
    margin-top: 1em;
    border-top: 1px solid var(--gray-200);
    padding-top: 0.5em;
}

.body-boilerplate summary {
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.body-boilerplate summary:hover {
    color: var(--text-secondary);
}

.body-boilerplate-text {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 0.5em;
}

.detail-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.detail-image-item {
    background: var(--gray-0);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.detail-image-item:hover {
    border-color: var(--brand);
    opacity: 0.85;
    transition: opacity 0.15s, border-color 0.15s;
}

.detail-image-item img {
    width: 100%;
    max-height: 160px;
    object-fit: cover;
    display: block;
}

.detail-image-caption {
    display: block;
    padding: 4px 8px;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.detail-docs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-doc-card {
    display: flex;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    text-decoration: none;
    font-size: var(--text-sm);
    transition: background 0.15s, border-color 0.15s;
    overflow: hidden;
}

.detail-doc-card:hover {
    background: var(--elevate-2);
    border-color: var(--brand);
}

.detail-doc-thumb {
    width: 80px;
    flex-shrink: 0;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.detail-doc-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.detail-doc-body {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.detail-doc-name {
    color: var(--brand-light);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-doc-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.detail-changes {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-change-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--gray-0);
    border-radius: 4px;
    font-size: var(--text-sm);
}

.detail-change-time {
    color: var(--text-muted);
    font-size: var(--text-xs);
    min-width: 120px;
}

.detail-change-type {
    font-weight: 600;
    font-size: var(--text-xs);
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.type-new { background: color-mix(in oklch, var(--success) 15%, transparent); color: var(--success); }
.type-modified { background: color-mix(in oklch, var(--warning) 15%, transparent); color: var(--warning); }
.type-removed { background: color-mix(in oklch, var(--error) 15%, transparent); color: var(--error); }

.detail-change-field { color: var(--text-muted); }

.detail-url {
    color: var(--info);
    text-decoration: none;
    font-size: var(--text-sm);
    word-break: break-all;
}

.detail-url:hover { text-decoration: underline; }

.detail-error {
    text-align: center;
    color: var(--error);
    padding: 40px 16px;
}

.detail-status-active { color: var(--success); }
.detail-status-removed { color: var(--error); }

.article-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--article-border);
    cursor: pointer;
    position: relative;
    transition: background 0.1s;
}

.article-item::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    background: var(--elevate-1);
    pointer-events: none;
    transition: opacity 0.1s;
}

.article-item:hover::before { opacity: 1; }

.article-item.selected {
    background: var(--elevate-2);
    border-left: 2px solid var(--brand-light);
}

.article-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.article-title {
    font-weight: 500;
    font-size: var(--text-md);
    color: var(--text-primary);
    text-decoration: none;
}

.article-badge {
    font-size: var(--text-xs);
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--brand-badge-bg);
    color: var(--brand-light);
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
}

.article-badge-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    flex-shrink: 0;
}

.article-badge-location {
    opacity: 0.7;
}

.font-extrabold {
    font-weight: 800;
}

.article-lead {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-original-title {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-meta {
    font-size: var(--text-xs);
    color: var(--brand-light);
    font-weight: 500;
    margin-top: 4px;
    display: flex;
    gap: 12px;
}

.article-file-badge {
    font-size: 11px;
    color: var(--text-muted);
}

.tag-filter-overlay { z-index: 350; }
.tag-filter-panel {
    width: 720px;
    height: auto;
    max-height: 70vh;
}
.tag-filter-panel .selected-tags-bar {
    border-top: none;
    margin: 0;
}
.tag-filter-panel .overlay-body {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-content: center;
    justify-content: center;
}
.tag-filter-header {
    gap: 12px;
}
.tag-filter-header .overlay-title {
    flex: 0 0 auto;
}
.tag-search-wrap {
    flex: 0 0 40%;
    min-width: 0;
}
.tag-search-wrap input {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-xs);
    outline: none;
    width: 100%;
    box-sizing: border-box;
}
.tag-search-wrap input:focus {
    border-color: var(--brand);
}
.tag-apply-btn {
    width: auto;
    padding: 0 14px;
    font-size: var(--text-xs);
    white-space: nowrap;
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.tag-apply-btn:hover {
    background: var(--brand-light);
    border-color: var(--brand-light);
}
.tag-cloud-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--gray-100);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    line-height: 1.5;
}
.tag-cloud-item:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}
.tag-cloud-item.tag-active {
    background: var(--brand);
    color: #fff;
}
.tag-count {
    font-size: 10px;
    opacity: 0.7;
}

.selected-tags-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--gray-50);
    align-items: center;
}
.selected-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--brand);
    color: #fff;
    font-size: var(--text-xs);
    cursor: pointer;
    transition: background 0.15s;
}
.selected-tag-chip:hover {
    background: var(--brand-light);
}
.selected-tag-clear {
    font-size: var(--text-xs);
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    margin-left: 4px;
}
.selected-tag-clear:hover {
    color: var(--danger, #d32f2f);
    text-decoration: underline;
}
.selected-tags-count {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
}

.toolbar-text-btn {
    background: var(--gray-100);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 18px;
    height: 32px;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    min-width: 80px;
    text-align: center;
}
.toolbar-text-btn:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}
.toolbar-text-btn.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.toolbar-text-btn.active:hover {
    background: var(--brand-light);
    border-color: var(--brand-light);
}
.toolbar-reset-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    flex-shrink: 0;
    padding: 0;
    margin-left: auto;
}
.toolbar-reset-btn:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}
.toolbar-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.toolbar-checkbox input[type="checkbox"] {
    accent-color: var(--brand);
    cursor: pointer;
}

.idrop-native {
    display: none !important;
}

.articles-count-label {
    font-size: var(--text-xs);
    color: #02819e;
    font-weight: 700;
    white-space: nowrap;
    padding: 0 4px;
    border: 1px solid #02819e;
    border-radius: var(--radius);
}

.icon-dropdown {
    position: relative;
    display: inline-flex;
}

.icon-dropdown-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 32px;
    height: 32px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    flex-shrink: 0;
}

.icon-dropdown-btn:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}

.icon-dropdown-btn svg {
    flex-shrink: 0;
    pointer-events: none;
}

.idrop-dot {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brand);
    border: 1.5px solid var(--surface-base);
    display: none;
    pointer-events: none;
}

.idrop-dot.idrop-dot-active {
    display: block;
}

.icon-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 500;
    overflow: hidden;
}

.icon-dropdown-menu.idrop-open {
    display: block;
}

.idrop-item {
    padding: 8px 14px;
    font-size: var(--text-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.1s;
    white-space: nowrap;
}

.idrop-item:hover {
    background: var(--gray-100);
}

.idrop-item.idrop-item-active {
    color: var(--brand);
    font-weight: 500;
    background: color-mix(in srgb, var(--brand) 8%, transparent);
}

.view-toggle-btn {
    background: var(--gray-100);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.view-toggle-btn:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}
.view-btn-active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.view-btn-active:hover {
    background: var(--brand);
    color: #fff;
}

.article-item-card {
    display: flex;
    flex-direction: row;
    gap: 12px;
    min-height: 90px;
    padding: 10px 16px;
    border-bottom: 2px solid var(--border);
}
.article-card-img {
    width: 80px;
    min-height: 70px;
    flex-shrink: 0;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: var(--radius);
    background-color: var(--gray-100);
}
.article-card-img-wappen {
    background-size: contain;
    background-color: transparent;
}
.article-card-media-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-shrink: 0;
    width: 18px;
}

.article-media-cell {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1;
}

.article-media-cell svg {
    opacity: 0.6;
}

.article-media-cell span {
    font-weight: 600;
}

.article-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.article-card-summary {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 4px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-group-header {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 8px 16px;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--gray-100);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}

.article-group-count {
    font-weight: 400;
    padding: 0 6px;
    border-radius: 8px;
    background: var(--gray-200);
    color: var(--text-muted);
    font-size: 10px;
    line-height: 18px;
}

.article-cat-badge {
    display: inline-block;
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 8px;
    background: var(--gray-200);
    color: var(--text-secondary);
    margin-right: 4px;
    font-weight: 500;
}

.article-rel-badge {
    display: inline-block;
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 8px;
    margin-right: 4px;
    font-weight: 600;
}

.article-rel-hoch {
    background: oklch(0.90 0.10 145);
    color: oklch(0.30 0.10 145);
}

.article-rel-mittel {
    background: oklch(0.92 0.08 85);
    color: oklch(0.40 0.10 85);
}

.article-rel-gering {
    background: var(--gray-200);
    color: var(--text-muted);
}

.protocol-summary {
    padding: 14px 20px;
    background: var(--surface-elevated);
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    flex-shrink: 0;
}

.protocol-summary.hidden { display: none; }

.proto-count {
    margin-left: auto;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.proto-stat { text-align: center; }

.proto-stat-value {
    font-size: var(--text-lg);
    font-weight: 700;
}

.proto-stat-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
}

.val-success { color: var(--success); }
.val-error { color: var(--error); }
.val-warning { color: var(--warning); }
.val-info { color: var(--info); }
.val-neutral { color: var(--text-muted); }

.proto-entry {
    padding: 4px 20px;
    border-bottom: 1px solid var(--proto-border);
    display: grid;
    grid-template-columns: 140px 60px 120px 1fr;
    gap: 6px;
    align-items: start;
    line-height: 1.4;
    font-family: ui-monospace, 'Courier New', monospace;
    font-size: var(--text-xs);
    position: relative;
}

.proto-entry::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    background: var(--elevate-1);
    pointer-events: none;
    transition: opacity 0.1s;
}

.proto-entry:hover::before { opacity: 1; }

.proto-entry.level-error { border-left: 3px solid var(--error); }
.proto-entry.level-warning { border-left: 3px solid var(--warning); }
.proto-entry.level-info { border-left: 3px solid transparent; }
.proto-entry.level-debug { border-left: 3px solid transparent; opacity: 0.55; }

.proto-entry.phase-start,
.proto-entry.phase-finish {
    background: color-mix(in oklch, var(--brand) 4%, transparent);
    font-weight: 600;
}

.proto-entry.phase-gemeinde_start {
    background: color-mix(in oklch, var(--info) 4%, transparent);
    border-top: 1px solid var(--border);
    margin-top: 2px;
}

.proto-entry.phase-gemeinde_finish {
    border-bottom: 2px solid var(--border);
    margin-bottom: 2px;
}

.proto-time {
    color: var(--text-muted);
    font-size: var(--text-xs);
}

.proto-level {
    font-weight: 600;
    font-size: var(--text-xs);
    text-transform: uppercase;
}

.proto-level.level-error { color: var(--error); }
.proto-level.level-warning { color: var(--warning); }
.proto-level.level-info { color: var(--info); }
.proto-level.level-debug { color: var(--text-muted); }

.proto-phase {
    color: var(--text-muted);
    font-size: var(--text-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.proto-message {
    color: var(--text-primary);
    word-break: break-word;
}

.proto-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.spinner-center {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

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

#toast-container {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toast {
    padding: 10px 16px;
    border-radius: var(--radius);
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    font-size: var(--text-sm);
    animation: slideIn 0.25s ease;
    box-shadow: var(--shadow-toast);
}

.toast-success { border-color: var(--success); color: var(--success); }
.toast-error { border-color: var(--error); color: var(--error); }
.toast-info { border-color: var(--info); color: var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.modal {
    position: fixed;
    inset: 0;
    background: var(--modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) * 1.5);
    width: 440px;
    max-width: 90vw;
    box-shadow: 0 8px 32px var(--modal-backdrop);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: var(--text-lg); }

.modal-close {
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--elevate-1);
    color: var(--text-primary);
}

.modal-body { padding: 16px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.form-input {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: var(--gray-100);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--brand);
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

.input-group {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.input-full {
    flex: 1;
    padding: 7px 12px;
    background: var(--gray-100);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: var(--text-md);
    font-family: inherit;
    outline: none;
}

.input-full:focus { border-color: var(--brand); }

.detect-result {
    margin-top: 14px;
    padding: 14px;
    background: var(--gray-0);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: var(--text-sm);
}

.detect-result.hidden { display: none; }
.detect-success { border-color: var(--success); }
.detect-fail { border-color: var(--error); }
.tag-success { color: var(--success); }
.tag-error { color: var(--error); }

.kbd {
    font-size: var(--text-xs);
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--gray-100);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: ui-monospace, monospace;
}

::-webkit-scrollbar {
    width: 14px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 9999px;
    border: 4px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    background-clip: content-box;
}

::-webkit-scrollbar-track { background: transparent; }

* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}


.overlay-backdrop {
    position: fixed;
    inset: 0;
    background: var(--overlay-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.overlay-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay-panel {
    background: var(--overlay-body-bg);
    border-radius: 12px;
    width: 90vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--overlay-shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--overlay-header-bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 12px;
    min-height: 48px;
}

.overlay-title {
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.overlay-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    font-size: var(--text-sm);
    text-decoration: none;
    transition: background 0.15s;
}

.overlay-btn:hover {
    background: var(--gray-200);
}

.overlay-btn svg {
    width: 16px;
    height: 16px;
}

.overlay-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
}

.overlay-close:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.overlay-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    min-height: 0;
}

@media (max-width: 640px) {
    .overlay-panel { width: 96vw; height: 96vh; border-radius: 8px; }
    .overlay-header { padding: 8px 12px; }
    .overlay-body { padding: 14px 12px; }
}

.image-overlay { z-index: 300; }

.image-overlay .overlay-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    flex-direction: column;
    padding: 16px;
}

.image-overlay-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    cursor: default;
}

.image-overlay-caption {
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-top: 12px;
    text-align: center;
    max-width: 80%;
}

.pdf-overlay { z-index: 400; }

.pdf-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    justify-content: center;
}

.pdf-tb-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: background 0.15s, color 0.15s;
}

.pdf-tb-btn:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}

.pdf-tb-btn svg {
    width: 18px;
    height: 18px;
}

.pdf-page-info,
.pdf-zoom-info {
    color: var(--text-primary);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    min-width: 48px;
    text-align: center;
    user-select: none;
}

.pdf-tb-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

.pdf-overlay .overlay-body {
    background: var(--gray-100);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    overflow: auto;
}

.pdf-loading {
    color: var(--text-muted);
    font-size: 14px;
    padding: 40px;
    text-align: center;
}

.pdf-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.pdf-search-bar {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.pdf-search-bar.visible {
    display: flex;
}

#pdf-search-input {
    background: var(--gray-0);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 5px 10px;
    border-radius: var(--radius);
    font-size: 13px;
    width: 220px;
    outline: none;
}

#pdf-search-input:focus {
    border-color: var(--brand);
}

.pdf-search-count {
    color: var(--text-muted);
    font-size: 12px;
    min-width: 70px;
    text-align: center;
    user-select: none;
}

.pdf-canvas-wrapper {
    background: white;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    line-height: 0;
    position: relative;
}

.pdf-text-layer {
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    pointer-events: none;
}

.pdf-text-layer span {
    color: transparent;
    white-space: pre;
    line-height: 1;
}

.pdf-search-highlight {
    position: absolute;
    background: oklch(0.85 0.18 90);
    color: transparent;
    border-radius: 2px;
    padding: 2px 1px;
    pointer-events: none;
    z-index: 2;
}

.pdf-search-highlight-active {
    background: oklch(0.7 0.2 30);
    opacity: 0.6;
    outline: 2px solid oklch(0.65 0.2 30);
}

.hidden { display: none !important; }

.detail-images-rich { display: flex; flex-direction: column; gap: 16px; }

.detail-image-rich {
    display: flex;
    gap: 16px;
    background: var(--gray-25);
    border: 1px solid var(--gray-100);
    border-radius: 8px;
    padding: 12px;
    align-items: flex-start;
}

.detail-image-rich .detail-image-preview {
    flex: 0 0 120px;
    max-width: 120px;
    border-radius: 6px;
    overflow: hidden;
}

.detail-image-rich .detail-image-preview img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    transition: transform 0.2s;
}

.detail-image-rich .detail-image-preview img:hover {
    transform: scale(1.03);
}

.detail-image-meta {
    flex: 1;
    min-width: 0;
    font-size: 0.875rem;
    color: var(--gray-900);
}

.img-meta-ai-desc {
    margin-bottom: 10px;
    line-height: 1.5;
    color: var(--gray-900);
}

.img-meta-row {
    display: flex;
    gap: 8px;
    padding: 3px 0;
    border-bottom: 1px solid var(--gray-100);
    align-items: baseline;
    font-size: 0.8125rem;
}

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

.img-meta-label {
    font-weight: 600;
    flex: 0 0 90px;
    color: var(--gray-400);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.03em;
}

.img-meta-tags { display: flex; flex-wrap: wrap; gap: 4px; }

.img-tag {
    background: var(--gray-100);
    border-radius: 4px;
    padding: 1px 7px;
    font-size: 0.75rem;
    color: var(--gray-900);
}

.img-meta-alt {
    margin-bottom: 8px;
    font-style: italic;
    color: var(--gray-400);
}

.img-analyze-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--brand);
    color: var(--gray-0);
    border: none;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.img-analyze-btn:hover { filter: brightness(1.1); }
.img-analyze-btn:disabled { opacity: 0.6; cursor: wait; }

@media (max-width: 640px) {
    .detail-image-rich { flex-direction: column; }
    .detail-image-rich .detail-image-preview { flex: none; max-width: 100%; }
    .detail-doc-rich { flex-direction: column; }
    .detail-doc-rich .detail-doc-preview { flex: none; max-width: 100%; }
}

.detail-docs-rich { display: flex; flex-direction: column; gap: 16px; }

.detail-doc-rich {
    display: flex;
    gap: 16px;
    background: var(--gray-25);
    border: 1px solid var(--gray-100);
    border-radius: 8px;
    padding: 12px;
    align-items: flex-start;
}

.detail-doc-rich .detail-doc-preview {
    flex: 0 0 120px;
    max-width: 120px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: var(--gray-50);
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-doc-rich .detail-doc-preview img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    transition: transform 0.2s;
}

.detail-doc-rich .detail-doc-preview img:hover {
    transform: scale(1.03);
}

.detail-doc-icon {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gray-400);
    padding: 16px;
    text-align: center;
}

.detail-doc-content {
    flex: 1;
    min-width: 0;
    font-size: 0.875rem;
}

.detail-doc-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.detail-doc-title {
    font-weight: 600;
    color: var(--brand);
    text-decoration: none;
    cursor: pointer;
}

.detail-doc-title:hover { text-decoration: underline; }

.detail-doc-info {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.detail-doc-converted-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--warning) 14%, transparent);
    color: oklch(0.5 0.14 75);
    border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
    white-space: nowrap;
    margin-left: 4px;
}

.pdf-meta-summary {
    margin-bottom: 10px;
    line-height: 1.5;
    color: var(--gray-900);
}

.pdf-meta-row {
    display: flex;
    gap: 8px;
    padding: 3px 0;
    border-bottom: 1px solid var(--gray-100);
    align-items: baseline;
    font-size: 0.8125rem;
}

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

.pdf-meta-label {
    font-weight: 600;
    flex: 0 0 100px;
    color: var(--gray-400);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.03em;
}

.pdf-meta-doctype {
    font-weight: 500;
}

.pdf-relevance {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 6px;
}

.pdf-relevance-hoch {
    background: oklch(0.85 0.12 145);
    color: oklch(0.3 0.12 145);
}

.pdf-relevance-mittel {
    background: oklch(0.9 0.08 80);
    color: oklch(0.4 0.08 80);
}

.pdf-relevance-gering {
    background: var(--gray-100);
    color: var(--gray-400);
}

.pdf-meta-tags { display: flex; flex-wrap: wrap; gap: 4px; }

.pdf-tag {
    background: var(--gray-100);
    border-radius: 4px;
    padding: 1px 7px;
    font-size: 0.75rem;
    color: var(--gray-900);
}

.pdf-decisions {
    margin: 0;
    padding-left: 18px;
    font-size: 0.8125rem;
    line-height: 1.6;
}

.pdf-decisions li { color: var(--gray-900); }

.pdf-analyze-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--brand);
    color: var(--gray-0);
    border: none;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 4px;
}

.pdf-analyze-btn:hover { filter: brightness(1.1); }
.pdf-analyze-btn:disabled { opacity: 0.6; cursor: wait; }

.pdf-meta-actions {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.pdf-chat-btn {
    font-size: 0.75rem;
    padding: 4px 10px;
}

.pdf-text-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--gray-100);
    color: var(--brand);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.pdf-text-btn:hover {
    background: var(--brand);
    color: var(--gray-0);
    border-color: var(--brand);
}

.text-overlay { z-index: 500; }

.text-overlay-text {
    font-family: 'Noto Sans Mono', 'Consolas', 'Menlo', monospace;
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    tab-size: 4;
}

.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.3s, transform 0.3s;
    max-width: 400px;
}
.toast.visible { opacity: 1; transform: translateX(0); }

.toast-info { background: #1a2332; }
.toast-success { background: #155724; }
.toast-error { background: #922; }

.toast-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.toast-msg {
    line-height: 1.4;
}

.article-overlay { z-index: 250; }

.article-overlay-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.article-overlay-nav-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.article-overlay-nav-btn:hover:not(:disabled) { background: var(--gray-200); }
.article-overlay-nav-btn:disabled { opacity: 0.3; cursor: default; }
.article-overlay-nav-btn svg { width: 16px; height: 16px; }

.article-overlay-counter {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 50px;
    text-align: center;
}

.ai-alternative-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: var(--ai-accent-bg);
    border-left: 3px solid var(--ai-accent-border);
    border-radius: 0 4px 4px 0;
}

.ai-alt-title-label {
    font-size: 11px;
    font-weight: 600;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.ai-alt-title-text {
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.4;
}

.ai-summary {
    font-size: 14px;
    line-height: 1.5;
    color: #2c3e50;
    margin-bottom: 10px;
    font-style: italic;
}

.ai-classification {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.ai-cat-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: #4a6fa5;
    color: #fff;
}

.ai-relevance {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.ai-relevance-hoch { background: #ffe0e0; color: #a33; }
.ai-relevance-mittel { background: #fff3cd; color: #856404; }
.ai-relevance-gering { background: #d4edda; color: #155724; }

.ai-sentiment {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.ai-sentiment-neutral { background: #e2e8f0; color: #4a5568; }
.ai-sentiment-positiv { background: #d4edda; color: #155724; }
.ai-sentiment-negativ { background: #ffe0e0; color: #a33; }
.ai-sentiment-gemischt { background: #fff3cd; color: #856404; }

.ai-entities {
    margin-top: 8px;
}

.ai-entity-row {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-size: 13px;
    margin-bottom: 4px;
    line-height: 1.5;
}

.ai-entity-label {
    font-weight: 600;
    color: #4a6fa5;
    min-width: 80px;
    flex-shrink: 0;
    font-size: 12px;
}

.ai-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.ai-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    background: #e8eef6;
    color: #4a6fa5;
    font-weight: 500;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.admin-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.admin-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.admin-row-inactive {
    opacity: 0.5;
}

.admin-row-inactive:hover {
    opacity: 0.8;
}

.admin-tabs {
    display: flex;
    gap: 0;
}

.admin-tab {
    padding: 6px 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: background 0.15s, color 0.15s;
}

.admin-tab:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}

.admin-tab:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.admin-tab.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

.admin-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 16px;
}

.admin-fieldset legend {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--brand);
    padding: 0 8px;
}

.admin-crawl-days {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.admin-crawl-day {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
}

.admin-crawl-day:hover {
    background: var(--surface-elevated);
}

.admin-crawl-day input:checked + span {
    color: var(--brand);
    font-weight: 600;
}

.admin-modified-info {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
}

.manual-crawl-box {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    background: var(--surface);
}

.schedule-history-info {
    font-size: 10px;
    line-height: 1.3;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
}

#btn-crawl.crawling {
    background: var(--warning);
    border-color: var(--warning);
    animation: pulse-crawl 1.5s ease-in-out infinite;
}

.schedule-table {
    width: 100%;
    max-width: 600px;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.schedule-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
}

.schedule-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.schedule-table tbody tr:hover {
    background: var(--surface-elevated);
}

.schedule-day {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 100px;
}

.schedule-time-input {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: var(--text-sm);
    width: 100px;
}

.schedule-time-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px oklch(0.559 0.102 221 / 0.2);
}

.agent-prompt-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    margin-bottom: 16px;
    overflow: hidden;
}

.agent-prompt-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--surface-elevated);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.agent-prompt-header h3 {
    margin: 0;
    font-size: var(--text-base);
    flex: 1;
}

.agent-prompt-header .agent-prompt-id {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-family: monospace;
}

.agent-prompt-header .agent-prompt-model {
    font-size: var(--text-xs);
    padding: 2px 8px;
    border-radius: 99px;
    background: var(--brand);
    color: #fff;
}

.agent-prompt-body {
    padding: 18px;
    display: none;
}

.agent-prompt-body.open {
    display: block;
}

.agent-prompt-field {
    margin-bottom: 14px;
}

.agent-prompt-field label {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.agent-prompt-field input,
.agent-prompt-field select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: var(--text-sm);
    box-sizing: border-box;
}

.agent-prompt-field textarea {
    width: 100%;
    min-height: 300px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: var(--text-xs);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
    tab-size: 2;
}

.agent-prompt-field textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(0,150,136,0.15);
}

.agent-prompt-field-row {
    display: flex;
    gap: 14px;
}

.agent-prompt-field-row .agent-prompt-field {
    flex: 1;
}

.agent-prompt-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.agent-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 12px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: border-color 0.15s, color 0.15s;
}

.agent-add-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.cp-group {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    margin-bottom: 16px;
    overflow: hidden;
}
.cp-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.cp-group-header:hover {
    background: var(--surface-hover);
}
.cp-group-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cp-group-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--brand-badge-bg);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cp-group-title {
    margin: 0;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-primary);
}
.cp-group-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
}
.cp-group-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cp-group-count {
    font-size: var(--text-xs);
    color: var(--text-muted);
    padding: 2px 8px;
    background: var(--surface-raised);
    border-radius: 10px;
}
.cp-group-chevron {
    color: var(--text-muted);
    transition: transform 0.2s;
}
.cp-group-chevron.rotated {
    transform: rotate(180deg);
}
.cp-group-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.cp-group-body.open {
    max-height: 5000px;
    padding: 0 16px 16px;
}

.crawler-prompt-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    margin-bottom: 12px;
    overflow: hidden;
    transition: box-shadow 0.15s;
}

.crawler-prompt-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.crawler-prompt-card.crawler-prompt-modified {
    border-left: 3px solid var(--brand);
}

.crawler-prompt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px 4px;
    cursor: pointer;
}

.crawler-prompt-header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.crawler-prompt-header-left h3 {
    margin: 0;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.crawler-prompt-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crawler-prompt-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.crawler-prompt-model-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    background: var(--brand);
    color: #fff;
    white-space: nowrap;
}

.crawler-prompt-modified-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    background: #f59e0b;
    color: #fff;
    white-space: nowrap;
}

.crawler-prompt-chevron {
    transition: transform 0.2s;
    color: var(--text-muted);
}

.crawler-prompt-card.expanded .crawler-prompt-chevron {
    transform: rotate(180deg);
}

.crawler-prompt-preview {
    padding: 4px 18px 12px;
    cursor: pointer;
}

.crawler-prompt-body {
    padding: 0 18px 18px;
    display: none;
    border-top: 1px solid var(--border);
}

.crawler-prompt-body.open {
    display: block;
    padding-top: 14px;
}

.crawler-prompt-field {
    margin-bottom: 14px;
}

.crawler-prompt-field label {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.crawler-prompt-field select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: var(--text-sm);
    box-sizing: border-box;
}

.crawler-prompt-field textarea {
    width: 100%;
    min-height: 350px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: var(--text-xs);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
    tab-size: 2;
}

.crawler-prompt-field textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(0,150,136,0.15);
}

.crawler-prompt-actions {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.admin-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: var(--radius);
    transition: color 0.15s;
}

.admin-toggle-btn.active {
    color: var(--success);
}

.admin-toggle-btn:hover {
    background: var(--surface-elevated);
}

.admin-coat-of-arms {
    height: 20px;
    width: auto;
    display: block;
    object-fit: contain;
}

.admin-url-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-url-cell a {
    color: var(--brand);
    text-decoration: none;
    font-size: var(--text-xs);
}

.admin-url-cell a:hover {
    text-decoration: underline;
}

.admin-actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 2px;
}

.admin-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.admin-action-icon:hover {
    color: var(--brand);
    background: var(--surface-elevated);
}

.admin-action-icon svg {
    width: 16px;
    height: 16px;
}

.admin-action-danger:hover {
    color: var(--error);
}

.admin-form {
    max-width: 700px;
}

.admin-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.admin-form-header h3 {
    margin: 0;
    font-size: var(--text-base);
    font-weight: 600;
}

.admin-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 20px;
    margin-bottom: 20px;
}

.admin-field label {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.admin-field input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-elevated);
    color: var(--text-primary);
    font-size: var(--text-sm);
}

.admin-field input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.admin-field-wide {
    grid-column: 1 / -1;
}

.admin-field-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-field-row input {
    flex: 1;
}

.admin-form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.btn-danger {
    color: var(--error) !important;
    border-color: var(--error) !important;
}

.btn-danger:hover {
    background: var(--error) !important;
    color: white !important;
}

.btn-warning {
    color: oklch(0.7 0.15 70) !important;
    border-color: oklch(0.7 0.15 70) !important;
}

.btn-success {
    color: var(--success) !important;
    border-color: var(--success) !important;
}

.admin-test-result {
    margin-top: 6px;
    font-size: var(--text-xs);
    line-height: 1.5;
}

.admin-test-success {
    color: var(--success);
    font-weight: 500;
}

.admin-test-error {
    color: var(--error);
    font-weight: 500;
}

.admin-test-pending {
    color: var(--text-muted);
    font-style: italic;
}

.admin-test-detail {
    display: block;
    color: var(--text-muted);
    margin-top: 2px;
}

.profile-overlay { z-index: 350; }

.profile-section {
    margin-bottom: 24px;
}

.profile-section:last-child {
    margin-bottom: 0;
}

.profile-section-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--brand);
    margin-bottom: 10px;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--brand);
    display: inline-block;
}

.profile-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 4px 12px;
    font-size: var(--text-sm);
}

.profile-label {
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.profile-value {
    color: var(--text-primary);
    word-break: break-word;
}

.profile-value a {
    color: var(--brand);
    text-decoration: none;
}

.profile-value a:hover {
    text-decoration: underline;
}

.profile-members-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: var(--text-sm);
    margin-top: 6px;
}

.profile-members-table th {
    text-align: left;
    padding: 6px 10px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-members-table td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.profile-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.profile-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.profile-sources {
    margin-top: 6px;
    font-size: var(--text-xs);
}

.profile-sources a {
    color: var(--brand);
    text-decoration: none;
    display: block;
    padding: 2px 0;
}

.profile-sources a:hover {
    text-decoration: underline;
}

.profile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    cursor: pointer;
    color: oklch(0.45 0.1 221);
    opacity: 1;
    transition: opacity 0.15s, color 0.15s;
    vertical-align: middle;
    margin-left: 4px;
    flex-shrink: 0;
}

.profile-icon-inactive {
    color: var(--text-muted);
    opacity: 0.3;
}

.profile-icon-inactive:hover {
    opacity: 0.6;
}

.profile-icon svg {
    width: 14px;
    height: 14px;
}

.profile-generate-info {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.profile-generate-info p {
    margin-bottom: 16px;
    font-size: var(--text-sm);
}

.profile-coat-of-arms {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 4px;
}

.dashboard-search-wrap {
    position: relative;
    flex: 0 1 180px;
    min-width: 120px;
}
.dashboard-search-wrap input {
    width: 100%;
    padding: 5px 26px 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    background: var(--gray-0);
}
.dashboard-search-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.dashboard-search-clear:hover {
    color: var(--text-primary);
}

.search-input-wrap {
    flex: 0 0 50%;
}
.search-input-wrap .input-full {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    background: var(--gray-0);
}
.fts-snippet {
    font-size: var(--text-sm);
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.fts-snippet b {
    color: var(--text-primary);
    font-weight: 700;
}
.fts-snip-label {
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 4px;
    white-space: nowrap;
}
.fts-snip-ai, .fts-snip-img, .fts-snip-pdf {
    display: block;
    padding: 2px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fts-snip-ai { color: var(--text-muted); }
.fts-snip-img .fts-snip-label { color: var(--brand); }
.fts-snip-pdf .fts-snip-label { color: #b45309; }
.fts-snip-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
mark.search-hit {
    background: #fff3b0;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}
.page-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
}
.page-info {
    font-size: var(--text-xs);
    color: var(--text-muted);
    min-width: 48px;
    text-align: center;
    white-space: nowrap;
}
.page-btn {
    padding: 2px 6px;
    min-width: 24px;
    font-size: var(--text-sm);
    line-height: 1;
}
.page-btn:disabled {
    opacity: .35;
    cursor: default;
}
.admin-table-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
    gap: 8px;
}
.admin-th-sort {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.admin-th-sort:hover {
    color: var(--brand);
}

.rag-layout {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.rag-chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.rag-layout:has(.rag-context-pane:not(.hidden)) .rag-chat-container {
    flex: 0 0 60%;
}

.rag-context-pane {
    flex: 0 0 40%;
    min-width: 0;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
}

.rag-context-pane.hidden { display: none; }

.rag-ctx-pane-inner {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.rag-ctx-pane-collapse {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius);
    padding: 0;
    flex-shrink: 0;
}
.rag-ctx-pane-collapse:hover {
    background: var(--hover);
    color: var(--text-primary);
}
.rag-ctx-pane-collapse svg {
    width: 14px;
    height: 14px;
}
.rag-pane-expand-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius);
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.rag-pane-expand-btn:hover {
    background: var(--hover);
    color: var(--brand);
}
.rag-pane-expand-btn svg {
    width: 16px;
    height: 16px;
}
.rag-pane-expand-btn.hidden { display: none; }
.rag-ctx-pane-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-elevated);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
}

.rag-ctx-pane-header svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.rag-ctx-pane-article {
    padding: 16px;
}

.rag-ctx-pane-article .detail-section { margin-bottom: 16px; }
.rag-ctx-pane-article .detail-transfer-btn-chat { display: none; }

.pp-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-elevated);
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: center;
}

.pp-toolbar .pdf-tb-btn {
    width: 26px;
    height: 26px;
}

.pp-toolbar .pdf-tb-btn svg {
    width: 14px;
    height: 14px;
}

.pp-toolbar .pdf-page-info,
.pp-toolbar .pdf-zoom-info {
    font-size: 11px;
    min-width: 36px;
}

.pp-toolbar .pdf-tb-sep {
    height: 16px;
    margin: 0 2px;
}

.pp-search-bar {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.pp-search-bar.visible {
    display: flex;
}

.pp-search-bar input {
    background: var(--gray-0);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: var(--radius);
    font-size: 12px;
    flex: 1;
    min-width: 0;
    outline: none;
}

.pp-search-bar input:focus {
    border-color: var(--brand);
}

.pp-body {
    flex: 1;
    overflow: auto;
    background: var(--gray-100);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    min-height: 0;
}

.pp-title {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.rag-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.rag-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    gap: 12px;
    color: var(--text-muted);
    flex: 1;
}
.rag-welcome-icon svg {
    width: 56px;
    height: 56px;
    opacity: 0.5;
}
.rag-welcome h2 {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.rag-welcome p {
    max-width: 420px;
    font-size: var(--text-sm);
    line-height: 1.6;
}
.rag-welcome-icon-article svg {
    width: 56px;
    height: 56px;
    color: var(--brand);
    opacity: 0.7;
}

.rag-welcome-icon-pdf svg {
    width: 56px;
    height: 56px;
    color: var(--warning);
    opacity: 0.8;
}

.rag-welcome-ctx-hint {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    max-width: 420px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rag-welcome-sep {
    color: var(--text-muted);
    margin: 0 2px;
}

.rag-prompt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 520px;
    margin-top: 4px;
}

.rag-prompt-chip {
    background: color-mix(in srgb, var(--brand) 10%, transparent);
    color: var(--brand);
    border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
    border-radius: 999px;
    padding: 5px 14px;
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.rag-prompt-chip:hover {
    background: color-mix(in srgb, var(--brand) 20%, transparent);
    border-color: color-mix(in srgb, var(--brand) 50%, transparent);
}

.rag-prompt-chip-pdf {
    background: color-mix(in srgb, var(--warning) 10%, transparent);
    color: oklch(0.5 0.14 75);
    border-color: color-mix(in srgb, var(--warning) 30%, transparent);
}

.rag-prompt-chip-pdf:hover {
    background: color-mix(in srgb, var(--warning) 20%, transparent);
    border-color: color-mix(in srgb, var(--warning) 50%, transparent);
}

.rag-welcome-favs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
    justify-content: center;
    max-width: 720px;
}

.rag-welcome-fav-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--brand);
    background: var(--brand-badge-bg);
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.rag-welcome-fav-chip:hover {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

.rag-stats-bar {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}
.rag-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.65;
    font-size: var(--text-md);
    word-break: break-word;
}
.rag-msg-user {
    align-self: flex-end;
    background: var(--brand);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.rag-msg-assistant {
    align-self: flex-start;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.rag-msg-assistant:has(.rag-msg-with-sources) {
    max-width: 100%;
    width: 100%;
}
.rag-msg-content {
    line-height: 1.5;
}
.rag-msg-content p {
    margin: 0 0 4px;
}
.rag-msg-content p:last-child {
    margin-bottom: 0;
}
.rag-table-details {
    margin: 8px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.rag-table-summary {
    padding: 7px 12px;
    font-size: 0.88em;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--gray-100);
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.rag-table-summary::before {
    content: '\25B6';
    font-size: 0.65em;
    transition: transform 0.15s;
}
.rag-table-details[open] > .rag-table-summary::before {
    transform: rotate(90deg);
}
.rag-table-summary::-webkit-details-marker { display: none; }
.rag-table-wrap {
    width: 100%;
    overflow-x: auto;
}
.rag-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92em;
    line-height: 1.4;
}
.rag-table th,
.rag-table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    white-space: normal;
    word-break: break-word;
}
.rag-table thead th {
    background: var(--gray-100);
    font-weight: 600;
    text-align: left;
    position: sticky;
    top: 0;
}
.rag-table tbody tr:nth-child(even) {
    background: var(--elevate-0);
}
.rag-table tbody tr:hover {
    background: var(--gray-50);
}
.rag-msg-content h3 {
    font-size: 1.05em;
    font-weight: 600;
    margin: 10px 0 3px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.rag-msg-content h3:first-child {
    margin-top: 0;
}
.rag-msg-content h4 {
    font-size: 0.95em;
    font-weight: 600;
    margin: 8px 0 2px;
    color: var(--text-primary);
}
.rag-msg-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}
.rag-msg-content ul {
    margin: 2px 0 6px;
    padding-left: 18px;
}
.rag-msg-content li {
    margin-bottom: 1px;
}
.rag-msg-content code {
    background: var(--elevate-2);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
}
.rag-msg-content strong {
    font-weight: 600;
}
.rag-msg-with-sources {
    display: flex;
    gap: 0;
    width: 100%;
    align-items: flex-start;
}
.rag-msg-with-sources > .rag-msg-content {
    flex: 1 1 0%;
    min-width: 0;
    padding-right: 20px;
}
.rag-source-panel {
    flex: 0 0 20%;
    width: 20%;
    min-width: 140px;
    max-width: 240px;
    align-self: stretch;
    background: transparent;
    border: none;
    border-left: 2px solid var(--border);
    border-radius: 0;
    padding: 0 0 0 14px;
}
.rag-source-panel-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--brand);
    margin-bottom: 10px;
}
.rag-source-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.rag-source-item {
    display: block;
    padding: 7px 9px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--bg);
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.rag-source-item:hover {
    border-color: var(--brand);
    background: var(--brand-badge-bg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.rag-source-item-title {
    display: -webkit-box;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.rag-source-item-meta {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 3px;
}
.rag-inline-source {
    display: inline;
    color: var(--brand);
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    border-bottom: 1px dotted var(--brand);
    transition: opacity 0.15s;
}
.rag-inline-source:hover {
    opacity: 0.75;
}
@media (max-width: 800px) {
    .rag-msg-with-sources {
        flex-direction: column;
    }
    .rag-source-panel {
        flex: none;
        width: 100%;
        border-left: none;
        border-top: 2px solid var(--border);
        padding: 12px 0 0 0;
        margin-left: 0;
        margin-top: 12px;
    }
}
.rag-typing {
    color: var(--text-muted);
    font-style: italic;
}

.rag-progress {
    margin-bottom: 10px;
    transition: all 0.3s ease;
}
.rag-progress-collapsed {
    opacity: 0.55;
    margin-bottom: 12px;
}
.rag-progress-collapsed .rag-step {
    padding: 2px 0;
}
.rag-progress-collapsed .rag-step-active {
    display: none;
}
.rag-progress-accordion {
    margin-bottom: 8px;
    font-size: 12px;
    width: 90%;
}
.rag-progress-accordion-bar {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    color: var(--text-muted);
    user-select: none;
    padding: 3px 0;
    list-style: none;
    font-size: 11px;
    font-weight: 500;
}
.rag-progress-accordion-bar::-webkit-details-marker {
    display: none;
}
.rag-progress-accordion-icon {
    display: inline-block;
    font-size: 8px;
    transition: transform 0.2s ease;
    opacity: 0.6;
}
.rag-progress-accordion[open] .rag-progress-accordion-icon {
    transform: rotate(90deg);
}
.rag-progress-accordion .rag-progress-steps {
    padding: 6px 0 2px 2px;
    gap: 2px;
    border-left: 2px solid var(--border);
    margin-left: 3px;
    padding-left: 10px;
    margin-top: 4px;
}
.rag-progress-accordion .rag-step {
    animation: none;
    font-size: 11px;
    gap: 6px;
}
.rag-progress-accordion .rag-step-icon {
    width: 13px;
    height: 13px;
}
.rag-progress-accordion .rag-step-icon svg {
    width: 11px;
    height: 11px;
}
.rag-progress-accordion .rag-step-detail {
    font-size: 10px;
}
.rag-progress-steps {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rag-step {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    line-height: 1.4;
    transition: opacity 0.25s ease;
    animation: rag-step-in 0.25s ease both;
}
.rag-step-enter {
    opacity: 0;
    transform: translateY(6px);
}
@keyframes rag-step-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.rag-step-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rag-step-done .rag-step-icon {
    color: var(--brand);
}
.rag-step-done .rag-step-icon svg {
    width: 14px;
    height: 14px;
}
.rag-step-active .rag-step-label {
    color: var(--text-primary);
    font-weight: 500;
}
.rag-step-done .rag-step-label {
    color: var(--text-secondary);
}
.rag-step-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.rag-step-detail {
    font-size: 11px;
    color: var(--text-muted);
}
.rag-step-spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: rag-spin 0.75s linear infinite;
}
@keyframes rag-spin {
    to { transform: rotate(360deg); }
}
.rag-msg-content-hidden {
    display: none;
}
.rag-error {
    color: var(--error);
}
.rag-input-area {
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-base);
}
.rag-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: border-color 0.15s;
}
.rag-input-wrap:focus-within {
    border-color: var(--brand);
}
#rag-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--text-md);
    resize: none;
    line-height: 1.5;
    max-height: 150px;
}
.rag-send-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--brand);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.rag-send-btn:hover { opacity: 0.85; }
.rag-send-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}
.rag-send-btn svg {
    width: 16px;
    height: 16px;
}
.rag-input-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 4px;
    text-align: center;
}
.rag-doc-item, .rag-session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: default;
    font-size: var(--text-sm);
}
.rag-session-item {
    cursor: pointer;
}
.rag-session-item:hover {
    background: var(--elevate-1);
}
.rag-session-item.active {
    background: var(--brand-badge-bg);
}
.rag-doc-info, .rag-session-info {
    min-width: 0;
    flex: 1;
}
.rag-doc-name, .rag-session-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.rag-doc-meta, .rag-session-meta {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.rag-doc-del {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}
.rag-doc-item:hover .rag-doc-del,
.rag-session-item:hover .rag-doc-del {
    opacity: 1;
}
.rag-doc-del:hover {
    color: var(--error);
}
.drawer-empty {
    font-size: var(--text-xs);
    color: var(--text-muted);
    padding: 8px;
    text-align: center;
}
.rag-filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 0 0 8px;
}
.rag-filter-select {
    padding: 5px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    outline: none;
    transition: border-color 0.15s;
    max-width: 180px;
    flex: 1 1 auto;
    min-width: 0;
}
.rag-filter-select:focus {
    border-color: var(--brand);
}
.rag-filter-stats {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: auto;
}
.rag-filter-reset {
    background: var(--elevate-1);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.rag-filter-reset:hover {
    color: var(--brand);
    border-color: var(--brand);
    background: var(--elevate-2);
}
.rag-filter-stat {
    display: inline-block;
    padding: 2px 8px;
    background: var(--brand-badge-bg);
    color: var(--brand);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}

/* ─── RAG Drawer Tabs ────────────────────────────────── */
.rag-drawer-tabs {
    display: flex;
    gap: 2px;
    background: var(--elevate-1);
    border-radius: 6px;
    padding: 3px;
    margin-bottom: 10px;
}
.rag-drawer-tab {
    flex: 1;
    padding: 5px 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.rag-drawer-tab:hover {
    color: var(--text-primary);
}
.rag-drawer-tab.active {
    background: var(--surface);
    color: var(--brand);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* ─── Model Selector (Toolbar) ──────────────────────── */
.toolbar-model-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    margin-right: 8px;
}
.toolbar-model-selector.hidden {
    display: none;
}
.rag-model-select {
    padding: 5px 28px 5px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--elevate-1);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    min-width: 160px;
    transition: border-color 0.15s;
    outline: none;
}
.rag-model-select:hover {
    border-color: var(--brand);
}
.rag-model-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 20%, transparent);
}
.rag-model-select optgroup {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-muted);
}
.rag-model-select option {
    font-weight: 400;
    color: var(--text-primary);
    padding: 4px 8px;
}


/* ─── RAG Side Panel Tabs ───────────────────────────── */
.rag-sidepanel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.rag-sidepanel-tab {
    flex: 1;
    padding: 5px 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.rag-sidepanel-tab:hover:not(:disabled) {
    color: var(--text-primary);
}
.rag-sidepanel-tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
}
.rag-sidepanel-tab:disabled {
    opacity: 0.35;
    cursor: default;
}
.rag-sidepanel-content.hidden {
    display: none;
}
.rag-sidepanel-images {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    max-height: 400px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.rag-sidepanel-img {
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border);
    aspect-ratio: 4 / 3;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.rag-sidepanel-img:hover {
    border-color: var(--brand);
    box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}
.rag-sidepanel-img img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: var(--gray-100);
}

/* ─── RAG Section Accordions (Einordnung / Weitermachen) ─── */
.rag-section-accordion {
    margin-top: 12px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    overflow: hidden;
}
.rag-section-accordion-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    list-style: none;
    user-select: none;
    transition: color 0.15s, background 0.15s;
}
.rag-section-accordion-bar::-webkit-details-marker {
    display: none;
}
.rag-section-accordion-bar:hover {
    color: var(--text-primary);
    background: var(--elevate-1);
}
.rag-section-accordion[open] > .rag-section-accordion-bar {
    color: var(--brand);
    border-bottom: 1px solid var(--border);
}
.rag-section-accordion[open] > .rag-section-accordion-bar .rag-progress-accordion-icon {
    transform: rotate(90deg);
}
.rag-section-accordion-body {
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
}
.rag-section-accordion-body h3,
.rag-section-accordion-body h4 {
    margin-top: 0;
}

/* ─── Delete All Sessions Button ─── */
.rag-session-list-header {
    display: flex;
    justify-content: flex-end;
    padding: 4px 8px 6px;
    border-bottom: 1px solid var(--border);
}
.rag-delete-all-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 3px 10px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.rag-delete-all-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(220, 53, 69, 0.08);
}

/* ─── Image Overlay Metadata ─── */
.image-overlay-meta {
    padding: 12px 16px;
    max-width: 700px;
    margin: 0 auto;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}
.image-overlay-meta .img-meta-ai-desc {
    margin-bottom: 8px;
    font-style: italic;
    color: var(--text-primary);
}
.image-overlay-meta .img-meta-row {
    display: flex;
    gap: 8px;
    padding: 3px 0;
    border-top: 1px solid var(--border);
    font-size: 12px;
}
.image-overlay-meta .img-meta-label {
    font-weight: 600;
    min-width: 80px;
    flex-shrink: 0;
    color: var(--text-muted);
}
.image-overlay-meta .img-meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.image-overlay-meta .img-tag {
    display: inline-block;
    padding: 1px 7px;
    background: var(--brand-badge-bg);
    color: var(--brand);
    border-radius: 3px;
    font-size: 11px;
}

.ai-marker {
    position: relative;
    border-left: 2px solid var(--ai-accent-border);
    background: var(--ai-accent-bg);
    padding: 1px 6px 1px 4px;
    border-radius: 0 3px 3px 0;
}

.ai-marker-icon {
    display: inline-flex;
    align-items: center;
    margin-right: 3px;
    color: var(--ai-icon-color);
    font-size: 0.6em;
    vertical-align: middle;
    line-height: 1;
    opacity: 0.7;
}

.ai-marker-icon svg {
    width: 10px;
    height: 10px;
    fill: var(--ai-icon-color);
    flex-shrink: 0;
}

.ai-marker[data-ai-tooltip] {
    cursor: default;
}

.ai-marker[data-ai-tooltip]:hover::after {
    content: attr(data-ai-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: var(--gray-0);
    font-size: 11px;
    font-weight: 400;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    line-height: 1.3;
    letter-spacing: 0;
    text-transform: none;
}

.ai-marker[data-ai-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--gray-900);
    z-index: 1000;
    pointer-events: none;
}

.detail-ai-section {
    border-left: 3px solid var(--ai-accent-border);
    background: var(--ai-accent-bg);
    padding: 12px 14px;
    border-radius: 0 6px 6px 0;
    margin-bottom: 12px;
}

.ai-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.ai-section-header h4 {
    margin-bottom: 0;
}

.article-analyze-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: filter 0.15s;
    white-space: nowrap;
}
.article-analyze-btn:hover { filter: brightness(1.1); }
.article-analyze-btn:disabled { opacity: 0.6; cursor: wait; }

.ai-empty-hint {
    color: var(--gray-400);
    font-size: 12px;
    font-style: italic;
    margin-top: 4px;
}

.detail-ai-section h4 {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-ai-section h4 .ai-marker-icon {
    font-size: 1em;
    opacity: 0.6;
}

.detail-ai-section h4 .ai-marker-icon svg {
    width: 14px;
    height: 14px;
}

.img-meta-ai-wrap {
    border-left: 2px solid var(--ai-accent-border);
    padding-left: 8px;
    margin-bottom: 6px;
}

.pdf-meta-ai-wrap {
    border-left: 2px solid var(--ai-accent-border);
    padding-left: 8px;
}

.prompt-editor-overlay { z-index: 320; }
.prompt-exec-overlay { z-index: 330; }

.prompt-lib-inline {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.prompt-lib-inline-header {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.prompt-editor-panel {
    width: 90vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.prompt-exec-panel {
    width: 60vw;
    max-width: 700px;
    height: auto;
    max-height: 90vh;
}

.prompt-lib-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.prompt-lib-search-wrap {
    position: relative;
}

.prompt-lib-search-wrap input {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-family: inherit;
    background: var(--surface-base);
    color: var(--text-primary);
    outline: none;
    width: 180px;
    transition: border-color 0.15s;
}

.prompt-lib-search-wrap input:focus {
    border-color: var(--brand);
}

.prompt-lib-header-actions select {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-family: inherit;
    background: var(--surface-base);
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
}

.prompt-lib-body {
    padding: 16px 20px;
}

.prompt-lib-section-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 16px 0 8px;
}

.prompt-lib-section-title:first-child {
    margin-top: 0;
}

.prompt-lib-fav-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
    margin-bottom: 8px;
}

.prompt-lib-cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
    margin-bottom: 8px;
}

.prompt-card {
    background: var(--surface-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    cursor: default;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.prompt-card:hover {
    border-color: var(--brand);
    box-shadow: 0 2px 8px oklch(0 0 0 / 0.06);
}

.prompt-card-fav {
    border-color: oklch(0.75 0.15 85 / 0.4);
    background: oklch(0.98 0.01 85);
}

.prompt-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.prompt-card-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

.prompt-card-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.prompt-card:hover .prompt-card-actions {
    opacity: 1;
}

.prompt-card-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px;
    border-radius: 4px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, color 0.1s;
}

.prompt-card-btn:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.prompt-card-btn.prompt-fav-active {
    color: oklch(0.7 0.15 85);
}

.prompt-card-btn-del:hover {
    color: var(--error);
}

.prompt-card-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.4;
}

.prompt-card-preview {
    font-size: var(--text-xs);
    color: var(--text-muted);
    opacity: 0.7;
    line-height: 1.4;
    max-height: 2.8em;
    overflow: hidden;
    word-break: break-word;
}

.prompt-card-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding-top: 4px;
}

.prompt-card-footer .prompt-card-use {
    margin-left: auto;
}

.prompt-card-status {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
}

.prompt-card-status.inactive {
    background: oklch(0.93 0.03 25);
    color: oklch(0.5 0.15 25);
}

.prompt-card-inactive {
    opacity: 0.6;
}

.prompt-card-creator {
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
}

.prompt-card-scope {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.prompt-scope-all {
    background: oklch(0.93 0.02 240);
    color: oklch(0.45 0.1 240);
}

.prompt-scope-rag {
    background: oklch(0.93 0.02 290);
    color: oklch(0.5 0.1 290);
}

.prompt-scope-article {
    background: oklch(0.93 0.02 142);
    color: oklch(0.45 0.12 142);
}

.prompt-scope-pdf {
    background: oklch(0.93 0.02 25);
    color: oklch(0.5 0.12 25);
}

.prompt-card-use {
    font-size: var(--text-xs);
    padding: 3px 12px;
}

.prompt-editor-body {
    padding: 16px 20px;
}

.prompt-editor-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prompt-editor-form label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-top: 4px;
}

.prompt-editor-form label .text-muted {
    font-weight: 400;
    color: var(--text-muted);
}

.prompt-editor-form input[type="text"],
.prompt-editor-form select,
.prompt-editor-form textarea {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-family: inherit;
    background: var(--surface-base);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
    box-sizing: border-box;
    display: block;
}

.prompt-editor-form input[type="text"]:focus,
.prompt-editor-form select:focus,
.prompt-editor-form textarea:focus {
    border-color: var(--brand);
}

.prompt-editor-form textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

.prompt-editor-row {
    display: flex;
    gap: 12px;
}

.prompt-editor-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.prompt-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.prompt-ph-config-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.prompt-ph-config-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--gray-50);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.prompt-ph-key {
    font-family: monospace;
    font-weight: 600;
    color: var(--brand);
    font-size: var(--text-xs);
    min-width: 100px;
}

.prompt-ph-config-item input[type="text"],
.prompt-ph-config-item select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-xs);
    background: var(--surface-base);
    color: var(--text-primary);
}

.prompt-ph-label { width: 100px; }
.prompt-ph-default { width: 100px; }
.prompt-ph-options { flex: 1; min-width: 150px; }

.prompt-ph-required-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-xs);
    color: var(--text-muted);
    cursor: pointer;
}

.prompt-exec-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.prompt-exec-body label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.prompt-exec-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 4px;
}

.prompt-exec-field label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--brand);
    font-family: monospace;
}

.prompt-exec-input {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-family: inherit;
    background: var(--surface-base);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}

.prompt-exec-input:focus {
    border-color: var(--brand);
}

textarea.prompt-exec-input {
    resize: vertical;
    min-height: 60px;
    line-height: 1.5;
}

select.prompt-exec-input {
    cursor: pointer;
}

.prompt-exec-required label {
    color: var(--text-primary);
    font-weight: 600;
}

.prompt-exec-preview {
    background: var(--gray-50);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: var(--text-sm);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
    color: var(--text-primary);
}

.prompt-exec-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.prompt-exec-manual {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-family: inherit;
    background: var(--surface-base);
    color: var(--text-primary);
    resize: vertical;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.15s;
}

.prompt-exec-manual:focus {
    border-color: var(--brand);
}

.prompt-exec-target-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.prompt-exec-target-row label {
    margin: 0;
    white-space: nowrap;
}

.prompt-exec-target-row select {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    background: var(--surface-base);
    color: var(--text-primary);
}

.prompt-lib-scope-toggles {
    display: flex;
    gap: 4px;
    align-items: center;
}

.prompt-scope-chip {
    padding: 4px 10px;
    font-size: var(--text-xs);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-base);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.prompt-scope-chip.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

.prompt-scope-chip:hover:not(.active) {
    background: var(--gray-50);
    color: var(--text-primary);
}

.prompt-lib-view-toggle {
    display: flex;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.prompt-lib-view-btn {
    padding: 4px 8px;
    font-size: 14px;
    background: var(--surface-base);
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}

.prompt-lib-view-btn.active {
    background: var(--brand);
    color: #fff;
}

.prompt-lib-view-btn:hover:not(.active) {
    background: var(--gray-50);
}

.prompt-lib-grid.prompt-lib-list-view {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.prompt-lib-grid.prompt-lib-list-view .prompt-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 8px 12px;
    gap: 12px;
}

.prompt-lib-grid.prompt-lib-list-view .prompt-card .prompt-card-title {
    flex: 1;
    margin: 0;
}

.prompt-lib-grid.prompt-lib-list-view .prompt-card .prompt-card-scope {
    flex-shrink: 0;
}

.prompt-lib-grid.prompt-lib-list-view .prompt-card .prompt-card-preview,
.prompt-lib-grid.prompt-lib-list-view .prompt-card .prompt-card-desc {
    display: none;
}

.rag-prompt-lib-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 6px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.rag-prompt-lib-btn:hover {
    color: var(--brand);
    background: var(--brand-badge-bg);
}

.rag-prompt-lib-btn svg {
    width: 18px;
    height: 18px;
}

.prompt-lib-toolbar-btn {
    color: var(--text-muted);
}

.prompt-lib-toolbar-btn:hover {
    color: var(--brand);
    background: var(--brand-badge-bg);
}

.help-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.help-header {
    padding: 20px 24px 12px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}
.help-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.help-title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.help-search {
    width: 100%;
    padding: 8px 12px;
    background: var(--gray-100);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.help-search:focus {
    border-color: var(--brand);
}
.help-search::placeholder {
    color: var(--text-muted);
}
.help-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px 40px;
}
.help-section {
    margin-bottom: 8px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
    background: var(--gray-0);
}
.help-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: var(--gray-50);
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    transition: background 0.15s;
}
.help-section-header:hover {
    background: var(--gray-100);
}
.help-section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--brand-badge-bg);
    color: var(--brand);
    flex-shrink: 0;
}
.help-section-icon svg {
    width: 16px;
    height: 16px;
}
.help-section-title {
    flex: 1;
}
.help-section-chevron {
    color: var(--text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}
.help-section.open .help-section-chevron {
    transform: rotate(180deg);
}
.help-section-body {
    display: none;
    padding: 4px 16px 16px;
}
.help-section.open .help-section-body {
    display: block;
}
.help-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}
.help-item:last-child {
    border-bottom: none;
}
.help-item-heading {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 6px;
}
.help-item-text {
    font-size: var(--text-sm);
    color: var(--text-secondary, var(--gray-400));
    line-height: 1.65;
}
.help-item-text p {
    margin: 0 0 8px;
}
.help-item-text p:last-child {
    margin-bottom: 0;
}
.help-item-text strong {
    color: var(--text-primary);
    font-weight: 600;
}
.help-item-text ul,
.help-item-text ol {
    margin: 6px 0;
    padding-left: 20px;
}
.help-item-text li {
    margin-bottom: 3px;
}
.help-shortcuts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    margin-top: 4px;
}
.help-shortcuts-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 12px;
    border-bottom: 2px solid var(--gray-200);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.help-shortcuts-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--text-primary);
}
.help-shortcuts-table kbd {
    display: inline-block;
    padding: 2px 7px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 22px;
    text-align: center;
    box-shadow: 0 1px 0 var(--gray-200);
}

#tour-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: none;
}
#tour-overlay.active {
    display: block;
}
.tour-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1;
    pointer-events: auto;
}
.tour-spotlight {
    position: fixed;
    z-index: 2;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    transition: all 0.3s ease;
    pointer-events: none;
}
.tour-tooltip {
    position: fixed;
    z-index: 10001;
    width: 340px;
    background: var(--gray-0);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transition: left 0.3s ease, top 0.3s ease;
    pointer-events: auto;
}
.tour-tooltip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 0;
}
.tour-tooltip-title {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--text-primary);
}
.tour-tooltip-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.tour-tooltip-close:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}
.tour-tooltip-body {
    padding: 8px 16px 12px;
    font-size: var(--text-sm);
    color: var(--text-secondary, var(--gray-400));
    line-height: 1.6;
}
.tour-tooltip-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 14px;
    border-top: 1px solid var(--gray-100);
}
.tour-tooltip-step {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 500;
}
.tour-tooltip-buttons {
    display: flex;
    gap: 8px;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}
.users-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    padding: 10px 12px;
    border-bottom: 2px solid var(--gray-200);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.users-table td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--text-primary);
    vertical-align: middle;
}
.users-table tr:hover td {
    background: var(--gray-50);
}
.user-role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: var(--text-xs);
    font-weight: 600;
}
.role-admin {
    background: var(--brand-badge-bg);
    color: var(--brand);
}
.role-user {
    background: var(--gray-100);
    color: var(--text-secondary, var(--gray-400));
}
.btn-danger {
    color: var(--red-500, #ef4444);
    border-color: var(--red-500, #ef4444);
}
.btn-danger:hover {
    background: var(--red-500, #ef4444);
    color: #fff;
}
.user-form-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}
.user-form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.user-form-label {
    width: 130px;
    flex-shrink: 0;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
}
.user-form-input {
    flex: 1;
    padding: 8px 10px;
    background: var(--gray-0);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.user-form-input:focus {
    border-color: var(--brand);
}
.user-form-error {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: var(--radius);
    color: var(--red-500, #ef4444);
    font-size: var(--text-xs);
    font-weight: 500;
}
.user-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.changelog-release {
    margin-bottom: 28px;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    overflow: hidden;
    background: var(--gray-0);
}
.changelog-release-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
}
.changelog-version {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--brand);
    background: var(--brand-badge-bg);
    padding: 2px 10px;
    border-radius: 6px;
}
.changelog-publish-date {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 500;
}
.changelog-entry {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
}
.changelog-entry:last-child {
    border-bottom: none;
}
.changelog-entry-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}
.changelog-type-badge {
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
}
.changelog-entry-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
}
.changelog-entry-time {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
.changelog-entry-desc {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    line-height: 1.5;
    padding-left: 0;
}

.login-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, oklch(0.97 0.01 221) 0%, oklch(0.94 0.02 221) 50%, oklch(0.97 0.005 260) 100%);
}
.login-card {
    background: var(--surface-base);
    border-radius: 12px;
    box-shadow: 0 8px 32px oklch(0 0 0 / 0.12), 0 2px 8px oklch(0 0 0 / 0.06);
    padding: 40px 36px 36px;
    width: 360px;
    max-width: 90vw;
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo-full {
    display: inline-flex;
    align-items: flex-start;
    gap: 4px;
    justify-content: center;
}
.login-spark-svg {
    width: 220px;
    height: auto;
}
.login-logo-vc {
    font-size: 12px;
    font-weight: 700;
    color: var(--brand);
    margin-top: -2px;
    line-height: 1;
    letter-spacing: 0;
}
.login-subtitle {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-muted);
}
.login-field {
    margin-bottom: 16px;
}
.login-field label {
    display: block;
    margin-bottom: 5px;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
}
.login-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-base);
    color: var(--text-primary);
    font-size: var(--text-md);
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.login-field input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px oklch(0.559 0.102 221 / 0.12);
}
.login-error {
    margin: 0 0 12px;
    font-size: var(--text-sm);
    color: var(--error);
    min-height: 1.2em;
}
.login-submit {
    width: 100%;
    padding: 10px 16px;
    font-size: var(--text-md);
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity 0.15s;
}
.login-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.proto-toolbar-inline {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.proto-toolbar-inline select {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-base);
    color: var(--text-primary);
    font-size: var(--text-xs);
}
.protocol-entries-scroll {
    max-height: calc(100vh - 260px);
    overflow-y: auto;
}

.rail-logout-btn {
    margin-top: 4px;
    border-top: 1px solid var(--sidebar-border);
    padding-top: 8px;
    color: var(--text-muted);
    transition: color 0.15s;
}
.rail-logout-btn:hover {
    color: var(--error) !important;
    background: oklch(0.55 0.22 25 / 0.08) !important;
}

.drawer-item-lock {
    flex-shrink: 0;
    color: var(--text-muted);
    opacity: 0.5;
    margin-left: auto;
}

.drawer-crawler-status {
    margin-top: auto;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    font-size: var(--text-xs);
}
.drawer-version-footer {
    margin-top: auto;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.5;
}
.drawer-version-footer .drawer-version-line {
    display: block;
}
.drawer-version-footer .drawer-version-num {
    font-weight: 600;
    color: var(--text-secondary, var(--text-muted));
}
.drawer-status-heading {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.drawer-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.drawer-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--text-muted);
}
.drawer-status-dot.active {
    background: var(--green, #22c55e);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
    animation: pulse-dot 1.5s ease-in-out infinite;
}
.drawer-status-dot.waiting {
    background: var(--text-muted);
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.drawer-status-text {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--text-xs);
}
.drawer-status-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.drawer-status-line {
    color: var(--text-muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.admin-pw-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, oklch(0.97 0.01 221 / 0.92) 0%, oklch(0.94 0.02 221 / 0.92) 50%, oklch(0.97 0.005 260 / 0.92) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.admin-pw-overlay.hidden { display: none; }
.admin-pw-icon {
    text-align: center;
    margin-bottom: 12px;
    color: var(--brand);
}
.admin-pw-card {
    background: var(--surface-base);
    border-radius: 12px;
    padding: 40px 36px 36px;
    width: 360px;
    max-width: 90vw;
    box-shadow: 0 8px 32px oklch(0 0 0 / 0.12), 0 2px 8px oklch(0 0 0 / 0.06);
}
.admin-pw-title {
    margin: 0 0 6px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}
.admin-pw-desc {
    margin: 0 0 20px;
    font-size: var(--text-sm);
    color: var(--text-muted);
    text-align: center;
}
.admin-pw-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    background: var(--surface-base);
    color: var(--text-primary);
    margin-bottom: 8px;
}
.admin-pw-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px color-mix(in oklch, var(--brand) 20%, transparent);
}
.admin-pw-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.ai-dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.ai-dash-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-dash-title h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}
.ai-dash-title svg {
    color: var(--brand);
}
.ai-dash-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-currency-select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    background: var(--surface-base);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
    transition: border-color 0.15s;
}
.ai-currency-select:hover {
    border-color: var(--brand);
}

.ai-dash-filters {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 20px;
    flex-wrap: wrap;
    padding: 14px 16px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.ai-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ai-filter-group label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ai-filter-group select,
.ai-filter-group input[type="date"] {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-xs);
    background: var(--surface-base);
    color: var(--text-primary);
    min-width: 120px;
}
.ai-filter-reset {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-xs);
    background: var(--surface-base);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.ai-filter-reset:hover {
    border-color: var(--error, #ef4444);
    color: var(--error, #ef4444);
}

.ai-dash-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.ai-kpi-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: box-shadow 0.15s;
}
.ai-kpi-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.ai-kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ai-kpi-cost .ai-kpi-icon { background: rgba(59,130,246,0.1); color: #3b82f6; }
.ai-kpi-calls .ai-kpi-icon { background: rgba(16,185,129,0.1); color: #10b981; }
.ai-kpi-tokens .ai-kpi-icon { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.ai-kpi-duration .ai-kpi-icon { background: rgba(245,158,11,0.1); color: #f59e0b; }
.ai-kpi-avg .ai-kpi-icon { background: rgba(236,72,153,0.1); color: #ec4899; }
.ai-kpi-body {
    flex: 1;
    min-width: 0;
}
.ai-kpi-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}
.ai-kpi-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.ai-kpi-sub {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
    opacity: 0.8;
}

.ai-dash-charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.ai-chart-card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    position: relative;
    min-height: 260px;
}
.ai-chart-card.ai-chart-wide {
    grid-column: auto;
}
.ai-chart-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}
.ai-chart-card canvas {
    max-height: 240px;
}

.ai-dash-tables {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.ai-table-card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    overflow-x: auto;
}
.ai-table-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.ai-mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
}
.ai-mini-table th {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.ai-mini-table td {
    padding: 6px 8px;
    border-bottom: 1px solid color-mix(in oklch, var(--border) 50%, transparent);
    color: var(--text-primary);
}
.ai-mini-table tr:hover {
    background: var(--surface-hover);
}
.ai-pct-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 80px;
}
.ai-pct-fill {
    height: 6px;
    border-radius: 3px;
    background: var(--brand);
    min-width: 2px;
    transition: width 0.3s ease;
}
.ai-pct-bar span {
    font-size: 10px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.ai-group-row {
    background: var(--surface-raised);
}
.ai-group-row td {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}
.ai-submod-row td {
    font-size: 11px;
    color: var(--text-secondary);
}
.ai-model-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--brand-badge-bg);
    color: var(--brand);
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.ai-dash-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.ai-dash-section-title svg {
    color: var(--text-muted);
}

.ai-usage-table-wrap {
    overflow-x: auto;
    margin-bottom: 12px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.ai-usage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
}
.ai-usage-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.ai-usage-table td {
    padding: 8px 12px;
    border-bottom: 1px solid color-mix(in oklch, var(--border) 50%, transparent);
    color: var(--text-primary);
    vertical-align: middle;
}
.ai-usage-row:hover { background: var(--surface-hover); }
.ai-ts { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ai-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-status-ok {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--success, #22c55e);
    font-weight: 600;
    font-size: 10px;
}
.ai-status-error {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--error, #ef4444);
    font-weight: 600;
    font-size: 10px;
}
.ai-detail-row td { padding: 0 !important; }
.ai-detail-content {
    padding: 14px 18px;
    background: var(--surface-base);
    border-radius: var(--radius);
    margin: 4px 12px 10px;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid var(--border);
}
.ai-detail-content strong { color: var(--text-primary); }
.ai-error-msg { color: var(--error, #ef4444); }
.ai-prompt-preview pre {
    margin: 4px 0 0;
    padding: 10px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 11px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}
.ai-usage-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 0;
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.btn-icon-sm {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-muted);
    border-radius: 4px;
    transition: all 0.15s;
}
.btn-icon-sm:hover { background: var(--surface-hover); color: var(--text-primary); }

@media (max-width: 900px) {
    .ai-dash-charts-row { grid-template-columns: 1fr; }
    .ai-dash-tables { grid-template-columns: 1fr; }
    .ai-dash-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .ai-dash-kpis { grid-template-columns: 1fr; }
    .ai-dash-filters { flex-direction: column; align-items: stretch; }
    .ai-dash-header { flex-direction: column; gap: 10px; align-items: flex-start; }
}

/* ===== Prompt Library Overlay ===== */
.prompt-library-overlay { z-index: 310; }
.prompt-library-panel {
    width: 90vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
}
.prompt-library-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}
.prompt-library-title-wrap {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.prompt-library-title-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--brand-badge-bg);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.prompt-library-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.prompt-library-subtitle {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.4;
}
.prompt-library-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--gray-50);
    flex-wrap: wrap;
}
.prompt-library-search {
    flex: 1;
    min-width: 200px;
    position: relative;
    display: flex;
    align-items: center;
}
.prompt-library-search svg {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    pointer-events: none;
}
.prompt-library-search input {
    width: 100%;
    padding: 7px 10px 7px 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-family: inherit;
    background: var(--surface-base);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}
.prompt-library-search input:focus {
    border-color: var(--brand);
}
.prompt-library-toolbar select {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    background: var(--surface-base);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}
.prompt-lib-filter-btn {
    background: var(--surface-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 8px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.prompt-lib-filter-btn:hover { color: var(--brand); border-color: var(--brand); }
.prompt-lib-filter-btn.active { background: var(--brand-badge-bg); color: var(--brand); border-color: var(--brand); }
.prompt-lib-extra-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--gray-50);
}
.prompt-lib-extra-filters select,
.prompt-lib-extra-filters .toolbar-text-btn {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-xs);
    background: var(--surface-base);
    color: var(--text-primary);
    cursor: pointer;
}
.prompt-lib-reset-btn {
    margin-left: auto;
    white-space: nowrap;
}
.prompt-lib-new-btn { white-space: nowrap; }
.prompt-library-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}
.prompt-lib-section { margin-bottom: 24px; }
.prompt-lib-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.prompt-lib-group-icon {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}
.prompt-lib-group-icon-fav { color: oklch(0.7 0.15 85); }
.prompt-lib-group-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}
.prompt-lib-group-count {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-left: 2px;
}
.prompt-lib-sort-btn {
    margin-left: auto;
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--text-muted);
    font-size: var(--text-xs);
    padding: 3px 8px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}
.prompt-lib-sort-btn:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}
.prompt-lib-sort-btn svg { transition: transform 0.2s; }
.prompt-lib-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-xs);
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}
.prompt-lib-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.prompt-lib-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}
.prompt-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--surface-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, background 0.15s;
}
.prompt-row:hover {
    border-color: var(--brand);
    background: var(--brand-badge-bg);
}
.prompt-row-inactive { opacity: 0.6; }
.prompt-row-inactive-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
    background: var(--gray-100);
    color: var(--text-muted);
}
.prompt-row-fav {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.15s;
    flex-shrink: 0;
}
.prompt-row-fav:hover { color: oklch(0.7 0.15 85); }
.prompt-row-fav.prompt-row-fav-active { color: oklch(0.7 0.15 85); }
.prompt-row-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.prompt-row-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.prompt-row-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.prompt-row-scope {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--gray-100);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
.prompt-row-scope.prompt-scope-article { background: oklch(0.95 0.05 230); color: oklch(0.4 0.15 230); }
.prompt-row-scope.prompt-scope-rag { background: oklch(0.95 0.05 150); color: oklch(0.4 0.15 150); }
.prompt-row-scope.prompt-scope-pdf { background: oklch(0.95 0.05 30); color: oklch(0.4 0.15 30); }
.prompt-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}
.prompt-row-meta-chip {
    font-size: 10px;
    font-weight: 500;
    padding: 1px 7px;
    border-radius: 9px;
    background: var(--gray-100);
    color: var(--text-muted);
    line-height: 1.5;
    white-space: nowrap;
}
.prompt-row-meta-scope {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.prompt-row-meta-scope.prompt-scope-article { background: oklch(0.95 0.05 230); color: oklch(0.4 0.15 230); }
.prompt-row-meta-scope.prompt-scope-rag { background: oklch(0.95 0.05 150); color: oklch(0.4 0.15 150); }
.prompt-row-meta-scope.prompt-scope-pdf { background: oklch(0.95 0.05 30); color: oklch(0.4 0.15 30); }
.prompt-meta-status-active { background: oklch(0.94 0.06 150); color: oklch(0.38 0.14 150); }
.prompt-meta-status-inactive { background: oklch(0.94 0.04 30); color: oklch(0.45 0.12 30); }
.prompt-row-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.prompt-row-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: var(--text-muted);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.prompt-row-btn:hover { background: var(--gray-100); color: var(--text-primary); }
.prompt-row-btn-play:hover { color: var(--brand); }
.prompt-row-btn-del:hover { color: var(--error); }
.prompt-row-drag {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 2px;
    border-radius: 4px;
    cursor: grab;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
}
.prompt-row-draggable:hover .prompt-row-drag { opacity: 1; }
.prompt-row-drag:active { cursor: grabbing; }
.prompt-row-draggable {
    user-select: none;
}
.prompt-row-dragging {
    opacity: 0.4;
    border-style: dashed;
}
.prompt-row-drop-before {
    box-shadow: 0 -2px 0 0 var(--brand);
}
.prompt-row-drop-after {
    box-shadow: 0 2px 0 0 var(--brand);
}

/* Prompt Editor Sections */
.prompt-editor-section {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 8px;
}
.prompt-editor-section-title {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.prompt-editor-advanced { padding-top: 8px; }
.prompt-editor-advanced-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}
.prompt-editor-advanced-toggle svg { transition: transform 0.2s; color: var(--text-muted); }
.prompt-editor-advanced-body {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.text-required { color: var(--error); margin-left: 2px; }
.btn-disabled { opacity: 0.5; cursor: not-allowed !important; }

/* Prompt Exec Sections */
.prompt-exec-header { align-items: center; }
.prompt-exec-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.prompt-exec-title-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--brand-badge-bg);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
}
.prompt-exec-section { margin-bottom: 4px; }
.prompt-exec-section-title {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.prompt-exec-actions {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.prompt-exec-actions-buttons { display: flex; gap: 8px; }

/* Drawer RAG Favorites */
.rag-fav-list .rag-session-item { background: oklch(0.99 0.01 85 / 0.5); }
.rag-session-fav {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px;
    color: var(--text-muted);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
}
.rag-session-item:hover .rag-session-fav,
.rag-session-fav.rag-session-fav-active { opacity: 1; }
.rag-session-fav:hover { color: oklch(0.7 0.15 85); }
.rag-session-fav.rag-session-fav-active { color: oklch(0.7 0.15 85); }

@media (max-width: 700px) {
    .prompt-library-panel { width: 96vw; height: 92vh; }
    .prompt-library-toolbar { gap: 6px; }
    .prompt-library-search { min-width: 100%; order: -1; }
}

.prompt-ph-empty {
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: var(--text-sm);
    line-height: 1.5;
}
.prompt-ph-empty code {
    background: var(--surface-1);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: var(--font-mono, monospace);
    font-size: 0.9em;
    color: var(--text);
}
.prompt-exec-field-error {
    color: var(--red);
    font-size: var(--text-xs);
    margin-top: 4px;
    line-height: 1.3;
}
.prompt-exec-field-invalid input,
.prompt-exec-field-invalid textarea,
.prompt-exec-field-invalid select {
    border-color: var(--red) !important;
    box-shadow: 0 0 0 2px oklch(0.7 0.18 25 / 0.15);
}
.prompt-exec-preview-ph {
    display: inline-block;
    background: oklch(0.95 0.1 25 / 0.5);
    color: var(--red);
    border: 1px solid oklch(0.7 0.18 25 / 0.4);
    padding: 0 6px;
    border-radius: 3px;
    font-family: var(--font-mono, monospace);
    font-size: 0.92em;
    font-weight: 500;
}
