/* =====================================================================
   CowAgent Console Styles
   =====================================================================
   Refined visual layer: calm surfaces, softer contrast, consistent rhythm.
   Keep this block isolated so it is easy to reapply after upstream updates.
   ===================================================================== */

:root {
    --cow-surface: #ffffff;
    --cow-surface-soft: #f8fafb;
    --cow-border: rgba(15, 23, 42, 0.08);
    --cow-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 14px rgba(15, 23, 42, 0.035);
    --cow-shadow-md: 0 14px 34px rgba(15, 23, 42, 0.09), 0 2px 8px rgba(15, 23, 42, 0.04);
    --cow-radius: 12px;
    --cow-radius-lg: 16px;
}

.dark {
    --cow-surface: #17191c;
    --cow-surface-soft: #1d2024;
    --cow-border: rgba(255, 255, 255, 0.085);
    --cow-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.18), 0 6px 18px rgba(0, 0, 0, 0.12);
    --cow-shadow-md: 0 18px 42px rgba(0, 0, 0, 0.30), 0 2px 10px rgba(0, 0, 0, 0.18);
}

/* Calm the global canvas without changing layout dimensions. */
body {
    letter-spacing: -0.006em;
    -webkit-font-smoothing: antialiased;
}

/* Collapsible desktop sidebar */
#sidebar {
    --cow-sidebar-width: 13rem;
    --cow-sidebar-collapsed-width: 4.25rem;
    width: var(--cow-sidebar-width) !important;
    transition: width 220ms ease-in-out, transform 300ms ease-in-out !important;
}
#sidebar.sidebar-collapsed {
    width: var(--cow-sidebar-collapsed-width) !important;
}
#sidebar.sidebar-collapsed .sidebar-brand-text,
#sidebar.sidebar-collapsed .menu-group > button span,
#sidebar.sidebar-collapsed .menu-group > button .chevron,
#sidebar.sidebar-collapsed .sidebar-item span,
#sidebar.sidebar-collapsed #sidebar-version {
    display: none;
}
#sidebar.sidebar-collapsed > div:first-child {
    padding-left: 0.625rem;
    padding-right: 0.625rem;
    justify-content: center;
}
#sidebar.sidebar-collapsed .sidebar-collapse-btn {
    margin-left: 0;
}
#sidebar.sidebar-collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}
#sidebar.sidebar-collapsed nav {
    padding-left: 0.625rem;
    padding-right: 0.625rem;
}
#sidebar.sidebar-collapsed .menu-group > button {
    display: none;
}
#sidebar.sidebar-collapsed .menu-group-items {
    padding-left: 0;
}
#sidebar.sidebar-collapsed .sidebar-item {
    justify-content: center;
    gap: 0;
    padding-left: 0;
    padding-right: 0;
    position: relative;
}
#sidebar.sidebar-collapsed .sidebar-item .item-icon {
    width: 2.5rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* Sidebar labels use the body-level tooltip portal below. Keeping the
   tooltip outside #sidebar avoids clipping by the navigation scroller. */
#sidebar.sidebar-collapsed .sidebar-item.active {
    box-shadow: inset 0 0 0 1px rgba(74,190,110,.22);
}
#sidebar.sidebar-collapsed > div:last-child {
    padding-left: 0.625rem;
    padding-right: 0.625rem;
}
@media (max-width: 1023px) {
    #sidebar { width: 13rem !important; }
    #sidebar.sidebar-collapsed { width: 13rem !important; }
    #sidebar-collapse-btn { display: none; }
}

/* Softer navigation hierarchy */
#sidebar {
    background: linear-gradient(180deg, #151719 0%, #101112 100%) !important;
    border-right: 1px solid rgba(255,255,255,0.06);
}
#sidebar > div:first-child {
    border-bottom-color: rgba(255,255,255,0.07) !important;
}
.sidebar-item {
    position: relative;
    color: #9ca3af;
}
.sidebar-item.active {
    background: linear-gradient(90deg, rgba(74,190,110,0.16), rgba(74,190,110,0.06)) !important;
    color: #f1f5f9 !important;
    box-shadow: inset 2px 0 0 #4abe6e;
}
.sidebar-item.active .item-icon { color: #74d995; }
.sidebar-item:hover:not(.active) { background: rgba(255,255,255,0.055) !important; }

/* Shared elevated surfaces used by cards, dialogs and menus. */
.confirm-modal,
.cfg-dropdown-menu,
.attach-menu,
.slash-menu,
.knowledge-graph-tooltip {
    border-color: var(--cow-border) !important;
    box-shadow: var(--cow-shadow-md) !important;
}

/* More composed configuration controls. */
#view-config input[type="text"],
#view-config input[type="number"],
#view-config input[type="password"],
#view-config textarea,
#view-config select {
    border-radius: 10px;
    background-color: var(--cow-surface-soft);
    border-color: var(--cow-border);
}
#view-config input:focus,
#view-config textarea:focus,
#view-config select:focus {
    border-color: rgba(74,190,110,0.75) !important;
    box-shadow: 0 0 0 4px rgba(74,190,110,0.10) !important;
}
.cfg-dropdown-selected {
    border-radius: 10px;
    background: var(--cow-surface-soft);
    border-color: var(--cow-border);
}
.cfg-dropdown-menu { border-radius: 12px; padding: 5px; }
.cfg-dropdown-item { border-radius: 8px; padding: 9px 10px; }

/* Keep chat bubbles and input visually quiet and intentional. */
#chat-input {
    border-radius: 14px !important;
    background: var(--cow-surface-soft);
    border-color: var(--cow-border) !important;
}
#chat-input:focus {
    border-color: rgba(74,190,110,0.72) !important;
    box-shadow: 0 0 0 4px rgba(74,190,110,0.09) !important;
}

/* MCP workspace: Apple-like calm surfaces with clear service hierarchy. */
.mcp-view { background: linear-gradient(180deg, #f7f8fa 0%, #fbfbfc 48%, #f5f6f8 100%); }
.dark .mcp-view { background: linear-gradient(180deg, #111315 0%, #151719 100%); }
.mcp-hero { display:flex; align-items:center; gap:16px; }
.mcp-hero-mark { width:52px; height:52px; display:flex; align-items:center; justify-content:center; flex:none; border-radius:16px; color:#fff; background:linear-gradient(145deg,#64748b,#1e293b); box-shadow:0 8px 20px rgba(30,41,59,.22); font-size:21px; }
.mcp-beta { display:inline-flex; align-items:center; padding:5px 9px; border:1px solid #dbe1e8; border-radius:999px; color:#64748b; background:rgba(255,255,255,.72); font-size:11px; font-weight:600; letter-spacing:.01em; }
.dark .mcp-beta { border-color:#30353b; background:#1c2024; color:#aab3bf; }
.mcp-primary-button,.mcp-secondary-button { display:inline-flex; align-items:center; justify-content:center; gap:8px; border:0; border-radius:10px; cursor:pointer; font-size:13px; font-weight:600; transition:transform .18s, box-shadow .18s, background .18s; }
.mcp-primary-button { padding:10px 15px; color:#fff; background:#1d1d1f; box-shadow:0 4px 12px rgba(0,0,0,.14); }
.mcp-primary-button:hover { background:#3a3a3c; transform:translateY(-1px); box-shadow:0 7px 18px rgba(0,0,0,.18); }
.dark .mcp-primary-button { background:#f5f5f7; color:#1d1d1f; }
.dark .mcp-primary-button:hover { background:#fff; }
.mcp-source-bar { display:flex; align-items:center; gap:12px; padding:14px 16px; border:1px solid #e3e6eb; border-radius:14px; background:rgba(255,255,255,.8); box-shadow:0 2px 8px rgba(15,23,42,.035); }
.dark .mcp-source-bar { border-color:#2c3137; background:#1b1e21; }
.mcp-source-icon { width:32px; height:32px; display:flex; align-items:center; justify-content:center; flex:none; border-radius:10px; color:#2563eb; background:#eaf2ff; }
.dark .mcp-source-icon { color:#8ab4ff; background:#1d3152; }
.mcp-source-bar strong { display:block; color:#1d1d1f; font-size:13px; font-weight:600; }
.dark .mcp-source-bar strong { color:#f5f5f7; }
.mcp-source-bar p { margin-top:3px; color:#86868b; font-size:12px; line-height:1.45; }
.mcp-source-label { flex:none; padding:5px 8px; border-radius:6px; color:#6e6e73; background:#f1f2f4; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:11px; }
.dark .mcp-source-label { color:#a1a1a6; background:#292d32; }
.mcp-section-label { display:flex; align-items:center; gap:8px; color:#1d1d1f; font-size:13px; font-weight:600; }
.dark .mcp-section-label { color:#f5f5f7; }
.mcp-count { min-width:21px; padding:2px 6px; border-radius:999px; color:#6e6e73; background:#e9ebef; text-align:center; font-size:11px; font-weight:600; }
.dark .mcp-count { color:#c5c7ca; background:#30343a; }
.mcp-runtime-label { color:#5f6368; font-size:11px; }
.mcp-runtime-label i { margin-right:6px; color:#34c759; font-size:8px; }
.dark .mcp-runtime-label { color:#a1a1a6; }
.mcp-server-card { display:flex; align-items:center; gap:14px; min-height:76px; padding:14px 16px; border:1px solid #e1e4e8; border-radius:14px; background:rgba(255,255,255,.92); box-shadow:0 3px 12px rgba(15,23,42,.045); transition:transform .18s, box-shadow .18s, border-color .18s; }
.mcp-server-card:hover { transform:translateY(-1px); border-color:#cbd2db; box-shadow:0 8px 22px rgba(15,23,42,.08); }
.dark .mcp-server-card { border-color:#2c3137; background:#1b1e21; box-shadow:0 4px 18px rgba(0,0,0,.16); }
.mcp-server-icon { width:40px; height:40px; display:flex; align-items:center; justify-content:center; flex:none; border-radius:12px; color:#2563eb; background:#edf3ff; font-size:16px; }
.dark .mcp-server-icon { color:#9abfff; background:#20375d; }
.mcp-server-heading { display:flex; align-items:center; gap:9px; min-width:0; }
.mcp-server-name { color:#1d1d1f; font-size:14px; font-weight:600; }
.dark .mcp-server-name { color:#f5f5f7; }
.mcp-transport { padding:3px 7px; border-radius:5px; color:#6e6e73; background:#f1f2f4; font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:.03em; }
.dark .mcp-transport { color:#b0b3b8; background:#292d32; }
.mcp-endpoint { margin-top:5px; overflow:hidden; color:#86868b; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:11px; text-overflow:ellipsis; white-space:nowrap; }
.mcp-status { display:flex; align-items:center; gap:6px; flex:none; color:#34c759; font-size:11px; }
.mcp-status i { font-size:7px; }
.mcp-switch { position:relative; display:inline-flex; width:36px; height:22px; flex:none; cursor:pointer; }
.mcp-switch span { width:36px; height:22px; border-radius:999px; background:#d1d1d6; transition:background .2s; }
.mcp-switch span:after { content:''; position:absolute; top:3px; left:3px; width:16px; height:16px; border-radius:50%; background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.22); transition:transform .2s; }
.mcp-switch input:checked + span { background:#34c759; }
.mcp-switch input:checked + span:after { transform:translateX(14px); }
.mcp-icon-button,.mcp-close-button { width:30px; height:30px; display:flex; align-items:center; justify-content:center; flex:none; border:0; border-radius:8px; color:#8e8e93; background:transparent; cursor:pointer; transition:background .15s,color .15s; }
.mcp-icon-button:hover,.mcp-close-button:hover { color:#1d1d1f; background:#f1f2f4; }
.mcp-icon-button.danger:hover { color:#ff3b30; background:#fff0ef; }
.dark .mcp-icon-button:hover,.dark .mcp-close-button:hover { color:#fff; background:#30343a; }
.mcp-empty-state { padding:48px 24px; border:1px dashed #d7dbe1; border-radius:16px; background:rgba(255,255,255,.52); text-align:center; }
.dark .mcp-empty-state { border-color:#353a41; background:rgba(255,255,255,.025); }
.mcp-empty-icon { width:52px; height:52px; display:flex; align-items:center; justify-content:center; margin:0 auto 14px; border-radius:16px; color:#8e8e93; background:#eef0f3; font-size:20px; }
.dark .mcp-empty-icon { color:#a1a1a6; background:#292d32; }
.mcp-empty-state h3 { color:#1d1d1f; font-size:15px; font-weight:600; }
.dark .mcp-empty-state h3 { color:#f5f5f7; }
.mcp-empty-state p { margin:6px 0 17px; color:#86868b; font-size:12px; }
.mcp-secondary-button { padding:9px 13px; color:#1d1d1f; background:#fff; border:1px solid #d7dbe1; }
.mcp-secondary-button:hover { background:#f5f5f7; }
.dark .mcp-secondary-button { color:#f5f5f7; background:#25282c; border-color:#3a4048; }
.mcp-editor-card { padding:22px; border:1px solid #e1e4e8; border-radius:16px; background:rgba(255,255,255,.95); box-shadow:0 10px 30px rgba(15,23,42,.08); }
.dark .mcp-editor-card { border-color:#30353b; background:#1b1e21; }
.mcp-field-label { display:block; margin-bottom:8px; color:#6e6e73; font-size:12px; font-weight:600; }
.dark .mcp-field-label { color:#b0b3b8; }
.mcp-field { width:100%; padding:10px 12px; border:1px solid #d7dbe1; border-radius:10px; outline:none; color:#1d1d1f; background:#fbfbfc; font-size:13px; transition:border .15s,box-shadow .15s; }
.mcp-field:focus { border-color:#8ab4ff; box-shadow:0 0 0 4px rgba(37,99,235,.11); }
.dark .mcp-field { border-color:#3a4048; color:#f5f5f7; background:#24272b; }
.mcp-text-button { padding:10px 12px; border:0; color:#6e6e73; background:transparent; cursor:pointer; font-size:13px; }
.mcp-text-button:hover { color:#1d1d1f; }
.dark .mcp-text-button:hover { color:#fff; }
@media (max-width: 640px) { .mcp-hero { align-items:flex-start; flex-wrap:wrap; } .mcp-hero .mcp-primary-button { margin-left:68px; } .mcp-status { display:none; } .mcp-source-label { display:none; } }

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Animations */
@keyframes pulseDot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: #94a3b8 transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }
.dark ::-webkit-scrollbar-thumb { background: #475569; }
.dark ::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Generic Tooltip (via data-tooltip attribute) */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    white-space: nowrap;
    background: #1e293b;
    color: #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 100;
}
[data-tooltip-pos="bottom"]::after {
    bottom: auto;
    top: calc(100% + 8px);
}
.dark [data-tooltip]::after {
    background: #334155;
    color: #f1f5f9;
}
[data-tooltip]:hover::after {
    opacity: 1;
}
[data-tooltip=""]:hover::after {
    display: none;
}

/* Sidebar */
.sidebar-item.active {
    background: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
}
.sidebar-item.active .item-icon { color: #4ABE6E; }

/* Session Panel */
.session-panel {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #fafafa;
    border-right: 1px solid #e5e7eb;
    height: 100vh;
    overflow: hidden;
    transition: width 0.2s ease;
}
.dark .session-panel {
    background: #111111;
    border-right-color: rgba(255, 255, 255, 0.08);
}
.session-panel.hidden { display: none; }
.session-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.dark .session-panel-header { border-bottom-color: rgba(255, 255, 255, 0.08); }
.session-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}
.dark .session-panel-title { color: #d1d5db; }
.session-panel-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: none;
    background: none;
    color: #9ca3af;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-size: 12px;
}
.session-panel-close:hover {
    background: #f3f4f6;
    color: #374151;
}
.dark .session-panel-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e5e5;
}
.session-panel-new {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 12px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px dashed #d1d5db;
    background: none;
    color: #6b7280;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.session-panel-new:hover {
    border-color: #9ca3af;
    color: #374151;
    background: #f9fafb;
}
.dark .session-panel-new {
    border-color: rgba(255, 255, 255, 0.12);
    color: #9ca3af;
}
.dark .session-panel-new:hover {
    border-color: rgba(255, 255, 255, 0.25);
    color: #e5e5e5;
    background: rgba(255, 255, 255, 0.04);
}

/* Session List */
.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
    scrollbar-width: none;
}
.session-list:hover { scrollbar-width: thin; }
.session-list::-webkit-scrollbar { width: 4px; background: transparent; }
.session-list::-webkit-scrollbar-thumb { background: transparent; border-radius: 2px; }
.session-list:hover::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); }
.dark .session-list:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
.session-group-label {
    padding: 10px 8px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
}
.dark .session-group-label { color: #525252; }
.session-empty {
    padding: 20px 12px;
    text-align: center;
    font-size: 13px;
    color: #9ca3af;
}
.session-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin: 1px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    color: #6b7280;
    font-size: 13px;
    position: relative;
}
.dark .session-item { color: #a3a3a3; }
.session-item:hover {
    background: #f3f4f6;
    color: #111827;
}
.dark .session-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e5e5e5;
}
.session-item.active {
    background: #e5e7eb;
    color: #111827;
}
.dark .session-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}
.session-icon {
    flex-shrink: 0;
    font-size: 11px;
    color: #9ca3af;
    width: 16px;
    text-align: center;
}
.dark .session-icon { color: #525252; }
.session-item.active .session-icon { color: #4ABE6E; }
.session-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.session-delete {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    font-size: 10px;
    color: #9ca3af;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.session-item:hover .session-delete { opacity: 1; }
.session-delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}
.dark .session-delete:hover { background: rgba(239, 68, 68, 0.15); }

/* Rename button: shares the look of the delete button, sits to its left.
   Negative right margin tightens the gap to the delete button only. */
.session-rename {
    flex-shrink: 0;
    margin-right: -6px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #9ca3af;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.session-item:hover .session-rename { opacity: 1; }
.session-rename:hover {
    color: #4ABE6E;
    background: rgba(74, 190, 110, 0.12);
}
.dark .session-rename:hover { background: rgba(74, 190, 110, 0.18); }

/* Inline title editor */
.session-title-input {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-family: inherit;
    color: #111827;
    background: #ffffff;
    border: 1px solid #4ABE6E;
    border-radius: 6px;
    padding: 2px 6px;
    outline: none;
}
.dark .session-title-input {
    color: #e5e5e5;
    background: rgba(255, 255, 255, 0.06);
    border-color: #4ABE6E;
}

/* Context Divider */
.context-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: #9ca3af;
}
.context-divider::before, .context-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #d1d5db, transparent);
}
.dark .context-divider::before, .dark .context-divider::after {
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.12), transparent);
}
.context-divider span {
    font-size: 12px;
    white-space: nowrap;
    color: #9ca3af;
}

/* Confirm Modal */
.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.confirm-overlay.visible { opacity: 1; }
.confirm-modal {
    background: #fff;
    border-radius: 14px;
    width: 380px;
    max-width: 90vw;
    padding: 28px 24px 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    transform: scale(0.92);
    transition: transform 0.2s ease;
}
.confirm-overlay.visible .confirm-modal { transform: scale(1); }
.dark .confirm-modal {
    background: #1e1e1e;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.confirm-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}
.dark .confirm-title { color: #e5e7eb; }
.confirm-message {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    margin-bottom: 24px;
}
.dark .confirm-message { color: #9ca3af; }
.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.confirm-btn {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
}
.confirm-btn-cancel {
    background: #f3f4f6;
    color: #374151;
}
.confirm-btn-cancel:hover { background: #e5e7eb; }
.dark .confirm-btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: #d1d5db;
}
.dark .confirm-btn-cancel:hover { background: rgba(255, 255, 255, 0.14); }
.confirm-btn-ok {
    background: #ef4444;
    color: #fff;
}
.confirm-btn-ok:hover { background: #dc2626; }

/* Session panel overlay (mobile only, click to close) */
.session-panel-overlay {
    display: none;
}
@media (max-width: 768px) {
    .session-panel-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 44;
        background: rgba(0, 0, 0, 0.3);
    }
    .session-panel-overlay.hidden {
        display: none;
    }
}

/* Mobile: session panel as overlay */
@media (max-width: 768px) {
    .session-panel {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 45;
        width: 220px;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }
    .dark .session-panel {
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }
}

/* Menu Groups */
.menu-group-items { max-height: 0; overflow: hidden; transition: max-height 0.25s ease-out; }
.menu-group.open .menu-group-items { max-height: 2000px; transition: max-height 0.35s ease-in; }
.menu-group .chevron { transition: transform 0.25s ease; }
.menu-group.open .chevron { transform: rotate(90deg); }

/* View Switching */
.view { display: none; height: 100%; }
.view.active { display: flex; flex-direction: column; }

/* Chat view is split horizontally: conversation + workspace panel */
#view-chat.active { flex-direction: row; }
.chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Markdown Content */
.msg-content p { margin: 0.5em 0; line-height: 1.7; }
.msg-content p:first-child { margin-top: 0; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content h1, .msg-content h2, .msg-content h3,
.msg-content h4, .msg-content h5, .msg-content h6 {
    margin-top: 1.2em; margin-bottom: 0.6em; font-weight: 600; line-height: 1.3;
}
.msg-content h1 { font-size: 1.4em; }
.msg-content h2 { font-size: 1.25em; }
.msg-content h3 { font-size: 1.1em; }
.msg-content ul { margin: 0.5em 0; padding-left: 1.8em; list-style: disc; }
.msg-content ol { margin: 0.5em 0; padding-left: 1.8em; list-style: decimal; }
.msg-content li { margin: 0.25em 0; }
.msg-content pre {
    border-radius: 8px; overflow-x: auto; margin: 0.8em 0;
    background: #f1f5f9; padding: 1em;
}
.dark .msg-content pre { background: #111111; }
.msg-content code {
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.875em;
}
.msg-content :not(pre) > code {
    background: rgba(74, 190, 110, 0.1); color: #1C6B3B;
    padding: 2px 6px; border-radius: 4px;
}
.dark .msg-content :not(pre) > code {
    background: rgba(74, 190, 110, 0.15); color: #74E9A4;
}
.msg-content pre code { background: transparent; padding: 0; color: inherit; }
.msg-content blockquote {
    border-left: 3px solid #4ABE6E; padding: 0.5em 1em;
    margin: 0.8em 0; background: rgba(74, 190, 110, 0.05); border-radius: 0 6px 6px 0;
}
.dark .msg-content blockquote { background: rgba(74, 190, 110, 0.08); }
.msg-content table { border-collapse: collapse; width: 100%; margin: 0.8em 0; }
.msg-content th, .msg-content td {
    border: 1px solid #e2e8f0; padding: 8px 12px; text-align: left;
}
.dark .msg-content th, .dark .msg-content td { border-color: rgba(255,255,255,0.1); }
.msg-content th { background: #f1f5f9; font-weight: 600; }
.dark .msg-content th { background: #111111; }
.msg-content img { max-width: 100%; height: auto; border-radius: 8px; margin: 0.5em 0; }
.msg-content a { color: #35A85B; text-decoration: underline; }
.msg-content a:hover { color: #228547; }

/* Overrides for user bubble (white text on green bg) */
.user-bubble.msg-content a { color: #ffffff !important; text-decoration: underline; text-decoration-color: rgba(255,255,255,0.6); }
.user-bubble.msg-content a:hover { color: #e0f5e8 !important; text-decoration-color: #e0f5e8; }
.user-bubble.msg-content :not(pre) > code { background: rgba(255,255,255,0.2); color: #ffffff; }
.msg-content hr { border: none; height: 1px; background: #e2e8f0; margin: 1.2em 0; }
.dark .msg-content hr { background: rgba(255,255,255,0.1); }

/* SSE Streaming cursor */
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.sse-streaming::after {
    content: '▋';
    display: inline-block;
    margin-left: 2px;
    color: #4ABE6E;
    animation: blink 0.9s step-end infinite;
    font-size: 0.85em;
    vertical-align: middle;
}

/* Agent steps (thinking summaries + tool indicators) */
.agent-steps:empty { display: none; }
.agent-steps:not(:empty) {
    margin-bottom: 0.625rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.08);
}
.dark .agent-steps:not(:empty) { border-bottom-color: rgba(255, 255, 255, 0.08); }

.agent-step {
    font-size: 0.75rem;
    line-height: 1.4;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}
.agent-step:last-child { margin-bottom: 0; }

/* Thinking step - collapsible */
.agent-thinking-step .thinking-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
    user-select: none;
}
.agent-thinking-step .thinking-header:hover { color: #64748b; }
.dark .agent-thinking-step .thinking-header:hover { color: #cbd5e1; }
.agent-thinking-step .thinking-header i:first-child { font-size: 0.625rem; margin-top: 1px; }
.agent-thinking-step .thinking-chevron {
    font-size: 0.5rem;
    margin-left: auto;
    transition: transform 0.2s ease;
    opacity: 0.5;
}
.agent-thinking-step.expanded .thinking-chevron { transform: rotate(90deg); }
.agent-thinking-step .thinking-full {
    display: none;
    margin-top: 0.375rem;
    margin-left: 1rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    font-size: 0.75rem;
    line-height: 1.5;
    color: #94a3b8;
    max-height: 300px;
    overflow-y: auto;
}
.dark .agent-thinking-step .thinking-full {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.04);
}
.agent-thinking-step.expanded .thinking-full { display: block; }
.agent-thinking-step .thinking-full p { margin: 0.25em 0; }
.agent-thinking-step .thinking-full p:first-child { margin-top: 0; }
.agent-thinking-step .thinking-full p:last-child { margin-bottom: 0; }
.agent-thinking-step .thinking-duration {
    font-size: 0.625rem;
    color: #b0b8c4;
    margin-bottom: 0.375rem;
}
/* Streaming reasoning: render as plain pre to avoid expensive markdown
   re-parsing on every chunk. Wrap long lines so the bubble width is
   respected and use the same font size/color as the rendered version. */
.agent-thinking-step .thinking-stream-pre {
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.5;
    color: inherit;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Content step - real text output frozen before tool calls */
.agent-content-step {
    font-size: 0.875rem;
    line-height: 1.6;
    color: inherit;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.06);
}
.dark .agent-content-step { border-bottom-color: rgba(255, 255, 255, 0.06); }
.agent-content-step .agent-content-body p { margin: 0.25em 0; }
.agent-content-step .agent-content-body p:first-child { margin-top: 0; }
.agent-content-step .agent-content-body p:last-child { margin-bottom: 0; }

/* Tool step - collapsible */
.agent-tool-step .tool-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
    user-select: none;
    padding: 1px 0;
    border-radius: 4px;
}
.agent-tool-step .tool-header:hover { color: #64748b; }
.dark .agent-tool-step .tool-header:hover { color: #cbd5e1; }
.agent-tool-step .tool-icon { font-size: 0.625rem; }
.agent-tool-step .tool-chevron {
    font-size: 0.5rem;
    margin-left: auto;
    transition: transform 0.2s ease;
    opacity: 0.5;
}
.agent-tool-step.expanded .tool-chevron { transform: rotate(90deg); }
.agent-tool-step .tool-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-left: 0.25rem;
}

/* Tool detail panel */
.agent-tool-step .tool-detail {
    display: none;
    margin-top: 0.375rem;
    margin-left: 1rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}
.dark .agent-tool-step .tool-detail {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.04);
}
.agent-tool-step.expanded .tool-detail { display: block; }
.tool-detail-section { margin-bottom: 0.375rem; }
.tool-detail-section:last-child { margin-bottom: 0; }
.tool-detail-label {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    margin-bottom: 0.125rem;
}
.tool-detail-content {
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.7rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem 0;
    background: transparent;
    color: inherit;
}
.tool-error-text { color: #f87171; }
.tool-live-output:empty { display: none; }
.tool-streaming .tool-live-output:not(:empty)::after {
    content: ' ';
    display: inline-block;
    width: 0.45em;
    height: 1em;
    margin-left: 0.15em;
    vertical-align: -0.15em;
    background: currentColor;
    animation: tool-cursor-blink 1s steps(1) infinite;
}
@keyframes tool-cursor-blink { 50% { opacity: 0; } }

/* Log level highlighting */
.log-line { display: block; }
.log-line-debug    { color: #94a3b8; }
.log-line-info     { background-color: rgba(59, 130, 246, 0.08); }
.log-line-warning  { background-color: rgba(234, 179, 8, 0.15); color: #fde68a; }
.log-line-error    { background-color: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.log-line-critical { background-color: rgba(239, 68, 68, 0.35); color: #ff4444; font-weight: bold;  }

/* Tool failed state */
.agent-tool-step.tool-failed .tool-name { color: #f87171; }

/* Config form controls */
#view-config input[type="text"],
#view-config input[type="number"],
#view-config input[type="password"] {
    height: 40px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#view-config input:focus {
    border-color: #4ABE6E;
    box-shadow: 0 0 0 3px rgba(74, 190, 110, 0.12);
}
#view-config input[type="text"]:hover,
#view-config input[type="number"]:hover,
#view-config input[type="password"]:hover {
    border-color: #94a3b8;
}
.dark #view-config input[type="text"]:hover,
.dark #view-config input[type="number"]:hover,
.dark #view-config input[type="password"]:hover {
    border-color: #64748b;
}

/* Custom dropdown */
.cfg-dropdown {
    position: relative;
    outline: none;
}
.cfg-dropdown-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;
    padding: 0 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 0.875rem;
    color: #1e293b;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
}
.dark .cfg-dropdown-selected {
    border-color: #475569;
    background: rgba(255, 255, 255, 0.05);
    color: #f1f5f9;
}
.cfg-dropdown-selected:hover { border-color: #94a3b8; }
.dark .cfg-dropdown-selected:hover { border-color: #64748b; }
.cfg-dropdown.open .cfg-dropdown-selected,
.cfg-dropdown:focus .cfg-dropdown-selected {
    border-color: #4ABE6E;
    box-shadow: 0 0 0 3px rgba(74, 190, 110, 0.12);
}
.cfg-dropdown-arrow {
    font-size: 0.625rem;
    color: #94a3b8;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-left: 0.5rem;
}
.cfg-dropdown.open .cfg-dropdown-arrow { transform: rotate(180deg); }
.cfg-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 240px;
    overflow-y: auto;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 4px;
}
.dark .cfg-dropdown-menu {
    border-color: #334155;
    background: #1e1e1e;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}
.cfg-dropdown.open .cfg-dropdown-menu { display: block; }
.cfg-dropdown-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #334155;
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dark .cfg-dropdown-item { color: #cbd5e1; }
.cfg-dropdown-item:hover { background: #f1f5f9; }
.dark .cfg-dropdown-item:hover { background: rgba(255, 255, 255, 0.08); }
.cfg-dropdown-item.active {
    background: rgba(74, 190, 110, 0.1);
    color: #228547;
    font-weight: 500;
}
.dark .cfg-dropdown-item.active {
    background: rgba(74, 190, 110, 0.15);
    color: #74E9A4;
}
/* When an item carries a hint (e.g. brand alias next to a technical model
   id), label/hint are split into two spans so the hint sits on the right in
   a dim, smaller weight. Without a hint the row stays a plain text node and
   uses the default ellipsis behaviour, so no layout regressions for old call
   sites. */
.cfg-dropdown-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cfg-dropdown-hint {
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 12px;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 400;
}
.dark .cfg-dropdown-hint {
    color: #64748b;
}
.cfg-dropdown-item.active .cfg-dropdown-hint {
    /* Tint the hint toward the brand colour on the active row so it doesn't
       fight with the highlighted label tone. */
    color: rgba(34, 133, 71, 0.65);
}
.dark .cfg-dropdown-item.active .cfg-dropdown-hint {
    color: rgba(116, 233, 164, 0.6);
}
/* The active row gets a trailing brand-green checkmark via a Font Awesome
   pseudo-element so every dropdown (chat / vision / image / asr / tts / etc.)
   surfaces "this is what's currently selected" without per-call JS plumbing.
   When a hint is present, the ✓ sits to its right with a small gap; without
   a hint, margin-left:auto pushes the ✓ flush against the right edge. */
.cfg-dropdown-item.active::after {
    content: '\f00c';                  /* FontAwesome check glyph */
    font-family: 'Font Awesome 6 Free', 'Font Awesome 5 Free', 'FontAwesome';
    font-weight: 900;
    margin-left: auto;
    padding-left: 12px;
    color: #4abe6e;
    font-size: 11px;
    flex-shrink: 0;
}
.cfg-dropdown-item.active:has(.cfg-dropdown-hint)::after {
    /* When hint occupies the auto-margin slot, the ✓ no longer benefits
       from `margin-left: auto`; replace it with a small fixed gap so the
       ✓ trails the hint cleanly. */
    margin-left: 0;
    padding-left: 10px;
}

/* API Key masking via CSS (avoids browser password prompts) */
.cfg-key-masked {
    -webkit-text-security: disc;
    text-security: disc;
}

/* Provider logo image — vendors flagged as `provider-logo-invert-dark`
   ship a black wordmark that disappears on the dark canvas; we invert their
   luminance only in dark mode so the brand stays recognizable without
   touching multi-color marks like Google/MiniMax. */
.provider-logo-img {
    object-fit: contain;
    object-position: center;
}
.dark .provider-logo-invert-dark {
    filter: invert(1) brightness(1.15);
}

/* Models page — provider dropdown rows.
   Configured rows look like ordinary picker entries; the .active row's
   trailing brand-green ✓ already announces "this is what's selected"
   (handled globally by .cfg-dropdown-item.active::after above).
   Unconfigured rows are visually subdued and carry a trailing gear icon
   as a "click to set up" affordance. */
.cap-provider-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cap-provider-gear {
    margin-left: auto;
    padding-left: 12px;
    color: #94a3b8;
    font-size: 11px;
    flex-shrink: 0;
}
.cap-provider-item.cap-provider-unconfigured {
    color: #94a3b8;
}
.dark .cap-provider-item.cap-provider-unconfigured {
    color: #64748b;
}
.cap-provider-item.cap-provider-unconfigured:hover {
    color: #475569;
}
.dark .cap-provider-item.cap-provider-unconfigured:hover {
    color: #cbd5e1;
}
.cap-provider-item.cap-provider-unconfigured:hover .cap-provider-gear {
    color: #475569;
}
.dark .cap-provider-item.cap-provider-unconfigured:hover .cap-provider-gear {
    color: #cbd5e1;
}
/* If the active row ever lands on an unconfigured vendor (defensive — the
   click handler normally diverts to the modal), suppress the global ✓ so
   the gear remains the sole trailing icon and the row keeps reading as
   "needs setup" rather than "already selected". */
.cap-provider-item.cap-provider-unconfigured.active::after {
    content: none;
}

/* "Add vendor" modal picker — each configured row carries a static
   brand-green ✓ via decorateVendorModalPicker so users can see what's set
   up at a glance. The active row's global ✓ is suppressed here to avoid
   showing two checks side by side on configured + selected rows. */
.vendor-picker-item.active::after {
    content: none;
}
.vendor-picker-configured-mark {
    margin-left: auto;
    padding-left: 12px;
    color: #4abe6e;
    font-size: 11px;
    flex-shrink: 0;
}
/* "Custom" row is an add-new action: trailing + instead of ✓. */
.vendor-picker-add-mark {
    margin-left: auto;
    padding-left: 12px;
    color: #94a3b8;
    font-size: 11px;
    flex-shrink: 0;
}

/* Chat Input */
#chat-input {
    resize: none; height: 42px; max-height: 180px;
    overflow-y: hidden;
    transition: border-color 0.2s ease;
}

/* Attachment Preview Bar */
.attachment-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}
.attachment-preview.hidden { display: none; }

.attach-menu {
    position: absolute;
    left: 72px;
    bottom: calc(100% + 6px);
    min-width: 148px;
    padding: 6px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 8px 30px -6px rgba(0, 0, 0, 0.1), 0 2px 8px -2px rgba(0, 0, 0, 0.04);
    z-index: 55;
    animation: slashMenuIn 0.15s ease-out;
}
.attach-menu.hidden { display: none; }
.attach-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #334155;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    text-align: left;
}
.attach-menu-item:hover {
    background: #EDFDF3;
    color: #228547;
}
.attach-menu-item i {
    width: 14px;
    text-align: center;
    color: #64748b;
}
.attach-menu-item:hover i { color: inherit; }

.att-thumb {
    position: relative;
    width: 64px; height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.dark .att-thumb { border-color: rgba(255,255,255,0.1); }
.att-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
}

.att-chip {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 28px 6px 10px;
    border-radius: 8px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    font-size: 12px;
    color: #475569;
    max-width: 180px;
}
.dark .att-chip { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); color: #94a3b8; }
.att-uploading { opacity: 0.6; pointer-events: none; }
.att-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.att-remove {
    position: absolute;
    top: -4px; right: -4px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    border: none;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.att-thumb:hover .att-remove,
.att-chip:hover .att-remove { opacity: 1; }

/* Drag-over highlight */
.drag-over {
    background: rgba(74, 190, 110, 0.08) !important;
    border-color: #4ABE6E !important;
}

/* User message attachments */
.user-msg-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.user-msg-image {
    max-width: 200px;
    max-height: 160px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
}
.user-msg-image:hover { opacity: 0.9; }
.user-msg-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.15);
    font-size: 12px;
}
.user-msg-file.is-openable {
    cursor: pointer;
    transition: background 0.15s ease;
}
.user-msg-file.is-openable:hover {
    background: rgba(255,255,255,0.28);
}

/* Placeholder Cards */
.placeholder-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.placeholder-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Slash Command Menu */
.slash-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 30px -6px rgba(0, 0, 0, 0.1), 0 2px 8px -2px rgba(0, 0, 0, 0.04);
    z-index: 50;
    padding: 4px;
    animation: slashMenuIn 0.15s ease-out;
}
.slash-menu.hidden { display: none; }

@keyframes slashMenuIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.slash-menu-header {
    padding: 6px 10px 4px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.slash-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s ease;
}
.slash-menu-item:hover,
.slash-menu-item.active {
    background: #EDFDF3;
}
.slash-menu-item .cmd {
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}
.slash-menu-item.active .cmd {
    color: #228547;
}
.slash-menu-item .desc {
    font-size: 12px;
    color: #94a3b8;
    margin-left: 12px;
    white-space: nowrap;
}

/* Dark mode */
.dark .slash-menu {
    background: #1A1A1A;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 30px -6px rgba(0, 0, 0, 0.35), 0 2px 8px -2px rgba(0, 0, 0, 0.15);
}
.dark .slash-menu-header {
    color: #64748b;
}
.dark .slash-menu-item:hover,
.dark .slash-menu-item.active {
    background: rgba(74, 190, 110, 0.1);
}
.dark .slash-menu-item .cmd {
    color: #e2e8f0;
}
.dark .slash-menu-item.active .cmd {
    color: #4ABE6E;
}
.dark .slash-menu-item .desc {
    color: #64748b;
}

.dark .attach-menu {
    background: #1A1A1A;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 30px -6px rgba(0, 0, 0, 0.35), 0 2px 8px -2px rgba(0, 0, 0, 0.15);
}
.dark .attach-menu-item {
    color: #e2e8f0;
}
.dark .attach-menu-item i {
    color: #94a3b8;
}
.dark .attach-menu-item:hover {
    background: rgba(74, 190, 110, 0.1);
    color: #4ABE6E;
}

/* ============================================================
   Knowledge View
   ============================================================ */

/* Tab toggle */
.knowledge-tab, .memory-tab {
    color: #64748b;
}
.knowledge-tab.active, .memory-tab.active {
    background: #fff;
    color: #334155;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.dark .knowledge-tab.active, .dark .memory-tab.active {
    background: rgba(255,255,255,0.1);
    color: #e2e8f0;
}

/* File tree */
.knowledge-tree-group {
    margin-bottom: 2px;
}
.knowledge-tree-group-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border: none;
    background: none;
    transition: background 0.15s, color 0.15s;
    text-transform: capitalize;
}
.knowledge-tree-group-btn:hover {
    background: rgba(0,0,0,0.04);
    color: #334155;
}
.dark .knowledge-tree-group-btn:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}
.knowledge-tree-group-btn i.chevron {
    font-size: 8px;
    transition: transform 0.15s;
}
.knowledge-tree-group.open > .knowledge-tree-group-btn .chevron {
    transform: rotate(90deg);
}
.knowledge-tree-group-items {
    display: none;
}
.knowledge-tree-group.open > .knowledge-tree-group-items {
    display: block;
}

.knowledge-tree-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px 5px 24px;
    border-radius: 6px;
    font-size: 12px;
    color: #64748b;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.knowledge-tree-file:hover {
    background: rgba(0,0,0,0.04);
    color: #334155;
}
.knowledge-tree-file.active {
    background: #EDFDF3;
    color: #228547;
}

.knowledge-actions {
    display: flex;
    gap: 2px;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s;
}
.knowledge-tree-file:hover .knowledge-actions,
.knowledge-tree-group-btn:hover .knowledge-actions,
.knowledge-tree-file:focus-within .knowledge-actions,
.knowledge-tree-group-btn:focus-within .knowledge-actions {
    opacity: 1;
}
.knowledge-action {
    padding: 3px 5px;
    border-radius: 5px;
    color: #94a3b8;
    font-size: 9px;
}
.knowledge-action:hover {
    color: #228547;
    background: rgba(34, 133, 71, 0.08);
}
.knowledge-action.danger:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}
.dark .knowledge-tree-file:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}
.dark .knowledge-tree-file.active {
    background: rgba(74, 190, 110, 0.1);
    color: #4ABE6E;
}
.knowledge-import-drag-over {
    outline: 2px dashed rgba(74, 190, 110, 0.55);
    outline-offset: 4px;
    border-radius: 14px;
}
#knowledge-dialog-card.knowledge-document-dialog {
    max-width: 760px;
}
#knowledge-document-content {
    min-height: 320px;
    line-height: 1.55;
}

/* Graph legend */
.knowledge-graph-legend {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    color: #64748b;
    z-index: 10;
}
.knowledge-graph-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.knowledge-graph-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Graph tooltip */
.knowledge-graph-tooltip {
    position: absolute;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 12px;
    color: #334155;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 20;
}
.dark .knowledge-graph-tooltip {
    background: #1A1A1A;
    border-color: rgba(255,255,255,0.1);
    color: #e2e8f0;
}

/* Config field tooltip */
.cfg-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    color: #94a3b8;
    cursor: help;
    font-size: 12px;
}
.cfg-tip:hover { color: #64748b; }
.dark .cfg-tip:hover { color: #cbd5e1; }
/* Floating tooltip portal — appended to <body> by JS so it isn't clipped
   by overflow:hidden ancestors. */
.cfg-tip-floating {
    position: fixed;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    white-space: nowrap;
    background: #1e293b;
    color: #e2e8f0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 9999;
}
.dark .cfg-tip-floating {
    background: #334155;
    color: #f1f5f9;
}
.cfg-tip-floating.show {
    opacity: 1;
}

/* Example cards: equal height via flex stretch + fixed 2-line description area */
.example-card {
    display: flex;
    flex-direction: column;
}
.example-card > p {
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.5em;  /* ~2 lines at text-sm leading-relaxed */
}

/* --------------------------------------------------------------------
 * Voice pill — compact custom audio player used by mic uploads and TTS
 * replies. Replaces the bulky native <audio controls> with a play/pause
 * icon + thin progress bar + duration counter so it blends into chat
 * bubbles without the chrome-grey browser default look.
 * ------------------------------------------------------------------ */
.voice-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.05);
    color: rgb(71, 85, 105);
    font-size: 12px;
    line-height: 1;
    max-width: 240px;
    user-select: none;
    cursor: default;
}
.dark .voice-pill {
    background: rgba(255, 255, 255, 0.08);
    color: rgb(203, 213, 225);
}
.voice-pill[data-loading="1"] {
    opacity: 0.65;
}
.voice-pill-btn {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-500, #2563eb);
    color: #fff;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.1s ease;
}
.voice-pill-btn:hover { transform: scale(1.05); }
.voice-pill-btn i { font-size: 9px; margin-left: 1px; }
.voice-pill-btn[data-state="play"] i { margin-left: 2px; }
.voice-pill-btn[data-state="pause"] i { margin-left: 0; }
.voice-pill-track {
    flex: 1;
    height: 3px;
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.25);
    overflow: hidden;
    min-width: 70px;
}
.dark .voice-pill-track {
    background: rgba(148, 163, 184, 0.25);
}
.voice-pill-fill {
    height: 100%;
    width: 0%;
    background: var(--color-primary-500, #2563eb);
    border-radius: inherit;
    transition: width 0.1s linear;
}
.voice-pill-time {
    font-variant-numeric: tabular-nums;
    font-size: 11px;
    color: inherit;
    opacity: 0.75;
    flex-shrink: 0;
    min-width: 28px;
    text-align: right;
}
.voice-pill audio { display: none; }

/* Send button toggles into a Stop button while an SSE stream is in flight.
   Match the look of the disabled send button (light grey block + white
   glyph) so it reads as the same visual element, just paused/idle from
   sending perspective and clickable to stop. */
#send-btn.send-btn-cancel {
    background-color: rgb(203 213 225) !important; /* slate-300, == disabled send-btn */
    color: white !important;
}
#send-btn.send-btn-cancel:hover {
    background-color: rgb(148 163 184) !important; /* slate-400 */
}
#send-btn.send-btn-cancel:disabled {
    background-color: rgb(226 232 240) !important; /* slate-200, while stop is in flight */
    color: white !important;
    cursor: progress;
}
.dark #send-btn.send-btn-cancel {
    background-color: rgb(71 85 105) !important; /* slate-600, == dark disabled send-btn */
    color: white !important;
}
.dark #send-btn.send-btn-cancel:hover {
    background-color: rgb(100 116 139) !important; /* slate-500 */
}
.dark #send-btn.send-btn-cancel:disabled {
    background-color: rgb(51 65 85) !important; /* slate-700 */
    color: rgb(203 213 225) !important;
}

.agent-cancelled-tag {
    font-style: italic;
}

/* =====================================================================
   Code Block Enhancements
   ===================================================================== */
.code-block-wrapper {
    position: relative;
    margin: 1em 0;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
}

.dark .code-block-wrapper {
    background: #1e293b;
    border-color: #334155;
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5em 1em;
    background: #e2e8f0;
    border-bottom: 1px solid #cbd5e1;
    font-size: 0.85em;
}

.dark .code-block-header {
    background: #0f172a;
    border-bottom-color: #334155;
}

.code-block-lang {
    color: #64748b;
    font-weight: 500;
    text-transform: lowercase;
}

.dark .code-block-lang {
    color: #94a3b8;
}

.code-copy-btn {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 0.25em 0.5em;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 0.9em;
}

.code-copy-btn:hover {
    background: rgba(100, 116, 139, 0.1);
    color: #475569;
}

.dark .code-copy-btn {
    color: #94a3b8;
}

.dark .code-copy-btn:hover {
    background: rgba(148, 163, 184, 0.1);
    color: #cbd5e1;
}

.code-block-wrapper pre {
    margin: 0;
    border-radius: 0;
    border: none;
}

/* =====================================================================
   Drag and Drop Overlay
   ===================================================================== */
/* Anchor the absolutely-positioned overlay to the chat view. */
#view-chat {
    position: relative;
}

.drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(59, 130, 246, 0.1);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.drag-overlay.active {
    opacity: 1;
}

.drag-overlay.hidden {
    display: none;
}

.drag-overlay-content {
    background: white;
    border: 3px dashed #3b82f6;
    border-radius: 16px;
    padding: 3em 4em;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: bounce 1s ease infinite;
}

.dark .drag-overlay-content {
    background: #1e293b;
    border-color: #60a5fa;
}

.drag-overlay-content i {
    font-size: 4em;
    color: #3b82f6;
    margin-bottom: 0.5em;
}

.dark .drag-overlay-content i {
    color: #60a5fa;
}

.drag-overlay-content p {
    font-size: 1.5em;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.dark .drag-overlay-content p {
    color: #f1f5f9;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* =====================================================================
   Message Action Buttons
   ===================================================================== */
.edit-msg-btn,
.delete-msg-btn,
.regenerate-msg-btn {
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

.user-message-group:hover .edit-msg-btn,
.user-message-group:hover .delete-msg-btn,
.bot-message-group:hover .regenerate-msg-btn {
    opacity: 1;
}

.edit-msg-btn:hover,
.regenerate-msg-btn:hover {
    color: #3b82f6 !important;
}

.delete-msg-btn:hover {
    color: #ef4444 !important;
}

.edit-msg-btn:disabled,
.delete-msg-btn:disabled {
    cursor: not-allowed !important;
    opacity: 0.35 !important;
}

/* =====================================================================
   Workspace Panel (preview + file manager)
   ===================================================================== */
.workspace-panel {
    position: relative;
    flex-shrink: 0;
    width: 420px;
    min-width: 280px;
    max-width: 70vw;
    height: 100%;
    display: flex;
    background: #ffffff;
    border-left: 1px solid #e5e7eb;
}
.dark .workspace-panel {
    background: #1A1A1A;
    border-left-color: rgba(255, 255, 255, 0.08);
}
.workspace-panel.hidden { display: none; }

.workspace-inner {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.workspace-resizer {
    position: absolute;
    left: -3px;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 20;
}
.workspace-resizer:hover,
.workspace-resizer.dragging { background: rgba(74, 190, 110, 0.35); }

.workspace-header {
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 8px 0 10px;
    border-bottom: 1px solid #e5e7eb;
}
.dark .workspace-header { border-bottom-color: rgba(255, 255, 255, 0.08); }

.workspace-tabs { display: flex; gap: 2px; }
.workspace-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.workspace-tab i { font-size: 12px; }
.workspace-tab:hover { background: #f1f5f9; color: #334155; }
.workspace-tab.active { background: #EDFDF3; color: #228547; }
.dark .workspace-tab { color: #94a3b8; }
.dark .workspace-tab:hover { background: rgba(255, 255, 255, 0.06); color: #e2e8f0; }
.dark .workspace-tab.active { background: rgba(74, 190, 110, 0.12); color: #4ABE6E; }

.workspace-header-actions { display: flex; align-items: center; gap: 2px; }
.workspace-icon-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 13px;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.workspace-icon-btn:hover { background: #f1f5f9; color: #334155; }
.workspace-icon-btn.hidden { display: none; }
.dark .workspace-icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: #e2e8f0; }

.workspace-body {
    display: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
}
.workspace-body.active { display: flex; }

.workspace-file-title {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 12px;
    color: #64748b;
    border-bottom: 1px solid #f1f5f9;
    word-break: break-all;
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}
.workspace-file-title.hidden { display: none; }
.dark .workspace-file-title { color: #94a3b8; border-bottom-color: rgba(255, 255, 255, 0.06); }

.workspace-preview-content {
    flex: 1;
    min-height: 0;
    overflow: auto;
    position: relative;
}
.workspace-preview-content iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: #fff;
}
.workspace-preview-content .ws-pad { padding: 16px; }
.workspace-preview-content img.ws-media,
.workspace-preview-content video.ws-media {
    max-width: 100%;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
}
.workspace-preview-content audio.ws-media { width: 100%; margin-top: 12px; }
.workspace-preview-content pre {
    margin: 0;
    padding: 16px;
    font-size: 12.5px;
    line-height: 1.6;
    white-space: pre;
    overflow: auto;
}

.workspace-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #94a3b8;
    font-size: 13px;
    padding: 24px;
    text-align: center;
}
.workspace-empty i { font-size: 26px; opacity: 0.4; }

/* Files tab */
.workspace-files-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
}
.workspace-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    height: 32px;
    border-radius: 8px;
    background: #f1f5f9;
}
.workspace-search i { font-size: 11px; color: #94a3b8; }
.workspace-search input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: none;
    font-size: 13px;
    color: #334155;
}
.dark .workspace-search { background: rgba(255, 255, 255, 0.06); }
.dark .workspace-search input { color: #e2e8f0; }

.workspace-breadcrumb {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 0 12px 8px;
    font-size: 12px;
    color: #94a3b8;
}
.workspace-breadcrumb .crumb { cursor: pointer; border-radius: 4px; padding: 1px 4px; }
.workspace-breadcrumb .crumb:hover { background: #f1f5f9; color: #334155; }
.dark .workspace-breadcrumb .crumb:hover { background: rgba(255, 255, 255, 0.08); color: #e2e8f0; }
.workspace-breadcrumb .sep { opacity: 0.5; }

.workspace-file-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 6px 12px;
}
.ws-file-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s ease;
}
.ws-file-row:hover { background: #f1f5f9; }
.dark .ws-file-row:hover { background: rgba(255, 255, 255, 0.06); }
.ws-file-row.active { background: #EDFDF3; }
.dark .ws-file-row.active { background: rgba(74, 190, 110, 0.12); }
.ws-file-row > i {
    width: 16px;
    text-align: center;
    font-size: 13px;
    flex-shrink: 0;
}
.ws-file-name {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dark .ws-file-name { color: #e2e8f0; }
.ws-file-meta {
    flex-shrink: 0;
    font-size: 11px;
    color: #94a3b8;
}
.ws-file-path {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* File icon colors by kind */
.ws-icon-directory { color: #f59e0b; }
.ws-icon-html { color: #f97316; }
.ws-icon-markdown { color: #6366f1; }
.ws-icon-image { color: #10b981; }
.ws-icon-video { color: #ec4899; }
.ws-icon-audio { color: #8b5cf6; }
.ws-icon-pdf { color: #ef4444; }
.ws-icon-csv { color: #14b8a6; }
.ws-icon-code { color: #3b82f6; }
.ws-icon-office { color: #2563eb; }
.ws-icon-text,
.ws-icon-file { color: #94a3b8; }

/* =====================================================================
   Artifact / File Cards in messages
   ===================================================================== */
.file-card-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 10px 0;
}
.file-card {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.file-card:hover {
    border-color: #4ABE6E;
    box-shadow: 0 2px 10px -2px rgba(74, 190, 110, 0.25);
}
.dark .file-card { background: #232323; border-color: rgba(255, 255, 255, 0.1); }
.dark .file-card:hover { border-color: #4ABE6E; }
.file-card > i.file-card-icon { font-size: 16px; flex-shrink: 0; }
.file-card-info { min-width: 0; flex: 1; }
.file-card-name {
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dark .file-card-name { color: #e2e8f0; }
.file-card-sub {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-card-actions { display: flex; gap: 2px; flex-shrink: 0; }
.file-card-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 11px;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.file-card-btn:hover { background: #f1f5f9; color: #334155; }
.dark .file-card-btn:hover { background: rgba(255, 255, 255, 0.08); color: #e2e8f0; }

/* Inline path chip (fallback for paths mentioned only in text) */
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 7px;
    margin: 0 1px;
    border-radius: 6px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    font-size: 0.88em;
    color: #334155;
    cursor: pointer;
    vertical-align: baseline;
    text-decoration: none;
}
.file-chip:hover { border-color: #4ABE6E; color: #228547; }
.file-chip i { font-size: 0.85em; opacity: 0.7; }
.dark .file-chip { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.1); color: #e2e8f0; }
.dark .file-chip:hover { border-color: #4ABE6E; color: #4ABE6E; }

/* =====================================================================
   Mention (@) menu
   ===================================================================== */
.mention-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 30px -6px rgba(0, 0, 0, 0.1), 0 2px 8px -2px rgba(0, 0, 0, 0.04);
    z-index: 50;
    padding: 4px;
    animation: slashMenuIn 0.15s ease-out;
}
.mention-menu.hidden { display: none; }
.dark .mention-menu {
    background: #1A1A1A;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 30px -6px rgba(0, 0, 0, 0.35), 0 2px 8px -2px rgba(0, 0, 0, 0.15);
}
.mention-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: 8px;
    cursor: pointer;
}
.mention-item:hover,
.mention-item.active { background: #EDFDF3; }
.dark .mention-item:hover,
.dark .mention-item.active { background: rgba(74, 190, 110, 0.1); }
.mention-item > i { width: 15px; text-align: center; font-size: 12px; flex-shrink: 0; }
.mention-item .m-name {
    font-size: 13px;
    color: #334155;
    flex-shrink: 0;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dark .mention-item .m-name { color: #e2e8f0; }
.mention-item .m-path {
    font-size: 11px;
    color: #94a3b8;
    flex: 1;
    min-width: 0;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: rtl;
}
.mention-empty { padding: 10px; font-size: 12px; color: #94a3b8; text-align: center; }

/* Drop target highlight when dragging a workspace file into the chat */
.chat-main.ws-drop-active::after {
    content: '';
    position: absolute;
    inset: 8px;
    border: 2px dashed #4ABE6E;
    border-radius: 14px;
    background: rgba(74, 190, 110, 0.06);
    pointer-events: none;
    z-index: 30;
}

/* Mobile: workspace panel takes over the chat view */
@media (max-width: 768px) {
    .workspace-panel {
        position: absolute;
        inset: 0;
        width: 100% !important;
        max-width: none;
        z-index: 46;
    }
    .workspace-resizer { display: none; }
}

/* --------------------------------------------------------------------
 * Custom visual themes
 * The existing Tailwind utility classes remain intact; these variables
 * provide a narrow, upgrade-friendly skin for the Web console.
 * ------------------------------------------------------------------ */
:root {
    --cow-accent: #35A85B;
    --cow-accent-soft: rgba(53, 168, 91, 0.12);
    --cow-page: #f8fafc;
    --cow-surface: #ffffff;
    --cow-sidebar: #0A0A0A;
    --cow-border: rgba(15, 23, 42, 0.10);
}

html[data-cow-theme="eye-care"] {
    --cow-accent: #5f8f68;
    --cow-accent-soft: rgba(95, 143, 104, 0.14);
    --cow-page: #f3f5ed;
    --cow-surface: #fbfcf7;
    --cow-sidebar: #34483a;
    --cow-border: rgba(69, 88, 69, 0.18);
}
html[data-cow-theme="tech"] {
    --cow-accent: #22d3ee;
    --cow-accent-soft: rgba(34, 211, 238, 0.14);
    --cow-page: #07111f;
    --cow-surface: #0d1b2a;
    --cow-sidebar: #050b14;
    --cow-border: rgba(34, 211, 238, 0.20);
}
html[data-cow-theme="steady"] {
    --cow-accent: #8da3b8;
    --cow-accent-soft: rgba(141, 163, 184, 0.16);
    --cow-page: #151b24;
    --cow-surface: #202936;
    --cow-sidebar: #10161f;
    --cow-border: rgba(148, 163, 184, 0.18);
}
html[data-cow-theme="apple"] {
    --cow-accent: #007aff;
    --cow-accent-soft: rgba(0, 122, 255, 0.12);
    --cow-page: #f5f5f7;
    --cow-surface: rgba(255, 255, 255, 0.72);
    --cow-sidebar: rgba(255, 255, 255, 0.62);
    --cow-border: rgba(60, 60, 67, 0.18);
}

/* --------------------------------------------------------------------
 * Unified visual system for all four themes.
 * The theme selector changes the mood; layout, spacing and interaction
 * language remain consistent across the console.
 * ------------------------------------------------------------------ */
html[data-cow-theme] {
    --cow-radius: 14px;
    --cow-radius-lg: 20px;
    --cow-shadow-soft: 0 10px 30px rgba(15, 23, 42, .06);
    --cow-shadow-float: 0 18px 50px rgba(15, 23, 42, .12);
}
html[data-cow-theme="eye-care"] {
    --cow-shadow-soft: 0 10px 30px rgba(56, 78, 58, .08);
    --cow-shadow-float: 0 18px 50px rgba(56, 78, 58, .14);
}
html[data-cow-theme="tech"] {
    --cow-shadow-soft: 0 10px 30px rgba(0, 0, 0, .24);
    --cow-shadow-float: 0 18px 50px rgba(0, 0, 0, .38);
}
html[data-cow-theme="steady"] {
    --cow-shadow-soft: 0 10px 30px rgba(0, 0, 0, .16);
    --cow-shadow-float: 0 18px 50px rgba(0, 0, 0, .28);
}
html[data-cow-theme="apple"] {
    --cow-shadow-soft: 0 10px 30px rgba(60, 60, 67, .08);
    --cow-shadow-float: 0 20px 55px rgba(60, 60, 67, .16);
}

html[data-cow-theme] #app,
html[data-cow-theme] #main-content,
html[data-cow-theme] #content-area,
html[data-cow-theme] #view-chat,
html[data-cow-theme] .chat-main {
    background: var(--cow-page) !important;
}
html[data-cow-theme] #sidebar {
    background: linear-gradient(180deg, color-mix(in srgb, var(--cow-sidebar) 92%, var(--cow-accent) 8%), var(--cow-sidebar)) !important;
    box-shadow: 8px 0 30px rgba(0,0,0,.08);
}
html[data-cow-theme] #sidebar > div:first-child {
    min-height: 64px;
    padding-left: 18px;
    padding-right: 18px;
}
html[data-cow-theme] .sidebar-item {
    margin: 3px 0;
    border-radius: 11px !important;
    letter-spacing: .01em;
}
html[data-cow-theme] .sidebar-item.active {
    box-shadow: inset 3px 0 0 var(--cow-accent), 0 6px 18px var(--cow-accent-soft) !important;
}
html[data-cow-theme] .menu-group > button {
    padding-top: 11px;
    padding-bottom: 7px;
}
html[data-cow-theme] #main-content > header {
    min-height: 62px;
    background: color-mix(in srgb, var(--cow-surface) 92%, transparent) !important;
    backdrop-filter: blur(18px);
}
html[data-cow-theme] #chat-messages {
    background:
        radial-gradient(circle at 50% 0%, var(--cow-accent-soft), transparent 34%),
        var(--cow-page) !important;
}
html[data-cow-theme] #welcome-screen {
    animation: cowThemeEnter .35s ease both;
}
html[data-cow-theme] #welcome-screen > img {
    border: 1px solid color-mix(in srgb, var(--cow-accent) 35%, transparent);
    box-shadow: 0 12px 30px var(--cow-accent-soft) !important;
}
html[data-cow-theme] .example-card {
    border-color: var(--cow-border) !important;
    border-radius: var(--cow-radius) !important;
    background: color-mix(in srgb, var(--cow-surface) 94%, transparent) !important;
    box-shadow: var(--cow-shadow-soft);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease !important;
}
html[data-cow-theme] .example-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--cow-shadow-float);
    border-color: var(--cow-accent) !important;
}
html[data-cow-theme] #chat-input {
    min-height: 46px;
    border-radius: 16px !important;
    background: color-mix(in srgb, var(--cow-surface) 88%, var(--cow-page)) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 8px 24px rgba(0,0,0,.05);
}
html[data-cow-theme] #chat-input:focus {
    box-shadow: 0 0 0 4px var(--cow-accent-soft), 0 8px 24px rgba(0,0,0,.06) !important;
}
html[data-cow-theme] #send-btn {
    width: 44px;
    height: 44px;
    border-radius: 13px !important;
    background: var(--cow-accent) !important;
    box-shadow: 0 8px 18px var(--cow-accent-soft);
}
html[data-cow-theme] .session-panel,
html[data-cow-theme] .workspace-panel {
    background: color-mix(in srgb, var(--cow-surface) 96%, transparent) !important;
    box-shadow: var(--cow-shadow-float);
}
html[data-cow-theme] .session-item,
html[data-cow-theme] .ws-file-row {
    border-radius: 10px;
}
html[data-cow-theme] .session-item.active,
html[data-cow-theme] .ws-file-row.active {
    background: var(--cow-accent-soft) !important;
    color: var(--cow-accent) !important;
}
html[data-cow-theme] .cfg-dropdown-selected,
html[data-cow-theme] #view-config input,
html[data-cow-theme] #view-config textarea,
html[data-cow-theme] #view-config select {
    border-radius: 12px !important;
    box-shadow: var(--cow-shadow-soft);
}
html[data-cow-theme] .confirm-modal,
html[data-cow-theme] .cfg-dropdown-menu,
html[data-cow-theme] .attach-menu,
html[data-cow-theme] .slash-menu,
html[data-cow-theme] .mention-menu,
html[data-cow-theme] #visual-theme-menu,
html[data-cow-theme] #lang-menu {
    border-radius: 14px !important;
    background: var(--cow-surface) !important;
    box-shadow: var(--cow-shadow-float) !important;
    backdrop-filter: blur(18px);
}
html[data-cow-theme] .workspace-tab.active,
html[data-cow-theme] .knowledge-tab.active,
html[data-cow-theme] .memory-tab.active {
    color: var(--cow-accent) !important;
    background: var(--cow-accent-soft) !important;
}
@keyframes cowThemeEnter {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

html[data-cow-theme] body { background-color: var(--cow-page) !important; }
html[data-cow-theme] #sidebar { background-color: var(--cow-sidebar) !important; }
html[data-cow-theme] #main-content > header,
html[data-cow-theme] .session-panel,
html[data-cow-theme] .session-panel-header,
html[data-cow-theme] .workspace-panel,
html[data-cow-theme] .workspace-header { border-color: var(--cow-border) !important; }
html[data-cow-theme] .sidebar-item.active,
html[data-cow-theme] .knowledge-tab.active,
html[data-cow-theme] .memory-tab.active { background: var(--cow-accent-soft) !important; }
html[data-cow-theme] .sidebar-item.active .item-icon,
html[data-cow-theme] a:hover,
html[data-cow-theme] .text-primary-500,
html[data-cow-theme] .text-primary-400 { color: var(--cow-accent) !important; }
html[data-cow-theme] .bg-primary-500,
html[data-cow-theme] .bg-primary-600 { background-color: var(--cow-accent) !important; }
html[data-cow-theme] .border-primary-300,
html[data-cow-theme] .border-primary-400,
html[data-cow-theme] .border-primary-500 { border-color: var(--cow-accent) !important; }
html[data-cow-theme] .focus\:ring-primary-400\/50:focus { --tw-ring-color: color-mix(in srgb, var(--cow-accent) 50%, transparent) !important; }

/* --------------------------------------------------------------------
 * APPLE — a deliberately separate visual language, not a recolour.
 * Wide quiet canvas, grouped glass surfaces, system-blue controls and
 * restrained shadows make this clearly different from the default skin.
 * ------------------------------------------------------------------ */
html[data-cow-theme="apple"] {
    --cow-radius: 18px;
    --cow-radius-lg: 24px;
    --cow-page: #eef1f6;
    --cow-surface: rgba(255, 255, 255, .78);
    --cow-border: rgba(60, 60, 67, .13);
    --cow-shadow-soft: 0 12px 32px rgba(36, 42, 54, .08), inset 0 1px 0 rgba(255, 255, 255, .72);
    --cow-shadow-float: 0 22px 60px rgba(36, 42, 54, .14), inset 0 1px 0 rgba(255, 255, 255, .82);
}
html[data-cow-theme="apple"] body {
    color: #1d1d1f !important;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", Arial, sans-serif !important;
    letter-spacing: -.018em;
    background:
        radial-gradient(ellipse 72% 55% at -10% -16%, rgba(0, 122, 255, .18), transparent 65%),
        radial-gradient(ellipse 52% 42% at 108% 4%, rgba(175, 82, 222, .12), transparent 68%),
        linear-gradient(135deg, #f8f9fc 0%, #eef1f6 48%, #f7f8fb 100%) !important;
}
html[data-cow-theme="apple"] #app,
html[data-cow-theme="apple"] #main-content,
html[data-cow-theme="apple"] #content-area,
html[data-cow-theme="apple"] #view-chat,
html[data-cow-theme="apple"] .chat-main {
    background: transparent !important;
}
html[data-cow-theme="apple"] #sidebar {
    background: linear-gradient(180deg, rgba(255,255,255,.79), rgba(246,247,250,.62)) !important;
    color: #1d1d1f !important;
    border-right: 1px solid rgba(60, 60, 67, .12) !important;
    box-shadow: 12px 0 42px rgba(36, 42, 54, .07) !important;
    backdrop-filter: saturate(180%) blur(30px);
    -webkit-backdrop-filter: saturate(180%) blur(30px);
}
html[data-cow-theme="apple"] #sidebar > div:first-child {
    min-height: 72px;
    padding-left: 20px;
    padding-right: 16px;
}
html[data-cow-theme="apple"] #sidebar .text-white { color: #1d1d1f !important; }
html[data-cow-theme="apple"] #sidebar .text-neutral-500,
html[data-cow-theme="apple"] #sidebar .text-neutral-600 { color: #8e8e93 !important; }
html[data-cow-theme="apple"] #sidebar .border-white\/10 { border-color: rgba(60,60,67,.11) !important; }
html[data-cow-theme="apple"] #sidebar nav { padding: 18px 12px !important; }
html[data-cow-theme="apple"] .menu-group > button {
    padding: 14px 12px 7px !important;
    color: #8e8e93 !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: .09em !important;
}
html[data-cow-theme="apple"] .sidebar-item {
    min-height: 40px;
    margin: 4px 0 !important;
    padding: 0 12px !important;
    border-radius: 12px !important;
    color: #5f6368 !important;
    font-weight: 500;
}
html[data-cow-theme="apple"] .sidebar-item:hover,
html[data-cow-theme="apple"] .menu-group > button:hover {
    color: #1d1d1f !important;
    background: rgba(60, 60, 67, .065) !important;
}
html[data-cow-theme="apple"] .sidebar-item.active {
    color: #006fe6 !important;
    background: linear-gradient(135deg, rgba(0,122,255,.16), rgba(0,122,255,.08)) !important;
    box-shadow: inset 0 0 0 1px rgba(0,122,255,.08), 0 4px 12px rgba(0,122,255,.08) !important;
}
html[data-cow-theme="apple"] .sidebar-item.active .item-icon { color: #007aff !important; }
html[data-cow-theme="apple"] #main-content > header {
    min-height: 72px;
    padding-left: 28px !important;
    padding-right: 28px !important;
    background: rgba(255, 255, 255, .62) !important;
    border-bottom-color: rgba(60,60,67,.10) !important;
    box-shadow: 0 1px 0 rgba(255,255,255,.75) inset;
    backdrop-filter: saturate(180%) blur(28px);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
}
html[data-cow-theme="apple"] #main-content > header .font-medium { font-weight: 650; color: #1d1d1f !important; }
html[data-cow-theme="apple"] #main-content > header button,
html[data-cow-theme="apple"] #main-content > header a {
    border-radius: 11px !important;
}
html[data-cow-theme="apple"] #main-content > header button:hover,
html[data-cow-theme="apple"] #main-content > header a:hover {
    background: rgba(60,60,67,.075) !important;
}
html[data-cow-theme="apple"] #chat-messages {
    padding: 12px 24px 0;
    background: transparent !important;
}
html[data-cow-theme="apple"] #welcome-screen {
    max-width: 920px;
    margin: 0 auto;
    padding-top: 8vh !important;
    padding-bottom: 9vh !important;
}
html[data-cow-theme="apple"] #welcome-screen > img {
    width: 76px !important;
    height: 76px !important;
    margin-bottom: 22px !important;
    border-radius: 23px !important;
    box-shadow: 0 18px 42px rgba(0,122,255,.19), inset 0 1px 0 rgba(255,255,255,.42) !important;
}
html[data-cow-theme="apple"] #welcome-title {
    font-size: 32px !important;
    line-height: 1.13 !important;
    letter-spacing: -.042em;
    font-weight: 700 !important;
    color: #1d1d1f !important;
}
html[data-cow-theme="apple"] #welcome-subtitle {
    max-width: 590px;
    margin-bottom: 38px !important;
    color: #6e6e73 !important;
    font-size: 15px !important;
    line-height: 1.65 !important;
}
html[data-cow-theme="apple"] #welcome-screen > .grid {
    gap: 14px !important;
    max-width: 780px !important;
}
html[data-cow-theme="apple"] .example-card {
    min-height: 146px;
    padding: 20px !important;
    border: 1px solid rgba(255,255,255,.72) !important;
    border-radius: 20px !important;
    background: linear-gradient(135deg, rgba(255,255,255,.82), rgba(255,255,255,.57)) !important;
    box-shadow: var(--cow-shadow-soft) !important;
    backdrop-filter: saturate(150%) blur(20px);
    -webkit-backdrop-filter: saturate(150%) blur(20px);
}
html[data-cow-theme="apple"] .example-card > div:first-child { margin-bottom: 13px !important; }
html[data-cow-theme="apple"] .example-card > div:first-child > div {
    width: 32px !important;
    height: 32px !important;
    border-radius: 11px !important;
}
html[data-cow-theme="apple"] .example-card .font-medium { color: #242426 !important; font-weight: 650 !important; }
html[data-cow-theme="apple"] .example-card > p { color: #6e6e73 !important; }
html[data-cow-theme="apple"] .example-card:hover {
    transform: translateY(-4px) scale(1.008) !important;
    border-color: rgba(0,122,255,.20) !important;
    box-shadow: 0 20px 42px rgba(36,42,54,.13), inset 0 1px 0 rgba(255,255,255,.86) !important;
}
html[data-cow-theme="apple"] .chat-main > .flex-shrink-0 {
    margin: 0 24px 18px;
    padding: 12px 14px !important;
    border: 1px solid rgba(255,255,255,.76) !important;
    border-radius: 22px !important;
    background: rgba(255,255,255,.60) !important;
    box-shadow: 0 16px 38px rgba(36,42,54,.09), inset 0 1px 0 rgba(255,255,255,.82) !important;
    backdrop-filter: saturate(180%) blur(26px);
    -webkit-backdrop-filter: saturate(180%) blur(26px);
}
html[data-cow-theme="apple"] #chat-input {
    min-height: 48px;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    border: 1px solid rgba(60,60,67,.14) !important;
    border-radius: 16px !important;
    background: rgba(255,255,255,.80) !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,.035), 0 1px 0 rgba(255,255,255,.9) !important;
}
html[data-cow-theme="apple"] #chat-input:focus {
    border-color: rgba(0,122,255,.62) !important;
    box-shadow: 0 0 0 4px rgba(0,122,255,.14), inset 0 1px 2px rgba(0,0,0,.03) !important;
}
html[data-cow-theme="apple"] #send-btn {
    width: 42px;
    height: 42px;
    border-radius: 14px !important;
    background: linear-gradient(180deg, #1593ff, #0071e3) !important;
    box-shadow: 0 8px 18px rgba(0,122,255,.26), inset 0 1px 0 rgba(255,255,255,.28) !important;
}
html[data-cow-theme="apple"] #send-btn:hover { transform: translateY(-1px); filter: brightness(1.035); }
html[data-cow-theme="apple"] #new-chat-btn:hover,
html[data-cow-theme="apple"] #attach-btn:hover,
html[data-cow-theme="apple"] #optimize-btn:hover,
html[data-cow-theme="apple"] #mic-btn:hover {
    color: #007aff !important;
    background: rgba(0,122,255,.10) !important;
}
html[data-cow-theme="apple"] .session-panel,
html[data-cow-theme="apple"] .workspace-panel,
html[data-cow-theme="apple"] .confirm-modal,
html[data-cow-theme="apple"] .cfg-dropdown-menu,
html[data-cow-theme="apple"] .attach-menu,
html[data-cow-theme="apple"] .slash-menu,
html[data-cow-theme="apple"] .mention-menu,
html[data-cow-theme="apple"] #visual-theme-menu,
html[data-cow-theme="apple"] #lang-menu {
    border: 1px solid rgba(255,255,255,.76) !important;
    background: rgba(255,255,255,.73) !important;
    box-shadow: var(--cow-shadow-float) !important;
    backdrop-filter: saturate(180%) blur(28px);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
}
html[data-cow-theme="apple"] .session-panel,
html[data-cow-theme="apple"] .workspace-panel { border-color: rgba(60,60,67,.12) !important; }
html[data-cow-theme="apple"] .session-panel-header,
html[data-cow-theme="apple"] .workspace-header { border-bottom-color: rgba(60,60,67,.10) !important; }
html[data-cow-theme="apple"] .session-panel-new,
html[data-cow-theme="apple"] .mcp-primary-button {
    background: #007aff !important;
    box-shadow: 0 8px 18px rgba(0,122,255,.19) !important;
}
html[data-cow-theme="apple"] .session-item,
html[data-cow-theme="apple"] .ws-file-row,
html[data-cow-theme="apple"] .workspace-tab,
html[data-cow-theme="apple"] .cfg-dropdown-item,
html[data-cow-theme="apple"] .attach-menu-item { border-radius: 10px !important; }
html[data-cow-theme="apple"] .session-item.active,
html[data-cow-theme="apple"] .ws-file-row.active,
html[data-cow-theme="apple"] .workspace-tab.active,
html[data-cow-theme="apple"] .knowledge-tab.active,
html[data-cow-theme="apple"] .memory-tab.active {
    color: #007aff !important;
    background: rgba(0,122,255,.12) !important;
}
html[data-cow-theme="apple"] .cfg-dropdown-selected,
html[data-cow-theme="apple"] #view-config input,
html[data-cow-theme="apple"] #view-config textarea,
html[data-cow-theme="apple"] #view-config select {
    border: 1px solid rgba(60,60,67,.14) !important;
    border-radius: 12px !important;
    background: rgba(255,255,255,.68) !important;
    box-shadow: inset 0 1px 1px rgba(0,0,0,.025), 0 5px 16px rgba(36,42,54,.045) !important;
}
html[data-cow-theme="apple"] .cfg-dropdown-selected:focus-within,
html[data-cow-theme="apple"] #view-config input:focus,
html[data-cow-theme="apple"] #view-config textarea:focus,
html[data-cow-theme="apple"] #view-config select:focus {
    border-color: rgba(0,122,255,.60) !important;
    box-shadow: 0 0 0 4px rgba(0,122,255,.12) !important;
}
html[data-cow-theme="apple"] .file-card,
html[data-cow-theme="apple"] .file-chip {
    border-color: rgba(60,60,67,.12) !important;
    background: rgba(255,255,255,.64) !important;
    box-shadow: 0 5px 16px rgba(36,42,54,.045);
}
html[data-cow-theme="apple"] .text-slate-500,
html[data-cow-theme="apple"] .text-slate-400 { color: #86868b !important; }
@media (max-width: 768px) {
    html[data-cow-theme="apple"] #main-content > header { min-height: 62px; padding: 0 16px !important; }
    html[data-cow-theme="apple"] #chat-messages { padding: 0 10px; }
    html[data-cow-theme="apple"] #welcome-screen { padding: 8vh 8px 7vh !important; }
    html[data-cow-theme="apple"] #welcome-screen > .grid { gap: 10px !important; }
    html[data-cow-theme="apple"] .example-card { min-height: 128px; padding: 16px !important; border-radius: 17px !important; }
    html[data-cow-theme="apple"] .chat-main > .flex-shrink-0 { margin: 0 10px 10px; padding: 9px !important; border-radius: 18px !important; }
}

/* APPLE night — deep graphite glass, intentionally dark but never pitch-black. */
html.dark[data-cow-theme="apple"] {
    --cow-page: #1b1e24;
    --cow-surface: rgba(42, 46, 55, .72);
    --cow-border: rgba(255, 255, 255, .105);
    --cow-shadow-soft: 0 14px 38px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255,255,255,.055);
    --cow-shadow-float: 0 24px 64px rgba(0, 0, 0, .32), inset 0 1px 0 rgba(255,255,255,.07);
}
html.dark[data-cow-theme="apple"] body {
    color: #f2f2f7 !important;
    background:
        radial-gradient(ellipse 72% 58% at -10% -16%, rgba(10, 132, 255, .16), transparent 66%),
        radial-gradient(ellipse 52% 44% at 108% 2%, rgba(191, 90, 242, .10), transparent 68%),
        linear-gradient(135deg, #252932 0%, #1b1e24 52%, #20242c 100%) !important;
}
html.dark[data-cow-theme="apple"] #sidebar {
    background: linear-gradient(180deg, rgba(42,46,56,.87), rgba(30,33,40,.80)) !important;
    color: #f2f2f7 !important;
    border-right-color: rgba(255,255,255,.09) !important;
    box-shadow: 12px 0 44px rgba(0,0,0,.20) !important;
}
html.dark[data-cow-theme="apple"] #sidebar .text-white { color: #f2f2f7 !important; }
html.dark[data-cow-theme="apple"] #sidebar .text-neutral-500,
html.dark[data-cow-theme="apple"] #sidebar .text-neutral-600 { color: #a9adb7 !important; }
html.dark[data-cow-theme="apple"] #sidebar .border-white\/10 { border-color: rgba(255,255,255,.09) !important; }
html.dark[data-cow-theme="apple"] .menu-group > button { color: #9399a5 !important; }
html.dark[data-cow-theme="apple"] .sidebar-item { color: #c8cbd2 !important; }
html.dark[data-cow-theme="apple"] .sidebar-item:hover,
html.dark[data-cow-theme="apple"] .menu-group > button:hover {
    color: #fff !important;
    background: rgba(255,255,255,.075) !important;
}
html.dark[data-cow-theme="apple"] .sidebar-item.active {
    color: #69b7ff !important;
    background: linear-gradient(135deg, rgba(10,132,255,.28), rgba(10,132,255,.13)) !important;
    box-shadow: inset 0 0 0 1px rgba(100,181,255,.16), 0 5px 14px rgba(0,0,0,.15) !important;
}
html.dark[data-cow-theme="apple"] .sidebar-item.active .item-icon { color: #64b5ff !important; }
html.dark[data-cow-theme="apple"] #main-content > header {
    background: rgba(38,42,51,.70) !important;
    border-bottom-color: rgba(255,255,255,.085) !important;
    box-shadow: 0 1px 0 rgba(255,255,255,.055) inset !important;
}
html.dark[data-cow-theme="apple"] #main-content > header .font-medium { color: #f2f2f7 !important; }
html.dark[data-cow-theme="apple"] #main-content > header button,
html.dark[data-cow-theme="apple"] #main-content > header a { color: #bcc1cb !important; }
html.dark[data-cow-theme="apple"] #main-content > header button:hover,
html.dark[data-cow-theme="apple"] #main-content > header a:hover { background: rgba(255,255,255,.085) !important; color: #fff !important; }
html.dark[data-cow-theme="apple"] #welcome-title,
html.dark[data-cow-theme="apple"] .example-card .font-medium { color: #f5f5f7 !important; }
html.dark[data-cow-theme="apple"] #welcome-subtitle,
html.dark[data-cow-theme="apple"] .example-card > p { color: #abb0ba !important; }
html.dark[data-cow-theme="apple"] .example-card {
    border-color: rgba(255,255,255,.095) !important;
    background: linear-gradient(135deg, rgba(56,61,72,.80), rgba(40,44,53,.72)) !important;
    box-shadow: var(--cow-shadow-soft) !important;
}
html.dark[data-cow-theme="apple"] .example-card:hover {
    border-color: rgba(100,181,255,.28) !important;
    box-shadow: 0 20px 46px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.09) !important;
}
html.dark[data-cow-theme="apple"] .chat-main > .flex-shrink-0 {
    border-color: rgba(255,255,255,.10) !important;
    background: rgba(43,47,57,.75) !important;
    box-shadow: 0 16px 40px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.075) !important;
}
html.dark[data-cow-theme="apple"] #chat-input {
    color: #f2f2f7 !important;
    border-color: rgba(255,255,255,.12) !important;
    background: rgba(26,29,36,.72) !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,.25), 0 1px 0 rgba(255,255,255,.045) !important;
}
html.dark[data-cow-theme="apple"] #chat-input::placeholder { color: #8d939f !important; }
html.dark[data-cow-theme="apple"] #chat-input:focus {
    border-color: rgba(10,132,255,.74) !important;
    box-shadow: 0 0 0 4px rgba(10,132,255,.18), inset 0 1px 2px rgba(0,0,0,.22) !important;
}
html.dark[data-cow-theme="apple"] .session-panel,
html.dark[data-cow-theme="apple"] .workspace-panel,
html.dark[data-cow-theme="apple"] .confirm-modal,
html.dark[data-cow-theme="apple"] .cfg-dropdown-menu,
html.dark[data-cow-theme="apple"] .attach-menu,
html.dark[data-cow-theme="apple"] .slash-menu,
html.dark[data-cow-theme="apple"] .mention-menu,
html.dark[data-cow-theme="apple"] #visual-theme-menu,
html.dark[data-cow-theme="apple"] #lang-menu {
    color: #edf0f5 !important;
    border-color: rgba(255,255,255,.11) !important;
    background: rgba(47,51,61,.84) !important;
    box-shadow: var(--cow-shadow-float) !important;
}
html.dark[data-cow-theme="apple"] .session-panel-header,
html.dark[data-cow-theme="apple"] .workspace-header { border-bottom-color: rgba(255,255,255,.09) !important; }
html.dark[data-cow-theme="apple"] .session-item.active,
html.dark[data-cow-theme="apple"] .ws-file-row.active,
html.dark[data-cow-theme="apple"] .workspace-tab.active,
html.dark[data-cow-theme="apple"] .knowledge-tab.active,
html.dark[data-cow-theme="apple"] .memory-tab.active { color: #75bdff !important; background: rgba(10,132,255,.20) !important; }
html.dark[data-cow-theme="apple"] .cfg-dropdown-selected,
html.dark[data-cow-theme="apple"] #view-config input,
html.dark[data-cow-theme="apple"] #view-config textarea,
html.dark[data-cow-theme="apple"] #view-config select,
html.dark[data-cow-theme="apple"] .file-card,
html.dark[data-cow-theme="apple"] .file-chip {
    color: #edf0f5 !important;
    border-color: rgba(255,255,255,.11) !important;
    background: rgba(43,47,57,.72) !important;
    box-shadow: inset 0 1px 1px rgba(255,255,255,.035), 0 6px 16px rgba(0,0,0,.15) !important;
}
html.dark[data-cow-theme="apple"] .text-slate-500,
html.dark[data-cow-theme="apple"] .text-slate-400 { color: #a7adb8 !important; }

/* Dark-mode surface tuning for the three skins. */
.dark[data-cow-theme="eye-care"] body { background-color: #202a24 !important; }
.dark[data-cow-theme="eye-care"] .bg-white,
.dark[data-cow-theme="eye-care"] .dark\:bg-\[\#1A1A1A\] { background-color: #27342b !important; }
.dark[data-cow-theme="tech"] body { background-color: #07111f !important; }
.dark[data-cow-theme="tech"] .bg-white,
.dark[data-cow-theme="tech"] .dark\:bg-\[\#1A1A1A\] { background-color: #0d1b2a !important; }
.dark[data-cow-theme="steady"] body { background-color: #151b24 !important; }
.dark[data-cow-theme="steady"] .bg-white,
.dark[data-cow-theme="steady"] .dark\:bg-\[\#1A1A1A\] { background-color: #202936 !important; }
