:root { --bg-color: #f5f5f5; --card-bg: #ffffff; --user-bg: #e3f2fd; --user-border: #1976d2; --assistant-bg: #f5f5f5; --assistant-border: #9e9e9e; --thinking-bg: #fff8e1; --thinking-border: #ffc107; --thinking-text: #666; --tool-bg: #f3e5f5; --tool-border: #9c27b0; --tool-result-bg: #e8f5e9; --tool-error-bg: #ffebee; --text-color: #212121; --text-muted: #757575; --code-bg: #263238; --code-text: #aed581; --sidebar-width: 280px; --border-color: #e0e0e0; --tool-reply-bg: #fff8e1; --input-bg: #ffffff; }

/* Dark mode */
[data-theme="dark"] { --bg-color: #121212; --card-bg: #1e1e1e; --user-bg: #1a3a5c; --user-border: #42a5f5; --assistant-bg: #1e1e1e; --assistant-border: #757575; --thinking-bg: #2d2a1f; --thinking-border: #ffc107; --thinking-text: #b0a080; --tool-bg: #2d1f3d; --tool-border: #ba68c8; --tool-result-bg: #1f2d1f; --tool-error-bg: #3d1f1f; --text-color: #e0e0e0; --text-muted: #9e9e9e; --code-bg: #1a1a1a; --code-text: #aed581; --border-color: #333; --tool-reply-bg: #2d2a1f; --input-bg: #2a2a2a; }
* { box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg-color); color: var(--text-color); margin: 0; padding: 16px; line-height: 1.6; }
.container { max-width: 800px; margin: 0 auto; }
h1 { font-size: 1.5rem; margin-bottom: 24px; padding-bottom: 8px; border-bottom: 2px solid var(--user-border); }
.project-header-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.project-header-bar h1 { margin-bottom: 0; padding-bottom: 0; border-bottom: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-icon-btn { width: 24px; height: 24px; padding: 4px; background: transparent; border: none; border-radius: 4px; cursor: pointer; opacity: 0.5; transition: opacity 0.15s, background 0.15s; flex-shrink: 0; }
.copy-icon-btn::before { content: ''; display: block; width: 16px; height: 16px; background-color: var(--text-muted); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='14' height='14' x='8' y='8' rx='2' ry='2'/%3E%3Cpath d='M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='14' height='14' x='8' y='8' rx='2' ry='2'/%3E%3Cpath d='M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2'/%3E%3C/svg%3E") center/contain no-repeat; }
.copy-icon-btn:hover { opacity: 1; background: rgba(0,0,0,0.05); }
.copy-icon-btn:hover::before { background-color: var(--user-border); }
.copy-icon-btn.copied::before { background-color: #4caf50; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat; }
.copy-icon-btn.copied { opacity: 1; }
.session-id-bar { display: flex; align-items: center; gap: 6px; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 2px solid var(--user-border); }
.session-id-label { font-size: 0.8rem; color: var(--text-muted); }
.session-id-value { font-size: 0.75rem; color: var(--text-muted); background: rgba(0,0,0,0.05); padding: 2px 8px; border-radius: 4px; }
.copy-icon-btn-small { width: 18px; height: 18px; padding: 2px; }
.copy-icon-btn-small::before { width: 14px; height: 14px; }
.header-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; border-bottom: 2px solid var(--user-border); padding-bottom: 8px; margin-bottom: 24px; }
.header-row h1 { border-bottom: none; padding-bottom: 0; margin-bottom: 0; flex: 1; min-width: 200px; }
.message { margin-bottom: 16px; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); scroll-margin-bottom: 120px; }
.message.user { background: var(--user-bg); border-left: 4px solid var(--user-border); scroll-margin-top: 70px; }
.message.assistant { background: var(--card-bg); border-left: 4px solid var(--assistant-border); }
.message.tool-reply { background: var(--tool-reply-bg); border-left: 4px solid #ff9800; }
.tool-reply .role-label { color: #e65100; }
.tool-reply .tool-result { background: transparent; padding: 0; margin: 0; }
.tool-reply .tool-result .truncatable.truncated::after { background: linear-gradient(to bottom, transparent, #fff8e1); }
.message-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; background: rgba(0,0,0,0.03); font-size: 0.85rem; }
.role-label { font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.user .role-label { color: var(--user-border); }
time { color: var(--text-muted); font-size: 0.8rem; }
.timestamp-link { color: inherit; text-decoration: none; }
.timestamp-link:hover { text-decoration: underline; }
.message:target { animation: highlight 2s ease-out; }
@keyframes highlight { 0% { background-color: rgba(25, 118, 210, 0.2); } 100% { background-color: transparent; } }
.message-content { padding: 16px; }
.message-content p { margin: 0 0 12px 0; }
.message-content p:last-child { margin-bottom: 0; }
.thinking { background: var(--thinking-bg); border: 1px solid var(--thinking-border); border-radius: 8px; padding: 12px; margin: 12px 0; font-size: 0.9rem; color: var(--thinking-text); }
.thinking-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: #f57c00; margin-bottom: 8px; }
.thinking p { margin: 8px 0; }
.assistant-text { margin: 8px 0; }
.tool-use { background: var(--tool-bg); border: 1px solid var(--tool-border); border-radius: 8px; padding: 12px; margin: 12px 0; }
.tool-header { font-weight: 600; color: var(--tool-border); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.tool-icon { font-size: 1.1rem; }
.tool-description { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 8px; font-style: italic; }
.tool-result { background: var(--tool-result-bg); border-radius: 8px; padding: 12px; margin: 12px 0; }
.tool-result.tool-error { background: var(--tool-error-bg); }
.file-tool { border-radius: 8px; padding: 12px; margin: 12px 0; }
.write-tool { background: linear-gradient(135deg, #e3f2fd 0%, #e8f5e9 100%); border: 1px solid #4caf50; }
.edit-tool { background: linear-gradient(135deg, #fff3e0 0%, #fce4ec 100%); border: 1px solid #ff9800; }
.file-tool-header { font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; font-size: 0.95rem; }
.write-header { color: #2e7d32; }
.edit-header { color: #e65100; }
.read-header { color: #1565c0; }
.read-tool { background: linear-gradient(135deg, #e3f2fd 0%, #e8eaf6 100%); border: 1px solid #1976d2; }
.read-range { font-weight: normal; font-size: 0.85em; color: var(--text-muted); }
.file-tool-icon { font-size: 1rem; }
.file-tool-path { font-family: monospace; background: rgba(0,0,0,0.08); padding: 2px 8px; border-radius: 4px; }
.file-tool-fullpath { font-family: monospace; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; word-break: break-all; }
.file-content { margin: 0; }
.edit-section { display: flex; margin: 4px 0; border-radius: 4px; overflow: hidden; }
.edit-section .copy-wrapper { flex: 1; }
.edit-label { padding: 8px 12px; font-weight: bold; font-family: monospace; display: flex; align-items: flex-start; }
.edit-old { background: #fce4ec; }
.edit-old .edit-label { color: #b71c1c; background: #f8bbd9; }
.edit-old .edit-content { color: #880e4f; }
.edit-new { background: #e8f5e9; }
.edit-new .edit-label { color: #1b5e20; background: #a5d6a7; }
.edit-new .edit-content { color: #1b5e20; }
.edit-content { margin: 0; flex: 1; background: transparent; font-size: 0.85rem; }
.edit-replace-all { font-size: 0.75rem; font-weight: normal; color: var(--text-muted); }
.write-tool .truncatable.truncated::after { background: linear-gradient(to bottom, transparent, #e6f4ea); }
.edit-tool .truncatable.truncated::after { background: linear-gradient(to bottom, transparent, #fff0e5); }
.todo-list { background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%); border: 1px solid #81c784; border-radius: 8px; padding: 12px; margin: 12px 0; }
.todo-header { font-weight: 600; color: #2e7d32; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; font-size: 0.95rem; }
.todo-items { list-style: none; margin: 0; padding: 0; }
.todo-item { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgba(0,0,0,0.06); font-size: 0.9rem; }
.todo-item:last-child { border-bottom: none; }
.todo-icon { flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-weight: bold; border-radius: 50%; }
.todo-completed .todo-icon { color: #2e7d32; background: rgba(46, 125, 50, 0.15); }
.todo-completed .todo-content { color: #558b2f; text-decoration: line-through; }
.todo-in-progress .todo-icon { color: #f57c00; background: rgba(245, 124, 0, 0.15); }
.todo-in-progress .todo-content { color: #e65100; font-weight: 500; }
.todo-pending .todo-icon { color: #757575; background: rgba(0,0,0,0.05); }
.todo-pending .todo-content { color: #616161; }
pre { background: var(--code-bg); color: var(--code-text); padding: 12px; border-radius: 6px; overflow-x: auto; font-size: 0.85rem; line-height: 1.5; margin: 8px 0; white-space: pre-wrap; word-wrap: break-word; font-family: ui-monospace, "SF Mono", Menlo, Monaco, "Cascadia Code", "Consolas", monospace; }
pre.json { color: #e0e0e0; }
code { background: rgba(0,0,0,0.08); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; font-family: ui-monospace, "SF Mono", Menlo, Monaco, "Cascadia Code", "Consolas", monospace; }
pre code { background: none; padding: 0; }
.user-content { margin: 0; }
.truncatable { position: relative; }
.truncatable.truncated .truncatable-content { max-height: 200px; overflow: hidden; }
.truncatable.truncated::after { content: ''; position: absolute; bottom: 32px; left: 0; right: 0; height: 60px; background: linear-gradient(to bottom, transparent, var(--card-bg)); pointer-events: none; }
.message.user .truncatable.truncated::after { background: linear-gradient(to bottom, transparent, var(--user-bg)); }
.message.tool-reply .truncatable.truncated::after { background: linear-gradient(to bottom, transparent, #fff8e1); }
.tool-use .truncatable.truncated::after { background: linear-gradient(to bottom, transparent, var(--tool-bg)); }
.tool-result .truncatable.truncated::after { background: linear-gradient(to bottom, transparent, var(--tool-result-bg)); }
.expand-btn { display: none; width: 100%; padding: 8px 16px; margin-top: 4px; background: rgba(0,0,0,0.05); border: 1px solid rgba(0,0,0,0.1); border-radius: 6px; cursor: pointer; font-size: 0.85rem; color: var(--text-muted); }
.expand-btn:hover { background: rgba(0,0,0,0.1); }
.truncatable.truncated .expand-btn, .truncatable.expanded .expand-btn { display: block; }
.commit-card { margin: 8px 0; padding: 10px 14px; background: #fff3e0; border-left: 4px solid #ff9800; border-radius: 6px; }
.commit-card a { text-decoration: none; color: #5d4037; display: block; }
.commit-card a:hover { color: #e65100; }
.commit-card-hash { font-family: monospace; color: #e65100; font-weight: 600; margin-right: 8px; }

/* Copy buttons */
.copy-wrapper { position: relative; }
.copy-btn { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; padding: 4px; background: transparent; border: none; border-radius: 4px; cursor: pointer; opacity: 0; transition: opacity 0.15s; z-index: 10; }
.copy-btn::before { content: ''; display: block; width: 16px; height: 16px; background-color: #999; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='14' height='14' x='8' y='8' rx='2' ry='2'/%3E%3Cpath d='M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='14' height='14' x='8' y='8' rx='2' ry='2'/%3E%3Cpath d='M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2'/%3E%3C/svg%3E") center/contain no-repeat; }
.copy-wrapper:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255,255,255,0.1); }
.copy-btn:hover::before { background-color: #fff; }
.copy-btn.copied::before { background-color: #4caf50; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat; }
.file-tool-fullpath { position: relative; display: inline-block; cursor: pointer; }
.file-tool-fullpath:hover { background: rgba(0,0,0,0.05); border-radius: 3px; }
.file-tool-fullpath .copy-btn { top: 50%; transform: translateY(-50%); right: -28px; width: 20px; height: 20px; padding: 2px; }
.file-tool-fullpath .copy-btn::before { width: 14px; height: 14px; background-color: #666; }
.file-tool-fullpath:hover .copy-btn { opacity: 1; }
.file-tool-fullpath .copy-btn:hover::before { background-color: #333; }

/* Status bar */
.status-bar { position: fixed; top: 0; left: 0; right: 0; padding: 8px 16px; background: var(--user-border); color: white; font-size: 0.85rem; display: flex; justify-content: space-between; align-items: center; z-index: 1000; }
.status-bar.disconnected { background: #f44336; }
.status-bar.reconnecting { background: #ff9800; }
.status-indicator { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #4caf50; }
.status-bar.disconnected .status-dot { background: white; }
.status-bar.reconnecting .status-dot { background: white; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.session-title-bar { font-size: 0.85rem; opacity: 0.9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }

/* Hamburger button */
.hamburger-btn { background: none; border: none; color: white; font-size: 1.2rem; cursor: pointer; padding: 4px 8px; margin-right: 8px; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.hamburger-btn:hover { background: rgba(255,255,255,0.2); }

/* Sidebar */
.sidebar { position: fixed; top: 40px; left: 0; bottom: 0; width: var(--sidebar-width); background: var(--card-bg); border-right: 1px solid var(--border-color); z-index: 999; display: flex; flex-direction: column; transform: translateX(0); transition: transform 0.3s ease; overflow: hidden; }
.sidebar.closed { transform: translateX(calc(-1 * var(--sidebar-width))); }
.sidebar-resize-handle { position: absolute; right: 0; top: 0; bottom: 0; width: 4px; cursor: ew-resize; background: transparent; z-index: 10; }
.sidebar-resize-handle:hover, .sidebar-resize-handle.dragging { background: var(--user-border); }
.sidebar-overlay { display: none; position: fixed; inset: 0; top: 40px; background: rgba(0,0,0,0.5); z-index: 998; }

/* Sidebar header */
.sidebar-header { padding: 12px; border-bottom: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.sidebar-search { padding: 8px 12px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 0.85rem; width: 100%; outline: none; background: var(--input-bg); color: var(--text-color); }
.sidebar-search:focus { border-color: var(--user-border); box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1); }
.sidebar-controls { display: flex; align-items: center; justify-content: space-between; }
.auto-switch { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-muted); cursor: pointer; user-select: none; }
.auto-switch input { margin: 0; cursor: pointer; }
.auto-switch:hover { color: var(--text-color); }
.auto-switch.active { color: var(--user-border); }
.sort-select { padding: 4px 6px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--input-bg); color: var(--text-muted); font-size: 0.75rem; cursor: pointer; transition: all 0.15s; outline: none; }
.sort-select:hover { border-color: var(--user-border); color: var(--text-color); }
.sort-select:focus { border-color: var(--user-border); box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1); }
.new-session-btn { padding: 6px 10px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--card-bg); color: var(--text-muted); font-size: 0.9rem; cursor: pointer; transition: all 0.15s; }
.new-session-btn:hover { border-color: var(--user-border); color: var(--user-border); background: rgba(25, 118, 210, 0.05); }

/* Sort row (Group by / Order by dropdowns) */
.sidebar-sort-row { display: flex; gap: 12px; padding-top: 8px; border-top: 1px solid var(--border-color); margin-top: 8px; }
.sort-label { display: flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--text-muted); flex: 1; }
.sort-label span { white-space: nowrap; }
.sort-label .sort-select { flex: 1; min-width: 0; }

/* Project list */
.project-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.project-item { margin-bottom: 0; }
.project-header { display: flex; align-items: center; gap: 6px; padding: 5px 12px; font-weight: 600; font-size: 0.85rem; color: var(--text-color); cursor: pointer; user-select: none; }
.project-header:hover { background: rgba(0,0,0,0.04); }
.project-header .project-icon { font-size: 0.8rem; color: var(--text-muted); transition: transform 0.2s; }
.project-item.collapsed .project-icon { transform: rotate(-90deg); }
.project-item.collapsed .session-list { display: none; }
.project-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-header .unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--user-border); flex-shrink: 0; display: none; }
.project-item.unread > .project-header .unread-dot { display: block; }
.project-item.waiting > .project-header .unread-dot { display: block; background: #f57c00; }
.project-new-btn { opacity: 0; padding: 2px 8px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--card-bg); color: var(--text-muted); font-size: 0.8rem; cursor: pointer; transition: all 0.15s; flex-shrink: 0; }
.project-header:hover .project-new-btn { opacity: 0.7; }
.project-new-btn:hover { opacity: 1 !important; border-color: var(--user-border); color: var(--user-border); background: rgba(25, 118, 210, 0.05); }

/* Session list */
.session-list { padding-left: 16px; }

/* Date sections within projects */
.date-section { margin-bottom: 2px; }
.date-section.empty { display: none; }
.date-section.collapsed .date-session-list { display: none; }
.date-divider { display: flex; align-items: center; padding: 4px 8px 2px 8px; cursor: pointer; user-select: none; }
.date-divider::before { content: '— '; color: var(--user-border); opacity: 0.5; }
.date-label { font-size: 0.7rem; color: var(--user-border); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; opacity: 0.7; white-space: nowrap; }
.date-divider:hover .date-label { opacity: 1; }
.date-section.collapsed .date-divider .date-label::after { content: ' ▸'; font-size: 0.65rem; }
.date-session-list { }

.session-item { display: flex; align-items: center; padding: 4px 12px; font-size: 0.85rem; color: var(--text-muted); cursor: pointer; border-left: 3px solid transparent; transition: all 0.15s; }
.session-item:hover { background: rgba(0,0,0,0.04); color: var(--text-color); }
.session-item.active { background: rgba(25, 118, 210, 0.12); color: var(--user-border); border-left: 4px solid var(--user-border); border-right: 4px solid var(--user-border); font-weight: 500; box-shadow: 0 2px 8px rgba(25, 118, 210, 0.15), inset 4px 0 8px -4px rgba(25, 118, 210, 0.3), inset -4px 0 8px -4px rgba(25, 118, 210, 0.3); margin-left: 2px; margin-right: 2px; border-radius: 4px; }
.session-item.pending { font-style: italic; opacity: 0.7; }
.session-item .session-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--user-border); flex-shrink: 0; margin-right: 6px; display: none; }
.session-item.unread .unread-dot { display: block; }
.session-item.waiting .unread-dot { display: block; background: #f57c00; }
.session-item.running .unread-dot { display: block; width: 10px; height: 10px; background: transparent; border: 1.5px solid #f57c00; border-top-color: transparent; animation: spin 0.8s linear infinite; }
.session-item .close-btn { opacity: 0; padding: 2px 6px; border-radius: 3px; font-size: 0.75rem; margin-left: 4px; }
.session-item:hover .close-btn { opacity: 0.5; }
.session-item .close-btn:hover { opacity: 1; background: rgba(0,0,0,0.1); }

/* Session item in session-mode: block with multiple lines */
.session-item .session-project-row { display: none; }
.session-item .session-branch-row { display: none; }
.session-item .session-project { font-size: 0.75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .session-branch { font-size: 0.7rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .session-meta-time { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.session-item .session-meta-sep { color: var(--text-muted); margin: 0 4px; font-size: 0.7rem; }
.session-item .new-in-folder-btn { display: none; }
.session-item.session-mode { flex-direction: column; align-items: flex-start; padding: 8px 12px 8px 20px; gap: 2px; position: relative; border-radius: 6px; margin: 3px 6px; background: rgba(0,0,0,0.03); }
.session-item.session-mode .session-title { font-weight: 500; width: 100%; }
.session-item.session-mode .session-project-row { display: flex; align-items: center; width: 100%; gap: 4px; }
.session-item.session-mode .session-project { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item.session-mode .session-meta { display: flex; align-items: center; flex-shrink: 0; gap: 6px; }
.session-item.session-mode .session-branch { flex-shrink: 0; }
.session-item.session-mode .new-in-folder-btn { display: none; padding: 0 4px; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); background: transparent; border: 1px solid var(--border-color); border-radius: 3px; cursor: pointer; line-height: 1.1; flex-shrink: 0; }
.session-item.session-mode:hover .new-in-folder-btn { display: inline-flex; }
.session-item.session-mode .new-in-folder-btn:hover { color: var(--user-border); border-color: var(--user-border); background: rgba(25, 118, 210, 0.08); }
.session-item.session-mode .unread-dot { position: absolute; left: 8px; top: 50%; margin-top: -4px; margin-right: 0; }
.session-item.session-mode.running .unread-dot { margin-top: -5px; }
.session-item.session-mode .close-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); margin-left: 0; }
.session-item.session-mode.active { border-left: 4px solid var(--user-border); border-right: 4px solid var(--user-border); border-radius: 6px; margin-left: 4px; margin-right: 4px; }

/* Top-level date sections in session mode */
.project-list.session-mode > .date-section { margin-bottom: 4px; }
.project-list.session-mode > .date-section > .date-divider { padding: 8px 12px 4px 12px; }
.project-list.session-mode > .date-section > .date-divider::before { content: ''; }
.project-list.session-mode > .date-section > .date-divider .date-label { font-size: 0.8rem; font-weight: 600; }
.project-list.session-mode > .date-section > .date-session-list { padding-left: 0; }

/* Archived sessions */
.session-item.archived { opacity: 0.5; }
.session-item.archived:hover { opacity: 0.7; }
.date-section.archived-section > .date-divider .date-label { color: var(--text-muted); }
.date-section.archived-section > .date-divider .date-label::before { content: '📦 '; }

/* Session status colors - based on title suffix (only when enabled) */
.status-colors-enabled .session-item.status-done { background: rgba(76, 175, 80, 0.12); }
.status-colors-enabled .session-item.status-done:hover { background: rgba(76, 175, 80, 0.20); }
.status-colors-enabled .session-item.status-waiting { background: rgba(255, 193, 7, 0.15); }
.status-colors-enabled .session-item.status-waiting:hover { background: rgba(255, 193, 7, 0.25); }
.status-colors-enabled .session-item.status-in-progress { background: rgba(33, 150, 243, 0.12); }
.status-colors-enabled .session-item.status-in-progress:hover { background: rgba(33, 150, 243, 0.20); }

/* Session tooltip */
.session-tooltip { position: fixed; background: var(--code-bg); color: #fff; padding: 10px 14px; border-radius: 6px; font-size: 0.8rem; max-width: 350px; z-index: 1100; box-shadow: 0 4px 12px rgba(0,0,0,0.3); pointer-events: none; }
.session-tooltip .tooltip-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,0.15); }
.session-tooltip .tooltip-label { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; margin-bottom: 2px; }
.session-tooltip .tooltip-value { margin-bottom: 8px; word-wrap: break-word; }
.session-tooltip .tooltip-value:last-child { margin-bottom: 0; }
.session-tooltip .tooltip-message { max-height: 150px; overflow-y: auto; white-space: pre-wrap; }
.session-tooltip .tooltip-summary { max-height: 200px; overflow-y: auto; white-space: pre-wrap; font-style: italic; color: var(--text-secondary, #ccc); }
.session-tooltip .tooltip-usage { display: flex; flex-wrap: wrap; gap: 8px; font-family: monospace; font-size: 0.75rem; }
.session-tooltip .usage-item { background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 3px; white-space: nowrap; }
.session-tooltip .tooltip-cost { font-family: monospace; font-size: 0.9rem; color: #4caf50; font-weight: 600; }

/* Message tooltip for token usage */
.message-tooltip { position: fixed; background: var(--code-bg); color: #fff; padding: 8px 12px; border-radius: 6px; font-size: 0.75rem; z-index: 1100; box-shadow: 0 4px 12px rgba(0,0,0,0.3); pointer-events: none; display: none; font-family: monospace; }
.message-tooltip .usage-row { display: flex; gap: 12px; }
.message-tooltip .model-row { margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,0.15); }
.message-tooltip .usage-item { white-space: nowrap; }
.message-tooltip .usage-label { color: var(--text-muted); margin-right: 4px; }
.message.assistant .message-header { cursor: help; }

/* Session header */
.session-header { position: sticky; top: 0; background: var(--bg-color); padding: 8px 16px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; z-index: 10; margin: -16px -16px 16px -16px; }
.session-title-display { font-weight: 600; font-size: 0.9rem; color: var(--text-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* Floating controls (scroll buttons + auto-scroll) */
.floating-controls { position: fixed; bottom: 100px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 999; }
.scroll-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-muted); font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,0.1); transition: all 0.15s; opacity: 0.7; }
.scroll-btn:hover { opacity: 1; border-color: var(--user-border); color: var(--user-border); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.scroll-btn-end { opacity: 0.5; }
.scroll-btn-end:hover { opacity: 0.9; }
.scroll-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.scroll-btn:disabled:hover { border-color: var(--border-color); color: var(--text-muted); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.auto-scroll-float { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 18px; font-size: 0.75rem; color: var(--text-muted); cursor: pointer; user-select: none; box-shadow: 0 2px 8px rgba(0,0,0,0.1); opacity: 0.85; transition: all 0.15s; }
.auto-scroll-float:hover { opacity: 1; }
.auto-scroll-float input { margin: 0; cursor: pointer; }
.auto-scroll-float.active { border-color: var(--user-border); color: var(--user-border); }

/* Session containers */
.session-container { display: none; }
.session-container.active { display: block; }

/* Lazy loading states */
.session-container.loading { position: relative; min-height: 200px; }
.session-container.loading::after { content: ''; position: absolute; top: 50%; left: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border: 3px solid var(--border-color); border-top-color: var(--user-border); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.load-error { padding: 20px; text-align: center; color: var(--text-muted); }
.load-error button { padding: 8px 16px; background: var(--user-border); color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }
.load-error button:hover { opacity: 0.9; }

/* Layout adjustments for sidebar */
body { padding-top: 56px; padding-bottom: 100px; }
.main-content { margin-left: var(--sidebar-width); transition: margin-left 0.3s ease; }
.main-content.sidebar-closed { margin-left: 0; }

/* Input bar for sending messages */
.input-bar { position: fixed; bottom: 0; left: var(--sidebar-width); right: 0; padding: 12px 16px; background: var(--card-bg); border-top: 1px solid var(--border-color); display: flex; gap: 12px; align-items: flex-start; z-index: 1000; transition: left 0.3s ease; }
.input-bar.sidebar-closed { left: 0; }
.input-bar.hidden { display: none; }
.input-bar-left { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.input-textarea { width: 100%; min-height: 40px; max-height: 120px; padding: 10px 14px; border: 1px solid var(--border-color); border-radius: 8px; font-family: inherit; font-size: 0.9rem; resize: none; outline: none; line-height: 1.4; background: var(--input-bg); color: var(--text-color); }
.input-textarea:focus { border-color: var(--user-border); box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1); }
.input-textarea::placeholder { color: var(--text-muted); }
.input-textarea.drop-target { border-color: var(--user-border); background: rgba(25, 118, 210, 0.08); box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2); }
[data-theme="dark"] .input-textarea.drop-target { background: rgba(66, 165, 245, 0.12); }
.input-meta-row { display: flex; align-items: center; gap: 10px; min-height: 20px; flex-wrap: wrap; }
.input-status { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; min-height: 20px; }
.input-status.running { color: #f57c00; }
.input-status .spinner { width: 14px; height: 14px; border: 2px solid #f57c00; border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
.context-indicator { display: flex; align-items: center; gap: 8px; min-height: 18px; font-size: 0.78rem; color: var(--text-muted); flex-wrap: wrap; }
.context-indicator-group { display: inline-flex; align-items: baseline; gap: 6px; }
.context-indicator-label { text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.68rem; color: var(--text-muted); }
.context-indicator-value { font-weight: 700; color: var(--text-color); }
.context-indicator-detail { font-variant-numeric: tabular-nums; }
.context-indicator-sep { color: var(--text-muted); opacity: 0.6; }
@keyframes spin { to { transform: rotate(360deg); } }
.send-btn, .interrupt-btn, .fork-btn { padding: 10px 16px; border: none; border-radius: 8px; font-size: 0.9rem; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: background 0.15s; }
.send-btn { background: var(--user-border); color: white; }
.send-btn:hover { background: #1565c0; }
.send-btn:disabled { background: #bdbdbd; cursor: not-allowed; }
.interrupt-btn { background: #f44336; color: white; }
.interrupt-btn:hover { background: #d32f2f; }
.fork-btn { background: #9c27b0; color: white; }
.fork-btn:hover { background: #7b1fa2; }
.fork-btn:disabled { background: #bdbdbd; cursor: not-allowed; }
.fork-btn.hidden { display: none; }
.input-bar-buttons { display: flex; gap: 8px; align-items: flex-end; }

/* Pending session styles */
.pending-session-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; color: var(--text-muted); text-align: center; }
.pending-session-placeholder p { margin: 0; font-size: 1rem; }

/* Placeholder message styles */
.placeholder-message { opacity: 0.7; }
.placeholder-message .message-header time { font-style: italic; }

/* Mobile styles */
@media (max-width: 768px) {
    /* Sidebar floats over content on mobile */
    .sidebar { z-index: 1001; }
    .sidebar-overlay.visible { display: block; }
    .main-content { margin-left: 0 !important; }
    .input-bar { left: 0 !important; }

    /* General mobile adjustments - iOS safe area support */
    html, body { overflow-x: hidden; width: 100%; max-width: 100vw; position: relative; }
    body {
        padding: 8px;
        padding-top: calc(56px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
        padding-left: calc(8px + env(safe-area-inset-left, 0px));
        padding-right: calc(8px + env(safe-area-inset-right, 0px));
    }
    .container { max-width: 100%; width: 100%; padding: 0; overflow-x: hidden; box-sizing: border-box; }
    .message { border-radius: 8px; max-width: 100%; overflow: hidden; scroll-margin-bottom: calc(160px + env(safe-area-inset-bottom, 0px)); }
    .message-content { padding: 12px; overflow-x: hidden; word-break: break-word; overflow-wrap: anywhere; }
    .message-content code { word-break: break-all; }

    /* Pre/code blocks - prevent horizontal overflow */
    pre {
        font-size: 0.75rem;
        padding: 8px;
        max-width: 100%;
        overflow-x: auto;
        box-sizing: border-box;
        -webkit-overflow-scrolling: touch;
        word-break: break-all;
    }
    pre code { word-break: break-all; white-space: pre-wrap; }

    /* Tool elements - constrain width */
    .tool-use, .tool-result, .file-tool { max-width: 100%; overflow: hidden; box-sizing: border-box; }
    .tool-header { flex-wrap: wrap; }
    .file-tool-fullpath { word-break: break-all; }

    /* Input bar - iOS keyboard and touch handling */
    .input-bar {
        padding: 8px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        padding-left: calc(8px + env(safe-area-inset-left, 0px));
        padding-right: calc(8px + env(safe-area-inset-right, 0px));
        flex-direction: column;
        gap: 16px; /* Increased gap for better touch separation */
        width: 100%;
        box-sizing: border-box;
    }
    .input-bar-left { width: 100%; flex: none; }
    .input-textarea {
        touch-action: manipulation;
        font-size: 16px; /* Prevents iOS zoom on focus */
        -webkit-appearance: none;
        border-radius: 8px;
    }
    .input-status { min-height: 0; }
    .input-bar-buttons { width: 100%; flex: none; }
    .input-bar-buttons .send-btn, .input-bar-buttons .interrupt-btn {
        flex: 1;
        justify-content: center;
        min-height: 48px;
        padding: 14px 16px;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        -webkit-user-select: none;
        user-select: none;
        font-size: 16px;
    }
    .send-btn.hidden, .interrupt-btn.hidden { display: none; }
    .fork-btn { display: none !important; }

    .session-header { margin: -8px -8px 8px -8px; padding: 8px 12px; }
    .status-bar {
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
        padding-top: calc(8px + env(safe-area-inset-top, 0px));
        padding-left: calc(16px + env(safe-area-inset-left, 0px));
        padding-right: calc(16px + env(safe-area-inset-right, 0px));
    }
    .floating-controls { bottom: calc(150px + env(safe-area-inset-bottom, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); }
    .scroll-btn { width: 44px; height: 44px; } /* iOS minimum touch target */
    .sidebar-resize-handle, .preview-resize-handle { display: none; }
    .preview-pane { width: 100% !important; left: 0; }
    .preview-pane.open ~ .main-content, .main-content.preview-open { margin-right: 0 !important; }
    .input-bar.preview-open { right: 0 !important; display: none; }
    .floating-controls.preview-open { right: calc(12px + env(safe-area-inset-right, 0px)) !important; }

    /* Hide terminal on mobile - xterm.js doesn't work well with virtual keyboards */
    .terminal-toggle-btn { display: none; }

    /* Sidebar mobile improvements */
    .sidebar {
        padding-top: env(safe-area-inset-top, 0px);
        padding-left: env(safe-area-inset-left, 0px);
    }
}

/* Flash message */
.flash-message { position: fixed; top: 48px; left: 50%; transform: translateX(-50%); padding: 10px 20px; border-radius: 6px; font-size: 0.9rem; font-weight: 500; z-index: 1001; opacity: 0; pointer-events: none; transition: opacity 0.3s ease, top 0.3s ease; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.flash-message.visible { opacity: 1; top: 56px; pointer-events: auto; }
.flash-message.info { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }
.flash-message.success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.flash-message.warning { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.flash-message.error { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }

/* New Session Modal */
.new-session-modal { border: none; border-radius: 12px; padding: 0; box-shadow: 0 8px 32px rgba(0,0,0,0.2); max-width: 480px; width: 90%; background: var(--card-bg); }
.new-session-modal::backdrop { background: rgba(0,0,0,0.5); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
.modal-header h2 { margin: 0; font-size: 1.1rem; font-weight: 600; color: var(--text-color); }
.modal-close-btn { background: none; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer; padding: 0; line-height: 1; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.modal-close-btn:hover { background: rgba(0,0,0,0.05); color: var(--text-color); }
#new-session-form { padding: 20px; }
.modal-field { margin-bottom: 16px; }
.modal-field label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-color); margin-bottom: 6px; }
.modal-input, .modal-select { width: 100%; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 0.9rem; font-family: inherit; background: var(--input-bg); color: var(--text-color); outline: none; box-sizing: border-box; }
.modal-input:focus, .modal-select:focus { border-color: var(--user-border); box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1); }
.modal-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.model-select-wrapper { display: flex; flex-direction: column; gap: 8px; }
.model-search { font-size: 0.85rem; padding: 8px 10px; }
.modal-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-color); }
.modal-btn { padding: 10px 20px; border-radius: 6px; font-size: 0.9rem; font-weight: 500; cursor: pointer; border: none; transition: all 0.15s; }
.modal-btn-cancel { background: #f5f5f5; color: var(--text-muted); }
.modal-btn-cancel:hover { background: #e0e0e0; color: var(--text-color); }
.modal-btn-create { background: var(--user-border); color: white; }
.modal-btn-create:hover { background: #1565c0; }
.modal-btn-create:disabled { background: #bdbdbd; cursor: not-allowed; }

/* Permission Modal */
.permission-modal { border: none; border-radius: 12px; padding: 0; box-shadow: 0 8px 32px rgba(0,0,0,0.2); max-width: 600px; width: 90%; background: var(--card-bg); }
.permission-modal::backdrop { background: rgba(0,0,0,0.5); }
.permission-content { padding: 16px 20px; }
.permission-intro { margin: 0 0 16px 0; color: var(--text-muted); font-size: 0.9rem; }
.denials-list { display: flex; flex-direction: column; gap: 12px; }
.denial-item { background: var(--bg-color); border-radius: 8px; padding: 12px; border: 1px solid var(--border-color); }
.denial-header { display: flex; gap: 8px; margin-bottom: 10px; font-family: var(--font-mono, monospace); font-size: 0.85rem; flex-wrap: wrap; }
.denial-tool { font-weight: 600; color: var(--user-border); }
.denial-operation { color: var(--text-muted); word-break: break-all; }
.denial-options { display: flex; flex-direction: column; gap: 6px; }
.permission-option { display: flex; align-items: flex-start; gap: 8px; padding: 8px; border-radius: 4px; cursor: pointer; transition: background 0.15s; }
.permission-option:hover { background: rgba(0,0,0,0.05); }
.permission-option input[type="radio"] { margin-top: 3px; accent-color: var(--user-border); }
.option-label { flex: 1; font-size: 0.9rem; color: var(--text-color); }
.option-example { font-family: var(--font-mono, monospace); font-size: 0.8rem; color: var(--text-muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-btn-grant { background: #4caf50; color: white; }
.modal-btn-grant:hover { background: #43a047; }
.modal-btn-reject { background: #f5f5f5; color: var(--text-muted); }
.modal-btn-reject:hover { background: #e0e0e0; color: var(--text-color); }
/* Sandbox denial styling */
.sandbox-denial { border-color: #f57c00; background: #fff8e1; }
.sandbox-denial .denial-header { margin-bottom: 8px; }
.sandbox-warning { display: flex; gap: 12px; padding: 8px; background: rgba(255,152,0,0.1); border-radius: 6px; }
.sandbox-warning .warning-icon { font-size: 1.5rem; color: #f57c00; flex-shrink: 0; }
.sandbox-warning .warning-text { flex: 1; }
.sandbox-warning .warning-text strong { color: #e65100; display: block; margin-bottom: 4px; }
.sandbox-warning .warning-text p { margin: 0 0 8px 0; font-size: 0.85rem; color: var(--text-muted); }
.sandbox-warning .warning-text p:last-child { margin-bottom: 0; }
.sandbox-warning .sandbox-hint { font-size: 0.8rem; margin-bottom: 4px; }
.sandbox-warning .sandbox-action { margin-top: 8px; }
.sandbox-warning .sandbox-allow-option { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: rgba(76, 175, 80, 0.1); border: 1px solid #4caf50; border-radius: 6px; cursor: pointer; }
.sandbox-warning .sandbox-allow-option:hover { background: rgba(76, 175, 80, 0.15); }
.sandbox-warning .sandbox-allow-option input[type="checkbox"] { margin: 0; }
.sandbox-warning .sandbox-dir-path { background: rgba(0,0,0,0.1); padding: 2px 8px; border-radius: 4px; font-size: 0.85rem; word-break: break-all; }
.modal-btn-dismiss { background: #6c757d; color: white; }
.modal-btn-dismiss:hover { background: #5a6268; }
[data-theme="dark"] .sandbox-denial { background: #3d2a1a; border-color: #f57c00; }
[data-theme="dark"] .sandbox-warning { background: rgba(255,152,0,0.15); }
[data-theme="dark"] .sandbox-warning .warning-text strong { color: #ffb74d; }
[data-theme="dark"] .sandbox-warning .sandbox-allow-option { background: rgba(76, 175, 80, 0.15); border-color: #66bb6a; }
[data-theme="dark"] .sandbox-warning .sandbox-allow-option:hover { background: rgba(76, 175, 80, 0.25); }
[data-theme="dark"] .sandbox-warning .sandbox-dir-path { background: rgba(255,255,255,0.1); }
[data-theme="dark"] .permission-option:hover { background: rgba(255,255,255,0.05); }
[data-theme="dark"] .modal-btn-reject { background: #2d2d2d; }
[data-theme="dark"] .modal-btn-reject:hover { background: #3d3d3d; }
[data-theme="dark"] .modal-btn-dismiss { background: #4a4a4a; }
[data-theme="dark"] .modal-btn-dismiss:hover { background: #5a5a5a; }

/* Theme toggle button */
.theme-toggle { background: none; border: none; color: white; font-size: 1.3rem; cursor: pointer; padding: 4px 8px; display: flex; align-items: center; justify-content: center; border-radius: 4px; opacity: 0.7; transition: opacity 0.15s; }
.theme-toggle:hover { opacity: 1; background: rgba(255,255,255,0.2); }

/* Dark mode overrides for hardcoded colors */
[data-theme="dark"] .tool-reply .tool-result .truncatable.truncated::after { background: linear-gradient(to bottom, transparent, var(--tool-reply-bg)); }
[data-theme="dark"] .message-header { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .write-tool { background: linear-gradient(135deg, #1a3a5c 0%, #1f2d1f 100%); border-color: #388e3c; }
[data-theme="dark"] .edit-tool { background: linear-gradient(135deg, #3d2a1a 0%, #3d1f2d 100%); border-color: #f57c00; }
[data-theme="dark"] .read-tool { background: linear-gradient(135deg, #1a3a5c 0%, #1f1f3d 100%); border-color: #1976d2; }
[data-theme="dark"] .todo-list { background: linear-gradient(135deg, #1f2d1f 0%, #252d1f 100%); border-color: #4caf50; }
[data-theme="dark"] .edit-old { background: #3d1f2d; }
[data-theme="dark"] .edit-old .edit-label { color: #ef9a9a; background: #5d2a3d; }
[data-theme="dark"] .edit-old .edit-content { color: #ef9a9a; }
[data-theme="dark"] .edit-new { background: #1f2d1f; }
[data-theme="dark"] .edit-new .edit-label { color: #a5d6a7; background: #2d4a2d; }
[data-theme="dark"] .edit-new .edit-content { color: #a5d6a7; }
[data-theme="dark"] .commit-card { background: #2d2a1f; border-color: #f57c00; }
[data-theme="dark"] .commit-card a { color: #bcaaa4; }
[data-theme="dark"] .commit-card a:hover { color: #ffb74d; }
[data-theme="dark"] .modal-btn-cancel { background: #2d2d2d; }
[data-theme="dark"] .modal-btn-cancel:hover { background: #3d3d3d; }
[data-theme="dark"] .project-header:hover { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .session-item:hover { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .session-item.active { background: rgba(25, 118, 210, 0.2); box-shadow: 0 2px 8px rgba(25, 118, 210, 0.25), inset 4px 0 8px -4px rgba(25, 118, 210, 0.4), inset -4px 0 8px -4px rgba(25, 118, 210, 0.4); }
[data-theme="dark"] .session-item.session-mode { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .session-item.session-mode:hover { background: rgba(255,255,255,0.08); }
[data-theme="dark"] .status-colors-enabled .session-item.status-done { background: rgba(76, 175, 80, 0.15); }
[data-theme="dark"] .status-colors-enabled .session-item.status-done:hover { background: rgba(76, 175, 80, 0.25); }
[data-theme="dark"] .status-colors-enabled .session-item.status-waiting { background: rgba(255, 193, 7, 0.18); }
[data-theme="dark"] .status-colors-enabled .session-item.status-waiting:hover { background: rgba(255, 193, 7, 0.28); }
[data-theme="dark"] .status-colors-enabled .session-item.status-in-progress { background: rgba(33, 150, 243, 0.15); }
[data-theme="dark"] .status-colors-enabled .session-item.status-in-progress:hover { background: rgba(33, 150, 243, 0.25); }
[data-theme="dark"] .expand-btn { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .expand-btn:hover { background: rgba(255,255,255,0.1); }
[data-theme="dark"] code { background: rgba(255,255,255,0.08); }
[data-theme="dark"] .file-tool-path { background: rgba(255,255,255,0.08); }
[data-theme="dark"] .session-id-value { background: rgba(255,255,255,0.05); }
[data-theme="dark"] .write-tool .truncatable.truncated::after { background: linear-gradient(to bottom, transparent, #1a3040); }
[data-theme="dark"] .edit-tool .truncatable.truncated::after { background: linear-gradient(to bottom, transparent, #3d2520); }
[data-theme="dark"] .flash-message.info { background: #1a3a5c; color: #90caf9; border-color: #1976d2; }
[data-theme="dark"] .flash-message.success { background: #1f2d1f; color: #a5d6a7; border-color: #388e3c; }
[data-theme="dark"] .flash-message.warning { background: #3d2a1a; color: #ffcc80; border-color: #f57c00; }
[data-theme="dark"] .flash-message.error { background: #3d1f1f; color: #ef9a9a; border-color: #d32f2f; }

/* Preview Pane */
:root { --preview-pane-width: 700px; } /* Widened for split view */
.preview-pane { position: fixed; top: 40px; right: 0; bottom: 0; width: var(--preview-pane-width); background: var(--card-bg); border-left: 1px solid var(--border-color); z-index: 999; display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.3s ease; }
.preview-pane.open { transform: translateX(0); }

/* Split View Container */
.preview-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* File view row: tree sidebar + file preview (horizontal layout) */
.file-view-row {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Tree Header (New) */
.file-tree-header {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.02);
    height: 41px; /* Match preview header exactly */
    justify-content: space-between;
}

.tree-header-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-color);
}

/* Custom Hamburger Icon */
.hamburger-icon {
    display: block;
    width: 16px;
    height: 12px;
    position: relative;
    background: transparent;
}

.hamburger-icon::before,
.hamburger-icon::after,
.hamburger-icon span {
    content: '';
    display: block;
    position: absolute;
    width: 100%;
    height: 2px;
    background-color: var(--text-muted);
    border-radius: 1px;
    transition: background-color 0.15s;
}

.hamburger-icon::before { top: 0; }
.hamburger-icon span { top: 5px; }
.hamburger-icon::after { bottom: 0; }

button:hover .hamburger-icon::before,
button:hover .hamburger-icon::after,
button:hover .hamburger-icon span {
    background-color: var(--text-color);
}

/* Stylized Folder Icon (outline style) */
.folder-icon {
    width: 16px;
    height: 12px;
    position: relative;
    border: 1.5px solid currentColor;
    border-radius: 0 2px 2px 2px;
    background: transparent;
    transition: opacity 0.15s;
}

.folder-icon::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -1.5px;
    width: 7px;
    height: 5px;
    border: 1.5px solid currentColor;
    border-bottom: none;
    border-radius: 2px 2px 0 0;
    transition: opacity 0.15s;
}

/* Updated Toggle Button Styles */
.tree-toggle-btn, .tree-expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px; /* Larger hit area */
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
}

.tree-toggle-btn:hover, .tree-expand-btn:hover {
    background: rgba(0,0,0,0.05);
}

/* Dark mode adjustment for hover */
[data-theme="dark"] .tree-toggle-btn:hover, 
[data-theme="dark"] .tree-expand-btn:hover {
    background: rgba(255,255,255,0.05);
}

/* Button to expand tree (in preview header) */
.tree-expand-btn {
    display: none; /* Hidden by default */
    margin-right: 8px;
}

/* When sidebar is collapsed, show the expand button in preview header */
.preview-pane.tree-collapsed .tree-expand-btn {
    display: flex;
}

/* Hide tree sidebar when parent has tree-collapsed class */
.preview-pane.tree-collapsed .file-tree-sidebar {
    display: none;
}

/* Current Path Header in Tree (Adjusted) */
.tree-current-path {
    padding: 8px 12px;
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
    word-break: break-all;
    background: rgba(0,0,0,0.02);
}


.file-tree-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
}

/* File Content Area */
.preview-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    background: var(--card-bg);
}

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

/* Adjust header to span full width or just main area? 
   Let's keep one header for the whole pane for simplicity, 
   or maybe move title to main area.
   Let's try a unified header for now.
*/

.main-content.preview-open { margin-right: var(--preview-pane-width); transition: margin-right 0.3s ease; }
.input-bar.preview-open { right: var(--preview-pane-width); transition: right 0.3s ease; }
.floating-controls.preview-open { right: calc(var(--preview-pane-width) + 20px); transition: right 0.3s ease; }
.preview-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border-color); background: rgba(0,0,0,0.02); flex-shrink: 0; }
.preview-title { flex: 1; overflow: hidden; min-width: 0; }
.preview-filename { font-weight: 600; font-size: 0.95rem; color: var(--text-color); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-path { font-size: 0.75rem; color: var(--text-muted); font-family: monospace; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.preview-view-toggle, .preview-follow-toggle { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--card-bg); cursor: pointer; font-size: 0.8rem; color: var(--text-muted); user-select: none; }
.preview-view-toggle:hover, .preview-follow-toggle:hover { border-color: var(--user-border); color: var(--user-border); }
.preview-view-toggle input[type="checkbox"], .preview-follow-toggle input[type="checkbox"] { width: 14px; height: 14px; margin: 0; cursor: pointer; accent-color: var(--user-border); }
.preview-view-toggle .toggle-label { font-size: 0.8rem; }
.preview-copy-btn { padding: 6px 12px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--card-bg); color: var(--text-muted); font-size: 0.8rem; cursor: pointer; }
.preview-copy-btn:hover { border-color: var(--user-border); color: var(--user-border); }
.preview-close-btn { width: 28px; height: 28px; border: none; background: transparent; color: var(--text-muted); font-size: 1.4rem; cursor: pointer; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.preview-close-btn:hover { background: rgba(0,0,0,0.05); color: var(--text-color); }
.preview-content { flex: 1; overflow: auto; padding: 0; }
.preview-content pre { margin: 0; padding: 16px; border-radius: 0; font-size: 0.85rem; line-height: 1.6; }
.preview-content pre code { display: block; background: none; padding: 0; }
.preview-status { padding: 8px 16px; font-size: 0.8rem; border-top: 1px solid var(--border-color); display: none; }
.preview-status.visible { display: block; }
.preview-status.error { background: var(--tool-error-bg); color: #c62828; }
.preview-status.warning { background: #fff3e0; color: #e65100; }
.preview-status.loading { background: #e3f2fd; color: var(--user-border); }
.preview-resize-handle { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; cursor: ew-resize; background: transparent; }
.preview-resize-handle:hover, .preview-resize-handle.dragging { background: var(--user-border); }

/* Dark mode overrides for preview pane */
[data-theme="dark"] .preview-header { background: rgba(255,255,255,0.02); }
[data-theme="dark"] .preview-close-btn:hover { background: rgba(255,255,255,0.05); }
[data-theme="dark"] .preview-status.error { background: #3d1f1f; color: #ef9a9a; }
[data-theme="dark"] .preview-status.warning { background: #3d2a1a; color: #ffcc80; }
[data-theme="dark"] .preview-status.loading { background: #1a3a5c; color: #90caf9; }

/* Markdown preview styles */
.markdown-preview { padding: 20px 24px; color: var(--text-color); line-height: 1.7; }
.markdown-preview h1 { font-size: 1.75rem; margin: 0 0 16px 0; padding-bottom: 8px; border-bottom: 2px solid var(--border-color); }
.markdown-preview h2 { font-size: 1.4rem; margin: 24px 0 12px 0; padding-bottom: 6px; border-bottom: 1px solid var(--border-color); }
.markdown-preview h3 { font-size: 1.15rem; margin: 20px 0 10px 0; }
.markdown-preview h4, .markdown-preview h5, .markdown-preview h6 { font-size: 1rem; margin: 16px 0 8px 0; }
.markdown-preview p { margin: 0 0 14px 0; }
.markdown-preview ul, .markdown-preview ol { margin: 0 0 14px 0; padding-left: 24px; }
.markdown-preview li { margin-bottom: 6px; }
.markdown-preview blockquote { margin: 14px 0; padding: 12px 16px; border-left: 4px solid var(--user-border); background: rgba(25, 118, 210, 0.05); border-radius: 0 6px 6px 0; }
.markdown-preview blockquote p:last-child { margin-bottom: 0; }
.markdown-preview a { color: var(--user-border); text-decoration: none; }
.markdown-preview a:hover { text-decoration: underline; }
.markdown-preview hr { border: none; border-top: 1px solid var(--border-color); margin: 24px 0; }

/* Markdown tables - attractive styling */
.markdown-preview table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.9rem; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.markdown-preview thead { background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%); }
.markdown-preview th { padding: 12px 16px; text-align: left; font-weight: 600; color: var(--text-color); border-bottom: 2px solid var(--border-color); }
.markdown-preview td { padding: 10px 16px; border-bottom: 1px solid var(--border-color); }
.markdown-preview tbody tr:last-child td { border-bottom: none; }
.markdown-preview tbody tr:hover { background: rgba(25, 118, 210, 0.04); }
.markdown-preview tbody tr:nth-child(even) { 
    background: rgba(0,0,0,0.05); /* Slightly darker than header */
}

/* Tree Resize Handle */
.tree-resize-handle {
    width: 4px;
    background: transparent;
    cursor: ew-resize;
    flex-shrink: 0;
    transition: background 0.2s ease;
    z-index: 10;
}
.tree-resize-handle:hover,
.tree-resize-handle.dragging {
    background: var(--user-border);
}
.preview-pane.tree-collapsed .tree-resize-handle {
    display: none;
}

.markdown-preview tbody tr:nth-child(even):hover { background: rgba(25, 118, 210, 0.06); }

/* Markdown code blocks */
.markdown-preview pre { margin: 14px 0; border-radius: 8px; }
.markdown-preview code { font-size: 0.85em; }

/* Dark mode markdown */
[data-theme="dark"] .markdown-preview blockquote { background: rgba(66, 165, 245, 0.1); border-left-color: var(--user-border); }
[data-theme="dark"] .markdown-preview thead { background: linear-gradient(135deg, #2a2a2a 0%, #333 100%); }
[data-theme="dark"] .markdown-preview tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
[data-theme="dark"] .markdown-preview tbody tr:hover { background: rgba(66, 165, 245, 0.08); }
[data-theme="dark"] .markdown-preview tbody tr:nth-child(even):hover { background: rgba(66, 165, 245, 0.1); }

/* Image preview */
.image-preview {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    min-height: 100%;
}
.image-preview img {
    max-width: 100%;
    max-height: calc(100vh - 200px);
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
[data-theme="dark"] .image-preview img {
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Audio preview */
.audio-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    min-height: 200px;
    gap: 16px;
}
.audio-preview .audio-filename {
    font-size: 14px;
    color: var(--text-secondary);
    word-break: break-all;
    text-align: center;
    max-width: 100%;
}
.audio-preview audio {
    width: 100%;
    max-width: 500px;
    border-radius: 8px;
}
[data-theme="dark"] .audio-preview audio {
    /* Dark mode audio player styling where supported */
    filter: invert(1) hue-rotate(180deg);
}

/* URL/HTML preview iframes */
.url-preview-iframe,
.html-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}
.preview-content:has(.url-preview-iframe),
.preview-content:has(.html-preview-iframe) {
    padding: 0;
    overflow: hidden;
}
[data-theme="dark"] .url-preview-iframe,
[data-theme="dark"] .html-preview-iframe {
    /* Note: Cannot invert iframe content, but container has white bg for readability */
}

/* VibeDeck command blocks */
.vibedeck-command-wrapper {
    position: relative;
    display: block;
}
.vibedeck-command-wrapper pre {
    margin: 0;
}
.vibedeck-execute-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--accent-color, #007bff);
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    opacity: 0.9;
    transition: opacity 0.2s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 1;
}
.vibedeck-execute-btn:hover {
    opacity: 1;
    transform: scale(1.15);
}
.vibedeck-execute-btn:active {
    transform: scale(0.95);
}

/* Tree Node Styles */
.tree-root {
    margin: 0;
    padding: 0;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.tree-item {
    list-style: none;
}
.tree-summary {
    cursor: pointer;
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-color);
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tree-summary:hover {
    background: rgba(0,0,0,0.04);
}
.tree-summary.selected {
    background: rgba(25, 118, 210, 0.1);
    color: var(--user-border);
}
.tree-icon {
    width: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9em;
}
.tree-children {
    padding-left: 14px; /* Indentation */
    margin: 0;
    list-style: none;
    border-left: 1px solid rgba(0,0,0,0.05);
    margin-left: 10px;
}
details > summary {
    list-style: none;
}
details > summary::-webkit-details-marker {
    display: none;
}

/* Icons using simple unicode/emoji for now, or could use SVG */
.tree-icon-folder::before {
    content: "📁";
    opacity: 0.5; /* Gray-ish by opacity */
    filter: grayscale(100%); /* Make it gray */
}
details[open] > summary .tree-icon-folder::before {
    content: "📂";
    opacity: 0.7;
    filter: grayscale(100%);
}
.tree-icon-file::before {
    content: "📄";
    opacity: 0.7;
}

/* Context menu for file tree */
.tree-context-menu {
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 4px 0;
    min-width: 160px;
    z-index: 2000;
}

.context-menu-item {
    display: block;
    width: 100%;
    padding: 8px 14px;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-color);
    cursor: pointer;
    transition: background 0.1s;
}

.context-menu-item:hover {
    background: rgba(25, 118, 210, 0.1);
    color: var(--user-border);
}

[data-theme="dark"] .tree-context-menu {
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

[data-theme="dark"] .context-menu-item:hover {
    background: rgba(66, 165, 245, 0.15);
}

.context-menu-divider {
    margin: 4px 8px;
    border: none;
    border-top: 1px solid var(--border-color);
}

.context-menu-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 4px 14px 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.context-menu-item.selected {
    background: rgba(25, 118, 210, 0.15);
}

.context-menu-item.selected::before {
    content: '✓ ';
}

[data-theme="dark"] .context-menu-item.selected {
    background: rgba(66, 165, 245, 0.2);
}

/* Status-specific colors for selected menu items */
.context-menu-item.selected.status-done {
    background: rgba(76, 175, 80, 0.20);
}
.context-menu-item.selected.status-waiting {
    background: rgba(255, 193, 7, 0.25);
}
.context-menu-item.selected.status-in-progress {
    background: rgba(33, 150, 243, 0.20);
}

[data-theme="dark"] .context-menu-item.selected.status-done {
    background: rgba(76, 175, 80, 0.25);
}
[data-theme="dark"] .context-menu-item.selected.status-waiting {
    background: rgba(255, 193, 7, 0.28);
}
[data-theme="dark"] .context-menu-item.selected.status-in-progress {
    background: rgba(33, 150, 243, 0.25);
}

.context-menu-item-danger {
    color: #d32f2f;
}

.context-menu-item-danger:hover {
    background: rgba(211, 47, 47, 0.1);
    color: #d32f2f;
}

[data-theme="dark"] .context-menu-item-danger {
    color: #ef5350;
}

[data-theme="dark"] .context-menu-item-danger:hover {
    background: rgba(239, 83, 80, 0.15);
    color: #ef5350;
}

/* File tree drag-over state for upload */
.file-tree-content.drag-over {
    background: rgba(25, 118, 210, 0.1);
    border: 2px dashed var(--user-border);
    border-radius: 8px;
}

[data-theme="dark"] .file-tree-content.drag-over {
    background: rgba(66, 165, 245, 0.15);
}

/* Git changes footer in file tree */
.git-changes-footer {
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
    background: rgba(0,0,0,0.02);
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.git-changes-btn {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: border-color 0.15s, background 0.15s;
}

.git-changes-btn:hover {
    border-color: var(--user-border);
    background: rgba(25, 118, 210, 0.05);
}

.git-icon {
    color: #f57c00;
    font-size: 0.9rem;
}

/* Branch icon uses a different color */
.git-changes-branch .git-icon {
    color: #7b1fa2;
}

.git-count {
    margin-left: auto;
    background: rgba(25, 118, 210, 0.1);
    color: var(--user-border);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

[data-theme="dark"] .git-changes-footer {
    background: rgba(255,255,255,0.02);
}

[data-theme="dark"] .git-changes-btn:hover {
    background: rgba(66, 165, 245, 0.1);
}

[data-theme="dark"] .git-count {
    background: rgba(66, 165, 245, 0.2);
}

/* Draggable file items */
.tree-summary[draggable="true"] {
    cursor: grab;
}

.tree-summary[draggable="true"]:active {
    cursor: grabbing;
}

/* Back Button in Preview Header */
.preview-back-btn {
    padding: 4px 8px;
    margin-right: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.9rem;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
}
.preview-back-btn:hover {
    background: rgba(0,0,0,0.05);
}

/* Dark mode adjustments */
[data-theme="dark"] .tree-summary:hover {
    background: rgba(255,255,255,0.04);
}
[data-theme="dark"] .tree-summary.selected {
    background: rgba(25, 118, 210, 0.2);
}
[data-theme="dark"] .tree-children {
    border-left-color: rgba(255,255,255,0.05);
}

/* Right Sidebar Toggle */
.right-sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    margin-left: auto;
    color: rgba(255,255,255,0.7);
    transition: opacity 0.15s;
}
.right-sidebar-toggle .folder-icon::before {
    background: var(--header-bg, #2196f3);
}
.right-sidebar-toggle:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}
.right-sidebar-toggle.active {
    color: white;
}

/* Tree Sidebar in Preview Pane */
.file-tree-sidebar {
    width: 250px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: rgba(0,0,0,0.02);
    flex-shrink: 0;
    transition: width 0.2s ease, opacity 0.2s ease;
    overflow: hidden;
    position: relative;
}

.file-tree-sidebar.collapsed {
    width: 0;
    opacity: 0;
    border-right: none;
}

/* Toggle Tree Button (inside preview pane) */
.toggle-tree-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
}
.toggle-tree-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-color);
}
.toggle-tree-btn .icon-open { display: none; }
.toggle-tree-btn.collapsed .icon-open { display: block; }
.toggle-tree-btn.collapsed .icon-close { display: none; }

/* View Switcher in Preview Header */
.view-switcher {
    display: flex;
    background: rgba(0,0,0,0.05);
    border-radius: 6px;
    padding: 2px;
    margin-right: 8px;
}
.switcher-btn {
    border: none;
    background: transparent;
    padding: 4px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-muted);
}
.switcher-btn.active {
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    font-weight: 500;
}
[data-theme="dark"] .view-switcher {
    background: rgba(255,255,255,0.05);
}
[data-theme="dark"] .switcher-btn.active {
    background: #333;
}

/* Hide tools mode - hides tool calls, tool results, and tool reply messages */
body.hide-tools .tool-use,
body.hide-tools .tool-result,
body.hide-tools .file-tool,
body.hide-tools .todo-list,
body.hide-tools .message.tool-reply {
    display: none !important;
}

/* Hide assistant messages that only contain tool elements (no visible text) */
body.hide-tools .message.assistant:not(:has(.assistant-text)):not(:has(.thinking)) {
    display: none !important;
}

/* ==================== Diff View Styles ==================== */

/* Diff header in sidebar */
.diff-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: linear-gradient(135deg, #fff3e0 0%, #fce4ec 100%);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}
[data-theme="dark"] .diff-header {
    background: linear-gradient(135deg, #3d2a1a 0%, #3d1f2d 100%);
}
.diff-header-label {
    font-weight: 600;
    color: #e65100;
}
[data-theme="dark"] .diff-header-label {
    color: #ffb74d;
}
.diff-header-branch {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(0,0,0,0.08);
    padding: 2px 8px;
    border-radius: 4px;
}
.diff-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    padding: 0 4px;
    line-height: 1;
    border-radius: 4px;
}
.diff-close-btn:hover {
    background: rgba(0,0,0,0.1);
    color: var(--text-color);
}

/* Diff file list */
.diff-file-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.diff-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
    font-size: 0.85rem;
}
.diff-file-item:hover {
    background: rgba(0,0,0,0.05);
}
.diff-file-item.selected {
    background: rgba(25, 118, 210, 0.1);
    border-left: 3px solid var(--user-border);
    padding-left: 9px;
}
[data-theme="dark"] .diff-file-item:hover {
    background: rgba(255,255,255,0.05);
}
[data-theme="dark"] .diff-file-item.selected {
    background: rgba(66, 165, 245, 0.15);
}

/* File status indicator */
.diff-file-status {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    border-radius: 3px;
    flex-shrink: 0;
}
.diff-status-staged {
    background: #c8e6c9;
    color: #2e7d32;
}
.diff-status-modified {
    background: #fff9c4;
    color: #f57f17;
}
.diff-status-untracked {
    background: #bbdefb;
    color: #1565c0;
}
.diff-status-committed {
    background: #e1bee7;
    color: #7b1fa2;
}
[data-theme="dark"] .diff-status-staged {
    background: #1b5e20;
    color: #a5d6a7;
}
[data-theme="dark"] .diff-status-modified {
    background: #4a4000;
    color: #fff59d;
}
[data-theme="dark"] .diff-status-untracked {
    background: #0d47a1;
    color: #90caf9;
}
[data-theme="dark"] .diff-status-committed {
    background: #4a148c;
    color: #ce93d8;
}

/* File name */
.diff-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: monospace;
}

/* File stats (+/- numbers) */
.diff-file-stats {
    display: flex;
    gap: 6px;
    font-family: monospace;
    font-size: 0.75rem;
    flex-shrink: 0;
}
.diff-additions {
    color: #2e7d32;
    font-weight: 600;
}
.diff-deletions {
    color: #c62828;
    font-weight: 600;
}
[data-theme="dark"] .diff-additions {
    color: #81c784;
}
[data-theme="dark"] .diff-deletions {
    color: #ef9a9a;
}

/* Diff content in preview pane */
.diff-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.diff-status-bar {
    padding: 8px 16px;
    background: rgba(0,0,0,0.03);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}
.diff-status-label {
    text-transform: capitalize;
    color: var(--text-muted);
}
.diff-content {
    flex: 1;
    overflow: auto;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Diff hunk */
.diff-hunk {
    margin-bottom: 16px;
}
.diff-hunk-header {
    background: rgba(0,0,0,0.08);
    color: var(--text-muted);
    padding: 4px 16px;
    font-size: 0.8rem;
    position: sticky;
    top: 0;
    z-index: 1;
}
[data-theme="dark"] .diff-hunk-header {
    background: rgba(255,255,255,0.08);
}
.diff-hunk-content {
    padding: 0;
}

/* Diff lines */
.diff-line {
    display: flex;
    min-height: 22px;
}
.diff-line-prefix {
    width: 24px;
    flex-shrink: 0;
    text-align: center;
    user-select: none;
    color: var(--text-muted);
}
.diff-line-content {
    flex: 1;
    padding: 0 12px 0 0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Line types */
.diff-line-add {
    background: #e8f5e9;
}
.diff-line-add .diff-line-prefix {
    background: #c8e6c9;
    color: #2e7d32;
}
.diff-line-add .diff-line-content {
    color: #1b5e20;
}
.diff-line-del {
    background: #ffebee;
}
.diff-line-del .diff-line-prefix {
    background: #ffcdd2;
    color: #c62828;
}
.diff-line-del .diff-line-content {
    color: #b71c1c;
}
.diff-line-ctx {
    background: transparent;
}
[data-theme="dark"] .diff-line-add {
    background: rgba(46, 125, 50, 0.2);
}
[data-theme="dark"] .diff-line-add .diff-line-prefix {
    background: rgba(46, 125, 50, 0.4);
    color: #a5d6a7;
}
[data-theme="dark"] .diff-line-add .diff-line-content {
    color: #a5d6a7;
}
[data-theme="dark"] .diff-line-del {
    background: rgba(198, 40, 40, 0.2);
}
[data-theme="dark"] .diff-line-del .diff-line-prefix {
    background: rgba(198, 40, 40, 0.4);
    color: #ef9a9a;
}
[data-theme="dark"] .diff-line-del .diff-line-content {
    color: #ef9a9a;
}

/* Section separator */
.diff-separator {
    padding: 8px 16px;
    background: linear-gradient(135deg, #fff3e0 0%, #fce4ec 100%);
    color: #e65100;
    font-weight: 600;
    margin: 16px 0;
    border-radius: 4px;
}
[data-theme="dark"] .diff-separator {
    background: linear-gradient(135deg, #3d2a1a 0%, #3d1f2d 100%);
    color: #ffb74d;
}

/* Empty state */
.diff-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    font-style: italic;
}

.diff-no-git-info {
    padding: 12px 16px;
    color: var(--text-muted);
    font-size: 0.85em;
    line-height: 1.4;
}

/* Diff context menu */
.diff-context-menu {
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 150px;
    padding: 4px 0;
}
.diff-context-menu .context-menu-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-color);
}
.diff-context-menu .context-menu-item:hover {
    background: rgba(0,0,0,0.05);
}
[data-theme="dark"] .diff-context-menu .context-menu-item:hover {
    background: rgba(255,255,255,0.08);
}

/* Make edit tools look clickable for diff view */
.edit-tool {
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.15s;
}
.edit-tool:hover {
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}
.edit-tool:active {
    transform: scale(0.995);
}

/* ===== Floating Artifacts Panel ===== */

.artifacts-float {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 100;
    background: var(--bg-color, #fff);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    min-width: 220px;
    max-width: 650px;
    transition: box-shadow 0.2s;
}
.artifacts-float:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
[data-theme="dark"] .artifacts-float {
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
[data-theme="dark"] .artifacts-float:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* Adjust position when preview pane is open */
.preview-open ~ .artifacts-float,
.artifacts-float.preview-open {
    right: calc(var(--preview-pane-width, 700px) + 20px);
}

.artifacts-float .artifacts-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
    border-radius: 8px;
}
.artifacts-float.expanded .artifacts-header {
    border-bottom: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
}

.artifacts-float .artifacts-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.artifacts-float .artifacts-badge {
    background: #2196f3;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}
.artifacts-float .artifacts-badge:empty {
    display: none;
}

.artifacts-float .artifacts-expand-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px;
    margin-left: auto;
    transition: transform 0.2s;
}
.artifacts-float.expanded .artifacts-expand-btn {
    transform: rotate(180deg);
}

.artifacts-float .artifacts-body {
    display: none;
    width: 350px;
    height: 600px;
    overflow-y: auto;
    resize: both;
    min-width: 200px;
    min-height: 100px;
    max-height: 80vh;
}
.artifacts-float.expanded .artifacts-body {
    display: block;
}

.artifacts-float .artifacts-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
}

.artifacts-float .artifacts-empty {
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 12px;
    text-align: center;
}

/* Artifact tags - colored boxes */
.artifact-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: filter 0.1s, transform 0.1s;
}
.artifact-tag:hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
}
.artifact-tag:active {
    transform: translateY(0);
}

.artifact-tag .tag-type {
    font-weight: 600;
    opacity: 0.8;
    white-space: nowrap;
}

.artifact-tag .tag-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.artifact-tag .tag-timestamp {
    font-size: 0.65rem;
    opacity: 0.6;
    white-space: nowrap;
    margin-left: auto;
}

/* Type-specific colors */
.artifact-tag.type-file {
    background: #e3f2fd;
    color: #1565c0;
}
[data-theme="dark"] .artifact-tag.type-file {
    background: #1e3a5f;
    color: #90caf9;
}

.artifact-tag.type-diff {
    background: #fff3e0;
    color: #e65100;
}
[data-theme="dark"] .artifact-tag.type-diff {
    background: #4a2c00;
    color: #ffb74d;
}

.artifact-tag.type-url {
    background: #e8f5e9;
    color: #2e7d32;
}
[data-theme="dark"] .artifact-tag.type-url {
    background: #1b3d1f;
    color: #81c784;
}

.artifact-tag.type-gui {
    background: #f3e5f5;
    color: #7b1fa2;
}
[data-theme="dark"] .artifact-tag.type-gui {
    background: #3d1f47;
    color: #ce93d8;
}

/* Artifact scroll highlight effect */
.message.artifact-highlight {
    animation: artifact-highlight-pulse 1.5s ease-out;
}
@keyframes artifact-highlight-pulse {
    0% { background-color: rgba(33, 150, 243, 0.3); }
    100% { background-color: transparent; }
}
[data-theme="dark"] .message.artifact-highlight {
    animation: artifact-highlight-pulse-dark 1.5s ease-out;
}
@keyframes artifact-highlight-pulse-dark {
    0% { background-color: rgba(33, 150, 243, 0.2); }
    100% { background-color: transparent; }
}

/* ==========================================================================
   Terminal Panel
   ========================================================================== */

/* Terminal toggle button (in status bar, matches folder toggle) */
.terminal-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: rgba(255,255,255,0.7);
    transition: opacity 0.15s;
}
.terminal-toggle-btn:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}
.terminal-toggle-btn.active {
    color: white;
}

/* Terminal icon (mini terminal shape) */
.terminal-icon {
    width: 16px;
    height: 12px;
    position: relative;
    border: 1.5px solid currentColor;
    border-radius: 2px;
    background: transparent;
    transition: opacity 0.15s;
}
.terminal-icon::after {
    content: '>';
    position: absolute;
    top: -1px;
    left: 2px;
    font-size: 9px;
    font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
    font-weight: bold;
    line-height: 12px;
}

/* Terminal resize handle (between file view and terminal) */
.terminal-resize-handle {
    height: 4px;
    background: transparent;
    cursor: ns-resize;
    flex-shrink: 0;
    display: none;
}
.terminal-resize-handle:hover {
    background: var(--accent-color);
}

/* Terminal panel */
.terminal-panel {
    display: none;
    height: 200px;
    min-height: 100px;
    background: var(--bg-code);
    border-top: 1px solid var(--border-color);
    overflow: hidden;
}

/* Terminal container */
.terminal-container {
    flex: 1;
    padding: 12px 4px;
    overflow: hidden;
    min-height: 0;
}
.terminal-container .xterm {
    height: 100%;
    width: 100%;
}
.terminal-container .xterm-viewport {
    overflow-y: auto;
}
.terminal-container .xterm-screen {
    height: 100%;
}

/* Right pane layout modes controlled by CSS classes on .preview-pane */

/* When only terminal is open (no file view): terminal fills the pane */
.preview-pane.terminal-only .file-view-row,
.preview-pane.terminal-only .terminal-resize-handle {
    display: none;
}
.preview-pane.terminal-only .terminal-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: auto;
    border-top: none;
}

/* When both file view and terminal are open: split vertically */
.preview-pane.split-mode .terminal-panel {
    display: flex;
    flex-direction: column;
}
.preview-pane.split-mode .terminal-resize-handle {
    display: block;
}

/* Flex children within preview-main-area */
.preview-main-area .preview-header {
    flex-shrink: 0;
}
.preview-main-area .preview-content {
    flex: 1;
    min-height: 80px;
    overflow: auto;
}
.preview-main-area .preview-status {
    flex-shrink: 0;
}
