/* ============================================
   Priori - Paper & Ink Theme
   Warm, literary aesthetic
   ============================================ */

/* ============================================
   FONTS
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============================================
   LUCIDE ICONS
   ============================================ */
[data-lucide],
svg.lucide {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    display: inline-block;
    vertical-align: middle;
}

/* Sprite icons inherit color */
svg.lucide {
    fill: none;
    stroke: currentColor;
}

.btn-icon [data-lucide],
.btn-icon-sm [data-lucide],
.btn-icon svg.lucide,
.btn-icon-sm svg.lucide {
    width: 20px;
    height: 20px;
}

.dropdown-chevron {
    width: 14px;
    height: 14px;
    opacity: 0.6;
    transition: transform 0.15s ease;
}

.custom-dropdown.open .dropdown-chevron {
    transform: rotate(180deg);
}

/* Animate spin for loading icons */
.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

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

/* ============================================
   CSS CUSTOM PROPERTIES - THEME SYSTEM
   ============================================ */
:root,
[data-theme="light"] {
    /* Background colors - Warm cream/parchment */
    --bg-primary: #faf6f1;
    --bg-secondary: #f5f0e8;
    --bg-tertiary: #efe9df;
    --bg-elevated: #fffcf7;
    --bg-overlay: rgba(45, 35, 25, 0.6);
    
    /* Surface colors */
    --surface-1: #fffcf7;
    --surface-2: #f5f0e8;
    --surface-3: #efe9df;
    --surface-hover: #e8e0d4;
    
    /* Text colors - Rich ink tones */
    --text-primary: #2d2419;
    --text-secondary: #4a3f31;
    --text-tertiary: #6b5d4d;
    --text-muted: #8c7b68;
    --text-inverse: #faf6f1;
    
    /* Border colors */
    --border-default: #d9cfc2;
    --border-subtle: #e8e0d4;
    --border-strong: #b8a992;
    --border-focus: #2d2419;
    
    /* Accent colors - Deep sepia/brown ink */
    --accent: #5c4a36;
    --accent-hover: #3d3024;
    --accent-subtle: rgba(92, 74, 54, 0.08);
    --accent-text: #5c4a36;
    
    /* Status colors - Earthy tones */
    --success: #4a6741;
    --success-bg: rgba(74, 103, 65, 0.1);
    --warning: #8b6914;
    --warning-bg: rgba(139, 105, 20, 0.1);
    --error: #8b3a3a;
    --error-bg: rgba(139, 58, 58, 0.1);
    --info: #5c4a36;
    --info-bg: rgba(92, 74, 54, 0.08);
    
    /* Message colors */
    --user-message-bg: #e8e0d4;
    --user-message-text: #2d2419;
    --bot-message-bg: transparent;
    --bot-message-text: #2d2419;
    --bot-message-border: transparent;
    
    /* Sidebar */
    --sidebar-bg: #f5f0e8;
    --sidebar-border: #d9cfc2;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 68px;
    
    /* Input */
    --input-bg: #fffcf7;
    --input-border: #d9cfc2;
    --input-focus-border: #5c4a36;
    --input-placeholder: #8c7b68;
    
    /* Shadow - Warm tinted */
    --shadow-sm: 0 1px 2px rgba(45, 36, 25, 0.06);
    --shadow-md: 0 2px 4px rgba(45, 36, 25, 0.08);
    --shadow-lg: 0 4px 12px rgba(45, 36, 25, 0.1);
    --shadow-xl: 0 8px 24px rgba(45, 36, 25, 0.12);
    
    /* Scrollbar */
    --scrollbar-bg: transparent;
    --scrollbar-thumb: #c9bfb0;
    --scrollbar-thumb-hover: #b8a992;
    
    /* Special */
    --code-bg: #f5f0e8;
    --code-text: #2d2419;
    --reasoning-bg: rgba(92, 74, 54, 0.05);
    --reasoning-border: rgba(92, 74, 54, 0.15);
    --reasoning-text: #4a3f31;
}

[data-theme="dark"] {
    /* Background colors - Warm dark parchment */
    --bg-primary: #1a1714;
    --bg-secondary: #13110e;
    --bg-tertiary: #252019;
    --bg-elevated: #1f1b16;
    --bg-overlay: rgba(20, 18, 15, 0.85);
    
    /* Surface colors */
    --surface-1: #1f1b16;
    --surface-2: #252019;
    --surface-3: #302920;
    --surface-hover: rgba(250, 246, 241, 0.08);
    
    /* Text colors - Brighter warm cream */
    --text-primary: #f5efe6;
    --text-secondary: #d9cfc2;
    --text-tertiary: #b8a992;
    --text-muted: #8c7b68;
    --text-inverse: #1a1714;
    
    /* Border colors - Warm brown */
    --border-default: #302920;
    --border-subtle: #252019;
    --border-strong: #4a3f31;
    --border-focus: #d9cfc2;
    
    /* Accent colors - Warm cream */
    --accent: #d9cfc2;
    --accent-hover: #e8e0d4;
    --accent-subtle: rgba(217, 207, 194, 0.08);
    --accent-text: #d9cfc2;
    
    /* Status colors - Muted warm versions */
    --success: #7fa87a;
    --success-bg: rgba(127, 168, 122, 0.12);
    --warning: #c9a855;
    --warning-bg: rgba(201, 168, 85, 0.12);
    --error: #c27a7a;
    --error-bg: rgba(194, 122, 122, 0.12);
    --info: #b8a992;
    --info-bg: rgba(184, 169, 146, 0.08);
    
    /* Message colors */
    --user-message-bg: #252019;
    --user-message-text: #f5efe6;
    --bot-message-bg: transparent;
    --bot-message-text: #f5efe6;
    --bot-message-border: transparent;
    
    /* Sidebar */
    --sidebar-bg: #13110e;
    --sidebar-border: #302920;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 68px;
    
    /* Input */
    --input-bg: #1f1b16;
    --input-border: #302920;
    --input-focus-border: #5c4a36;
    --input-placeholder: #5c4a36;
    
    /* Shadow - Warm dark */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.5);
    
    /* Scrollbar */
    --scrollbar-bg: transparent;
    --scrollbar-thumb: #4a3f31;
    --scrollbar-thumb-hover: #5c4a36;
    
    /* Special */
    --code-bg: #252019;
    --code-text: #e8e0d4;
    --reasoning-bg: rgba(217, 207, 194, 0.04);
    --reasoning-border: rgba(217, 207, 194, 0.1);
    --reasoning-text: #b8a992;
}

/* ============================================
   BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow: hidden;
    /* Use dvh for mobile viewport stability, fallback to vh */
    height: 100vh;
    height: 100dvh;
}

body {
    font-family: 'Crimson Pro', Georgia, 'Times New Roman', serif;
    background: var(--bg-primary);
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevent overscroll bounce */
    overscroll-behavior: none;
}

/* ============================================
   LAYOUT
   ============================================ */
.main-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    transition: padding-left 0.2s ease;
    padding-left: var(--sidebar-collapsed-width);
}

.main-container.chat-sidebar-open {
    padding-left: var(--sidebar-width);
}

.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-app {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: var(--bg-primary);
    overflow: hidden;
}

/* ============================================
   HEADER
   ============================================ */
.chat-header {
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-subtle);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-right: 1.5rem;
}

.brand-logo {
    width: 28px;
    height: 28px;
    color: #C9A227; /* Antique brass */
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.3s ease;
    user-select: none;
}

.brand-logo.spinning {
    animation: logo-spin 0.6s ease-out forwards;
}

.brand-logo.dragging {
    animation: none;
    cursor: grabbing;
}

@keyframes logo-spin {
    from { transform: rotate(var(--start-rotation, 0deg)); }
    to { transform: rotate(var(--end-rotation, 360deg)); }
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.4rem;
    font-weight: 700;
    font-style: italic;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.brand-tagline {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 0.6rem;
    font-weight: 400;
    font-style: normal;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    opacity: 0.7;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 500;
    font-size: 0.95rem;
    border: none;
    border-radius: 12px;
    padding: 0.5rem 1rem;
    transition: all 0.15s ease;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--accent);
    color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-hover);
}

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

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
}

.btn-icon:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 0.875rem;
}

/* Action buttons - message actions (copy, edit, regenerate) */
.action-button {
    padding: 0.5rem;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    opacity: 0.7;
    transition: all 0.15s ease;
}

.action-button [data-lucide] {
    width: 16px;
    height: 16px;
}

.action-button:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text-secondary);
    opacity: 1;
}

/* Copy button success state */
.action-button.copy-success {
    color: var(--text-primary);
    opacity: 1;
}

.action-button.copy-success:hover {
    color: var(--text-primary);
}

/* Send button */
.send-button {
    height: 38px;
    width: 38px;
    padding: 0;
    border-radius: 12px;
    background: var(--accent);
    color: var(--bg-primary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button [data-lucide] {
    width: 18px;
    height: 18px;
    stroke: var(--bg-primary);
    stroke-width: 2;
}

.send-button:hover:not(:disabled) {
    opacity: 0.85;
}

.send-button:disabled {
    background: var(--surface-3);
    color: var(--text-muted);
}

.send-button:disabled [data-lucide] {
    stroke: var(--text-muted);
}

/* Stop button - matches send button sizing */
.stop-button {
    padding: 0.625rem;
    border-radius: 12px;
    background: var(--error);
    color: white;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stop-button [data-lucide] {
    width: 18px;
    height: 18px;
    stroke: white;
    stroke-width: 2;
}

.stop-button:hover {
    opacity: 0.9;
}

/* Settings button */
.settings-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 12px;
}

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

/* ============================================
   DROPDOWNS
   ============================================ */
.model-selector,
.theme-selector {
    position: relative;
}

.custom-dropdown {
    position: relative;
}

.model-label,
.theme-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.model-label:hover,
.theme-label:hover {
    background: var(--surface-hover);
}

/* Chevron icon styling handled by .dropdown-chevron class */

.model-name,
.theme-name {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.dropdown-options {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    min-width: 180px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s ease;
    overflow: visible;
    padding: 0.5rem 0;
}

.custom-dropdown.open .dropdown-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-option {
    padding: 0.625rem 1rem;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: background 0.1s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-option:hover {
    background: var(--surface-hover);
}

.dropdown-option[data-selected="true"] {
    background: var(--accent-subtle);
    color: var(--accent-text);
}

/* Nested dropdown groups - inline accordion style */
.dropdown-group {
    position: relative;
}

.dropdown-group-trigger {
    padding: 0.625rem 1rem;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    transition: background 0.1s ease;
}

.dropdown-group-trigger:hover {
    background: var(--surface-hover);
}

.submenu-chevron {
    width: 14px;
    height: 14px;
    opacity: 0.5;
    transition: transform 0.15s ease;
}

.dropdown-group.active .submenu-chevron {
    transform: rotate(90deg);
}

/* Submenu - inline accordion (hidden by default) */
.dropdown-submenu {
    display: none;
    position: static;
    background: var(--surface-1);
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.dropdown-group.active .dropdown-submenu {
    display: block;
}

.dropdown-submenu .dropdown-option {
    padding-left: 1.5rem;
    font-size: 0.8125rem;
}

/* Portaled dropdown (moved to body) */
body > .dropdown-options {
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
}

.dropdown-group.active .dropdown-group-trigger {
    background: var(--surface-hover);
}

/* ============================================
   CHAT CONTAINER & MESSAGES
   ============================================ */
.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0.5rem 1rem 1rem;
    background: var(--bg-primary);
    width: 100%;
    position: relative;
    /* Mobile scrolling optimization */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* Welcome message */
.welcome-message {
    text-align: center;
    padding: 2rem;
    width: max-content;
    max-width: 90%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.welcome-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: #C9A227; /* Antique brass */
    opacity: 0.85;
    animation: wheel-settle 1.2s ease-out;
}

.welcome-icon svg {
    width: 100%;
    height: 100%;
}

@keyframes wheel-settle {
    0% {
        transform: rotate(-180deg);
        opacity: 0;
    }
    40% {
        opacity: 0.85;
    }
    60% {
        transform: rotate(15deg);
    }
    80% {
        transform: rotate(-8deg);
    }
    100% {
        transform: rotate(0deg);
        opacity: 0.85;
    }
}

.welcome-message h2 {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.75rem;
    font-weight: 500;
    font-style: italic;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.welcome-subtitle {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0;
    line-height: 1.6;
}

.welcome-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0.75rem 0 0 0;
}

.welcome-link {
    color: var(--text-secondary);
    text-decoration: underline;
    text-decoration-color: var(--border-default);
    text-underline-offset: 2px;
    transition: all 0.15s ease;
}

.welcome-link:hover {
    color: var(--text-primary);
    text-decoration-color: var(--text-secondary);
}

/* Messages */
.message {
    max-width: 900px;
    margin: 0 auto 1.5rem auto;
    animation: messageIn 0.2s ease-out;
}

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

.instant-load .message {
    animation: none !important;
}

.user-message {
    display: flex;
    justify-content: flex-end;
}

.user-message-wrapper {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.bot-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.bot-message .message-wrapper {
    max-width: 100%;
    width: 100%;
    overflow: hidden;
}

.message-content {
    padding: 1rem 1.25rem;
    border-radius: 16px;
    line-height: 1.75;
    font-size: 1.05rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    color: var(--text-primary);
}

.user-message .message-content {
    background: var(--user-message-bg);
    color: var(--user-message-text);
    border-radius: 16px;
}

/* User attached files row */
.user-attachments-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.user-message-text {
    display: block;
}

/* User attached file preview (images and PDFs) */
.user-file-preview {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
    max-width: 100%;
}

.user-file-preview:hover {
    background: rgba(255, 255, 255, 0.12);
}

.user-file-preview .file-thumbnail {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.user-file-preview .file-icon {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    flex-shrink: 0;
}

.user-file-preview .file-name {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bot-message .message-content {
    background: var(--bot-message-bg);
    color: var(--bot-message-text);
    padding: 0.75rem 1rem;
}

/* Markdown images in messages */
.message-content .markdown-image,
.tree-detail-text .markdown-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    margin: 0.5rem 0;
    cursor: pointer;
    transition: opacity 0.2s;
}

.message-content .markdown-image:hover,
.tree-detail-text .markdown-image:hover {
    opacity: 0.9;
}

/* Markdown Tables */
.table-wrapper {
    overflow-x: auto;
    margin: 1rem 0;
    border-radius: 8px;
    border: 1px solid var(--border-default);
}

.markdown-table,
.message-content table,
.tree-detail-text table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    margin: 1rem 0;
}

.markdown-table th,
.message-content table th,
.tree-detail-text table th {
    background: var(--surface-2);
    color: var(--text-primary);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-default);
    text-align: left;
}

.markdown-table td,
.message-content table td,
.tree-detail-text table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    vertical-align: top;
}

.markdown-table tbody tr:last-child td,
.message-content table tbody tr:last-child td,
.tree-detail-text table tbody tr:last-child td {
    border-bottom: none;
}

.markdown-table tbody tr:hover,
.message-content table tbody tr:hover,
.tree-detail-text table tbody tr:hover {
    background: var(--surface-2);
}

.markdown-table th:first-child,
.markdown-table td:first-child,
.message-content table th:first-child,
.message-content table td:first-child,
.tree-detail-text table th:first-child,
.tree-detail-text table td:first-child {
    padding-left: 1rem;
}

.markdown-table th:last-child,
.markdown-table td:last-child,
.message-content table th:last-child,
.message-content table td:last-child,
.tree-detail-text table th:last-child,
.tree-detail-text table td:last-child {
    padding-right: 1rem;
}

/* Tree detail images and files */
.tree-detail-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tree-detail-image {
    margin-bottom: 0.5rem;
}

.tree-detail-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
}

.tree-detail-file {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    cursor: pointer;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.tree-detail-file:hover {
    background: var(--surface-3);
}

.tree-detail-file svg {
    width: 16px;
    height: 16px;
}

/* Tree detail attachment with thumbnail */
.tree-detail-attachment {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 0.75rem;
    transition: background 0.15s ease;
}

.tree-detail-attachment:hover {
    background: var(--surface-3);
}

.tree-detail-thumbnail {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.tree-detail-attachment.tree-detail-pdf svg {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    flex-shrink: 0;
}

.tree-detail-filename {
    font-size: 0.875rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Message actions */
.message-actions {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    margin-top: 0.5rem;
    padding-left: 0.5rem; /* 1rem content padding - 0.5rem button padding = icon aligns */
    width: 100%;
}

.user-message .message-actions {
    justify-content: flex-end;
    padding-left: 0;
    padding-right: 0rem;
}

/* Message metadata (model, thinking, web search) */
.bot-message .message-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    padding: 0.25rem 1rem;
    margin-top: 0;
}

.bot-message .message-meta:empty {
    display: none;
}

.meta-model {
    color: var(--text-tertiary);
}

.meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-tertiary);
}

.meta-tag [data-lucide],
.meta-tag svg.lucide {
    width: 12px;
    height: 12px;
}

.meta-dot {
    color: var(--text-tertiary);
    opacity: 0.5;
}

/* ============================================
   MARKDOWN CONTENT
   ============================================ */
.message-content p {
    margin: 0.75rem 0;
}

.message-content p:first-child { margin-top: 0; }
.message-content p:last-child { margin-bottom: 0; }

.message-content h1, .message-content h2, .message-content h3,
.message-content h4, .message-content h5, .message-content h6,
.tree-detail-text h1, .tree-detail-text h2, .tree-detail-text h3,
.tree-detail-text h4, .tree-detail-text h5, .tree-detail-text h6 {
    font-family: 'Crimson Pro', Georgia, serif;
    margin: 1.5rem 0 0.75rem;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1:first-child, .message-content h2:first-child,
.message-content h3:first-child,
.tree-detail-text h1:first-child, .tree-detail-text h2:first-child,
.tree-detail-text h3:first-child { margin-top: 0; }

.message-content ul, .message-content ol,
.tree-detail-text ul, .tree-detail-text ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.message-content li,
.tree-detail-text li { margin: 0.375rem 0; }

.code-block-wrapper {
    position: relative;
    margin: 1rem 0;
}

.message-content pre,
.tree-detail-text pre {
    background: var(--code-bg);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
}

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

.code-block-wrapper + .code-block-wrapper {
    margin-top: 0.5rem;
}

.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--code-bg);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
}

.code-block-wrapper:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.code-copy-btn i,
.code-copy-btn svg {
    width: 14px;
    height: 14px;
}

.code-copy-btn.copied {
    color: var(--text-primary);
    opacity: 1;
}

.message-content code,
.tree-detail-text code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
}

.message-content pre code,
.tree-detail-text pre code {
    background: transparent;
    padding: 0;
}

/* Links in message content */
.message-content a,
.tree-detail-text a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: var(--border-default);
    text-underline-offset: 2px;
    transition: all 0.15s ease;
}

.message-content a:hover,
.tree-detail-text a:hover {
    color: var(--accent-hover);
    text-decoration-color: var(--accent);
}

.message-content a:visited,
.tree-detail-text a:visited {
    color: var(--text-secondary);
}

/* ============================================
   BRANCH NAVIGATION
   ============================================ */
.branch-navigation {
    display: flex;
    align-items: center;
    gap: 0.125rem;
}

.branch-nav-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.75rem;
}

.branch-nav-btn:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.branch-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.branch-info {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    padding: 0 0.25rem;
    font-family: 'JetBrains Mono', monospace;
}

/* ============================================
   CHAT INPUT
   ============================================ */
.chat-input-container {
    padding: 1rem;
    background: var(--bg-primary);
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Attachments Container (multiple files) - wrapper for border */
.attachments-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0 0.5rem 0 0;
    margin-bottom: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    margin-right: -0.5rem;
}

/* Add spacing after container, before border - only when attachments visible */
.attachments-container:not([style*="none"]) + .chat-input-row {
    border-top: 1px solid var(--border-default);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--surface-2);
    border-radius: 10px;
    transition: background 0.15s ease;
}

.attachment-item:hover {
    background: var(--surface-3);
}

.attachment-thumbnail-wrapper {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-3);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.attachment-thumbnail-wrapper:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.attachment-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.attachment-pdf-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    color: var(--text-secondary);
}

.attachment-pdf-icon svg {
    width: 24px;
    height: 24px;
}

.attachment-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.attachment-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-size {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
}

.attachment-remove {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: transparent;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.attachment-remove:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.attachment-remove svg {
    width: 14px;
    height: 14px;
}

/* PDF Viewer Modal */
.pdf-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
}

.pdf-viewer-modal.open {
    display: flex;
}

.pdf-viewer-container {
    position: relative;
    width: 95vw;
    max-width: 1600px;
    height: 90vh;
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pdf-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

.pdf-viewer-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-viewer-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--surface-2);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.pdf-viewer-close:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.pdf-viewer-close svg {
    width: 18px;
    height: 18px;
}

.pdf-viewer-content {
    flex: 1;
    overflow: hidden;
}

.pdf-viewer-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* Input Wrapper */
.chat-input-wrapper {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 24px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem 0.5rem 1rem;
}

.chat-input-wrapper:focus-within {
    /* No outline on focus */
}

/* Text Input Row */
.chat-input-row {
    display: flex;
    width: 100%;
}

/* Action Row */
.chat-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.5rem;
}

.action-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 0.5rem;
}

.action-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Control Island - Groups thinking + model selector */
.control-island {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    height: 38px;
    padding: 0 0.25rem;
    gap: 0.125rem;
}

.island-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

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

.island-btn.thinking-toggle-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
}

.control-island .island-btn,
.control-island .thinking-toggle-btn {
    width: auto;
    height: auto;
    min-width: auto;
    padding: 0.375rem;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

#thinkingToggleBtn svg {
    width: 16px !important;
    height: 16px !important;
}

.island-divider {
    width: 1px;
    height: 20px;
    background: var(--border-default);
    margin: 0 0.25rem;
}

.control-island .model-selector {
    margin: 0;
}

.control-island .model-label {
    padding: 0.375rem 0.5rem;
    background: transparent;
    border-radius: 12px;
}

.control-island .model-label:hover {
    background: var(--surface-hover);
}

.control-island .model-name {
    font-size: 0.9rem;
}

.control-island .dropdown-chevron {
    width: 16px;
    height: 16px;
}

.action-right .dropdown-chevron {
    width: 18px;
    height: 18px;
}

/* Action buttons in the bottom row */
.action-btn {
    height: 38px;
    width: 38px;
    padding: 0;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

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

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

/* Attachment Menu */
.attachment-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 0.5rem 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.15s ease;
}

.attachment-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.attachment-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.1s ease;
}

.attachment-menu-item:hover {
    background: var(--surface-hover);
}

.attachment-menu-item i {
    width: 20px;
    text-align: center;
    color: var(--text-tertiary);
}

/* Text Input */
.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0 0 0.75rem 0;
    font-size: 1.1rem;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    outline: none;
    height: auto;
    min-height: 1.5em;
    max-height: 200px;
    overflow: hidden;
}

.chat-input::placeholder {
    color: var(--input-placeholder);
}

/* Thinking Toggle Button */
/* Thinking Toggle Button - extends .action-btn */
.thinking-toggle-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
}

.thinking-toggle-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Search Toggle Button */
.search-toggle-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
}

.island-btn.search-toggle-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
}

.search-toggle-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

#searchToggleBtn svg {
    width: 16px !important;
    height: 16px !important;
}

/* Web Search Indicator */
.searching-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: linear-gradient(135deg, rgba(52, 168, 83, 0.08), rgba(26, 115, 232, 0.08));
    border: 1px solid rgba(52, 168, 83, 0.2);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.searching-indicator svg {
    width: 18px;
    height: 18px;
    color: #34a853;
}

.searching-indicator .search-query {
    font-style: italic;
    color: var(--text-secondary);
}

/* Web Search Citations */
.citations-container {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface-2);
    border-radius: 10px;
    border: 1px solid var(--border-default);
}

.citations-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.citations-header svg {
    width: 14px;
    height: 14px;
    color: #34a853;
}

.citations-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.citation-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-decoration: none;
    transition: all 0.15s ease;
}

.citation-item:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

.citation-item svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.citation-domain {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   MESSAGE QUEUE
   ============================================ */
.message-queue {
    margin-bottom: 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: 16px;
    overflow: hidden;
}

.queue-header {
    padding: 0.625rem 1rem;
    background: var(--surface-3);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.queue-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clear-queue-btn {
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
}

.queue-messages {
    max-height: 160px;
    overflow-y: auto;
}

.queue-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.queue-item:last-child { border-bottom: none; }
.queue-item:hover { background: var(--surface-hover); }

.queue-item-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.queue-number {
    background: var(--text-primary);
    color: var(--bg-primary);
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.queue-text {
    color: var(--text-primary);
    font-size: 0.8125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   CHAT SIDEBAR (Collapsible)
   ============================================ */
.chat-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-collapsed-width);
    height: 100vh;
    height: 100dvh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.2s ease;
    overflow: hidden;
}

.chat-sidebar.open {
    width: var(--sidebar-width);
}

/* Sidebar header with toggle */
.sidebar-header {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    flex-shrink: 0;
}

.sidebar-toggle-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.sidebar-toggle-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.sidebar-toggle-btn i {
    font-size: 1.125rem;
    transition: transform 0.2s ease;
}

/* Toggle icon states - show/hide based on sidebar state */
.sidebar-toggle-btn .icon-open { display: none; }
.chat-sidebar.open .sidebar-toggle-btn .icon-closed { display: none; }
.chat-sidebar.open .sidebar-toggle-btn .icon-open { display: block; }

/* Theme toggle button */
.theme-toggle-btn {
    position: relative;
}

.theme-toggle-btn .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-toggle-btn .theme-icon-light { display: none; }
[data-theme="dark"] .theme-toggle-btn .theme-icon-dark { display: block; }

/* New chat button */
.new-chat-btn {
    width: 100%;
    height: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    padding-left: 6px; /* Center icon in 44px collapsed width: (44 - 32) / 2 = 6 */
    gap: 0.75rem;
    overflow: hidden;
    white-space: nowrap;
    background: transparent;
    border: none;
    color: var(--text-primary);
    transition: background 0.15s ease;
}

.new-chat-btn:hover {
    background: var(--surface-hover);
}

.new-chat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    flex-shrink: 0;
    background: var(--text-primary);
    color: var(--bg-primary);
    border-radius: 12px;
}

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

.new-chat-btn .btn-text {
    font-weight: 500;
    opacity: 1;
    transition: opacity 0.15s ease;
}

/* Collapsed state - text fades, icon stays in place */
.chat-sidebar:not(.open) .new-chat-btn .btn-text,
.chat-sidebar:not(.open) .search-btn .btn-text {
    opacity: 0;
    pointer-events: none;
}

/* Search button */
.search-btn {
    width: 100%;
    height: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    padding-left: 6px;
    gap: 0.75rem;
    overflow: hidden;
    white-space: nowrap;
    background: transparent;
    border: none;
    color: var(--text-primary);
    transition: background 0.15s ease;
}

.search-btn:hover {
    background: var(--surface-hover);
}

.search-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    flex-shrink: 0;
    color: var(--text-secondary);
    border-radius: 12px;
}

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

.search-btn .btn-text {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
    opacity: 1;
    transition: opacity 0.15s ease;
}

/* Sidebar assumptions button */
.sidebar-assumptions-btn {
    width: 100%;
    height: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    padding-left: 6px;
    gap: 0.75rem;
    overflow: hidden;
    white-space: nowrap;
    background: transparent;
    border: none;
    color: var(--text-primary);
    transition: background 0.15s ease;
}

.sidebar-assumptions-btn:hover {
    background: var(--surface-hover);
}

.sidebar-assumptions-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    color: var(--text-secondary);
    border-radius: 12px;
}

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

.sidebar-assumptions-btn .btn-text {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
    opacity: 1;
    transition: opacity 0.15s ease;
}

.chat-sidebar:not(.open) .sidebar-assumptions-btn .btn-text {
    opacity: 0;
    pointer-events: none;
}

/* Tree button */
.tree-btn {
    width: 100%;
    height: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    padding-left: 6px;
    gap: 0.75rem;
    overflow: hidden;
    white-space: nowrap;
    background: transparent;
    border: none;
    color: var(--text-primary);
    transition: background 0.15s ease;
}

.tree-btn:hover {
    background: var(--surface-hover);
}

/* Hide tree button when sidebar is open (inline tree is visible instead) */
.chat-sidebar.open .tree-btn {
    display: none;
}

.tree-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    flex-shrink: 0;
    color: var(--text-secondary);
    border-radius: 12px;
}

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

.tree-btn .btn-text {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
    opacity: 1;
    transition: opacity 0.15s ease;
}

.chat-sidebar:not(.open) .tree-btn .btn-text {
    opacity: 0;
    pointer-events: none;
}

/* Sidebar content */
.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.chat-sidebar.open .sidebar-content {
    opacity: 1;
}

/* Search Modal */
.modal-content.search-modal-content {
    width: 90%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--surface-1);
    border-radius: 16px;
    overflow: hidden;
}

.search-modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-modal-icon {
    position: absolute;
    left: 0.875rem;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-modal-input {
    width: 100%;
    padding: 0.75rem 4.5rem 0.75rem 2.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.search-modal-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface-1);
}

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

.search-action-btn {
    position: absolute;
    right: 0.625rem;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.search-action-btn i,
.search-action-btn svg {
    width: 16px;
    height: 16px;
}

.search-modal-body {
    overflow-y: auto;
    padding: 0;
    max-height: 0;
    transition: max-height 0.2s ease, padding 0.2s ease;
}

.search-modal-body.has-results {
    max-height: 50vh;
    padding: 1rem;
}

.search-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.search-empty-state i,
.search-empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.search-empty-state p {
    font-size: 0.875rem;
    margin: 0;
}

.search-result-item {
    padding: 0.875rem 1rem;
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.search-result-item:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}

.search-result-item:last-child {
    margin-bottom: 0;
}

.search-result-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.search-result-preview {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-result-preview mark {
    background: var(--accent-subtle);
    color: var(--accent);
    border-radius: 2px;
    padding: 0 2px;
}

.search-no-results {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Tree visualization - fixed at top */
.conversation-tree-container {
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    margin: 0.5rem;
    overflow: hidden;
    flex-shrink: 0;
}

/* Conversations list - scrollable */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tree-visualization {
    height: 180px;
    width: 100%;
    overflow: hidden;
    position: relative;
}

#treeSvg {
    width: 100%;
    height: 100%;
    background: var(--surface-1);
    cursor: grab;
    /* Enable touch gestures */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

#treeSvg:active { cursor: grabbing; }

.tree-controls {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.25rem;
    z-index: 10;
}

.tree-control-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0.7;
}

.tree-control-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    opacity: 1;
}

.tree-control-btn [data-lucide] {
    width: 12px;
    height: 12px;
}

/* Tree Fullscreen Modal */
.modal-content.tree-modal-content {
    width: 95vw;
    max-width: 1600px;
    height: 90vh;
    max-height: 90vh;
}

.modal-body.tree-modal-body {
    flex: 1;
    padding: 0;
    position: relative;
    overflow: hidden;
    display: flex;
}

.tree-fullscreen-container {
    flex: 1;
    min-width: 50%;
    height: 100%;
    background: var(--surface-1);
    overflow: hidden;
    position: relative;
}

#treeFullscreenSvg {
    width: 100%;
    height: 100%;
    cursor: grab;
    display: block;
    /* Enable touch gestures */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

#treeFullscreenSvg:active {
    cursor: grabbing;
}

.tree-fullscreen-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 10;
}

/* Tree Detail Panel */
.tree-detail-panel {
    width: 30%;
    min-width: 200px;
    max-width: 450px;
    flex-shrink: 0;
    height: 100%;
    background: var(--surface-1);
    border-left: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tree-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 0.75rem;
    padding: 2rem;
    text-align: center;
}

.tree-detail-empty [data-lucide] {
    width: 32px;
    height: 32px;
    opacity: 0.5;
}

.tree-detail-empty p {
    font-size: 0.875rem;
    font-style: italic;
}

.tree-detail-content {
    display: none;
    flex-direction: column;
    height: 100%;
}

.tree-detail-content.active {
    display: flex;
}

.tree-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

.tree-detail-type {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.tree-detail-type.user {
    color: var(--accent);
}

.tree-detail-type.assistant {
    color: var(--text-secondary);
}

.tree-detail-nav-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.tree-detail-nav-btn [data-lucide] {
    width: 14px;
    height: 14px;
    stroke: var(--text-secondary);
}

.tree-detail-nav-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.tree-detail-nav-btn:hover [data-lucide] {
    stroke: white;
}

.tree-detail-text {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.tree-detail-text p {
    margin-bottom: 0.75rem;
}

.tree-detail-text .code-block-wrapper {
    margin-bottom: 0.75rem;
}

.tree-detail-text code {
    font-family: 'JetBrains Mono', monospace;
}

.tree-fullscreen-controls .tree-control-btn {
    width: 32px;
    height: 32px;
    opacity: 0.9;
}

.tree-fullscreen-controls .tree-control-btn [data-lucide] {
    width: 16px;
    height: 16px;
}

/* Tree node with text in fullscreen */
.tree-node-fullscreen {
    cursor: pointer;
}

.tree-node-fullscreen rect.node-bg {
    fill: var(--surface-2);
    stroke: var(--border-default);
    stroke-width: 1;
    rx: 8;
    ry: 8;
}

.tree-node-fullscreen.user-node rect.node-bg {
    fill: var(--user-message-bg);
    stroke: var(--border-strong);
}

.tree-node-fullscreen.bot-node rect.node-bg {
    fill: var(--surface-1);
    stroke: var(--border-default);
}

.tree-node-fullscreen.current-path rect.node-bg {
    stroke: var(--accent);
    stroke-width: 2;
}

.tree-node-fullscreen.selected rect.node-bg {
    stroke: var(--accent);
    stroke-width: 3;
    filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), 0.4));
}

.tree-node-fullscreen text {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 11px;
    fill: var(--text-primary);
}

.tree-node-fullscreen text.node-type {
    font-size: 9px;
    fill: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tree-node-fullscreen text.node-file-label {
    font-size: 10px;
    fill: var(--text-muted);
}

.tree-link-fullscreen {
    fill: none;
    stroke: var(--border-default);
    stroke-width: 1.5;
}

.tree-link-fullscreen.current-path {
    stroke: var(--accent);
    stroke-width: 2;
}

.tree-node { cursor: pointer; }

.tree-node rect {
    stroke-width: 2;
    transition: all 0.15s ease;
}

/* User nodes: hollow/outlined (fill matches tree bg to cover lines) */
.tree-node.user-node rect {
    fill: var(--surface-2);
    stroke: var(--border-strong);
}

/* Bot/model nodes: solid filled */
.tree-node.bot-node rect {
    fill: var(--text-tertiary);
    stroke: var(--text-tertiary);
}

/* Current path highlighting */
.tree-node.current-path.user-node rect {
    fill: var(--surface-2);
    stroke: var(--text-primary);
}

.tree-node.current-path.bot-node rect {
    fill: var(--text-primary);
    stroke: var(--text-primary);
}

.tree-link {
    fill: none;
    stroke: var(--border-default);
    stroke-width: 2;
}

.tree-link.current-path {
    stroke: var(--text-primary);
    stroke-width: 2;
}

.tree-tooltip {
    position: fixed;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    box-shadow: var(--shadow-lg);
    font-size: 0.75rem;
    color: var(--text-primary);
    max-width: 200px;
    z-index: 10000;
    pointer-events: none;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.tree-tooltip.visible { opacity: 1; }

.tree-tooltip .tooltip-type {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

/* Conversations list */
.conversation-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

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

.conversation-item.active {
    background: var(--accent-subtle);
    border-color: var(--accent);
}

.conversation-content {
    flex: 1;
    min-width: 0;
}

.conversation-title {
    font-weight: 400;
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-meta {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.conversation-dot {
    color: var(--text-muted);
    opacity: 0.5;
}

/* Conversation menu (3-dot) */
.conversation-item {
    position: relative;
}

.conversation-menu-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all 0.15s ease;
}

.conversation-item:hover .conversation-menu-btn,
.conversation-menu-btn:focus,
.conversation-menu.open + .conversation-menu-btn,
.conversation-item:has(.conversation-menu.open) .conversation-menu-btn {
    opacity: 0.7;
}

.conversation-menu-btn:hover {
    opacity: 1 !important;
    background: var(--surface-hover);
    color: var(--text-primary);
}

.conversation-menu-btn [data-lucide],
.conversation-menu-btn svg {
    width: 16px;
    height: 16px;
}

.conversation-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 120px;
    padding: 0.375rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.15s ease;
}

.conversation-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.conversation-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background 0.1s ease;
    text-align: left;
}

.conversation-menu-item:hover {
    background: var(--surface-hover);
}

.conversation-menu-item.delete-btn:hover {
    background: var(--error-bg);
    color: var(--error);
}

.conversation-menu-item [data-lucide],
.conversation-menu-item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Pinned conversation indicator */
.conversation-item.pinned .conversation-title::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 0.375rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%235c4a36' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 17v5'/%3E%3Cpath d='M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.6;
    vertical-align: middle;
}

[data-theme="dark"] .conversation-item.pinned .conversation-title::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23d9cfc2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 17v5'/%3E%3Cpath d='M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z'/%3E%3C/svg%3E");
}

/* ============================================
   CONTROLS SIDEBAR (Assumptions)
   ============================================ */
.controls-sidebar {
    width: 0;
    height: 100vh;
    height: 100dvh;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s ease;
    flex-shrink: 0;
}

.controls-sidebar.open {
    width: 360px;
}

.controls-sidebar .sidebar-header {
    padding: 0.875rem 1rem;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.controls-sidebar .sidebar-header h3 {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    font-style: italic;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.controls-sidebar .sidebar-header h3 i {
    color: var(--text-muted);
}

.controls-sidebar .sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 1;
}

/* Close button */
.close-sidebar-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    color: var(--text-tertiary);
    border: none;
    border-radius: 12px;
    cursor: pointer;
}

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

/* Controls Grid */
.assumptions-grid {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Empty State */
.controls-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    min-height: 100%;
    height: 100%;
}

.controls-empty-icon {
    color: var(--accent);
    margin-bottom: 1rem;
}

.controls-empty-icon [data-lucide] {
    width: 32px;
    height: 32px;
}

.controls-empty p {
    font-size: 0.9rem;
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
}

.controls-empty span {
    font-size: 0.8rem;
    opacity: 0.7;
}

.assumption-item {
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    padding: 1rem;
    position: relative;
}

/* Light mode: give assumption cards a warmer accent bg */
:root:not([data-theme="dark"]) .assumption-item {
    background: linear-gradient(135deg, #fdf9f3 0%, #f9f3e8 100%);
    border-color: #e0d4c0;
    box-shadow: 0 1px 3px rgba(139, 119, 91, 0.08);
}

.assumption-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.assumption-type {
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.assumption-confidence {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
}

.confidence-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.confidence-high { background: var(--success); }
.confidence-medium { background: var(--warning); }
.confidence-low { background: var(--error); }
.confidence-text { color: var(--text-muted); }

.assumption-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.assumption-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem 0.875rem;
    border-radius: 12px;
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

.assumption-checkbox:hover {
    background: var(--surface-hover);
}

.assumption-checkbox.selected {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent-text);
}

.assumption-checkbox.changed {
    background: var(--warning-bg);
    border-color: var(--warning);
}

.assumption-checkbox input { display: none; }

/* Custom option trigger - small + button inline with options */
.custom-option-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.875rem;
    border-radius: 12px;
    background: transparent;
    border: 1px dashed var(--border-default);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.custom-option-trigger:hover {
    border-color: var(--accent);
    color: var(--accent);
    border-style: solid;
}

.custom-option-trigger svg {
    width: 14px;
    height: 14px;
}

/* Expanded custom input */
.custom-option-expanded {
    display: inline-flex;
    min-width: 120px;
    max-width: 200px;
}

.custom-option-text {
    width: 100%;
    padding: 0.5rem 0.875rem;
    border-radius: 12px;
    border: 1px solid var(--accent);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8125rem;
    outline: none;
}

.custom-option-text::placeholder {
    color: var(--text-muted);
}

.ai-guessing-badge {
    position: absolute;
    top: -8px;
    left: 12px;
    background: var(--error);
    color: white;
    font-size: 0.5625rem;
    font-weight: 700;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Load More button (at bottom of assumptions) */
.load-more-button {
    width: 100%;
    padding: 0.625rem;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.load-more-button:hover {
    color: var(--text-primary);
}

/* Apply button (fixed at bottom) */
.apply-changes-container {
    flex-shrink: 0;
    padding: 1rem;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-default);
    display: none;
}

.apply-changes-container.has-changes {
    display: block;
}

.apply-changes-button {
    width: 100%;
    padding: 0.875rem;
    transition: opacity 0.2s ease;
}

.change-count {
    background: var(--surface-3);
    color: var(--text-primary);
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

/* Loading state */
.assumptions-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    gap: 0.75rem;
    flex: 1;
    min-height: 200px;
}

.assumptions-loading .loading-spinner {
    color: var(--accent);
}

.assumptions-loading .loading-spinner [data-lucide] {
    width: 24px;
    height: 24px;
}

.assumptions-loading .spinning-logo {
    width: 40px;
    height: 40px;
    color: #C9A227; /* Antique brass - match brand logo */
    animation: steer 2.5s ease-in-out infinite;
}

@keyframes steer {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(35deg); }
    75% { transform: rotate(-35deg); }
}

.assumptions-loading .spinning-logo svg {
    width: 100%;
    height: 100%;
}

.assumptions-loading .loading-content {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
}

.assumptions-loading p {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin: 0;
}

.no-controls-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 2rem;
    flex: 1;
    min-height: 100%;
    height: 100%;
}

.no-controls-icon {
    font-size: 2.5rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.no-controls-content h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.no-controls-content p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Defaults styling */
.default-item {
    opacity: 0.85;
}

.default-item:hover {
    opacity: 1;
}

/* Simple welcome state (when defaults is off) */
.sidebar-welcome-simple {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    flex: 1;
    color: var(--text-muted);
}

.sidebar-welcome-simple .sidebar-welcome-stars {
    color: var(--accent);
    margin-bottom: 1rem;
}

.sidebar-welcome-simple .sidebar-welcome-stars [data-lucide] {
    width: 32px;
    height: 32px;
}

.sidebar-welcome-simple p {
    font-size: 0.9rem;
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
}

.sidebar-welcome-simple span {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* ============================================
   SETTINGS MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 20px;
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95);
    transition: transform 0.2s ease;
    display: flex;
    flex-direction: column;
}

.modal-overlay.open .modal-content {
    transform: scale(1);
}

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

.modal-header h2 {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-header h2 i { color: var(--text-muted); }

.close-modal-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    color: var(--text-tertiary);
    border: none;
    border-radius: 12px;
    cursor: pointer;
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-default);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Settings */
.setting-section { margin-bottom: 1.5rem; }
.setting-section:last-child { margin-bottom: 0; }

.setting-group-title {
    font-family: 'Google Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.setting-group-title i { color: var(--text-muted); }

.setting-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.setting-label i { color: var(--text-muted); }

.setting-description {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    line-height: 1.5;
    margin: 0;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.setting-item:last-child { margin-bottom: 0; }
.setting-item-info { flex: 1; }
.setting-item .setting-label { margin-bottom: 0.25rem; }

/* Input */
.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.setting-input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 0.625rem 0.875rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
}

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

.setting-input::placeholder { color: var(--input-placeholder); }

/* Model dropdown in settings */
.setting-section .model-label {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 0.625rem 0.875rem;
    justify-content: space-between;
}

.setting-section .model-label:hover {
    border-color: var(--input-focus-border);
}

/* Settings modal */
#settingsModal .modal-content {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

#settingsModal .modal-body {
    overflow-x: hidden;
    overflow-y: auto;
}


.toggle-visibility-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-visibility-btn [data-lucide] {
    width: 18px;
    height: 18px;
}

/* Toggle switch */
.toggle-switch { position: relative; flex-shrink: 0; }
.toggle-switch input[type="checkbox"] { display: none; }

.toggle-label {
    display: block;
    width: 44px;
    height: 24px;
    background: var(--surface-3);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    position: relative;
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-label { background: var(--accent); }
.toggle-switch input:checked + .toggle-label .toggle-slider { transform: translateX(20px); }

.cancel-btn {
    background: var(--surface-2);
    color: var(--text-primary);
}

.cancel-btn:hover { background: var(--surface-hover); }

.save-btn {
    background: var(--text-primary);
    color: var(--bg-primary);
}

.save-btn:hover { background: var(--text-secondary); }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    min-width: 280px;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    pointer-events: auto;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.25s ease;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex: 1;
}

.toast-content i { font-size: 1rem; flex-shrink: 0; }

.toast-message {
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 12px;
}

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

.toast-success { border-left: 3px solid var(--success); }
.toast-success .toast-content i { color: var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-error .toast-content i { color: var(--error); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning .toast-content i { color: var(--warning); }
.toast-info { border-left: 3px solid var(--info); }
.toast-info .toast-content i { color: var(--info); }

/* ============================================
   EDIT MESSAGE
   ============================================ */
/* Edit mode - uses exact same classes as main input area */
.chat-input-wrapper.edit-mode {
    max-width: 100%;
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
}

.chat-input-wrapper.edit-mode .attachments-container {
    max-height: 150px;
    flex-shrink: 0;
}

.chat-input-wrapper.edit-mode .chat-input {
    max-height: 150px;
    overflow-y: auto;
}

.edit-button { 
    padding: 0.5rem 1rem; 
}

.edit-button.cancel {
    background: var(--surface-2);
    color: var(--text-primary);
}

.edit-button.cancel:hover { 
    background: var(--surface-hover); 
}

/* ============================================
   REASONING DISPLAY
   ============================================ */
.reasoning-container { margin-bottom: 0.75rem; }

.reasoning-details {
    background: var(--reasoning-bg);
    border: 1px solid var(--reasoning-border);
    border-radius: 12px;
    overflow: hidden;
}

.reasoning-summary {
    padding: 0.625rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--reasoning-text);
    list-style: none;
}

.reasoning-summary::-webkit-details-marker { display: none; }

.reasoning-summary::before {
    content: '▶';
    font-size: 0.5rem;
    transition: transform 0.15s ease;
}

.reasoning-details[open] .reasoning-summary::before { transform: rotate(90deg); }

.reasoning-summary.reasoning-streaming {
    background: linear-gradient(90deg, var(--reasoning-bg), rgba(138, 180, 248, 0.15), var(--reasoning-bg));
    background-size: 200% 100%;
    animation: reasoningPulse 1.5s ease-in-out infinite;
}

@keyframes reasoningPulse {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.reasoning-content {
    padding: 1rem;
    font-size: 0.875rem;
    color: var(--reasoning-text);
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}

/* ============================================
   THINKING/IMAGE INDICATORS
   ============================================ */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem;
    background: var(--reasoning-bg);
    border: 1px solid var(--reasoning-border);
    border-radius: 12px;
}

.thinking-spinner {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: thinkPulse 1.5s ease-in-out infinite;
}

.thinking-spinner i { font-size: 1rem; color: white; }

@keyframes thinkPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.thinking-text { display: flex; flex-direction: column; gap: 0.125rem; }
.thinking-title { font-size: 0.9375rem; font-weight: 500; color: var(--reasoning-text); }
.thinking-subtitle { font-size: 0.8125rem; color: var(--text-muted); }

.image-generating-indicator {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem;
    background: var(--info-bg);
    border: 1px solid rgba(26, 115, 232, 0.2);
    border-radius: 12px;
}

.image-generating-spinner {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: imagePulse 1.5s ease-in-out infinite;
}

.image-generating-spinner i { font-size: 1rem; color: white; }

@keyframes imagePulse {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.05) rotate(3deg); }
    75% { transform: scale(1.05) rotate(-3deg); }
}

.image-generating-text { display: flex; flex-direction: column; gap: 0.125rem; }
.generating-title { font-size: 0.9375rem; font-weight: 500; color: var(--accent-text); }
.generating-subtitle { font-size: 0.8125rem; color: var(--text-muted); }

/* Generated images */
.generated-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.generated-image-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: transparent;
    width: fit-content;
}

.generated-image-container:hover { box-shadow: var(--shadow-lg); }

.generated-image {
    max-width: 100%;
    max-height: 50vh;
    width: auto;
    height: auto;
    display: block;
    margin: 0;
    cursor: pointer;
}

.image-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 0.375rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.generated-image-container:hover .image-actions { opacity: 1; }

.image-action-btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.image-action-btn:hover { background: rgba(0, 0, 0, 0.8); }

/* Image modal */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
}

.image-modal.open { display: flex; }

.image-modal-container {
    position: relative;
    max-width: 95vw;
    max-height: 90vh;
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.image-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

.image-modal-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-modal-actions {
    display: flex;
    gap: 0.5rem;
}

.image-modal-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--surface-2);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.image-modal-btn:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.image-modal-btn [data-lucide] {
    width: 18px;
    height: 18px;
}

.image-modal-content {
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-1);
}

.image-modal-img {
    max-width: 95vw;
    max-height: calc(90vh - 60px);
    object-fit: contain;
    display: block;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar-bg); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

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

/* ============================================
   UTILITY
   ============================================ */
body.modal-open { overflow: hidden; }

body.controls-disabled .toggle-controls-btn {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================
   PULL TO REFRESH (Mobile)
   ============================================ */
.ptr-container {
    position: fixed;
    top: -44px;
    left: 0;
    right: 0;
    height: 44px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-default);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.ptr-container.active {
    transform: translateY(var(--ptr-offset, 0px));
    transition: none;
}

.ptr-container.refreshing {
    transform: translateY(44px);
    transition: transform 0.2s ease;
}

.ptr-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.ptr-icon {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.ptr-container.refreshing .ptr-icon {
    color: var(--accent);
    animation: ptr-spin 0.8s linear infinite;
}

.ptr-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
}

.ptr-container.refreshing .ptr-text {
    color: var(--text-secondary);
}

.main-container {
    transition: transform 0.2s ease;
}

.main-container.ptr-pulling {
    transition: none;
}

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

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .main-container { padding-left: var(--sidebar-collapsed-width); }
    .main-container.chat-sidebar-open { padding-left: var(--sidebar-collapsed-width); }
    
    .chat-sidebar {
        width: var(--sidebar-collapsed-width);
        left: 0;
    }
    
    .chat-sidebar.open { width: var(--sidebar-width); }
    
    .controls-sidebar.open { width: 100%; }
    
    .toast-container { left: 1rem; right: 1rem; }
    .toast { min-width: auto; max-width: none; }
}

/* Mobile input bar fixes */
@media (max-width: 480px) {
    /* Use fixed positioning for entire chat app on mobile to prevent keyboard resize issues */
    .chat-app {
        position: fixed;
        top: 0;
        left: var(--sidebar-collapsed-width);
        right: 0;
        bottom: 0;
        width: auto;
        height: auto;
    }
    
    /* Reset header to normal flow within fixed container */
    .chat-header {
        flex-shrink: 0;
    }
    
    /* Chat container fills available space */
    .chat-container {
        flex: 1;
        min-height: 0;
    }

    .chat-input-container {
        flex-shrink: 0;
        padding: 0.75rem;
    }
    
    .chat-input-wrapper {
        padding: 0.5rem 0.75rem 0.375rem 0.75rem;
        border-radius: 20px;
    }
    
    .chat-input {
        font-size: 1rem;
        padding: 0 0 0.5rem 0;
    }
    
    .chat-action-row {
        padding-top: 0.375rem;
        gap: 0.25rem;
    }
    
    .action-left {
        gap: 0.25rem;
        margin-right: 0.25rem;
        flex-shrink: 1;
        min-width: 0;
    }
    
    .action-right {
        gap: 0.25rem;
        flex-shrink: 0;
    }
    
    /* Smaller control island on mobile */
    .control-island {
        padding: 0.125rem;
        gap: 0;
        flex-shrink: 1;
        min-width: 0;
    }
    
    .control-island .island-btn,
    .control-island .thinking-toggle-btn {
        padding: 0.25rem;
    }
    
    .control-island .model-label {
        padding: 0.25rem 0.375rem;
        max-width: 100px;
        overflow: hidden;
    }
    
    .control-island .model-name {
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 60px;
    }
    
    .control-island .dropdown-chevron {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }
    
    .island-divider {
        height: 16px;
        margin: 0 0.125rem;
    }
    
    /* Smaller action buttons on mobile */
    .action-btn {
        height: 34px;
        width: 34px;
    }
    
    .action-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .send-button {
        height: 34px;
        width: 34px;
    }
    
    .send-button [data-lucide] {
        width: 16px;
        height: 16px;
    }
    
    .control-island {
        height: 34px;
    }
    
    .stop-button {
        padding: 0.5rem;
    }
    
    /* Mobile dropdown positioning */
    .dropdown-options {
        right: auto;
        left: 0;
        min-width: 200px;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .dropdown-option,
    .dropdown-group-trigger {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .dropdown-submenu .dropdown-option {
        font-size: 0.75rem;
    }
    
    /* Tree modal mobile layout */
    .modal-content.tree-modal-content {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }
    
    .modal-body.tree-modal-body {
        flex-direction: column;
    }
    
    .tree-fullscreen-container {
        min-width: 100%;
        height: 45%;
        flex: none;
    }
    
    .tree-detail-panel {
        width: 100%;
        max-width: none;
        min-width: auto;
        height: 55%;
        flex: none;
        border-left: none;
        border-top: 1px solid var(--border-default);
    }
    
    .tree-detail-empty {
        padding: 1rem;
    }
    
    .tree-detail-empty [data-lucide] {
        width: 24px;
        height: 24px;
    }
    
    .tree-detail-empty p {
        font-size: 0.8rem;
    }
    
    .tree-detail-header {
        padding: 0.75rem;
    }
    
    .tree-detail-text {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
    
    .tree-fullscreen-controls {
        bottom: 0.5rem;
        right: 0.5rem;
    }
    
    .tree-fullscreen-controls .tree-control-btn {
        width: 28px;
        height: 28px;
    }
    
    
    /* Controls sidebar on mobile - fixed and above everything */
    .controls-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1100;
        width: 0;
    }
    
    .controls-sidebar.open {
        width: 100%;
    }
}

/* ============================================
   DISABLE HOVER STATES ON TOUCH DEVICES
   Using both hover:none AND pointer:coarse for better coverage
   ============================================ */
@media (hover: none), (pointer: coarse) {
    /* Slower transition for tap feedback - makes release animation visible */
    .settings-btn,
    .sidebar-toggle-btn,
    .new-chat-btn,
    .search-btn,
    .sidebar-assumptions-btn,
    .tree-btn,
    .island-btn,
    .action-btn,
    .tree-control-btn,
    .tree-detail-nav-btn,
    .close-modal-btn,
    .close-sidebar-btn,
    .branch-nav-btn,
    .conversation-item,
    .search-result-item,
    .btn-icon {
        transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, opacity 0.25s ease;
    }
    
    /* Buttons */
    .btn-primary:hover:not(:disabled),
    .btn-secondary:hover:not(:disabled),
    .btn-ghost:hover:not(:disabled),
    .btn-icon:hover:not(:disabled) {
        background: inherit;
        color: inherit;
        box-shadow: none;
    }
    
    .btn-primary:hover:not(:disabled) {
        background: var(--accent);
    }
    
    .btn-secondary:hover:not(:disabled) {
        background: var(--surface-2);
    }
    
    .btn-ghost:hover:not(:disabled) {
        background: transparent;
        color: var(--text-secondary);
    }
    
    .btn-icon:hover:not(:disabled) {
        background: transparent;
        color: var(--text-secondary);
    }
    
    .btn-icon:active:not(:disabled) {
        background: var(--surface-hover);
        color: var(--text-primary);
        transition: none; /* Instant IN */
    }
    
    /* Action buttons */
    .action-button:hover:not(:disabled) {
        background: transparent;
        color: var(--text-muted);
        opacity: 0.7;
    }
    
    .send-button:hover:not(:disabled) {
        opacity: 1;
    }
    
    .stop-button:hover {
        opacity: 1;
    }
    
    /* Settings button */
    .settings-btn:hover {
        background: transparent;
        color: var(--text-secondary);
    }
    
    .settings-btn:active {
        background: var(--surface-hover);
        color: var(--text-primary);
    }
    
    /* Dropdowns */
    .model-label:hover,
    .theme-label:hover {
        background: transparent;
    }
    
    .dropdown-option:hover {
        background: transparent;
    }
    
    .dropdown-group-trigger:hover {
        background: transparent;
    }
    
    /* Sidebar */
    .sidebar-toggle-btn:hover {
        background: transparent;
        color: var(--text-secondary);
    }
    
    .sidebar-toggle-btn:active {
        background: var(--surface-hover);
        color: var(--text-primary);
    }
    
    .new-chat-btn:hover,
    .search-btn:hover,
    .sidebar-assumptions-btn:hover,
    .tree-btn:hover {
        background: transparent;
    }
    
    .new-chat-btn:active,
    .search-btn:active,
    .sidebar-assumptions-btn:active,
    .tree-btn:active {
        background: var(--surface-hover);
    }
    
    /* Conversation items */
    .conversation-item:hover {
        background: transparent;
    }
    
    .conversation-item:active {
        background: var(--surface-hover);
    }
    
    /* Always show menu button on touch (no hover to reveal it) */
    .conversation-menu-btn {
        opacity: 0.5;
    }
    
    .conversation-item:hover .conversation-menu-btn {
        opacity: 0.5;
    }
    
    .conversation-menu-btn:hover {
        opacity: 0.5;
        background: transparent;
        color: var(--text-muted);
    }
    
    .conversation-menu-btn:active {
        opacity: 1;
        background: var(--surface-hover);
        color: var(--text-primary);
    }
    
    .conversation-menu-item:hover {
        background: transparent;
    }
    
    .conversation-menu-item:active {
        background: var(--surface-hover);
    }
    
    .conversation-menu-item.delete-btn:active {
        background: var(--error-bg);
        color: var(--error);
    }
    
    /* Control island */
    .island-btn:hover {
        background: transparent;
        color: var(--text-secondary);
    }
    
    .island-btn:active {
        background: var(--surface-hover);
        color: var(--text-primary);
    }
    
    .control-island .model-label:hover {
        background: transparent;
    }
    
    .control-island .model-label:active {
        background: var(--surface-hover);
    }
    
    /* Action row buttons */
    .action-btn:hover {
        background: var(--bg-secondary);
        color: var(--text-secondary);
    }
    
    .action-btn:active {
        background: var(--surface-hover);
        color: var(--text-primary);
    }
    
    /* Links */
    .welcome-link:hover {
        color: var(--text-secondary);
        text-decoration-color: var(--border-default);
    }
    
    .message-content a:hover,
    .tree-detail-text a:hover {
        color: var(--accent);
        text-decoration-color: var(--border-default);
    }
    
    /* Code copy button - always visible on touch */
    .code-block-wrapper .code-copy-btn {
        opacity: 1;
    }
    
    .code-copy-btn:hover {
        background: var(--code-bg);
        color: var(--text-tertiary);
    }
    
    /* Branch navigation */
    .branch-nav-btn:hover:not(:disabled) {
        background: transparent;
        color: var(--text-tertiary);
    }
    
    .branch-nav-btn:active:not(:disabled) {
        background: var(--surface-hover);
        color: var(--text-primary);
    }
    
    /* Search modal */
    .search-result-item:hover {
        background: var(--surface-1);
        border-color: var(--border-default);
    }
    
    .search-result-item:active {
        background: var(--surface-hover);
        border-color: var(--accent);
    }
    
    .search-action-btn:hover {
        color: var(--text-muted);
        background: transparent;
    }
    
    .search-action-btn:active {
        background: var(--surface-hover);
        color: var(--text-primary);
    }
    
    /* Tree controls */
    .tree-control-btn:hover {
        background: var(--surface-1);
        color: var(--text-muted);
        opacity: 0.7;
    }
    
    .tree-control-btn:active {
        background: var(--surface-hover);
        color: var(--text-primary);
        opacity: 1;
    }
    
    .tree-detail-nav-btn:hover {
        background: transparent;
        border-color: var(--border-default);
        color: var(--text-secondary);
    }
    
    .tree-detail-nav-btn:active {
        background: var(--accent);
        border-color: var(--accent);
        color: white;
    }
    
    .tree-detail-nav-btn:hover [data-lucide] {
        stroke: var(--text-secondary);
    }
    
    .tree-detail-nav-btn:active [data-lucide] {
        stroke: white;
    }
    
    /* Attachments */
    .attachment-item:hover {
        background: var(--surface-2);
    }
    
    .attachment-thumbnail-wrapper:hover {
        transform: none;
        box-shadow: none;
    }
    
    .attachment-remove:hover {
        background: transparent;
        color: var(--text-tertiary);
    }
    
    .attachment-menu-item:hover {
        background: transparent;
    }
    
    /* File previews */
    .user-file-preview:hover {
        background: rgba(255, 255, 255, 0.08);
    }
    
    .tree-detail-file:hover {
        background: var(--surface-2);
    }
    
    .tree-detail-attachment:hover {
        background: var(--surface-2);
    }
    
    /* Tables */
    .markdown-table tbody tr:hover,
    .message-content table tbody tr:hover,
    .tree-detail-text table tbody tr:hover {
        background: transparent;
    }
    
    /* Images */
    .message-content .markdown-image:hover,
    .tree-detail-text .markdown-image:hover {
        opacity: 1;
    }
    
    .generated-image-container:hover {
        box-shadow: none;
    }
    
    .generated-image-container:hover .image-actions {
        opacity: 1;
    }
    
    .image-action-btn:hover {
        background: rgba(0, 0, 0, 0.6);
    }
    
    /* Assumptions */
    .assumption-checkbox:hover {
        background: var(--surface-1);
    }
    
    .custom-option-trigger:hover {
        border-color: var(--border-default);
        color: var(--text-muted);
        border-style: dashed;
    }
    
    /* Modal buttons */
    .close-modal-btn:hover,
    .close-sidebar-btn:hover {
        background: transparent;
        color: var(--text-tertiary);
    }
    
    .close-modal-btn:active,
    .close-sidebar-btn:active {
        background: var(--surface-hover);
        color: var(--text-primary);
    }
    
    .pdf-viewer-close:hover {
        background: var(--surface-2);
        color: var(--text-secondary);
    }
    
    .pdf-viewer-close:active {
        background: var(--surface-hover);
        color: var(--text-primary);
    }
    
    .image-modal-btn:hover {
        background: var(--surface-2);
        color: var(--text-secondary);
    }
    
    .image-modal-btn:active {
        background: var(--surface-hover);
        color: var(--text-primary);
    }
    
    /* Queue items */
    .queue-item:hover {
        background: transparent;
    }
    
    /* Citations */
    .citation-item:hover {
        border-color: var(--border-default);
        color: var(--text-secondary);
        background: var(--bg-primary);
    }
    
    /* Toast */
    .toast-close:hover {
        background: transparent;
        color: var(--text-muted);
    }
    
    /* Edit button */
    .edit-button.cancel:hover {
        background: var(--surface-2);
    }
    
    /* Load more button */
    .load-more-button:hover {
        color: var(--text-muted);
    }
    
    /* Copy success state */
    .action-button.copy-success:hover {
        color: var(--success);
    }
    
    /* Default items */
    .default-item:hover {
        background: var(--surface-1);
    }
    
    /* Settings modal */
    .setting-section .model-label:hover {
        background: transparent;
    }
    
    .cancel-btn:hover {
        background: var(--surface-2);
    }
    
    .save-btn:hover {
        background: var(--accent);
    }
    
    /* Code block hover - always show copy button on touch */
    .code-block-wrapper .code-copy-btn {
        opacity: 1;
    }
    
    /* Inline tree - disable all hover feedback */
    .tree-node,
    .tree-node-fullscreen,
    #treeSvg,
    #treeFullscreenSvg {
        -webkit-tap-highlight-color: transparent;
    }
    
    .tree-node rect,
    .tree-node-fullscreen rect {
        transition: none;
    }
    
    /* Disable hover wrapper effects */
    .code-block-wrapper:hover .code-copy-btn {
        /* Already visible via opacity: 1 above */
    }
    
    /* Global tap highlight removal for touch */
    button, a, [role="button"], .clickable {
        -webkit-tap-highlight-color: transparent;
    }
}