/* ═══════════════════════════════════════════════
   Pipeline Grid — Design System
   Canvas-based spreadsheet with dark theme
   ═══════════════════════════════════════════════ */

/* ── Reset & Custom Properties ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors — Indigo/Violet palette */
    --bg-primary: #0c0e14;
    --bg-secondary: #12151e;
    --bg-tertiary: #181c28;
    --bg-surface: #1e2233;
    --bg-elevated: #252a3a;
    --bg-hover: #2a3045;

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.16);

    --text-primary: #e8eaf0;
    --text-secondary: #9ca3b8;
    --text-tertiary: #636b82;
    --text-muted: #454d64;

    /* Accent palette */
    --accent-indigo: #818cf8;
    --accent-indigo-dim: rgba(129, 140, 248, 0.15);
    --accent-indigo-glow: rgba(129, 140, 248, 0.3);
    --accent-violet: #a78bfa;
    --accent-cyan: #67e8f9;
    --accent-emerald: #34d399;
    --accent-amber: #fbbf24;
    --accent-rose: #fb7185;

    /* Grid dimensions */
    --header-height: 56px;
    --toolbar-height: 48px;
    --formula-height: 36px;
    --statusbar-height: 28px;
    --asset-drawer-height: min(45vh, 360px);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

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

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    interpolate-size: allow-keywords;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── App Header ── */
.app-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-5) 0 0;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
    z-index: 100;
}

.app-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-indigo-dim), transparent);
}

.header-left {
    display: flex;
    align-items: center;
    height: 100%;
}

.menu-container {
    display: flex;
    align-items: center;
    height: 100%;
}

.logo-mark {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-indigo-dim);
    border-radius: var(--radius-md);
    border: 1px solid rgba(129, 140, 248, 0.2);
}

.header-title h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-indigo));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-wrap: nowrap;
}

.header-subtitle {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 400;
    letter-spacing: 0.02em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    margin-left: 20px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-3);
    border-radius: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    font-size: 11px;
    color: var(--text-secondary);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: background var(--duration-normal) var(--ease-out);
}

.connection-status.connected .status-dot {
    background: var(--accent-emerald);
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}

.connection-status.streaming .status-dot {
    background: var(--accent-indigo);
    box-shadow: 0 0 6px var(--accent-indigo-glow);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.4);
    }
}

/* ── Toolbar ── */
.toolbar {
    height: var(--toolbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-5);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.toolbar-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toolbar-select,
.toolbar-input {
    height: 30px;
    padding: 0 var(--sp-2);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 12px;
    outline: none;
    transition: border-color var(--duration-fast) var(--ease-out);
}

.toolbar-select {
    padding-right: var(--sp-4);
    cursor: pointer;
}

.toolbar-input {
    width: 64px;
    text-align: center;
    font-family: var(--font-mono);
}

.toolbar-select:focus,
.toolbar-input:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 2px var(--accent-indigo-dim);
}

/* Style toolbar */
.toolbar-section {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 var(--sp-2);
    border-right: 1px solid var(--border-subtle);
}
.toolbar-section:last-of-type { border-right: none; }

.toolbar-select-sm {
    height: 28px;
    width: fit-content;
    padding: 0 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    outline: none;
    cursor: pointer;
}
.toolbar-select-sm:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 2px var(--accent-indigo-dim);
}

.style-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out);
}
.style-btn:hover { background: var(--bg-surface); }
.style-btn.active {
    background: var(--accent-indigo-dim);
    border-color: var(--accent-indigo);
    color: var(--accent-indigo);
}

.style-color {
    position: relative;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
}
.style-color:hover { background: var(--bg-surface); }
.style-color-label {
    position: relative;
    z-index: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    pointer-events: none;
}
.style-color-label-hint {
    border: solid 3px var(--text-primary);
    background-color: var(--bg-primary);
    border-radius: 5px;
    width: 15px;
    height: 15px;
    margin: 2px
}
.style-color input[type="color"] {
    position: absolute;
    inset: 4px 4px 2px 4px;
    width: calc(100% - 8px);
    height: 4px;
    bottom: 2px;
    top: auto;
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

/* Buttons */
.btn {
    height: 30px;
    padding: 0 var(--sp-4);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    transition: all var(--duration-fast) var(--ease-out);
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: white;
    box-shadow: 0 1px 4px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5558e6, #7780f5);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* Batch info */
.batch-info {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    animation: fade-in var(--duration-normal) var(--ease-out);
}

.batch-id {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-tertiary);
    padding: 2px var(--sp-2);
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
}

.progress-bar {
    width: 120px;
    height: 4px;
    background: var(--bg-surface);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-indigo), var(--accent-violet));
    border-radius: 2px;
    transition: width var(--duration-normal) var(--ease-out);
}

.progress-text {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    color: var(--accent-indigo);
    min-width: 32px;
}

/* ── Formula Bar ── */
.formula-bar {
    height: var(--formula-height);
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-default);
}

.formula-cell-ref {
    width: 60px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border-default);
}

.formula-icon {
    width: 32px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    border-right: 1px solid var(--border-subtle);
}

.formula-input {
    flex: 1;
    height: 100%;
    padding: 0 var(--sp-3);
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    outline: none;
}

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

/* ── Menu ── */
.menu {
    height: 100%;
    width: fit-content;
    position: relative;
}
.menu-main-btn {
    width: fit-content;
    height: 100%;
    padding: 10px 30px;
    background: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    border-left: solid 1px var(--border-subtle);
    border-right: solid 1px var(--border-subtle);
}

.menu-main-btn:hover {
    background: var(--bg-hover);
}

.menu-options {
    position: sticky;
    display: flex;
    flex-direction: column;
    align-items: start;
    min-width: 120%;
    width: fit-content;
    overflow: hidden;
    height: 0;
    transition: height 0.1s;
}

.menu[data-open="open"] .menu-options {
    height: fit-content;
}

.menu-secondary-btn {
    width: 100%;
    padding: 10px 30px 10px 10px;
    background: var(--bg-elevated);
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    text-align: start;
    display: flex;
    place-items: center;
    gap: var(--sp-2);
}

.menu-secondary-btn:hover {
    background: var(--bg-hover);
}

.menu-secondary-btn svg {
    fill: var(--text-primary);
    width: 15px;
    height: 15px;
}

.menu-secondary-btn:disabled {
    color: var(--text-tertiary);
}

.menu-secondary-btn:disabled svg {
    fill: var(--text-tertiary);
}

.menu-mobile input{
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.menu-mobile {
    height: 100%;
    aspect-ratio: 1;
    background: none;
    border: none;
    display: none;
    place-items: center;
}

.menu-mobile svg {
    height: 60%;
    aspect-ratio: 1;
    fill: var(--text-primary);
}

.menu-mobile:has(input:checked) {
    background: var(--bg-elevated);
}

/* ── Canvas Grid Container ── */
.grid-container {
    position: relative;
    height: calc(100vh - var(--header-height) - var(--toolbar-height) - var(--formula-height) - var(--statusbar-height));
    overflow: hidden;
    background: var(--bg-primary);
    cursor: cell;
}

body.asset-drawer-open .grid-container {
    height: calc(100vh - var(--header-height) - var(--toolbar-height) - var(--formula-height) - var(--statusbar-height) - var(--asset-drawer-height));
}

.grid-container canvas {
    position: absolute;
    top: 0;
    left: 0;
}

#gridCanvas {
    z-index: 1;
}

#headerCanvas {
    z-index: 2;
}

#selectionCanvas {
    z-index: 3;
}

/* Asset drawer */
.asset-drawer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--statusbar-height);
    height: 0;
    max-height: 45vh;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-default);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
    transform: translateY(100%);
    transition: transform var(--duration-normal) var(--ease-out), height var(--duration-normal) var(--ease-out);
    z-index: 80;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.asset-drawer.open {
    transform: translateY(0);
    height: var(--asset-drawer-height);
}

.asset-drawer.drop-active {
    border-top-color: var(--accent-indigo);
    box-shadow: 0 -10px 28px rgba(129, 140, 248, 0.35);
}

.asset-drawer.drop-active .asset-canvas {
    background: radial-gradient(circle at 0 0, rgba(129, 140, 248, 0.18), transparent 45%);
}

.asset-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
}

.asset-drawer-left {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.asset-drawer-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.asset-tabs {
    display: inline-flex;
    gap: 6px;
}

.asset-tab {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.asset-tab.active,
.asset-tab:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
    background: var(--bg-hover);
}

.asset-drawer-actions {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
}

.asset-drawer-body {
    position: relative;
    flex: 1;
    display: flex;
    overflow: hidden;
}

.asset-drawer-view {
    flex: 1;
    display: flex;
    min-height: 0;
}

.asset-drawer-view.hidden {
    display: none;
}

.asset-canvas {
    position: relative;
    flex: 1;
    overflow: hidden;
    background: radial-gradient(circle at 0 0, rgba(129, 140, 248, 0.08), transparent 45%);
    touch-action: none;
}

.asset-canvas-inner {
    position: absolute;
    inset: 0;
    transform: translate(0, 0);
}

.asset-node {
    position: absolute;
    width: 140px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    padding: var(--sp-2);
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: grab;
    user-select: none;
}

.asset-node.selected {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 2px var(--accent-indigo-glow);
}

.asset-node-select {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--border-default);
    background: var(--bg-surface);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.asset-node-select::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-primary);
    opacity: 0;
}

.asset-node.selected .asset-node-select {
    border-color: var(--accent-indigo);
    background: var(--accent-indigo);
}

.asset-node.selected .asset-node-select::after {
    opacity: 1;
}

@media (pointer: coarse) {
    .asset-node-select {
        display: inline-flex;
    }
}

.asset-list-view {
    background: var(--bg-secondary);
    overflow: auto;
}

.asset-list-body {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
}

.asset-list-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
}

.asset-list-thumb {
    width: 48px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 11px;
    overflow: hidden;
    flex-shrink: 0;
}

.asset-list-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.asset-list-meta {
    flex: 1;
    min-width: 0;
}

.asset-list-name {
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asset-list-sub {
    font-size: 11px;
    color: var(--text-tertiary);
}

.asset-list-actions {
    display: flex;
    gap: var(--sp-2);
}

.asset-list-actions button {
    border: 1px solid var(--border-default);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.asset-list-actions button:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
    background: var(--bg-hover);
}

.asset-node:active {
    cursor: grabbing;
}

.asset-node-thumb {
    width: 100%;
    height: 72px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 11px;
    overflow: hidden;
}

.asset-node-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.asset-node-label {
    font-size: 12px;
    color: var(--text-secondary);
    word-break: break-word;
}

.asset-context-menu {
    position: absolute;
    z-index: 10;
    min-width: 140px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 4px;
    box-shadow: var(--shadow-md);
}

.asset-context-menu.hidden {
    display: none;
}

.asset-context-btn {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-primary);
    text-align: left;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
}

.asset-context-btn:hover {
    background: var(--bg-hover);
}

.hidden-input {
    display: none;
}

/* Column action bar — embedded into the active column's header band. */
.column-popup {
    position: fixed;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 4px;
    background: var(--accent-indigo-dim, rgba(129, 140, 248, 0.18));
    border-left: 1px solid var(--accent-indigo, #818cf8);
    border-right: 1px solid var(--accent-indigo, #818cf8);
    border-bottom: 1px solid var(--accent-indigo, #818cf8);
    box-sizing: border-box;
    pointer-events: none;
    overflow: hidden;
}
.column-popup.hidden { display: none; }
.column-popup-btn {
    height: 20px;
    padding: 0 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    color: var(--accent-indigo, #818cf8);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    pointer-events: auto;
}
.column-popup-btn:hover {
    background: rgba(129, 140, 248, 0.25);
    border-color: var(--accent-indigo, #818cf8);
}
.column-popup-btn.icon-btn { width: 20px; padding: 0; }
.column-popup-btn.hidden { display: none; }

/* Context menu */
.context-menu {
    position: fixed;
    z-index: 200;
    min-width: 140px;
    background: var(--bg-elevated, #1a1d26);
    border: 1px solid var(--border-color, #2a2e3a);
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    user-select: none;
}
.context-menu.hidden { display: none; }
.context-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-primary, #e8eaf0);
    font-family: var(--font-sans);
    font-size: 13px;
    text-align: left;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
}
.context-menu-btn:hover {
    background: rgba(129, 140, 248, 0.2);
}

/* Dialog modal */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}
.dialog-backdrop.hidden { display: none; }
.dialog {
    width: 360px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}
.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.dialog-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.dialog-close {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.dialog-close:hover { color: var(--text-primary); }
.dialog-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.dialog-field { display: flex; flex-direction: column; gap: 4px; }
.dialog-inputs { display: flex; flex-direction: column; gap: 12px; }
.dialog-input-group { display: flex; flex-direction: column; gap: 4px; }
.dialog-input-row { display: flex; gap: 8px; align-items: center; }
.dialog-input-row .dialog-select,
.dialog-input-row .dialog-input { flex: 1 1 0; min-width: 0; }
.dialog-hint {
    font-size: 12px;
    color: var(--text-tertiary);
}
.dialog-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.dialog-select {
    height: 32px;
    padding: 0 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 12px;
    outline: none;
}
.dialog-select:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 2px var(--accent-indigo-dim);
}
.dialog-input {
    height: 32px;
    padding: 0 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 12px;
    outline: none;
}
.dialog-textarea {
    min-height: 84px;
    height: auto;
    padding: 8px;
    resize: vertical;
    line-height: 1.4;
}
.dialog-input:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 2px var(--accent-indigo-dim);
}
.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-primary);
}

/* ── Guided tour ── */
.tour-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: transparent;
}
.tour-backdrop.hidden { display: none; }
.tour-card {
    position: fixed;
    width: 360px;
    max-width: calc(100% - 32px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    padding: 16px;
    color: var(--text-primary);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
    animation: tour-pop 0.28s ease-out;
}
.tour-card.animate {
    animation: tour-pop 0.28s ease-out;
}
.tour-card.pos-top .tour-arrow { bottom: -7px; top: auto; }
.tour-card.pos-bottom .tour-arrow { top: -7px; }
.tour-card.pos-left .tour-arrow { right: -7px; left: auto; }
.tour-card.pos-right .tour-arrow { left: -7px; }
.tour-step {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
}
.tour-title {
    margin: 6px 0 8px;
    font-size: 16px;
    font-weight: 600;
}
.tour-body {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}
.tour-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}
.tour-actions-right {
    display: flex;
    gap: 8px;
}
.tour-spotlight {
    position: fixed;
    border: 2px solid var(--accent-indigo);
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(8, 10, 16, 0.6);
    pointer-events: none;
    transition: all 0.25s ease;
    animation: tour-pulse 1.6s ease-in-out infinite;
}
.tour-spotlight.hidden { display: none; }
.tour-arrow {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-default);
    border-top: 1px solid var(--border-default);
    transform: rotate(45deg);
    left: var(--tour-arrow-x, 24px);
    top: var(--tour-arrow-y, 24px);
}
.tour-iris {
    position: fixed;
    border: 2px solid var(--accent-indigo);
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(8, 10, 16, 0.6);
    pointer-events: none;
    transition: width 0.45s ease, height 0.45s ease, left 0.45s ease, top 0.45s ease, opacity 0.45s ease;
    z-index: 1201;
}
.tour-iris.hidden { display: none; }

@keyframes tour-pop {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes tour-pulse {
    0%, 100% { box-shadow: 0 0 0 9999px rgba(8, 10, 16, 0.6), 0 0 0 0 rgba(129, 140, 248, 0.2); }
    50% { box-shadow: 0 0 0 9999px rgba(8, 10, 16, 0.6), 0 0 0 6px rgba(129, 140, 248, 0.25); }
}

.local-models-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.local-model-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.local-model-meta {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.local-model-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.local-model-sub {
    font-size: 11px;
    color: var(--text-tertiary);
}

.local-model-actions {
    display: flex;
    gap: 8px;
}

/* In-cell edit overlay (floats above canvases) */
.cell-edit-overlay {
    position: absolute;
    z-index: 10;
    background: #0c0e14;
    color: var(--text-primary);
    border: 2px solid var(--accent-indigo);
    padding: 0 6px;
    font-family: var(--font-sans);
    font-size: 12px;
    outline: none;
    box-shadow: 0 0 12px rgba(129, 140, 248, 0.3);
}

/* ── Status Bar ── */
.status-bar {
    height: var(--statusbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-4);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    font-size: 11px;
    color: var(--text-tertiary);
}

.status-bar-right {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.status-sep {
    color: var(--border-default);
}

.status-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all var(--duration-fast) var(--ease-out);
}

.status-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
    background: var(--bg-hover);
}

body.asset-drawer-drop #assetDrawerToggle {
    border-color: var(--accent-indigo);
    color: var(--text-primary);
    background: var(--accent-indigo-dim);
    box-shadow: 0 0 0 2px var(--accent-indigo-glow);
}

.llm-status-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.llm-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.llm-status-detail {
    font-size: 12px;
    color: var(--text-tertiary);
}

.llm-progress {
    width: 100%;
}

/* ── Scrollbar (for overflow containers) ── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

/* ── Animations ── */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Responsive tweaks ── */
@media (max-width: 768px) {
    .tour-card {
        width: auto;
    }
    .tour-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .tour-actions-right {
        justify-content: space-between;
    }

    .toolbar-label {
        display: none;
    }

    .batch-id {
        display: none;
    }

    .header-subtitle {
        display: none;
    }

    .menu-container {
        top: 100%;
        flex-direction: column;
        width: 100%;
        position: absolute;
        z-index: 2;
        display: none;
    }

    .menu-options {
        position: relative;
    }

    .menu {
        width: 100%;
        height: fit-content;
    }

    .menu-main-btn {
        width: 100%;
        height: fit-content;
    }

    .menu-mobile {
        display: grid;
    }

    .menu-mobile:has(input:checked) + .menu-container {
        display: block;
    }
}

/* ── Header user section ── */
.h-hidden { display: none !important; }

.user-section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.credits-chip {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    color: var(--accent-indigo);
    background: var(--accent-indigo-dim);
    border: 1px solid rgba(129,140,248,0.25);
    padding: 3px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.user-email-chip {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-user-btn {
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--accent-indigo);
    background: var(--accent-indigo);
    color: #fff;
    transition: opacity .15s;
    white-space: nowrap;
}

.header-user-btn:hover { opacity: 0.85; }

.header-user-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-default);
}

.header-user-btn-ghost:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}

/* ── Onboarding toast ── */
.onboarding-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    max-width: 320px;
    background: var(--bg-surface, #181c28);
    border: 1px solid rgba(129, 140, 248, 0.35);
    border-radius: 10px;
    padding: 14px 16px;
    color: var(--text-primary, #e8eaf0);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    font-size: 13px;
    line-height: 1.5;
    z-index: 1000;
    animation: onboarding-slide-in 0.35s ease-out;
}

.onboarding-toast-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--accent-indigo);
}

.onboarding-toast-body {
    color: var(--text-secondary, #9ca3b8);
}
.onboarding-toast-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.onboarding-toast .btn {
    font-size: 12px;
    padding: 4px 10px;
}

.onboarding-toast-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-tertiary, #636b82);
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
}

.onboarding-toast-close:hover {
    color: var(--text-primary, #e8eaf0);
}

@keyframes onboarding-slide-in {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
