.tree-root.atlas-root {
    min-height: 680px;
    overflow: hidden;
    padding: 0;
}
.layout:has(.tree-root.atlas-root) {
    grid-template-columns: minmax(0, 1fr);
}
.layout:has(.tree-root.atlas-root) .drawer,
.map-panel:has(.tree-root.atlas-root) .map-quick-actions {
    display: none;
}
.atlas-shell {
    position: relative;
    /* Capped by the space below the canvas so its dock stays on screen (SHARE-11). */
    min-height: 460px;
    height: clamp(460px, var(--atlas-shell-available-height, 78vh), max(720px, min(78vh, 900px)));
    overflow: hidden;
    display: grid;
    grid-template-rows: 1fr;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--card-soft);
    user-select: none;
}
.atlas-shell.atlas-fullscreen-fallback {
    position: fixed;
    inset: 0;
    z-index: var(--z-full-canvas);
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    background: var(--card);
}
body:has(.atlas-fullscreen-fallback) { overflow: hidden; }
.atlas-controls {
    position: absolute;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 5;
    display: block;
    pointer-events: none;
}
.atlas-controls-primary {
    position: relative;
    display: flex;
    align-items: stretch;
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
    gap: 5px;
    padding: 6px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: rgba(var(--card-rgb), .96);
    box-shadow: 0 16px 36px rgba(0,0,0,.24), var(--shadow-soft);
    backdrop-filter: blur(18px);
    pointer-events: auto;
}
.atlas-pod-handle {
    width: 42px;
    min-width: 42px;
    padding: 0 !important;
    color: var(--accent);
    cursor: grab;
    touch-action: none;
}
.atlas-pod-handle.is-dragging { cursor: grabbing; }
.atlas-controls .ghost-button,
.atlas-controls .primary-button {
    min-width: 64px;
    min-height: 42px;
    padding: 7px 11px;
    white-space: nowrap;
}
.atlas-tools-toggle {
    width: 42px;
    min-width: 42px !important;
    padding-inline: 0 !important;
}
.atlas-controls-secondary {
    position: absolute;
    bottom: calc(100% + 8px);
    z-index: 6;
    display: grid;
    width: min(320px, calc(100vw - 36px));
    max-height: min(62vh, 560px);
    overflow-y: auto;
    padding: 7px;
    border: 1px solid var(--line-strong);
    border-radius: 13px;
    background: rgba(var(--card-rgb), .985);
    box-shadow: 0 20px 48px rgba(0,0,0,.3), var(--shadow-soft);
    backdrop-filter: blur(18px);
    pointer-events: auto;
}
.atlas-controls-secondary[hidden] { display: none; }
/* The tray opens centred above the dock (phones widen it below). */
.atlas-shell .atlas-controls .atlas-controls-secondary { left: 50%; transform: translateX(-50%); }
.atlas-command-menu { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.atlas-command-menu > * { grid-column: 1 / 2; }
.atlas-command-menu > .ghost-button {
    justify-content: flex-start;
    width: 100%;
    border-color: transparent;
    background: transparent;
    text-align: left;
}
.atlas-command-menu > .ghost-button:hover,
.atlas-command-menu > .ghost-button:focus-visible {
    border-color: var(--line-strong);
    background: var(--card-soft);
}
.atlas-viewport {
    grid-row: 1;
    position: relative;
    min-height: 0;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    overscroll-behavior: contain;
    background:
        radial-gradient(circle at 50% 44%, rgba(var(--accent-rgb), .09), transparent 40%),
        linear-gradient(180deg, var(--card), var(--card-soft));
}
.atlas-viewport.panning { cursor: grabbing; }
.atlas-svg { width: 100%; height: 100%; display: block; }
.atlas-connection {
    fill: none;
    stroke: color-mix(in srgb, var(--accent) 48%, var(--line-strong));
    stroke-width: 4;
    stroke-dasharray: 10 10;
    stroke-linecap: round;
    opacity: .52;
    pointer-events: none;
}
.atlas-island {
    cursor: grab;
    color: var(--text);
}
.atlas-island:active { cursor: grabbing; }
.atlas-island.dragging { cursor: grabbing; opacity: .94; }
/* Keyboard focus is also drawn on the island shape, which every browser
   paints; an outline on an SVG group is not reliable (SHARE-19). */
.atlas-island:focus-visible .atlas-island-surface { stroke: var(--accent); stroke-width: 5; }
.atlas-island-surface {
    fill: var(--card);
    stroke: var(--line-strong);
    stroke-width: 3;
    filter: drop-shadow(0 14px 20px rgba(18, 32, 38, .12));
    transition: stroke .15s ease, filter .15s ease;
}
.atlas-island:hover .atlas-island-surface,
.atlas-island.selected .atlas-island-surface {
    stroke: var(--accent);
    stroke-width: 5;
    filter: drop-shadow(0 18px 28px rgba(var(--accent-rgb), .18));
}
.atlas-island.lifecycle-paused .atlas-island-surface { stroke-dasharray: 12 7; }
.atlas-island.lifecycle-completed .atlas-island-surface { stroke: var(--green); }
.atlas-island.lifecycle-archived { opacity: .72; }
.atlas-island.lifecycle-archived:hover, .atlas-island.lifecycle-archived.selected, .atlas-island.lifecycle-archived:focus-visible { opacity: 1; }
.atlas-island.lifecycle-archived .atlas-island-surface { stroke-dasharray: 3 8; }
.atlas-island-title {
    fill: var(--text);
    font-size: 18px;
    font-weight: 800;
}
.atlas-island-meta {
    fill: var(--muted);
    font-size: 12px;
    font-weight: var(--weight-semibold);
}
.atlas-primary-badge {
    fill: var(--accent);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}
.atlas-progress-track { fill: var(--surface-hover); }
.atlas-progress-value { fill: var(--green); }
.atlas-branch-row {
    fill: var(--text);
    font-size: 13px;
    font-weight: var(--weight-semibold);
}
.atlas-branch-row.status-todo .atlas-branch-bullet { fill: var(--red); }
.atlas-branch-row.status-learning .atlas-branch-bullet { fill: var(--blue); }
.atlas-branch-row.status-learned .atlas-branch-bullet { fill: var(--green); }
.atlas-branch-row.status-structural .atlas-branch-bullet { fill: var(--muted); }
.atlas-collapsed-label {
    fill: var(--muted);
    font-size: 12px;
    font-style: italic;
}
/* Explicit Fold/Show controls summary visibility at every semantic zoom level. */
.atlas-shell[data-atlas-level="overview"] .atlas-island-meta { font-size: 14px; }
/* Unsaved Atlas moves after a failed save (SHARE-21). */
.atlas-save-state {
    position: absolute;
    top: 12px;
    left: 50%;
    z-index: 3;
    transform: translateX(-50%);
    max-width: min(520px, calc(100% - 24px));
    margin: 0;
    padding: 8px 12px;
    border: 1px solid color-mix(in srgb, var(--red) 55%, var(--line));
    border-radius: 999px;
    background: rgba(var(--card-rgb), .96);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}
.atlas-save-state::before { content: "! "; color: var(--red); }
.atlas-save-state[hidden] { display: none; }
/* The hint sits just above the action dock, which takes the bottom row. */
.atlas-hint {
    position: absolute;
    left: 50%;
    bottom: 78px;
    transform: translateX(-50%);
    max-width: min(680px, calc(100% - 24px));
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(var(--card-rgb), .9);
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    pointer-events: none;
}
.atlas-loading,
.atlas-empty {
    place-items: center;
}
.atlas-empty {
    min-height: 620px;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 10px;
    padding: 28px;
    color: var(--muted);
    text-align: center;
}
.atlas-empty strong { color: var(--text); font-size: 18px; }

@media (max-width: 720px) {
    .atlas-shell {
        min-height: 480px;
        height: clamp(480px, 68dvh, 620px);
    }
    .atlas-shell:not(.atlas-fullscreen-fallback) .atlas-viewport {
        touch-action: pan-y;
        overscroll-behavior-y: auto;
    }
    .atlas-controls { right: 6px; bottom: max(6px, env(safe-area-inset-bottom)); left: 6px; }
    .atlas-controls-primary {
        gap: 3px;
        padding: 4px;
        border-radius: 12px;
    }
    .atlas-controls .ghost-button,
    .atlas-controls .primary-button,
    .atlas-tools-toggle {
        width: 100%;
        min-width: 0 !important;
        min-height: 44px;
        padding: 6px 3px;
        font-size: 11px;
    }
    .atlas-controls-secondary { right: 0; left: 0 !important; width: auto; transform: none !important; }
    .atlas-hint { bottom: 72px; border-radius: 14px; }
}

@media (max-height: 560px) {
    .tree-root.atlas-root { min-height: 240px; }
    .atlas-shell {
        min-height: 240px;
        height: clamp(240px, calc(100dvh - 120px), 520px);
    }
    .atlas-hint { display: none; }
}

@media (pointer: coarse), (any-pointer: coarse) {
    .atlas-shell:not(.atlas-fullscreen-fallback) .atlas-viewport {
        touch-action: pan-y;
        overscroll-behavior-y: auto;
    }
}

@media (forced-colors: active) {
    .atlas-island-surface { fill: Canvas; stroke: CanvasText; filter: none; }
    .atlas-island.selected .atlas-island-surface { stroke: Highlight; }
    .atlas-island-title, .atlas-island-meta, .atlas-branch-row { fill: CanvasText; }
}
