:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #4493e0;
    --success: #3fb950;
    --error: #f85149;
    --warning: #d29922;
    --border: #30363d;
    --border-hover: #484f58;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Consolas', monospace;
}

[data-theme="light"] {
    --bg-primary: #f7f7f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --accent: #0a84ff;
    --accent-hover: #0666d0;
    --success: #0f7b5c;
    --error: #d92d20;
    --warning: #a16207;
    --border: #e6e7eb;
    --border-hover: #d4d6db;
}

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

html {
    overflow-x: hidden;
    width: 100%;
    overscroll-behavior: none; /* Disable pull-to-refresh */
}

body {
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, var(--font-mono);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow: hidden;
    width: 100%;
    overscroll-behavior: none; /* Disable pull-to-refresh */
    touch-action: pan-x pan-y; /* Allow normal scrolling but prevent browser gestures */
    position: relative;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    max-height: 100vh;
    max-height: 100dvh;
}

# Icon helpers
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

/* Status dots (replace emoji dots) */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background-color: var(--border); }
.dot.dot-on { background-color: var(--success); }
.dot.dot-idle { background-color: #9ca3af; }
.dot.dot-error { background-color: var(--error); }

/* Header styles removed - using tab-based interface */

/* Session Tabs Bar */
.session-tabs-bar {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    min-height: 36px;
    position: relative;
    overflow: visible; /* Ensure dropdown can overflow */
}

.tabs-section {
    display: flex;
    align-items: center;
    flex: 1;
    overflow-x: auto;
    overflow-y: visible; /* Allow dropdown to overflow vertically */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.tabs-section::-webkit-scrollbar {
    height: 4px;
}

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

.tabs-container {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 0;
}

.session-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px 6px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    max-width: 200px;
    position: relative;
    user-select: none;
}

.session-tab:hover {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.session-tab.active {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-bottom-color: var(--bg-primary);
}

.session-tab.dragging {
    opacity: 0.5;
}

.tab-content {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.tab-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.tab-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.3s ease;
    position: relative;
}

.tab-status.active {
    background-color: var(--success);
}

.tab-status.idle {
    background-color: #3b82f6;  /* Blue to indicate Claude likely finished */
    animation: idle-gentle-pulse 3s infinite;
}

.tab-status.disconnected {
    background-color: var(--error);
}

.tab-status.error {
    background-color: var(--error);
}

/* Pulse animation for active sessions */
.tab-status.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes idle-gentle-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

/* Unread indicator - changes status dot to blue */
.tab-status.unread {
    background-color: #3b82f6 !important;
    animation: unread-pulse 1.5s infinite;
}

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

.session-tab.has-unread .tab-name {
    color: #3b82f6;
    font-weight: 600;
}

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

.tab-close {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
    flex-shrink: 0;
}

.session-tab:hover .tab-close {
    opacity: 0.6;
}

.tab-close:hover {
    opacity: 1;
    background-color: var(--border);
}

.tab-name-input {
    width: 100%;
    font: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-hover);
    border-radius: 4px;
    padding: 2px 4px;
    outline: none;
}

.tab-new {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-left: 4px;
}

.tab-actions { display: flex; gap: 6px; align-items: center; }
.tab-tile {
  width: 28px; height: 28px; display:flex; align-items:center; justify-content:center;
  background: transparent; border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-secondary); cursor: pointer; transition: all .2s; flex-shrink: 0; margin-left: 4px;
}
.tab-tile:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.tab-tile[disabled] { opacity: .5; cursor: not-allowed; }

/* Global tabs are visible; panes can be enabled optionally */

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

.tab-settings {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    margin-left: auto;
    flex-shrink: 0;
}

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

/* Tab Overflow Dropdown for Mobile */
.tab-overflow-wrapper {
    position: relative;
    display: none;
}

.tab-overflow-btn {
    width: auto;
    height: 28px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 4px;
}

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

.tab-overflow-count {
    font-size: 12px;
    font-weight: 600;
}

.tab-overflow-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 200px;
    max-width: 300px;
    z-index: 10000; /* Higher z-index to ensure it appears above everything */
    max-height: 400px;
    overflow-y: auto;
}

.tab-overflow-menu.active {
    display: block;
}

.overflow-tab-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--border);
}

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

.overflow-tab-item:hover {
    background-color: var(--bg-tertiary);
}

.overflow-tab-item.active {
    background-color: var(--bg-tertiary);
    color: var(--accent);
}

.overflow-tab-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.overflow-tab-close {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.overflow-tab-close:hover {
    background-color: var(--error);
    color: white;
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    /* Overflow wrapper visibility is controlled by JavaScript */
}

/* Terminal Container */
.terminal-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.terminal-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
}


/* Session Dropdown Styles - Hidden when using tabs */
.session-dropdown {
    position: relative;
    display: none; /* Hide dropdown when using tabs */
}

.session-btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

.session-btn svg {
    opacity: 0.8;
}

.dropdown-arrow {
    transition: transform 0.2s;
}

.session-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    min-width: 320px;
    max-width: 400px;
    z-index: 1000;
    display: none;
}

.session-dropdown-menu.active {
    display: block;
}

.session-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-dropdown-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.session-list {
    max-height: 300px;
    overflow-y: auto;
}

.session-item {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.session-item:hover {
    background-color: var(--bg-tertiary);
}

.session-item.active {
    background-color: var(--bg-tertiary);
    border-left: 3px solid var(--accent);
    padding-left: 13px;
}

.session-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.session-status {
    font-size: 10px;
}

.session-details {
    flex: 1;
}

.session-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.session-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.session-folder {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.session-actions {
    display: flex;
    gap: 4px;
}

.no-sessions {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.session-dropdown-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

/* Session Modal Styles */
.session-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

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

.session-modal .modal-content {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 8px 12px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover:not(:disabled) {
    background-color: var(--bg-secondary);
    border-color: var(--border-hover);
}

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

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    border-color: var(--border);
}

.btn-danger {
    background-color: var(--error);
    color: white;
    border-color: var(--error);
}

.btn-danger:hover:not(:disabled) {
    background-color: #d73a49;
    border-color: #d73a49;
}

.btn-danger-skip {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #8b0000;
    color: white;
    border: 2px solid #660000;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger-skip:hover {
    background-color: #a00000;
    border-color: #800000;
    box-shadow: 0 0 10px rgba(139, 0, 0, 0.5);
}

.btn-danger-skip svg {
    width: 24px;
    height: 24px;
}

.main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.terminal-container {
    flex: 1;
    position: relative;
    background-color: var(--bg-primary);
    width: 100%;
    overflow: hidden;
}

/* Context menu for tabs */
.pane-session-menu { position: absolute; z-index: 3000; min-width: 220px; background: var(--bg-secondary); border:1px solid var(--border); border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,.35); padding:6px; }
.pane-session-item { padding:8px 10px; border-radius:6px; cursor:pointer; color: var(--text-primary); }
.pane-session-item.used { color: var(--text-secondary); }
.pane-session-item:hover { background: var(--bg-tertiary); }

/* Split View */
.split-container {
    flex: 1;
    display: flex;
    min-height: 0;
    position: relative;
}

.split-pane {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-primary);
    transition: border-color 0.2s ease;
}

.split-pane.split-active {
    border: 2px solid var(--accent);
}

.split-terminal-wrapper {
    flex: 1;
    min-height: 0;
  width: 100%;
    display: flex;
    flex-direction: column;
}

.split-left {
    width: 50%;
}

.split-right {
    width: 50%;
}

.split-divider {
    width: 6px;
  background: var(--border);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.split-divider:hover {
    background: var(--border-hover);
}

.split-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.split-close:hover {
    opacity: 1;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Drop zone for drag-to-split */
.split-drop-zone {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100px;
    background: rgba(88, 166, 255, 0.15);
    border: 2px dashed rgba(88, 166, 255, 0.5);
    border-radius: 8px;
    pointer-events: none;
    z-index: 100;
}

#terminal {
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
}

.terminal-overlay {
    position: fixed; /* Cover the full app regardless of container visibility */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5000;
    background-color: rgba(13, 17, 23, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.overlay-content {
    text-align: center;
    padding: 40px;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    max-width: 520px;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.start-prompt h2 {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.start-prompt p {
    margin-bottom: 20px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.start-buttons {
    display: flex;
    gap: 12px;
    align-items: stretch;
    justify-content: center;
    flex-wrap: wrap;
}
.start-buttons .btn {
    min-width: 180px;
}

.error-message h3 {
    color: var(--error);
    margin-bottom: 12px;
}

.error-message p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

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

.modal-content {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    margin: 20px auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.close-btn, .modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    -webkit-tap-highlight-color: transparent;
}

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

.modal-body {
    padding: 20px;
}

.setting-group {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.setting-group label {
    flex: 0 0 auto;
    width: 100px;
    font-weight: 500;
    font-size: 14px;
}

.setting-group input[type="range"] {
    flex: 1;
    height: 4px;
    background: var(--border);
    outline: none;
    border-radius: 2px;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    cursor: pointer;
    border-radius: 50%;
}

.setting-group select {
    flex: 1;
    padding: 6px 12px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-mono);
}

.setting-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

#fontSizeValue {
    flex: 0 0 auto;
    width: 40px;
    font-size: 12px;
    color: var(--text-secondary);
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

/* Plan Modal Styles */
.plan-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 10001;
    animation: fadeIn 0.3s ease;
}

.plan-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.plan-modal .modal-content {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.plan-modal .modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.plan-modal .modal-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.plan-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 20px;
}

.plan-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #10b981;
    animation: pulse 2s infinite;
}

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

.plan-status-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.plan-content {
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text-primary);
}

.plan-content h2 {
    color: var(--accent);
    font-size: 1.2rem;
    margin: 1rem 0;
}

.plan-content h3 {
    color: var(--text-primary);
    font-size: 1rem;
    margin: 0.8rem 0;
}

.plan-content ul,
.plan-content ol {
    margin: 0.5rem 0 0.5rem 1.5rem;
}

.plan-content li {
    margin: 0.3rem 0;
}

.plan-content code {
    background-color: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--accent);
}

.plan-content pre {
    background-color: var(--bg-tertiary);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
}

.plan-modal .modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    gap: 15px;
}

.plan-modal .btn {
    padding: 10px 30px;
    font-size: 1rem;
    font-weight: 600;
}

.plan-modal .btn-success {
    background-color: #10b981;
    color: white;
}

.plan-modal .btn-success:hover {
    background-color: #059669;
}

.plan-modal .btn-danger {
    background-color: #ef4444;
    color: white;
}

.plan-modal .btn-danger:hover {
    background-color: #dc2626;
}

/* Legacy mobile styles - removed in favor of comprehensive mobile styles section below */

.xterm .xterm-viewport {
    background-color: transparent !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

.xterm .xterm-screen {
    background-color: transparent !important;
}

/* Fix xterm canvas width on mobile */
.xterm {
    width: 100%;
    height: 100%;
}

.xterm-screen canvas {
    max-width: 100%;
}

/* Fix scrollbar extending beyond viewport */
.xterm-viewport::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.xterm-viewport::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.xterm-viewport::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
}

.xterm-viewport::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* Folder Browser Modal */
.folder-browser-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.folder-browser-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.folder-browser-content {
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.folder-browser-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 20px;
    gap: 16px;
    overflow: hidden;
}

.folder-path-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 36px;
    height: 36px;
}

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

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

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

.folder-path-input {
    flex: 1;
    padding: 8px 12px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}

.folder-create-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--accent);
    border-radius: 4px;
}

.folder-name-input {
    flex: 1;
    padding: 8px 12px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}

.folder-name-input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.folder-list-container {
    flex: 1;
    min-height: 200px;
    max-height: 400px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background-color: var(--bg-tertiary);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.folder-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    min-height: 0;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 4px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.folder-item:hover {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

.folder-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

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

.folder-browser-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

.folder-browser-buttons {
    display: flex;
    gap: 8px;
}

.empty-folder-message {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Mobile Menu Styles */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    margin: 0;
    border-radius: 4px;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s ease;
}

.hamburger-btn:hover {
    background-color: var(--bg-tertiary);
}

.hamburger-line {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.mobile-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100%;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    z-index: 3000;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.mobile-menu.active {
    left: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.mobile-menu-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.close-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-menu-btn {
    padding: 12px 16px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: left;
}

.mobile-menu-btn:hover:not(:disabled) {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

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

.mobile-menu-btn.btn-danger {
    background-color: var(--error);
    color: white;
    border-color: var(--error);
}

.mobile-menu-btn.btn-danger:hover:not(:disabled) {
    background-color: #d73a49;
    border-color: #d73a49;
}

.desktop-only {
    display: block;
}

/* Ensure pre-formatted text and code blocks wrap properly */
pre, code {
    word-wrap: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

/* Mobile Modal Fixes */
@media (max-width: 768px) {
    /* Base modal fixes */
    .settings-modal,
    .session-modal,
    .folder-browser-modal {
        padding: 10px;
        align-items: flex-start;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-content {
        width: calc(100% - 20px);
        max-width: none;
        max-height: calc(100vh - 20px);
        margin: 10px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .folder-browser-content {
        width: calc(100% - 20px);
        max-width: none;
        max-height: calc(100vh - 20px);
        height: auto;
    }
    
    .modal-header {
        padding: 15px;
        position: sticky;
        top: 0;
        background-color: var(--bg-secondary);
        z-index: 10;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        padding: 15px;
        position: sticky;
        bottom: 0;
        background-color: var(--bg-secondary);
        z-index: 10;
        gap: 10px;
    }
    
    /* Ensure buttons in modals are touch-friendly */
    .modal-footer .btn {
        min-height: 44px;
        padding: 12px 20px;
    }
    
    /* Fix folder browser specific issues */
    .folder-list-container {
        max-height: 40vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .folder-item {
        min-height: 44px;
        padding: 12px;
    }
    
    /* Session modal fixes */
    .session-list {
        max-height: 50vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .session-item {
        min-height: 44px;
        padding: 10px;
    }
    
    /* Ensure close buttons are easily tappable */
    .close-btn,
    .modal-close {
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
    }
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .hamburger-btn {
        display: flex;
        flex-shrink: 0;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    .header {
        padding: 8px 12px;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 0;
        flex-shrink: 0;
        min-height: 44px;
    }
    
    .header-content {
        flex: 1;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        min-width: 0;
    }
    
    .header-info {
        display: flex;
        flex-direction: row;
        gap: 8px;
        align-items: center;
        justify-content: flex-end;
    }
    
    .status {
        font-size: 11px;
        padding: 2px 6px;
        white-space: nowrap;
    }
    
    .working-dir {
        font-size: 11px;
        padding: 2px 6px;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .header-controls {
        display: none;
    }
    
    .main {
        flex: 1;
        overflow: hidden;
    }
    
    .terminal-container {
        padding: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
    
    #terminal {
        padding: 8px;
        width: 100%;
        height: 100%;
        box-sizing: border-box;
    }
    
    /* Force xterm to respect mobile viewport */
    .xterm {
        width: 100% !important;
        height: 100% !important;
    }
    
    .xterm-viewport {
        width: 100% !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }
    
    .xterm-screen {
        width: 100% !important;
    }
    
    .overlay-content {
        padding: 20px;
        max-width: 90%;
    }
    
    .start-prompt h2 {
        font-size: 20px;
    }
    
    .start-prompt p {
        font-size: 14px;
    }
    
    /* Modal styles are handled in the Mobile Modal Fixes section above */
}

/* Extra small devices (phones in portrait) */
@media (max-width: 480px) {
    .header {
        padding: 6px 8px;
        display: flex;
        flex-direction: row;
        align-items: center;
    }
    
    .hamburger-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        padding: 8px;
    }
    
    .header-info {
        gap: 6px;
    }
    
    .status {
        font-size: 10px;
        padding: 1px 4px;
    }
    
    .working-dir {
        font-size: 10px;
        padding: 1px 4px;
        max-width: 120px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 11px;
    }
    
    .start-buttons { flex-direction: column; width: 100%; }
    .start-buttons .btn { width: 100%; }
    
    /* Extra terminal fixes for very small screens */
    #terminal {
        padding: 4px;
    }
    
    /* Ensure modals don't overflow */
    .modal-content {
        max-height: 85vh;
        overflow-y: auto;
    }
    
    /* Adjust main container */
    .main {
        padding: 0;
        margin: 0;
    }
    
    body {
        overflow-x: hidden;
    }
}

/* Mode Switcher Styles */
.mode-switcher {
    position: fixed;
    bottom: 80px; /* Increased from 20px to avoid covering text input */
    right: 20px;
    z-index: 1000;
    display: none;
    flex-direction: column;
    gap: 10px;
}

/* Show mode switcher on mobile devices */
@media (max-width: 1024px) and (hover: none) and (pointer: coarse),
       (max-width: 768px) {
    .mode-switcher {
        display: flex;
    }
}

.mode-switcher-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    width: 56px;
    height: 56px;
}

.mode-switcher-btn:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.mode-switcher-btn:active {
    transform: translateY(0);
}

.mode-switcher-btn.switching {
    animation: modeSwitchPulse 0.3s ease;
}

@keyframes modeSwitchPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
        background-color: var(--accent);
    }
    100% {
        transform: scale(1);
    }
}

.mode-switcher-btn svg {
    width: 24px;
    height: 24px;
    stroke: var(--accent);
    flex-shrink: 0;
}

/* Add visual indicator for current mode */
.mode-switcher-btn[data-mode="chat"] {
    border-color: var(--success);
}

.mode-switcher-btn[data-mode="code"] {
    border-color: var(--accent);
}

.mode-switcher-btn[data-mode="plan"] {
    border-color: var(--warning);
}

/* Escape Button Styles */
.escape-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--error);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    width: 56px;
    height: 56px;
}

.escape-btn:hover {
    background-color: var(--bg-tertiary);
    border-color: #ff4444;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 68, 68, 0.2);
}

.escape-btn:active {
    transform: translateY(0);
}

.escape-btn.pressed {
    animation: escapeBtnPress 0.2s ease;
}

@keyframes escapeBtnPress {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.9);
        background-color: var(--error);
    }
    100% {
        transform: scale(1);
    }
}

.escape-btn svg {
    width: 24px;
    height: 24px;
    stroke: var(--error);
    flex-shrink: 0;
}

/* Commands UI removed */
