/* DeNovo Works Orchestrator
   Inspired by GitHub dark + modern SaaS tooling.
   Unique palette: slate bg, cyan/teal accent, warm neutrals. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Backgrounds */
    --bg-base: #0d1117;
    --bg-surface: #161b22;
    --bg-overlay: #1c2129;
    --bg-inset: #010409;

    /* Borders */
    --border: #30363d;
    --border-muted: #21262d;
    --border-accent: rgba(56,189,248,0.4);

    /* Text */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-tertiary: #484f58;
    --text-link: #58a6ff;

    /* Accent: cyan/teal */
    --accent: #38bdf8;
    --accent-muted: rgba(56,189,248,0.15);
    --accent-fg: #0ea5e9;
    --accent-emphasis: #0284c7;

    /* Status colors */
    --green: #3fb950;
    --green-muted: rgba(63,185,80,0.15);
    --red: #f85149;
    --red-muted: rgba(248,81,73,0.15);
    --amber: #d29922;
    --amber-muted: rgba(210,153,34,0.15);
    --purple: #a371f7;
    --purple-muted: rgba(163,113,247,0.15);

    /* Geometry */
    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

.mono {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 13px;
}

/* ═══════════════════════════════════════════
   TOP BAR — GitHub-inspired nav
   ═══════════════════════════════════════════ */
.topbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-inner {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    cursor: default;
    user-select: none;
}
.brand-icon {
    color: var(--accent);
    font-size: 18px;
}
.brand-name {
    font-weight: 600;
    color: var(--text-primary);
    cursor: default;
}
.brand-page {
    font-weight: 500;
    color: var(--text-secondary);
    cursor: default;
}
.brand-sep {
    color: var(--text-tertiary);
}
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-dim {
    background: var(--border-muted);
    color: var(--text-tertiary);
}
.badge-active {
    background: var(--accent-muted);
    color: var(--accent);
}

/* ═══════════════════════════════════════════
   PHASE STEPPER — horizontal progress bar
   ═══════════════════════════════════════════ */
.stepper-bar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}
.stepper-inner {
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 44px;
    gap: 0;
}
.step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px;
    position: relative;
}
.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: all 0.3s;
}
.step.active .step-dot {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-muted);
}
.step.done .step-dot {
    background: var(--green);
}
.step-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    transition: color 0.3s;
}
.step.active .step-label {
    color: var(--text-primary);
}
.step.done .step-label {
    color: var(--text-secondary);
}
.step.clickable {
    cursor: pointer;
}
.step.clickable:hover .step-label {
    color: var(--accent);
}
.step.clickable:hover .step-dot {
    box-shadow: 0 0 6px var(--green);
}
.step.viewing .step-dot {
    box-shadow: 0 0 8px var(--amber);
    background: var(--amber);
}
.step.viewing .step-label {
    color: var(--amber);
}
.step-line {
    flex: 1;
    height: 1px;
    background: var(--border-muted);
    margin: 0 12px;
}

/* ═══════════════════════════════════════════
   MAIN LAYOUT
   ═══════════════════════════════════════════ */

.app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: calc(100vh - 52px); /* subtract topbar */
}

/* ─── Session Sidebar ─────────────────────── */
.session-sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar-header {
    padding: 16px 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-muted);
}
.sidebar-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sidebar-session-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
.sidebar-session-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid transparent;
    position: relative;
}
.sidebar-session-item:hover {
    background: var(--bg-overlay);
}
.sidebar-session-item.active {
    background: var(--bg-overlay);
    border-left-color: var(--accent);
}
.sidebar-phase-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}
.sidebar-phase-dot.phase-setup { background: var(--accent); }
.sidebar-phase-dot.phase-discovery { background: var(--purple); }
.sidebar-phase-dot.phase-executing { background: var(--amber); }
.sidebar-phase-dot.phase-review { background: var(--green); }
.sidebar-phase-dot.phase-complete {
    background: none;
    position: relative;
}
.sidebar-phase-dot.phase-complete::after {
    content: '\2713';
    position: absolute;
    top: -3px;
    left: -1px;
    font-size: 10px;
    color: var(--green);
    font-weight: bold;
}
.sidebar-session-info {
    flex: 1;
    min-width: 0;
}
.sidebar-session-goal {
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
.sidebar-session-meta {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 2px;
}
.sidebar-session-delete {
    position: absolute;
    right: 8px;
    top: 8px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 2px 4px;
}
.sidebar-session-item:hover .sidebar-session-delete {
    opacity: 1;
}
.sidebar-session-delete:hover {
    color: var(--red);
}

/* ─── Main Content Area ───────────────────── */
.main-content {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 80px;
    width: 100%;
}

.phase { display: none; }
.phase.active { display: block; }

/* ─── Welcome State ──────────────────────── */
.welcome-card {
    text-align: center;
    padding: 100px 20px;
}
.welcome-icon {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 16px;
}
.welcome-card h1 {
    font-size: 24px;
    margin-bottom: 8px;
}
.welcome-card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
    }
    .session-sidebar {
        display: none;
    }
}

.page-title {
    margin-bottom: 28px;
}
.page-title h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.page-title p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════
   SETUP — Two-column grid
   ═══════════════════════════════════════════ */
.setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
@media (max-width: 768px) {
    .setup-grid { grid-template-columns: 1fr; }
}

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-muted);
    background: var(--bg-overlay);
}
.panel-icon {
    font-size: 16px;
}
.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
}
.required-tag {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    background: var(--accent-muted);
    padding: 2px 7px;
    border-radius: 3px;
}
.optional-tag {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    background: var(--border-muted);
    padding: 2px 7px;
    border-radius: 3px;
}
.panel-body {
    padding: 18px;
}
.panel-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--accent-emphasis);
    color: #fff;
    border-color: var(--accent-emphasis);
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-fg);
    border-color: var(--accent-fg);
}
.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-outline:hover:not(:disabled) {
    color: var(--text-primary);
    border-color: var(--text-tertiary);
    background: var(--bg-overlay);
}
.btn-accent {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
}
.btn-accent:hover:not(:disabled) {
    background: #2ea043;
}
.btn-danger {
    background: var(--red-muted);
    color: var(--red);
    border-color: rgba(248,81,73,0.3);
}
.btn-danger:hover:not(:disabled) {
    background: rgba(248,81,73,0.2);
}
.btn-lg {
    padding: 12px 28px;
    font-size: 14px;
    border-radius: var(--radius-lg);
}

.action-bar {
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
}
.action-bar-split {
    justify-content: space-between;
}

/* ═══════════════════════════════════════════
   INPUTS
   ═══════════════════════════════════════════ */
.input-group {
    display: flex;
    gap: 8px;
}
input[type="text"], textarea {
    flex: 1;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}
input[type="text"]:focus, textarea:focus {
    border-color: var(--accent-fg);
    box-shadow: 0 0 0 3px var(--accent-muted);
}
textarea {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    resize: vertical;
    min-height: 48px;
}

/* ─── Folder picker ─── */
.folder-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}
.folder-picker-btn {
    flex-shrink: 0;
}
.folder-picker-path {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-height: 36px;
}
.folder-picker-path.has-value {
    color: var(--text-primary);
}

/* ─── Scan results ─── */
.scan-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
}
.scan-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--accent);
}
.scan-stat-icon {
    font-size: 14px;
}
.scan-files {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border-muted);
    border-radius: var(--radius);
    background: var(--bg-inset);
}
.scan-file {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    font-size: 12px;
    border-bottom: 1px solid var(--border-muted);
}
.scan-file:last-child { border-bottom: none; }
.scan-file-name {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}
.scan-file-meta {
    color: var(--text-tertiary);
    font-size: 11px;
}

/* ═══════════════════════════════════════════
   DROP ZONE (file upload)
   ═══════════════════════════════════════════ */
.drop-zone {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--bg-inset);
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-muted);
}
.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-tertiary);
    font-size: 13px;
}
.drop-icon {
    font-size: 20px;
    color: var(--accent);
    font-weight: 700;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-muted);
}

/* ─── File chips ─── */
.file-chips {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-overlay);
    border: 1px solid var(--border-muted);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}
.file-chip-icon {
    color: var(--accent);
}
.file-chip-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-muted);
}
.file-chip-row:last-child { border-bottom: none; }
.file-desc-input {
    width: 100%;
    background: var(--bg-inset);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-secondary);
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.file-desc-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}
.file-desc-input.has-value {
    color: var(--text-primary);
    border-color: var(--green);
}

/* ═══════════════════════════════════════════
   DISCOVERY — Chat + Sidebar
   ═══════════════════════════════════════════ */
.discovery-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 20px;
    min-height: 500px;
}
@media (max-width: 768px) {
    .discovery-layout { grid-template-columns: 1fr; }
    .context-sidebar { display: none; }
}

.chat-pane {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-muted);
    background: var(--bg-overlay);
}
.chat-pane-header h2 {
    font-size: 14px;
    font-weight: 600;
}
.counter-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--border-muted);
    color: var(--text-tertiary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-msg {
    display: flex;
    gap: 10px;
    max-width: 90%;
}
.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.chat-msg.user .msg-avatar {
    background: var(--purple-muted);
    color: var(--purple);
}
.chat-msg.assistant .msg-avatar {
    background: var(--accent-muted);
    color: var(--accent);
}
.msg-body {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}
.chat-msg.user .msg-body {
    background: var(--purple-muted);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}
.chat-msg.assistant .msg-body {
    background: var(--bg-overlay);
    border: 1px solid var(--border-muted);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-compose {
    border-top: 1px solid var(--border-muted);
    padding: 12px 18px;
    background: var(--bg-overlay);
}
.chat-compose textarea {
    width: 100%;
    display: block;
    min-height: 60px;
    max-height: 400px;
    overflow-y: auto;
    resize: none; /* auto-grow handles it */
}
.compose-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}
.compose-hint {
    font-size: 11px;
    color: var(--text-tertiary);
}
.compose-actions {
    display: flex;
    gap: 8px;
}

/* ─── Context Sidebar ─── */
.context-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 14px 16px;
}
.sidebar-section:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.sidebar-section:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.sidebar-section + .sidebar-section {
    border-top: none;
}
.sidebar-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}
.sidebar-value {
    font-size: 13px;
    color: var(--text-secondary);
    word-break: break-all;
}

/* ═══════════════════════════════════════════
   EXECUTION — Progress
   ═══════════════════════════════════════════ */
.exec-container {
    max-width: 700px;
}
.exec-progress {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}
.exec-bar {
    height: 4px;
    background: var(--border-muted);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 14px;
}
.exec-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-emphasis), var(--accent));
    border-radius: 2px;
    width: 0%;
    transition: width 0.5s ease;
}
.exec-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.exec-status-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
}
.exec-turns-counter {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}
.exec-turns-counter strong {
    color: var(--accent);
}
.exec-model-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 3px;
    background: var(--purple-muted);
    color: var(--purple);
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ─── Live execution log ─── */
.exec-log {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.8;
}
.log-entry {
    color: var(--text-secondary);
    padding: 2px 0;
    border-bottom: 1px solid var(--border-muted);
}
.log-entry:last-child { border-bottom: none; }
.log-entry.log-error {
    color: var(--red);
}
.log-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    margin-right: 8px;
    vertical-align: middle;
    animation: pulse 1.5s ease-in-out infinite;
}
.log-dot.error {
    background: var(--red);
    animation: none;
}
@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}
.log-time {
    color: var(--text-tertiary);
    margin-right: 10px;
}

.exec-turns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.turn-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
}
.turn-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.turn-card-body {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: pre-wrap;
    max-height: 60px;
    overflow: hidden;
}

/* ═══════════════════════════════════════════
   REVIEW — Tabs + Panels
   ═══════════════════════════════════════════ */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.tab {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.tab:hover {
    color: var(--text-primary);
}
.tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

.review-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.prose {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}
.prose h2, .prose h3, .prose h4 { margin-top: 16px; }
.prose ul, .prose ol { margin: 8px 0; }
.prose li { margin: 4px 0; }

/* ─── File changes ─── */
.file-change-list {}
.change-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-muted);
    font-size: 13px;
}
.change-row:last-child { border-bottom: none; }
.change-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    min-width: 52px;
    text-align: center;
}
.change-badge.added   { background: var(--green-muted);  color: var(--green); }
.change-badge.modified { background: var(--amber-muted); color: var(--amber); }
.change-badge.deleted  { background: var(--red-muted);   color: var(--red); }
.change-path {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-primary);
}

/* ─── Diff viewer ─── */
.diff-viewer {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre;
    color: var(--text-secondary);
}
.diff-add { color: var(--green); }
.diff-del { color: var(--red); }
.diff-hunk { color: var(--purple); font-weight: 600; }

/* ─── Turn details ─── */
.turn-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.td-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
}
.td-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.td-preview {
    font-size: 13px;
    color: var(--text-tertiary);
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.5;
}

/* ─── Alert ─── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-error {
    background: var(--red-muted);
    border: 1px solid rgba(248,81,73,0.3);
    color: var(--red);
}

/* ─── Review actions bar ─── */
.review-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    margin-top: 8px;
}
.review-actions-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ═══════════════════════════════════════════
   COMPLETE
   ═══════════════════════════════════════════ */
.complete-card {
    text-align: center;
    padding: 60px 20px;
}
.complete-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--green-muted);
    color: var(--green);
    font-size: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}
.complete-card h1 {
    font-size: 24px;
    margin-bottom: 8px;
}
.complete-card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ═══════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════ */
.hidden { display: none !important; }

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
}

/* ═══════════════════════════════════════════
   MODAL — Git choice overlay
   ═══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(1,4,9,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
}
.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}
.modal-card h2 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 10px;
}
.modal-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}
.modal-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.modal-option-btn {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 18px;
    text-align: left;
    width: 100%;
    border-radius: var(--radius);
    justify-content: flex-start;
}
.modal-option-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
    line-height: 1.4;
}
.modal-option-btn strong {
    display: block;
    font-size: 13px;
    margin-bottom: 2px;
}
.modal-option-btn small {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 400;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }


/* ─── Plan Container ────────────────────────────── */
.plan-container {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    min-height: 200px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 24px;
}
.plan-content {
    min-height: 100px;
}


/* ─── Topbar Buttons ────────────────────────────── */
.topbar-btn {
    font-size: 12px;
    padding: 4px 12px;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}


/* ─── Discovery Status (live feedback) ──────────── */
.discovery-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-muted);
    background: var(--bg-inset);
}

.discovery-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse-dot 1.4s ease-in-out infinite;
    flex-shrink: 0;
}

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


/* ─── Image Thumbnails & Modal ──────────────────── */
.file-thumb {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
    flex-shrink: 0;
}
.file-thumb:hover {
    border-color: var(--accent);
}

.file-chip-image {
    cursor: pointer;
    color: var(--text-link);
}
.file-chip-image:hover {
    text-decoration: underline;
}

.image-modal-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}
.image-modal-card img {
    max-width: 90vw;
    max-height: 80vh;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}


/* ─── Chat Image Preview ────────────────────────── */
.chat-image-preview {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    flex-wrap: wrap;
    border-top: 1px solid var(--border-muted);
}
.chat-image-thumb {
    position: relative;
    display: inline-block;
}
.chat-image-preview img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color 0.15s;
}
.chat-image-preview img:hover {
    border-color: var(--accent);
}
.chat-image-remove {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--red);
    color: white;
    border: none;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}


/* ─── Review Notice ─────────────────────────────── */
.review-notice {
    background: var(--accent-muted);
    color: var(--accent);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius);
    padding: 10px 16px;
    font-size: 12px;
    margin-bottom: 16px;
}


/* ─── Small Button ──────────────────────────────── */
.btn-sm {
    font-size: 12px;
    padding: 4px 10px;
    min-height: unset;
}


/* ─── Read-Only Mode (viewing past phases) ──────── */
main.read-only {
    position: relative;
}
main.read-only::after {
    content: 'Viewing past phase (read-only)';
    position: sticky;
    top: 0;
    display: block;
    background: var(--amber-muted);
    color: var(--amber);
    text-align: center;
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    z-index: 10;
}
main.read-only .phase.active {
    opacity: 0.6;
    pointer-events: none;
}
main.read-only .btn,
main.read-only textarea,
main.read-only input,
main.read-only .drop-zone {
    pointer-events: none !important;
    opacity: 0.4 !important;
}


/* ─── Admin Panel ───────────────────────────────── */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 768px) {
    .admin-grid { grid-template-columns: 1fr; }
}
.admin-input {
    display: block;
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}
.admin-input:focus {
    outline: none;
    border-color: var(--accent);
}
select.admin-input {
    appearance: auto;
}
.admin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-muted);
    font-size: 13px;
}
.admin-item:last-child {
    border-bottom: none;
}
.admin-link {
    color: var(--accent);
    font-size: 11px;
    word-break: break-all;
}
.admin-item-col {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}
.admin-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.admin-link-row {
    overflow: hidden;
}
.admin-item-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}


/* ─── Turn Detail Badges ──────────────────────────── */
.td-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--accent-muted);
    color: var(--accent);
    margin-left: 6px;
    vertical-align: middle;
}
.td-badge-fail {
    background: var(--red-muted);
    color: var(--red);
}
.td-badge-fix {
    background: var(--amber-muted);
    color: var(--amber);
}

/* ─── Preview Tab ───────────────────────────────── */
.preview-container {
    min-height: 400px;
    position: relative;
}
.preview-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 13px;
}
.preview-iframe {
    width: 100%;
    height: 500px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
}
