/* andilm - Design System (2026 Redesign) */

/* ============================================
   DESIGN TOKENS — DARK THEME (default)
   ============================================ */
:root, html.dark {
    /* Backgrounds */
    --color-base:          #0f0f1a;
    --color-panel:         #131322;
    --color-surface:       #1a1a2e;
    --color-surface-alt:   #161630;
    --color-surface-50:    #222240;
    --color-surface-100:   #282848;
    --color-surface-200:   #323250;
    --color-surface-hover: #1e1e38;

    /* Borders */
    --color-border:        #1e1e38;
    --color-border-muted:  #282848;
    --color-border-strong: #3a3a5c;

    /* Brand — Enterprise Purple/Indigo */
    --color-brand:         #7c3aed;
    --color-brand-hover:   #6d28d9;
    --color-brand-subtle:  rgba(124, 58, 237, 0.06);
    --color-brand-muted:   rgba(124, 58, 237, 0.08);
    --color-brand-10:      rgba(124, 58, 237, 0.10);

    /* Secondary accent */
    --color-accent:        #6366f1;
    --color-accent-hover:  #4f46e5;

    /* Gradients */
    --gradient-brand:      linear-gradient(135deg, #7c3aed, #6366f1);
    --gradient-brand-hover:linear-gradient(135deg, #6d28d9, #4f46e5);
    --gradient-surface:    linear-gradient(135deg, rgba(124, 58, 237, 0.03), rgba(99, 102, 241, 0.03));

    /* Text */
    --color-text:          #e2e2f0;
    --color-text-muted:    #a0a0c0;
    --color-text-subtle:   #6a6a8a;
    --color-text-inverse:  #ffffff;

    /* Chat */
    --color-chat-user:     #2a2a4a;
    --color-chat-assistant:#1a1a32;

    /* Misc */
    --color-overlay:       rgba(0, 0, 0, 0.6);
    --color-scrollbar:     #3a3a5c;
    --color-scrollbar-hover:#4a4a6e;

    /* Radius */
    --radius-sm:   4px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-xl:   16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow:0 0 40px rgba(124, 58, 237, 0.08);

    /* Transitions */
    --transition-fast:   150ms ease;
    --transition-normal: 200ms ease;
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Layout */
    --topbar-height: 56px;
    --panel-left:    360px;
    --panel-right:   360px;

    /* Type accent colors */
    --color-type-audio:       #4ade80;
    --color-type-video:       #22d3ee;
    --color-type-mindmap:     #34d399;
    --color-type-report:      #818cf8;
    --color-type-flashcards:  #fbbf24;
    --color-type-quiz:        #f472b6;
    --color-type-infographic: #fb923c;
    --color-type-slidedeck:   #a78bfa;
    --color-type-datatable:   #94a3b8;

    /* Priority colors */
    --color-priority-critical:    #ef4444;
    --color-priority-critical-bg: rgba(239, 68, 68, 0.15);
    --color-priority-high:        #f97316;
    --color-priority-high-bg:     rgba(249, 115, 22, 0.15);
    --color-priority-medium:      #eab308;
    --color-priority-medium-bg:   rgba(234, 179, 8, 0.15);
    --color-priority-low:         #6b7280;
    --color-priority-low-bg:      rgba(107, 114, 128, 0.15);

    /* Connector type colors */
    --color-connector-api:        #3b82f6;
    --color-connector-api-bg:     rgba(59, 130, 246, 0.2);
    --color-connector-mcp:        #7c3aed;
    --color-connector-mcp-bg:     rgba(124, 58, 237, 0.2);
    --color-connector-agent:      #10b981;
    --color-connector-agent-bg:   rgba(16, 185, 129, 0.2);
    --color-connector-manual:     #6b7280;
    --color-connector-manual-bg:  rgba(107, 114, 128, 0.2);

    /* Status colors */
    --color-status-pending:       var(--color-text-subtle);
    --color-status-dispatched:    var(--color-brand);
    --color-status-completed:     #22c55e;
    --color-status-failed:        #ef4444;

    /* Actions layout */
    --actions-sidebar: 280px;

    /* Glass */
    --glass-bg:    color-mix(in srgb, var(--color-panel) 80%, transparent);
    --glass-blur:  blur(16px) saturate(180%);
}

/* ============================================
   DESIGN TOKENS — LIGHT THEME
   ============================================ */
html.light {
    /* Backgrounds */
    --color-base:          #f5f5fa;
    --color-panel:         #ffffff;
    --color-surface:       #eeeef6;
    --color-surface-alt:   #e8e8f2;
    --color-surface-50:    #e4e4f0;
    --color-surface-100:   #dcdcea;
    --color-surface-200:   #d2d2e4;
    --color-surface-hover: #ebebf5;

    /* Borders */
    --color-border:        #dcdce8;
    --color-border-muted:  #e4e4f0;
    --color-border-strong: #c5c5d8;

    /* Brand */
    --color-brand:         #7c3aed;
    --color-brand-hover:   #6d28d9;
    --color-brand-subtle:  rgba(124, 58, 237, 0.04);
    --color-brand-muted:   rgba(124, 58, 237, 0.06);
    --color-brand-10:      rgba(124, 58, 237, 0.08);

    /* Secondary accent */
    --color-accent:        #6366f1;
    --color-accent-hover:  #4f46e5;

    /* Gradients */
    --gradient-brand:      linear-gradient(135deg, #7c3aed, #6366f1);
    --gradient-brand-hover:linear-gradient(135deg, #6d28d9, #4f46e5);
    --gradient-surface:    linear-gradient(135deg, rgba(124, 58, 237, 0.02), rgba(99, 102, 241, 0.02));

    /* Text */
    --color-text:          #1a1a2e;
    --color-text-muted:    #52527a;
    --color-text-subtle:   #8888a8;
    --color-text-inverse:  #ffffff;

    /* Chat */
    --color-chat-user:     #e6e6f4;
    --color-chat-assistant:#f2f2fa;

    /* Misc */
    --color-overlay:       rgba(0, 0, 0, 0.3);
    --color-scrollbar:     #c5c5d8;
    --color-scrollbar-hover:#a0a0b8;

    /* Shadows — lighter, more diffused */
    --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-glow:0 0 40px rgba(124, 58, 237, 0.05);

    /* Priority colors — darker for light bg */
    --color-priority-critical:    #dc2626;
    --color-priority-critical-bg: rgba(220, 38, 38, 0.12);
    --color-priority-high:        #ea580c;
    --color-priority-high-bg:     rgba(234, 88, 12, 0.12);
    --color-priority-medium:      #ca8a04;
    --color-priority-medium-bg:   rgba(202, 138, 4, 0.12);
    --color-priority-low:         #4b5563;
    --color-priority-low-bg:      rgba(75, 85, 99, 0.12);

    /* Connector type colors — light */
    --color-connector-api-bg:     rgba(59, 130, 246, 0.12);
    --color-connector-mcp-bg:     rgba(124, 58, 237, 0.12);
    --color-connector-agent-bg:   rgba(16, 185, 129, 0.12);
    --color-connector-manual-bg:  rgba(107, 114, 128, 0.12);

    /* Glass */
    --glass-bg:    color-mix(in srgb, var(--color-panel) 85%, transparent);
    --glass-blur:  blur(16px) saturate(150%);
}

/* ============================================
   BASE STYLES
   ============================================ */

/* Smooth theme transition */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease !important;
}

/* Page loading bar */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
}
#page-loader.htmx-request {
    opacity: 1;
    background: var(--gradient-brand);
    animation: loading-bar 2s ease-out forwards;
}
@keyframes loading-bar {
    0%   { transform: scaleX(0); transform-origin: left; }
    20%  { transform: scaleX(0.3); transform-origin: left; }
    60%  { transform: scaleX(0.7); transform-origin: left; }
    100% { transform: scaleX(0.95); transform-origin: left; }
}

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--color-scrollbar) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-scrollbar); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-scrollbar-hover); }

/* YAML editor line numbers — hide scrollbar but allow programmatic scroll */
.yaml-line-gutter { scrollbar-width: none; -ms-overflow-style: none; overflow-y: auto; }
.yaml-line-gutter::-webkit-scrollbar { display: none; }

/* View Transition API */
@view-transition {
    navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.25s;
}

/* ============================================
   MODERN EFFECTS
   ============================================ */

/* Glass morphism panel */
.glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

/* Focus glow ring */
.glow-ring {
    box-shadow: 0 0 0 1px var(--color-brand),
                0 0 12px rgba(124, 58, 237, 0.2);
}

/* Gradient border via ::before pseudo */
.gradient-border {
    position: relative;
}
.gradient-border::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: var(--gradient-brand);
    z-index: -1;
    opacity: 0;
    transition: opacity var(--transition-normal);
}
.gradient-border:hover::before {
    opacity: 0.2;
}

/* Ambient card glow on hover */
.card-glow {
    transition: all 0.25s var(--spring);
}
.card-glow:hover {
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

/* Gradient shine sweep on hover */
.shine-hover {
    position: relative;
    overflow: hidden;
}
.shine-hover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.04) 50%, transparent 60%);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
    pointer-events: none;
}
.shine-hover:hover::after {
    transform: translateX(100%);
}

/* ============================================
   LAYOUT
   ============================================ */

/* Notebook 3-panel layout */
.notebook-layout {
    display: grid;
    grid-template-columns: var(--panel-left) 1fr var(--panel-right);
    height: 100%;
}
.notebook-panel {
    overflow: hidden;
    border-right: 1px solid var(--color-border);
}
.notebook-panel:last-child { border-right: none; }

/* Two-world slide container */
.worlds-container {
    display: flex;
    width: 200%;
    height: calc(100vh - var(--topbar-height));
    transition: transform 400ms var(--spring);
}
.worlds-container.show-actions {
    transform: translateX(-50%);
}
.world {
    width: 50%;
    height: 100%;
    flex-shrink: 0;
    overflow: hidden;
}

/* Actions world layout */
.actions-layout {
    display: grid;
    grid-template-columns: var(--actions-sidebar) 1fr;
    grid-template-rows: auto 1fr;
    height: 100%;
    background: var(--color-base);
}
.actions-header {
    grid-column: 1 / -1;
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-panel);
}
.actions-sidebar {
    border-right: 1px solid var(--color-border);
    background: var(--color-panel);
    overflow-y: auto;
    padding: 12px;
}
.actions-main {
    overflow-y: auto;
    padding: 16px;
}

/* World toggle pill */
.world-toggle {
    display: inline-flex;
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    padding: 2px;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}
.world-toggle:hover { border-color: var(--color-brand); }
.world-toggle span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.world-toggle span.active {
    background: var(--gradient-brand);
    color: var(--color-text-inverse);
}

/* Action card */
.action-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 12px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.action-card:hover { border-color: var(--color-border-strong); }
.action-card-critical { border-left-color: var(--color-priority-critical); }
.action-card-critical:hover { box-shadow: 0 0 16px rgba(239, 68, 68, 0.08); }
.action-card-high    { border-left-color: var(--color-priority-high); }
.action-card-medium  { border-left-color: var(--color-priority-medium); }
.action-card-low     { border-left-color: var(--color-priority-low); }

/* Priority badge */
.priority-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: var(--radius-full);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.priority-critical { background: var(--color-priority-critical-bg); color: var(--color-priority-critical); }
.priority-high     { background: var(--color-priority-high-bg);     color: var(--color-priority-high); }
.priority-medium   { background: var(--color-priority-medium-bg);   color: var(--color-priority-medium); }
.priority-low      { background: var(--color-priority-low-bg);      color: var(--color-priority-low); }

/* Connector badge */
.connector-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
}
.connector-badge-api     { background: var(--color-connector-api-bg);     color: var(--color-connector-api);     border-color: rgba(59,130,246,0.3); }
.connector-badge-mcp     { background: var(--color-connector-mcp-bg);     color: var(--color-connector-mcp);     border-color: rgba(124,58,237,0.3); }
.connector-badge-agent   { background: var(--color-connector-agent-bg);   color: var(--color-connector-agent);   border-color: rgba(16,185,129,0.3); }
.connector-badge-manual  { background: var(--color-connector-manual-bg);  color: var(--color-connector-manual);  border-color: rgba(107,114,128,0.3); }

/* Provenance chip */
.provenance-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--color-surface-50);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-md);
    padding: 2px 8px;
    font-size: 10px;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: border-color var(--transition-fast), color var(--transition-fast);
}
.provenance-chip:hover {
    border-color: var(--color-brand);
    color: var(--color-text);
}

/* Status stepper */
.status-stepper {
    display: flex;
    align-items: center;
    gap: 0;
}
.status-stepper .step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-surface-200);
    flex-shrink: 0;
    transition: background var(--transition-fast);
}
.status-stepper .step-line {
    width: 16px;
    height: 2px;
    background: var(--color-surface-200);
    flex-shrink: 0;
}
.status-stepper .step-dot.past       { background: rgba(124, 58, 237, 0.4); }
.status-stepper .step-line.past      { background: rgba(124, 58, 237, 0.4); }
.status-stepper .step-dot.active     { background: var(--color-brand); }
.status-stepper .step-dot.completed  { background: var(--color-status-completed); }
.status-stepper .step-dot.failed     { background: var(--color-status-failed); }
.status-stepper .step-dot.expired    { background: var(--color-text-secondary); opacity: 0.5; }

/* Target row */
.target-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--color-surface-50);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-md);
    margin-top: 6px;
}

/* Dispatch button */
.dispatch-btn {
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    background: var(--gradient-brand);
    color: var(--color-text-inverse);
    border: none;
    cursor: pointer;
    transition: opacity var(--transition-fast);
    white-space: nowrap;
}
.dispatch-btn:hover { opacity: 0.9; }
.dispatch-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.dispatch-btn-completed {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}
.dispatch-btn-manual {
    background: var(--color-surface-100);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border-muted);
}

/* Connector card (sidebar) */
.connector-card {
    padding: 8px 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-md);
    margin-bottom: 6px;
}

/* Filter select in actions sidebar */
.actions-filter-select {
    width: 100%;
    background: var(--color-surface-50);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-md);
    padding: 4px 8px;
    font-size: 11px;
    color: var(--color-text);
    outline: none;
    transition: border-color var(--transition-fast);
}
.actions-filter-select:focus { border-color: var(--color-brand); }

/* Progress bar (sidebar summary) */
.actions-progress {
    height: 6px;
    background: var(--color-surface-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.actions-progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--gradient-brand);
    transition: width 400ms var(--spring);
}

/* Panel header — glass tint */
.panel-header {
    background: color-mix(in srgb, var(--color-panel) 92%, var(--color-brand) 2%);
    border-bottom: 1px solid var(--color-border);
}

/* ============================================
   COMPONENTS
   ============================================ */

/* Source item */
.source-item {
    transition: all var(--transition-fast);
}
.source-item:hover {
    background: var(--color-brand-subtle);
}
.source-item.source-selected {
    box-shadow: inset 3px 0 0 var(--color-brand);
    background: var(--color-brand-subtle);
}

/* Chat bubbles */
.chat-bubble-user {
    background: var(--gradient-brand);
    color: var(--color-text-inverse);
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 2px 12px rgba(124, 58, 237, 0.2);
}
.chat-bubble-assistant {
    background: var(--color-chat-assistant);
    border-radius: 20px 20px 20px 4px;
    border: 1px solid var(--color-border);
    line-height: 1.6;
}

/* Chat message actions */
.chat-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border);
}

.chat-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    color: var(--color-text-subtle);
    transition: all var(--transition-fast);
    cursor: pointer;
    background: none;
    border: none;
}
.chat-action-btn:hover {
    color: var(--color-text-muted);
    background: var(--color-surface-50);
}
.chat-action-btn.active {
    color: var(--color-brand);
}
.chat-action-btn svg {
    width: 14px;
    height: 14px;
}

.chat-action-save {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border-muted);
    background: none;
    color: var(--color-text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.chat-action-save:hover {
    border-color: var(--color-brand);
    color: var(--color-text);
    background: var(--color-brand-subtle);
}
.chat-action-save svg {
    width: 14px;
    height: 14px;
}

/* Topic chip */
.topic-chip {
    display: inline-block;
    padding: 6px 14px;
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-full);
    font-size: 13px;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s var(--spring);
}
.topic-chip:hover {
    border-color: transparent;
    background: var(--gradient-brand);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

/* Modal overlay */
.modal-overlay {
    background: var(--color-overlay);
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
}

/* Notebook card */
.notebook-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.25s var(--spring);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.notebook-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-brand);
    opacity: 0;
    transition: opacity var(--transition-normal);
}
.notebook-card:hover {
    border-color: var(--color-border-strong);
    background: var(--color-surface-hover);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    transform: translateY(-2px);
}
.notebook-card:hover::after {
    opacity: 1;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--color-text-subtle);
    text-align: center;
}

/* Report item */
.report-item {
    background: var(--color-chat-assistant);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    transition: all var(--transition-fast);
    border-left: 3px solid var(--color-type-report);
}
.report-item:hover {
    border-color: var(--color-border-strong);
    border-left-color: var(--color-brand);
    background: var(--color-surface-hover);
}

/* Note item */
.note-item {
    background: var(--color-chat-assistant);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
}
.note-item:hover {
    border-color: var(--color-border-strong);
    border-left-color: var(--color-brand);
}

/* ============================================
   PROSE (Markdown content)
   ============================================ */

.prose-dark {
    color: var(--color-text);
    line-height: 1.7;
}

.prose-dark h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border-muted);
}
.prose-dark h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 1.25rem 0 0.5rem;
}
.prose-dark h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 1rem 0 0.4rem;
}
.prose-dark h4,
.prose-dark h5,
.prose-dark h6 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0.75rem 0 0.3rem;
}

.prose-dark > h1:first-child,
.prose-dark > h2:first-child,
.prose-dark > h3:first-child {
    margin-top: 0;
}

.prose-dark p {
    margin: 0.6rem 0;
}

.prose-dark a {
    color: var(--color-brand);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.prose-dark a:hover {
    color: var(--color-brand-hover);
}

.prose-dark strong {
    color: var(--color-text);
    font-weight: 600;
}

.prose-dark ul,
.prose-dark ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}
.prose-dark ul { list-style-type: disc; }
.prose-dark ol { list-style-type: decimal; }
.prose-dark li { margin: 0.25rem 0; }
.prose-dark li > ul,
.prose-dark li > ol { margin: 0.15rem 0; }

.prose-dark blockquote {
    border-left: 3px solid var(--color-brand);
    padding: 0.5rem 0 0.5rem 1rem;
    margin: 0.75rem 0;
    color: var(--color-text-muted);
    background: var(--color-brand-subtle);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.prose-dark blockquote p { margin: 0.25rem 0; }

.prose-dark code {
    background: var(--color-surface-100);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: 0.85em;
    color: var(--color-brand);
}

.prose-dark pre {
    background: var(--color-surface-50);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    overflow-x: auto;
    font-size: 0.8rem;
    line-height: 1.5;
}
.prose-dark pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: var(--color-text);
}

.prose-dark table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.85rem;
}
.prose-dark th {
    background: var(--color-surface-50);
    font-weight: 600;
    color: var(--color-text);
    text-align: left;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border-muted);
}
.prose-dark td {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--color-border-muted);
    color: var(--color-text);
}
.prose-dark tr:nth-child(even) td {
    background: var(--color-brand-subtle);
}

.prose-dark hr {
    border: none;
    border-top: 1px solid var(--color-border-muted);
    margin: 1.25rem 0;
}

.prose-dark img {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin: 0.75rem 0;
}

/* Light theme prose overrides */
html.light .prose-dark { color: var(--color-text); }
html.light .prose-dark h1,
html.light .prose-dark h2,
html.light .prose-dark h3,
html.light .prose-dark h4 { color: var(--color-text); }
html.light .prose-dark a { color: var(--color-brand); }
html.light .prose-dark strong { color: var(--color-text); }
html.light .prose-dark code {
    background: var(--color-surface-50);
    color: #7c3aed;
}
html.light .prose-dark pre {
    background: var(--color-surface-50);
    border-color: var(--color-border-muted);
}
html.light .prose-dark pre code { color: var(--color-text); }
html.light .prose-dark blockquote {
    border-color: var(--color-brand);
    background: var(--color-surface-50);
    color: var(--color-text-muted);
}
html.light .prose-dark th {
    background: var(--color-surface-50);
    border-color: var(--color-border);
    color: var(--color-text);
}
html.light .prose-dark td {
    border-color: var(--color-border-muted);
}
html.light .prose-dark tr:nth-child(even) td {
    background: var(--color-surface-50);
}

/* Citation badges */
.citation-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    background: var(--color-brand);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    border: none;
    vertical-align: super;
    margin: 0 1px;
    transition: all var(--transition-fast);
    position: relative;
}
.citation-badge:hover {
    background: var(--color-brand-hover);
    transform: scale(1.15);
}

/* Citation tooltip */
.citation-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-surface-100);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 400;
    color: var(--color-text-muted);
    max-width: 300px;
    white-space: normal;
    line-height: 1.4;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    pointer-events: none;
}
.citation-tooltip strong {
    display: block;
    color: var(--color-text);
    margin-bottom: 2px;
}
.citation-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--color-border-strong);
}

/* Citation popup overlay */
.citation-popup-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in 0.15s ease-out;
}
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Citation popup card */
.citation-popup {
    background: var(--color-panel);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-xl);
    width: min(600px, 90vw);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: popup-in 0.2s ease-out;
}
@keyframes popup-in {
    from { transform: scale(0.95) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.citation-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.citation-popup-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 12px;
}
.citation-popup-close {
    background: none;
    border: none;
    color: var(--color-text-subtle);
    font-size: 22px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}
.citation-popup-close:hover {
    background: var(--color-surface-50);
    color: var(--color-text);
}

.citation-popup-body {
    overflow-y: auto;
    padding: 20px;
    flex: 1;
}
.citation-popup-content {
    font-size: 13px;
    line-height: 1.7;
    color: var(--color-text-muted);
    white-space: pre-wrap;
    word-break: break-word;
}
.citation-popup-loading,
.citation-popup-error {
    font-size: 13px;
    color: var(--color-text-subtle);
    text-align: center;
    padding: 20px;
}

/* Highlighted citation passage */
.citation-highlight {
    background: rgba(124, 58, 237, 0.2);
    color: var(--color-text);
    border-radius: 2px;
    padding: 1px 0;
    border-bottom: 2px solid var(--color-brand);
}
.citation-ellipsis {
    color: var(--color-text-subtle);
}

/* Source highlight when citation is clicked */
.source-item.source-highlighted {
    background: var(--color-brand-10);
    box-shadow: inset 3px 0 0 var(--color-brand);
    animation: source-highlight-pulse 2s ease-out;
}
@keyframes source-highlight-pulse {
    0% { background: rgba(124, 58, 237, 0.2); }
    100% { background: var(--color-brand-10); }
}

/* Inspector table */
.inspector-table th,
.inspector-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   CONFIG ENGINE
   ============================================ */

.config-input-item {
    transition: all var(--transition-fast);
}
.config-input-item:hover {
    border-color: var(--color-border-strong);
}

.config-output-btn {
    transition: all var(--transition-fast);
}
.config-output-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.config-toggle {
    cursor: pointer;
    border: none;
}
.config-toggle span {
    transition: transform var(--transition-fast);
}

/* ============================================
   INTERACTIVE STATES
   ============================================ */

/* Focus ring for keyboard navigation */
.topic-chip:focus-visible,
.notebook-card:focus-visible,
.source-item:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}

/* Active/pressed states */
.topic-chip:active { transform: scale(0.98); }
.notebook-card:active { transform: scale(0.99); }

/* ============================================
   ANIMATIONS
   ============================================ */

/* Toast */
.toast {
    animation: toast-in 0.3s var(--spring);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
@keyframes toast-in {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--color-surface-50) 25%, var(--color-surface-100) 50%, var(--color-surface-50) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s infinite;
    border-radius: var(--radius-md);
}
@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Typing indicator */
.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-brand);
    animation: typing-bounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ============================================
   TOPBAR
   ============================================ */
.topbar-glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid color-mix(in srgb, var(--color-border) 60%, transparent);
}

/* ============================================
   MODAL ENHANCEMENTS
   ============================================ */
.modal-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}
.modal-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-brand);
}

/* Tab pill active state (gradient) */
.tab-pill-active {
    background: var(--gradient-brand);
    color: #fff;
}

/* Source type card (add-source modal) */
.source-type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 12px;
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--accent) 6%, var(--color-surface));
    border: 1px solid color-mix(in srgb, var(--accent) 12%, transparent);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}
.source-type-card:hover {
    background: color-mix(in srgb, var(--accent) 12%, var(--color-surface));
    border-color: color-mix(in srgb, var(--accent) 28%, transparent);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 15%, transparent);
}
.source-type-card-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--accent) 14%, var(--color-surface));
    color: var(--accent);
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

.mobile-tab-bar { display: none; }

@media (max-width: 767px) {
    .notebook-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        height: calc(100% - 48px);
    }
    .notebook-panel,
    .notebook-layout > div {
        border-right: none;
    }
    .notebook-layout > .mobile-panel {
        display: none;
    }
    .notebook-layout > .mobile-panel.active {
        display: flex;
    }

    .mobile-tab-bar {
        display: flex;
        height: 48px;
        background: var(--glass-bg);
        backdrop-filter: var(--glass-blur);
        -webkit-backdrop-filter: var(--glass-blur);
        border-top: 1px solid var(--color-border);
    }
    .mobile-tab-bar button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        font-size: 10px;
        color: var(--color-text-subtle);
        transition: color var(--transition-fast);
    }
    .mobile-tab-bar button.active {
        color: var(--color-brand);
    }
    .mobile-tab-bar button svg {
        width: 18px;
        height: 18px;
    }

    /* Actions world mobile */
    .worlds-container {
        width: 100%;
        transition: none;
    }
    .worlds-container.show-actions { transform: none; }
    .worlds-container .world-intelligence { width: 100%; }
    .worlds-container .world-actions { display: none; width: 100%; }
    .worlds-container.show-actions .world-intelligence { display: none; }
    .worlds-container.show-actions .world-actions { display: flex; flex-direction: column; }

    .actions-layout {
        grid-template-columns: 1fr;
    }
    .actions-sidebar {
        display: none;
    }
}

/* Report new-item highlight */
@keyframes report-highlight {
    from { background-color: rgba(124, 58, 237, 0.18); }
    to   { background-color: transparent; }
}
.animate-report-new {
    animation: report-highlight 1.5s ease-out;
}
