/* Fermi-LLM - Styles v2.0 */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fb;
    --bg-panel: #ffffff;
    --bg-input: #f3f4f6;
    --bg-hover: #e9ecf0;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --accent: #4f46e5;
    --accent-hover: #6366f1;
    --accent-light: #eef2ff;
    --success: #16a34a;
    --success-light: #f0fdf4;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --error: #dc2626;
    --error-light: #fef2f2;
    --scheduled: #0d9488;
    --scheduled-light: #f0fdfa;
    --simulated: #7c3aed;
    --simulated-light: #f5f3ff;
    --border: #e5e7eb;
    --border-focus: #4f46e5;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-strong: rgba(0,0,0,0.35);
    --star-color: currentColor;  /* the ✦ in the Examples and Guide me buttons */
    --fav-color: #d99a00;        /* the selected favourite-model ★ */
    --brand-from: #4f46e5;       /* header brand gradient */
    --brand-to: #9333ea;
    --overlay: rgba(15, 23, 42, 0.45);
    --help-highlight: #f59e0b;   /* Help tour outline around the explained control */
    --success-hover: #15803d;
    --error-hover: #b91c1c;
    --surface-raised: #ffffff;
    --surface-translucent: rgba(255, 255, 255, 0.88);
    --card-gradient-end: #f7f7ff;
    --indigo-border: #c7d2fe;
    --success-border: #bbf7d0;
    --success-strong: #15803d;
    --info-bg: #eff6ff;
    --info-fg: #1d4ed8;
    --orange-bg: #fff7ed;
    --orange-fg: #c2410c;
    /* Code editor + syntax tokens (GitHub-light) */
    --editor-bg: #fafbfc;
    --editor-text: #24292e;
    --tok-comment: #6a737d;
    --tok-key: #22863a;
    --tok-string: #032f62;
    --tok-number: #005cc5;
    --tok-bool: #b31d28;
    --tok-kw: #d73a49;
    --tok-fn: #6f42c1;
    --tok-deco: #e36209;
    --diff-add-bg: #e6ffec;
    --diff-add-fg: #1a7f37;
    --diff-del-bg: #ffebe9;
    --diff-del-fg: #cf222e;
    --scroll-track: #f3f4f6;
    --scroll-thumb: #9ca3af;
    --scroll-thumb-hover: #6b7280;
    /* Inline SVG charts (SED, TS bars) */
    --chart-bg: #ffffff;
    --chart-frame: #d1d5db;
    --chart-grid: #eceff3;
    --chart-tick: #6b7280;
    --chart-label: #374151;
    --chart-lnl: #2eb840;
    color-scheme: light;
    --font-mono: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Consolas', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* Dark theme: set by the inline script in index.html (saved choice, else the
   OS preference) and by toggleTheme() in app.js. */
:root[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #111827;
    --bg-panel: #1e293b;
    --bg-input: #273449;
    --bg-hover: #334155;
    --text-primary: #e5e7eb;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-light: #272b4f;
    --success: #16a34a;
    --success-light: #11291d;
    --warning: #f59e0b;
    --warning-light: #2d2413;
    --error: #ef4444;
    --error-light: #3a1a1d;
    --scheduled: #2dd4bf;
    --scheduled-light: #11302d;
    --simulated: #a78bfa;
    --simulated-light: #2a1f4a;
    --border: #334155;
    --border-focus: #818cf8;
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-strong: rgba(0,0,0,0.6);
    --star-color: #f5b83d;       /* warm yellow */
    --fav-color: #f5b83d;
    --brand-from: #818cf8;
    --brand-to: #c084fc;
    --overlay: rgba(0, 0, 0, 0.6);
    --help-highlight: #facc15;
    --success-hover: #22c55e;
    --error-hover: #dc2626;
    --surface-raised: #1e293b;
    --surface-translucent: rgba(30, 41, 59, 0.88);
    --card-gradient-end: #1f2442;
    --indigo-border: #4f46e5;
    --success-border: #166534;
    --success-strong: #4ade80;
    --info-bg: #172554;
    --info-fg: #93c5fd;
    --orange-bg: #3b1d0c;
    --orange-fg: #fdba74;
    /* GitHub-dark */
    --editor-bg: #0d1117;
    --editor-text: #c9d1d9;
    --tok-comment: #8b949e;
    --tok-key: #7ee787;
    --tok-string: #a5d6ff;
    --tok-number: #79c0ff;
    --tok-bool: #ff7b72;
    --tok-kw: #ff7b72;
    --tok-fn: #d2a8ff;
    --tok-deco: #ffa657;
    --diff-add-bg: #12261e;
    --diff-add-fg: #7ee787;
    --diff-del-bg: #2d1517;
    --diff-del-fg: #ffa198;
    --scroll-track: #111827;
    --scroll-thumb: #64748b;
    --scroll-thumb-hover: #94a3b8;
    --chart-bg: #0f172a;
    --chart-frame: #475569;
    --chart-grid: #1e293b;
    --chart-tick: #94a3b8;
    --chart-label: #cbd5e1;
    --chart-lnl: #73de93;
    color-scheme: dark;
}

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

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

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

/* Keep the fixed application chrome at its intrinsic height.  Only the
   workspace should absorb vertical resizing and content pressure. */
.header,
.pipeline-progress,
.action-bar {
    flex: 0 0 auto;
}

/* Header */
.header {
    /* Three columns so the info strip stays centered whatever the widths of
       the left (menu, theme, title) and right (sign-in) groups. */
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    column-gap: 12px;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    min-height: 48px;
}
/* Brand: the app icon (the phone page's, in the theme's colourway), the name, and the tagline under it.
   fermi-llm-mark*-{30,60,90}.png are the 512px icons with the corners rounded (22%, as the phone's
   .hero img) and scaled down with Lanczos: a browser shrinking the square 512px PNG gives rough edges. */
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(79, 70, 229, 0.25));
}
:root[data-theme="dark"] .brand-mark.logo-l, :root:not([data-theme="dark"]) .brand-mark.logo-d { display: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--accent);
    background: linear-gradient(90deg, var(--brand-from), var(--brand-to));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.brand-tagline {
    margin: 2px 0 0;
    font-size: 11.5px;
    font-style: italic;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 600px) {
    .brand-tagline { display: none; }
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-center { display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 0; }
/* Info strip: slightly larger than the old inline badges. Versions are short
   and always shown whole; a long GPU name is cut and expands on hover. */
.header-center .session-badge,
.header-center .gpu-info { font-size: 11px; }
.header-center .gpu-info { max-width: 300px; }
.header-center #version-info { max-width: none; overflow: visible; }
.header-center .gpu-info:hover { max-width: none; overflow: visible; }
.header-right { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }

.model-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}
.model-status-dot.available { background: var(--success); }
.model-status-dot.no_gpu { background: var(--warning); }
.model-status-dot.loading { background: var(--warning); animation: pulse 1.5s infinite; }
.model-status-dot.error { background: var(--error); }
.gpu-info {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--accent);
    color: white;
    border-radius: 10px;
    font-weight: 500;
}
.session-badge {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
/* Settings menu (☰) and its Panels / Models flyouts */
.menu-wrap { position: relative; display: flex; }
.menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 200;
    min-width: 220px;
    padding: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px var(--shadow-strong);
}
.menu.hidden { display: none; }
/* Open, the ☰ button becomes a tab of the menu: the panel's colour, its
   sides running down into the menu (::after fills the gap and hides the
   menu's top border under it), the left edges one line, and a curved
   corner (::before) joining the tab's right side to the menu's top edge.
   The menu sits 6px under the 30px button; the corner radius is 8px. */
#main-menu-btn[aria-expanded="true"] {
    position: relative; z-index: 201;
    background: var(--bg-panel); color: var(--text-primary);
    border-color: var(--border); border-bottom-color: transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
#main-menu-btn[aria-expanded="true"]::after {
    content: ''; position: absolute; left: -1px; right: -1px; top: 100%; height: 8px;
    background: var(--bg-panel); border: 1px solid var(--border); border-width: 0 1px;
}
#main-menu-btn[aria-expanded="true"]::before {
    content: ''; position: absolute; left: 100%; top: calc(100% - 1px); width: 9px; height: 9px;
    background: radial-gradient(circle at 100% 0, transparent 7.6px, var(--border) 8px, var(--border) 8.6px, var(--bg-panel) 9px);
}
#main-menu-btn[aria-expanded="true"] + .menu { border-top-left-radius: 0; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible, .menu-sub.open > .menu-item {
    background: var(--bg-hover);
    outline: none;
}
.menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }
a.menu-item { text-decoration: none; }
.menu-ext { flex: none; color: var(--text-muted); font-size: 12px; }
.menu-item:disabled { color: var(--text-muted); cursor: not-allowed; background: transparent; }
.menu-label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* Keyboard shortcut hint on a menu item (app.js localizeShortcutHints) */
.menu-kbd { flex: none; color: var(--text-muted); font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }
.menu-detail {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.menu-item.has-sub::after { content: '\203A'; font-size: 16px; color: var(--text-muted); line-height: 1; }
.menu-sub { position: relative; }
.submenu {
    display: none;
    position: absolute;
    top: -5px;
    left: 100%;
    margin-left: 4px;
    min-width: 200px;
    padding: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px var(--shadow-strong);
}
/* Hover opens a flyout on devices that can hover; click/tap sets .open. */
@media (hover: hover) {
    .menu-sub:hover > .submenu { display: block; }
}
.menu-sub.open > .submenu { display: block; }
.submenu-models { min-width: 340px; max-height: min(70vh, 480px); overflow-y: auto; }
.menu-group-label {
    padding: 8px 10px 3px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.menu-check { width: 14px; flex: 0 0 14px; color: var(--accent); font-weight: 700; }
/* Model row with a favourite star (signed-in users; app.js renderModelMenu) */
.menu-row { display: flex; align-items: center; gap: 2px; }
.menu-row > .menu-item { flex: 1; min-width: 0; }
.fav-btn {
    flex: 0 0 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}
.fav-btn:hover:not(:disabled), .fav-btn:focus-visible { background: var(--bg-hover); color: var(--accent); outline: none; }
.fav-btn.active, .fav-btn.active:hover:not(:disabled), .fav-btn.active:focus-visible { color: var(--fav-color); }
.fav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
/* Unselected stars show only while the pointer is over their row (or keyboard focus is in it),
   so the menu is not a column of stars; touch screens without hover keep them visible. */
@media (hover: hover) {
    .fav-btn:not(.active) { opacity: 0; }
    .menu-row:hover .fav-btn:not(.active):not(:disabled),
    .menu-row:focus-within .fav-btn:not(.active):not(:disabled) { opacity: 1; }
    .menu-row:hover .fav-btn:not(.active):disabled { opacity: 0.35; }
}
.menu-tag {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 8px;
    background: var(--accent-light);
    color: var(--accent);
}
/* On/off switch drawn next to toggle items; .active on the item turns it on. */
.switch {
    position: relative;
    flex: 0 0 28px;
    width: 28px;
    height: 16px;
    border-radius: 8px;
    background: var(--scroll-thumb);
    transition: background 0.15s;
}
.switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.15s;
}
.menu-item.active .switch { background: var(--accent); }
.menu-item.active .switch::after { transform: translateX(12px); }
@media (max-width: 600px) {
    /* No room for flyouts: submenus expand inline under their item. */
    .submenu, .menu-sub:hover > .submenu {
        position: static;
        margin: 0 0 0 12px;
        box-shadow: none;
        border: none;
        border-left: 1px solid var(--border);
        border-radius: 0;
        display: none;
    }
    .menu-sub.open > .submenu { display: block; }
}

/* ============================================================
   Pipeline Progress Bar
   ============================================================ */
.pipeline-progress {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.pipeline-progress.hidden { display: none; }

/* Share: a split button on the right of the progress bar. The steps row
   is its own scroller (.progress-steps), so the button keeps its place
   and the steps slide beside it, never under it. The left part copies
   the link, the arrow opens the Share menu (the popover below). */
.share-split {
    margin-left: auto;
    flex-shrink: 0;
    display: inline-flex;
    align-items: stretch;
}
.share-session-btn, .share-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.share-session-btn { border-radius: var(--radius) 0 0 var(--radius); }
.share-menu-btn { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; padding: 6px 7px; }
.share-session-btn:hover, .share-menu-btn:hover { border-color: var(--accent); color: var(--accent); }
.share-menu-btn:hover { border-left: 1px solid var(--accent); margin-left: -1px; }
.share-session-btn.copied { border-color: var(--success); color: var(--success); }

/* The Share menu (openShareMenu): mode, the email box, the people shared
   with, Copy link, Revoke link. */
.share-popover {
    position: fixed; z-index: 1001; width: 340px; max-width: calc(100vw - 8px);
    max-height: calc(100vh - 8px); overflow-y: auto; padding: 10px;
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: 0 6px 24px var(--shadow-strong);
    display: flex; flex-direction: column; gap: 6px; font-size: 13px;
}
.share-popover .hidden { display: none; }
.share-pop-head { display: flex; align-items: baseline; gap: 8px; padding: 0 4px 2px; min-width: 0; }
.share-pop-head b { font-size: 14px; }
.share-pop-head span { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; background: var(--bg-input); border-radius: var(--radius-sm); }
.share-seg button {
    padding: 5px 6px; border: none; border-radius: calc(var(--radius-sm) - 1px); background: none;
    color: var(--text-secondary); font: inherit; font-size: 12.5px; cursor: pointer;
}
.share-seg button[aria-checked="true"] { background: var(--bg-panel); color: var(--text-primary); font-weight: 600; box-shadow: var(--shadow); }
.share-seg button:disabled { opacity: 0.45; cursor: not-allowed; }
.share-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.share-hint { margin: 0; padding: 0 4px; font-size: 11.5px; line-height: 1.4; color: var(--text-muted); }
.share-email-row { display: flex; gap: 6px; margin-top: 4px; }
.share-email-row input {
    flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-input); color: var(--text-primary); font: inherit; font-size: 13px;
}
.share-email-row input:focus { outline: none; border-color: var(--accent); }
.share-email-row .btn-primary { padding: 6px 12px; font-size: 13px; }
.share-note-row { display: flex; padding: 0 4px; }
.share-note-toggle { border: none; background: none; padding: 0; color: var(--accent); font: inherit; font-size: 11.5px; cursor: pointer; }
.share-note-toggle:hover { text-decoration: underline; }
.share-note-row input {
    flex: 1; min-width: 0; margin: 0 -4px; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-input); color: var(--text-primary); font: inherit; font-size: 12.5px;
}
.share-note-row input:focus { outline: none; border-color: var(--accent); }
.share-people { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.share-people-title { padding: 0 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.share-person { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 6px; padding: 3px 4px; border-radius: var(--radius-sm); }
.share-person:hover { background: var(--bg-hover); }
.share-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-how { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.share-remove {
    width: 20px; height: 20px; border: none; border-radius: 50%; background: none;
    color: var(--text-muted); font: inherit; font-size: 15px; line-height: 1; cursor: pointer;
}
.share-remove:hover { background: var(--bg-input); color: var(--error); }
.share-people-none { margin-top: 2px; }
.share-row {
    text-align: left; padding: 7px 8px; font-size: 13px; border: none; margin-top: 2px;
    border-radius: var(--radius-sm); background: none; color: var(--text-primary); cursor: pointer;
}
.share-row:hover, .share-row:focus-visible { background: var(--bg-hover); outline: none; }
.share-row.danger { color: var(--error); }
.share-row small { display: block; font-size: 11px; line-height: 1.35; color: var(--text-muted); margin-top: 1px; }
.share-row b { font-weight: 600; }

/* The steps scroll sideways inside their own row when the window is
   narrow; the Share button to their right stays put. */
.progress-steps {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius);
    background: var(--bg-input);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    min-width: 140px;
    flex-shrink: 0; /* keep its width; the row scrolls instead */
}

.progress-step.active {
    background: var(--warning-light);
    border-color: var(--warning);
    box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.15);
}
.progress-step.pass {
    background: var(--success-light);
    border-color: var(--success);
}
.progress-step.fail {
    background: var(--error-light);
    border-color: var(--error);
}
/* Waiting for the user (Review: a proposal to Apply or Discard): yellow
   like a running step, without the pulse. */
.progress-step.warn {
    background: var(--warning-light);
    border-color: var(--warning);
}
/* Not reached yet: quieter, since the bar is always on screen. */
.progress-step:not(.active):not(.pass):not(.fail):not(.warn) { opacity: 0.75; }

.step-indicator {
    flex-shrink: 0;
}

.step-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    background: var(--bg-hover);
    color: var(--text-muted);
    border: 2px solid var(--border);
    transition: all 0.3s ease;
}

.progress-step.active .step-icon {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
    animation: pulse 1.5s infinite;
}
.progress-step.pass .step-icon {
    background: var(--success);
    color: white;
    border-color: var(--success);
}
.progress-step.fail .step-icon {
    background: var(--error);
    color: white;
    border-color: var(--error);
}
.progress-step.warn .step-icon {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}

.step-info {
    min-width: 0;
}
.step-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}
.step-detail {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.progress-step.active .step-label { color: var(--warning); }
.progress-step.pass .step-label { color: var(--success); }
.progress-step.fail .step-label { color: var(--error); }
.progress-step.warn .step-label { color: var(--warning); }

.progress-connector {
    width: 24px;
    height: 2px;
    background: var(--border);
    flex-shrink: 0;
}

/* ============================================================
   Examples: the ✦ Examples button in the chat input bar and its popover
   ============================================================ */
.examples-btn {
    align-self: flex-end;
    padding: 8px 5px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.examples-btn:hover, .examples-btn[aria-expanded="true"] {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}
.examples-btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.btn-star { color: var(--star-color); }   /* warm yellow in dark mode only */

/* Opens upwards from the input bar (the .menu look: panel, border, shadow) */
.examples-popover {
    top: auto;
    bottom: calc(100% + 6px);
    left: 10px;
    width: min(420px, calc(100% - 20px));
    max-height: 60vh;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.examples-popover.hidden { display: none; }
.examples-group {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 6px 2px;
}
.examples-foot {
    font-size: 11px;
    color: var(--text-muted);
    padding: 6px 6px 2px;
    border-top: 1px solid var(--border);
    margin-top: 2px;
}

.demo-card {
    display: block;
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.demo-card:hover, .demo-card:focus-visible {
    background: var(--accent-light);
    border-color: var(--accent);
    outline: none;
}

.demo-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}
.demo-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.speed-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.speed-badge.fast {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid var(--success);
}
.speed-badge.slow {
    background: var(--warning-light);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.demo-card-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ============================================================
   Co-pilot: the ✧ Co-pilot button and its step card in the chat
   ============================================================ */

.copilot-card { max-width: 100%; }
.copilot-card .message-body { width: 100%; white-space: normal; }   /* the card is HTML, not text */
.copilot-head { display: flex; align-items: center; gap: 8px; }
.copilot-progress { font-size: 11px; color: var(--text-muted); flex: 1; }
.copilot-close {
    background: transparent; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 13px; padding: 0 2px;
}
.copilot-close:hover { color: var(--text-primary); }
.copilot-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.copilot-intro { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }

.copilot-opts { display: flex; flex-direction: column; gap: 5px; }
.copilot-opt {
    display: block; width: 100%; text-align: left; font: inherit; color: inherit;
    padding: 7px 9px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.copilot-opt:hover:not(:disabled) { border-color: var(--accent); }
.copilot-opt.selected { border-color: var(--accent); background: var(--accent-light); box-shadow: inset 3px 0 0 var(--accent); }
.copilot-opt:disabled { opacity: 0.55; cursor: not-allowed; }
.copilot-opt-head { display: flex; align-items: center; gap: 8px; }
.copilot-opt-label { flex: 1; font-weight: 600; font-size: 13px; color: var(--text-primary); }
.copilot-opt-why { display: block; font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.copilot-default { font-size: 10px; font-weight: 500; color: var(--text-muted); }
.copilot-est {
    font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 3px; white-space: nowrap;
    color: var(--accent); border: 1px solid var(--accent); background: var(--bg-panel);
}
.copilot-est.over { color: var(--error); border-color: var(--error); }

.copilot-extras { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 8px; font-size: 12px; color: var(--text-secondary); }
.copilot-chip {
    font: inherit; font-size: 12px; padding: 2px 9px; border-radius: 12px; cursor: pointer;
    background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border);
}
.copilot-chip.on { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

.copilot-src-search { position: relative; display: flex; gap: 6px; }
.copilot-src-search input, .copilot-ask input, .copilot-custom input {
    flex: 1; min-width: 0; padding: 6px 8px; font: inherit; font-size: 13px;
    background: var(--bg-input); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius); outline: none;
}
.copilot-src-search input:focus, .copilot-ask input:focus { border-color: var(--border-focus); }
.copilot-src-search input[type=search] { -webkit-appearance: none; appearance: none; }
.copilot-suggest {
    position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 50;
    display: flex; flex-direction: column; background: var(--bg-panel);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 18px var(--shadow-strong);
}
.copilot-suggest:empty { display: none; }
.copilot-suggest-item {
    text-align: left; font: inherit; font-size: 12px; padding: 6px 9px; cursor: pointer;
    background: transparent; border: none; color: var(--text-primary);
}
.copilot-suggest-item span { color: var(--text-muted); }
.copilot-suggest-head {
    font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 6px 9px 2px;
    border-top: 1px solid var(--border);
}
.copilot-suggest-head:first-child { border-top: none; }
.copilot-suggest-item:hover, .copilot-suggest-item:focus-visible { background: var(--accent-light); outline: none; }

.copilot-src { margin-top: 8px; font-size: 12px; color: var(--text-primary); }
.copilot-note { margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.copilot-note.error { color: var(--error); }
.copilot-note.warn { color: var(--warning); }
.copilot-grbs { margin-top: 10px; }
.copilot-custom { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.copilot-custom input { flex: 0 1 140px; }
.copilot-request {
    padding: 8px 10px; font-size: 13px; line-height: 1.45; color: var(--text-primary);
    background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius);
}
.copilot-change { margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.copilot-link { font: inherit; background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }

.copilot-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.copilot-card .btn-apply {
    padding: 5px 14px; font-size: 12px; font-weight: 600; color: #fff;
    background: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius-sm); cursor: pointer;
}
.copilot-card .btn-apply:hover:not(:disabled) { background: var(--accent-hover); }
.copilot-card .btn-apply:disabled { opacity: 0.5; cursor: not-allowed; }
.copilot-small {
    font: inherit; font-size: 12px; padding: 4px 10px; cursor: pointer; white-space: nowrap;
    background: var(--bg-panel); color: var(--text-secondary);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.copilot-small:hover { color: var(--text-primary); border-color: var(--accent); }
.copilot-ask { display: flex; gap: 6px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.copilot-answer { margin-top: 6px; font-size: 12px; line-height: 1.45; color: var(--text-primary); }
.copilot-answer.muted { color: var(--text-muted); font-style: italic; }

/* ============================================================
   Live Pipeline Log
   ============================================================ */
.pipeline-live-log {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 8px;
    font-size: 12px;
    font-family: var(--font-mono);
}

.live-log-entry {
    padding: 4px 8px;
    margin-bottom: 3px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.live-log-entry.active { background: var(--warning-light); }
.live-log-entry.pass { background: var(--success-light); }
.live-log-entry.fail { background: var(--error-light); }

.log-status-icon {
    flex-shrink: 0;
    font-size: 10px;
    width: 14px;
    text-align: center;
    line-height: 18px;
}
.log-status-icon.active { color: var(--warning); }
.log-status-icon.pass { color: var(--success); }
.log-status-icon.fail { color: var(--error); }

.log-agent {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    text-transform: uppercase;
    flex-shrink: 0;
    letter-spacing: 0.3px;
}
.log-agent.master {
    background: var(--accent-light);
    color: var(--accent);
}
.log-agent.validation {
    background: var(--success-light);
    color: var(--success);
}
.log-agent.system {
    background: var(--bg-input);
    color: var(--text-muted);
}

/* ============================================================
   Main layout
   ============================================================ */
.main-layout {
    flex: 1;
    display: flex;
    /* Scroll horizontally instead of clipping the rightmost panel on narrow
       (e.g. 13") screens. Panels shrink to their min-width, then a horizontal
       scrollbar appears so every panel stays reachable. */
    overflow-x: auto;
    overflow-y: hidden;
    /* Panels are cards on the page's background; the 8px gaps between them
       are the splitters (an inert one next to a rail). */
    padding: 8px;
    background: var(--bg-secondary);
    scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

/* Panels */
.panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: width 0.2s, flex 0.2s;
}
.panel.hidden { display: none; }
/* With YAML and Python both hidden, the code area leaves the row and the
   remaining panels share its width instead of leaving an empty grey gap.
   !important beats the inline flex a splitter drag leaves on a panel. */
.code-panels:not(:has(> .panel:not(.hidden))) { display: none; }
.main-layout:not(:has(.panel-code:not(.hidden):not(.folded))) > .panel:not(.folded) { flex-grow: 1 !important; }
/* Both editors folded: the code area is just their two rails. */
.code-panels:not(:has(> .panel:not(.hidden):not(.folded))) { flex: 0 0 auto !important; min-width: 0 !important; }

/* A folded panel is a rail: its header turned on its side, a click opens it
   (layoutPanels / openPanel in app.js). !important beats a dragged width. */
.panel.folded {
    flex: 0 0 30px !important;
    min-width: 30px !important;
    cursor: pointer;
}
.panel.folded > :not(.panel-header) { display: none !important; }
.panel.folded .panel-header {
    flex: 1;
    flex-direction: column;
    justify-content: flex-start;
    padding: 12px 0;
    border-bottom: none;
    container-type: normal;
}
.panel.folded .panel-header h2 { writing-mode: vertical-rl; gap: 9px; color: var(--text-secondary); }
.panel.folded .panel-header .panel-icon { display: block; }
/* New content in a panel: its header lights up for a moment (flashPanel). */
.panel.panel-updated { animation: panel-ring 1.6s ease-out; }
.panel.panel-updated .panel-header { animation: panel-flash 1.6s ease-out; }
@keyframes panel-ring {
    0%, 30% { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
    100% { box-shadow: 0 0 0 2px transparent, var(--shadow); }
}
@keyframes panel-flash {
    0%, 30% { background: var(--accent-light); }
}
.panel.folded .panel-actions, .panel.folded .panel-header > .agent-badge { display: none; }
.panel.folded:hover .panel-header { background: var(--bg-hover); }
.panel.folded:hover .panel-header h2 { color: var(--text-primary); }
.panel.folded .panel-header:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }

/* Panels are resized via draggable splitter bars inserted between them by
   initSplitters() in app.js (replaces the old CSS resize corner handle). */
.splitter {
    flex: 0 0 8px;
    /* Counted at its width when a container sizes to its content (the code
       area with both editors folded); an empty div otherwise counts as 0. */
    min-width: 8px;
    cursor: col-resize;
    background: transparent;
    position: relative;
    z-index: 5;
    touch-action: none;
}
/* The grab handle: a short pill that shows on hover and while dragging. */
.splitter::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 40px;
    margin: -20px 0 0 -2px;
    border-radius: 2px;
    background: var(--border);
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}
.splitter:hover::after { opacity: 1; background: var(--text-muted); }
.splitter.active::after { opacity: 1; background: var(--accent); height: 64px; margin-top: -32px; }
.splitter.splitter-inert { cursor: default; pointer-events: none; }
.splitter.splitter-hidden { display: none; } /* set by updateSplitterVisibility() */
body.col-resizing { cursor: col-resize; user-select: none; }
body.col-resizing .panel, body.col-resizing .code-panels { transition: none !important; }

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    min-height: 40px;
    /* Above the editor below it, so a button's hover label is not covered;
       the container lets narrow panels drop button labels (@container below). */
    position: relative;
    z-index: 3;
    container: panel-header / inline-size;
}
/* One line, whatever the width: icon, title (ellipsis when cramped), and
   on the code panels the generation dot. */
.panel-header h2 {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}
.panel-header .panel-icon { flex: none; color: var(--accent); }
.panel-header .panel-title { overflow: hidden; text-overflow: ellipsis; }
/* config.yaml / analysis.py read like an editor's file tab. */
.panel-header .file-name { font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; }
.panel-header h2 .status-dot { flex: none; width: 7px; height: 7px; }
.panel-header > .agent-badge, .panel-header .pipeline-badge { white-space: nowrap; }
.panel-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.panel-actions button {
    padding: 2px 8px;
    font-size: 11px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
/* Icon-only header buttons (Revert, Copy); data-hint is their hover label
   (not data-tip, which marks the plot points' hover cards). */
.panel-actions .icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    border-color: transparent;
}
.panel-actions .icon-btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border); }
/* Dim the icon, not the button, so the hover label stays readable. */
.panel-actions .icon-btn:disabled { opacity: 1; }
.panel-actions .icon-btn:disabled .btn-icon { opacity: 0.35; }
.panel-actions .icon-btn:disabled:hover { background: transparent; }
.panel-actions .icon-btn.copied { color: var(--success); }
.panel-actions:has(.icon-btn) { gap: 2px; }
.panel-actions .btn-icon { flex: none; display: block; }
.panel-actions [data-hint]::after {
    content: attr(data-hint);
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: var(--text-primary);
    color: var(--bg-panel);
    font: 500 11px/1.3 var(--font-sans);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.12s, transform 0.12s;
    z-index: 30;
}
/* Shown on a disabled button too (it explains what the button would do). */
.panel-actions [data-hint]:hover::after, .panel-actions [data-hint]:focus-visible::after {
    opacity: 1;
    transform: none;
    transition-delay: 0.25s;
}
/* Text buttons in a header: icon + label; the label drops on a narrow panel. */
.panel-actions .compare-btn { display: inline-flex; align-items: center; gap: 5px; }
/* A code panel squeezed to ~200px keeps its file name whole: the file icon
   says nothing the .yaml / .py does not. */
@container panel-header (max-width: 220px) {
    .panel-header .panel-icon { display: none; }
}
@container panel-header (max-width: 430px) {
    .panel-actions .btn-label { display: none; }
    .panel-actions .compare-btn, .panel-actions .notify-btn { padding: 3px 6px; }
}
.panel-actions button:hover { background: var(--bg-hover); color: var(--text-primary); }
.panel-actions button:disabled { opacity: 0.4; cursor: not-allowed; }
.panel-actions button:disabled:hover { background: var(--bg-input); color: var(--text-secondary); }
/* The bell: email the signed-in owner when the running pipeline ends. */
.panel-actions .notify-btn { display: inline-flex; align-items: center; gap: 4px; }
.panel-actions .notify-btn[hidden] { display: none; }   /* the class rule beat the hidden attribute */
.panel-actions .notify-btn .bell-icon { flex: none; }
.panel-actions .notify-btn.on { color: var(--success); border-color: var(--success); }
.panel-actions .notify-btn.on .bell-icon path:first-child { fill: currentColor; }
/* Per-panel Save: only visible while the editor has unsaved manual edits. */
.panel-actions .btn-save {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}
.panel-actions .btn-save:hover { background: var(--accent-hover); color: #fff; }
.panel-actions .btn-save.hidden,
#save-btn.hidden { display: none; }

.agent-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 500;
}
.agent-badge.master, .agent-badge:not(.validation) {
    background: var(--accent-light);
    color: var(--accent);
}
.agent-badge.validation {
    background: var(--success-light);
    color: var(--success);
}

/* Agent tags in chat messages */
.agent-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.agent-tag.master {
    background: var(--accent-light);
    color: var(--accent);
}
.agent-tag.validation {
    background: var(--success-light);
    color: var(--success);
}
.agent-tag.system {
    background: var(--bg-input);
    color: var(--text-muted);
}

/* Chat panel */
.panel-chat { flex: 0 1 340px; min-width: 280px; }
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.message {
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
}
.message.user {
    background: var(--accent);
    color: #ffffff;
    align-self: flex-end;
    max-width: 90%;
    border-bottom-right-radius: 2px;
}
.message.assistant {
    background: var(--bg-input);
    color: var(--text-primary);
    align-self: flex-start;
    max-width: 95%;
    border-bottom-left-radius: 2px;
}
.message-header {
    margin-bottom: 6px;
}
/* A Master or Validation Agent reply folds to its first line: a new user
   message folds every one above it, and its header opens it again. */
.message.collapsible .message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
}
.message.collapsible .message-header:hover { background: var(--bg-hover); }
.message.collapsible .message-header:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.message-summary {
    display: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--text-muted);
}
.message-toggle {
    flex: 0 0 auto;
    margin-left: auto;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-muted);
    transition: transform 0.15s ease;
}
.message.collapsible.collapsed .message-header { margin-bottom: 0; }
.message.collapsible.collapsed .message-summary { display: block; }
.message.collapsible.collapsed .message-toggle { transform: rotate(-90deg); }
.message.collapsible.collapsed .message-body,
.message.collapsible.collapsed .message-actions { display: none; }
/* The reply's notices (departures from the request) stay visible when folded. */
.message-notices { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 4px; }
.message-notice {
    font-size: 0.86em; line-height: 1.35; padding: 4px 8px; border-radius: 6px;
    color: var(--warning); background: var(--warning-light); border: 1px solid var(--warning);
}
.message-notice::before { content: '⚠ '; }
.message-notice code { font-size: 0.95em; }
.message.collapsible.collapsed .message-notices { margin-bottom: 0; }
.message.collapsible.collapsed .message-changes { margin-bottom: 0; }
/* Plan 3: the values the reply changed, the time window, an unclear
   phrase's reading and its alternative (changesHtml). Outside the fold. */
.message-changes {
    font-size: 0.84em; line-height: 1.4; margin: 6px 0 4px; padding: 5px 8px;
    border: 1px solid var(--border); border-radius: 6px; background: var(--bg-secondary);
    color: var(--text-secondary);
}
.message-changes ul { list-style: none; margin: 2px 0 0; padding: 0; }
.message-changes li { padding: 1px 0; overflow-wrap: anywhere; }
.message-changes code { font-size: 0.95em; color: var(--text-primary); }
.message-changes details summary { cursor: pointer; color: var(--text-muted); }
.message-changes .chg-label { font-weight: 600; color: var(--text-primary); margin-right: 4px; }
.message-changes .chg-n { color: var(--text-muted); margin-right: 5px; font-variant-numeric: tabular-nums; }
.message-changes .chg-by {
    font-size: 0.86em; padding: 0 5px; border-radius: 8px; white-space: nowrap;
    background: var(--bg-input); color: var(--text-secondary);
}
.message-changes .chg-by.chg-intent { background: var(--accent-light); color: var(--accent); }
.message-changes .chg-by.chg-rule { background: var(--warning-light); color: var(--warning); }
.message-changes .chg-by.chg-revert,
.message-changes .chg-by.chg-restore { background: var(--success-light); color: var(--success); }
.message-changes .chg-none { color: var(--text-muted); }
.message-changes .chg-window { margin-top: 3px; }
.message-changes .chg-reading { margin-top: 3px; }
.message-changes .chg-alt {
    font: inherit; padding: 0 6px; border: 1px solid var(--accent); border-radius: 10px;
    background: var(--accent-light); color: var(--accent); cursor: pointer;
}
.message-changes .chg-alt:hover { background: var(--accent); color: #fff; }
/* The History menu of the editor panels (openHistoryMenu). */
.history-menu {
    position: fixed; z-index: 60; width: 340px; max-width: calc(100vw - 16px); max-height: 60vh;
    display: flex; flex-direction: column; background: var(--surface-raised);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 8px 24px var(--shadow-strong);
}
.history-menu.hidden { display: none; }
.history-head { padding: 8px 12px 6px; font-weight: 600; font-size: 0.9em; border-bottom: 1px solid var(--border); }
.history-sub { font-weight: 400; color: var(--text-muted); margin-left: 4px; }
.history-empty { padding: 12px; color: var(--text-muted); font-size: 0.86em; }
.history-list { overflow-y: auto; padding: 4px; }
.history-item {
    display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left;
    padding: 6px 8px; border: 0; border-radius: var(--radius-sm); background: none;
    color: var(--text-primary); font: inherit; font-size: 0.86em; cursor: pointer;
}
.history-item:hover:not(:disabled) { background: var(--bg-hover); }
.history-item.current { cursor: default; background: var(--accent-light); }
.history-line { display: flex; align-items: baseline; gap: 6px; }
.history-id { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.history-label { font-weight: 500; }
.history-time { margin-left: auto; color: var(--text-muted); white-space: nowrap; }
.history-tag { font-size: 0.85em; padding: 0 5px; border-radius: 8px; background: var(--bg-input); color: var(--text-secondary); }
.history-tag.now { background: var(--accent); color: #fff; }
.history-detail { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-body { white-space: pre-wrap; word-wrap: break-word; }
.message-body strong { color: var(--accent); font-weight: 600; }
.message-body ul, .message-body ol { margin: 4px 0 4px 20px; }
.message-body li { margin: 2px 0; }
/* Edit and resend: a small button under the last message of the thread
   (refreshEditButtons), and the strip above the message box while editing. */
.message-foot {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
}
.message-edited { opacity: 0.75; font-style: italic; }
.msg-edit {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #ffffff;
    border-radius: 4px;
    font-size: 11px;
    padding: 1px 7px;
    cursor: pointer;
}
.msg-edit:hover { background: rgba(255, 255, 255, 0.25); }
.msg-edit:focus-visible { outline: 2px solid #ffffff; outline-offset: 1px; }
.chat-edit-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-top: 1px solid var(--border);
    background: var(--bg-input);
    font-size: 12px;
    color: var(--text-muted);
}
.chat-edit-bar span { flex: 1; }
.chat-edit-bar button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 4px;
    font-size: 12px;
    padding: 2px 8px;
    cursor: pointer;
}
.chat-edit-bar button:hover { background: var(--bg-hover); }
.chat-edit-bar.hidden, .message-foot.hidden, .msg-edit.hidden { display: none; }

.chat-input-area {
    position: relative;   /* anchors the Examples popover */
    padding: 10px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;      /* message box on its own line, buttons below */
    gap: 8px;
}
.chat-input-wrap {
    position: relative;   /* anchors the resize grip */
    flex: 1 1 100%;
    display: flex;
}
.chat-input-area textarea {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 10px 8px 22px;   /* room for the grip at the top left */
    border-radius: var(--radius);
    /* Resized from the grip at the top left (initChatInputResize), not from
       the browser's bottom-right corner handle. */
    resize: none;
    height: 72px;
    min-height: 60px;
    max-height: 60vh;
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}
.chat-input-area textarea:focus { border-color: var(--border-focus); }
/* Top-left grip: drag up to grow the message box, down to shrink it. */
.chat-input-grip {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    cursor: ns-resize;
    touch-action: none;
    border-radius: 3px;
    color: var(--text-muted);
    /* two short diagonal lines, like the browser's corner handle, mirrored */
    background:
        linear-gradient(135deg, transparent 42%, currentColor 42%, currentColor 58%, transparent 58%) 0 0 / 8px 8px no-repeat,
        linear-gradient(135deg, transparent 45%, currentColor 45%, currentColor 55%, transparent 55%) 0 0 / 14px 14px no-repeat;
}
.chat-input-grip:hover, .chat-input-grip.dragging { color: var(--accent); }
.chat-input-grip:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }
body.resizing-chat-input { cursor: ns-resize; user-select: none; }
.chat-input-area textarea::placeholder { color: var(--text-muted); }
#send-btn {
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s;
    align-self: flex-end;
}
#send-btn { margin-left: auto; }   /* Examples left, Send right */
#send-btn:hover { background: var(--accent-hover); }
#send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Code panels */
.code-panels {
    flex: 1;
    display: flex;
}
.panel-code { flex: 1; min-width: 200px; }

/* Editor + syntax-highlight backdrop. The textarea is the editable source of
   truth (transparent text + visible caret); the <pre> behind it shows the
   colorized copy. Both MUST share identical font metrics, padding and
   white-space so the layers line up exactly. */
.editor-wrap {
    --gutter-w: 44px;
    flex: 1;
    position: relative;
    min-height: 0;
    overflow: hidden;
    background: var(--editor-bg);
}
/* Line numbers (syncGutter keeps them scrolled with the editor). */
.editor-gutter {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--gutter-w);
    box-sizing: border-box;
    padding: 12px 10px 12px 0;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    white-space: pre;
    text-align: right;
    overflow: hidden;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    user-select: none;
    pointer-events: none;
    z-index: 1;
}
/* An empty editor: an icon and a line in place of a blank sheet. */
.editor-empty {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
}
.editor-empty svg { color: var(--accent); opacity: 0.5; margin-bottom: 4px; }
.editor-empty small { font-size: 12px; opacity: 0.85; }
.code-editor:placeholder-shown ~ .editor-gutter,
.code-editor.hidden ~ .editor-gutter { display: none; }
.code-editor:placeholder-shown:not(.hidden) ~ .editor-empty { display: flex; }
.code-editor,
.editor-highlight {
    margin: 0;
    border: none;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    tab-size: 2;
    white-space: pre;
    overflow: auto;
}
.code-editor {
    position: absolute;
    inset: 0 0 0 var(--gutter-w);
    background: transparent;
    color: transparent;
    caret-color: var(--editor-text);
    resize: none;
    outline: none;
    z-index: 2;
}
.editor-highlight {
    position: absolute;
    inset: 0 0 0 var(--gutter-w);
    z-index: 1;
    pointer-events: none;
    color: var(--editor-text);
    background: transparent;
}
/* When the highlight layer is empty (e.g. before generation), let the
   textarea's own color show so the placeholder remains legible. */
.editor-highlight:empty + .code-editor { color: var(--editor-text); }

/* Syntax token colors (GitHub-light / GitHub-dark, see :root) */
.tok-comment { color: var(--tok-comment); font-style: italic; }
.tok-key     { color: var(--tok-key); }
.tok-string  { color: var(--tok-string); }
.tok-number  { color: var(--tok-number); }
.tok-bool    { color: var(--tok-bool); }
.tok-kw      { color: var(--tok-kw); }
.tok-fn      { color: var(--tok-fn); }
.tok-deco    { color: var(--tok-deco); }
.code-editor::placeholder { color: var(--text-muted); }
.code-editor.hidden, .editor-highlight.hidden { display: none; }

/* Regeneration proposal: diff view + Apply/Discard banner (feedback #7) */
.proposal-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--accent-light);
    border-bottom: 1px solid var(--accent);
    font-size: 12px;
    color: var(--text-primary);
}
.proposal-banner.hidden { display: none; }
.proposal-text { flex: 1; }
.proposal-banner .btn-apply,
.message-actions .btn-apply {
    padding: 3px 12px;
    font-size: 12px;
    font-weight: 600;
    background: var(--accent);
    color: white;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.proposal-banner .btn-apply:hover,
.message-actions .btn-apply:hover { background: var(--accent-hover); }
.proposal-banner .btn-discard,
.message-actions .btn-discard {
    padding: 3px 12px;
    font-size: 12px;
    background: var(--bg-panel);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.proposal-banner .btn-discard:hover,
.message-actions .btn-discard:hover { background: var(--bg-hover); color: var(--text-primary); }
.message-actions button:disabled { opacity: 0.6; cursor: default; }

/* Choice buttons under a chat message (e.g. a follow-up that needs a new setup) */
.message-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.message-actions-note { font-size: 11px; color: var(--text-muted); }

.diff-view {
    position: absolute;
    inset: 0;
    z-index: 3;
    margin: 0;
    padding: 12px;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    white-space: pre;
    background: var(--editor-bg);
    color: var(--editor-text);
}
.diff-view.hidden { display: none; }
.diff-view.inline {
    position: static;
    max-height: 280px;
    margin-top: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.diff-line { display: block; padding: 0 4px; }
.diff-line.diff-add { background: var(--diff-add-bg); color: var(--diff-add-fg); }
.diff-line.diff-del { background: var(--diff-del-bg); color: var(--diff-del-fg); }
.diff-line.diff-com { background: color-mix(in srgb, var(--tok-comment) 12%, transparent); color: var(--tok-comment); }

/* Action-bar button while a proposal is pending */
.btn-attention {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
}
.result-card.warn { border-left-color: var(--warning); }
.product-checks { margin: 4px 0 0; padding-left: 0; list-style: none; font-size: 12px; }
.product-checks li { margin: 2px 0; }
.result-card details summary { cursor: pointer; font-size: 12px; color: var(--accent); }

/* Download-all-outputs link in the Results panel */
.btn-download-all {
    display: inline-block;
    padding: 6px 14px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
}
.btn-download-all:hover { background: var(--accent-hover); }

/* Structured download card in Pipeline Results */
.download-card {
    padding: 14px;
    border: 1px solid var(--border);
    background: linear-gradient(145deg, var(--surface-raised) 0%, var(--card-gradient-end) 100%);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.download-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.download-card-header h4 {
    margin: 0 0 2px;
    color: var(--text-primary);
    font-size: 13px;
}
.download-card-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.35;
}
.download-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 10px;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 17px;
    font-weight: 700;
}
.download-bundle-btn {
    display: flex;
    align-items: center;
    min-width: 0;
    text-decoration: none;
    border-radius: 9px;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s,
                background 0.15s;
}
/* The Downloads card's three buttons: YAML + Python, All outputs, Logs. */
.download-main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px;
}
.download-bundle-btn {
    gap: 10px;
    padding: 10px 11px;
    color: #fff;
    background: linear-gradient(135deg, #4338ca 0%, #6366f1 100%);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.22);
}
.download-bundle-btn:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}
/* One colour per button: the files that ran (indigo, above), all outputs
   (teal), the logs (burnt orange) and the notebook (slate); white text
   stays readable on each. */
.download-bundle-btn.outputs {
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.22);
}
.download-bundle-btn.outputs:hover { box-shadow: 0 6px 16px rgba(13, 148, 136, 0.3); }
.download-bundle-btn.logs {
    background: linear-gradient(135deg, #9a3412 0%, #c2410c 100%);
    box-shadow: 0 4px 12px rgba(194, 65, 12, 0.22);
}
.download-bundle-btn.logs:hover { box-shadow: 0 6px 16px rgba(194, 65, 12, 0.3); }
.download-bundle-btn.notebook {
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
    box-shadow: 0 4px 12px rgba(51, 65, 85, 0.22);
}
.download-bundle-btn.notebook:hover { box-shadow: 0 6px 16px rgba(51, 65, 85, 0.3); }
.download-bundle-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    height: 27px;
    padding: 0 7px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.download-bundle-badge {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.24);
    color: #fff;
}
.download-btn-copy {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    line-height: 1.25;
}
.download-btn-copy strong {
    overflow: hidden;
    font-size: 11px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.download-btn-copy small {
    overflow: hidden;
    margin-top: 2px;
    font-size: 9px;
    font-weight: 400;
    opacity: 0.72;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.download-btn-arrow {
    margin-left: auto;
    flex: 0 0 auto;
    font-size: 14px;
    opacity: 0.7;
}
.download-bundle-btn:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* Results panel */
.panel-results { flex: 0 1 350px; min-width: 280px; }
.results-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-size: 13px;
}

.result-card {
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 10px;
    border-left: 3px solid var(--border);
}
.result-card.success { border-left-color: var(--success); }
.result-card.fail { border-left-color: var(--error); }
.result-card.aborted { border-left-color: var(--error); background: var(--error-light); }
.result-card.running { border-left-color: var(--warning); }
.result-card.info { border-left-color: var(--accent); background: var(--accent-light); }
.result-card.info h4 { color: var(--accent); }

.result-card h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.result-card .result-note {
    font-size: 11px;
    color: var(--text-muted);
    margin: 6px 0 0;
    line-height: 1.4;
}
.result-card td span[title] {
    color: var(--text-muted);
    border-bottom: 1px dotted var(--text-muted);
    cursor: help;
}

.result-card pre {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
}

.pipeline-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 600;
}
.pipeline-badge.idle { background: var(--bg-input); color: var(--text-muted); }
.pipeline-badge.running { background: var(--warning-light); color: var(--warning); }
.pipeline-badge.complete { background: var(--success-light); color: var(--success); }
.pipeline-badge.error, .pipeline-badge.validation_failed, .pipeline-badge.script_blocked { background: var(--error-light); color: var(--error); }
.pipeline-badge.aborted { background: var(--error-light); color: var(--error); }

/* Explain panel */
.panel-explain { flex: 0 1 300px; min-width: 250px; }
.explain-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-size: 13px;
    line-height: 1.6;
}
.explain-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.explain-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 6px;
}
.explain-section p { color: var(--text-secondary); margin-bottom: 6px; }
.explain-section ol, .explain-section ul { margin-left: 16px; color: var(--text-secondary); }
.explain-section ul { list-style: disc; margin-bottom: 6px; }
.explain-section li { margin: 3px 0; }

.explain-log { margin-top: 8px; }
.explain-entry {
    padding: 8px 10px;
    margin-bottom: 6px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 12px;
    border-left: 2px solid var(--accent);
}
.explain-entry.validation { border-left-color: var(--success); }
.explain-entry.system { border-left-color: var(--text-muted); }
.explain-entry .entry-time {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.explain-entry .entry-agent {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 4px;
}
.explain-entry .entry-agent.master { color: var(--accent); }
.explain-entry .entry-agent.validation { color: var(--success); }
.explain-entry .entry-agent.system { color: var(--text-muted); }

/* Status dots */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.idle { background: var(--text-muted); }
.status-dot.active { background: var(--success); }
.status-dot.error { background: var(--error); }
.status-dot.running {
    background: var(--warning);
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Action bar */
.action-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    position: relative;
}
.monitor-next {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
    padding: 3px 6px 3px 8px;
    font-size: 11px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    min-width: 0;
}
.monitor-next label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; min-width: 0; }
.monitor-next #monitor-next-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.monitor-next.on { border-color: var(--accent); color: var(--accent); }
.monitor-next input:disabled + span, .monitor-next:has(input:disabled) { opacity: 0.6; }
.monitor-caret {
    padding: 0 5px;
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
}
.monitor-caret:disabled { cursor: default; }
.monitor-panel {
    position: absolute;
    left: 16px;
    bottom: calc(100% + 6px);
    z-index: 60;
    width: min(480px, calc(100vw - 32px));
    padding: 10px 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    font-size: 12px;
}
.monitor-panel-title { font-weight: 600; margin-bottom: 4px; }
.monitor-panel .rc-hint { margin: 0 0 4px; }
.btn-primary {
    padding: 8px 24px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--success-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger {
    padding: 8px 18px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s;
}
.btn-danger:hover:not(:disabled) { background: var(--error-hover); }
.btn-danger:disabled {
    /* Nothing to abort: a quiet outline instead of a red button. */
    cursor: not-allowed;
    background: transparent;
    color: var(--text-muted);
    box-shadow: inset 0 0 0 1px var(--border);
}
.btn-secondary {
    padding: 8px 16px;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.global-status {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
}

/* Scrollbar (WebKit/Blink; Firefox uses scrollbar-color below) */
* { scrollbar-color: var(--scroll-thumb) var(--scroll-track); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scroll-track); }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }

/* Responsive */
@media (max-width: 1200px) {
    .panel-chat { flex: 0 0 280px; }
    .panel-explain { flex: 0 0 240px; }
    .gpu-info { display: none; }
    .progress-step { min-width: 110px; padding: 4px 8px; }
    .step-detail { max-width: 140px; }
}
/* Outputs panel */
.panel-outputs { flex: 0 1 460px; min-width: 340px; }
.outputs-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-size: 13px;
}

@media (max-width: 900px) {
    .main-layout { flex-direction: column; }
    .splitter { display: none; } /* stacked layout: no horizontal resizing */
    .panel-chat, .panel-explain, .panel-results, .panel-outputs { flex: 0 0 250px; }
    .code-panels { flex-direction: column; }
    .header { grid-template-columns: 1fr auto; row-gap: 6px; }
    .header-center { grid-column: 1 / -1; grid-row: 2; }
    .progress-steps { flex-wrap: wrap; gap: 4px; }
    .progress-connector { display: none; }
    /* Stacked: a folded panel is a strip with its name across. */
    .main-layout, .code-panels { gap: 8px; }
    .panel.folded { flex: 0 0 40px !important; min-width: 0 !important; }
    .panel.folded .panel-header { flex-direction: row; padding: 0 12px; }
    .panel.folded .panel-header h2 { writing-mode: horizontal-tb; }
}

/* ============================================================
   Long-run confirmation dialog
   ============================================================ */
#run-confirm-overlay,
#abort-confirm-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.run-confirm-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px var(--shadow-strong);
    max-width: 480px;
    width: calc(100% - 48px);
    padding: 20px 24px;
}

.run-confirm-box h3 {
    color: var(--warning);
    font-size: 1.05rem;
    margin-bottom: 10px;
}

.abort-confirm-box h3 { color: var(--error); }

.run-confirm-box p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 10px;
}

.run-confirm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.run-confirm-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.run-confirm-table td.rc-min {
    text-align: right;
    font-family: var(--font-mono);
    white-space: nowrap;
}

/* Run-limit dialog: the user's running sessions with Open / Abort. */
.rl-table td { vertical-align: middle; overflow-wrap: anywhere; }
.rl-table td.rl-actions { text-align: right; white-space: nowrap; width: 1%; }
.rl-table td.rl-actions button { padding: 3px 10px; font-size: 0.8rem; margin-left: 4px; }

.run-confirm-box .rc-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.run-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

/* ============================================================
   Time-based ETA bar (running pipeline)
   ============================================================ */
#eta-container {
    margin: 10px 0 12px;
}

.eta-track {
    height: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.eta-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 4px;
    transition: width 1s linear;
}

.eta-label {
    margin-top: 5px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* ============================================================
   Authentication (Google Sign-In) + My Tasks
   ============================================================ */
.auth-area { display: flex; align-items: center; }
/* One Sign in button; its chooser lists Google, ORCID and guest. */
.signin-wrap { position: relative; display: flex; align-items: center; }
.signin-wrap.hidden { display: none; }
.signin-btn {
    height: 30px; padding: 0 12px; font: inherit; font-size: 13px; font-weight: 600;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--accent); color: #fff; cursor: pointer;
}
.signin-btn:hover { filter: brightness(1.08); }
.signin-btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.signin-chooser { left: auto; right: 0; min-width: 250px; padding: 6px; }
.signin-row { display: flex; justify-content: center; padding: 4px 6px 8px; }
.signin-provider { padding: 8px 10px; }
.signin-provider .orcid-glyph { flex: none; }
.signin-provider .inst-glyph { flex: none; color: var(--accent); }
.menu-hint { display: block; font-size: 11px; color: var(--text-muted); font-weight: 400; }
.gsi-btn-wrap {
    display: flex; align-items: center; min-height: 40px;
    /* Google's button is a light-scheme iframe; in a dark page a mismatched
       color-scheme makes the browser paint a white box behind it. */
    color-scheme: light;
}
.user-orcid {
    display: inline-flex; align-items: center; gap: 5px; margin-top: 2px;
    font-size: 11px; color: var(--text-secondary); text-decoration: none;
}
.user-orcid:hover span { text-decoration: underline; }
.user-orcid.hidden { display: none; }
.user-orcid .orcid-glyph { width: 14px; height: 14px; }
.user-email.muted-note { font-style: italic; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.user-menu { position: relative; display: flex; align-items: center; }
.user-menu.hidden { display: none; }
.avatar-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0;
    border: 1px solid var(--border); border-radius: 50%;
    background: var(--accent); color: #fff; cursor: pointer; overflow: hidden;
    font-size: 14px; font-weight: 600;
}
.avatar-btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.user-avatar { width: 100%; height: 100%; object-fit: cover; }
.account-popover { left: auto; right: 0; min-width: 200px; }
.account-info {
    display: flex; flex-direction: column; gap: 2px;
    padding: 8px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
}
.user-name {
    font-size: 13px; font-weight: 600; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-email {
    font-size: 11px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Modal */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: var(--overlay);
    display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal {
    background: var(--bg-panel); color: var(--text-primary);
    width: min(560px, 92vw); max-height: 80vh; display: flex; flex-direction: column;
    border-radius: var(--radius); box-shadow: 0 12px 40px var(--shadow-strong);
    border: 1px solid var(--border);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; margin: 0; }
.modal-close {
    background: none; border: none; font-size: 22px; line-height: 1;
    color: var(--text-muted); cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--text-primary); }
.mytasks-list { overflow-y: auto; padding: 10px 14px 16px; }
.task-item {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.task-item:hover { background: var(--bg-hover); border-color: var(--accent); }
.task-item.current { border-color: var(--accent); background: var(--accent-light); }
.task-title {
    font-size: 13px; font-weight: 600; color: var(--text-primary);
    margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-muted); flex-wrap: wrap; }
.task-status {
    text-transform: capitalize; padding: 1px 8px; border-radius: 999px;
    background: var(--bg-input); color: var(--text-secondary);
}
.task-status.complete { background: var(--success-light); color: var(--success); }
.task-status.error, .task-status.validation_failed { background: var(--error-light); color: var(--error); }
.task-status.running { background: var(--warning-light); color: var(--warning); }
.task-badge {
    padding: 1px 8px; border-radius: 999px;
    background: var(--accent-light); color: var(--accent); font-weight: 600;
}

/* Suggestion tickets (modal views, unread dots) */
.ticket-modal { width: min(640px, calc(100vw - 32px)); max-height: 85vh; }
.ticket-body { overflow-y: auto; padding: 12px 18px 16px; }
.ticket-hint { font-size: 13px; color: var(--text-secondary); margin: 4px 0 10px; }
.ticket-error { font-size: 12px; color: var(--error); margin: 4px 0; }
.ticket-error.hidden { display: none; }
.ticket-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ticket-form { display: flex; flex-direction: column; gap: 10px; }
.ticket-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.ticket-form label.ticket-check { flex-direction: row; align-items: center; gap: 6px; }
.ticket-form input[type="text"], .ticket-form input[type="email"], .ticket-form textarea,
.ticket-form select, .ticket-toolbar select, .ticket-meta select {
    font: inherit; font-size: 13px; color: var(--text-primary);
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 6px 8px;
}
.ticket-form textarea { resize: vertical; min-height: 60px; }
.ticket-form input:focus, .ticket-form textarea:focus, .ticket-form select:focus {
    outline: none; border-color: var(--border-focus);
}
.ticket-form .run-confirm-actions { margin-top: 4px; }
.menu-note { margin-left: auto; font-size: 11px; color: var(--success); }
/* Email notifications dialog (account menu) */
.notify-prefs { display: flex; flex-direction: column; gap: 8px; }
.notify-pref { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; cursor: pointer; }
.notify-pref input[type="checkbox"] { margin-top: 3px; flex: none; }
.notify-pref span { display: flex; flex-direction: column; gap: 2px; }
.notify-pref small { color: var(--text-secondary); font-size: 12px; }
.notify-sub { margin: -2px 0 4px 24px; padding-left: 10px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.notify-sub.disabled { opacity: 0.5; }
.notify-pref-num { flex-wrap: wrap; align-items: center; color: var(--text-secondary); }
.notify-pref-num input[type="number"] { width: 60px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-primary); color: var(--text-primary); font: inherit; }
.notify-prefs .run-confirm-actions { margin-top: 8px; align-items: center; }
.ticket-meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    font-size: 12px; color: var(--text-muted); margin-bottom: 10px;
}
.ticket-text { font-size: 13px; line-height: 1.5; color: var(--text-primary); white-space: pre-wrap; overflow-wrap: anywhere; }
.ticket-original { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.ticket-thread { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.ticket-comment {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-secondary);
}
.ticket-comment.admin { border-color: var(--indigo-border); background: var(--accent-light); }
.ticket-comment.internal { border-style: dashed; background: var(--warning-light); }
.ticket-comment-meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    font-size: 11px; color: var(--text-muted); margin-bottom: 4px;
}
.ticket-comment-meta strong { color: var(--text-primary); font-size: 12px; }
.ticket-internal-tag { color: var(--warning); font-weight: 600; }
.ticket-event { font-size: 11px; color: var(--text-muted); text-align: center; font-style: italic; }
.ticket-link {
    background: none; border: none; padding: 0; font: inherit; font-size: 12px;
    color: var(--accent); cursor: pointer; text-decoration: underline;
}
.ticket-status {
    padding: 1px 8px; border-radius: 999px;
    background: var(--bg-input); color: var(--text-secondary);
}
.ticket-status.open { background: var(--info-bg); color: var(--info-fg); }
.ticket-status.triaged, .ticket-status.in_progress { background: var(--warning-light); color: var(--warning); }
.ticket-status.done { background: var(--success-light); color: var(--success); }
.unread-dot {
    display: inline-block; width: 8px; height: 8px; flex: 0 0 8px;
    border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle;
}
.unread-dot.hidden { display: none; }
/* Red count on the avatar: replies the user has not read, plus for an admin
   the tickets no admin has opened. Empty text falls back to a plain dot. */
.avatar-unread {
    position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px;
    padding: 0 4px; box-sizing: border-box; border-radius: 999px;
    background: var(--error); color: #fff; border: 2px solid var(--bg-primary);
    font-size: 10px; font-weight: 700; line-height: 12px; text-align: center;
    pointer-events: none;
}
.avatar-unread:empty { min-width: 10px; width: 10px; height: 10px; padding: 0; }
.avatar-unread.hidden { display: none; }
.menu-badge {
    display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 8px;
    border-radius: 999px; background: var(--error); color: #fff;
    font-size: 11px; font-weight: 700; line-height: 16px; text-align: center;
}
.menu-badge.hidden { display: none; }
.menu-item.hidden { display: none; }

/* ============================================================
   Header icon buttons + task sidebar (ChatGPT-style)
   ============================================================ */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; font-size: 16px; line-height: 1;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: transparent; color: var(--text-secondary); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* Workspace row wraps the pinned sidebar + the (horizontally scrolling) panels */
.workspace-row { flex: 1 1 0; display: flex; min-height: 0; overflow: hidden; }

.task-sidebar {
    /* --sidebar-w is the width the user dragged it to (initSidebarResize). */
    flex: 0 0 var(--sidebar-w, 250px); display: flex; flex-direction: column;
    background: var(--bg-secondary); border-right: 1px solid var(--border);
    overflow: hidden; transition: flex-basis 0.15s ease; position: relative;
}
/* Drag handle on the sidebar's right edge, like the panel splitters. */
.sidebar-resizer {
    position: absolute; top: 0; right: 0; bottom: 0; width: 6px; z-index: 6;
    cursor: col-resize; touch-action: none; transition: background 0.15s;
}
.sidebar-resizer:hover, .sidebar-resizer.active, .sidebar-resizer:focus-visible {
    background: var(--accent); outline: none;
}
body.col-resizing .task-sidebar { transition: none; }
.task-sidebar.collapsed { flex-basis: 0; width: 0; border-right: none; overflow: hidden; }
.task-sidebar.collapsed > * { display: none; }
/* Folded (foldSidebar): a 30px rail with its name on its side, as .panel.folded. */
.task-sidebar.folded { flex-basis: 30px; }
.task-sidebar.folded > :not(.sidebar-rail) { display: none; }
.sidebar-rail { display: none; }
.task-sidebar.folded > .sidebar-rail {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 9px;
    padding: 12px 0; border: none; background: none; cursor: pointer;
    color: var(--text-secondary); font: inherit; font-size: 13px; font-weight: 600;
}
.sidebar-rail span { writing-mode: vertical-rl; }
.sidebar-rail:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-rail:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
.sidebar-top .sidebar-fold-btn { flex: 0 0 auto; align-self: center; }

.sidebar-top { padding: 10px; display: flex; gap: 6px; }
.new-project-btn {
    flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
    padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-panel); color: var(--accent); cursor: pointer;
}
.new-project-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.new-task-btn {
    flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 12px; font-size: 13px; font-weight: 600;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-panel); color: var(--text-primary); cursor: pointer;
}
.new-task-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.new-task-btn .plus { font-size: 16px; font-weight: 700; color: var(--accent); }

/* State-keyword chips under the search box (renderSearchChips). */
.search-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: -2px 10px 6px; }
.search-chips[hidden] { display: none; }
.search-chips button {
    font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--border); background: var(--bg-panel); color: var(--text-muted);
}
.search-chips button b { color: var(--text-primary); font-weight: 700; }
.search-chips button:hover { border-color: var(--accent); color: var(--accent); }
.search-chips button.on { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.search-chips button.on b { color: var(--accent); }

/* Now and Scheduled cards over the list (renderSidebarNow): a headline and
   one line each; "on" while the list is filtered to them. */
.sidebar-now { display: flex; flex-direction: column; gap: 4px; margin: 0 10px 6px; }
.sidebar-now[hidden] { display: none; }
.now-card {
    display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left;
    padding: 6px 9px 6px 10px; border: 1px solid var(--border); border-left-width: 3px;
    border-radius: var(--radius); background: var(--bg-panel); color: var(--text-primary); cursor: pointer;
}
.now-card b { font-size: 12px; font-weight: 600; }
.now-card span { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-card:hover { background: var(--bg-hover); }
.now-card.going { border-left-color: var(--accent); }
.now-card.ok { border-left-color: var(--success); }
.now-card.warn { border-left-color: var(--warning); }
.now-card.bad { border-left-color: var(--error); }
.now-card.scheduled { border-left-color: var(--scheduled); }
.now-card.on { background: var(--accent-light); border-color: var(--accent); }
.now-pill {
    font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--accent); background: var(--accent-light); color: var(--accent); white-space: nowrap;
}
.now-pill[hidden] { display: none; }
.now-pill.ok { border-color: var(--success); color: var(--success); background: var(--success-light); }
.now-pill.warn { border-color: var(--warning); color: var(--warning); background: var(--warning-light); }
.now-pill.bad { border-color: var(--error); color: var(--error); background: var(--error-light); }

/* Search box under "New session" (renderTaskList filters the rows). */
.sidebar-search {
    display: flex; align-items: center; gap: 6px; margin: -4px 10px 6px;
    padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-panel); color: var(--text-muted);
}
.sidebar-search[hidden] { display: none; }
.sidebar-search:focus-within { border-color: var(--accent); color: var(--accent); }
.sidebar-search input {
    flex: 1; min-width: 0; padding: 6px 0; font-size: 12px; border: none; outline: none;
    background: transparent; color: var(--text-primary);
}
.sidebar-search input::placeholder { color: var(--text-muted); }
/* Keyword tokens in the bar (renderSearchTokens): a pill with × before the caret. */
.search-tokens { display: flex; gap: 3px; flex-wrap: wrap; align-items: center; }
.search-tokens:empty { display: none; }
.search-token {
    display: inline-flex; align-items: center; gap: 2px; white-space: nowrap;
    font-size: 10.5px; font-weight: 600; line-height: 1.4; padding: 0 2px 0 7px; border-radius: 999px;
    background: var(--accent-light); color: var(--accent); border: 1px solid var(--accent);
}
.search-token button {
    border: none; background: transparent; color: inherit; cursor: pointer; font-size: 12px;
    line-height: 1; padding: 0 4px; border-radius: 999px;
}
.search-token button:hover { background: var(--accent); color: var(--on-accent, #fff); }
.sidebar-search input::-webkit-search-cancel-button { cursor: pointer; }
.project-group.search-hidden { display: none; }
/* A collapsed project opens while its sessions are being searched. */
.task-list.searching .project-group.collapsed .project-body { display: block; }
.task-list.searching .project-group.collapsed .project-caret { transform: rotate(90deg); }
.search-empty { padding: 16px 12px; text-align: center; color: var(--text-muted); font-size: 12px; }

.task-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.task-row {
    display: flex; flex-direction: column; gap: 2px;
    padding: 8px 10px; margin-bottom: 3px; border-radius: var(--radius-sm);
    cursor: pointer; border: 1px solid transparent;
}
.task-row:hover { background: var(--bg-hover); }
.task-row.active { background: var(--accent-light); border-color: var(--accent); }
.task-row-title {
    font-size: 13px; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-row.active .task-row-title { color: var(--accent); font-weight: 600; }
.task-row-meta {
    display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
    font-size: 10px; color: var(--text-muted);
}
.task-row-date, .task-row-count { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
/* Sessions that ran something stand out; "0 tasks" stays muted. */
.task-row-count { color: var(--accent); font-weight: 600; }
.task-row-count.none { color: var(--text-muted); font-weight: normal; }
/* Projects: collapsible groups of session rows. */
.project-group { margin-bottom: 4px; border-radius: var(--radius-sm); border: 1px solid transparent; }
.project-header {
    display: flex; align-items: center; gap: 6px; padding: 6px 8px;
    border-radius: var(--radius-sm); cursor: pointer; user-select: none;
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
}
.project-header:hover { background: var(--bg-hover); }
.project-header:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.project-caret {
    width: 0; height: 0; flex: 0 0 auto; transition: transform 0.12s;
    border-left: 5px solid currentColor; border-top: 4px solid transparent;
    border-bottom: 4px solid transparent; transform: rotate(90deg);
}
.project-group.collapsed .project-caret { transform: none; }
.project-icon {
    flex: 0 0 auto; width: 13px; height: 10px; border: 1.5px solid var(--accent);
    border-radius: 1px 3px 2px 2px; position: relative; top: 1px;
}
.project-icon::before {
    content: ''; position: absolute; left: -1.5px; top: -4px; width: 6px; height: 3px;
    border: 1.5px solid var(--accent); border-bottom: none; border-radius: 2px 2px 0 0;
}
.project-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-group.has-active.collapsed .project-name { color: var(--accent); }
.project-count { font-size: 10px; font-weight: normal; color: var(--text-muted); }
.project-dot { display: none; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.project-group.collapsed .project-dot.attention { display: inline-block; background: var(--accent); }
.project-group.collapsed .project-dot.working {
    display: inline-block; background: var(--warning); animation: pulse 1.5s infinite;
}
.project-rename, .session-rename {
    width: 100%; font: inherit; font-weight: 600; padding: 1px 4px;
    border: 1px solid var(--accent); border-radius: 3px;
    background: var(--bg-panel); color: var(--text-primary);
}
.session-rename { font-weight: normal; box-sizing: border-box; }
.project-body { padding-left: 10px; margin-left: 9px; border-left: 1px solid var(--border); }
.project-group.collapsed .project-body { display: none; }
.project-empty { font-size: 11px; color: var(--text-muted); padding: 4px 6px 6px; line-height: 1.4; }
.task-list-loose.labelled { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.task-row.dragging { opacity: 0.45; }
.project-group.drop-target { border-color: var(--accent); background: var(--accent-light); }
.task-list.drop-target .task-list-loose { outline: 1px dashed var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.task-list .task-list-loose { min-height: 24px; }

/* Several sessions selected with Ctrl/Cmd+Click or Shift+Click. */
.task-row.selected { background: var(--accent-light); border-color: var(--accent); border-style: dashed; }
.task-row.selected.active { border-style: solid; }
.selection-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    margin: 0 10px 6px; padding: 6px 8px; font-size: 12px;
    border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-light);
    position: relative;
}
.selection-bar[hidden] { display: none; }
.selection-count { flex: 1 1 100%; font-weight: 600; color: var(--accent); }
.selection-btn {
    padding: 3px 8px; font-size: 12px; cursor: pointer; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-panel); color: var(--text-primary);
}
.selection-btn:hover { background: var(--bg-hover); }
.selection-btn.danger { color: var(--error); }
.selection-close {
    position: absolute; top: 4px; right: 4px; border: none; background: none; cursor: pointer;
    font-size: 16px; line-height: 1; color: var(--text-muted); padding: 0 4px;
}
.delete-list { margin: 0 0 10px 18px; font-size: 0.85rem; color: var(--text-primary); max-height: 180px; overflow-y: auto; }
.delete-list li.more { list-style: none; color: var(--text-muted); }

/* Keyboard highlight in the sessions list (only while the keyboard is used). */
.task-list:focus { outline: none; }
.task-list.keyboard-nav:focus .task-row.cursor,
.task-list.keyboard-nav:focus .project-header.cursor {
    outline: 2px solid var(--accent); outline-offset: -2px;
}
/* Info card of the New session / New project buttons. */
.info-hover p { font-size: 12px; line-height: 1.45; color: var(--text-secondary); margin: 4px 0 0; }
.info-hover-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* Right-click menu of a session row (showSessionMenu). */
.session-menu {
    position: fixed; z-index: 1001; min-width: 150px; padding: 4px;
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: 0 6px 24px var(--shadow-strong);
    display: flex; flex-direction: column;
}
.session-menu button {
    text-align: left; padding: 7px 12px; font-size: 13px; border: none;
    border-radius: var(--radius-sm); background: none; color: var(--text-primary); cursor: pointer;
}
.session-menu button:hover, .session-menu button:focus-visible { background: var(--bg-hover); outline: none; }
.session-menu button.danger { color: var(--error); }
.session-menu button.muted { color: var(--text-muted); font-size: 12px; }
.session-menu button.current { color: var(--accent); font-weight: 600; }
.session-menu { max-height: 70vh; overflow-y: auto; max-width: 260px; }
.session-menu button { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The Share menu: rows with a second line (openShareMenu). */
.session-menu.rich { min-width: 250px; max-width: 330px; }
.session-menu.rich button { white-space: normal; }
.session-menu button small { display: block; font-size: 11px; line-height: 1.35; color: var(--text-muted); margin-top: 1px; }
.session-menu button.danger small { color: var(--text-muted); }
/* Session summary shown beside the sidebar while hovering a row. */
.task-hover {
    position: fixed; z-index: 1000; width: 320px; max-width: calc(100vw - 24px);
    padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-panel); color: var(--text-primary);
    box-shadow: 0 6px 24px rgba(0,0,0,0.18); font-size: 12px; line-height: 1.4;
    pointer-events: none; opacity: 0; visibility: hidden; transition: opacity 0.12s ease;
}
.task-hover.visible { opacity: 1; visibility: visible; }
.task-hover-status { font-size: 11px; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.task-hover-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.task-hover dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; }
.task-hover dt { color: var(--text-muted); }
.task-hover dd { margin: 0; overflow-wrap: anywhere; }
.task-hover-request {
    margin-top: 8px; padding: 6px 8px; border-left: 3px solid var(--border);
    background: var(--bg-secondary); color: var(--text-secondary); overflow-wrap: anywhere;
}
.task-hover-request span {
    display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-muted); margin-bottom: 2px;
}
/* Background work in a session that is not on screen: a pulsing dot while
   a review/generation runs, an accent dot and edge once its reply is ready. */
.task-row-dot { margin-right: 6px; vertical-align: middle; }
.task-row.attention { border-left: 3px solid var(--accent); background: var(--accent-light); }
.task-row.attention .task-row-title { font-weight: 600; }
/* Sessions with a task on simulated counts (purple edge and tag), a
   scheduled re-run (teal) or waiting in the run queue (amber); the tags sit
   at the left of the meta line. The live states come later, so their edge
   wins over the purple one. */
.task-row.simulated { border-left: 3px solid var(--simulated); }
.task-row.scheduled { border-left: 3px solid var(--scheduled); }
.task-row.queued { border-left: 3px solid var(--warning); }
.task-row.shared { border-left: 3px solid var(--accent); }
.task-row-tag {
    font-size: 10px; font-weight: 600; line-height: 1.3; white-space: nowrap;
    min-width: 0; overflow: hidden; text-overflow: ellipsis;
    padding: 0 6px; border-radius: 999px; margin-right: auto;
}
.task-row-tag + .task-row-tag { margin-left: 4px; }
.task-row-tag.scheduled { color: var(--scheduled); background: var(--scheduled-light); }
.task-row-tag.scheduled.paused { color: var(--text-muted); background: var(--bg-hover); }
.task-row-tag.scheduled.interrupted { color: var(--error); background: var(--error-light); }
.task-row-tag.queued { color: var(--warning); background: var(--warning-light); }
.task-row-tag.simulated { color: var(--simulated); background: var(--simulated-light); }
.task-row-tag.shared { color: var(--accent); background: var(--bg-hover); }

.sidebar-empty { padding: 20px 12px; text-align: center; color: var(--text-muted); font-size: 12px; }
.sidebar-hint {
    padding: 8px 12px; font-size: 10px; color: var(--text-muted);
    border-top: 1px solid var(--border); line-height: 1.4;
}

@media (max-width: 900px) {
    /* On narrow screens the sidebar overlays the panels instead of squeezing them */
    .task-sidebar { position: absolute; top: 0; bottom: 0; left: 0; z-index: 50;
                    width: var(--sidebar-w, 250px); max-width: calc(100vw - 40px);
                    box-shadow: 2px 0 12px rgba(0,0,0,0.15); }
    .workspace-row { position: relative; }
}

/* Validation Agent script review (findings list, script output, call trace) */
.review-findings ul { list-style: none; margin: 6px 0 0; padding: 0; }
.review-findings .finding {
    font-size: 12px;
    margin: 0 0 4px;
    padding: 4px 8px;
    border-left: 3px solid var(--border);
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}
.review-findings .finding-error { border-left-color: var(--error); background: var(--error-light); }
.review-findings .finding-warning { border-left-color: var(--warning); background: var(--warning-light); }
.finding-tag {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-right: 6px;
}
.finding-line { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-right: 6px; }
.review-note { font-size: 11px; color: var(--text-muted); }
.script-output {
    font-family: var(--font-mono);
    font-size: 11px;
    max-height: 320px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg-input);
    padding: 8px;
    border-radius: var(--radius-sm);
}
.call-trace { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 6px; }
.call-trace td { padding: 2px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.call-trace code { font-family: var(--font-mono); word-break: break-all; }
.call-trace tr.call-failed td { color: var(--error); }

/* Task chains in the Outputs panel: one block per task, newest first,
   each under a divider that names the task and what it continued. */
.task-divider {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 6px 0;
    margin: 14px 0 8px;
    border-top: 2px solid var(--border);
    font-size: 11px;
    color: var(--text-secondary);
    list-style: none;
    cursor: pointer;
}
.task-divider::-webkit-details-marker { display: none; }
.task-divider::before {
    content: '\25B8';
    color: var(--text-muted);
    font-size: 10px;
}
details[open] > .task-divider::before { content: '\25BE'; }
.task-divider.running { cursor: default; }
.task-divider.running::before { content: ''; }
.task-block:first-of-type > .task-divider,
.task-divider.running:first-child { margin-top: 0; }
.task-divider-text { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.task-chip {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 8px;
    background: var(--success-light);
    color: var(--success);
    white-space: nowrap;
}
.task-chip.failed, .task-chip.aborted { background: var(--error-light); color: var(--error); }
.task-chip.running { background: var(--warning-light); color: var(--warning); }
.task-head-note { font-size: 10px; color: var(--accent); white-space: nowrap; }
.task-actions { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 6px; padding-left: 14px; }
.task-continue {
    padding: 2px 10px;
    font-size: 11px;
    background: var(--bg-panel);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
}
.task-continue:hover { background: var(--accent-light); }
a.task-continue { text-decoration: none; display: inline-block; line-height: 1.5; }
.task-continue.active { background: var(--accent); color: #fff; }
.task-continue:disabled { opacity: 0.55; cursor: default; }
.monitor-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 0 0 8px;
    padding: 6px 10px;
    font-size: 12px;
    background: var(--accent-light);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
}
.monitor-strip .monitor-text { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.monitor-strip .monitor-actions { display: flex; gap: 6px; }
.monitor-paused { color: var(--error); font-weight: 600; }
.monitor-strip.interrupted { border-color: var(--error); }
.monitor-strip .monitor-run-now { font-weight: 600; }
.monitor-box { max-width: 520px; }
.monitor-form { display: grid; gap: 8px; margin: 10px 0; font-size: 13px; }
.monitor-form label { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.monitor-form input[type="number"] { width: 64px; padding: 3px 6px; font: inherit; }
.monitor-form select { flex: 1 1 200px; padding: 3px 6px; font: inherit; }
.task-block-body { padding-left: 2px; }
.task-others {
    margin-top: 18px;
    padding-top: 8px;
    border-top: 2px dashed var(--border);
}
.task-other-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    padding: 4px 0;
    font-size: 11px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}
.task-other-summary { flex-basis: 100%; color: var(--text-muted); padding-left: 2px; }

/* ============================================================
   Help tour: a dimmed page with the explained control outlined,
   and a card with the step text (app.js HELP_STEPS / showHelpStep)
   ============================================================ */
.help-tour { position: fixed; inset: 0; z-index: 1100; }
.help-spotlight {
    position: fixed; border-radius: var(--radius-sm); pointer-events: none;
    outline: 3px solid var(--help-highlight); outline-offset: 3px;
    box-shadow: 0 0 0 9999px var(--overlay), 0 0 16px 4px var(--help-highlight);
}
.help-spotlight.no-target { outline: none; box-shadow: 0 0 0 9999px var(--overlay); }
.help-card {
    position: fixed; width: min(340px, calc(100vw - 32px));
    background: var(--bg-panel); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 10px 40px var(--shadow-strong); padding: 16px 18px;
    /* placeHelpStep sets max-height when the card is taller than the room
       next to its control: the text then scrolls and the footer stays put. */
    max-height: calc(100vh - 32px); overflow-y: auto;
}
.help-card h3 { font-size: 1rem; margin-bottom: 6px; }
.help-card p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.5; }
.help-items { margin: 8px 0 0 18px; color: var(--text-secondary); font-size: 0.85rem; line-height: 1.45; }
.help-items li + li { margin-top: 4px; }
.help-items strong { color: var(--text-primary); }
.help-demo-note { margin-top: 10px; color: var(--text-muted); font-size: 0.78rem; font-style: italic; }
.help-card-footer {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-top: 14px; padding-top: 10px;
    position: sticky; bottom: -16px; background: var(--bg-panel);
    margin-bottom: -16px; padding-bottom: 16px;
}
.help-count { color: var(--text-muted); font-size: 0.8rem; }
.help-card-footer .help-actions { display: flex; gap: 8px; }
.help-card-footer button { padding: 6px 14px; }
.help-next {
    background: var(--accent); color: white; border: none;
    border-radius: var(--radius); cursor: pointer; font-weight: 600; font-size: 13px;
}
.help-next:hover { background: var(--accent-hover); }

/* Interactive tutorial (tutorial.js): the help tour's card and outline,
   drawn the same way. An action card (.blocking) also takes the clicks
   outside its control (.tut-block panes around it); under a soft card the
   page stays usable. Above Compare and the plot pop-up (1000, 1100). */
.tutorial-layer { position: fixed; inset: 0; z-index: 1150; pointer-events: none; }
.tutorial-layer .help-card, .tutorial-layer .tut-block { pointer-events: auto; }
.tut-block { position: fixed; background: transparent; }
.tut-progress { display: flex; gap: 4px; margin-bottom: 10px; }
.tut-progress span { flex: 1; height: 3px; border-radius: 2px; background: var(--border); }
.tut-progress span.done { background: var(--accent); opacity: 0.45; }
.tut-progress span.now { background: var(--accent); }
.tut-group { color: var(--text-muted); font-size: 0.72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.speed-badge.tutorial { background: var(--accent-light); color: var(--accent); border: 1px solid var(--accent); }
body.tutorial-on .welcome-tile[data-for="tutorial"], body.tutorial-on .tutorial-card { display: none; }
.tut-spin { display: inline-block; width: 0.8em; height: 0.8em; margin-right: 8px; vertical-align: -0.05em;
    border: 2px solid var(--accent-light); border-top-color: var(--accent); border-radius: 50%;
    animation: tut-spin 0.8s linear infinite; }
@keyframes tut-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tut-spin { animation-duration: 2.4s; } }

/* Server-wide notice posted from the /admin page, and the bar of a session
   an admin opened read-only (app.js refreshBanner / showAdminViewBar). Both
   float over the top of the page, which is laid out to the full height. */
.site-banner, .admin-view-bar {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: min(760px, calc(100% - 32px));
    padding: 8px 10px 8px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    box-shadow: 0 4px 14px var(--shadow-strong);
}
.site-banner.info { background: var(--info-bg); color: var(--info-fg); border: 1px solid var(--indigo-border); }
.site-banner.warning { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning); }
.site-banner span { white-space: pre-line; }
.site-banner button {
    flex: none; border: none; background: transparent; color: inherit;
    font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.admin-view-bar {
    top: auto;
    bottom: 12px;
    background: var(--warning-light);
    color: var(--text-primary);
    border: 1px solid var(--warning);
}
.admin-view-bar code { font-size: 12px; }
/* The desktop page opened on a phone (app.js showPhoneHint): under the
   dialogs, over everything else. */
.phone-hint {
    position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 950; max-width: 480px; margin: 0 auto; padding: 14px;
    background: var(--bg-panel); color: var(--text-primary);
    border: 1px solid var(--accent); border-radius: 12px;
    box-shadow: 0 4px 24px var(--shadow-strong); font-size: 14px; line-height: 1.4;
}
.phone-hint p { margin: 0 0 12px; }
.phone-hint-btns { display: flex; gap: 8px; }
.phone-hint-btns > * {
    flex: 1; min-height: 44px; display: flex; align-items: center; justify-content: center;
    padding: 8px 12px; border-radius: var(--radius); font-family: inherit; font-size: 14px; font-weight: 600;
}
.phone-hint-open { background: var(--accent); color: #fff; text-decoration: none; }
/* The live view of a shared session (showSharedViewBar). */
.shared-view-bar { background: var(--info-bg); color: var(--info-fg); border-color: var(--indigo-border); }
.shared-view-bar .btn-secondary { flex: none; padding: 4px 10px; font-size: 12px; }
/* Send by email… (openShareEmailDialog): the two link modes. */
.share-mode { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }

/* ---- Compare view (Outputs panel → Compare…) ---- */
.compare-btn {
    padding: 3px 10px; font-size: 12px; cursor: pointer; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-panel); color: var(--text-primary);
}
.compare-btn:hover { border-color: var(--accent); color: var(--accent); }
#compare-overlay {
    position: fixed; inset: 0; background: var(--overlay); z-index: 1000;
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.compare-box {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
    width: min(1180px, 100%); max-height: 94vh; display: flex; flex-direction: column; overflow: hidden;
}
.compare-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.compare-head h3 { margin: 0; font-size: 15px; flex: 1; }
.compare-head .compare-close { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.compare-body { display: grid; grid-template-columns: 300px 1fr; min-height: 0; flex: 1; }
.compare-pick { border-right: 1px solid var(--border); overflow-y: auto; padding: 10px 12px; font-size: 12px; }
.compare-pick h4 { margin: 10px 0 6px; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.compare-pick label.pick { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; cursor: pointer; }
.compare-pick label.pick input { margin-top: 2px; }
.compare-pick .pick-title { color: var(--text-primary); }
.compare-pick .pick-sub { color: var(--text-muted); font-size: 11px; }
.compare-pick .pick-kinds { color: var(--accent); font-size: 11px; }
.compare-pick select { width: 100%; margin-top: 4px; font-size: 12px; padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-input, var(--bg-panel)); color: var(--text-primary); }
.compare-pick .muted { color: var(--text-muted); }
.compare-cat-add { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.compare-cat-add input { width: 100%; font-size: 12px; padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-input, var(--bg-panel)); color: var(--text-primary); box-sizing: border-box; }
.compare-cat-add .btn-secondary { align-self: flex-start; }
.compare-main { overflow-y: auto; padding: 12px 16px; display: grid; gap: 14px; grid-template-columns: 1fr 1fr; align-content: start; }
.compare-main .compare-plot { grid-column: span 1; }
.compare-main .compare-table-wrap { grid-column: 1 / -1; }
.compare-main .compare-wide { grid-column: 1 / -1; }
.compare-maps .map-row-svg { width: 100%; height: auto; max-height: 300px; display: block; margin-bottom: 6px; }
.compare-loc-body { display: grid; grid-template-columns: 1fr; gap: 10px; }
.compare-loc-body #compare-loc { max-width: 480px; }
.compare-loc-body .sed-svg { width: 100%; height: auto; }
@media (max-width: 1000px) { .compare-main { grid-template-columns: 1fr; } .compare-body { grid-template-columns: 1fr; } .compare-pick { border-right: none; border-bottom: 1px solid var(--border); max-height: 36vh; } }
.compare-plot h4, .compare-table-wrap h4 { margin: 0 0 4px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.compare-plot h4 .spacer, .compare-table-wrap h4 .spacer { flex: 1; }
.compare-plot .sed-svg { width: 100%; height: auto; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.compare-table th, .compare-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.compare-table th { color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.compare-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.compare-table .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
/* Compare: the fit-numbers table (app.js compareFitHtml) — sections of rows, one column per pick */
.compare-fit-ref { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; font-size: 12px; color: var(--text-secondary); }
.compare-fit-ref select { font-size: 12px; }
.compare-fit-scroll { overflow-x: auto; min-width: 0; }
.compare-fit { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; table-layout: fixed; }
.compare-fit th, .compare-fit td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; font-weight: 400; }
.compare-fit thead th { vertical-align: bottom; border-bottom: 1px solid var(--text-secondary); }
.compare-fit .q { position: sticky; left: 0; z-index: 1; background: var(--bg-panel); color: var(--text-secondary); font-weight: 500; }
.compare-fit thead th.q { width: 170px; }
.compare-fit thead th.q { color: var(--text-muted); font-weight: 600; }
.compare-fit .is-ref { background: color-mix(in srgb, var(--accent-light) 55%, transparent); }
.compare-fit .fit-ent { display: grid; gap: 2px; }
.compare-fit .fit-kind { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.compare-fit .fit-ref { font-size: 10px; letter-spacing: .04em; color: var(--accent); background: var(--accent-light); border-radius: 999px; padding: 0 7px; }
.compare-fit .fit-name { display: flex; align-items: center; gap: 6px; color: var(--text-primary); font-weight: 600; }
.compare-fit .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.compare-fit .fit-sub { font-size: 11px; color: var(--text-muted); }
.compare-fit tr.fit-group th, .compare-fit tr.fit-group td { background: var(--bg-input); color: var(--text-primary); font-weight: 600; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; padding-top: 7px; padding-bottom: 7px; }
.compare-fit .fit-gnote { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-muted); }
.compare-fit .fit-unit { display: block; color: var(--text-muted); font-weight: 400; font-size: 11px; }
.compare-fit .fit-band { display: block; color: var(--text-primary); font-weight: 600; }
.compare-fit .fit-whose { display: block; color: var(--text-muted); font-weight: 400; font-size: 11px; }
.compare-fit .v { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-primary); }
.compare-fit .v .pm { color: var(--text-muted); }
.compare-fit .fit-cellsub { display: block; color: var(--text-muted); font-size: 11px; margin-top: 1px; }
.compare-fit .muted { color: var(--text-muted); }
.fit-m { color: var(--accent); font-weight: 700; font-size: 10px; vertical-align: super; margin-left: 1px; cursor: help; }
.fit-tag { display: inline-block; font-size: 10px; border: 1px solid var(--border); color: var(--text-muted); border-radius: 999px; padding: 0 6px; margin-left: 4px; vertical-align: 1px; white-space: nowrap; }
.fit-tag.warn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, transparent); background: var(--warning-light); cursor: help; }
.fit-tag.acc { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-light); }
.fit-delta { display: inline-block; margin-top: 3px; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-secondary); background: var(--bg-input); border-radius: var(--radius-sm); padding: 0 6px; white-space: nowrap; }
.fit-delta .sig { color: var(--text-muted); }
.fit-approx { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; cursor: help; }
.fit-src { cursor: help; text-decoration: underline dotted; text-underline-offset: 2px; }
.compare-fit tr.fit-notice td { padding-top: 8px; padding-bottom: 8px; }
.fit-noticebox { display: flex; gap: 8px; align-items: flex-start; max-width: 95ch; background: var(--warning-light); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); border-radius: var(--radius-sm); padding: 7px 10px; color: var(--text-primary); }
.fit-bang { flex: none; width: 16px; height: 16px; border-radius: 50%; background: var(--warning); color: var(--bg-panel); font-weight: 700; font-size: 11px; display: grid; place-items: center; margin-top: 1px; }
.fit-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.fit-flag { font: inherit; font-size: 11px; display: inline-flex; gap: 5px; align-items: baseline; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-primary); border-radius: var(--radius-sm); padding: 1px 7px; cursor: help; }
.fit-flag b { color: var(--warning); font-variant-numeric: tabular-nums; }
.fit-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-panel); min-width: 0; }
.fit-card-head { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: grid; gap: 3px; padding: 7px 10px; }
.fit-card-head:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; border-radius: var(--radius); }
.fit-card-top { display: flex; align-items: center; gap: 6px; color: var(--text-primary); }
.fit-chev { margin-left: auto; color: var(--text-muted); transition: transform .15s; }
.fit-card.open .fit-chev { transform: rotate(90deg); }
.fit-card-sum { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.fit-card-body { border-top: 1px solid var(--border); padding: 8px 10px 10px; display: grid; gap: 8px; }
.fit-seg { display: inline-flex; justify-self: start; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.fit-seg button { font: inherit; font-size: 11px; border: none; background: none; color: var(--text-secondary); padding: 2px 9px; cursor: pointer; }
.fit-seg button + button { border-left: 1px solid var(--border); }
.fit-seg button.on { background: var(--accent); color: #fff; }
.fit-params { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; }
.fit-params dt { color: var(--text-secondary); }
.fit-params dd { margin: 0; text-align: right; }
.fit-note { font-size: 11px; color: var(--text-muted); }
.compare-fit-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 6px; font-size: 11px; color: var(--text-muted); }
.compare-fit-legend b { color: var(--text-secondary); font-weight: 600; }
.plot-tip.fit-tip { max-width: 320px; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .fit-chev { transition: none; } }
.compare-empty { grid-column: 1 / -1; color: var(--text-muted); padding: 30px; text-align: center; }
.compare-main .btn-secondary.small { padding: 2px 8px; font-size: 11px; }
.compare-seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-right: 4px; }
.compare-seg button { border: none; background: none; color: var(--text-muted); font-size: 11px; padding: 2px 8px; cursor: pointer; }
.compare-seg button + button { border-left: 1px solid var(--border); }
.compare-seg button.on { background: var(--accent); color: #fff; }
.compare-cmap { font-size: 11px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; margin-right: 4px; }
.compare-cmap select { font-size: 11px; padding: 1px 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-input, var(--bg-panel)); color: var(--text-primary); }
.compare-plot svg .legend-item:hover text, .plot-popup svg .legend-item:hover text { text-decoration: underline; }
/* The enlarge button in a Compare plot's head (app.js openComparePlot) */
.compare-main .compare-enlarge { position: static; flex: none; }

/* Run queue: an approved run waiting for a slot (server.py run_queue) */
.pipeline-badge.queued { background: var(--warning-light); color: var(--warning); }
.result-card.queued .queue-note { color: var(--text-muted); font-size: 0.9em; }
.result-card.queued .queue-note:empty { display: none; }
.rl-state { margin-left: 6px; font-size: 0.8em; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }

/* Welcome message: the three ways to start (welcomeTilesHtml). */
.welcome-tiles { display: grid; gap: 6px; margin-top: 10px; }
.message.collapsed .welcome-tiles { display: none; }
.welcome-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 12px;
    text-align: left;
    font: inherit;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-panel);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.welcome-tile b { font-size: 13px; font-weight: 600; color: var(--accent); }
.welcome-tile small { font-size: 12px; color: var(--text-secondary); }
.welcome-tile:hover { border-color: var(--accent); background: var(--accent-light); }

/* Outputs before any run: faint sketches of what a run shows (outputsEmptyHtml). */
.outputs-empty { padding: 20px 8px; text-align: center; color: var(--text-muted); }
.ghost-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 16px; }
.ghost-tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    text-align: left;
}
.ghost-tile svg { width: 100%; height: 64px; }
.ghost-axis { fill: none; stroke: var(--border); stroke-width: 1.2; }
.ghost-line { fill: none; stroke: var(--text-muted); stroke-width: 1.5; opacity: 0.5; }
.ghost-dot { fill: var(--text-muted); opacity: 0.6; }
.ghost-blob { fill: var(--accent); opacity: 0.12; }
.outputs-empty p { max-width: 380px; margin: 0 auto; font-size: 13px; line-height: 1.5; }

/* Discuss mode (renderDiscussPlan, addDiscussMessage in app.js): the
   discussion's bubbles are lighter than the chat's, so a talk is never
   mistaken for a request, and the Plan strip sits above the message box. */
.message.discuss-user {
    background: var(--accent-light);
    color: var(--text-primary);
    border: 1px solid var(--accent);
    align-self: flex-end;
    max-width: 90%;
    border-bottom-right-radius: 2px;
    white-space: pre-wrap;
}
.message.discuss-assistant {
    background: var(--bg-input);
    color: var(--text-primary);
    align-self: flex-start;
    max-width: 95%;
    border: 1px dashed var(--border);
    border-bottom-left-radius: 2px;
}
.message.discuss-assistant.pending .message-body { font-style: italic; }
.message.discuss-note { border-style: solid; border-color: var(--accent); }
.message.discuss-note.warn { border-color: var(--warning); background: var(--warning-light); }
.agent-tag.discuss { background: var(--bg-panel); color: var(--accent); border: 1px solid var(--accent); }
#panel-chat.discussing .chat-input-area textarea { border-color: var(--accent); border-style: dashed; }
#panel-chat.discussing #send-btn { background: var(--bg-panel); color: var(--accent); border: 1px solid var(--accent); }
#panel-chat.discussing #send-btn:hover { background: var(--accent-light); }
.copilot-card .copilot-link[data-act="discuss"] { display: inline-block; margin-top: 8px; font-size: 12px; }

/* The plan in the mode bar (renderDiscussPlan): a summary button and Write
   request on the bar's right; the chips open in a drop-up over the
   conversation (.discuss-plan-pop), or pinned under the bar
   (.discuss-plan-pinned). Problems turn the summary red, a run over the
   limit amber. Each answer carries the line of what it changed
   (.discuss-changes, setDiscussChanges). */
.discuss-plan {
    display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0;
    justify-content: flex-end; font-size: 12px;
}
.discuss-plan.hidden { display: none; }
.plan-sum {
    display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 100%;
    font: inherit; padding: 4px 8px; cursor: pointer; color: var(--text-primary);
    background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.plan-sum:hover { background: var(--accent-light); }
.plan-sum:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }
.plan-sum svg { flex: 0 0 auto; color: var(--accent); }
.plan-sum b { flex: 0 0 auto; font-weight: 600; }
.plan-sum-text { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.plan-count {
    flex: 0 0 auto; min-width: 18px; padding: 0 5px; border-radius: 999px; text-align: center;
    font-size: 11px; font-weight: 600; line-height: 16px; background: var(--accent); color: #fff;
}
.plan-count.zero { background: var(--bg-panel); color: var(--text-muted); border: 1px solid var(--border); }
/* Questions still open: an amber dot (the drop-up lists them). */
.plan-dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.plan-sum .caret {
    flex: 0 0 auto; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent;
    border-bottom: 5px solid var(--text-muted); transition: transform 0.15s;
}
.plan-sum[aria-expanded="true"] .caret { transform: rotate(180deg); }
.discuss-plan.lvl-warn .plan-sum { border-color: var(--warning); }
.discuss-plan.lvl-warn .plan-sum-text { color: var(--warning); }
.discuss-plan.lvl-bad .plan-sum { border-color: var(--error, #c0392b); }
.discuss-plan.lvl-bad .plan-sum-text { color: var(--error, #c0392b); }
.plan-sum.flash { animation: plan-flash 1.2s ease-out 1; }
@keyframes plan-flash {
    0% { box-shadow: 0 0 0 0 var(--accent); background: var(--accent-light); }
    100% { box-shadow: 0 0 0 6px transparent; }
}
@media (prefers-reduced-motion: reduce) { .plan-sum.flash { animation: none; background: var(--accent-light); } }
.discuss-plan .btn-apply {
    flex: 0 0 auto; padding: 4px 10px; font: inherit; font-size: 12px; font-weight: 600; color: #fff;
    background: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius-sm); cursor: pointer;
}
.discuss-plan .btn-apply:hover:not(:disabled) { background: var(--accent-hover); }
.discuss-plan .btn-apply[disabled] { opacity: 0.5; cursor: not-allowed; }
.discuss-plan-pop {
    position: absolute; left: 10px; right: 10px; bottom: calc(100% + 4px); z-index: 30;
    max-height: min(50vh, 360px); overflow-y: auto; padding: 8px 10px;
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.discuss-plan-pinned {
    margin: 6px 10px 0; padding: 6px 10px; font-size: 12px; max-height: 22vh; overflow-y: auto;
    background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.discuss-plan-pinned.hidden { display: none; }
.discuss-plan-body { font-size: 12px; }
.discuss-plan-foot { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.discuss-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.discuss-chip {
    display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
    padding: 2px 2px 2px 8px; border: 1px solid var(--border); border-radius: 12px;
    background: var(--bg-panel); color: var(--text-primary); line-height: 1.5;
}
.discuss-plan-pop .discuss-chip { background: var(--bg-input); }
.discuss-chip-label { color: var(--text-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; }
.discuss-chip button {
    font: inherit; font-size: 13px; line-height: 1; width: 18px; height: 18px; border-radius: 50%;
    border: none; background: none; color: var(--text-muted); cursor: pointer; padding: 0;
}
.discuss-chip button:hover, .discuss-chip button:focus-visible { background: var(--accent-light); color: var(--text-primary); }
.discuss-empty { color: var(--text-muted); }
.discuss-open { margin-top: 6px; color: var(--warning); }
.discuss-open b { font-weight: 600; }
.discuss-issue { margin-top: 4px; color: var(--error, #c0392b); }
.discuss-issue::before { content: '⚠ '; }
/* A computation on the saved results (setDiscussComputed in app.js). */
.discuss-computed { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.discuss-computed .output-card { margin: 0; max-width: 520px; }
.discuss-computed .dcomp-table { max-width: 720px; }
.dcomp-table { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-panel); }
.dcomp-title { font-size: 12px; font-weight: 600; padding: 6px 8px 0; color: var(--text-primary); }
.dcomp-scroll { overflow-x: auto; padding: 4px 4px 6px; }
.dcomp-table table { border-collapse: collapse; font-size: 12px; width: 100%; }
.dcomp-table th { text-align: left; font-weight: 600; color: var(--text-secondary); padding: 3px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dcomp-table td { padding: 3px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dcomp-table tr:last-child td { border-bottom: none; }
.dcomp-table td.num { font-family: var(--font-mono); font-size: 11.5px; }
.dcomp-error { font-size: 12px; color: var(--error, #b91c1c); }
.dcomp-code summary { cursor: pointer; font-size: 11.5px; color: var(--text-muted); }
.dcomp-method { font-size: 12px; color: var(--text-secondary); line-height: 1.45; }
.dcomp-method ul { margin: 2px 0 2px; padding-left: 16px; }
.dcomp-method li { margin: 1px 0; }
.dcomp-note { font-size: 11px; color: var(--text-muted); }
.rh-fn { text-decoration: underline dotted; text-underline-offset: 2px; cursor: help; font-family: var(--font-mono); font-size: 0.95em; }
.dcomp-method .dcomp-fn { color: var(--text-primary); font-family: var(--font-mono); font-size: 0.95em; }
.rh-fn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; border-radius: 2px; }
/* A helper's hover card (showFnTip in app.js), placed like the citation card. */
.fn-tip { position: fixed; z-index: 1200; max-width: 320px; padding: 6px 9px; border-radius: var(--radius-sm);
    background: var(--text-primary); color: var(--bg-panel); font: 400 11.5px/1.4 var(--font-sans);
    pointer-events: none; opacity: 0; transition: opacity 0.12s; box-shadow: var(--shadow-md, 0 4px 14px rgba(0,0,0,0.18)); }
.fn-tip.on { opacity: 1; }
.fn-tip-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 3px; }
.fn-tip-head b { font-family: var(--font-mono); font-weight: 600; }
.fn-tip-head span { font-size: 10.5px; opacity: 0.75; }
/* The Python editor's cards (pyHoverShow): a panel-coloured card that
   follows the theme, the name in the accent colour, the explanation
   beside an accent bar. */
.fn-tip.wide {
    --fn-tip-name: var(--accent);
    max-width: 440px; padding: 9px 12px 10px;
    background: var(--bg-panel); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 12px; line-height: 1.5;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.08);
}
:root[data-theme="dark"] .fn-tip.wide {
    --fn-tip-name: var(--accent-hover);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.35);
}
.fn-tip.wide .fn-tip-head { margin-bottom: 5px; }
.fn-tip.wide .fn-tip-head b { color: var(--fn-tip-name); font-size: 12.5px; }
.fn-tip.wide .fn-tip-head span { color: var(--text-muted); opacity: 1; font-size: 11px; }
.fn-tip code { font-family: var(--font-mono); font-size: 0.95em; }
.fn-tip-sig { display: block; margin-bottom: 4px; font: 11px/1.4 var(--font-mono); opacity: 0.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.fn-tip.wide .fn-tip-sig { opacity: 1; color: var(--text-secondary); background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 7px; margin: 0 0 8px; }
.fn-tip-doc { border-left: 3px solid var(--fn-tip-name, var(--accent)); padding: 1px 0 1px 9px; }
.fn-tip.wide .fn-tip-doc code { background: var(--accent-light); color: var(--fn-tip-name); padding: 0 3px; border-radius: 3px; }
.fn-tip-opts { margin-top: 4px; font-size: 10.5px; opacity: 0.8; overflow-wrap: anywhere; }
.fn-tip.wide .fn-tip-opts { margin-top: 8px; color: var(--text-muted); opacity: 1; }
/* The name under the pointer in the editor (pyHoverCheck). */
.editor-highlight .py-hover { text-decoration: underline; text-decoration-thickness: 1.5px;
    text-decoration-color: var(--accent); text-underline-offset: 3px; }
.dcomp-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.dcomp-btn { font-size: 12px; padding: 3px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-panel); color: var(--text-primary); cursor: pointer; }
.dcomp-btn:hover { border-color: var(--accent); color: var(--accent); }
.dcomp-kept { color: var(--success, #15803d); }
.kept-results { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.kept-result { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.kept-question { font-size: 12.5px; color: var(--text-secondary); font-style: italic; }
.kept-result .output-card { margin: 0; }
.dcomp-code[open] summary { margin-bottom: 4px; }
.dcomp-src, .dcomp-out { margin: 0 0 6px; padding: 6px 8px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-family: var(--font-mono); font-size: 11.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; }
.dcomp-err { color: var(--error, #b91c1c); }
.dcomp-label, .dcomp-attempt { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; color: var(--text-muted); margin: 2px 0 2px; }
.discuss-changes {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px;
    margin-top: 6px; padding-top: 5px; border-top: 1px dashed var(--border);
    font-size: 11.5px; color: var(--text-muted);
}
.discuss-changes-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.discuss-changes .dc-add { color: var(--success, #15803d); }
.discuss-changes .dc-change { color: var(--text-secondary); }
.discuss-lookups { border-top-style: solid; }
.discuss-lookups + .discuss-changes { margin-top: 3px; padding-top: 0; border-top: none; }
.discuss-warnings { flex-direction: column; gap: 2px; margin-top: 4px; padding-top: 0; border-top: none; }
.discuss-warnings .dc-warn { color: var(--warning); }
.discuss-sources { border-top-style: solid; }
/* Literature searches (setDiscussLiterature, refreshLiteratureLink). */
.discuss-literature { border-top-style: solid; }
.discuss-literature .dc-simbad { flex-basis: 100%; color: var(--text-secondary); }
.discuss-lit-ask {
    margin-top: 8px; padding: 8px 10px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg-subtle, var(--bg-panel));
    font-size: 12.5px; color: var(--text-secondary);
}
.discuss-lit-ask .lit-ask-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.discuss-lit-ask button { padding: 4px 10px; font-size: 12px; }
.lit-manual {
    display: inline-block; margin-top: 6px; padding: 0; border: none; background: none;
    color: var(--accent); font-size: 11.5px; cursor: pointer;
}
.lit-manual:hover { text-decoration: underline; }
.discuss-sources .dc-src { color: var(--accent); text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.discuss-sources .dc-src:hover { text-decoration: underline; }
sup.dsrc { font-size: 0.72em; line-height: 0; margin-left: 1px; position: relative; }
sup.dsrc a { color: var(--accent); text-decoration: none; font-weight: 600; padding: 0 1px; }
/* The citation's hover card (showCiteTip in app.js): one fixed element,
   placed above the superscript and kept inside the window, since the
   conversation scrolls and would clip a card drawn inside it. */
.cite-tip {
    position: fixed; z-index: 1200; max-width: 260px;
    padding: 4px 8px; border-radius: var(--radius-sm);
    background: var(--text-primary); color: var(--bg-panel);
    font: 500 11px/1.3 var(--font-sans); pointer-events: none;
    opacity: 0; transition: opacity 0.12s;
}
.cite-tip.on { opacity: 1; }
.discuss-summary { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); color: var(--text-secondary); line-height: 1.45; }
.discuss-summary b { font-weight: 600; color: var(--text-primary); }
/* A follow-up's plan (after a run): the task it continues from and the
   setup it keeps, amber when it changes the setup (discussFollowupLine). */
.discuss-followup { margin-bottom: 6px; padding: 5px 8px; border-left: 3px solid var(--accent); background: var(--bg-secondary); border-radius: var(--radius-sm); color: var(--text-secondary); line-height: 1.45; }
.discuss-followup b { font-weight: 600; color: var(--text-primary); }
.discuss-followup.changes { border-left-color: var(--warning); background: var(--warning-light); }
.discuss-changes .dc-remove { text-decoration: line-through; text-decoration-color: var(--text-muted); }

/* The mode bar above the message box (refreshModeBar, setChatMode in
   app.js): Guided | Discuss | Draft. */
.chat-mode-bar {
    position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; min-width: 0;
    padding: 8px 10px 0; border-top: 1px solid var(--border);
    container-type: inline-size; container-name: modebar;
}
/* A narrow chat panel keeps the bar on one line while it holds the plan:
   the modes not in force show their icon only (the name is in the title), the plan its count. */
@container modebar (max-width: 560px) {
    .chat-mode-bar.with-plan .mode-seg:not(.active) { font-size: 0; gap: 0; padding: 4px 9px; }
    .chat-mode-bar .plan-sum-text { display: none; }
    .chat-mode-bar .discuss-plan { gap: 4px; }
    .chat-mode-bar .plan-sum { padding: 4px 6px; }
}
@container modebar (max-width: 360px) {
    .chat-mode-bar .plan-write-more, .chat-mode-bar .plan-sum b { display: none; }
}
.chat-mode-bar.hidden { display: none; }
.chat-mode-bar:not(.hidden) ~ .chat-input-area { border-top: none; }
.mode-segs {
    display: inline-flex; flex: 0 0 auto; border: 1px solid var(--border);
    border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-input);
}
.mode-seg {
    display: inline-flex; align-items: center; gap: 5px;
    font: inherit; font-size: 12px; font-weight: 600; padding: 4px 11px;
    border: none; background: transparent; color: var(--text-secondary); cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.mode-seg + .mode-seg { border-left: 1px solid var(--border); }
.mode-seg:hover:not(.active):not(.disabled) { background: var(--accent-light); color: var(--text-primary); }
.mode-seg.active { background: var(--accent); color: #fff; }
.mode-seg.disabled { opacity: 0.5; cursor: not-allowed; }
.mode-seg:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }

/* Compare: save what it shows with a task of this session. */
.compare-main .compare-save { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.compare-save select { font: inherit; }

/* ---- The landing page (guest mode off, not signed in: app.js showLanding) ---- */
body.landing-mode #app { display: none; }
/* The app's body is the window's height with no scroll; the landing page scrolls. */
body.landing-mode { height: auto; min-height: 100vh; overflow: auto; }
.landing {
    --l-title-from: #4c1d95; --l-title-to: #9d4edd; --l-gold: #d99a0b;
    --l-sky-top: #f4f0ff; --l-sky-bottom: #fbfaff; --l-band: rgba(124, 58, 237, 0.10); --l-star: rgba(76, 29, 149, 0.22);
    --l-card: rgba(255, 255, 255, 0.86); --l-card-line: rgba(76, 29, 149, 0.12);
    --l-shadow: 0 1px 2px rgba(30, 16, 70, 0.06), 0 18px 48px rgba(46, 16, 101, 0.14);
    --l-step: rgba(124, 58, 237, 0.07); --l-ico: #6d28d9;
    position: relative; isolation: isolate; min-height: 100vh; display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 40px 16px 28px; box-sizing: border-box; overflow-x: clip;
    background: linear-gradient(180deg, var(--l-sky-top), var(--l-sky-bottom));
}
:root[data-theme="dark"] .landing {
    --l-title-from: #a78bfa; --l-title-to: #e0aaff; --l-gold: #fbbf24;
    --l-sky-top: #070b1d; --l-sky-bottom: #120c2c; --l-band: rgba(139, 92, 246, 0.16); --l-star: rgba(255, 255, 255, 0.55);
    --l-card: rgba(15, 23, 42, 0.78); --l-card-line: rgba(167, 139, 250, 0.18);
    --l-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 48px rgba(0, 0, 0, 0.45);
    --l-step: rgba(167, 139, 250, 0.09); --l-ico: #c4b5fd;
}
.landing.hidden { display: none; }
/* The sky behind the card: two tiles of faint stars and, across it, a glow
   like the Galactic plane of the LAT's all-sky map. */
.landing-sky { position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background-image:
        radial-gradient(1.2px 1.2px at 22px 34px, var(--l-star), transparent),
        radial-gradient(1px 1px at 120px 80px, var(--l-star), transparent),
        radial-gradient(1.4px 1.4px at 70px 150px, var(--l-star), transparent),
        radial-gradient(1px 1px at 160px 190px, var(--l-star), transparent),
        radial-gradient(1px 1px at 45px 230px, var(--l-star), transparent),
        radial-gradient(1.6px 1.6px at 200px 40px, var(--l-star), transparent),
        radial-gradient(1px 1px at 250px 130px, var(--l-star), transparent),
        radial-gradient(1.2px 1.2px at 300px 260px, var(--l-star), transparent);
    background-size: 330px 290px; }
.landing-sky::before { content: ""; position: absolute; left: -20%; right: -20%; top: 50%; height: 46%;
    transform: translateY(-50%) rotate(-9deg);
    background: radial-gradient(ellipse 50% 50% at 50% 50%, var(--l-band), transparent 70%); }
.landing-sky::after { content: ""; position: absolute; inset: 0;
    background-image:
        radial-gradient(1px 1px at 90px 20px, var(--l-star), transparent),
        radial-gradient(1.3px 1.3px at 30px 110px, var(--l-star), transparent),
        radial-gradient(1px 1px at 150px 160px, var(--l-star), transparent);
    background-size: 190px 210px; opacity: 0.7; }
.landing-top { position: fixed; top: 14px; right: 16px; z-index: 1; }
.landing-top .icon-btn { background: var(--l-card); border-color: var(--l-card-line); }
.landing-card { width: 100%; max-width: 470px; background: var(--l-card); border: 1px solid var(--l-card-line);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-radius: 20px; box-shadow: var(--l-shadow); padding: 34px 34px 24px; text-align: center; box-sizing: border-box;
    animation: landing-in 0.5s ease-out both; }
@keyframes landing-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.landing-mark { width: 128px; height: 128px; margin: 0 auto 16px; display: block;
    filter: drop-shadow(0 6px 16px rgba(46, 16, 101, 0.25)); }
.landing-card h1 { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 800; letter-spacing: -0.01em;
    background: linear-gradient(90deg, var(--l-title-from), var(--l-title-to));
    -webkit-background-clip: text; background-clip: text; color: transparent; }
.landing-tagline { margin: 6px 0 20px; color: var(--text-muted); font-size: 14px; font-style: italic; }
.landing-text { margin: 0 0 12px; color: var(--text-primary); font-size: 16px; font-weight: 500; line-height: 1.45; text-wrap: balance; }
.landing-steps { list-style: none; margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.landing-steps li { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 6px 11px;
    border-radius: 12px; background: var(--l-step); }
.landing-step-ico { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 4px; border-radius: 50%;
    background: var(--l-card); color: var(--l-ico); box-shadow: 0 1px 3px rgba(46, 16, 101, 0.12); }
.landing-steps b { font-size: 13px; color: var(--text-primary); }
.landing-steps li > span:last-child { font-size: 12px; line-height: 1.35; color: var(--text-muted); }
.landing-notice { margin: 0 0 16px; padding: 8px 12px; border-radius: 10px; background: var(--l-step);
    border: 1px solid var(--l-card-line); color: var(--text-primary); font-size: 14px; }
.landing-notice.hidden, .landing-provider.hidden, .landing-note.hidden, #landing-google.hidden { display: none; }
.landing-signin { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 14px; }
#landing-google { min-height: 44px; display: flex; justify-content: center; }
.landing-provider { width: 260px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 10px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-primary);
    color: var(--text-primary); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
    transition: background 0.15s, border-color 0.15s; }
.landing-provider:hover { background: var(--bg-secondary); border-color: var(--accent); }
.landing-provider:focus-visible, .landing-tutorial:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.landing-note { margin: 0 0 16px; color: var(--text-muted); font-size: 13px; line-height: 1.45; }
.landing-or { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; color: var(--text-muted); font-size: 13px; }
.landing-or::before, .landing-or::after { content: ""; flex: 1; border-top: 1px solid var(--l-card-line); }
.landing-tutorial { width: 260px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 10px 14px; margin-bottom: 18px; border-radius: 999px; border: 1px solid var(--accent); background: transparent;
    color: var(--accent); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.landing-tutorial:hover:not(:disabled) { background: var(--l-step); }
.landing-tutorial:disabled { cursor: default; opacity: 0.75; border-style: dashed; }
.landing-soon { font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 999px; background: var(--l-step);
    color: var(--text-muted); border: 1px solid var(--l-card-line); }
.landing-links { display: flex; justify-content: center; gap: 18px; padding-top: 14px; border-top: 1px solid var(--l-card-line); }
.landing-docs { color: var(--accent); font-weight: 500; text-decoration: none; }
.landing-docs:hover { text-decoration: underline; }
.landing-foot { margin: 18px 0 0; color: var(--text-muted); font-size: 12px; opacity: 0.85; }
.landing-ack { margin-top: 4px; max-width: 470px; text-align: center; line-height: 1.5; }
@media (prefers-reduced-motion: reduce) { .landing-card { animation: none; } }
@media (max-width: 480px) {
    .landing { padding-top: 56px; }
    .landing-card { padding: 26px 18px 20px; border-radius: 16px; }
    .landing-provider, .landing-tutorial { width: 100%; }
    .landing-mark { width: 104px; height: 104px; }
    .landing-steps { gap: 6px; }
}
