/* Game Maker AI - Unified Orca Theme */

:root {
    /* Orca Brand Colors - Unified across entire site */
    --orca-navy: #0A1F24;
    --orca-teal: #25464A;
    --orca-sand: #E6DCCB;
    --orca-mist: #8CA0A3;
    --orca-border-subtle: rgba(230, 220, 203, 0.06);
    --orca-border-default: rgba(230, 220, 203, 0.10);
    --orca-border-strong: rgba(230, 220, 203, 0.16);
    
    /* Editor-specific mappings using Orca colors */
    --bg-primary: #0A1F24;
    --bg-secondary: #0D2832;
    --bg-tertiary: #132F3A;
    --bg-hover: #1A3844;
    --bg-active: #25464A;
    
    --border-color: var(--orca-border-default);
    --border-active: var(--orca-border-strong);
    
    --text-primary: var(--orca-sand);
    --text-secondary: var(--orca-mist);
    --text-muted: rgba(140, 160, 163, 0.7);
    
    /* Accent colors - teal-based */
    --accent-primary: #25464A;
    --accent-secondary: #3A6A70;
    --accent-glow: rgba(37, 70, 74, 0.35);
    
    /* Semantic colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3A6A70;
    
    --gradient-1: linear-gradient(135deg, rgba(37, 70, 74, 0.9) 0%, rgba(26, 54, 57, 0.95) 100%);
    --gradient-2: linear-gradient(180deg, #0A1F24 0%, #0D2832 50%, #132F3A 100%);
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 20px var(--accent-glow);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Light Theme - Sand-based */
[data-theme="light"] {
    --bg-primary: #F5F0EB;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #EDE8E2;
    --bg-hover: #E6DCCB;
    --bg-active: #D9CDB8;
    
    --border-color: rgba(10, 31, 36, 0.1);
    --border-active: rgba(10, 31, 36, 0.2);
    
    --text-primary: #0A1F24;
    --text-secondary: #25464A;
    --text-muted: #8CA0A3;
    
    --accent-primary: #25464A;
    --accent-secondary: #0A1F24;
    --accent-glow: rgba(37, 70, 74, 0.15);
    
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    
    --shadow-sm: 0 2px 8px rgba(10, 31, 36, 0.08);
    --shadow-md: 0 4px 16px rgba(10, 31, 36, 0.1);
    --shadow-lg: 0 8px 32px rgba(10, 31, 36, 0.12);
    
    --gradient-1: linear-gradient(135deg, #25464A 0%, #3A6A70 50%, #8CA0A3 100%);
    --gradient-2: linear-gradient(135deg, #F5F0EB 0%, #EDE8E2 100%);
}

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

html, body {
    height: 100%;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}

/* Main Layout */
.app-container {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: 100vw;
    background: var(--bg-primary);
    overflow: hidden;
}

/* Left Panel - Chat/Code Toggle */
.left-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    width: 420px;
    height: 100%;
    min-width: 280px;
    max-width: 800px;
    flex-shrink: 0;
    /* Ensure all children stay within bounds */
    contain: layout;
}

.left-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.panel-home-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.9;
    transition: opacity 0.15s ease;
}

.panel-home-btn:hover {
    opacity: 1;
}

.panel-home-btn img {
    border-radius: 4px;
}

.panel-header-spacer {
    flex: 1;
}

/* Top Right Controls - Fixed Position */
.editor-top-right {
    position: fixed;
    top: 10px;
    right: 16px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Auto-reload toggle - Clean minimal style */
.editor-auto-reload {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease;
}

.editor-auto-reload:hover {
    color: var(--text-primary);
}

.editor-auto-reload input[type="checkbox"] {
    display: none;
}

/* Custom toggle switch */
.editor-auto-reload .toggle-switch {
    position: relative;
    width: 32px;
    height: 18px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9px;
    transition: background 0.2s ease;
}

.editor-auto-reload .toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.editor-auto-reload input:checked + .toggle-switch {
    background: var(--orca-teal);
}

.editor-auto-reload input:checked + .toggle-switch::after {
    left: 16px;
    background: var(--orca-sand);
}

.editor-auto-reload span:last-child {
    white-space: nowrap;
}

/* Editor User Menu */
.editor-user-menu {
    position: relative;
}

.editor-user-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.editor-user-btn:hover {
    transform: scale(1.05);
}

.editor-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orca-teal) 0%, var(--orca-mist) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--orca-sand);
    border: 2px solid rgba(230, 220, 203, 0.2);
    transition: all 0.15s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.editor-user-btn:hover .editor-user-avatar {
    border-color: var(--orca-sand);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.editor-user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.editor-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.editor-user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.editor-user-info {
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    margin-bottom: 4px;
}

.editor-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.editor-user-credits {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.credits-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

.credits-dot.pro {
    background: #f59e0b;
}

/* Plan badge styles */
.editor-user-plan {
    margin-bottom: 8px;
}

.plan-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-badge.free {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}

.plan-badge.pro {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.plan-badge.pro-plus {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(236, 72, 153, 0.15));
    color: #a855f7;
}

/* Usage display in user dropdown */
.editor-user-usage {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.usage-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.usage-label {
    color: var(--text-secondary);
}

.usage-value {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
}

/* Quota warning message - subtle light yellow */
.quota-warning {
    color: #fbbf24;
    font-size: 13px;
    padding: 10px 14px;
    margin: 8px 0;
    background: rgba(251, 191, 36, 0.08);
    border-radius: 8px;
    line-height: 1.5;
}

.quota-warning a {
    color: #fbbf24;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 500;
}

.quota-warning a:hover {
    color: #f59e0b;
}

.editor-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

.editor-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.12s ease;
    text-decoration: none;
    text-align: left;
}

.editor-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.editor-dropdown-item svg {
    opacity: 0.7;
    flex-shrink: 0;
}

.editor-dropdown-item:hover svg {
    opacity: 1;
}

/* Clean text-style tabs */
.panel-tabs {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}

.panel-tab {
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

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

.panel-tab.active {
    color: var(--text-primary);
}

.panel-tab.active::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: var(--accent-secondary);
    border-radius: 1px;
}

/* Collapse button */
.panel-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.panel-collapse-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Resize handle - positioned on right edge of left panel */
.panel-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 100;
    background: transparent;
    transition: background 0.15s ease;
}

/* Visible indicator line */
.panel-resize-handle::after {
    content: '';
    position: absolute;
    right: 2px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: transparent;
    transition: background 0.15s ease;
}

.panel-resize-handle:hover {
    background: rgba(230, 220, 203, 0.05);
}

.panel-resize-handle:hover::after {
    background: var(--orca-sand);
    opacity: 0.5;
}

.panel-resize-handle.active,
.panel-resize-handle.active:hover {
    background: rgba(230, 220, 203, 0.1);
}

.panel-resize-handle.active::after {
    background: var(--orca-sand);
    opacity: 1;
}

/* Collapsed state */
.left-panel.collapsed {
    width: 48px !important;
    min-width: 48px;
}

.left-panel.collapsed .panel-tabs,
.left-panel.collapsed .panel-view,
.left-panel.collapsed .panel-resize-handle {
    display: none;
}

.left-panel.collapsed .left-panel-header {
    flex-direction: column;
    padding: 12px 8px;
    gap: 16px;
}

.left-panel.collapsed .panel-collapse-btn {
    transform: rotate(180deg);
}

/* Panel Views */
.panel-view {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    max-width: 100%;
}

.panel-view.active {
    display: flex;
}

/* Agent View */
.agent-view {
    /* Inherits flex styles from panel-view */
    overflow-x: hidden;
    position: relative;
}

.agent-view .conversation-bar {
    flex-shrink: 0;
}

.agent-view .chat-messages {
    flex: 1;
    overflow-y: auto;
}

.agent-view .chat-input-container {
    flex-shrink: 0;
}

/* Code View */
.code-view {
    /* Inherits flex styles from panel-view */
}

.code-view-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* File Panel - DEPRECATED, keeping for backwards compatibility */
.file-panel {
    grid-row: 1 / -1;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    transition: width 0.2s ease;
    width: 240px;
}

.file-panel.collapsed {
    width: 48px;
}

.file-panel.collapsed .file-nav-title,
.file-panel.collapsed .file-nav-actions,
.file-panel.collapsed .file-nav-project-name,
.file-panel.collapsed .file-tree {
    display: none;
}

.file-panel.collapsed .file-nav-header {
    justify-content: center;
    padding: 10px 8px;
}

.file-panel.collapsed .file-nav-project {
    justify-content: center;
    padding: 8px;
}

.file-nav-collapse {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.file-nav-collapse:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.file-nav-collapse svg {
    transition: transform 0.2s ease;
}

/* Header */
.header {
    grid-column: 2 / -1;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 34px;
    height: 34px;
    background: var(--gradient-1);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.logo-text {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-text span {
    color: var(--accent-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Conversation Bar - Top of Chat Panel */
.conversation-bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 1001;
    flex-shrink: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.conversation-current {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    min-width: 0;
}

.conversation-current:hover {
    background: var(--bg-hover);
    border-color: var(--border-active);
}

.conversation-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.conversation-name {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
}

.new-chat-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.new-chat-btn:hover {
    background: var(--accent-secondary);
    transform: scale(1.05);
}

/* Conversation Dropdown */
.conversation-dropdown {
    position: absolute;
    top: calc(100% + 11px);
    left: 0;
    right: 0;
    max-height: 0;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.2s ease;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    box-sizing: border-box;
}

.conversation-dropdown.active {
    max-height: 400px;
    border-color: var(--border-color);
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    opacity: 1;
    visibility: visible;
    overflow-y: auto;
    overflow-x: hidden;
}

.conversation-dropdown-header {
    padding: 8px 12px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.conversation-list {
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
}

.conversation-empty {
    padding: 24px 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* Conversation Loading State */
.conversation-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    height: 100%;
    color: var(--text-muted);
    font-size: 14px;
}

.conversation-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--orca-sand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.conversation-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.12s;
}

.conversation-item:last-child {
    border-bottom: none;
}

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

.conversation-item.active {
    background: var(--accent-glow);
    border-left: 2px solid var(--accent-primary);
}

.conversation-item-info {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.conversation-item-name {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.conversation-item-meta {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 1px;
}

.conversation-item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.12s;
}

.conversation-item:hover .conversation-item-actions {
    opacity: 1;
}

.conversation-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.12s;
}

.conversation-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.conversation-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

/* Message Edit Button */
.message-edit-btn {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all 0.15s;
    margin-left: 8px;
}

.message.user:hover .message-edit-btn {
    opacity: 1;
}

.message-edit-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Inline Edit */
.message.editing {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin: 4px 0;
}

.inline-edit-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inline-edit-textarea {
    width: 100%;
    min-height: 60px;
    max-height: 300px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-md);
    resize: none;
    outline: none;
}

.inline-edit-textarea:focus {
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.inline-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.inline-edit-cancel,
.inline-edit-send {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.inline-edit-cancel {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.inline-edit-cancel:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.inline-edit-send {
    background: var(--accent-primary);
    border: none;
    color: white;
}

.inline-edit-send:hover {
    background: var(--accent-secondary);
}

/* Theme Toggle */
.theme-toggle {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

/* Buttons */
.btn {
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-active);
}

.btn-primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-secondary);
    box-shadow: var(--shadow-glow);
}

/* Game Panel */
.game-panel {
    flex: 1;
    min-width: 0;
    height: 100%;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* File Preview */
.file-preview {
    position: absolute;
    inset: 0;
    background: var(--bg-primary);
    display: none;
    flex-direction: column;
    z-index: 5;
}

.file-preview-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.file-preview-path {
    flex: 1;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-size {
    font-size: 12px;
    color: var(--text-muted);
}

.file-preview-close {
    padding: 6px 12px;
    font-size: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.file-preview-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.file-preview-code {
    flex: 1;
    overflow: auto;
    padding: 16px;
}

.file-preview-code pre {
    margin: 0;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
}

.file-preview-image {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: auto;
    background: var(--bg-tertiary);
}

.file-preview-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.panel-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.game-preview {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.game-preview iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--bg-primary);
}

.game-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
}

.game-placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.15;
    font-weight: 800;
    letter-spacing: -2px;
}

/* Chat Panel */
.chat-panel {
    position: relative;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-color);
    min-height: 0; /* Critical for flex scrolling */
    z-index: 10; /* Above the game panel */
    min-width: 320px;
    max-width: 700px;
}

/* Resize Handle */
.chat-resize-handle {
    position: absolute;
    left: -4px;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    z-index: 100;
    background: transparent;
    transition: background 0.15s;
}

.chat-resize-handle:hover,
.chat-resize-handle.dragging {
    background: var(--accent-primary);
}

.chat-resize-handle::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 40px;
    background: var(--border-color);
    border-radius: 1px;
    opacity: 0;
    transition: opacity 0.15s;
}

.chat-resize-handle:hover::before,
.chat-resize-handle.dragging::before {
    opacity: 1;
    background: white;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0; /* Critical for flex scrolling */
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--border-active);
}

/* Messages */
.message {
    display: flex;
    gap: 12px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--gradient-1);
    color: white;
}

.message.assistant .message-avatar {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.message-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
}

.message-body {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.message-body p {
    margin-bottom: 8px;
}

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

/* Text blocks - for interleaved text/tool flow */
.message-text-block {
    margin-bottom: 8px;
}

.message-text-block:last-child {
    margin-bottom: 0;
}

.message-text-block:empty {
    display: none;
}

/* Thinking Block - AI reasoning display (simple gray text) */
.thinking-block {
    margin: 4px 0 8px 0;
}

.thinking-block[open] .thinking-content {
    max-height: 150px;
    overflow-y: auto;
}

.thinking-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    color: var(--text-muted);
    font-size: 12px;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.thinking-header:hover {
    opacity: 1;
}

.thinking-header::marker,
.thinking-header::-webkit-details-marker {
    display: none;
}

.thinking-header::before {
    content: '▶';
    font-size: 8px;
    transition: transform 0.15s ease;
    opacity: 0.5;
}

.thinking-block[open] .thinking-header::before {
    transform: rotate(90deg);
}

.thinking-label {
    font-style: italic;
}

.thinking-content {
    padding: 4px 0 4px 16px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-muted);
    font-style: italic;
    white-space: pre-wrap;
    word-break: break-word;
    opacity: 0.8;
}

.thinking-content::-webkit-scrollbar {
    width: 4px;
}

.thinking-content::-webkit-scrollbar-track {
    background: transparent;
}

.thinking-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.thinking-content::-webkit-scrollbar-thumb:hover {
    background: var(--border-active);
}

.message-body code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent-secondary);
}

.message-body pre {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border-color);
}

.message-body pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

.message-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.message-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid var(--border-color);
}

.message-image:hover {
    transform: scale(1.02);
}

/* Chat Input */
.chat-input-container {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.chat-input-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.attachment-preview {
    position: relative;
    width: 56px;
    height: 56px;
}

.attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.attachment-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: var(--error);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-box {
    flex: 1;
    position: relative;
}

.chat-input {
    width: 100%;
    min-height: 44px;
    max-height: 200px;
    padding: 12px 44px 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    resize: none;
    outline: none;
    transition: all 0.2s;
}

.chat-input:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

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

.chat-input-actions {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: flex;
    gap: 4px;
}

.chat-input-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
}

.chat-input-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.send-btn {
    width: 44px;
    height: 44px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-secondary);
    box-shadow: var(--shadow-glow);
}

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

.stop-btn {
    min-width: 44px;
    height: 44px;
    padding: 0 14px;
    gap: 6px;
    background: var(--error);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
}

.stop-btn:hover:not(:disabled) {
    background: #dc2626;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.stop-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.stop-btn .spin {
    animation: spin 1s linear infinite;
}

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

.message-stopped {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
    margin-top: 8px;
}

.chat-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 13px;
    line-height: 1.5;
    margin-top: 8px;
}

.chat-error svg {
    flex-shrink: 0;
    margin-top: 2px;
}

/* Screenshot display */
.chat-screenshot {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin: 8px 0;
}

.chat-screenshot .screenshot-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.chat-screenshot img {
    display: block;
    max-width: 400px;
}

/* Drop zone */
.drop-zone-overlay {
    position: fixed;
    inset: 0;
    background: rgba(37, 99, 235, 0.1);
    border: 3px dashed var(--accent-primary);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: none;
}

.drop-zone-overlay.active {
    display: flex;
}

.drop-zone-content {
    text-align: center;
    padding: 40px;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.drop-zone-icon {
    font-size: 32px;
    margin-bottom: 12px;
    font-weight: 700;
    color: var(--accent-primary);
}

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

/* Image modal */
.image-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: zoom-out;
}

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

.image-modal img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--radius-md);
}

/* Model selector above input - removed old styles, now using custom dropdown */

/* Custom Model Selector Dropdown */
.model-selector {
    position: relative;
}

.model-selector-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s ease;
}

.model-selector-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.model-selector.open .model-selector-btn {
    background: var(--bg-hover);
}

.model-selector-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
}

.model-selector-name {
    font-weight: 500;
}

.model-selector-arrow {
    opacity: 0.5;
    transition: transform 0.2s ease;
}

.model-selector.open .model-selector-arrow {
    transform: rotate(180deg);
}

.model-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.model-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.model-option {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.12s ease;
}

.model-option:hover {
    background: var(--bg-hover);
}

.model-option.active {
    background: var(--bg-active);
}

.model-option-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.model-option-desc {
    font-size: 11px;
    color: var(--text-muted);
}

.model-option.active .model-option-name {
    color: var(--orca-sand);
}

/* Legacy select (hidden) */
.model-select {
    display: none;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 20px;
    font-weight: 800;
    color: var(--accent-primary);
    opacity: 0.3;
}

.welcome-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.welcome-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 280px;
    line-height: 1.6;
}

.welcome-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 28px;
    width: 100%;
    max-width: 300px;
}

.welcome-suggestion {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
    font-size: 13px;
}

.welcome-suggestion:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

.welcome-suggestion-icon {
    margin-right: 8px;
    color: var(--accent-primary);
    font-weight: 600;
}

/* Streaming indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Tool Result Styles */
.tool-result-error {
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}

.tool-result-json {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    background: var(--bg-secondary);
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    max-height: 200px;
}

.tool-result-diff {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    background: var(--bg-secondary);
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    white-space: pre-wrap;
}

.tool-result-empty {
    color: var(--text-muted);
    font-style: italic;
}

.tool-error-text {
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}

/* File content with line numbers */
.tool-file-content {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    line-height: 1.5;
    background: var(--bg-secondary);
    padding: 8px 0;
    border-radius: 4px;
    overflow-x: auto;
    max-height: 300px;
    margin: 0;
    white-space: pre;
}

/* Grep results styling */
.tool-grep-file {
    margin-bottom: 8px;
    border-radius: 4px;
    overflow: hidden;
}

.tool-grep-filename {
    font-size: 11px;
    font-weight: 500;
    color: var(--accent-primary);
    padding: 4px 8px;
    background: var(--bg-secondary);
}

.tool-grep-match {
    display: flex;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    line-height: 1.6;
    border-bottom: 1px solid var(--border-color);
}

.tool-grep-match:last-child {
    border-bottom: none;
}

.tool-grep-line {
    flex-shrink: 0;
    width: 48px;
    padding: 2px 8px;
    text-align: right;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    user-select: none;
}

.tool-grep-content {
    flex: 1;
    padding: 2px 8px;
    overflow-x: auto;
    white-space: pre;
}

.tool-grep-content mark {
    background: var(--accent-glow);
    color: var(--accent-primary);
    padding: 1px 2px;
    border-radius: 2px;
}

.tool-result-summary {
    font-size: 10px;
    color: var(--text-muted);
    padding: 4px 8px;
    margin-top: 4px;
}

/* Directory listing */
.tool-list {
    max-height: 200px;
    overflow-y: auto;
}

.tool-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 3px;
}

.tool-list-item:hover {
    background: var(--bg-secondary);
}

.tool-list-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.tool-list-icon svg {
    display: block;
}

.tool-list-dir {
    color: var(--accent-primary);
}

.tool-list-file {
    color: var(--text-primary);
}

.tool-list-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-list-meta {
    color: var(--text-muted);
    font-size: 10px;
    flex-shrink: 0;
}

/* ============================================
   FILE PREVIEW MODAL
   ============================================ */

.file-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.file-preview-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.file-preview-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-preview-image-content {
    min-width: 300px;
}

.file-preview-code-content {
    width: 80vw;
    height: 80vh;
}

.file-preview-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.file-preview-path {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.file-preview-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.15s;
}

.file-preview-close:hover {
    background: var(--error);
    color: white;
}

.file-preview-run {
    padding: 6px 12px;
    background: var(--success);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.file-preview-run:hover {
    background: #0d9c6d;
}

.file-preview-image {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-conic-gradient(var(--bg-tertiary) 0% 25%, var(--bg-primary) 0% 50%) 50% / 20px 20px;
}

.file-preview-image img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    image-rendering: pixelated;
}

.file-preview-code {
    flex: 1;
    overflow: auto;
    padding: 0;
}

.file-preview-code pre {
    margin: 0;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    background: transparent;
}

.file-preview-code code {
    display: block;
    white-space: pre;
}

/* ============================================
   TOKEN USAGE INDICATOR
   ============================================ */

.token-usage-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border-bottom: 1px solid var(--border-color);
}

.token-usage-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
    max-width: 150px;
}

.token-usage-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease, background 0.3s ease;
}

.token-usage-text {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    white-space: nowrap;
}

/* ============================================
   SCREENSHOT MESSAGE
   ============================================ */

.screenshot-message {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin: 8px 0;
}

.screenshot-avatar {
    background: linear-gradient(135deg, #8b5cf6, #6366f1) !important;
    color: white !important;
}

.screenshot-avatar svg {
    width: 16px;
    height: 16px;
}

.screenshot-preview {
    background: repeating-conic-gradient(var(--bg-secondary) 0% 25%, var(--bg-primary) 0% 50%) 50% / 16px 16px;
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    justify-content: center;
    margin: 8px 0;
}

.screenshot-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: var(--shadow-md);
}

.screenshot-preview img:hover {
    transform: scale(1.02);
}

.screenshot-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: 8px 0 0 0;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-primary);
}

/* ========== PLANNING SYSTEM STYLES ========== */

/* Inline Planner (inside tool result) */
.planner-inline {
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.planner-stream-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.planner-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.planner-status-indicator.active {
    background: var(--accent-primary);
    animation: pulse 1.5s ease-in-out infinite;
}

.planner-status-indicator.done {
    background: var(--success);
}

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

.planner-stream {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg-primary);
}

.planner-text {
    color: var(--text-primary);
}

.planner-tools {
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.planner-tool-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 11px;
    border-bottom: 1px solid var(--border-color);
}

.planner-tool-item:last-child {
    border-bottom: none;
}

.planner-tool-icon {
    color: var(--text-muted);
    font-size: 10px;
}

.planner-tool-name {
    font-weight: 500;
    color: var(--text-primary);
}

.planner-tool-status {
    margin-left: auto;
    font-size: 10px;
}

.planner-tool-status.running {
    color: var(--accent-primary);
}

.planner-tool-status.success {
    color: var(--success);
}

.planner-tool-status.error {
    color: var(--error);
}

.planner-error {
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    font-size: 12px;
}

.planner-stopped {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}

/* Plan Display (inside tool result) */
.plan-display {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.plan-display.plan-completed {
    border-left: 3px solid var(--success);
}

.plan-reasoning {
    border-bottom: 1px solid var(--border-color);
}

.plan-reasoning-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: background 0.15s;
}

.plan-reasoning-toggle:hover {
    background: var(--bg-hover);
}

.plan-reasoning-toggle svg {
    transition: transform 0.2s;
}

.plan-reasoning-toggle.expanded svg {
    transform: rotate(180deg);
}

.plan-reasoning-content {
    padding: 0 16px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
}

.plan-reasoning-content.collapsed {
    display: none;
}

.plan-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.plan-section:last-child {
    border-bottom: none;
}

.plan-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-section-count {
    font-weight: normal;
    padding: 2px 8px;
    background: var(--bg-hover);
    border-radius: 10px;
}

.plan-section-count .completed-count {
    color: var(--success);
    font-weight: 600;
}

/* Assets Grid */
.plan-assets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.plan-asset {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px;
    font-size: 12px;
}

.plan-asset-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.plan-asset-name {
    font-weight: 600;
    color: var(--text-primary);
}

.plan-asset-resolution {
    padding: 2px 6px;
    background: var(--accent-glow);
    color: var(--accent-primary);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.plan-asset-parallel {
    margin-left: auto;
    color: var(--success);
    font-size: 14px;
    font-weight: bold;
}

.plan-asset-prompt {
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 4px;
}

.plan-asset-path {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
}

.plan-asset-deps {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border-color);
    color: var(--warning);
    font-size: 10px;
}

/* Steps */
.plan-steps {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.plan-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.plan-step.pending {
    opacity: 0.7;
}

.plan-step.in-progress {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
}

.plan-step.completed {
    border-color: var(--success);
    opacity: 0.8;
}

.plan-step.completed .plan-step-description {
    text-decoration: line-through;
    color: var(--text-muted);
}

.plan-step-checkbox {
    flex-shrink: 0;
    padding-top: 2px;
}

.plan-step-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border-active);
    appearance: none;
    cursor: default;
    transition: all 0.2s;
}

.plan-step.completed .plan-step-checkbox input[type="checkbox"] {
    background: var(--success);
    border-color: var(--success);
}

.plan-step.completed .plan-step-checkbox input[type="checkbox"]::after {
    content: '✓';
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: bold;
}

.plan-step-content {
    flex: 1;
    font-size: 13px;
    line-height: 1.4;
}

.plan-step-number {
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 4px;
}

.plan-step-description {
    color: var(--text-primary);
}

/* ========== Asset Preview ========== */
.asset-preview {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
}

.asset-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.asset-preview-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

.asset-preview-icon {
    width: 16px;
    height: 16px;
    stroke: var(--accent-primary);
}

.asset-animated-badge {
    background: var(--accent-primary);
    color: white;
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.asset-preview-path {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'Berkeley Mono', monospace;
}

.asset-preview-frame {
    position: relative;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Checkerboard pattern for transparency */
    background-image: 
        linear-gradient(45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(-45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1a1a 75%),
        linear-gradient(-45deg, transparent 75%, #1a1a1a 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
}

.asset-preview-iframe {
    border: none;
    background: transparent;
    display: block;
}

.asset-preview-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-secondary);
    font-size: 11px;
}

.asset-preview-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.asset-preview-description {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.4;
}

.asset-preview-note {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

.asset-preview-note svg {
    stroke: var(--accent-primary);
    flex-shrink: 0;
}

.asset-result {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.asset-result-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.asset-result-status .tool-icon.success {
    stroke: var(--success);
    width: 14px;
    height: 14px;
}

/* Responsive - only for very small screens */
@media (max-width: 600px) {
    .app-container {
        flex-direction: column;
    }

    .left-panel {
        width: 100% !important;
        max-width: none;
        min-width: 0;
        height: 50%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .left-panel-header {
        padding: 8px 12px;
    }
    
    .panel-tabs .panel-tab {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    .panel-resize-handle {
        display: none;
    }
    
    .file-preview-code-content {
        width: 95vw;
        height: 85vh;
    }
    
    .planner-modal {
        width: 95vw;
        max-height: 80vh;
    }
    
    .plan-assets-grid {
        grid-template-columns: 1fr;
    }
}
