:root,
:root[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2128;
    --bg-hover: #21262d;
    --bg-active: #30363d;
    --border: #30363d;
    --border-light: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --accent-bg: rgba(56, 139, 253, 0.15);
    --success: #3fb950;
    --success-bg: rgba(63, 185, 80, 0.12);
    --danger: #f85149;
    --danger-bg: rgba(248, 81, 73, 0.12);
    --warning: #d29922;
    --warning-bg: rgba(210, 153, 34, 0.12);
    --user-bubble: #1f6feb;
    --assistant-bubble: #1c2128;
    --code-bg: #0d1117;
    --scrollbar-thumb: #30363d;
    --scrollbar-track: transparent;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --modal-overlay: rgba(0, 0, 0, 0.6);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --sidebar-width: 280px;
    --fe-width: 320px;
    --transition: 0.2s ease;
}

:root[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #edf0f3;
    --bg-hover: #e4e8ec;
    --bg-active: #d1d5db;
    --border: #d0d7de;
    --border-light: #e4e8ec;
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-muted: #8b949e;
    --accent: #0969da;
    --accent-hover: #0550ae;
    --accent-bg: rgba(9, 105, 218, 0.1);
    --success: #1a7f37;
    --success-bg: rgba(26, 127, 55, 0.1);
    --danger: #cf222e;
    --danger-bg: rgba(207, 34, 46, 0.1);
    --warning: #9a6700;
    --warning-bg: rgba(154, 103, 0, 0.1);
    --user-bubble: #0969da;
    --assistant-bubble: #f6f8fa;
    --code-bg: #f6f8fa;
    --scrollbar-thumb: #c4c9cf;
    --scrollbar-track: transparent;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --modal-overlay: rgba(0, 0, 0, 0.3);
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

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

/* ===== LOGIN SCREEN ===== */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg-primary);
}
.login-screen.hidden { display: none; }

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 40px;
    text-align: center;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-logo { color: var(--accent); margin-bottom: 16px; }

.login-card h1 { font-size: 28px; font-weight: 700; margin-bottom: 4px; }

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

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

.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color var(--transition);
}
.input-group input:focus { border-color: var(--accent); }

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--user-bubble);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); }

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
}

.login-setup-diag {
    margin-top: 20px;
    text-align: left;
}

.btn-link-muted {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    width: auto;
    display: inline;
}
.btn-link-muted:hover {
    color: var(--accent);
}

.login-setup-diag-out {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 11px;
    line-height: 1.45;
    color: var(--text-secondary);
    max-height: 240px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.login-setup-diag-out.hidden { display: none; }

/* ===== APP LAYOUT ===== */
.app-container { display: flex; height: 100vh; }
.app-container.hidden { display: none; }

/* ===== LEFT SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border-light);
}
.sidebar-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn-icon.btn-sm { padding: 4px; }

.conversation-list { flex: 1; overflow-y: auto; padding: 8px; }

.conv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background var(--transition);
    margin-bottom: 2px;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-active); }

.conv-item-headline {
    display: flex;
    align-items: center;
    min-width: 0;
    width: 100%;
}
.conv-item-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    min-width: 0;
}
.conv-item-title {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.conv-model-chip {
    flex-shrink: 0;
    font-size: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-models-select {
    flex-shrink: 0;
    font-size: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    max-width: 10rem;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
}
.conv-models-select:focus {
    outline: none;
    border-color: var(--accent);
}

.conv-item-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: all var(--transition);
}
.conv-item:hover .conv-item-delete { opacity: 1; }
.conv-item-delete:hover { color: var(--danger); background: var(--danger-bg); }

.conv-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conv-owner-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    display: inline-block;
    width: fit-content;
    text-transform: capitalize;
}
.conv-owner-admin { background: rgba(139,92,246,0.15); color: #a78bfa; }
.conv-owner-developer { background: rgba(59,130,246,0.15); color: #60a5fa; }
.conv-owner-designer { background: rgba(236,72,153,0.15); color: #f472b6; }

.conv-item-readonly {
    border-left: 2px solid var(--text-muted);
    padding-left: 10px;
}
.conv-item-readonly .conv-item-title { opacity: 0.85; }

/* ===== CHANGE LOG ===== */
.cl-open-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cl-open-row .gh-desc { flex: 1; margin: 0; }

.cl-expand-btn {
    flex-shrink: 0;
    color: var(--accent);
}
.cl-expand-btn:hover { background: var(--bg-hover); }

.cl-modal-toolbar {
    display: flex;
    gap: 8px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.cl-modal-input {
    padding: 7px 10px;
    font-size: 13px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    outline: none;
}
.cl-modal-input:focus { border-color: var(--accent); }
.cl-modal-input-wide { flex: 1; min-width: 140px; }

.cl-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
    min-height: 0;
}

.cl-modal-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cl-modal-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

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

.cl-modal-footer .changelog-pagination { flex: 1; }
.cl-modal-footer .btn-editor-cancel { flex-shrink: 0; }

.cl-entry {
    padding: 8px 10px;
    border-radius: var(--radius-xs);
    margin-bottom: 4px;
    border-left: 3px solid var(--text-muted);
    background: var(--bg-hover);
}
.cl-entry.cl-create { border-left-color: #22c55e; }
.cl-entry.cl-edit { border-left-color: #3b82f6; }
.cl-entry.cl-delete { border-left-color: #ef4444; }
.cl-entry.cl-restore { border-left-color: #f59e0b; }

.cl-entry-top {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.cl-action-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--bg-active);
    color: var(--text-secondary);
    flex-shrink: 0;
}
.cl-create .cl-action-badge { background: rgba(34,197,94,0.15); color: #22c55e; }
.cl-edit .cl-action-badge { background: rgba(59,130,246,0.15); color: #3b82f6; }
.cl-delete .cl-action-badge { background: rgba(239,68,68,0.15); color: #ef4444; }
.cl-restore .cl-action-badge { background: rgba(245,158,11,0.15); color: #f59e0b; }

.cl-file {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
    color: var(--text-primary);
    word-break: break-all;
}

button.cl-file-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
button.cl-file-link:hover { color: var(--text-primary); }

.fv-modal-card { max-width: min(960px, 96vw); }
.fv-hint {
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 16px 10px;
    margin: 0;
    line-height: 1.4;
}
.fv-hint-red {
    color: #f87171;
    font-weight: 600;
}
.fv-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 16px;
    min-height: 240px;
    max-height: 280px;
}
.fv-pane { display: flex; flex-direction: column; min-width: 0; }
.fv-pane-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.fv-pane-cm-wrap {
    flex: 1;
    min-height: 200px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    overflow: hidden;
    background: var(--bg-primary);
}
.fv-pane-cm-wrap .CodeMirror {
    height: 200px;
    font-size: 11px;
}
.fv-pane-cm-wrap .CodeMirror-scroll {
    min-height: 198px;
}
.fv-pane-cm-wrap .CodeMirror-gutters {
    border-right: 1px solid var(--border);
    background: var(--bg-tertiary);
}
/* Diff lines (CodeMirror addLineClass background) */
.fv-pane-cm-wrap .fv-cm-diff-line {
    background: rgba(248, 113, 113, 0.24) !important;
}

.fv-pane-pre {
    margin: 0;
    padding: 8px;
    font-size: 10px;
    line-height: 1.35;
    overflow: auto;
    max-height: 200px;
    background: var(--bg-active);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    white-space: pre-wrap;
    word-break: break-word;
}

.fv-pane-pre code {
    display: block;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}
.fv-diff-line {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
}
.fv-diff-changed {
    color: #f87171;
    background: rgba(248, 113, 113, 0.14);
}
.fv-diff-placeholder {
    display: block;
    min-height: 1.35em;
    opacity: 0.2;
}
.fv-diff-placeholder .fv-diff-ph-inner {
    display: inline-block;
    min-width: 4px;
}
.fv-plain-msg {
    color: var(--text-muted);
    font-style: italic;
    padding: 8px;
    font-size: 12px;
    line-height: 1.4;
}

.fv-pane-pre-fallback {
    max-height: 200px;
}

.cl-entry[data-path] {
    cursor: pointer;
}
.cl-entry[data-path]:hover {
    filter: brightness(1.03);
}
.cl-entry[data-path] .cl-file {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.fv-version-list {
    padding: 8px 16px 12px;
    max-height: 200px;
    overflow-y: auto;
}
.fv-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 6px 8px;
    margin-bottom: 4px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--bg-hover);
    cursor: pointer;
    font-size: 11px;
}
.fv-row:hover { background: var(--bg-active); }
.fv-row.fv-row-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}
.fv-row-meta { color: var(--text-muted); font-size: 10px; }
.fv-row-action {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.fv-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
}
@media (max-width: 720px) {
    .fv-compare { grid-template-columns: 1fr; max-height: none; }
}

.cl-entry-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-muted);
}

/* Login activity (settings, super admin) */
.login-stats-office-hint {
    font-size: 10px;
    color: var(--text-muted);
    margin: 0 0 8px;
    line-height: 1.35;
}

.login-stats-list {
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-tertiary);
}
.login-stats-row--after-hours {
    background: rgba(248, 113, 113, 0.1);
    border-left: 3px solid #f87171;
}
.login-stats-row--after-hours .login-stats-user,
.login-stats-row--after-hours .login-stats-time {
    color: #f87171;
}
.login-stats-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-light);
    font-size: 12px;
}
.login-stats-row:last-child { border-bottom: none; }
.login-stats-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.login-stats-user {
    font-weight: 600;
    color: var(--text-primary);
}
.login-stats-role {
    font-size: 10px;
    text-transform: capitalize;
    color: var(--text-muted);
}
.login-stats-meta {
    flex-shrink: 0;
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
    color: var(--text-secondary);
}
.login-stats-time { white-space: nowrap; }
.login-stats-ip {
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--text-muted);
}
.login-stats-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
    min-height: 24px;
}

.cl-user {
    font-weight: 600;
    color: var(--text-secondary);
}

.cl-role {
    text-transform: capitalize;
    opacity: 0.7;
}

.cl-time {
    margin-left: auto;
}

.changelog-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.cl-page-btn {
    background: var(--bg-active);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}
.cl-page-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.cl-page-info {
    font-size: 11px;
    color: var(--text-muted);
}

/* ===== USAGE WIDGET & SETTINGS ===== */
.usage-widget {
    border-top: 1px solid var(--border-light);
    flex-shrink: 1;
    overflow-y: auto;
    min-height: 0;
}

.usage-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--transition);
}
.usage-header:hover { background: var(--bg-hover); }
.usage-header svg:first-child { flex-shrink: 0; }
.usage-header span { flex: 1; }
.usage-chevron { transition: transform 0.2s ease; flex-shrink: 0; }
.usage-chevron.open { transform: rotate(180deg); }

.usage-budget-bar {
    padding: 0 16px 10px;
}

.budget-bar-track {
    width: 100%;
    height: 6px;
    background: var(--bg-active);
    border-radius: 3px;
    overflow: hidden;
}

.budget-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.4s ease;
    min-width: 0;
}
.budget-bar-fill.warning { background: var(--warning); }
.budget-bar-fill.danger { background: var(--danger); }

.budget-bar-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.settings-panel {
    padding: 0 16px 20px;
    overflow-y: auto;
}
.settings-panel.hidden { display: none; }

.settings-group {
    margin-bottom: 12px;
}

.settings-group label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.settings-input-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.settings-input-row input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 13px;
    outline: none;
    width: 0;
}
.settings-input-row input:focus { border-color: var(--accent); }

.btn-settings-save {
    background: var(--accent-bg);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 6px 14px;
    border-radius: var(--radius-xs);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-settings-save:hover { background: var(--accent); color: #fff; }

/* Training chat log (Settings): paths, preview, prompt excerpts */
.chat-log-settings-status {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.45;
    margin: 4px 0 10px;
}
.chat-log-settings-status p { margin: 0 0 6px; }
.chat-log-when-append { margin-bottom: 8px !important; }
.chat-log-muted-sm {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px !important;
}
.chat-log-paths-box {
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    margin-bottom: 12px;
}
.chat-log-paths-box.hidden { display: none !important; }
.chat-log-path-line {
    font-size: 12px;
    margin: 0 0 6px;
    line-height: 1.4;
    word-break: break-word;
}
.chat-log-path-line code { font-size: 11px; }
.chat-log-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin: 8px 0 10px;
}
.chat-log-details-settings { margin-bottom: 10px; }
.chat-log-details-settings summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.chat-log-preview-pre {
    max-height: 220px;
    overflow: auto;
    font-size: 11px;
    line-height: 1.4;
    padding: 10px;
    margin: 6px 0 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-log-hooks { margin-top: 6px; }
.chat-log-hook-card {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}
.chat-log-hook-card:last-of-type { border-bottom: none; }
.chat-log-hook-card h5 {
    margin: 0 0 4px;
    font-size: 12px;
    color: var(--text-primary);
}
.chat-log-hook-source {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.chat-log-hook-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.chat-log-hook-preview-pre {
    max-height: 160px;
    overflow: auto;
    margin: 0;
    padding: 8px;
    font-size: 11px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg-secondary);
    border-radius: var(--radius-xs);
}
.chat-log-mt-sm {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}
#chatLogSettingsRefreshBtn { margin-top: 8px; width: 100%; max-width: 100%; }

.settings-presets {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.preset-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    cursor: pointer;
    transition: all var(--transition);
}
.preset-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-bg);
}

.usage-stats {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    padding: 8px 12px;
    margin-bottom: 10px;
}

.usage-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-size: 12px;
}
.usage-stat-row span:first-child { color: var(--text-muted); }
.usage-stat-row span:last-child {
    color: var(--text-primary);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
}

.btn-reset {
    width: 100%;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    padding: 6px;
}
.btn-reset:hover { color: var(--danger); }

.usage-stats-group .gh-desc {
    font-size: 11px;
    line-height: 1.45;
}

.usage-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
    margin-bottom: 12px;
}

.usage-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    padding: 8px 10px;
}

.usage-stat--wide {
    grid-column: 1 / -1;
}

.usage-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.usage-stat-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    color: var(--text-primary);
}

.budget-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.budget-label {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.budget-input {
    flex: 1;
    min-width: 72px;
    max-width: 140px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 13px;
    outline: none;
}

.budget-input:focus {
    border-color: var(--accent);
}

.preset-budgets {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.budget-bar-wrap {
    margin-bottom: 10px;
}

/* ===== GITHUB CONNECTION ===== */
.settings-divider {
    height: 1px;
    background: var(--border-light);
    margin: 12px 0;
}

.gh-connect-panel {}

.gh-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.5;
}
.gh-desc a { color: var(--accent); text-decoration: none; }
.gh-desc a:hover { text-decoration: underline; }

.gh-status-panel {}

.gh-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.gh-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border);
}

.gh-username {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.gh-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--success-bg);
    color: var(--success);
}

/* ===== DIGITALOCEAN ===== */
.btn-do-connect {
    width: 100%;
    text-align: center;
}

.do-icon {
    color: #0080ff;
    flex-shrink: 0;
}

.do-badge {
    background: rgba(0, 128, 255, 0.12);
    color: #0080ff;
}

.do-user-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.btn-do-confirm {
    background: #0080ff;
}
.btn-do-confirm:hover { background: #006ad4; }

.deploy-info {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    padding: 10px 12px;
    margin-bottom: 12px;
}

.deploy-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}

.deploy-info-label {
    font-size: 12px;
    color: var(--text-muted);
}

.deploy-info-value {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ===== FILE EXPLORER PUSH BAR ===== */
.fe-push-bar {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.fe-push-bar.hidden { display: none; }

.btn-push.hidden { display: none; }

.btn-push-do:hover {
    border-color: #0080ff;
    color: #0080ff;
    background: rgba(0, 128, 255, 0.1);
}

.btn-push {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-push:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-bg);
}
.btn-push svg { flex-shrink: 0; }

/* ===== PUSH MODAL ===== */
.modal-card-lg {
    max-width: 480px;
}

.push-form {
    margin: 12px 0;
}

.push-field {
    margin-bottom: 12px;
}

.push-field label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-weight: 600;
}

.push-field select,
.push-field input,
.push-field textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
    transition: border-color var(--transition);
}
.push-field select:focus,
.push-field input:focus,
.push-field textarea:focus { border-color: var(--accent); }

.push-field select option { background: var(--bg-secondary); }

.push-field textarea { resize: vertical; min-height: 40px; }

.push-repo-row {
    display: flex;
    gap: 6px;
}
.push-repo-row select { flex: 1; }

.push-new-repo,
.push-new-branch {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    padding: 12px;
    margin-bottom: 12px;
}
.push-new-repo .push-field:last-child,
.push-new-branch .push-field:last-child { margin-bottom: 0; }
.push-new-repo.hidden,
.push-new-branch.hidden { display: none; }

.push-field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.push-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}
.push-checkbox input { width: auto; padding: 0; }

.push-success {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--success-bg);
    border: 1px solid rgba(63, 185, 80, 0.3);
    border-radius: var(--radius-xs);
    padding: 12px 14px;
    margin-top: 10px;
    color: var(--success);
    font-size: 13px;
    line-height: 1.5;
}
.push-success.hidden { display: none; }
.push-success svg { flex-shrink: 0; margin-top: 2px; }
.push-success a { color: var(--accent); text-decoration: none; }
.push-success a:hover { text-decoration: underline; }
.push-success strong { color: var(--text-primary); }

.deploy-progress-wrap {
    margin-top: 12px;
    padding: 12px 0 4px;
}
.deploy-progress-wrap.hidden { display: none; }
.deploy-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}
.deploy-progress-meta #deployProgressPercent {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}
.deploy-progress-count { font-size: 12px; opacity: 0.9; }
.deploy-progress-track {
    height: 8px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    overflow: hidden;
}
.deploy-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent), #58a6ff);
    transition: width 0.15s ease-out;
}
.deploy-progress-file {
    margin-top: 8px;
    font-size: 11px;
    font-family: ui-monospace, monospace;
    color: var(--text-muted);
    word-break: break-all;
    line-height: 1.35;
    max-height: 3.9em;
    overflow: hidden;
}

.btn-push-confirm {
    background: var(--success);
    border: none;
    color: #fff;
    padding: 8px 18px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
}
.btn-push-confirm:hover { background: #2ea043; }
.btn-push-confirm:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-push-confirm .send-spinner {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

/* ===== TEAM MANAGEMENT ===== */
.settings-divider-section.hidden { display: none; }

.team-list { margin-bottom: 8px; }

.team-member {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: var(--radius-xs);
    margin-bottom: 3px;
    font-size: 12px;
    background: var(--bg-tertiary);
}
.team-member.disabled { opacity: 0.5; }

.team-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.team-role-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 1px 6px;
    border-radius: 8px;
}
.team-role-admin, .team-role-super_admin {
    background: var(--danger-bg);
    color: var(--danger);
}
.team-role-developer {
    background: var(--accent-bg);
    color: var(--accent);
}
.team-role-designer {
    background: var(--warning-bg);
    color: var(--warning);
}

.team-toggle { color: var(--success); }
.team-member.disabled .team-toggle { color: var(--text-muted); }
.team-delete { color: var(--text-muted); }
.team-delete:hover { color: var(--danger); }

.team-add-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.team-input {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
}
.team-input:focus { border-color: var(--accent); }
select.team-input { cursor: pointer; }
select.team-input option { background: var(--bg-secondary); }

/* ===== RESTRICTED PATHS ===== */
.restrict-list { margin-bottom: 8px; }

.restrict-add-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.restrict-users-wrap.hidden { display: none; }

.restrict-users-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
}

.restrict-user-pick-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.restrict-user-pick-row .team-input {
    flex: 1;
    min-width: 0;
}

.btn-restrict-add {
    flex-shrink: 0;
    padding-left: 12px;
    padding-right: 12px;
    white-space: nowrap;
}

.restrict-selected-users {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 28px;
    margin-top: 6px;
}

.restrict-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 2px 6px 2px 8px;
    border-radius: 4px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.restrict-user-chip button {
    background: none;
    border: none;
    padding: 0 2px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
}
.restrict-user-chip button:hover { color: #ef4444; }

.restrict-users-hint {
    font-size: 10px;
    color: var(--text-muted);
    margin: 6px 0 0;
    line-height: 1.35;
}

.restrict-users-empty {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

.restrict-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
    margin-bottom: 3px;
}

.restrict-path {
    font-size: 11px;
    color: var(--accent);
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.restrict-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.restrict-scopes {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.restrict-scope {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    display: inline-block;
}

.restrict-scope-global {
    background: rgba(239,68,68,0.15);
    color: #f87171;
}

.restrict-scope-user {
    background: rgba(59,130,246,0.15);
    color: #60a5fa;
}

.restrict-delete { color: var(--text-muted); flex-shrink: 0; margin-top: 2px; }
.restrict-delete:hover { color: var(--danger); }

/* ===== SIDEBAR FOOTER ===== */
.logged-in-user {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: capitalize;
}

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

.btn-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    padding: 6px 0;
    transition: color var(--transition);
}
.btn-text:hover { color: var(--danger); }

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-xs);
    padding: 8px;
    cursor: pointer;
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 101;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}
.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--accent);
    background: var(--bg-hover);
}
.theme-toggle.fe-shifted {
    right: calc(var(--fe-width) + 12px);
}

:root[data-theme="dark"] .theme-icon-sun  { display: block; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="light"] .theme-icon-sun  { display: none; }
:root[data-theme="light"] .theme-icon-moon { display: block; }

/* ===== CHAT AREA ===== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-agent-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 8px 24px 0;
    font-size: 12px;
    color: var(--text-muted);
}
.chat-agent-bar-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 11px;
}
.chat-agent-bar[data-mode="agent"] .chat-agent-bar-label { color: var(--accent); }
.chat-agent-bar[data-mode="plan"] .chat-agent-bar-label { color: var(--warning); }
.chat-agent-bar[data-mode="debug"] .chat-agent-bar-label { color: var(--danger); }
.chat-agent-bar[data-mode="ask"] .chat-agent-bar-label { color: var(--success); }
.chat-agent-bar-sep { opacity: 0.5; }
.chat-agent-model-id {
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--text-secondary);
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.last-turn-usage {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(480px, 58vw);
}
.last-turn-usage.last-turn-usage--hidden {
    display: none;
}

.agent-session-info {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex-shrink: 0;
    margin: 0 24px 8px;
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary);
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.agent-session-info.hidden {
    display: none;
}
.agent-session-info-text {
    flex: 1;
    min-width: 0;
}
.agent-session-info-dismiss {
    flex-shrink: 0;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-panel);
    color: var(--text-secondary);
    cursor: pointer;
}
.agent-session-info-dismiss:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 24px 0;
    scroll-behavior: smooth;
}

/* ===== WELCOME SCREEN ===== */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
}
.welcome-icon { color: var(--accent); margin-bottom: 20px; opacity: 0.7; }
.welcome-screen h2 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: 600;
}
.welcome-screen > p {
    max-width: 480px;
    line-height: 1.6;
    margin-bottom: 32px;
    font-size: 15px;
}

.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 520px;
}

.quick-prompt {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}
.quick-prompt:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-bg);
}

/* ===== MESSAGES ===== */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    margin-top: 2px;
}
.message.user .message-avatar { background: var(--user-bubble); color: #fff; }
.message.assistant .message-avatar { background: linear-gradient(135deg, #6e40c9, #58a6ff); color: #fff; }

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

.message-role {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: capitalize;
}

.message-stream-status {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.45;
}
.message-stream-status.is-hidden {
    display: none;
}

.message-live-log {
    font-size: 11px;
    line-height: 1.45;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding: 8px 10px;
    max-height: 160px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border-radius: var(--radius-xs);
    border: 1px dashed var(--border-light);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.message-live-log.is-hidden {
    display: none;
}
.message-live-log__line {
    padding: 2px 0;
    word-break: break-word;
}

.message-timing {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary);
    padding-top: 8px;
    border-top: 1px dashed var(--border-light);
}
.message-timing.is-hidden {
    display: none;
}

.message-stream-status::before {
    content: '';
    width: 6px;
    height: 6px;
    min-width: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: streamStatusPulse 1.1s ease-in-out infinite;
}
.message-stream-status.is-idle::before {
    animation: none;
    opacity: 0.45;
}
@keyframes streamStatusPulse {
    0%, 100% { opacity: 0.35; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

.message-activity {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.message-activity:empty {
    display: none;
}
.message-activity:not(:empty)::before {
    content: 'Agent steps';
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.message.assistant .message-activity:not(:empty) + .message-body {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
}
.message.assistant .message-activity:not(:empty) + .message-body:not(:empty)::before {
    content: 'Response';
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.message-body {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-body {
    background: var(--bg-tertiary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}
.message.assistant .message-body { padding: 4px 0; }

.message-body h1, .message-body h2, .message-body h3,
.message-body h4, .message-body h5, .message-body h6 {
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 600;
    line-height: 1.3;
}
.message-body h1 { font-size: 1.5em; }
.message-body h2 { font-size: 1.3em; }
.message-body h3 { font-size: 1.15em; }

.message-body p { margin-bottom: 12px; }
.message-body ul, .message-body ol { margin-bottom: 12px; padding-left: 24px; }
.message-body li { margin-bottom: 4px; }
.message-body a { color: var(--accent); text-decoration: none; }
.message-body a:hover { text-decoration: underline; }

.message-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 4px 16px;
    margin: 12px 0;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.message-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.message-body table { border-collapse: collapse; margin: 12px 0; width: 100%; overflow-x: auto; display: block; }
.message-body th, .message-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; font-size: 14px; }
.message-body th { background: var(--bg-tertiary); font-weight: 600; }

.message-body code:not(pre code) {
    background: var(--bg-active);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.code-block-wrapper {
    position: relative;
    margin: 12px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}
.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-active);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.copy-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition);
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { color: var(--success); border-color: var(--success); }

.code-block-wrapper pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    background: var(--code-bg) !important;
}
.code-block-wrapper pre code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 13px;
    line-height: 1.5;
    background: none !important;
    padding: 0 !important;
}

.streaming-cursor::after {
    content: '\25CA';
    animation: blink 0.8s step-end infinite;
    color: var(--accent);
    font-weight: 400;
}
@keyframes blink { 50% { opacity: 0; } }

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

/* ===== PROGRESS TRACKER ===== */
.progress-tracker {
    width: min(900px, calc(100% - 24px));
    margin: 12px auto 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
    animation: fadeIn 0.3s ease;
}

.progress-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 18px;
    background: var(--accent-bg);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    border-left: none;
    border-right: none;
    border-top: none;
    color: inherit;
    text-align: left;
}
.progress-header.has-errors {
    background: var(--danger-bg);
}

.progress-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
.progress-spinner.done {
    border: none;
    animation: none;
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
}
.progress-header.has-errors .progress-spinner.done {
    color: var(--warning);
}

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

.progress-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.progress-count {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.progress-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: transform var(--transition), color var(--transition);
}

.progress-tracker.collapsed .progress-toggle {
    transform: rotate(0deg);
}

.progress-tracker:not(.collapsed) .progress-toggle {
    transform: rotate(180deg);
}

.progress-steps {
    padding: 8px 0;
}

.progress-tracker.collapsed .progress-steps {
    display: none;
}

.progress-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 18px;
    transition: background var(--transition);
}
.progress-step.active {
    background: rgba(56, 139, 253, 0.06);
}

.progress-step-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

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

.progress-step.completed .progress-step-icon { color: var(--success); }
.progress-step.failed .progress-step-icon { color: var(--danger); }

.progress-step-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.progress-step-label {
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-step-status {
    font-size: 11px;
    color: var(--text-muted);
}
.progress-step.active .progress-step-status {
    color: var(--accent);
}
.progress-step.completed .progress-step-status {
    color: var(--success);
}
.progress-step.failed .progress-step-status {
    color: var(--danger);
}

/* ===== TOOL BLOCKS ===== */
.tool-block {
    max-width: 900px;
    margin: 8px auto 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.tool-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    transition: background var(--transition);
    gap: 10px;
}
.tool-block-header:hover { background: var(--bg-hover); }

.tool-block-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.tool-icon {
    display: flex;
    align-items: center;
    color: var(--accent);
    flex-shrink: 0;
}

.tool-label {
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.tool-status.running { background: var(--warning-bg); color: var(--warning); }
.tool-status.success { background: var(--success-bg); color: var(--success); }
.tool-status.error { background: var(--danger-bg); color: var(--danger); }

.tool-block-details {
    border-top: 1px solid var(--border-light);
    padding: 12px 14px;
    max-height: 400px;
    overflow-y: auto;
}
.tool-block-details.hidden { display: none; }

.tool-block-details strong {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.tool-block-details pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    padding: 10px 12px;
    overflow-x: auto;
    margin-bottom: 10px;
}
.tool-block-details pre code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.tool-block-details .typing-indicator { padding: 4px 0; }

/* ===== INPUT AREA ===== */
/* ===== PROJECT CONTEXT BADGE ===== */
.project-context {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin-bottom: 8px;
    background: var(--accent-bg);
    border: 1px solid rgba(56, 139, 253, 0.25);
    border-radius: var(--radius-xs);
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
}
.project-context.hidden { display: none; }
.project-context svg:first-child { flex-shrink: 0; }
.project-context span { flex: 1; }

.project-context-clear {
    color: var(--accent);
    opacity: 0.6;
    padding: 2px;
    border-radius: 3px;
    transition: all var(--transition);
}
.project-context-clear:hover {
    opacity: 1;
    background: rgba(56, 139, 253, 0.2);
}

/* ===== CHAT MODE (dropdown in composer footer) ===== */
.mode-select {
    flex: 0 1 auto;
    min-width: 6.5rem;
    max-width: 10rem;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    line-height: 1.3;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.mode-select:hover:not(:disabled) {
    border-color: var(--text-muted);
}
.mode-select:focus {
    outline: none;
    border-color: var(--accent);
}
.mode-select[data-mode="agent"] {
    border-color: var(--accent);
    background: var(--accent-bg);
    color: var(--accent);
}
.mode-select[data-mode="plan"] {
    border-color: var(--warning);
    background: var(--warning-bg);
    color: var(--warning);
}
.mode-select[data-mode="debug"] {
    border-color: var(--danger);
    background: var(--danger-bg);
    color: var(--danger);
}
.mode-select[data-mode="ask"] {
    border-color: var(--success);
    background: var(--success-bg);
    color: var(--success);
}
.mode-select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.2);
}

.chat-lock-hint {
    font-size: 12px;
    color: var(--danger);
    margin-bottom: 6px;
    line-height: 1.4;
}
.chat-lock-hint.hidden { display: none; }

.composer-footer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
}
.composer-model-legend {
    margin: 0;
    font-size: 10px;
    line-height: 1.45;
    color: var(--text-muted);
    max-width: 100%;
}
.composer-model-legend strong {
    color: var(--text-secondary);
    font-weight: 600;
}
.composer-footer-disabled {
    opacity: 0.45;
    pointer-events: none;
}
.composer-model {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
    flex: 1;
}
.ai-provider-select {
    flex: 0 1 auto;
    min-width: 7.5rem;
    max-width: 10rem;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}
.ai-provider-select:focus {
    outline: none;
    border-color: var(--accent);
}
.superpowers-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.superpowers-toggle:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}
.superpowers-toggle input {
    width: auto;
    margin: 0;
    padding: 0;
    accent-color: var(--accent);
    cursor: pointer;
}
.superpowers-toggle:has(input:checked) {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    background: color-mix(in srgb, var(--accent) 12%, var(--bg-tertiary));
}
.superpowers-toggle:has(input:disabled) {
    opacity: 0.55;
    cursor: not-allowed;
}
.agent-model-select {
    flex: 1 1 auto;
    width: auto;
    min-width: calc(12rem * 0.7);
    max-width: min(100%, calc(28rem * 0.7));
    padding: 5px 8px;
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    line-height: 1.3;
}
.agent-model-select:focus {
    outline: none;
    border-color: var(--accent);
}
.agent-fix-ai-btn {
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 11px;
    color: var(--accent);
    cursor: pointer;
    white-space: nowrap;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.agent-fix-ai-btn:hover {
    color: var(--accent-hover, var(--accent));
}
.agent-fix-ai-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.input-wrapper textarea:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

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

.chat-input-area.chat-input-locked .file-btn {
    pointer-events: none;
    opacity: 0.45;
}

.chat-input-area {
    padding: 16px 24px 20px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: border-color var(--transition);
}
.input-wrapper--composer {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 10px 12px 8px;
}
.input-wrapper--composer .file-preview {
    width: 100%;
    padding: 0 0 8px;
}
.composer-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    min-width: 0;
}
.composer-row .file-btn {
    flex-shrink: 0;
}
.input-wrapper:focus-within { border-color: var(--accent); }

.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 200px;
    padding: 4px 0;
}
.input-wrapper textarea::placeholder { color: var(--text-muted); }
.input-wrapper--composer .composer-row textarea {
    flex: 1;
    min-width: 0;
}

.file-btn { color: var(--text-muted); margin-bottom: 2px; }

.file-preview { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 8px; }
.file-preview.hidden { display: none; }

.file-tag {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--accent-bg);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
}
.file-tag-remove {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}

.btn-send {
    background: var(--user-bubble);
    border: none;
    color: #fff;
    padding: 8px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    margin-bottom: 2px;
}
.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-send.working {
    background: var(--danger);
    animation: sendPulse 1.5s ease-in-out infinite;
}
.btn-send.working:hover { background: #da3633; }

.send-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes sendPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(248, 81, 73, 0); }
}

/* ===== LOADING INDICATOR ===== */
.typing-indicator { display: flex; gap: 4px; padding: 8px 0; }
.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ===== FILE EXPLORER (RIGHT SIDEBAR) ===== */
.file-explorer {
    width: 0;
    min-width: 0;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, min-width 0.25s ease;
    overflow: hidden;
}
.file-explorer.open {
    width: var(--fe-width);
    min-width: var(--fe-width);
}

.fe-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px 12px;
    border-bottom: 1px solid var(--border-light);
    min-width: var(--fe-width);
}
.fe-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fe-projects {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    min-width: var(--fe-width);
}

.fe-projects select {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}
.fe-projects select:focus { border-color: var(--accent); }
.fe-projects select option { background: var(--bg-secondary); }

.fe-open-project {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    transition: background var(--transition), color var(--transition);
}
.fe-open-project:hover:not(.fe-open-project--disabled) {
    background: var(--bg-hover);
    border-color: var(--accent);
}
.fe-open-project--disabled {
    pointer-events: none;
    opacity: 0.4;
    cursor: default;
    color: var(--text-muted);
}

.fe-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 14px 10px;
    border-bottom: 1px solid var(--border-light);
    min-width: var(--fe-width);
}
.btn-fe-new {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}
.btn-fe-new:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent);
}
.btn-fe-new:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.fe-code-search-wrap {
    padding: 0 14px 10px;
    border-bottom: 1px solid var(--border-light);
    min-width: var(--fe-width);
}
.fe-code-search {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    outline: none;
}
.fe-code-search::placeholder {
    color: var(--text-muted);
}
.fe-code-search:focus {
    border-color: var(--accent);
}

.fe-search-hits {
    padding: 6px 0;
}
.fe-search-meta {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 14px 10px;
    line-height: 1.4;
}
.fe-hit-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    margin: 0;
    padding: 8px 14px;
    text-align: left;
    cursor: pointer;
    border: none;
    border-bottom: 1px solid var(--border-light);
    background: transparent;
    font: inherit;
    color: inherit;
    transition: background var(--transition);
}
.fe-hit-item:hover {
    background: var(--bg-hover);
}
.fe-hit-path {
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--accent);
    word-break: break-all;
}
.fe-hit-count {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}
.fe-hit-preview {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.35;
    display: block;
    max-height: 2.7em;
    overflow: hidden;
}
.fe-search-hint {
    font-size: 12px;
    padding-top: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.fe-creation-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    font-size: 12px;
}
.fe-creation-log-search {
    width: 100%;
    box-sizing: border-box;
    margin: 8px 0 0;
    padding: 7px 10px;
    font-size: 13px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    outline: none;
}
.fe-creation-log-search::placeholder {
    color: var(--text-muted);
}
.fe-creation-log-search:focus {
    border-color: var(--accent);
}
.fe-creation-list--settings {
    max-height: 200px;
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
}
#creationLogRefreshBtn {
    margin-top: 10px;
    width: 100%;
}
.fe-creation-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}
.fe-creation-item:last-child { border-bottom: none; }
.fe-creation-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.fe-creation-time {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
}
.fe-creation-type {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--accent);
}
.fe-creation-name {
    margin-top: 3px;
    color: var(--text-primary);
    word-break: break-all;
    font-family: ui-monospace, monospace;
    font-size: 11px;
    line-height: 1.35;
}
.fe-creation-user {
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
}
.fe-creation-empty {
    padding: 8px 0;
    color: var(--text-muted);
    font-style: italic;
}

.text-danger-soft {
    color: var(--danger);
    font-weight: 600;
}

.fe-creation-item--delete .fe-creation-time,
.fe-creation-item--delete .fe-creation-name,
.fe-creation-item--delete .fe-creation-user {
    color: var(--danger);
}
.fe-creation-item--delete .fe-creation-type {
    color: var(--danger);
    font-weight: 800;
}

.fe-delete-btn {
    flex-shrink: 0;
    color: var(--text-muted);
    border-radius: var(--radius-xs);
    opacity: 0;
    transition: opacity 0.15s ease;
}
.fe-item:hover .fe-delete-btn { opacity: 1; }
.fe-delete-btn:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

.fe-delete-card {
    max-width: 420px;
    width: 92vw;
}
.fe-delete-path {
    font-family: ui-monospace, monospace;
    font-size: 12px;
    word-break: break-all;
    margin: 0 0 10px;
    line-height: 1.4;
    color: var(--text-primary);
}
.fe-delete-warning {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 12px;
    line-height: 1.45;
}
.fe-delete-confirm {
    background: var(--danger) !important;
    border: 1px solid var(--danger) !important;
    color: #fff !important;
}
.fe-delete-confirm:hover:not(:disabled) {
    filter: brightness(1.08);
}

.fe-create-card {
    max-width: 420px;
    width: 92vw;
}
.fe-create-rules {
    margin: 0 0 14px;
}
.fe-create-rule-red {
    color: var(--danger);
    font-size: 12px;
    line-height: 1.45;
    margin: 0 0 8px;
}
.fe-create-rule-red:last-child {
    margin-bottom: 0;
}
.fe-create-error-msg {
    color: var(--danger) !important;
    font-weight: 600;
}
.fe-create-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.fe-create-opt {
    font-weight: 400;
    color: var(--text-muted);
}
.fe-create-input,
.fe-create-textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    padding: 8px 10px;
    font-size: 13px;
    font-family: ui-monospace, monospace;
    margin-bottom: 12px;
}
.fe-create-textarea {
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
}
.fe-create-file-only.hidden {
    display: none;
}

.fe-tree {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
    min-width: var(--fe-width);
}

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

.fe-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
}
.fe-item:hover { background: var(--bg-hover); }
.fe-item svg { color: var(--text-muted); flex-shrink: 0; }

/* Folders: collapsed by default; chevron + folder icon + name all toggle together */
.fe-dir {
    user-select: none;
}
.fe-dir .fe-folder-svg {
    color: var(--accent);
    flex-shrink: 0;
}
.fe-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    flex-shrink: 0;
    color: var(--text-muted);
}
.fe-chevron-svg {
    display: block;
    transition: transform 0.15s ease;
}
.fe-dir.collapsed .fe-chevron-svg {
    transform: rotate(0deg);
}
.fe-dir:not(.collapsed) .fe-chevron-svg {
    transform: rotate(90deg);
}
.fe-dir-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fe-dir .fe-delete-btn {
    margin-left: auto;
}
.fe-dir.collapsed + .fe-children {
    display: none;
}
.fe-children {
    display: block;
}

.fe-size {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.fe-children { /* no default hidden */ }

/* File Viewer Panel */
.fe-file-viewer {
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    max-height: 50%;
    min-width: var(--fe-width);
}
.fe-file-viewer.hidden { display: none; }

.fe-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-light);
    gap: 8px;
}
.fe-viewer-header span {
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

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

.fe-viewer-content {
    flex: 1;
    overflow: auto;
    margin: 0;
    padding: 12px 14px;
    background: var(--bg-primary);
    font-size: 12px;
    line-height: 1.5;
}
.fe-viewer-content code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* Code Editor Modal */

.editor-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}
.editor-modal-title svg { flex-shrink: 0; color: var(--text-muted); }
.editor-modal-path {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-card-editor .modal-header {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.editor-modal-body {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.cm-editor-container {
    width: 100%;
    height: 100%;
}

.cm-editor-container .CodeMirror {
    height: 100%;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.cm-editor-container .CodeMirror-gutters {
    border-right: 1px solid var(--border);
}

.cm-editor-container .CodeMirror-activeline-background {
    opacity: 0.06;
}

.editor-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.editor-status {
    font-size: 12px;
    color: var(--text-muted);
}
.editor-status.saved { color: var(--success, #22c55e); }

.fe-editor-actions {
    display: flex;
    gap: 8px;
}

.btn-editor-save {
    padding: 6px 20px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    transition: opacity var(--transition);
}
.btn-editor-save:hover { opacity: 0.85; }
.btn-editor-save:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-editor-cancel {
    padding: 6px 20px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: background var(--transition);
}
.btn-editor-cancel:hover { background: var(--bg-hover); }

/* Expand/Edit button on file rows */
.fe-file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.fe-expand-btn {
    opacity: 0;
    flex-shrink: 0;
    margin-left: 4px;
    transition: opacity 0.15s ease;
}
.fe-item:hover .fe-expand-btn { opacity: 1; }
.fe-expand-btn svg { color: var(--accent); }

/* File Explorer Toggle Button */
.fe-open-btn {
    position: fixed;
    right: 16px;
    bottom: 80px;
    z-index: 50;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--accent);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all var(--transition);
}
.fe-open-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.fe-open-btn.fe-open-active {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
}
.fe-open-btn.hidden { display: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 99;
        transform: translateX(-100%);
        box-shadow: var(--shadow);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: flex; }

    .file-explorer {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 99;
        box-shadow: var(--shadow);
    }

    .chat-agent-bar { padding: 8px 12px 0; }
    .chat-messages { padding: 16px 12px 0; }
    .chat-input-area { padding: 12px; }
    .welcome-screen h2 { font-size: 22px; }
    .quick-prompts { flex-direction: column; }
}

/* ===== DELETE CONFIRMATION MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}
.modal-overlay.hidden { display: none !important; }

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px 20px;
    width: 100%;
    max-width: 360px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.modal-card.modal-card-editor {
    width: 96vw;
    max-width: none;
    height: 92vh;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.modal-close-x {
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition);
}
.modal-close-x:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal-card h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--text-primary);
}

.modal-card > h3 {
    margin-bottom: 6px;
}

.modal-card > p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.modal-card input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}
.modal-card input:focus { border-color: var(--accent); }

.modal-error {
    color: var(--danger);
    font-size: 12px;
    min-height: 18px;
    margin-top: 8px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.btn-modal-cancel {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 18px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-modal-cancel:hover { color: var(--text-primary); background: var(--bg-hover); }

.btn-modal-confirm {
    background: var(--danger);
    border: none;
    color: #fff;
    padding: 8px 18px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-modal-confirm:hover { background: #da3633; }
.btn-modal-confirm:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== UTILITY ===== */
.hidden { display: none !important; }
