/* ==========================================================================
   THE CONVERSE BUILDER - canvas (the canvas lane, wave 2b)

   The dot-grid field; one card shape in four family hues (bible 3.2) and
   its states (3.3); connectors and lanes (3.4) in both readings - vertical
   cards, horizontal compact tiles with port dots; SEMANTIC ZOOM (3.5) keyed
   by the tier class convcanvas.js sets on the viewport (conv-tier-full /
   -compact / -overview, plus --conv-zoom); focus + folds + section bands
   (3.6); insert points, drag and drop (5.5); the minimap; motion (5.6).

   Positions come from FlowLayout (C#) as --conv-x / --conv-y custom properties into
   `translate`, so a layout change SLIDES every card to its new place; pan +
   zoom are one transform on .conv-canvas-world. Tokens only - no raw
   colours (Tests/ConversationBuilderPortalTests + ConversationCanvasPortalTests).
   ========================================================================== */

.conv-canvas {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background-color: var(--conv-canvas-bg);
    background-image: radial-gradient(var(--conv-canvas-dot) 1px, transparent 1.2px);
    background-size: 16px 16px;
    cursor: grab;
    outline: none;
}

.conv-canvas:focus-visible {
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--conv-ask) 40%, transparent);
}

.conv-canvas.is-panning,
.conv-canvas.is-dragging {
    cursor: grabbing;
}

.conv-canvas.is-drop-invalid {
    cursor: not-allowed;
}

.conv-canvas-world {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

/* Things outside a focused branch dim to 25% (bible 3.6). */
.conv-canvas .is-outside {
    opacity: .25;
}

/* ── Connectors ───────────────────────────────────────────────────────── */

.conv-edges {
    position: absolute;
    top: 0;
    left: 0;
    overflow: visible;
    pointer-events: none;
}

.conv-edge {
    fill: none;
    stroke: var(--conv-edge);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: opacity 200ms ease, stroke 200ms ease;
}

/* A solid connector outside a focused branch dims by its COLOUR, opaque, not by opacity: the paths of one bus share their
   stem and bar, and see-through strokes laid over each other would draw the shared part darker than the rest. */
.conv-canvas .conv-edge.is-outside:not(.is-disabled):not(.conv-edge--goto):not(.conv-edge--loopback) {
    opacity: 1;
    stroke: color-mix(in srgb, var(--conv-edge) 25%, var(--conv-canvas-bg));
}

.conv-edge--goto,
.conv-edge--loopback {
    stroke: var(--conv-flow);
    stroke-dasharray: 6 5;
    opacity: .85;
}

/* A skipped branch's merge bracket wears the skipped look (the cards above it are skipped too). */
.conv-edge.is-disabled {
    stroke-dasharray: 4 3;
    opacity: .45;
}

.conv-edge--goto.is-outside,
.conv-edge--loopback.is-outside {
    opacity: .2;
}

.conv-edge-arrow {
    fill: var(--conv-flow);
}

.conv-edge-label {
    fill: var(--theme-text-muted);
    font-size: 11px;
    font-family: var(--theme-font);
}

/* ── Cards ────────────────────────────────────────────────────────────── */

.conv-node {
    /* The selection ring wears THIS card's family hue (--conv-fam is set by the family class on
       the same element, so the ring has to be resolved here, not on .conv-builder). */
    --conv-select: var(--conv-fam, var(--conv-ask));
    position: absolute;
    top: 0;
    left: 0;
    translate: var(--conv-x, 0) var(--conv-y, 0);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 10px 16px;
    border: 1px solid var(--conv-node-border);
    border-radius: var(--theme-radius);
    background: var(--conv-node-bg);
    box-shadow: var(--theme-shadow);
    color: var(--theme-text);
    cursor: pointer;
    overflow: hidden;
    user-select: none;
    animation: conv-node-in var(--conv-motion);
    transition:
        translate var(--conv-motion),
        box-shadow var(--conv-motion),
        transform var(--conv-motion),
        border-color var(--conv-motion),
        opacity 200ms ease;
}

@keyframes conv-node-in {
    from {
        opacity: 0;
        scale: .96;
    }
}

@keyframes conv-node-out {
    to {
        opacity: 0;
        scale: .96;
    }
}

.conv-node:hover {
    box-shadow: var(--theme-shadow-lg);
    transform: translateY(-1px);
}

.conv-node.is-selected {
    border-color: var(--conv-select);
    box-shadow:
        0 0 0 2px var(--conv-select),
        0 0 0 6px color-mix(in srgb, var(--conv-select) 20%, transparent),
        var(--theme-shadow-lg);
}

/* The 4px family accent edge. */
.conv-node-accent {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 4px;
    background: var(--conv-fam, var(--conv-end));
}

/* The six-dot grip, on hover (drag the card or its grip - bible 5.5). */
.conv-node-grip {
    position: absolute;
    top: 50%;
    left: 4px;
    translate: 0 -50%;
    color: var(--theme-text-muted);
    font-size: 12px;
    line-height: 1;
    opacity: 0;
    cursor: grab;
    transition: opacity var(--conv-motion);
}

.conv-node:hover .conv-node-grip {
    opacity: .8;
}

/* The 32px icon tile: family-soft ground, family-hue glyph. */
.conv-node-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--conv-fam-soft, var(--conv-end-soft));
    color: var(--conv-fam, var(--conv-end));
    font-size: 1rem;
}

.conv-node-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

/* The Ask: 14px / 600, two lines. */
.conv-node-title {
    color: var(--theme-text-emphasis);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* The kind line: 12px / 400, muted. */
.conv-node-kind {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--theme-text-muted);
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-node-kind-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* A line with a key fact (a call's "gives back ZIP code +4" - Add an action, ruling C3): when the card runs out of room the
   KIND NAME gives way first - it is the only part that shrinks - and the fact, the useful part, keeps its width (up to all but
   the name's last letters; a longer fact ends in an ellipsis, the whole line is the tooltip). */
.conv-node-kind-text.has-fact {
    display: flex;
    align-items: baseline;
    min-width: 0;
}

.conv-node-kind-name {
    flex: 0 1 auto;
    min-width: 1.5em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-node-kind-sep {
    flex: none;
    margin: 0 4px;
}

.conv-node-kind-fact {
    flex: none;
    max-width: calc(100% - 3em);
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-node-glyph {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
    color: var(--theme-text-secondary);
}

/* THE SKILL IS OFF (packs as bundles, ruling B3): an exception that says itself on the kind line - "Weather is off" - in the
   warning ink, the plug glyph first. It replaces the kind's own words while it is true (bible 2.1: badges only for the
   exception). */
.conv-node-packoff {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    color: color-mix(in srgb, var(--conv-issue-warn) 70%, var(--theme-text-emphasis));
    font-weight: 600;
}

/* The compact (horizontal) tile has no kind line - the badge corner carries a plug when nothing else is wrong. */
.conv-node-badge.conv-node-packoff-dot {
    padding: 0 4px;
    font-size: 10px;
}

/* Exception badge: top-right, never a recoloured card. */
.conv-node-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--conv-issue-warn);
    color: var(--theme-text-emphasis);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.conv-node-badge.is-error {
    background: var(--conv-issue-error);
    color: var(--theme-text-on-danger);
}

/* Multi-select: a count chip on the primary (bible 3.3). */
.conv-node-count {
    position: absolute;
    bottom: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--conv-select);
    color: var(--theme-text-on-primary);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

/* Skipped in this conversation: 45% and a hatched accent edge. */
.conv-node.is-disabled {
    opacity: .45;
}

.conv-node.is-disabled .conv-node-accent {
    background: repeating-linear-gradient(
        45deg,
        var(--conv-fam, var(--conv-end)) 0,
        var(--conv-fam, var(--conv-end)) 3px,
        transparent 3px,
        transparent 6px);
}

.conv-node-skipped {
    font-style: italic;
}

/* The furniture of a skipped branch wears the same look - one skipped subtree, one look: its lane
   headers trade the flow underline for the hatch, its merge bracket goes dashed (END pills and Go To
   cards take the 45% and the hatched accent from the rules above). */
.conv-node--lane.is-disabled {
    border-bottom-color: transparent;
    background:
        repeating-linear-gradient(
            45deg,
            var(--conv-flow) 0,
            var(--conv-flow) 3px,
            transparent 3px,
            transparent 6px) left bottom / 100% 2px no-repeat border-box,
        var(--conv-flow-soft);
}

/* The copilot changed it: a 2s pulse of the family ring (reduced motion: a static ring). */
.conv-node.is-pulsing {
    animation: conv-node-pulse 1s ease-out 2;
}

@keyframes conv-node-pulse {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--conv-select) 55%, transparent), var(--theme-shadow);
    }

    100% {
        box-shadow: 0 0 0 12px color-mix(in srgb, var(--conv-select) 0%, transparent), var(--theme-shadow);
    }
}

/* Decisions wear the same card with a decision glyph. */
.conv-node--decision .conv-node-icon {
    border-radius: 50%;
}

/* "Starts when": a slimmer card. */
.conv-node--start {
    padding: 8px 12px;
    border-style: dashed;
    background: var(--theme-background-raised);
}

.conv-node--start .conv-node-icon {
    flex-basis: 28px;
    width: 28px;
    height: 28px;
}

/* Lane headers: slim cards on the flow-soft ground with a 2px flow underline. */
.conv-node--lane {
    padding: 8px 12px;
    border-color: transparent;
    border-bottom: 2px solid var(--conv-flow);
    background: var(--conv-flow-soft);
    box-shadow: none;
}

.conv-node--lane .conv-node-title {
    font-size: 13px;
    -webkit-line-clamp: 1;
}

/* Go To: a terminal card. */
.conv-node--goto {
    padding: 8px 12px 8px 16px;
    border-style: dashed;
    border-color: color-mix(in srgb, var(--conv-flow) 50%, var(--conv-node-border));
}

.conv-node--goto .conv-node-title {
    font-size: 13px;
    -webkit-line-clamp: 1;
}

/* END: a grey pill. */
.conv-node--end {
    justify-content: center;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: var(--conv-end-soft);
    box-shadow: none;
    color: var(--conv-end);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    cursor: default;
}

.conv-node--end:hover {
    box-shadow: none;
    transform: none;
}

/* A card that just left the layout fades where it was. */
.conv-node--leaving {
    pointer-events: none;
    animation: conv-node-out 200ms ease forwards;
}

/* ── Horizontal: compact tiles, the label below, port dots (bible 3.4) ── */

.conv-node--tile {
    flex-direction: column;
    justify-content: flex-start;
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
}

.conv-node--tile:hover {
    box-shadow: none;
    transform: none;
}

.conv-node--tile.is-selected {
    border-color: transparent;
    box-shadow: none;
}

.conv-tile {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border: 1px solid var(--conv-node-border);
    border-radius: calc(var(--theme-radius) * 1.5);
    background: var(--conv-fam-soft, var(--conv-end-soft));
    box-shadow: var(--theme-shadow);
    color: var(--conv-fam, var(--conv-end));
    font-size: 1.5rem;
    transition: box-shadow var(--conv-motion), transform var(--conv-motion);
}

.conv-tile .conv-node-accent {
    top: 14px;
    bottom: 14px;
    border-radius: 0 4px 4px 0;
}

.conv-node--tile:hover .conv-tile {
    box-shadow: var(--theme-shadow-lg);
    transform: translateY(-1px);
}

.conv-node--tile.is-selected .conv-tile {
    border-color: var(--conv-select);
    box-shadow:
        0 0 0 2px var(--conv-select),
        0 0 0 6px color-mix(in srgb, var(--conv-select) 20%, transparent),
        var(--theme-shadow-lg);
}

.conv-node--tile .conv-node-badge {
    top: -7px;
    right: -7px;
}

.conv-node--tile .conv-node-count {
    bottom: -7px;
    right: -7px;
}

.conv-node--decision .conv-tile {
    border-radius: 50%;
}

.conv-node--start .conv-tile {
    border-style: dashed;
    background: var(--theme-background-raised);
    color: var(--theme-text-secondary);
}

.conv-node--goto .conv-tile {
    border-style: dashed;
    border-color: color-mix(in srgb, var(--conv-flow) 50%, var(--conv-node-border));
}

.conv-tile-label {
    width: 100%;
    color: var(--theme-text-emphasis);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* Port dots where the connectors meet the 64px tile. */
.conv-node--tile::before,
.conv-node--tile::after {
    content: "";
    position: absolute;
    z-index: 1;
    top: 28px;
    width: 8px;
    height: 8px;
    border: 1.5px solid var(--conv-edge);
    border-radius: 50%;
    background: var(--conv-node-bg);
}

.conv-node--tile::before {
    left: calc(50% - 36px);
}

.conv-node--tile::after {
    left: calc(50% + 28px);
}

.conv-node--start.conv-node--tile::before,
.conv-node--goto.conv-node--tile::after {
    display: none;
}

.conv-node--tile.is-pulsing {
    animation: none;
}

.conv-node--tile.is-pulsing .conv-tile {
    animation: conv-node-pulse 1s ease-out 2;
}

/* ── Repeat frames, folds ─────────────────────────────────────────────── */

/* A repeated run: a thin rounded frame with a "Repeat" header. */
.conv-loopframe {
    position: absolute;
    border: 1.5px dashed color-mix(in srgb, var(--conv-flow) 45%, transparent);
    border-radius: calc(var(--theme-radius) * 1.5);
    background: color-mix(in srgb, var(--conv-flow) 4%, transparent);
    pointer-events: none;
    transition: opacity 200ms ease;
}

.conv-loopframe-head {
    position: absolute;
    top: 6px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--conv-flow);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.conv-loopframe-sub {
    color: var(--theme-text-muted);
    font-weight: 400;
}

/* A folded decision: one pill - "3 lanes · 14 moments · 1 issue" (bible 3.6). */
.conv-fold {
    position: absolute;
    top: 0;
    left: 0;
    translate: var(--conv-x, 0) var(--conv-y, 0);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px dashed color-mix(in srgb, var(--conv-flow) 55%, var(--conv-node-border));
    border-radius: 999px;
    background: var(--conv-flow-soft);
    box-shadow: var(--theme-shadow);
    color: var(--theme-text-secondary);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    animation: conv-node-in var(--conv-motion);
    transition: translate var(--conv-motion), box-shadow var(--conv-motion), opacity 200ms ease;
}

.conv-fold .bi {
    color: var(--conv-flow);
}

.conv-fold:hover,
.conv-fold:focus-visible {
    box-shadow: var(--theme-shadow-lg);
    outline: none;
}

.conv-fold:focus-visible {
    box-shadow: 0 0 0 2px var(--conv-flow), var(--theme-shadow-lg);
}

.conv-fold.has-issue {
    border-color: var(--conv-issue-warn);
}

.conv-fold.has-error {
    border-color: var(--conv-issue-error);
}

/* ── Section bands (bible 3.6) ────────────────────────────────────────── */

.conv-band {
    position: absolute;
    border: 1px solid color-mix(in srgb, var(--conv-flow) 20%, transparent);
    border-radius: calc(var(--theme-radius) * 1.5);
    background: color-mix(in srgb, var(--conv-flow) 5%, transparent);
    pointer-events: none;
    transition: opacity 200ms ease;
}

.conv-band-head {
    position: absolute;
    top: 4px;
    left: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 2px;
    pointer-events: auto;
}

.conv-band-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 75%;
    padding: 1px 6px;
    border: 0;
    border-radius: var(--theme-radius-button);
    background: transparent;
    color: var(--conv-flow);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.conv-band-title span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-band-title:hover,
.conv-band-title:focus-visible {
    background: color-mix(in srgb, var(--conv-flow) 12%, transparent);
    outline: none;
}

.conv-band-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--theme-text-muted);
    font-size: 10px;
    opacity: 0;
    cursor: pointer;
    transition: opacity var(--conv-motion);
}

.conv-band-head:hover .conv-band-remove,
.conv-band-remove:focus-visible {
    opacity: 1;
    outline: none;
}

.conv-band-remove:hover {
    background: color-mix(in srgb, var(--conv-issue-error) 14%, transparent);
    color: var(--conv-issue-error);
}

.conv-band-input {
    width: min(260px, 75%);
    padding: 1px 6px;
    border: 1px solid var(--conv-flow);
    border-radius: var(--theme-radius-button);
    background: var(--conv-node-bg);
    color: var(--theme-text-emphasis);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    outline: none;
}

/* ── Insert points (bible 3.4): calm canvas, power on intent ──────────── */

.conv-insert {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    width: 140px;
    height: 40px;
    translate: calc(var(--conv-x, 0px) - 70px) calc(var(--conv-y, 0px) - 20px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.conv-canvas--h .conv-insert {
    width: 40px;
    height: 120px;
    translate: calc(var(--conv-x, 0px) - 20px) calc(var(--conv-y, 0px) - 60px);
}

.conv-insert-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--theme-border);
    border-radius: 50%;
    background: var(--conv-node-bg);
    box-shadow: var(--theme-shadow);
    color: var(--theme-text-secondary);
    font-size: 12px;
    opacity: 0;
    cursor: pointer;
    transition: opacity var(--conv-motion), scale var(--conv-motion), background var(--conv-motion), color var(--conv-motion);
}

.conv-insert:hover .conv-insert-btn,
.conv-insert-btn:focus-visible,
.conv-insert.is-lane-end .conv-insert-btn {
    opacity: 1;
}

.conv-insert-btn:hover,
.conv-insert-btn:focus-visible {
    border-color: var(--conv-ask);
    background: var(--conv-ask-soft);
    color: var(--conv-ask);
    scale: 1.08;
    outline: none;
}

/* While a card is dragged every insert point becomes a target dot; the one under the pointer
   lights in the dragged card's family hue - or says why not. */
.conv-canvas.is-dragging .conv-insert {
    width: 220px;
    height: 52px;
    translate: calc(var(--conv-x, 0px) - 110px) calc(var(--conv-y, 0px) - 26px);
}

.conv-canvas--h.is-dragging .conv-insert {
    width: 52px;
    height: 140px;
    translate: calc(var(--conv-x, 0px) - 26px) calc(var(--conv-y, 0px) - 70px);
}

.conv-canvas.is-dragging .conv-insert-btn {
    opacity: .7;
    scale: .55;
    pointer-events: none;
}

.conv-canvas.is-dragging .conv-insert.is-drop-ok .conv-insert-btn {
    opacity: 1;
    scale: 1.15;
    border-color: transparent;
    background: var(--conv-drop, var(--conv-ask));
    color: var(--theme-text-on-primary);
}

.conv-canvas.is-dragging .conv-insert.is-drop-no .conv-insert-btn {
    opacity: 1;
    scale: .9;
    border-color: var(--conv-issue-error);
    background: color-mix(in srgb, var(--conv-issue-error) 14%, var(--conv-node-bg));
    color: var(--conv-issue-error);
}

.conv-canvas.is-dragging .conv-insert.is-drop-same .conv-insert-btn {
    opacity: .2;
}

/* ── Drag and drop ────────────────────────────────────────────────────── */

.conv-drag-layer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 30;
    width: 0;
    height: 0;
    pointer-events: none;
}

.conv-node.is-drag-ghost {
    pointer-events: none;
    opacity: .92;
    rotate: 2deg;
    box-shadow: var(--theme-shadow-lg);
    animation: none;
    transition: none;
}

.conv-node.is-drag-source {
    opacity: .35;
}

.conv-drop-reason {
    position: absolute;
    z-index: 40;
    max-width: 300px;
    padding: 6px 10px;
    border: 1px solid color-mix(in srgb, var(--conv-issue-error) 45%, var(--theme-border));
    border-radius: var(--theme-radius-button);
    background: var(--theme-background-raised);
    box-shadow: var(--theme-shadow-lg);
    color: var(--theme-text);
    font-size: var(--theme-font-size-xs);
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 120ms ease;
}

.conv-drop-reason.is-shown {
    opacity: 1;
    visibility: visible;
}

/* ── Focus mode: the breadcrumb chips (bible 3.6) ─────────────────────── */

.conv-focusbar {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 2px;
    max-width: calc(100% - 24px);
    padding: 4px 4px 4px 6px;
    border: 1px solid var(--theme-border-subtle);
    border-radius: var(--theme-radius-button);
    background: var(--theme-background-raised);
    box-shadow: var(--theme-shadow);
    overflow: hidden;
    animation: conv-focusbar-in 200ms ease;
}

@keyframes conv-focusbar-in {
    from {
        opacity: 0;
        translate: 0 -4px;
    }
}

.conv-focus-crumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 220px;
    padding: 3px 8px;
    border: 0;
    border-radius: var(--theme-radius-button);
    background: transparent;
    color: var(--theme-text-secondary);
    font: inherit;
    font-size: var(--theme-font-size-xs);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.conv-focus-crumb:hover,
.conv-focus-crumb:focus-visible {
    background: var(--conv-flow-soft);
    color: var(--conv-flow);
    outline: none;
}

.conv-focus-crumb.is-current {
    color: var(--theme-text-emphasis);
    cursor: default;
}

.conv-focus-crumb.is-current:hover {
    background: transparent;
    color: var(--theme-text-emphasis);
}

.conv-focus-crumb-sep {
    flex: 0 0 auto;
    color: var(--theme-text-muted);
    font-size: 10px;
}

.conv-focusbar-close {
    margin-left: 4px;
}

/* ── The minimap (bottom-right, hidden under 900px) ───────────────────── */

.conv-minimap {
    position: absolute;
    right: calc(var(--conv-right-inset, 0px) + 16px);
    bottom: 64px;
    z-index: 5;
    width: 200px;
    height: 136px;
    padding: 6px;
    border: 1px solid var(--theme-border-subtle);
    border-radius: var(--theme-radius);
    background: var(--theme-background-raised);
    box-shadow: var(--theme-shadow);
    cursor: pointer;
    touch-action: none;
}

.conv-minimap-svg {
    display: block;
    width: 100%;
    height: 100%;
}

.conv-mm-node {
    fill: color-mix(in srgb, var(--conv-fam, var(--conv-end)) 70%, var(--theme-background-raised));
}

.conv-mm-fold {
    fill: var(--conv-flow-soft);
}

.conv-mm-section {
    fill: color-mix(in srgb, var(--conv-flow) 10%, transparent);
}

.conv-mm-error {
    fill: var(--conv-issue-error);
}

.conv-mm-view {
    fill: color-mix(in srgb, var(--conv-ask) 10%, transparent);
    stroke: var(--conv-ask);
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
    cursor: grab;
}

@media (max-width: 899px) {
    .conv-minimap {
        display: none;
    }
}

/* the drawer and the preview dock squeeze the canvas: the minimap steps aside (CanvasHost.MinimapRoom) */
.conv-canvas.is-narrow .conv-minimap {
    display: none;
}

/* ── Zoom controls + the blank-canvas starters ────────────────────────── */

.conv-zoom {
    position: absolute;
    right: calc(var(--conv-right-inset, 0px) + 16px);
    bottom: 16px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--theme-border-subtle);
    border-radius: var(--theme-radius-button);
    background: var(--theme-background-raised);
    box-shadow: var(--theme-shadow);
}

.conv-zoom-value {
    min-width: 48px;
    color: var(--theme-text-secondary);
    font-size: var(--theme-font-size-xs);
    text-align: center;
}

.conv-starters {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.conv-starters-plus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 1.5px dashed var(--conv-ask);
    border-radius: 50%;
    background: var(--conv-node-bg);
    color: var(--conv-ask);
    font-size: 1.3rem;
    cursor: pointer;
    transition: background var(--conv-motion), transform var(--conv-motion);
}

.conv-starters-plus:hover,
.conv-starters-plus:focus-visible {
    background: var(--conv-ask-soft);
    transform: scale(1.06);
    outline: none;
}

.conv-starters-grid {
    display: grid;
    grid-template-columns: repeat(2, 200px);
    gap: 12px;
}

.conv-starter {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--conv-node-border);
    border-radius: var(--theme-radius);
    background: var(--conv-node-bg);
    box-shadow: var(--theme-shadow);
    color: var(--theme-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: box-shadow var(--conv-motion), transform var(--conv-motion);
}

.conv-starter:hover,
.conv-starter:focus-visible {
    box-shadow: var(--theme-shadow-lg);
    transform: translateY(-1px);
    outline: none;
}

.conv-starter .bi {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--conv-fam-soft, var(--conv-ask-soft));
    color: var(--conv-fam, var(--conv-ask));
}

.conv-starter-name {
    display: block;
    color: var(--theme-text-emphasis);
    font-size: var(--theme-font-size-sm);
    font-weight: 600;
}

.conv-starter-hint {
    display: block;
    margin-top: 2px;
    color: var(--theme-text-muted);
    font-size: var(--theme-font-size-xs);
}

/* ── SEMANTIC ZOOM (bible 3.5) - the module sets the tier class ───────── */

/* 40-70%: a compact card - icon + The Ask on one line; badges become dots. */
.conv-tier-compact .conv-node-title,
.conv-tier-compact .conv-tile-label {
    -webkit-line-clamp: 1;
}

.conv-tier-compact .conv-node-kind,
.conv-tier-compact .conv-node-grip,
.conv-tier-compact .conv-edge-label {
    display: none;
}

.conv-tier-compact .conv-node-badge,
.conv-tier-compact .conv-node-count {
    min-width: 10px;
    width: 10px;
    height: 10px;
    padding: 0;
    font-size: 0;
}

/* Under 40%: the overview - cards become family-coloured bars; section bands and decision
   labels stay legible as landmarks (their text is counter-scaled by --conv-zoom). */
.conv-tier-overview .conv-node:not(.conv-node--end):not(.conv-node--tile) {
    border-color: transparent;
    background: color-mix(in srgb, var(--conv-fam, var(--conv-end)) 45%, var(--conv-node-bg));
    box-shadow: none;
}

.conv-tier-overview .conv-node > *,
.conv-tier-overview .conv-tile > *,
.conv-tier-overview .conv-tile-label {
    visibility: hidden;
}

/* An error stays findable from far away: a red outline that keeps its width at any zoom. */
.conv-tier-overview .conv-node.has-error:not(.conv-node--tile),
.conv-tier-overview .conv-node--tile.has-error .conv-tile {
    box-shadow: 0 0 0 calc(3px / var(--conv-zoom, 1)) var(--conv-issue-error);
}

.conv-tier-overview .conv-node--tile .conv-tile {
    visibility: visible;
    border-color: transparent;
    background: color-mix(in srgb, var(--conv-fam, var(--conv-end)) 55%, var(--conv-node-bg));
    box-shadow: none;
}

.conv-tier-overview .conv-node--tile::before,
.conv-tier-overview .conv-node--tile::after {
    display: none;
}

.conv-tier-overview .conv-node--decision {
    overflow: visible;
}

.conv-tier-overview .conv-node--decision .conv-node-title,
.conv-tier-overview .conv-node--decision .conv-tile-label {
    visibility: visible;
    position: absolute;
    left: 0;
    bottom: calc(100% + 4px);
    width: auto;
    max-width: calc(320px / var(--conv-zoom, 1));
    padding: 0 calc(6px / var(--conv-zoom, 1));
    border-radius: calc(4px / var(--conv-zoom, 1));
    background: var(--theme-background-raised);
    color: var(--conv-flow);
    font-size: calc(13px / var(--conv-zoom, 1));
    line-height: 1.3;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* A section title is a landmark: above the bars, on its own chip, at a readable size. */
.conv-tier-overview .conv-band-head {
    z-index: 4;
}

.conv-tier-overview .conv-band-title {
    max-width: none;
    padding: 0 calc(6px / var(--conv-zoom, 1));
    border-radius: calc(4px / var(--conv-zoom, 1));
    background: var(--theme-background-raised);
    font-size: calc(12px / var(--conv-zoom, 1));
}

.conv-tier-overview .conv-insert,
.conv-tier-overview .conv-edge-label,
.conv-tier-overview .conv-loopframe-head,
.conv-tier-overview .conv-band-remove {
    display: none;
}

.conv-tier-overview .conv-fold span {
    visibility: hidden;
}

/* ── Search hits (the rail's Search): a quiet highlight - a click on one is a jump ── */

.conv-canvas {
    --conv-hit: var(--conv-issue-warn);
}

.conv-node.is-search-hit:not(.is-selected) {
    border-color: color-mix(in srgb, var(--conv-hit) 70%, var(--conv-node-border));
    box-shadow:
        0 0 0 3px color-mix(in srgb, var(--conv-hit) 26%, transparent),
        var(--theme-shadow);
}

.conv-node--tile.is-search-hit:not(.is-selected) {
    border-color: transparent;
    box-shadow: none;
}

.conv-node--tile.is-search-hit:not(.is-selected) .conv-tile {
    border-color: color-mix(in srgb, var(--conv-hit) 70%, var(--conv-node-border));
    box-shadow:
        0 0 0 3px color-mix(in srgb, var(--conv-hit) 26%, transparent),
        var(--theme-shadow);
}

.conv-mm-hit {
    fill: color-mix(in srgb, var(--conv-hit) 85%, var(--theme-background-raised));
}

/* ── Chips in a card's The Ask: a [[token]] reads as its friendly path (stored raw) ── */

.conv-node-chip {
    display: inline;
    padding: 0 5px;
    border-radius: var(--theme-radius-button);
    background: var(--conv-ask-soft);
    color: var(--conv-ask);
    font-weight: 600;
    white-space: nowrap;
}

.conv-node-chip.is-blank {
    background: color-mix(in srgb, var(--conv-issue-warn) 14%, var(--theme-background-raised));
    color: var(--theme-text-emphasis);
}

.conv-node-chip.is-bad {
    background: color-mix(in srgb, var(--conv-issue-error) 14%, var(--theme-background-raised));
    color: var(--conv-issue-error);
}

/* ── Sticky notes - the team's, pinned beside a moment, saved with the conversation ── */

.conv-note-card {
    position: absolute;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 8px 8px;
    border: 1px solid color-mix(in srgb, var(--conv-issue-warn) 45%, var(--theme-border-subtle));
    border-radius: var(--theme-radius);
    background: color-mix(in srgb, var(--conv-issue-warn) 14%, var(--theme-background-raised));
    box-shadow: var(--theme-shadow);
    color: var(--theme-text);
    font-size: 12px;
    line-height: 1.35;
    cursor: default;
    animation: conv-node-in var(--conv-motion);
    transition: opacity 200ms ease;
}

.conv-note-card.is-popped {
    z-index: 6;
    box-shadow: var(--theme-shadow-lg);
}

.conv-note-card.is-outside,
.conv-note-tab.is-outside {
    opacity: .25;
}

.conv-note-head {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--theme-text-muted);
    font-size: 11px;
    font-weight: 600;
}

.conv-note-kicker {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-note-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: var(--theme-radius-button);
    background: transparent;
    color: var(--theme-text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: background var(--conv-motion), color var(--conv-motion);
}

.conv-note-btn:hover,
.conv-note-btn:focus-visible {
    background: color-mix(in srgb, var(--conv-issue-warn) 22%, transparent);
    color: var(--theme-text-emphasis);
    outline: none;
}

.conv-note-text {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-line;
    word-break: break-word;
}

.conv-note-input {
    flex: 1;
    min-height: 0;
    padding: 4px 6px;
    border: 1px solid var(--theme-border);
    border-radius: calc(var(--theme-radius) * .75);
    background: var(--theme-background-raised);
    color: var(--theme-text);
    font: inherit;
    resize: none;
}

.conv-note-input:focus {
    border-color: var(--conv-issue-warn);
    outline: none;
}

.conv-note-tab {
    position: absolute;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--conv-issue-warn) 55%, var(--theme-border-subtle));
    border-radius: 6px;
    background: color-mix(in srgb, var(--conv-issue-warn) 30%, var(--theme-background-raised));
    box-shadow: var(--theme-shadow);
    color: var(--theme-text-emphasis);
    font-size: 11px;
    cursor: pointer;
    transition: transform var(--conv-motion), box-shadow var(--conv-motion);
}

.conv-note-tab:hover,
.conv-note-tab:focus-visible,
.conv-note-tab.is-open {
    box-shadow: var(--theme-shadow-lg);
    transform: translateY(-1px);
    outline: none;
}

.conv-tier-overview .conv-note-card,
.conv-tier-overview .conv-note-tab {
    display: none;
}

/* ── Reduced motion: every change is instant (bible 5.6) ──────────────── */

@media (prefers-reduced-motion: reduce) {
    .conv-node,
    .conv-tile,
    .conv-fold,
    .conv-edge,
    .conv-loopframe,
    .conv-band,
    .conv-insert-btn,
    .conv-node-grip,
    .conv-drop-reason,
    .conv-focusbar,
    .conv-starter,
    .conv-starters-plus,
    .conv-note-card,
    .conv-note-tab,
    .conv-note-btn {
        transition: none;
        animation: none;
    }

    .conv-note-tab:hover,
    .conv-note-tab.is-open {
        transform: none;
    }

    .conv-node:hover,
    .conv-node--tile:hover .conv-tile,
    .conv-starter:hover {
        transform: none;
    }

    .conv-node.is-pulsing,
    .conv-node--tile.is-pulsing .conv-tile {
        animation: none;
        box-shadow: 0 0 0 2px var(--conv-select), var(--theme-shadow-lg);
    }

    .conv-node--leaving {
        display: none;
    }
}
