/* Stage Tabs */
.stage-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    margin: 0 -16px;
    padding: 8px 16px 0;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.stage-tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
}

.stage-tab-btn:hover {
    color: var(--text);
    background: transparent;
}

.stage-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: transparent;
}

.stage-tab-btn svg {
    opacity: 0.7;
}

.stage-tab-btn.active svg {
    opacity: 1;
}

.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--border);
    border-radius: 9px;
    font-size: 12px;
    font-weight: 600;
}

.stage-tab-btn.active .tab-badge {
    background: var(--accent);
    color: white;
}

/* Tab Content */
.stage-tab-content {
    display: none;
    padding-top: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
}

.stage-tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Edit tab uses flex layout for code stages */
.stage-tab-edit.active {
    overflow: hidden;
}

/* Notebook edit tabs scroll — notebook content has natural height unlike Monaco */
.stage-tab-edit.active:has(.code-workspace-notebook) {
    overflow-y: auto;
    overflow-x: hidden;
}

/* Notebook workspace takes natural height (not flex-fill like Monaco).
   Finding #8 (08.17.26-notebook-ux-polish, root-caused live via
   getBoundingClientRect/elementFromPoint on sciflow.nalian.dev against
   subselcetA): this rule and `.code-workspace { flex: 1; ... }` below
   (~line 242) both carry the SAME specificity (one class each) — the
   element in the DOM has BOTH classes (`class="code-workspace
   code-workspace-notebook"`) — so the tie is broken by source order, and
   `.code-workspace` simply appears later in this file and silently won,
   leaving this rule dead. Confirmed live: computed `flex` on
   `#notebook-section-{id}` read `1 1 0%`, not `none`; the box's
   `clientHeight` (1015px, whatever the flex algorithm allocated at mount
   time) never grew to match Monaco's real async-resized content
   (`scrollHeight` 2050px — see notebook.js `_initCellEditor`'s
   `onDidContentSizeChange`), so the extra ~1035px of real cell content
   spilled past the box with `overflow: visible` and painted over
   `.input-mapping-section` below it. Two-class selector below gives this
   the higher specificity it needs to win regardless of source order —
   verified live (devtools override) that this restores `flex: none` and
   the box's height then tracks its real content, eliminating the overlap.
   This also feeds finding #2: before this fix, maximizing/popping out a
   notebook stage didn't help — the box's height was locked to the flex
   algorithm's allocation, not to available viewport, so more window
   space didn't reach the cells. */
.code-workspace.code-workspace-notebook {
    flex: none;
}

/* Config-only edit tabs (no Monaco editor) — scrolling is handled by
   the workflow panel override in stages_list.html, so no special
   overflow rule needed here. */

/* Non-edit tabs scroll their content */
.stage-tab-content.active:not(.stage-tab-edit) {
    overflow-y: auto;
}

/* Spinning animation for running status */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin {
    animation: spin 1s linear infinite;
}

/* Compact Description */
.stage-description-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    flex-shrink: 0;
}

.desc-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.desc-chevron:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.desc-chevron.expanded svg {
    transform: rotate(90deg);
}

.desc-summary {
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.desc-summary:hover {
    color: var(--text);
}

.desc-expanded {
    padding: 0 0 8px 30px;
    flex-shrink: 0;
}

/* Compact Dependencies */
.deps-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.deps-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.dep-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    font-size: 12px;
    font-family: var(--font-mono);
}

.dep-chip-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.deps-none {
    font-size: 12px;
    color: var(--text-secondary);
}

.dep-edit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.15s;
}

.dep-edit-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.dep-condition-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-family: var(--font-mono);
    color: #3b82f6;
    cursor: help;
}

/* Code Workspace */
.code-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-top: 4px;
}

.code-toolbar {
    display: flex;
    flex-wrap: wrap;
    row-gap: 6px;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    flex-shrink: 0;
}

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

.toolbar-label {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
}

.toolbar-version {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    background: none;
    padding: 0;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.toolbar-actions .btn {
    white-space: nowrap;
}

/* Visual-craft pass (design correction 2026-07-02, item 5 — owner: "does
   this toolbar look professional to you?"). Two real, measured defects
   found live, not just a taste call:
   1. Save/Run/Help/Snippets/Fullscreen/AI rendered at FIVE different
      heights (27.5–32px) because nothing here shared a sizing rule — each
      control (.btn, .btn-icon, <select>, .ai-toggle-btn) brought its own
      padding/border math. Harmonized to one height so the row reads as one
      instrument, not five unrelated controls that happen to be adjacent.
   2. The Help/Fullscreen icon buttons were being silently flex-shrunk from
      their declared 32×32 down to ~18×32 (oval, not square) even though
      the row had ~300px of unused slack — confirmed empirically (DevTools:
      forcing flex-shrink:0 alone fixed it, forcing width:32px!important
      did not, so the declared width was never the problem). Every action
      button now resists shrinking; the Snippets select (the one genuinely
      optional-width control, already carrying its own min-width floor)
      absorbs any real space pressure instead.
   Scoped to .code-toolbar so this doesn't change .btn-icon/.toolbar-select
   sizing anywhere else in the app.
   Heng Li review, round 1: disabling shrink on every action control means
   the row can genuinely run out of room to give at the real reachable
   floor — .stage-window has its own min-width:500px, and the fixed-size
   controls plus the select's own min-width already exceed the space left
   over at exactly that width. Rather than let it clip or force a
   horizontal scrollbar inside a titlebar-adjacent toolbar, .code-toolbar
   (below) now takes flex-wrap so .toolbar-actions drops to its own line
   under .toolbar-left when it doesn't fit — the same pattern the DAG
   toolbar (.dag-toolbar in stages_list.html) already uses for the
   identical problem, not a new convention. */
.code-toolbar .toolbar-actions > * {
    flex-shrink: 0;
}
.code-toolbar .toolbar-actions .toolbar-select {
    flex-shrink: 1;
}
.code-toolbar .toolbar-actions .btn,
.code-toolbar .toolbar-actions .btn-icon,
.code-toolbar .toolbar-actions .toolbar-select,
.code-toolbar .toolbar-actions .ai-toggle-btn {
    height: 30px;
    box-sizing: border-box;
}
.code-toolbar .toolbar-actions .btn-icon {
    width: 30px;
}
.code-toolbar .toolbar-actions .btn-icon,
.code-toolbar .toolbar-actions .toolbar-select,
.code-toolbar .toolbar-actions .ai-toggle-btn {
    border-radius: var(--radius-sm);
}

.toolbar-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 2px;
}

.toolbar-select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 12px;
    min-width: 100px;
}

/* Editor + AI Row */
.editor-ai-row {
    display: flex;
    flex: 1;
    min-height: 0;
}

.editor-ai-row .monaco-editor-container {
    flex: 1;
    min-height: 0;
    height: auto !important;
}

/* AI Side Panel */
.ai-side-panel {
    width: 350px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 0 6px 0;
    overflow: hidden;
}

.ai-side-panel .ai-chat-panel {
    height: 100%;
    border: none;
    border-radius: 0;
}

/* AI Toggle Button */
.ai-toggle-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.ai-toggle-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.ai-toggle-btn.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

/* AI Chat Panel */
.ai-chat-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 200px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
}

.ai-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-complete);
}

.ai-status-dot.streaming {
    background: var(--status-active);
    animation: breathe 2s ease-in-out infinite;
}

.ai-status-dot.error {
    background: var(--status-failed);
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.ai-side-panel .ai-welcome {
    padding: 20px 12px;
}

.ai-msg-wrapper {
    max-width: 88%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-msg-wrapper.user {
    align-self: flex-end;
    align-items: flex-end;
}

.ai-msg-wrapper.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.ai-msg-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 0 6px;
}

.ai-msg {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.ai-msg p {
    margin: 0 0 8px 0;
}

.ai-msg p:last-child {
    margin-bottom: 0;
}

.ai-msg.user {
    background: none;
    color: var(--text);
    border-right: 2px solid var(--accent);
    padding: 8px 14px 8px 0;
    border-radius: 0;
    font-family: var(--font-sans);
    font-size: 14px;
}

.ai-msg.assistant {
    background: none;
    color: var(--text-secondary);
    border: none;
    border-left: 2px solid var(--border);
    border-radius: 0;
    padding: 8px 0 8px 14px;
    font-size: 14px;
    line-height: 1.7;
}

.ai-msg .ai-code-block {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 12px 14px;
    border-radius: 6px;
    margin: 8px 0;
    font-family: var(--font-mono);
    font-size: 12px;
    overflow-x: auto;
    white-space: pre;
    display: block;
    line-height: 1.5;
}

.ai-msg .ai-code-block code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
    color: inherit;
}

.ai-msg .ai-inline-code {
    background: rgba(127,127,127,0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: var(--font-mono);
}

.ai-msg .ai-h2 {
    font-size: 14px;
    font-weight: 600;
    margin: 12px 0 6px 0;
}

.ai-msg .ai-h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 10px 0 4px 0;
}

.ai-msg .ai-list-item {
    padding: 2px 0 2px 4px;
}

.ai-msg .ai-list-num,
.ai-msg .ai-list-bullet {
    color: var(--accent);
    font-weight: 600;
    margin-right: 4px;
}

.ai-typing {
    display: flex;
    gap: 0;
    padding: 8px 0 8px 14px;
    align-self: flex-start;
    background: none;
    border-left: 2px solid var(--accent);
    border-radius: 0;
    animation: breathe 2s ease-in-out infinite;
}

.ai-typing-dot {
    display: none;
}

.ai-typing::after {
    content: 'Thinking...';
    font-size: 12px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.ai-input-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px 10px;
    border-top: 1px solid var(--border-subtle);
    background: transparent;
}

.ai-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-input-row:first-child {
    justify-content: space-between;
    padding: 0 2px;
}

.ai-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.ai-clear-btn:hover {
    background: var(--border);
    color: var(--text);
}

.ai-input-row:last-child {
    align-items: flex-end;
}

.ai-input {
    flex: 1;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    padding: 10px 0;
}

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

.ai-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.ai-send-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

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

/* Project-Level AI Workflow Planner Panel */
.project-ai-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 400px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 1000;
    display: none;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,0.2);
}

.project-ai-panel.open {
    display: flex;
}

.project-ai-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.project-ai-header-title {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
}

.project-ai-header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.project-ai-header-btn:hover {
    background: var(--border);
    color: var(--text);
}

.project-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.project-ai-welcome {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    padding: 16px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.project-ai-welcome ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.project-ai-welcome li {
    margin-bottom: 4px;
}

.project-ai-msg {
    max-width: 90%;
    padding: 8px 14px;
    font-size: 13px;
    line-height: 1.6;
    word-wrap: break-word;
}

.project-ai-msg.user {
    align-self: flex-end;
    color: var(--text);
    border-right: 2px solid var(--accent);
    padding: 8px 14px 8px 0;
}

.project-ai-msg.assistant {
    align-self: flex-start;
    color: var(--text-secondary);
    border-left: 2px solid var(--border);
    padding: 8px 0 8px 14px;
}

.project-ai-msg.assistant p {
    margin: 0 0 8px 0;
}

.project-ai-msg.assistant p:last-child {
    margin-bottom: 0;
}

.project-ai-msg.assistant code {
    background: rgba(127,127,127,0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: var(--font-mono);
}

.project-ai-msg.assistant pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 10px 12px;
    border-radius: 6px;
    margin: 8px 0;
    font-size: 12px;
    overflow-x: auto;
    line-height: 1.5;
}

.project-ai-msg.assistant pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: inherit;
}

.project-ai-msg.assistant ul,
.project-ai-msg.assistant ol {
    margin: 4px 0;
    padding-left: 20px;
}

.project-ai-msg.assistant strong {
    color: var(--text);
}

.project-ai-input-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 16px 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.project-ai-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.project-ai-input {
    flex: 1;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    padding: 10px 0;
}

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

.project-ai-input::placeholder {
    color: var(--text-secondary);
}

.project-ai-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.project-ai-send-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.project-ai-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Report Group Cards (Community Analysis) */
.report-group-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.report-group-card.report-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    margin: 0;
    border-radius: 0;
    background: var(--bg);
}

.report-group-card-header {
    font-size: 13px;
    font-weight: 600;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.report-group-card-body {
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.report-group-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Report Tab Bar (Community Analysis) */
.report-tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.report-tab-bar::-webkit-scrollbar {
    height: 4px;
}

.report-tab-bar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.report-tab-btn {
    padding: 6px 10px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.report-tab-btn:hover {
    color: var(--text);
}

.report-tab-btn.active {
    border-bottom-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

.report-tab-panel {
    display: none;
}

.report-tab-panel.active {
    display: block;
}

.report-tab-panels {
    overflow: hidden;
    padding: 12px;
}

/* Community Analysis Stats Panel */
.ca-stats-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 12px;
}

.ca-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.ca-stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ca-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ca-stat-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    font-family: var(--font-mono);
}

.ca-stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 13px;
}

.ca-stats-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
}

.ca-stats-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-size: 12px;
}

.ca-stats-table tr:last-child td {
    border-bottom: none;
}

/* Community Analysis AI Interpretation */
.ca-ai-interpretation {
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
}

.ca-ai-interp-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 6px;
}

/* Key Findings bullet list */
.ca-key-findings-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.ca-key-findings-list li {
    position: relative;
    padding: 8px 0 8px 20px;
    line-height: 1.6;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.ca-key-findings-list li:last-child {
    border-bottom: none;
}
.ca-key-findings-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

/* Community Analysis File Format Hints */

/* Query tab */
.query-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    height: 100%;
}
.query-tables {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.query-table-name {
    background: var(--bg-secondary);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}
.query-table-file {
    color: var(--text-tertiary);
    font-size: 11px;
}
.query-input-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.query-input {
    width: 100%;
    padding: 8px 10px;
    font-family: var(--font-mono, monospace);
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text-primary);
    resize: vertical;
    min-height: 60px;
}
.query-input:focus {
    outline: none;
    border-color: var(--accent);
}
.query-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.query-run-btn {
    padding: 6px 16px;
    font-size: 13px;
}
.query-hint {
    font-size: 11px;
    color: var(--text-tertiary);
}
.query-output {
    flex: 1;
    overflow: auto;
}
.query-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}
.query-results-wrap {
    overflow: hidden;
}
.query-table-wrap {
    overflow-x: auto;
    max-height: 400px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
}
.query-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: var(--font-mono, monospace);
}
.query-results-table th,
.query-results-table td {
    padding: 4px 8px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-subtle);
    text-align: left;
}
.query-results-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary, var(--bg-secondary));
    position: sticky;
    top: 0;
}
.query-results-table td {
    color: var(--text-primary);
}
.query-results-table tr:hover td {
    background: var(--bg-secondary);
}
.query-error {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--danger, #ef4444);
    background: var(--bg-secondary);
    border: 1px solid var(--danger, #ef4444);
    border-radius: 6px;
    font-family: var(--font-mono, monospace);
    white-space: pre-wrap;
    word-break: break-word;
}
.query-info {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-tertiary);
}
.query-tables-list {
    line-height: 1.8;
}
.query-history {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}
.query-history-label {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-right: 4px;
}
.query-history-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-family: var(--font-mono, monospace);
    color: var(--text-secondary);
    cursor: pointer;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.query-history-item:hover {
    background: var(--bg-tertiary, var(--bg-secondary));
    border-color: var(--accent);
    color: var(--text-primary);
}

/* File preview panels (community analysis file picker) */
.file-preview-container {
    margin-top: 6px;
    min-width: 0;
    overflow: hidden;
}
.file-preview-panel {
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: var(--bg-secondary);
    overflow: hidden;
}
.file-preview-meta {
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}
.file-preview-table-wrap {
    overflow-x: auto;
    max-height: 160px;
}
.file-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-family: var(--font-mono, monospace);
}
.file-preview-table th,
.file-preview-table td {
    padding: 3px 6px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-subtle);
    text-align: left;
}
.file-preview-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary, var(--bg-secondary));
    position: sticky;
    top: 0;
}
.file-preview-table td {
    color: var(--text-tertiary);
}
.file-preview-warnings {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-subtle);
}
.file-preview-warning {
    font-size: 11px;
    padding: 2px 0;
    line-height: 1.4;
}
.file-preview-warning.warn {
    color: #d97706;
}
.file-preview-warning.info {
    color: var(--text-tertiary);
}
.file-preview-empty {
    padding: 6px 8px;
    font-size: 11px;
    color: var(--text-tertiary);
}

.ca-file-hint {
    margin-top: 6px;
}

.ca-file-hint-header {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-tertiary);
    cursor: pointer;
    /* No user-select:none (click-trap fix, app-shell review §3.1/§3.8) — the
       inline onclick guards with _isSelectionClick() instead. */
}

/* Info icon rendered via CSS — no inline SVG needed */
.ca-file-hint-header::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background: currentColor;
    opacity: 0.6;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 100 14A7 7 0 008 1zm0 2.5a1 1 0 110 2 1 1 0 010-2zM6.5 7h1.75v4.25h1v.75h-3v-.75h1V7.75H6.5V7z'/%3E%3C/svg%3E") center/contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 100 14A7 7 0 008 1zm0 2.5a1 1 0 110 2 1 1 0 010-2zM6.5 7h1.75v4.25h1v.75h-3v-.75h1V7.75H6.5V7z'/%3E%3C/svg%3E") center/contain no-repeat;
    flex-shrink: 0;
}

.ca-file-hint-header:hover {
    color: var(--text-secondary);
}

.ca-file-hint-body {
    display: none;
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.ca-file-hint.expanded .ca-file-hint-body {
    display: block;
}

.ca-file-hint.expanded .ca-file-hint-header {
    color: var(--text-secondary);
}

.ca-file-hint-example {
    margin-top: 6px;
    padding: 6px 8px;
    background: var(--bg);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-tertiary);
}

/* Community Analysis Config Groups */
.ca-config-group {
    margin-bottom: 2px;
    border-bottom: 1px solid var(--border-subtle);
}

.ca-config-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.ca-config-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
    /* No user-select:none here (click-trap fix, app-shell review §3.1/§3.8) —
       the title text stays selectable; toggleCaGroup() guards against firing
       the toggle when the click is actually completing a text selection. */
}

.ca-config-group-header:hover {
    background: var(--bg-secondary);
}

.ca-config-group-header input[type="checkbox"] {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

/* Was .ca-config-group-title — the markup actually emits .ca-group-title, so this
   rule never matched (dead CSS). Fixed to the real class name it was meant to style. */
.ca-group-title {
    font-weight: 600;
    font-size: 13px;
    flex: 1;
    white-space: nowrap;
}

.ca-group-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.2s;
}

/* Chevron rendered via CSS — no inline SVG needed */
.ca-group-chevron::after {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") center/contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") center/contain no-repeat;
    color: var(--text-secondary);
}

.ca-group-chevron.collapsed {
    transform: rotate(-90deg);
}

.ca-config-group-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 0 0 8px 24px;
}

.ca-config-group-body.collapsed {
    display: none;
}

.ca-config-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
}

.ca-config-item:hover {
    background: var(--bg-secondary);
}

.ca-config-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
}

.ca-config-item.ca-coming-soon {
    opacity: 0.45;
    cursor: default;
}

.ca-config-item.ca-coming-soon:hover {
    background: none;
}

/* Help hint — generated via ::after so no extra <span> needed in HTML */
.ca-help-hint::after {
    content: '?';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid var(--border);
    font-size: 9px;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-left: 2px;
    flex-shrink: 0;
    cursor: help;
}

.ca-config-item:hover .ca-help-hint::after {
    border-color: var(--text-secondary);
    color: var(--text-secondary);
}

/* "soon" badge — generated via ::before on .ca-coming-soon
   (::after is used by ca-help-hint for the ? circle) */
.ca-coming-soon::before {
    content: 'soon';
    order: 99;
    font-size: 10px;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1px 6px;
    color: var(--text-tertiary);
    margin-left: 2px;
}

/* "Analyses to Include" checkboxes the standard pass alone can't deliver --
   COMMUNITY_ANALYSIS_UNIMPLEMENTED_STANDARD, see shared_templates.py +
   ca_analysis_checkbox_macro.html. Checking one of these now automatically
   makes update_config() derive run_full_report=True (08.02.26-community-
   analysis-toggle-and-mantel; no more separate toggle checkbox), which is
   what actually runs it. Dimmed + badged by default until saved in that
   state (unlike .ca-coming-soon: NOT "cursor: default" -- these ARE real,
   checkable, functioning checkboxes, so hover/click affordance stays
   normal). 08.02.26, second finding folded into
   python-runner-stdout-capture-regression. */
.ca-config-item.ca-needs-full-report {
    opacity: 0.6;
}

/* stage_detail.html sets this class on the checklist container from
   cfg.get('run_full_report') at render time -- 08.02.26-community-analysis-
   toggle-and-mantel: run_full_report is now auto-derived server-side
   (update_config(), routers/stages/configuration.py) from whether any
   checked box is in COMMUNITY_ANALYSIS_UNIMPLEMENTED_STANDARD, not read
   from a user-facing toggle checkbox. At that point every item below
   genuinely will run, so the dimming/badge would be actively misleading. */
[id^="ca-analyses-container-"].ca-full-report-on .ca-needs-full-report {
    opacity: 1;
}

.ca-extended-badge {
    order: 99;
    font-size: 10px;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1px 6px;
    color: var(--text-tertiary);
    margin-left: 4px;
    flex-shrink: 0;
}

[id^="ca-analyses-container-"].ca-full-report-on .ca-extended-badge {
    display: none;
}

/* Input File Browser — compact overrides for stage-detail context */
.input-file-browser {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}
.input-file-browser .file-search-bar {
    padding: 6px 12px;
}
.input-file-browser .file-table-header {
    display: grid;
    grid-template-columns: 32px 1fr 80px 40px;
    padding: 6px 12px;
    font-size: 11px;
}
.input-file-browser .file-table .folder-row,
.input-file-browser .file-table .file-row {
    display: grid;
    grid-template-columns: 32px 1fr 80px 40px;
    padding: 6px 12px;
    font-size: 13px;
}
.input-file-browser .file-table .folder-children .file-row {
    padding-left: 44px;
}
.input-file-browser .col-name {
    font-size: 13px;
    gap: 6px;
}
.input-file-browser .col-actions {
    opacity: 1;
}
.input-file-browser .col-size {
    font-size: 11px;
}

/* Collapsible input file browser wrapper */
.ifb-collapsible {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.ifb-collapsible .input-file-browser {
    border: none;
    border-radius: 0;
    margin-bottom: 0;
}
.ifb-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    background: var(--bg-secondary);
    /* No user-select:none (click-trap fix, app-shell review §3.1/§3.8) —
       toggleInputBrowser() guards with _isSelectionClick() instead. */
    transition: background 0.15s;
}
.ifb-header:hover {
    background: var(--bg-tertiary, rgba(0,0,0,0.04));
}
.ifb-chevron {
    flex-shrink: 0;
    transition: transform 0.2s;
    color: var(--text-tertiary);
}
.ifb-collapsible.collapsed .ifb-chevron {
    transform: rotate(-90deg);
}
.ifb-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
}
.ifb-status {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-tertiary);
    background: var(--bg);
    padding: 1px 8px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.ifb-collapsible.collapsed .ifb-body {
    display: none;
}
.ifb-body {
    border-top: 1px solid var(--border);
}
/* Badge on collapsed folder-rows showing selected file count */
.folder-sel-badge {
    display: none;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
}
.folder-row.collapsed .folder-sel-badge.has-sel {
    display: inline;
}

/* Run button pinned to bottom of Configure tab */
.config-run-action {
    position: sticky;
    bottom: 0;
    margin-top: auto;
    padding: 12px 0;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
    background: var(--bg);
    border-top: 1px solid var(--border-subtle);
    z-index: 5;
}

/* Molstar 3D viewer overrides */
#stage-tab-3d .msp-plugin {
    position: absolute !important;
    inset: 0;
}
[id^="molstar-container-"] {
    border-radius: 6px;
    overflow: hidden;
}
[id^="molstar-container-"] .msp-layout-standard {
    border: none !important;
}
/* Dark theme fix — hide Molstar's white backgrounds */
[id^="molstar-container-"] .msp-plugin .msp-layout-background {
    background: transparent !important;
}

/* Mol* browser fullscreen mode */
[id^="molstar-panel-"]:fullscreen {
    background: #000;
    display: flex;
    flex-direction: column;
}
[id^="molstar-panel-"]:fullscreen [id^="molstar-container-"] {
    flex: 1;
    min-height: 0 !important;
}

/* Ask AI field button */
.btn-ai-ask {
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.btn-ai-ask:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.btn-ai-ask.has-rec {
    border-color: #16a34a;
    color: #16a34a;
    background: color-mix(in srgb, #16a34a 8%, transparent);
}

.btn-ai-ask.has-rec:hover {
    border-color: #16a34a;
    color: #16a34a;
    background: color-mix(in srgb, #16a34a 16%, transparent);
}

/* AI field popover */
.ai-field-popover {
    position: fixed;
    z-index: 1010;
    width: 420px;
    padding: 10px 12px;
    background: var(--bg-secondary, #1e1e2e);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm, 6px);
    font-size: 12px;
    line-height: 1.5;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.ai-field-popover-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px;
}

.ai-field-popover-close:hover {
    color: var(--text);
}

.ai-field-popover-content {
    padding-right: 16px;
}

.ai-field-popover-loading {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.ai-field-popover-actions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.btn-ai-apply {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-ai-apply:hover {
    opacity: 0.85;
}

/* AI-suggested field highlight */
.ai-suggested {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent);
    border-color: var(--accent) !important;
}

/* ── Mol* trajectory playback slider ── */
#stage-detail-modal input[type="range"][id^="molstar-frame-slider"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #333;
    border-radius: 3px;
    outline: none;
    margin: 7px 0;
}

#stage-detail-modal input[type="range"][id^="molstar-frame-slider"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #1e3a5f;
}

#stage-detail-modal input[type="range"][id^="molstar-frame-slider"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #1e3a5f;
}

#stage-detail-modal input[type="range"][id^="molstar-frame-slider"]::-webkit-slider-runnable-track {
    height: 6px;
    background: #333;
    border-radius: 3px;
}

#stage-detail-modal input[type="range"][id^="molstar-frame-slider"]::-moz-range-track {
    height: 6px;
    background: #333;
    border-radius: 3px;
}

/* ── Binding Site Inline Picker Controls ── */
.bs-picker-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.92);
    border-radius: 0 0 6px 6px;
    margin-top: -1px;
}
/* Mol* viewer inside binding site picker */
[id^="binding-site-molstar-"] .msp-plugin {
    position: absolute !important;
    inset: 0;
}
[id^="binding-site-molstar-"] .msp-layout-standard {
    border: none !important;
}
[id^="binding-site-molstar-"] .msp-plugin .msp-layout-background {
    background: transparent !important;
}


/* ===== Mobile Responsiveness (≤640px) ===== */

@media (max-width: 640px) {
    /* Tab bar: allow wrapping */
    .stage-tabs {
        flex-wrap: wrap;
        gap: 2px;
    }

    .stage-tab-btn {
        font-size: 11px;
        padding: 6px 8px;
    }

    /* Config form: stack fields */
    .config-row {
        flex-direction: column;
    }

    .config-row .form-group {
        width: 100%;
    }

    /* Tighter padding in stage content */
    .stage-detail-content {
        padding: 12px;
    }
}

/* ── AI Interactive Flow Cards (ticket 06) ───────────────────────────────── */

.ai-plan-card,
.ai-run-card,
.ai-answer-card {
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg);
}

.ai-plan-infeasible {
    border-color: var(--status-failed, #dc2626);
}

.ai-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ai-card-label {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.ai-tier-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    border: 1px solid var(--accent);
    color: var(--accent);
    letter-spacing: 0.05em;
}

.ai-stage-count {
    font-size: 11px;
    color: var(--text-secondary);
}

.ai-confidence-badge {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.ai-conf-high {
    border-color: var(--status-complete, #27ae60);
    color: var(--status-complete, #27ae60);
}

.ai-conf-mid {
    border-color: var(--status-queued, #f39c12);
    color: var(--status-queued, #f39c12);
}

.ai-conf-low {
    border-color: var(--status-failed, #dc2626);
    color: var(--status-failed, #dc2626);
}

.ai-uncertain-badge {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
    border: 1px solid var(--text-tertiary, var(--text-secondary));
    color: var(--text-secondary);
    font-style: italic;
}

.ai-card-reasoning {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.ai-workflow-steps {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    color: var(--text);
    line-height: 1.6;
}

.ai-workflow-steps li {
    margin-bottom: 3px;
}

.ai-stage-list {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    color: var(--text);
    line-height: 1.6;
}

.ai-stage-list li {
    margin-bottom: 3px;
}

.ai-blockers-list {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    color: var(--status-failed, #dc2626);
    line-height: 1.6;
}

.ai-card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.ai-answer-text {
    font-size: 13px;
    color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
}

.ai-answer-empty {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
    margin: 0;
}

.ai-evidence-details {
    font-size: 12px;
    color: var(--text-secondary);
}

.ai-evidence-details summary {
    cursor: pointer;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.ai-evidence-pre {
    background: rgba(127,127,127,0.08);
    border-radius: 4px;
    padding: 8px;
    font-size: 11px;
    font-family: var(--font-mono);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
    margin: 0;
}

/* ── /AI Interactive Flow Cards ──────────────────────────────────────────── */

/* ── Help tab ─────────────────────────────────────────────────────────────── */
.stage-help-panel {
    padding: 8px 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.help-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-section-heading {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary);
}

.help-prose {
    font-size: 13px;
    line-height: 1.65;
    color: var(--text-primary);
    margin: 0;
}

.help-when-to-use {
    background: rgba(59, 130, 246, 0.06);
    border-left: 3px solid #3b82f6;
    border-radius: 0 6px 6px 0;
    padding: 10px 14px;
}

.help-dl {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
}

.help-dl-row {
    display: grid;
    grid-template-columns: minmax(110px, 150px) 1fr;
    gap: 12px;
    align-items: start;
}

.help-dl-term {
    font-size: 12px;
    font-family: var(--font-mono, monospace);
    color: #7c3aed;
    background: rgba(124, 58, 237, 0.08);
    padding: 2px 7px;
    border-radius: 4px;
    word-break: break-all;
    align-self: start;
    list-style: none;
}

.help-dl-def {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
}

.help-tips {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-tips li {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    padding-left: 20px;
    position: relative;
}

.help-tips li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: #3b82f6;
    font-weight: 700;
}

.help-tech-notes {
    background: var(--bg-secondary);
    border-radius: 6px;
    padding: 10px 14px;
}

.help-tech-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
}

.help-tech-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.help-tech-value {
    font-size: 12px;
    color: var(--text-primary);
}

.help-chip {
    font-size: 11px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1px 8px;
    color: var(--text-secondary);
}
/* ── /Help tab ────────────────────────────────────────────────────────────── */


/* ── AI-proposed edit card (08.22.26-ai-edit-apply-card) ─────────────────── */
.ai-edit-card {
    border: 1px solid var(--border, #d0d7de);
    border-left: 3px solid var(--accent, #0969da);
    border-radius: 6px;
    padding: 10px 12px;
    margin: 8px 0;
    background: var(--bg-subtle, #f6f8fa);
    font-size: 13px;
}
.ai-edit-card.applied { border-left-color: var(--success, #1a7f37); opacity: 0.85; }
.ai-edit-card-title { font-weight: 600; margin-bottom: 6px; }
.ai-edit-card-changes { margin: 0 0 8px 0; padding-left: 18px; }
.ai-edit-card-changes li { margin: 2px 0; word-break: break-word; }
.ai-edit-card-actions { display: flex; align-items: center; gap: 10px; }
.ai-edit-card-note { color: var(--text-muted, #57606a); font-size: 12px; }

/* ── AI surface handoff card (08.22.26-ai-surface-intent-routing-handoff) ──
   Rendered instead of attempting a request that escapes the sending
   surface's scope (a stage AI message that names another stage / an
   add-remove-step / ordering ask, or a Planner message that edits one
   existing stage). A suggestion, never a redirect -- nothing navigates
   until the button is clicked. Amber, not blue, to read as "elsewhere",
   not as a proposed change (that's .ai-edit-card's accent border). */
.ai-handoff-card {
    border: 1px solid var(--border, #d0d7de);
    border-left: 3px solid var(--attention, #9a6700);
    border-radius: 6px;
    padding: 10px 12px;
    margin: 8px 0;
    background: var(--bg-subtle, #f6f8fa);
    font-size: 13px;
}
.ai-handoff-card-title { font-weight: 600; margin-bottom: 6px; }
.ai-handoff-card-message {
    color: var(--text-muted, #57606a);
    font-style: italic;
    margin: 0 0 8px 0;
    word-break: break-word;
}
.ai-handoff-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.btn-ai-handoff {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    background: transparent;
    color: var(--attention, #9a6700);
    border: 1px solid var(--attention, #9a6700);
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn-ai-handoff:hover { opacity: 0.75; }
