/* AutoDevOS - Main Stylesheet */

:root {
    /* Surface layers */
    --surface-0: #0d1117;
    --surface-1: #161b22;
    --surface-2: #21262d;
    --surface-3: #30363d;
    --surface-4: #484f58;
    /* Backwards compat aliases */
    --bg-primary: var(--surface-0);
    --bg-secondary: var(--surface-1);
    --bg-tertiary: var(--surface-2);
    --border-color: var(--surface-3);

    /* Text */
    --text-primary: #e6edf3;
    --text-secondary: #9198a1;
    --text-tertiary: #6e7681;
    --text-disabled: #484f58;

    /* Semantic */
    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-yellow: #d29922;
    --accent-purple: #bc8cff;

    /* Spacing */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
    --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

    /* Typography */
    --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --text-xs: 0.75rem; --text-sm: 0.8125rem; --text-base: 0.875rem;
    --text-lg: 1rem; --text-xl: 1.25rem;

    /* Shorthand aliases */
    --border: var(--surface-3);
    --accent: var(--accent-blue);
    --error-text: var(--accent-red);

    /* Misc */
    --radius: 6px;
    --radius-sm: 4px;
    --radius-lg: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-overlay: 0 16px 48px rgba(0,0,0,0.6);
    --transition-fast: 100ms ease;
    --transition: 200ms ease;

    --sidebar-width: 48px;
    --topbar-height: 42px;
}

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

/* Skip-to-content link (accessibility) */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    z-index: 10000;
    padding: 8px 16px;
    background: var(--accent-blue);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 var(--radius) 0;
    transition: top var(--transition-fast);
}
.skip-to-content:focus {
    top: 0;
}

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

/* ===== App Layout ===== */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ===== Sidebar ===== */
.app-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--surface-1);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--sp-2) 0;
    z-index: 10;
}

.sidebar-logo {
    font-size: 1.3rem;
    margin-bottom: var(--sp-3);
    cursor: default;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    flex: 1;
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.sidebar-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
}

.sidebar-btn:hover { background: var(--surface-2); }
.sidebar-btn.active { background: var(--surface-2); }
.sidebar-btn.active::before {
    content: '';
    position: absolute;
    left: 0; top: 25%; bottom: 25%;
    width: 2px;
    background: var(--accent-blue);
    border-radius: 1px;
}

.sidebar-icon { font-size: 1.1rem; }

/* ===== App Content ===== */
.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* ===== Top Bar ===== */
.app-topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 var(--sp-4);
    gap: var(--sp-3);
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

#global-project-select {
    padding: 4px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    min-width: 170px;
}

.topbar-search-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: border-color var(--transition-fast);
}

.topbar-search-btn:hover { border-color: var(--text-secondary); }
.search-hint { font-size: var(--text-xs); color: var(--text-tertiary); }

/* Project Tab Bar */
.project-tab-bar {
    display: flex;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    flex-shrink: 0;
    min-height: 0;
}
.project-tab-bar:empty { display: none; }
.proj-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    border-right: 1px solid var(--surface-3);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.proj-tab:hover { background: var(--surface-2); color: var(--text-primary); }
.proj-tab.active {
    background: var(--surface-0);
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent-blue);
    font-weight: 600;
}
.proj-tab-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.proj-tab-close {
    font-size: 14px; line-height: 1;
    background: none; border: none; color: var(--text-tertiary);
    cursor: pointer; padding: 0 2px; border-radius: 2px;
}
.proj-tab-close:hover { background: var(--surface-3); color: var(--text-primary); }
.topbar-spacer { flex: 1; }

#user-info { color: var(--text-secondary); font-size: var(--text-sm); display: flex; align-items: center; gap: 6px; }
.avatar-sm { width: 20px; height: 20px; border-radius: 50%; vertical-align: middle; }
#logout-btn {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--text-xs);
}

/* ===== Panels ===== */
.app-panels {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
}

.panel { display: none; animation: fadeIn var(--transition); }
.panel.active { display: block; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel-header {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
    flex-wrap: wrap;
}

.panel-header h2 { font-size: var(--text-xl); }

/* ===== Buttons ===== */
.btn-primary {
    padding: 6px 14px;
    background: var(--accent-green);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 600;
    transition: opacity var(--transition-fast);
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary:focus-visible, .btn-secondary:focus-visible,
.btn-small:focus-visible, .btn-back:focus-visible,
.filter-btn:focus-visible, .action-btn:focus-visible,
.sidebar-btn:focus-visible, .drawer-ctrl-btn:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: -1px;
    border-color: var(--accent-blue);
}

.btn-secondary {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}
.btn-secondary:hover { border-color: var(--text-secondary); color: var(--text-primary); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-small {
    padding: 3px 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-xs);
}
.btn-small:hover { border-color: var(--text-secondary); color: var(--text-primary); }
.btn-small:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn-small.btn-primary { background: var(--accent-green); color: #fff; border: none; }
.btn-small.btn-primary:hover { opacity: 0.9; }

.btn-back {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
}

/* ===== Cards ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--sp-3);
}

.card {
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--sp-4);
    transition: border-color var(--transition-fast);
    cursor: pointer;
}
.card:hover { border-color: var(--accent-blue); box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
.card:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }

.card-title { font-size: var(--text-base); font-weight: 600; margin-bottom: var(--sp-1); }
.card-meta { color: var(--text-secondary); font-size: var(--text-xs); margin-bottom: var(--sp-1); }

/* Dashboard Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.dash-card {
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--sp-4);
}

.dash-card h4 {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--sp-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: var(--text-xs);
    font-weight: 600;
}

.badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-active { background: rgba(63, 185, 80, 0.15); color: var(--accent-green); }
.badge-running { background: rgba(88, 166, 255, 0.15); color: var(--accent-blue); }
.badge-running::before { animation: pulse-dot 1.5s ease-in-out infinite; }
.badge-completed { background: rgba(63, 185, 80, 0.15); color: var(--accent-green); }
.badge-failed { background: rgba(248, 81, 73, 0.15); color: var(--accent-red); }
.badge-queued { background: rgba(210, 153, 34, 0.15); color: var(--accent-yellow); }
.badge-paused { background: rgba(188, 140, 255, 0.15); color: var(--accent-purple); }
.badge-cancelled { background: rgba(139, 148, 158, 0.15); color: var(--text-secondary); }
.badge-skipped { background: rgba(139, 148, 158, 0.10); color: var(--text-secondary); }
.badge-pending { background: rgba(210, 153, 34, 0.10); color: var(--accent-yellow); }

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== Progress Bar ===== */
.progress-bar { width: 100%; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.3s ease; }
.progress-fill.pending { background: var(--text-secondary); }
.progress-fill.running { background: var(--accent-blue); }
.progress-fill.done { background: var(--accent-green); }
.progress-fill.failed { background: var(--accent-red); }

/* ===== Pipeline Steps ===== */
.pipeline-steps { display: flex; flex-direction: column; gap: 4px; }
.pipeline-step {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
}
.step-icon { width: 18px; text-align: center; }
.step-name { flex: 1; }
.step-status { color: var(--text-secondary); font-size: var(--text-xs); }

/* ===== Table ===== */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border-color); font-size: var(--text-sm); }
th { background: var(--surface-1); color: var(--text-secondary); font-weight: 600; }

/* ===== File Browser ===== */
.file-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--sp-3);
    min-height: 400px;
}

.file-tree {
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--sp-3);
    overflow-y: auto;
    max-height: 70vh;
    position: relative;
}

.file-content {
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: auto;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.file-toolbar {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
    font-size: var(--text-sm);
    font-weight: 600;
    flex-shrink: 0;
}

.file-toolbar-actions { margin-left: auto; display: flex; gap: 4px; }

#file-content-body {
    flex: 1;
    overflow: auto;
    padding: var(--sp-3);
}

.file-content pre {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

.file-content pre code { background: transparent !important; padding: 0 !important; }

.file-content textarea.file-editor {
    width: 100%; height: 100%;
    background: var(--surface-0);
    color: var(--text-primary);
    border: none;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.6;
    padding: var(--sp-3);
    resize: none;
}

.file-entry {
    display: flex; align-items: center; gap: 6px;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-xs);
}
.file-entry:hover { background: var(--surface-2); }
.file-entry:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: -1px; background: var(--surface-2); }
.file-entry .icon { width: 16px; text-align: center; }

/* File Preview Toolbar */
.fp-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}
.fp-file-path {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fp-toolbar-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.fp-tb-btn {
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}
.fp-tb-btn:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}
.fp-tb-btn.active {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

/* Markdown Preview */
.markdown-body {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 32px;
    line-height: 1.7;
    color: var(--text-primary);
    font-size: 14px;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    color: #4fc3f7;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.3;
}
.markdown-body h1 {
    font-size: 1.8em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}
.markdown-body h2 {
    font-size: 1.4em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}
.markdown-body h3 { font-size: 1.2em; }
.markdown-body p { margin: 0.8em 0; }
.markdown-body code {
    background: #2d2d2d;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.9em;
}
.markdown-body pre {
    background: #252526;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1em 0;
}
.markdown-body pre code {
    background: none;
    padding: 0;
}
.markdown-body blockquote {
    border-left: 3px solid #4fc3f7;
    margin: 1em 0;
    padding: 8px 16px;
    color: #aaa;
}
.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}
.markdown-body th, .markdown-body td {
    border: 1px solid #444;
    padding: 8px 12px;
    text-align: left;
}
.markdown-body th {
    background: #2d2d2d;
    font-weight: 600;
}
.markdown-body img {
    max-width: 100%;
    border-radius: 4px;
}
.markdown-body a {
    color: #89b4fa;
    text-decoration: none;
}
.markdown-body a:hover {
    text-decoration: underline;
}
.markdown-body ul, .markdown-body ol {
    padding-left: 24px;
    margin: 0.5em 0;
}
.markdown-body li {
    margin: 0.3em 0;
}
.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5em 0;
}

/* Image Preview */
.fp-image-preview {
    max-width: 100%;
    max-height: 80vh;
    display: block;
    margin: 20px auto;
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.fp-image-container {
    text-align: center;
    padding: 20px;
}
.fp-image-info {
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 8px;
}

/* PDF Preview */
.fp-pdf-preview {
    width: 100%;
    height: calc(100vh - 200px);
    min-height: 500px;
    border: none;
    border-radius: 4px;
}

.file-search {
    padding: 4px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius);
    font-size: var(--text-xs);
    width: 160px;
}

.search-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.search-wrapper .file-search { padding-right: 24px; }
.search-clear {
    position: absolute; right: 4px;
    background: none; border: none;
    color: var(--text-secondary);
    cursor: pointer; font-size: 11px;
    padding: 2px 4px; line-height: 1;
    border-radius: var(--radius-sm);
}
.search-clear:hover { color: var(--text-primary); background: var(--surface-3); }

/* ===== Upload UI ===== */
.upload-dropzone {
    position: absolute; inset: 0;
    background: rgba(88,166,255,0.08);
    border: 2px dashed var(--accent-blue);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    z-index: 10;
    pointer-events: none;
}
.dropzone-content { text-align: center; color: var(--accent-blue); font-size: var(--text-sm); }
.dropzone-icon { font-size: 2rem; display: block; margin-bottom: 4px; }

.upload-drop-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    transition: all var(--transition-fast);
    cursor: pointer;
}
.upload-drop-area:hover, .upload-drop-area.drag-over {
    border-color: var(--accent-blue);
    background: rgba(88,166,255,0.06);
}
.upload-drop-area p { color: var(--text-secondary); margin: 8px 0 12px; font-size: var(--text-sm); }

.upload-subpath-row { margin-top: var(--sp-3); }
.upload-subpath-input {
    width: 100%;
    padding: 4px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    margin-top: 4px;
}

.upload-file-list { margin-top: var(--sp-3); max-height: 200px; overflow-y: auto; }
.upload-file-item {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
}
.upload-file-item:hover { background: var(--surface-2); }
.upload-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-file-size { color: var(--text-secondary); white-space: nowrap; }

.upload-progress { margin-top: var(--sp-3); }
.upload-progress .progress-bar { height: 6px; }
.upload-progress span { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 4px; display: inline-block; }

.progress-fill--success { background: var(--accent-green) !important; }
.progress-fill--failed { background: var(--accent-red) !important; }

.upload-results { margin-top: var(--sp-3); }
.upload-result-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
}
.upload-result--uploaded { color: var(--accent-green); }
.upload-result--rejected, .upload-result--error { color: var(--accent-red); }
.upload-dialog-body { min-width: 400px; }

/* ===== Git Panel ===== */
.git-layout-v2 { display: flex; gap: 0; height: calc(100% - 52px); overflow: hidden; position: relative; }
.git-sidebar {
    width: 300px; min-width: 240px;
    display: flex; flex-direction: column;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}
.git-main { flex: 1; overflow-y: auto; padding: 0 var(--sp-3); }
.git-section-title { font-size: var(--text-sm); font-weight: 600; padding: var(--sp-2) var(--sp-3); color: var(--text-secondary); }
.git-branch-list { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 var(--sp-3) var(--sp-2); }
.git-branch-btn { border: none; cursor: pointer; font: inherit; }
.git-branch-btn:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
.git-actions { display: flex; gap: 4px; }

.git-diff-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: var(--sp-2);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border-color);
    font-size: var(--text-sm);
    font-weight: 600;
    position: sticky; top: 0;
    background: var(--surface-1);
    z-index: 1;
}

.git-diff-viewer {
    position: absolute;
    inset: 0;
    background: var(--surface-1);
    border: none;
    padding: var(--sp-3);
    overflow: auto;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.6;
    z-index: 5;
}

.diff-add { color: var(--accent-green); background: rgba(63,185,80,0.1); }
.diff-del { color: var(--accent-red); background: rgba(248,81,73,0.1); }
.diff-header { color: var(--accent-purple); font-weight: 600; }

/* Commit detail (file list + file diff) */
.commit-detail-header {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    padding: 10px 12px; background: var(--surface-2); border-radius: 6px;
    margin-bottom: 12px; font-size: 13px;
}
.commit-detail-header .commit-subject {
    width: 100%; margin-top: 6px; font-weight: 600;
}
.commit-file-list h4 {
    font-size: 12px; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.commit-file-entry {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 8px; border-radius: 4px; cursor: pointer;
    font-size: 12px; font-family: var(--font-mono);
}
.commit-file-entry:hover { background: var(--surface-2); }
.commit-file-diff-header {
    font-size: 12px; font-weight: 600; color: var(--accent-blue);
    padding: 8px 0 4px; border-top: 1px solid var(--surface-3); margin-top: 12px;
}

.commit-entry {
    display: flex; gap: var(--sp-3);
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.commit-entry:hover { background: var(--surface-2); }

.commit-hash { color: var(--accent-blue); font-family: var(--font-mono); min-width: 70px; }
.commit-msg { flex: 1; }
.commit-author { color: var(--text-secondary); min-width: 100px; }
.commit-date { color: var(--text-tertiary); min-width: 80px; font-size: var(--text-xs); }

/* Working Changes / Staging Area */
.git-wc-section { border-top: 1px solid var(--border-color); }
.git-wc-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--sp-2) var(--sp-3);
}
.git-wc-header h4 { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); }
.git-staged { background: rgba(63,185,80,0.03); }
.btn-tiny {
    font-size: 11px; padding: 2px 8px;
    border-radius: 3px; border: 1px solid var(--border-color);
    background: var(--surface-2); color: var(--text-secondary);
    cursor: pointer;
}
.btn-tiny:hover { border-color: var(--accent-blue); color: var(--text-primary); }
.git-file-list {
    max-height: 180px; overflow-y: auto;
    padding: 0 var(--sp-2) var(--sp-2);
}
.git-file-entry {
    display: flex; align-items: center; gap: 6px;
    padding: 3px 6px;
    font-size: var(--text-xs);
    border-radius: 3px;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.git-file-entry:hover { background: var(--surface-2); }
.git-file-entry.staged { background: rgba(63,185,80,0.06); }
.git-file-status {
    font-family: var(--font-mono); font-weight: 700;
    width: 16px; text-align: center; flex-shrink: 0;
}
.git-status-M { color: var(--accent-yellow); }
.git-status-A { color: var(--accent-green); }
.git-status-D { color: var(--accent-red); }
.git-status-R { color: var(--accent-purple); }
.git-status-\? { color: var(--text-tertiary); }
.git-file-path { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.git-stage-btn, .git-unstage-btn {
    opacity: 0; font-weight: 700; font-size: 14px;
    width: 20px; height: 20px; padding: 0;
    display: flex; align-items: center; justify-content: center;
}
.git-file-entry:hover .git-stage-btn,
.git-file-entry:hover .git-unstage-btn { opacity: 1; }
.git-stage-btn { color: var(--accent-green); }
.git-unstage-btn { color: var(--accent-red); }

/* Commit Box */
.git-commit-box {
    display: flex; gap: 6px; padding: var(--sp-2) var(--sp-3);
    border-top: 1px solid var(--border-color);
}
.git-commit-box textarea {
    flex: 1; resize: none;
    background: var(--surface-0); border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 6px 8px;
    color: var(--text-primary); font-size: var(--text-xs);
    font-family: inherit;
}
.git-commit-box textarea:focus { border-color: var(--accent-blue); outline: none; }
.git-commit-box .btn-primary { white-space: nowrap; align-self: flex-end; }

/* Git Graph + Commit List */
.git-commit-list { display: flex; flex-direction: column; }
.git-commit-row {
    display: flex; gap: 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.git-commit-row:hover { background: var(--surface-2); }
.git-graph-col {
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 40px;
    padding-left: 8px;
    white-space: nowrap;
    user-select: none;
}
.g-node { font-size: 10px; }
.g-pipe { opacity: 0.6; }
.g-space { opacity: 0; }
.git-commit-info {
    flex: 1; padding: 6px 8px;
    min-width: 0;
    display: flex; flex-direction: column; justify-content: center;
}
.git-commit-top {
    display: flex; align-items: center; gap: 6px;
    font-size: var(--text-sm);
}
.git-commit-top .commit-msg { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.git-commit-meta {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    display: flex; gap: var(--sp-3);
}
.git-ref {
    font-size: 10px; padding: 1px 5px;
    border-radius: 3px; font-weight: 600;
    white-space: nowrap; flex-shrink: 0;
}
.git-ref-branch { background: rgba(88,166,255,0.15); color: var(--accent-blue); }
.git-ref-remote { background: rgba(63,185,80,0.15); color: var(--accent-green); }
.git-ref-head { background: rgba(210,153,34,0.15); color: var(--accent-yellow); }

/* ===== Filter Buttons ===== */
.filter-group { display: flex; gap: 4px; }
.filter-btn {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--text-xs);
    transition: all var(--transition-fast);
}
.filter-btn.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }

/* ===== Detail Section ===== */
.detail-section { margin-bottom: var(--sp-5); }
.detail-section h3 {
    font-size: var(--text-base);
    margin-bottom: var(--sp-3);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border-color);
}

/* ===== Dialog ===== */
dialog {
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    padding: var(--sp-5);
    max-width: 500px; width: 90%;
    box-shadow: var(--shadow-overlay);
}
dialog::backdrop { background: rgba(0,0,0,0.7); }
dialog h3 { margin-bottom: var(--sp-4); }
.dialog-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: var(--sp-3);
}
.dialog-header h3 { margin-bottom: 0; }
.dialog-close {
    background: none; border: none; color: var(--text-secondary);
    font-size: 1.3rem; cursor: pointer; padding: 0 4px;
    line-height: 1; border-radius: var(--radius-sm);
}
.dialog-close:hover { color: var(--text-primary); background: var(--surface-2); }
dialog label { display: block; margin-bottom: var(--sp-3); font-size: var(--text-sm); color: var(--text-secondary); }
dialog input, dialog textarea {
    display: block; width: 100%; margin-top: 4px;
    padding: 6px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: var(--text-sm);
    transition: border-color var(--transition-fast);
}
dialog input:invalid:not(:placeholder-shown) {
    border-color: var(--accent-red);
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: var(--sp-4); }
.dialog-actions button { padding: 6px 14px; border-radius: var(--radius); cursor: pointer; font-size: var(--text-sm); }

/* Agent Dialog */
.agent-dialog { max-width: 700px; }
.agent-dialog-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-3); }
.agent-dialog-header button { background: none; border: none; color: var(--text-secondary); font-size: 1.3rem; cursor: pointer; }

/* ===== Select ===== */
select {
    padding: 4px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius);
    font-size: var(--text-sm);
}

/* ===== Loading & Placeholder ===== */
.loading { color: var(--text-secondary); padding: var(--sp-5); text-align: center; }
.placeholder { color: var(--text-secondary); padding: var(--sp-5); text-align: center; }

/* Spinner animation */
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid var(--surface-3); border-top-color: var(--accent-blue);
    border-radius: 50%; animation: spin 0.6s linear infinite;
    vertical-align: middle; margin-right: 6px;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, #2a3040 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-card { height: 100px; width: 100%; border-radius: var(--radius); margin-bottom: var(--sp-2); }
.skeleton-line { height: 14px; width: 80%; margin-bottom: var(--sp-2); border-radius: var(--radius-sm); }
.skeleton-line.short { width: 50%; }

/* ===== Toast Notifications ===== */
#toast-container {
    position: fixed; top: var(--sp-4); right: var(--sp-4);
    z-index: 10000;
    display: flex; flex-direction: column; gap: var(--sp-2);
    max-width: 400px;
}

.toast {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius);
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    font-size: var(--text-sm);
    transform: translateX(120%);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}
.toast--visible { transform: translateX(0); opacity: 1; }
.toast-icon { flex-shrink: 0; }
.toast-message { flex: 1; }
.toast-close { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 1.1rem; padding: 0 4px; }
.toast-action { background: none; border: 1px solid var(--border-color); color: var(--accent-blue); border-radius: var(--radius-sm); padding: 2px 8px; cursor: pointer; font-size: var(--text-xs); }
.toast--success { border-left: 3px solid var(--accent-green); }
.toast--error { border-left: 3px solid var(--accent-red); }
.toast--warning { border-left: 3px solid var(--accent-yellow); }
.toast--info { border-left: 3px solid var(--accent-blue); }

/* ===== Confirm Dialog ===== */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; justify-content: center; align-items: center; z-index: 10001; }
.confirm-dialog { background: var(--surface-1); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: var(--sp-5); max-width: 420px; width: 90%; box-shadow: var(--shadow-overlay); }
.confirm-title { margin-bottom: var(--sp-2); }
.confirm-message { color: var(--text-secondary); margin-bottom: var(--sp-4); font-size: var(--text-sm); line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-actions button { padding: 6px 14px; border-radius: var(--radius); cursor: pointer; font-size: var(--text-sm); }
.confirm-cancel { background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); }
.confirm-ok { background: var(--accent-green); border: none; color: #fff; font-weight: 600; }
.confirm-danger { background: var(--accent-red) !important; }

/* ===== Command Palette ===== */
.cmd-palette-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex; justify-content: center;
    padding-top: 15vh;
    z-index: 9999;
}

.cmd-palette {
    width: 550px; max-height: 400px;
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-overlay);
    display: flex; flex-direction: column;
    overflow: hidden;
}

.cmd-input {
    padding: var(--sp-3) var(--sp-4);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: var(--text-base);
    outline: none;
}

.cmd-results {
    overflow-y: auto;
    padding: var(--sp-2) 0;
}

.cmd-header {
    padding: var(--sp-2) var(--sp-4);
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cmd-item {
    display: flex; align-items: center;
    padding: var(--sp-2) var(--sp-4);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.cmd-item:hover, .cmd-item--selected { background: var(--surface-2); }

.cmd-item-label { flex: 1; font-size: var(--text-sm); }
.cmd-item-meta { color: var(--text-tertiary); font-size: var(--text-xs); margin-right: var(--sp-2); }
.cmd-item-shortcut {
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

/* ===== Context Menu ===== */
.context-menu {
    position: fixed;
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 200px;
    padding: var(--sp-1) 0;
    z-index: 10002;
}

.ctx-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px var(--sp-4);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: background var(--transition-fast);
}
.ctx-item:hover, .ctx-item:focus { background: var(--surface-2); outline: none; }
.ctx-danger { color: var(--accent-red); }
.ctx-separator { height: 1px; background: var(--border-color); margin: var(--sp-1) 0; }
.ctx-shortcut { color: var(--text-tertiary); font-size: var(--text-xs); }

/* ===== Terminal Drawer ===== */
.terminal-drawer {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border-color);
    background: var(--surface-1);
    flex-shrink: 0;
    min-height: 36px;
}

.drawer-handle {
    height: 6px;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.drawer-handle-bar {
    width: 40px; height: 3px;
    background: var(--surface-3);
    border-radius: 2px;
    transition: background var(--transition-fast);
}
.drawer-handle:hover .drawer-handle-bar { background: var(--text-secondary); }
.terminal-minimized .drawer-header::after {
    content: '▲ Terminal minimized';
    margin-left: auto;
    font-size: 11px;
    color: var(--text-secondary);
    padding-right: 8px;
}

.drawer-header {
    display: flex;
    align-items: center;
    padding: 0 var(--sp-2);
    height: 30px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.drawer-tabs {
    display: flex;
    gap: 1px;
    flex: 1;
    overflow-x: auto;
}

.drawer-tab {
    display: flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    font-size: var(--text-xs);
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.drawer-tab:hover { background: var(--surface-2); }
.drawer-tab.active { background: var(--surface-2); color: var(--text-primary); }

.tab-close {
    background: none; border: none;
    color: var(--text-tertiary);
    cursor: pointer; font-size: 0.9rem;
    padding: 0 2px;
    visibility: hidden;
}
.drawer-tab:hover .tab-close { visibility: visible; }

.drawer-controls { display: flex; gap: 2px; }
.drawer-ctrl-btn {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
}
.drawer-ctrl-btn:hover { background: var(--surface-2); }

.drawer-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    min-height: 26px;
}
.actions-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-right: 2px;
}
.actions-sep {
    color: var(--border);
    margin: 0 4px;
}
.action-btn {
    font-size: 11px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface-0);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}
.action-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.drawer-content {
    flex: 1;
    min-height: 0;
    position: relative;
    background: #1e1e1e;
}

.term-tab-content {
    position: absolute;
    inset: 0;
    display: none;
}

.term-tab-content .xterm { padding: 4px; height: 100%; }

/* ===== Pipeline Split View ===== */
.pipeline-split-view {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-height) - 40px);
}

.pipeline-topbar {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-1);
    flex-shrink: 0;
    border-radius: var(--radius) var(--radius) 0 0;
}

.pipeline-topbar .btn-back { font-size: var(--text-xs); }
.pipeline-topbar .job-status { margin-left: auto; }

.split-view {
    display: flex; flex: 1; min-height: 0;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--surface-1);
    overflow: hidden;
}

.split-view-sidebar {
    width: 240px; min-width: 240px;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: var(--sp-3) 0;
    background: var(--surface-1);
    flex-shrink: 0;
}

.split-view-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.pp-vert { list-style: none; padding: 0; margin: 0; }

.pp-vert-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: var(--text-xs);
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
}
.pp-vert-item:hover { background: var(--surface-2); }
.pp-vert-item--active { border-left-color: var(--accent-blue); background: rgba(88,166,255,0.08); }
.pp-vert-item--done .pp-vert-icon { color: var(--accent-green); }
.pp-vert-item--active .pp-vert-icon { color: var(--accent-blue); animation: pulse-dot 1.5s ease-in-out infinite; }
.pp-vert-item--error .pp-vert-icon { color: var(--accent-red); }
.pp-vert-item--pending .pp-vert-icon { color: var(--text-secondary); opacity: 0.5; }

.pp-vert-icon { width: 16px; text-align: center; font-size: var(--text-sm); flex-shrink: 0; }
.pp-vert-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-vert-badge { font-size: 0.65rem; padding: 1px 6px; border-radius: 8px; flex-shrink: 0; }

.split-view-main .pipeline-term-tabs {
    display: flex;
    align-items: center;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    min-height: 32px;
}
.split-view-main .pipeline-tab-bar {
    display: flex;
    flex: 1;
    overflow-x: auto;
    gap: 0;
}
.split-view-main .pipeline-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    font-size: var(--text-xs);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: all var(--transition-fast);
}
.split-view-main .pipeline-tab:hover { background: var(--surface-2); color: var(--text-primary); }
.split-view-main .pipeline-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-blue);
    background: var(--surface-2);
}
.split-view-main .pipeline-tab .tab-close {
    background: none; border: none; color: var(--text-secondary); cursor: pointer;
    font-size: 14px; padding: 0 2px; line-height: 1; border-radius: 3px;
}
.split-view-main .pipeline-tab .tab-close:hover { background: var(--surface-3); color: var(--text-primary); }
.split-view-main .pipeline-tab-actions {
    display: flex;
    gap: 2px;
    padding: 0 8px;
    flex-shrink: 0;
}
.split-view-main .pipeline-tab-actions .action-btn {
    font-size: 12px;
    padding: 2px 6px;
    min-width: auto;
}
.split-view-main .pipeline-term-content {
    flex: 1;
    min-height: 0;
    background: #1e1e1e;
    position: relative;
    overflow: hidden;
}
.split-view-main .pipeline-term-content .term-tab-content {
    position: absolute;
    inset: 0;
}
.split-view-main .pipeline-term-content .xterm { padding: 8px; height: 100%; }

.system-messages {
    padding: 4px var(--sp-3);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.system-messages.reconnected { color: var(--accent-yellow); background: rgba(210,153,34,0.1); }

.pipeline-job-list { display: flex; flex-direction: column; gap: 8px; }

.pipeline-job-card {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-3);
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}
.pipeline-job-card:hover { border-color: var(--accent-blue); }
.pipeline-job-card .job-info { flex: 1; }
.pipeline-job-card .job-info h4 { margin-bottom: 2px; font-size: var(--text-sm); }

/* ===== Login Page ===== */
.login-page { display: flex; justify-content: center; align-items: center; height: 100vh; }
.login-container {
    text-align: center;
    background: var(--surface-1);
    padding: 3rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    max-width: 400px; width: 90%;
}
.login-container h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.subtitle { color: var(--text-secondary); margin-bottom: 2rem; }
.login-form label { display: block; text-align: left; margin-bottom: 0.5rem; color: var(--text-secondary); font-size: var(--text-sm); }
.login-form input {
    width: 100%; padding: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: var(--text-sm);
}
.login-form button {
    width: 100%; padding: 10px;
    background: var(--accent-green);
    color: #fff; border: none;
    border-radius: var(--radius);
    font-size: var(--text-base);
    cursor: pointer; font-weight: 600;
}
.login-form button:hover { opacity: 0.9; }
.login-form button:disabled { opacity: 0.5; cursor: not-allowed; }
.error-text { color: var(--accent-red); font-size: var(--text-sm); margin-top: 0.5rem; }

/* ===== Responsive ===== */

/* Tablet landscape */
@media (max-width: 1024px) {
    .orch-split { grid-template-columns: 280px 1fr; }
    .help-toc ol { columns: 1; }
    .help-concept-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* Tablet portrait & small tablets */
@media (max-width: 767px) {
    .app-layout { flex-direction: column; }
    .app-sidebar {
        width: 100%;
        flex-direction: row;
        height: auto;
        padding: var(--sp-1) var(--sp-2);
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        position: fixed; bottom: 0; left: 0; right: 0;
        z-index: 100;
    }
    .sidebar-logo { display: none; }
    .sidebar-nav { flex-direction: row; gap: var(--sp-1); }
    .sidebar-bottom { flex-direction: row; }
    .sidebar-btn.active::before { display: none; }

    .app-content { padding-bottom: 50px; }
    .split-view { flex-direction: column; }
    .split-view-sidebar {
        width: 100% !important; min-width: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 180px;
    }
    .file-container { grid-template-columns: 1fr; }
    .dashboard-cards { grid-template-columns: 1fr; }

    .cmd-palette { width: 95%; }
    .orch-split { grid-template-columns: 1fr; }
    .orch-left { border-right: none; border-bottom: 1px solid var(--surface-3); max-height: 40vh; }
    .panel-header { flex-wrap: wrap; gap: var(--sp-2); }
    .file-toolbar-actions { flex-wrap: wrap; }
}

/* Small phones */
@media (max-width: 480px) {
    .sidebar-btn span:last-child { display: none; }
    .panel-header h2 { font-size: 1rem; }
    .help-manual { padding: var(--sp-3); }
    .help-hero h1 { font-size: 1.4rem; }
    .confirm-dialog { width: 92vw; min-width: 0; }
    .project-card { padding: var(--sp-2); }
    .btn-small { padding: 3px 8px; font-size: 0.7rem; }
}

/* ===== Button Variants ===== */
.btn-danger {
    background: var(--accent-red);
    color: #fff;
    border: 1px solid var(--accent-red);
}
.btn-danger:hover { opacity: 0.85; }

/* ===== Help Panel / User Manual ===== */
.help-panel-content {
    overflow-y: auto;
    height: 100%;
    padding: 0;
}
.help-manual {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--sp-4) var(--sp-5);
}
.help-hero {
    text-align: center;
    padding: var(--sp-5) 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--sp-5);
}
.help-hero h1 { font-size: 2rem; margin-bottom: var(--sp-2); }
.help-subtitle { color: var(--text-secondary); font-size: var(--text-sm); max-width: 600px; margin: 0 auto; }

.help-toc {
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-4);
    margin-bottom: var(--sp-5);
}
.help-toc h3 { margin-bottom: var(--sp-2); }
.help-toc ol { padding-left: 20px; columns: 2; column-gap: 2rem; }
.help-toc li { margin-bottom: 4px; font-size: var(--text-sm); break-inside: avoid; }
.help-toc a { color: var(--accent-blue); text-decoration: none; }
.help-toc a:hover { text-decoration: underline; }

.help-section {
    margin-bottom: var(--sp-5);
    padding-bottom: var(--sp-5);
    border-bottom: 1px solid var(--border-color);
}
.help-section:last-child { border-bottom: none; }
.help-section h2 {
    font-size: 1.4rem;
    margin-bottom: var(--sp-3);
    color: var(--accent-blue);
}
.help-section h3 {
    font-size: 1.1rem;
    margin-top: var(--sp-4);
    margin-bottom: var(--sp-2);
}
.help-section p { font-size: var(--text-sm); line-height: 1.6; margin-bottom: var(--sp-2); color: var(--text-secondary); }
.help-section ul, .help-section ol {
    font-size: var(--text-sm);
    line-height: 1.6;
    padding-left: 20px;
    margin-bottom: var(--sp-3);
    color: var(--text-secondary);
}
.help-section li { margin-bottom: 4px; }

.help-screenshot {
    width: 100%;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin: var(--sp-3) 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.help-concept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--sp-3);
    margin-top: var(--sp-3);
}
.help-concept-card {
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-4);
    transition: border-color var(--transition-fast);
}
.help-concept-card:hover { border-color: var(--accent-blue); }
.help-concept-card .concept-icon { font-size: 2rem; margin-bottom: var(--sp-2); }
.help-concept-card h4 { margin-bottom: var(--sp-1); }
.help-concept-card p { font-size: var(--text-xs); margin-bottom: 0; }

.help-steps {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin: var(--sp-3) 0;
}
.help-step {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    background: var(--surface-1);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}
.step-num {
    background: var(--accent-blue);
    color: #fff;
    width: 24px; height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.help-note {
    background: rgba(88,166,255,0.08);
    border-left: 3px solid var(--accent-blue);
    padding: var(--sp-3);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: var(--sp-3) 0;
}

.help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    margin: var(--sp-3) 0;
}
.help-table th, .help-table td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}
.help-table th {
    background: var(--surface-1);
    color: var(--text-primary);
    font-weight: 600;
}
.help-table td { color: var(--text-secondary); }
.help-table tr:hover td { background: var(--surface-1); }
.help-highlight td { background: rgba(88,166,255,0.08) !important; }
.help-table code { background: var(--surface-2); padding: 1px 5px; border-radius: 3px; font-size: 0.85em; }
.help-table kbd {
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 0.85em;
    font-family: monospace;
}

.help-code {
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--sp-3);
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    overflow-x: auto;
    margin: var(--sp-3) 0;
}

.help-workflow-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: var(--text-sm);
    margin: var(--sp-3) 0;
    padding: var(--sp-3);
    background: var(--surface-1);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
}
.wf-phase {
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 4px 10px;
    font-size: var(--text-xs);
    font-weight: 600;
}
.wf-sub { font-size: 10px; opacity: 0.8; }
.wf-gate { border-color: var(--accent-blue); color: var(--accent-blue); }

/* ═══ Orchestrator Pipeline Visualization ═══ */
.orchestrator-panel-content {
    padding: 0;
    overflow: hidden;
    height: calc(100vh - 80px);
}
.orch-split {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: 100%;
    gap: 0;
}
.orch-left {
    overflow-y: auto;
    padding: 20px 16px;
    border-right: 1px solid var(--surface-3);
}
.orch-right {
    overflow-y: auto;
    padding: 20px;
    background: var(--surface-0);
}
.orch-pipeline {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}
.orch-node {
    width: 100%;
    border: 1px solid var(--surface-3);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--surface-1);
    border-left: 3px solid var(--phase-color, var(--accent-blue));
    transition: transform 0.15s, box-shadow 0.15s;
}
.orch-node:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.orch-gate {
    border-color: var(--accent-yellow);
    background: var(--surface-2);
}
.orch-node-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.orch-phase-id {
    font-size: 10px;
    font-weight: 700;
    color: var(--phase-color, var(--accent-blue));
    background: rgba(255,255,255,0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
}
.orch-phase-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.orch-phase-zh {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 6px;
    font-weight: 400;
}
.orch-agents {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}
.orch-agent-btn {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--surface-3);
    cursor: pointer;
    font-family: monospace;
    transition: background 0.15s, border-color 0.15s;
}
.orch-agent-primary {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-blue);
    border-color: rgba(99, 102, 241, 0.3);
}
.orch-agent-primary:hover, .orch-agent-active.orch-agent-primary {
    background: rgba(99, 102, 241, 0.35);
    border-color: var(--accent-blue);
}
.orch-agent-backup {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-secondary);
    border-color: var(--surface-3);
    font-style: italic;
}
.orch-agent-backup:hover, .orch-agent-active.orch-agent-backup {
    background: rgba(107, 114, 128, 0.25);
    color: var(--text-primary);
}
.orch-gate-badge {
    font-size: 9px;
    color: var(--accent-yellow);
    background: rgba(245, 158, 11, 0.08);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    word-break: break-all;
}
.orch-connector {
    display: flex;
    justify-content: center;
    padding: 2px 0;
    color: var(--surface-4);
    font-size: 12px;
}
.orch-connector-gate { color: var(--accent-yellow); }
.orch-arrow { opacity: 0.7; }
.orch-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--surface-3);
}
.orch-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-secondary);
}
.orch-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}
.orch-legend-primary { background: rgba(99, 102, 241, 0.4); border: 1px solid var(--accent-blue); }
.orch-legend-backup { background: rgba(107, 114, 128, 0.2); border: 1px solid var(--surface-4); }
.orch-legend-gate { background: rgba(245, 158, 11, 0.2); border: 1px solid var(--accent-yellow); }

/* Orchestrator right pane (agent detail inline) */
.orch-detail-placeholder {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    border: 2px dashed var(--surface-3);
    border-radius: var(--radius-lg);
    margin: 20px;
    background: var(--surface-1);
}
.orch-detail-placeholder p { margin: 8px 0; }
.orch-detail-hint { font-size: 12px; opacity: 0.7; }
.orch-detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--surface-3);
}
.orch-detail-header h3 { margin: 0; font-size: 16px; }
.orch-detail-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 12px;
}
.orch-detail-content pre {
    background: var(--surface-1);
    border: 1px solid var(--surface-3);
    border-radius: 6px;
    padding: 12px;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: calc(100vh - 240px);
    overflow-y: auto;
}

/* Tool chips */
.orch-tools { margin-top: 12px; }
.orch-tools-title { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.orch-tool-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; margin: 3px 4px; border-radius: 12px;
    background: var(--surface-2); border: 1px solid var(--border-color);
    color: var(--text-primary); font-size: 0.8rem; cursor: pointer;
    transition: all 0.15s;
}
.orch-tool-chip:hover { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }
.orch-tool-cat { font-size: 0.7rem; opacity: 0.6; padding: 1px 5px; background: var(--surface-3); border-radius: 8px; }

/* Tool detail */
.orch-tool-detail { padding: 16px; }
.orch-tool-detail h3 { margin: 0 0 4px; }
.orch-tool-detail .orch-tool-desc { color: var(--text-secondary); margin-bottom: 16px; }
.orch-tool-params { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-bottom: 12px; }
.orch-tool-params th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border-color); color: var(--text-secondary); font-weight: 500; }
.orch-tool-params td { padding: 6px 8px; border-bottom: 1px solid var(--surface-2); }
.orch-tool-usage { background: var(--surface-1); padding: 10px 14px; border-radius: var(--radius); font-family: monospace; font-size: 0.8rem; overflow-x: auto; }

/* Editor */
.orch-editor { width: 100%; min-height: 400px; background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 12px; font-family: 'Cascadia Code', 'Fira Code', monospace; font-size: 0.85rem; resize: vertical; line-height: 1.5; tab-size: 2; }
.orch-edit-actions { display: flex; gap: 8px; margin-top: 8px; }
.orch-edit-btn { padding: 6px 16px; border-radius: var(--radius); border: 1px solid var(--border-color); background: var(--surface-2); color: var(--text-primary); cursor: pointer; font-size: 0.85rem; }
.orch-edit-btn:hover { background: var(--surface-3); }
.orch-edit-btn--save { background: var(--accent-green); color: #fff; border-color: var(--accent-green); }
.orch-edit-btn--save:hover { opacity: 0.9; }

/* Back button */
.orch-back-btn { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; margin-bottom: 12px; background: var(--surface-2); border: 1px solid var(--border-color); border-radius: var(--radius); color: var(--text-secondary); cursor: pointer; font-size: 0.8rem; }
.orch-back-btn:hover { background: var(--surface-3); color: var(--text-primary); }

/* Tool count badge on agent buttons */
.orch-agent-tool-count { font-size: 0.65rem; opacity: 0.5; margin-left: 2px; }

/* Phase status states */
.orch-node[data-status="done"] {
    opacity: 0.75;
    border-left-color: var(--accent-green, #22c55e) !important;
}
.orch-node[data-status="current"],
.orch-node[data-status="in_progress"] {
    border-left-width: 4px;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
    animation: orch-pulse 2s ease-in-out infinite;
}
.orch-node[data-status="queued"] {
    opacity: 0.45;
}
.orch-node[data-status="blocked"] {
    border-left-color: var(--accent-red, #ef4444) !important;
}
.orch-node[data-status="skipped"] {
    opacity: 0.35;
    text-decoration: line-through;
}

@keyframes orch-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(59, 130, 246, 0.2); }
    50% { box-shadow: 0 0 16px rgba(59, 130, 246, 0.5); }
}

/* Feature selector bar */
.orch-feature-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    margin-bottom: 12px;
}
.orch-feature-select {
    flex: 1;
    padding: 6px 10px;
    background: var(--surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
}
.orch-progress-bar {
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
}
.orch-progress-fill {
    height: 100%;
    background: var(--accent-green, #22c55e);
    border-radius: 3px;
    transition: width 0.5s ease;
}
.orch-status-icon {
    font-size: 14px;
    margin-left: 8px;
}
.orch-auto-refresh {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.orch-refresh-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 11px;
}
.orch-refresh-btn:hover {
    background: var(--surface-2);
    color: var(--text-primary);
}
.orch-phase-detail {
    padding: 16px;
}
.orch-phase-detail h3 {
    margin-top: 0;
    color: var(--text-primary);
}
.orch-phase-detail .detail-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.orch-phase-detail .detail-label {
    font-weight: 600;
    min-width: 100px;
    color: var(--text-secondary);
}
.orch-phase-detail .detail-value {
    color: var(--text-primary);
}
.orch-ask-user-record {
    background: var(--surface-2);
    border-radius: 6px;
    padding: 10px;
    margin: 8px 0;
    border-left: 3px solid var(--accent-blue);
}

/* ===== Empty States ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-5) var(--sp-4);
    min-height: 200px;
    text-align: center;
}
.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--sp-3);
    opacity: 0.3;
}
.empty-state-text {
    font-size: var(--text-base);
    color: var(--text-secondary);
    margin-bottom: var(--sp-2);
}
.empty-state-hint {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    max-width: 320px;
}

/* ===== Agent Search ===== */
.agent-search {
    padding: 4px 10px;
    background: var(--surface-0);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: var(--text-sm);
    width: 180px;
    transition: border-color var(--transition-fast);
}
.agent-search:focus {
    border-color: var(--accent-blue);
}

/* ===== Command Palette: No Results ===== */
.cmd-no-results {
    padding: var(--sp-4);
    text-align: center;
    color: var(--text-tertiary);
    font-size: var(--text-sm);
}

/* ===== Proxy Controls ===== */
.proxy-controls {
    margin-top: 12px;
}
.proxy-form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.proxy-form-row label {
    min-width: 100px;
    font-weight: 500;
    color: var(--text-secondary);
}
.proxy-input {
    flex: 1;
    max-width: 200px;
    padding: 6px 10px;
    background: var(--surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}
.proxy-input:focus {
    border-color: var(--accent-blue);
    outline: none;
}
.proxy-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--surface-3, #374151);
    border-radius: 24px;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-blue, #3b82f6);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}
.badge-success {
    background: var(--accent-green, #22c55e);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}
.badge-secondary {
    background: var(--surface-3, #374151);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}
.badge-info {
    background: var(--accent-blue, #3b82f6);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}
.badge-warning {
    background: #f59e0b;
    color: #1a1a2e;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}
