/* MindPaw Matrix — IDE Theme */

:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-hover: #1c2333;
    --surface-active: #21283b;
    --border: #30363d;
    --border-light: #3d444d;
    --text: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #7c3aed;
    --accent-hover: #9055f5;
    --accent-glow: rgba(124, 58, 237, 0.25);
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --info: #58a6ff;
    --user-bubble: #1a2744;
    --ai-bubble: #1c1c2e;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --sans: 'Inter', -apple-system, system-ui, sans-serif;
    --panel-files-width: 240px;
    --panel-preview-width: 1fr;
    --panel-chat-width: 400px;
    --header-h: 44px;
    --radius: 8px;
    --transition: 0.15s ease;
}

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

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ─── Header ─────────────────────── */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    padding: 0 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    -webkit-app-region: drag;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo {
    font-size: 22px;
}

.header h1 {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    color: white;
    font-weight: 500;
    vertical-align: middle;
}

.header-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
    -webkit-app-region: no-drag;
}

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

.header-btn.active {
    background: var(--surface-active);
    color: var(--text);
    border-color: var(--border);
}

.agent-badge {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    color: var(--accent-hover);
    font-weight: 500;
}

/* ─── IDE Three-Panel Layout ─────── */

.ide-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.ide-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s ease;
}

.panel-files {
    width: var(--panel-files-width);
    min-width: 180px;
    max-width: 400px;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.panel-preview {
    flex: 1;
    min-width: 200px;
    background: var(--bg);
}

.panel-chat {
    width: var(--panel-chat-width);
    min-width: 320px;
    max-width: 600px;
    background: var(--surface);
    border-left: 1px solid var(--border);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 36px;
    padding: 0 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
}

.panel-header h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ─── Panel Resizer ──────────────── */

.panel-resizer {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    transition: background 0.2s;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.panel-resizer:hover,
.panel-resizer.dragging {
    background: var(--accent);
}

/* ─── File Tree Panel ────────────── */

.file-roots {
    display: flex;
    gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
}

.root-btn {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.root-btn:hover {
    background: var(--surface-active);
    color: var(--text);
}

.root-btn.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent-hover);
}

.file-path-bar {
    display: flex;
    align-items: center;
    padding: 4px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.path-text {
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: rtl;
    text-align: left;
}

.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: background var(--transition);
    user-select: none;
}

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

.file-item.active {
    background: var(--surface-active);
}

.file-item.is-dir {
    font-weight: 500;
}

.file-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

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

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

.file-item[draggable="true"] {
    cursor: grab;
}

.file-item[draggable="true"]:active {
    cursor: grabbing;
    opacity: 0.6;
}

/* ─── Preview Panel ──────────────── */

.preview-header {
    padding: 0;
    overflow-x: auto;
}

.preview-tabs {
    display: flex;
    height: 100%;
    gap: 0;
}

.preview-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    height: 100%;
}

.preview-tab:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.preview-tab.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.preview-tab .tab-close {
    font-size: 14px;
    padding: 0 2px;
    border-radius: 4px;
    opacity: 0.5;
}

.preview-tab .tab-close:hover {
    opacity: 1;
    background: var(--surface-active);
}

.preview-content {
    flex: 1;
    overflow: auto;
    position: relative;
}

.welcome-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 10px;
    color: var(--text-muted);
}

.welcome-preview .welcome-icon {
    font-size: 48px;
    opacity: 0.4;
}

.welcome-preview h2 {
    font-size: 18px;
    color: var(--text-secondary);
}

.welcome-preview p {
    font-size: 13px;
}

.code-preview {
    padding: 0;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
}

.code-preview .line-numbers {
    display: inline-block;
    width: 48px;
    padding: 12px 8px 12px 12px;
    text-align: right;
    color: var(--text-muted);
    background: var(--surface);
    border-right: 1px solid var(--border);
    user-select: none;
    vertical-align: top;
    font-size: 12px;
    line-height: 1.6;
}

.code-preview .code-content {
    display: inline-block;
    padding: 12px 16px;
    overflow-x: auto;
    width: calc(100% - 48px);
    vertical-align: top;
}

.code-preview pre {
    margin: 0;
    padding: 0;
    background: transparent;
}

.code-preview code {
    font-family: var(--mono);
    font-size: 13px;
    background: transparent !important;
}

.preview-file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.preview-image {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    background: #111;
}

.preview-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* ─── Chat Panel ─────────────────── */

.chat-panel-header {
    gap: 8px;
}

.agent-switcher {
    flex-shrink: 0;
}

.agent-select {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--sans);
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

.chat-footer {
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.messages {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.6;
    max-width: 100%;
    word-wrap: break-word;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    background: var(--user-bubble);
    border: 1px solid rgba(88, 166, 255, 0.15);
    align-self: flex-end;
    max-width: 90%;
}

.message.assistant {
    background: var(--ai-bubble);
    border: 1px solid rgba(124, 58, 237, 0.15);
}

.message.error {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--danger);
}

.message pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    overflow-x: auto;
    font-size: 12px;
    margin: 8px 0;
}

.message code {
    font-family: var(--mono);
    font-size: 12px;
}

.message p code {
    background: var(--surface-hover);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
}

.message table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 12px;
}

.message th,
.message td {
    border: 1px solid var(--border);
    padding: 4px 8px;
    text-align: left;
}

.message th {
    background: var(--surface);
    font-weight: 600;
}

.message a {
    color: var(--info);
    text-decoration: none;
}

.message a:hover {
    text-decoration: underline;
}

.message img {
    max-width: 100%;
    border-radius: 6px;
    margin: 4px 0;
}

/* ─── Input ──────────────────────── */

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 10px;
}

.input-agent-indicator {
    font-size: 16px;
    flex-shrink: 0;
    padding-bottom: 4px;
}

.input-box {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--sans);
    font-size: 13px;
    padding: 8px 12px;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color var(--transition);
}

.input-box:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Drop zone highlight */
.input-box.drag-over {
    border-color: var(--accent);
    background: rgba(124, 58, 237, 0.08);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-send {
    background: var(--accent);
    border: none;
    color: white;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition);
}

.btn-send:hover {
    background: var(--accent-hover);
}

.btn-image {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background var(--transition);
    flex-shrink: 0;
}

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

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background var(--transition);
}

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

/* ─── Status Bar ─────────────────── */

.status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    font-size: 11px;
}

.context-bar {
    display: flex;
    align-items: center;
    gap: 4px;
}

.context-label {
    font-size: 11px;
}

.context-track {
    width: 50px;
    height: 4px;
    background: var(--surface-active);
    border-radius: 2px;
    overflow: hidden;
}

.context-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.context-pct {
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 10px;
}

.model-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--surface-hover);
    color: var(--text-secondary);
    font-family: var(--mono);
}

.cost-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 10px;
    margin-left: auto;
}

.cost-sep {
    color: var(--border);
}

/* ─── Approval ───────────────────── */

.approval-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.approval-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    max-width: 360px;
    width: 90%;
}

.approval-header {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.approval-body {
    font-size: 12px;
    font-family: var(--mono);
    background: var(--bg);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 16px;
    max-height: 200px;
    overflow: auto;
    word-break: break-all;
}

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

.btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-approve {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-always {
    background: var(--info);
    color: white;
    border-color: var(--info);
}

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

.btn:hover {
    filter: brightness(1.1);
}

/* ─── Modal ──────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: auto;
}

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

.modal-header h3 {
    font-size: 14px;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    padding: 18px;
}

.modal-wide {
    max-width: 600px;
}

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

/* ─── Settings Form ──────────────── */

.settings-section {
    margin-bottom: 20px;
}

.settings-section h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    font-size: 12px;
}

.settings-row label {
    color: var(--text-secondary);
    flex-shrink: 0;
    min-width: 100px;
}

.settings-row select,
.settings-row input[type="number"],
.settings-row input[type="text"] {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: var(--mono);
    min-width: 80px;
}

.settings-row select {
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--surface-active);
    border-radius: 10px;
    transition: background var(--transition);
}

.toggle-slider::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: all var(--transition);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--accent);
}

.toggle-switch input:checked+.toggle-slider::after {
    left: 19px;
    background: white;
}

.agent-settings-card {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 8px;
}

.agent-settings-card .agent-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
}

.memory-stat {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--mono);
    padding: 2px 8px;
    background: var(--surface-hover);
    border-radius: 4px;
}

/* ─── Preview Actions Bar ────────── */

.preview-actions {
    display: flex;
    gap: 2px;
    align-items: center;
}

/* ─── Editor ─────────────────────── */

.editor-area {
    flex: 1;
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: none;
    padding: 12px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    outline: none;
    tab-size: 4;
}

.editor-area:focus {
    box-shadow: inset 0 0 0 1px var(--accent);
}

.editor-modified .preview-tab.active::after {
    content: ' •';
    color: var(--accent);
}

/* ─── Terminal ───────────────────── */

.terminal-panel {
    border-top: 1px solid var(--border);
    background: #0d0d0d;
    display: flex;
    flex-direction: column;
    max-height: 250px;
    min-height: 120px;
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid #222;
}

.terminal-output {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.4;
    color: #b0b0b0;
    white-space: pre-wrap;
    word-break: break-all;
}

.terminal-output .cmd-line {
    color: #7ee787;
}

.terminal-output .stderr-line {
    color: #f97583;
}

.terminal-output .exit-code {
    color: #d29922;
    font-size: 11px;
}

.terminal-input-bar {
    display: flex;
    align-items: center;
    border-top: 1px solid #222;
    padding: 4px 10px;
    background: #111;
}

.terminal-prompt {
    color: #7ee787;
    font-family: var(--mono);
    font-size: 13px;
    margin-right: 6px;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #e6e6e6;
    font-family: var(--mono);
    font-size: 13px;
    outline: none;
}

/* ─── Attachment Preview ─────────── */

.attachment-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 10px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 11px;
    background: var(--accent);
    color: white;
    border-radius: 12px;
    cursor: default;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-remove {
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    opacity: 0.7;
    margin-left: 2px;
}

.attachment-remove:hover {
    opacity: 1;
}

/* ─── Image Preview ──────────────── */

.image-preview {
    display: flex;
    gap: 6px;
    padding: 6px 10px;
    overflow-x: auto;
    border-top: 1px solid var(--border);
}

.preview-thumb {
    position: relative;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-remove {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 16px;
    height: 16px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: pointer;
    line-height: 1;
}

.preview-remove:hover {
    background: var(--danger);
}

/* ─── Shortcuts ──────────────────── */

.shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 12px;
}

.shortcut {
    font-size: 11px;
    font-family: var(--mono);
    padding: 3px 10px;
    border-radius: 6px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-secondary);
}

.shortcut:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent-hover);
}

/* ─── Utilities ──────────────────── */

.hidden {
    display: none !important;
}

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

/* ─── Scrollbar ──────────────────── */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ─── Drag & Drop ────────────────── */

.file-drop-indicator {
    font-size: 11px;
    color: var(--accent);
    padding: 4px 8px;
    background: var(--accent-glow);
    border-radius: 4px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ─── Mobile Responsive (≤768px) ── */

/* Mobile bottom navigation */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 300;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 56px;
}

.mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    padding: 4px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.mobile-nav-btn span {
    font-size: 9px;
    font-family: var(--sans);
}

.mobile-nav-btn.active {
    color: var(--accent);
    background: var(--accent-glow);
}

@media (max-width: 768px) {
    /* Show mobile nav, hide desktop toggles */
    .mobile-nav { display: block; }
    .header-center { display: none; }

    /* Header simplified */
    .header {
        padding: 0 8px;
        height: 44px;
    }
    .header-left h1 { font-size: 14px; }
    .header-left .badge { font-size: 9px; }
    .header-right { gap: 2px; }
    .header-btn { font-size: 14px; padding: 4px 6px; }
    .agent-badge { font-size: 11px; padding: 2px 8px; }

    /* App height accounts for bottom nav */
    #app {
        height: calc(100vh - 56px - env(safe-area-inset-bottom, 0));
        overflow: hidden;
    }

    body {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0));
    }

    /* IDE layout → stacked (only one visible at a time) */
    .ide-layout { position: relative; }
    .panel-resizer { display: none !important; }

    .ide-panel {
        position: absolute;
        inset: 0;
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        display: none;
    }

    .ide-panel.mobile-active {
        display: flex !important;
    }

    /* Chat always starts visible on mobile */
    .panel-chat.mobile-active {
        display: flex !important;
    }

    /* Chat panel adjustments */
    .chat-panel-header h3 { font-size: 13px; }
    .agent-select { font-size: 11px; max-width: 100px; }

    .input-row { padding: 6px 8px; }
    .input-box {
        font-size: 15px; /* prevent iOS zoom */
        padding: 8px 10px;
    }

    .status-bar {
        gap: 6px;
        padding: 3px 8px;
        flex-wrap: wrap;
    }

    .context-track { width: 36px; }
    .cost-info { font-size: 9px; }
    .model-badge { font-size: 9px; }

    /* Messages */
    .message {
        max-width: 95%;
        font-size: 13px;
        padding: 8px 10px;
    }

    /* Modal full-screen on mobile */
    .modal-content,
    .modal-wide,
    .modal-inner.modal-wide {
        max-width: 100vw;
        width: 100vw;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .modal {
        align-items: flex-start;
    }

    .modal-body {
        padding: 12px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-header {
        padding: 10px 14px;
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--surface);
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        background: var(--surface);
    }

    /* Agent management form adjustments */
    .agent-card {
        padding: 8px !important;
    }

    #create-agent-details summary {
        font-size: 14px !important;
        padding: 12px 14px !important;
    }

    #create-agent-details input,
    #create-agent-details select,
    #create-agent-details textarea {
        font-size: 15px !important; /* prevent iOS zoom */
    }

    /* Settings */
    .settings-row {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }

    .settings-row label {
        min-width: 0;
    }

    .agent-settings-card {
        padding: 8px 10px;
    }

    /* File tree */
    .file-roots {
        padding: 4px 6px;
    }

    .root-btn { font-size: 10px; padding: 3px 6px; }

    .file-item {
        padding: 8px 10px;
        font-size: 13px;
    }

    /* Terminal */
    .terminal-panel {
        max-height: 200px;
        min-height: 100px;
    }

    .terminal-input {
        font-size: 15px; /* prevent iOS zoom */
    }

    /* Git */
    .git-file-row {
        font-size: 11px;
    }

    .git-action {
        opacity: 1; /* always visible on touch */
    }

    /* Heartbeat editor */
    #hb-editor {
        min-height: 200px !important;
        font-size: 14px !important;
    }

    /* Preview */
    .preview-file-info {
        flex-wrap: wrap;
        gap: 6px;
    }

    .code-preview {
        font-size: 11px;
    }
}

/* Tablet (769px - 900px) */
@media (min-width: 769px) and (max-width: 900px) {
    .panel-files {
        width: 200px;
        min-width: 160px;
    }

    .panel-preview {
        display: none;
    }

    .panel-chat {
        flex: 1;
    }
}

/* ─── Git Panel ──────────────────── */

.modal-wide .modal-inner,
.modal-inner.modal-wide {
    max-width: 680px;
    width: 90vw;
}

.git-file-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px;
    font-size: 12px;
    font-family: var(--mono);
    border-radius: 4px;
}

.git-file-row:hover {
    background: var(--surface-hover);
}

.git-status {
    width: 20px;
    text-align: center;
    font-weight: bold;
    font-size: 11px;
}

.git-status.staged {
    color: #7ee787;
}

.git-status.modified {
    color: #d29922;
}

.git-status.untracked {
    color: #8b949e;
}

.git-filename {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.git-action {
    opacity: 0;
    transition: opacity 0.15s;
}

.git-file-row:hover .git-action {
    opacity: 1;
}

.git-diff-content {
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.4;
    padding: 10px;
    background: #0d0d0d;
    border-radius: 6px;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre;
    color: #b0b0b0;
}

/* ─── Diagnostics (Lint) ─────────── */

.diagnostics-bar {
    border-top: 1px solid var(--border);
    background: var(--surface);
    max-height: 150px;
    overflow-y: auto;
    font-size: 12px;
}

.diagnostics-summary {
    display: flex;
    gap: 10px;
    padding: 4px 10px;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.diagnostics-list {
    padding: 2px 0;
}

.diagnostics-item {
    display: flex;
    gap: 8px;
    padding: 2px 10px;
    font-family: var(--mono);
    font-size: 11px;
    cursor: default;
}

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

.diagnostics-item.diag-error {
    border-left: 2px solid var(--danger);
}

.diagnostics-item.diag-warning {
    border-left: 2px solid var(--warning);
}

.diag-loc {
    color: var(--accent);
    min-width: 70px;
}

.diag-code {
    color: var(--text-muted);
    min-width: 60px;
}

.diag-msg {
    flex: 1;
    color: var(--text);
}

.diag-error {
    color: var(--danger);
}

.diag-warning {
    color: var(--warning);
}