/* ==========================================================================
   Rule Editor Layout — BEM-ish classes with cgr-editor prefix
   --------------------------------------------------------------------------
   Design tokens from design-tokens.css:
     --bg-base, --bg-elevated, --bg-overlay, --bg-inset
     --text-primary, --text-secondary, --text-muted
     --border-subtle, --border-default, --border-strong
     --accent, --accent-hover, --accent-soft
     --space-1…--space-6
     --radius-sm, --radius-md, --radius-lg
     --fs-12, --fs-14, --fs-16
     --fw-medium, --fw-semibold
     --shadow-xs, --shadow-sm, --shadow-focus
     --transition-fast, --transition-base
   ========================================================================== */

/* --------------------------------------------------------------------------
   Token aliases used internally (the pre-existing inline styles in the
   component already reference --surface-1, --surface-2, --border, --text-sm,
   --text-xs; we define them here so they resolve in this file's scope).
   -------------------------------------------------------------------------- */
:root {
    --surface-1: var(--bg-elevated);
    --surface-2: var(--bg-overlay);
    --border:    var(--border-default);
    --text-sm:   var(--fs-14);
    --text-xs:   var(--fs-12);
}

/* --------------------------------------------------------------------------
   0. Full-bleed: the editor needs more room than the 1100px page container.
   When the page container holds the editor, drop its max-width so the two
   code panes + tools panel can use the full content width.
   -------------------------------------------------------------------------- */
.portal-container:has(> .cgr-editor-topbar),
.portal-container:has(> .cgr-mobile-guard),
.portal-container:has(.cgr-editor-root) {
    /* The base .portal-container is `max-width:1100px; margin:0 auto`. Because
       the editor page turns .portal-main into a flex column (below), that
       centering margin would otherwise collapse the container to its content
       width. Force it to span the full content area in BOTH axes. */
    max-width: none;
    width: 100%;
    margin: 0;
    flex: 1;        /* fill .portal-main's column height */
    min-height: 0;  /* let the inner flex column shrink / scroll internally */
    /* Become a flex column so the inner .cgr-editor-root (flex:1) actually
       stretches to this container's full height instead of sizing to content
       (a block container would leave the split stuck at its 400px floor). */
    display: flex;
    flex-direction: column;
}

/* --------------------------------------------------------------------------
   0b. Full-height editor root: fills whatever height .portal-main gives us.
   .portal-main has padding-top (approx 24px) and the topbar banner may sit
   above the root.  We use height:100% chains so the root stretches to fill
   the available block, which in turn drives the flex layout below.
   The page body / html must also allow full height (set once globally).
   -------------------------------------------------------------------------- */
html, body { height: 100%; }

/* Only the editor page becomes a full-height flex column. Scoping this with
   :has() keeps every other page's normal block flow (a global flex column here
   would collapse their centered .portal-container to content width). */
.portal-main:has(.cgr-editor-root),
.portal-main:has(.cgr-mobile-guard) {
    display: flex;
    flex-direction: column;
}

/* Hard-cap the layout chain to the viewport on the editor page. The base chrome
   only sets min-height on .portal-app, so without a cap the whole column grows
   past 100vh when the spec-runner drawer opens and the PAGE scrolls instead of
   the editor split shrinking. Pin .portal-app to the viewport and clear the
   min-height:auto floors so the flex children can shrink. Scoped to the real
   editor (not the mobile guard, which is a short banner). */
.portal-app:has(.cgr-editor-root) {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
}

.portal-content:has(.cgr-editor-root),
.portal-main:has(.cgr-editor-root) {
    min-height: 0;
}

/* The root flex column that wraps topbar + split + drawer.
   Use 100% rather than a calc() magic-number so it adapts to any chrome
   (nav height, trial banners, etc.) above it automatically. */
.cgr-editor-root {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* --------------------------------------------------------------------------
   1. Topbar
   -------------------------------------------------------------------------- */

.cgr-editor-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-default);
    padding: var(--space-2) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    box-shadow: var(--shadow-xs);
}

/* Left cluster: back link + slug + version badge */
.cgr-editor-topbar__left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.cgr-editor-topbar__back {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--fs-14);
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    transition: color var(--transition-fast);
}
.cgr-editor-topbar__back:hover { color: var(--text-primary); }

.cgr-editor-topbar__slug {
    font-family: var(--font-mono);
    font-size: var(--fs-14);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* Keep the slug at its natural size; only ellipsis very long slugs.
       Previously flex-shrink:1 let sibling controls squeeze it to a few px. */
    flex-shrink: 0;
    max-width: 22rem;
}

.cgr-editor-topbar__version-group {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-shrink: 0;
}

.cgr-editor-topbar__basis-label {
    font-size: var(--fs-12);
    color: var(--text-muted);
    white-space: nowrap;
}

/* Right cluster: status + engine + actions */
.cgr-editor-topbar__right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* Auto-save status indicator */
.cgr-editor-save-status {
    font-size: var(--fs-12);
    color: var(--text-muted);
    white-space: nowrap;
    padding-inline: var(--space-1);
}
.cgr-editor-save-status--saving {
    color: var(--accent);
}
.cgr-editor-save-status--dirty {
    color: var(--warning, #F59E0B);
}

/* Engine label + select group */
.cgr-editor-topbar__engine-group {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}
.cgr-editor-topbar__engine-label {
    font-size: var(--fs-12);
    color: var(--text-muted);
    white-space: nowrap;
}

/* Engine empty-state help */
.cgr-editor-engine-empty-help {
    font-size: var(--fs-12);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* Overflow ("…") kebab menu */
.cgr-editor-overflow {
    position: relative;
    display: inline-flex;
}

.cgr-editor-overflow__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: var(--fs-16);
    line-height: 1;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.cgr-editor-overflow__toggle:hover {
    background: var(--bg-overlay);
    color: var(--text-primary);
}
.cgr-editor-overflow__toggle:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* Transparent full-viewport layer so a click anywhere closes the menu. */
.cgr-editor-overflow__backdrop {
    position: fixed;
    inset: 0;
    z-index: 199;
    background: transparent;
}

.cgr-editor-overflow__menu {
    position: absolute;
    top: calc(100% + var(--space-1));
    right: 0;
    z-index: 200;
    min-width: 180px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--space-1) 0;
    display: flex;
    flex-direction: column;
}

.cgr-editor-overflow__item {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: none;
    text-align: left;
    font-size: var(--fs-14);
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
    white-space: nowrap;
}
.cgr-editor-overflow__item:hover { background: var(--bg-overlay); }
.cgr-editor-overflow__item:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}
.cgr-editor-overflow__item--danger {
    color: var(--error, #EF4444);
}
.cgr-editor-overflow__item--danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

/* --------------------------------------------------------------------------
   2. Main split: editors + tools panel
   -------------------------------------------------------------------------- */

.cgr-editor-split {
    display: flex;
    gap: var(--space-3);
    margin: var(--space-4) 0;
    flex: 1;
    min-height: 0;
    align-items: stretch;
    /* Clip the panes to the split's flex-allocated height. Without this the panes (whose
       min-height is 0 so they *can* shrink, but whose Monaco content is tall) would paint past
       the bottom edge and overlap the spec-runner drawer below instead of yielding space to it. */
    overflow: hidden;
}

/* Source and spec panes share the same base style */
.cgr-editor-pane {
    flex: 1;
    min-width: 0;
    /* min-height:0 lets the pane shrink below its content's intrinsic height so that, when the
       bottom drawer expands, the space is deducted from the editor instead of the drawer being
       pushed off-screen / behind the editor. */
    min-height: 0;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-inset);
}

.cgr-editor-pane__header {
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.cgr-editor-pane__label {
    font-size: var(--fs-12);
    color: var(--text-secondary);
    flex: 1;
    font-weight: var(--fw-medium);
}

.cgr-editor-pane__hint {
    display: block;
    font-size: var(--fs-12);
    color: var(--text-muted);
    padding: var(--space-1) var(--space-3) 0;
    flex-shrink: 0;
}

.cgr-editor-pane__toolbar-btn {
    font-size: var(--fs-12);
    padding: 2px var(--space-2);
}

/* Monaco mount points — must keep a non-zero min-height (automaticLayout) */
.cgr-editor-monaco-mount {
    flex: 1;
    min-height: 160px;
}

/* Spec pane inner layout (editor + optional preview) */
.cgr-editor-pane__spec-inner {
    flex: 1;
    display: flex;
    min-height: 160px;
}

.cgr-editor-pane__spec-monaco {
    flex: 1;
    min-height: 160px;
}

.cgr-editor-pane__spec-preview {
    flex: 1;
    padding: var(--space-3);
    overflow: auto;
}


/* --------------------------------------------------------------------------
   3. Tools panel (collapsible right rail)
   -------------------------------------------------------------------------- */

.cgr-editor-tools {
    width: 320px;
    flex-shrink: 0;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    transition: width var(--transition-base);
}

.cgr-editor-tools--collapsed {
    width: 40px;
    min-width: 40px;
}

.cgr-editor-tools__header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

.cgr-editor-tools__title {
    font-size: var(--fs-12);
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cgr-editor-tools__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    font-size: var(--fs-14);
    transition: color var(--transition-fast), background var(--transition-fast);
}
.cgr-editor-tools__toggle:hover {
    background: var(--bg-overlay);
    color: var(--text-primary);
}
.cgr-editor-tools__toggle:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* Collapsed state: rotate toggle icon; no title visible */
.cgr-editor-tools--collapsed .cgr-editor-tools__title {
    display: none;
}
.cgr-editor-tools--collapsed .cgr-editor-tools__header {
    justify-content: center;
    padding: var(--space-2);
}

/* Tab strip */
.cgr-editor-tools__tabs {
    display: flex;
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-elevated);
    flex-shrink: 0;
}

/* Panel content area */
.cgr-editor-tools__panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* --------------------------------------------------------------------------
   4. Bottom drawer (spec runner)
   -------------------------------------------------------------------------- */

.cgr-editor-drawer {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    overflow: hidden;
    /* flex:none keeps the drawer at its natural height so the split above shrinks */
    flex: none;
}

/* When the drawer is open its body content scrolls rather than growing the page */
.cgr-editor-drawer [data-test="drawer-content"] {
    max-height: 40vh;
    overflow-y: auto;
}

.cgr-editor-drawer__toggle {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-14);
    color: var(--text-muted);
    transition: background var(--transition-fast);
}
.cgr-editor-drawer__toggle:hover { background: var(--bg-overlay); }

.cgr-editor-drawer__label {
    flex: 1;
    text-align: left;
}

.cgr-editor-drawer__chevron {
    font-size: var(--fs-12);
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   5. LSP status dot
   -------------------------------------------------------------------------- */

.cgr-lsp-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cgr-lsp-dot-connected    { background: var(--success, #10B981); }
.cgr-lsp-dot-reconnecting { background: var(--warning, #F59E0B); }
.cgr-lsp-dot-fallback     { background: var(--info,    #3B82F6); }
.cgr-lsp-dot-disconnected { background: var(--text-muted, #6B7280); }

/* --------------------------------------------------------------------------
   6. Mobile guard — used by MobileGuardBanner
   -------------------------------------------------------------------------- */

.cgr-mobile-guard {}
.cgr-mobile-guard-banner {}

/* --------------------------------------------------------------------------
   7. Responsive layout
   -------------------------------------------------------------------------- */

/* ≥1200px: full three-column layout (source | spec | tools) */
@media (min-width: 1200px) {
    .cgr-editor-tools { width: 320px; }
    .cgr-editor-tools--collapsed { width: 40px; }
}

/* 1024px–1199px: stack tools below the two editors */
@media (min-width: 1024px) and (max-width: 1199px) {
    .cgr-editor-split {
        flex-wrap: wrap;
    }
    .cgr-editor-tools {
        width: 100%;
        flex-shrink: 1;
    }
    .cgr-editor-tools--collapsed {
        width: 100%;
        height: 40px;
    }
    .cgr-editor-tools--collapsed .cgr-editor-tools__header {
        justify-content: flex-start;
        padding: var(--space-2) var(--space-3);
    }
    .cgr-editor-tools--collapsed .cgr-editor-tools__title {
        display: block;
    }
}

/* --------------------------------------------------------------------------
   AI footer — persistent bottom bar for natural-language intent input.
   Uses the --ai accent token (lila-blau, #8B7CF6) from design-tokens.css.
   -------------------------------------------------------------------------- */

.cgr-ai-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border-default);
    background: var(--bg-elevated);
    padding: var(--space-2) var(--space-3);
    position: relative;
}

.cgr-ai-footer__row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* KI badge */
.cgr-ai-footer__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-12);
    font-weight: var(--fw-semibold);
    color: #cfc6ff;
    background: var(--ai-soft, rgba(139, 124, 246, .14));
    border: 1px solid var(--ai, #8B7CF6);
    border-radius: var(--radius-pill);
    padding: 2px var(--space-2);
    flex-shrink: 0;
    white-space: nowrap;
}

/* Animated spark dot inside the badge */
.cgr-ai-footer__badge .spark {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ai, #8B7CF6);
    box-shadow: 0 0 8px var(--ai, #8B7CF6);
    flex-shrink: 0;
}

/* Quota chip (static placeholder; wired in issue 1116) */
.cgr-ai-quota {
    flex-shrink: 0;
    font-size: var(--fs-12);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-default);
    background: var(--bg-overlay);
    cursor: default;
    white-space: nowrap;
}

.cgr-ai-quota__label {
    font-family: var(--font-sans);
    color: var(--text-muted);
    margin-right: 4px;
}

/* Quota chip — amber warning state (>= 80% consumed) */
.cgr-ai-quota--warning {
    color: var(--warning, #F59E0B);
    border-color: rgba(245, 158, 11, .4);
    background: rgba(245, 158, 11, .1);
}

/* Quota chip — red exhausted state (100% consumed) */
.cgr-ai-quota--exhausted {
    color: var(--error, #EF4444);
    border-color: rgba(239, 68, 68, .4);
    background: rgba(239, 68, 68, .1);
}

/* Soft-warning line shown at >= 80% (below the AI footer row) */
.cgr-ai-quota-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-12);
    color: var(--warning, #F59E0B);
    padding: 0 var(--space-2) var(--space-1);
}

/* Hard-stop nudge line shown at 100% (upgrade prompt) */
.cgr-ai-quota-nudge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-12);
    color: var(--error, #EF4444);
    padding: 0 var(--space-2) var(--space-1);
}

.cgr-ai-quota-nudge a {
    color: #fca5a5;
    font-weight: var(--fw-semibold);
    text-decoration: none;
}

.cgr-ai-quota-nudge a:hover {
    text-decoration: underline;
}

/* AI text input */
.cgr-ai-input {
    flex: 1;
    background: var(--bg-inset);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--fs-14);
    padding: var(--space-2) var(--space-3);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.cgr-ai-input:focus {
    outline: none;
    border-color: var(--ai, #8B7CF6);
    box-shadow: 0 0 0 3px var(--ai-soft, rgba(139, 124, 246, .14));
}

.cgr-ai-input:disabled {
    opacity: .6;
    cursor: not-allowed;
}

/* Keyboard hint badge */
.cgr-ai-kbd {
    font-size: 11px;
    color: var(--text-muted);
    border: 1px solid var(--border-default);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: var(--font-mono);
    flex-shrink: 0;
}

/* Send button */
.cgr-ai-send {
    flex-shrink: 0;
    background: var(--ai, #8B7CF6);
    border: 1px solid var(--ai, #8B7CF6);
    color: #fff;
    font-weight: var(--fw-semibold);
}

.cgr-ai-send:hover:not(:disabled) {
    background: var(--ai-strong, #6D5EE6);
    border-color: var(--ai-strong, #6D5EE6);
}

/* Stop button in the top bar — visible only while an AI run is active */
.cgr-ai-stop-btn {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--ai, #8B7CF6);
    color: var(--ai, #8B7CF6);
    font-weight: var(--fw-semibold);
}

.cgr-ai-stop-btn:hover {
    background: var(--ai-soft, rgba(139, 124, 246, .14));
}

/* AI status line shown above the input row while the AI is streaming */
.cgr-ai-status {
    display: none;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-12);
    color: #cfc6ff;
    padding: 0 var(--space-1) var(--space-2);
}

.cgr-ai-status.show {
    display: flex;
}

.cgr-ai-status .spark {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ai, #8B7CF6);
    box-shadow: 0 0 8px var(--ai, #8B7CF6);
    animation: cgr-caret-blink 1s steps(1) infinite;
    flex-shrink: 0;
}

@keyframes cgr-caret-blink {
    50% { opacity: 0; }
}

/* --------------------------------------------------------------------------
   AI intent card placed above the editor (under the action row): swap the
   separating border to the bottom edge so it reads as a header band.
   -------------------------------------------------------------------------- */
.cgr-ai-footer--top {
    border-top: none;
    border-bottom: 1px solid var(--border-default);
}

/* --------------------------------------------------------------------------
   AI run modal — live "thought" stream shown while a durable run is active.
   Dimmed backdrop over the editor; auto-closes when the run ends (the markup
   is gated on _aiInputDisabled). Designed as a calm timeline, not a console.
   -------------------------------------------------------------------------- */
.cgr-ai-run-modal__backdrop {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(10, 12, 20, 0.55);
    backdrop-filter: blur(3px);
    animation: cgr-ai-modal-fade var(--transition-base) ease-out;
}

.cgr-ai-run-modal {
    width: 100%;
    max-width: 520px;
    background: var(--bg-elevated);
    border: 1px solid var(--ai, #8B7CF6);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--ai-soft, rgba(139, 124, 246, .14));
    padding: var(--space-4);
    animation: cgr-ai-modal-rise var(--transition-base) ease-out;
}

.cgr-ai-run-modal__header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.cgr-ai-run-modal__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-12);
    font-weight: var(--fw-semibold);
    color: #cfc6ff;
    background: var(--ai-soft, rgba(139, 124, 246, .14));
    border: 1px solid var(--ai, #8B7CF6);
    border-radius: var(--radius-pill);
    padding: 2px var(--space-2);
    flex-shrink: 0;
}

.cgr-ai-run-modal__badge .spark {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ai, #8B7CF6);
    box-shadow: 0 0 8px var(--ai, #8B7CF6);
    animation: cgr-caret-blink 1s steps(1) infinite;
}

.cgr-ai-run-modal__title {
    flex: 1;
    font-size: var(--fs-14);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
}

.cgr-ai-run-modal__stop {
    flex-shrink: 0;
}

.cgr-ai-run-modal__log {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 320px;
    overflow-y: auto;
}

.cgr-ai-run-modal__line {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-1) 0;
    position: relative;
    line-height: 1.5;
}

/* Vertical connector between consecutive markers (timeline spine) */
.cgr-ai-run-modal__line:not(:last-child) .cgr-ai-run-modal__marker::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 12px;
    bottom: -12px;
    width: 1px;
    transform: translateX(-50%);
    background: var(--border-default);
}

.cgr-ai-run-modal__marker {
    position: relative;
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    margin-top: 4px;
    border-radius: 50%;
    background: var(--border-strong, #4b5563);
}

.cgr-ai-run-modal__text {
    color: var(--text-secondary);
}

.cgr-ai-run-modal__line.is-done .cgr-ai-run-modal__text {
    color: var(--text-muted);
}

.cgr-ai-run-modal__line.is-current .cgr-ai-run-modal__marker {
    background: var(--ai, #8B7CF6);
    animation: cgr-ai-pulse 1.4s ease-in-out infinite;
}

.cgr-ai-run-modal__line.is-current .cgr-ai-run-modal__text {
    color: var(--text-primary);
    font-weight: var(--fw-medium);
}

@keyframes cgr-ai-modal-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cgr-ai-modal-rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes cgr-ai-pulse {
    0%, 100% { box-shadow: 0 0 0 4px var(--ai-soft, rgba(139, 124, 246, .18)); }
    50% { box-shadow: 0 0 0 7px rgba(139, 124, 246, .05); }
}

/* --------------------------------------------------------------------------
   AI actor badge — follows the focused editor pane while the AI is active.
   Positioned via JS (cgMonaco.aiBadgeMoveTo); hidden by default.
   Uses the --ai token (lila-blau) so it resolves in both themes.
   -------------------------------------------------------------------------- */

.cgr-ai-actor-badge {
    position: fixed;
    z-index: 300;
    display: none;
    align-items: center;
    gap: 5px;
    background: var(--ai, #8B7CF6);
    color: #fff;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    box-shadow: 0 2px 10px rgba(109, 94, 230, 0.6);
    pointer-events: none;
    transition: top var(--transition-base), left var(--transition-base);
    white-space: nowrap;
}

.cgr-ai-actor-badge.show {
    display: inline-flex;
}

.cgr-ai-actor-badge__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    flex-shrink: 0;
}

/* <1024px: handled by MobileGuardBanner which hides the editor */
