/* Work tree focus fade, Work drag states, and the small Path picker button. */
.small-button {
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 10px;
    padding: 7px 9px;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
}

.tree-root.focus-mode-on .dimmed-branch { opacity: .28; filter: saturate(.65); transition: opacity .16s ease, filter .16s ease; }
.tree-root.focus-mode-on .dimmed-branch:hover { opacity: .72; filter: saturate(.9); }
.tree-root.focus-mode-on .dimmed-branch::before { opacity: .22; }
.tree-root.focus-mode-on .dimmed-branch > ul::before { opacity: .22; }
.tree-root.work-root .node-card:not(.highlighted) { cursor: grab; }
.tree-root.work-root .node-card.work-dragging {
    cursor: grabbing;
    opacity: .9;
    pointer-events: none;
    position: relative;
    z-index: 8;
    box-shadow: 0 18px 38px rgba(31,41,51,.18);
}
.node-card.work-drag-ready { outline: 3px solid rgba(var(--accent-rgb), .28); }
.visual-node-svg.drag-ready rect { filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), .55)); }
.node-card.work-drop-child {
    outline: 3px solid rgba(var(--accent-rgb),.28);
    outline-offset: 3px;
}
.node-card.work-drop-before::before,
.node-card.work-drop-after::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    height: 4px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb),.12);
}
.node-card.work-drop-before::before { top: -8px; }
.node-card.work-drop-after::after { bottom: -8px; }
.depth-warning[hidden] { display: none; }
.drawer-form[hidden],
.drawer-empty-state[hidden],
.related-section[hidden],
.linked-map-section[hidden] { display: none !important; }

.note-items-section {
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 16px;
    padding: 12px;
    margin: 2px 0 12px;
}
.task-header { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 10px; }
.task-header h3 { margin: 0 0 4px; font-size: 15px; }
.task-header p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.note-item-list { display: grid; gap: 7px; margin-bottom: 10px; }
.note-item-list.empty { color: var(--muted); font-size: 13px; }
.branch-note-list { display: grid; gap: 8px; margin-bottom: 10px; }
.branch-note-list.empty { color: var(--muted); font-size: 13px; }
.branch-note-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
    border: 1px solid var(--line);
    background: var(--card-soft);
    border-radius: 12px;
    padding: 10px;
}
.branch-note-content { min-width: 0; }
.branch-note-card strong {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
}
.branch-note-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
    white-space: pre-wrap;
}
.branch-note-actions,
.note-item-actions { display: flex; gap: 6px; align-items: center; }
.branch-note-edit,
.branch-note-delete,
.note-item-edit,
.note-item-delete,
.note-item-move {
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 9px;
    color: var(--muted);
    padding: 5px 7px;
    font-size: 12px;
}
.branch-note-delete { color: var(--error-text); font-weight: 700; }
.note-item-move { min-width: 30px; font-weight: 800; }
.note-item-move:disabled { opacity: .45; cursor: default; }
.note-item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--line);
    background: var(--card-soft);
    border-radius: 12px;
    padding: 8px;
}
.note-item-row.checked { background: var(--green-soft); border-color: rgba(22,163,74,.22); }
.note-item-row.todo-drag-ready { outline: 2px solid rgba(var(--accent-rgb), .4); }
.note-item-row.todo-dragging { position: relative; z-index: 3; opacity: .88; pointer-events: none; box-shadow: 0 12px 24px rgba(31,41,51,.18); }
.note-item-row.todo-drop-before { box-shadow: 0 -4px 0 var(--accent); }
.note-item-row.todo-drop-after { box-shadow: 0 4px 0 var(--accent); }
.note-item-check { display: flex !important; gap: 8px !important; align-items: center; margin: 0 !important; color: var(--text) !important; font-size: 13px !important; min-width: 0; }
.note-item-check span { min-width: 0; overflow-wrap: anywhere; line-height: 1.4; }
.note-item-row.checked .note-item-check span { text-decoration: line-through; color: var(--muted); }
.note-item-delete { color: #b42318; font-weight: 700; }
.todos-evidence-prompt {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    padding: 11px;
    border: 1px solid color-mix(in srgb, var(--green) 32%, var(--line));
    border-radius: 12px;
    background: var(--green-soft);
}
.todos-evidence-prompt[hidden] { display: none; }
.todos-evidence-prompt strong,
.todos-evidence-prompt span { display: block; }
.todos-evidence-prompt span { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.add-note-item-row { display: grid; gap: 8px; }
.add-branch-note-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.add-branch-note-row textarea { grid-column: 1 / -1; }
.add-note-item-row { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.add-note-item-row textarea { min-height: 76px; margin: 0; resize: vertical; }
input:disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 720px) {
    .note-item-row { grid-template-columns: minmax(0, 1fr); gap: 11px; padding: 12px; }
    .note-item-check { align-items: flex-start; gap: 11px !important; font-size: 15px !important; }
    .note-item-check span { line-height: 1.45; }
    .note-item-actions,
    .branch-note-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .note-item-edit,
    .note-item-delete,
    .note-item-move,
    .branch-note-edit,
    .branch-note-delete { min-height: 44px; padding: 7px 10px; font-size: 13px; }
    .add-note-item-row { grid-template-columns: 1fr; }
    .add-branch-note-row { grid-template-columns: 1fr; }
    .branch-note-card { grid-template-columns: 1fr; gap: 11px; padding: 12px; }
    .todos-evidence-prompt { grid-template-columns: 1fr; }
    .todos-evidence-prompt .ghost-button { width: 100%; justify-content: center; min-height: 42px; }
}

/* v1.2 refinements: less header, cleaner cards, plan view */
.app-shell { padding-top: 18px; }
.compact-hero { margin-top: 0; }
.hero-copy { min-width: 0; flex: 1 1 auto; }
.hero-copy h1 { font-size: clamp(28px, 4vw, 42px); margin: 8px 0 10px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-content: start; }
.drawer .icon-button#closeDrawer { display: none !important; }
.drawer-header { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.drawer-header h2 { margin-bottom: 0; }
.node-title-row { position: relative; padding-right: 2px; }
.child-count {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 22px;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid rgba(var(--accent-rgb),.2);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}
.map-toolbar-actions .view-switch { flex: 1 1 100%; }
.view-switch { display: inline-flex; gap: 4px; padding: 4px; background: var(--card-soft); border: 1px solid var(--line); border-radius: 14px; }
.view-switch .view-button { flex: 1 1 0; }
.view-button { border: 0; background: transparent; color: var(--muted); border-radius: 10px; padding: 8px 10px; font-weight: 700; }
.view-button.active { background: var(--card); color: var(--accent); box-shadow: 0 4px 16px rgba(31,41,51,.08); }
.checkbox-row input,
.note-item-check input,
.focus-action-toggle input {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--control-border);
    border-radius: 6px;
    background: var(--card);
    display: inline-grid;
    place-content: center;
    flex: 0 0 auto;
}
.checkbox-row input::before,
.note-item-check input::before,
.focus-action-toggle input::before {
    content: "";
    width: 9px;
    height: 9px;
    transform: scale(0);
    transition: transform .08s ease;
    clip-path: polygon(14% 44%, 0 60%, 38% 100%, 100% 17%, 84% 0, 35% 64%);
    background: var(--card);
}
.checkbox-row input:checked,
.note-item-check input:checked,
.focus-action-toggle input:checked { background: var(--accent); border-color: var(--accent); }
.checkbox-row input:checked::before,
.note-item-check input:checked::before,
.focus-action-toggle input:checked::before { transform: scale(1); }
.note-item-check input { margin: 0; }
.note-item-row.checked .note-item-check input { background: var(--green); border-color: var(--green); }

.tree-root.plan-root { overflow: hidden; padding: 0; min-height: 680px; }
.visual-shell {
    overflow: hidden;
    grid-template-rows: auto 1fr;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--card), var(--card-soft));
    user-select: none;
}
.visual-controls {
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.visual-controls .ghost-button {
    min-height: 36px;
    padding: 7px 11px;
    border-radius: 10px;
    white-space: nowrap;
}
.visual-controls .ghost-button[data-visual-action="zoom-out"],
.visual-controls .ghost-button[data-visual-action="zoom-in"] {
    width: 44px;
    min-height: 44px;
    padding-inline: 0;
    font-size: 20px;
    line-height: 1;
}
.visual-zoom-readout {
    min-width: 104px;
    min-height: 36px;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
}
.visual-zoom-readout strong { font-size: 13px; }
.visual-zoom-readout span { color: var(--muted); }
.visual-controls .visual-branch-fold,
.visual-controls .visual-select-toggle,
.visual-controls .visual-bulk-connect,
.visual-controls .visual-disconnect-button,
.visual-controls .ghost-button[data-visual-action="reset-layout"],
.visual-controls .ghost-button[data-visual-action="fullscreen"] {
    min-width: 112px;
}
.visual-controls .ghost-button:disabled {
    opacity: .45;
    cursor: not-allowed;
    background: var(--card-soft);
}
.visual-viewport {
    position: relative;
    overflow: hidden;
    min-height: 0;
    cursor: grab;
    touch-action: none;
    overscroll-behavior: contain;
    -webkit-user-select: none;
    user-select: none;
}
.visual-marquee {
    position: absolute;
    z-index: 8;
    display: none;
    pointer-events: none;
    border: 2px solid var(--accent);
    border-radius: 6px;
    background: rgba(var(--accent-rgb),.14);
    box-shadow: 0 0 0 1px rgba(var(--card-rgb),.72);
}
.visual-marquee.active { display: block; }
.visual-viewport.marquee-selecting { cursor: crosshair; }
.visual-viewport.panning { cursor: grabbing; }
.visual-viewport.pinching { cursor: zoom-in; }
.visual-embedded-touch-hint { display: none; }

@media (max-width: 1250px) {
    .hero-actions { justify-content: flex-start; }
}
@media (max-width: 720px) {
    .compact-hero { flex-direction: column; }
    .map-toolbar-actions { justify-content: flex-start; }
}

/* Plan View measures the space below the embedded canvas so its action dock
   stays on screen on common laptop heights; it never grows past the old size. */
.visual-shell {
    min-height: 460px;
    height: clamp(460px, var(--visual-shell-available-height, 78vh), max(720px, min(78vh, 900px)));
}
.visual-shell.visual-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-radius: 0;
    border: 0;
    background: var(--card);
}
/* The dock row is transparent and spans the canvas; only its bar paints, so
   the row itself carries no shadow (it drew a band across the full canvas). */
.visual-shell.visual-fullscreen-fallback .visual-controls {
    align-items: center;
    gap: 8px;
}
.visual-shell.visual-fullscreen-fallback .visual-viewport { min-height: 0; }
.visual-shell.visual-fullscreen-fallback .visual-controls .ghost-button {
    min-height: 36px;
    padding: 7px 11px;
}
.visual-side-panel {
    position: absolute;
    top: 60px;
    bottom: 14px;
    z-index: 11;
    width: min(360px, calc(100vw - 34px));
    overflow: auto;
    border: 1px solid rgba(159,178,177,.45);
    border-radius: 18px;
    background: rgba(var(--card-rgb),.94);
    box-shadow: 0 18px 46px rgba(31,41,51,.16);
    backdrop-filter: blur(10px);
    padding: 14px;
    display: grid;
    align-content: start;
    gap: 12px;
    transition: transform .18s ease, opacity .18s ease;
    opacity: 0;
    pointer-events: none;
}
.visual-find-panel {
    left: 12px;
    transform: translateX(calc(-100% - 18px));
}
.visual-side-panel.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}
.visual-panel-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}
.visual-panel-head h3 {
    margin: 0;
    letter-spacing: 0;
}
.visual-side-panel label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    margin: 0;
}
.visual-side-panel .checkbox-row {
    display: flex !important;
}
.visual-side-panel .focus-scope-toggle {
    width: 100%;
}
.visual-side-panel .scope-button {
    flex: 1 1 0;
}
.visual-controls .visual-select-toggle.active,
.visual-controls .visual-bulk-connect.active {
    background: var(--accent-soft);
    border-color: rgba(var(--accent-rgb),.35);
    color: var(--accent);
    font-weight: 700;
}
.visual-controls .visual-bulk-connect:not(:disabled) { border-color: rgba(var(--accent-rgb),.3); }
.visual-controls .visual-branch-fold:not(:disabled) { border-color: rgba(var(--accent-rgb),.3); }
.visual-controls .visual-disconnect-button:not(:disabled) { color: #7a4d00; border-color: rgba(245,158,11,.35); background: #fffaf0; }
body:has(.visual-fullscreen-fallback) { overflow: hidden; }
/* v1.5 growth paths + SVG plan canvas */
.branch-map-actions,
.linked-map-section {
    border: 1px solid var(--line);
    background: var(--card-soft);
    border-radius: 16px;
    padding: 12px;
    display: grid;
    gap: 10px;
    margin: 4px 0 12px;
}
.branch-map-actions h3,
.linked-map-section h3 { margin: 0 0 4px; font-size: 14px; }
.branch-map-actions p,
.linked-map-section p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.branch-map-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.branch-position-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.branch-position-content { display: grid; gap: 12px; }
.branch-position-intro { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.branch-position-fields { display: grid; gap: 10px; }
.branch-position-fields label { display: grid; gap: 6px; }
.branch-position-fields .primary-button { width: 100%; justify-content: center; }
.branch-position-content > .field-help { margin: -3px 0 0; }
.drawer-section-position[hidden] { display: none !important; }
.map-link-badge {
    margin-left: 7px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.node-card.map-link-card { border-style: dashed; }

.visual-svg-canvas {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 100%;
    touch-action: none;
}
/* Plan canvas surface, connectors, and card shadow for both themes. The
   card shadow is a token so selection, drop-target, and drag states keep
   their own glow in dark mode too (STYLE-18). */
.visual-viewport,
.visual-svg-canvas {
    --plan-card-shadow: drop-shadow(0 8px 16px rgba(31,41,51,.09));
    background:
        radial-gradient(circle at center, var(--accent-glow), transparent 43%),
        linear-gradient(180deg, var(--card), var(--card-soft));
}
html[data-theme="dark"] :is(.visual-viewport, .visual-svg-canvas) {
    --plan-card-shadow: drop-shadow(0 9px 18px rgba(0,0,0,.34));
}
.visual-svg-canvas path {
    stroke: color-mix(in srgb, var(--accent) 55%, var(--line-strong));
    stroke-width: 2.6;
    stroke-linecap: round;
    fill: none;
    opacity: .68;
    vector-effect: non-scaling-stroke;
}
/* Dark connectors follow the chosen accent, mixed lower than in light mode. */
html[data-theme="dark"] .visual-svg-canvas path { stroke: color-mix(in srgb, var(--accent) 36%, var(--line-strong)); }
.visual-node-layer,
.visual-line-layer,
.visual-relationship-layer {
    transition: opacity .09s ease-out;
}
.visual-shell.visual-entry-settling .visual-node-layer,
.visual-shell.visual-entry-settling .visual-line-layer,
.visual-shell.visual-entry-settling .visual-relationship-layer {
    opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
    .visual-node-layer,
    .visual-line-layer,
    .visual-relationship-layer { transition: none; }
}
.visual-node-svg { cursor: pointer; outline: none; transition: opacity .22s ease, transform .22s ease; }
.visual-node-svg:focus-visible rect:not(.visual-root-keyline) {
    stroke: var(--accent);
    stroke-width: 4;
    filter: drop-shadow(0 0 0 rgba(var(--accent-rgb),0)) drop-shadow(0 8px 20px rgba(var(--accent-rgb),.28));
}
.visual-node-svg.dragging {
    transition: none;
}
.visual-node-svg.dragging rect {
    filter: none;
}
.visual-node-content {
    transform-box: fill-box;
    transform-origin: center;
    transition: opacity .18s ease;
}
.visual-node-svg text { user-select: none; }
.visual-node-svg rect {
    fill: var(--card);
    stroke: var(--line-strong);
    stroke-width: 2;
    filter: var(--plan-card-shadow);
    transition: stroke .12s ease, opacity .12s ease, filter .12s ease;
}
.visual-node-svg.status-todo rect { stroke: rgba(217,83,79,.42); }
.visual-node-svg.status-learning rect { stroke: rgba(37,99,235,.42); }
.visual-node-svg.status-learned rect { stroke: rgba(22,163,74,.42); }
.visual-node-svg.status-structural rect { stroke: var(--line-strong); }
.visual-node-svg.deadline-heat-far { --deadline-heat: var(--accent); --deadline-fill: color-mix(in srgb, var(--accent-soft) 42%, var(--card)); }
.visual-node-svg.deadline-heat-watch { --deadline-heat: color-mix(in srgb, var(--accent) 55%, var(--amber)); --deadline-fill: color-mix(in srgb, var(--amber-soft) 32%, var(--card)); }
.visual-node-svg.deadline-heat-soon { --deadline-heat: var(--amber); --deadline-fill: color-mix(in srgb, var(--amber-soft) 48%, var(--card)); }
.visual-node-svg.deadline-heat-urgent { --deadline-heat: #e06b26; --deadline-fill: color-mix(in srgb, #e06b26 10%, var(--card)); }
.visual-node-svg.deadline-heat-imminent { --deadline-heat: var(--red); --deadline-fill: color-mix(in srgb, var(--red-soft) 64%, var(--card)); }
.visual-node-svg.deadline-heat-today { --deadline-heat: #f02f29; --deadline-fill: color-mix(in srgb, #f02f29 16%, var(--card)); }
.visual-node-svg.deadline-heat-overdue { --deadline-heat: #b91c1c; --deadline-fill: color-mix(in srgb, #b91c1c 14%, var(--card)); }
.visual-node-svg[class*="deadline-heat-"]:not(.visual-root-node) .visual-node-content > rect:not(.visual-root-keyline) {
    fill: var(--deadline-fill);
}
.visual-node-svg .visual-deadline-rail {
    stroke: var(--deadline-heat);
    stroke-width: 5;
    stroke-linecap: round;
    opacity: .88;
    pointer-events: none;
    vector-effect: non-scaling-stroke;
}
.visual-node-svg.deadline-next .visual-deadline-rail { stroke-width: 7; opacity: 1; }
.visual-node-svg.deadline-heat-today .visual-deadline-rail,
.visual-node-svg.deadline-heat-overdue .visual-deadline-rail {
    filter: drop-shadow(0 0 5px color-mix(in srgb, var(--deadline-heat) 62%, transparent));
}
.visual-node-svg[class*="deadline-heat-"] .visual-time-marker-svg { fill: var(--deadline-heat); }
.visual-deadline-next-svg { font-weight: 800; letter-spacing: .06em; }
.visual-node-svg.visual-loose-node rect { stroke-dasharray: 7 5; fill: var(--card-soft); }
.visual-node-svg.visual-root-node .visual-root-surface {
    fill: var(--card-soft);
    stroke: color-mix(in srgb, var(--accent) 82%, white);
    stroke-width: 2.5;
    filter: drop-shadow(0 7px 12px rgba(var(--accent-rgb),.24));
}
.visual-node-svg.visual-root-node .visual-root-keyline {
    fill: none;
    stroke: rgba(var(--accent-rgb),.42);
    stroke-width: 1.4;
    filter: none;
    pointer-events: none;
}
.visual-node-svg.visual-root-node.status-learned .visual-root-surface { fill: var(--card-soft); stroke: color-mix(in srgb, var(--green) 72%, white); }
.visual-node-svg.visual-root-node .visual-svg-title { fill: var(--text); font-weight: 800; }
.visual-node-svg.visual-root-node .visual-root-title {
    letter-spacing: -.012em;
    paint-order: normal;
    stroke: none;
}
.visual-svg-title { fill: var(--text); font-size: calc(13px * var(--plan-branch-font-scale, 1)); font-weight: 700; pointer-events: none; }
.visual-status-symbol { fill: var(--muted); font-size: calc(14px * var(--plan-branch-font-scale, 1)); font-weight: 800; pointer-events: none; }
.visual-node-svg.status-todo .visual-status-symbol { fill: #b3403d; }
.visual-node-svg.status-learning .visual-status-symbol { fill: #2563eb; }
.visual-node-svg.status-learned .visual-status-symbol { fill: #16833d; }
/* The status symbol is the non-colour status cue; in dark mode it uses the
   dark status tokens so it stays readable on dark cards (STYLE-05). */
html[data-theme="dark"] .visual-node-svg.status-todo .visual-status-symbol { fill: var(--red); }
html[data-theme="dark"] .visual-node-svg.status-learning .visual-status-symbol { fill: var(--blue); }
html[data-theme="dark"] .visual-node-svg.status-learned .visual-status-symbol { fill: var(--green); }
.visual-node-svg.visual-root-node .visual-status-symbol { fill: var(--text); }
.visual-node-svg.selected rect,
.visual-node-svg.active-path-node rect {
    stroke: var(--accent);
    filter: drop-shadow(0 10px 22px rgba(var(--accent-rgb),.18));
}
.visual-node-svg.multi-selected rect {
    stroke: var(--accent);
    stroke-width: 3;
    filter: drop-shadow(0 10px 24px rgba(var(--accent-rgb),.24));
}
.visual-node-svg.connect-target rect {
    stroke-dasharray: 8 5;
}
.visual-shell.select-mode .visual-node-svg:not(.visual-root-node) { cursor: copy; }
.visual-shell.connect-mode .visual-node-svg:not(.multi-selected) { cursor: cell; }
.visual-node-svg.drop-target rect {
    stroke: var(--accent);
    stroke-width: 4;
    filter: drop-shadow(0 0 0 rgba(var(--accent-rgb),0)) drop-shadow(0 12px 26px rgba(var(--accent-rgb),.24));
}
.visual-drop-intent { position: absolute; z-index: 8; max-width: 210px; padding: 8px 11px; border: 1px solid var(--accent); border-radius: 9px; color: var(--text); background: color-mix(in srgb, var(--surface-solid) 94%, transparent); box-shadow: var(--shadow-soft); font-size: 12px; font-weight: 800; pointer-events: none; }
.visual-relationship-label { fill: var(--accent); font: 700 12px var(--font-sans); paint-order: stroke; stroke: var(--surface-solid); stroke-width: 5px; }
/* A faded branch dims its content but keeps an opaque card behind it, so
   connector lines never show through its title. */
.visual-node-svg.visual-faded .visual-node-content { opacity: .28; }
.visual-node-svg.visual-faded:hover .visual-node-content { opacity: .72; }
.visual-node-svg.visual-faded rect.visual-node-hit-target { fill: var(--card) !important; }
@keyframes mintyVisualBranchCreated {
    0% { filter: drop-shadow(0 0 0 rgba(var(--accent-rgb), 0)); }
    32% { filter: drop-shadow(0 0 12px rgba(var(--accent-rgb), .42)); }
    100% { filter: drop-shadow(0 0 0 rgba(var(--accent-rgb), 0)); }
}
.visual-node-svg.visual-just-created .visual-node-content > rect:not(.visual-root-keyline) {
    animation: mintyVisualBranchCreated .9s ease-out;
}
.visual-svg-canvas path.visual-line-faded { opacity: .16; }
.visual-node-svg.dragging { opacity: .92; cursor: grabbing !important; pointer-events: none; }
/* Branches can always be dragged; the central outcome stays anchored. Select,
   connect, and relate modes show their own cursor (more specific rules). */
.visual-shell .visual-node-svg:not(.visual-root-node) { cursor: grab; }
.visual-shell .visual-node-svg.visual-root-node { cursor: not-allowed; }
.visual-collapse-svg { cursor: pointer; }
.visual-collapse-svg.is-pending { opacity: .58; }
.visual-collapse-svg.is-pending:not(.is-queueable) { pointer-events: none; }
.visual-collapse-svg .visual-collapse-hit { fill: transparent; stroke: none; }
.visual-collapse-svg circle { fill: var(--card); stroke: rgba(var(--accent-rgb),.28); stroke-width: 1.4px; filter: drop-shadow(0 4px 8px rgba(31,41,51,.11)); }
.visual-collapse-svg text { fill: var(--accent); font-size: 18px; font-weight: 700; pointer-events: none; }
.visual-collapse-edge-svg .visual-collapse-hit { fill: transparent; stroke: none; }
.visual-collapse-edge-svg text { fill: var(--accent); font-size: 36px; font-weight: 800; letter-spacing: -.04em; pointer-events: none; }
.visual-collapse-edge-svg:hover text { fill: color-mix(in srgb, var(--accent) 82%, white); }
.visual-hidden-count-svg { fill: var(--accent); font-size: calc(12px * var(--plan-branch-font-scale, 1)); font-weight: 700; }
.visual-semantic-count-svg { fill: var(--muted); font-size: calc(11px * var(--plan-branch-font-scale, 1)); font-weight: 700; pointer-events: none; }
.visual-shell[data-zoom-mode="overview"] .visual-semantic-count-svg { fill: var(--accent); font-size: calc(12px * var(--plan-branch-font-scale, 1)); }
.visual-link-mark { fill: var(--accent); font-size: calc(16px * var(--plan-branch-font-scale, 1)); font-weight: 700; pointer-events: none; }
.visual-node-svg.map-link-node rect { stroke-dasharray: 7 5; fill: var(--card-soft); }
.visual-node-svg rect.visual-node-hit-target {
    fill: transparent !important;
    stroke: transparent !important;
    stroke-width: 14;
    stroke-dasharray: none !important;
    vector-effect: non-scaling-stroke;
    filter: none !important;
    pointer-events: stroke;
}
@media (pointer: coarse) {
    .visual-node-svg rect.visual-node-hit-target { stroke-width: 28; }
}

.visual-hierarchy-line,
.visual-line-pulse,
.visual-relationship-line { transition: opacity .22s ease; }

/* workspace command center */
.compact-hero {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) minmax(520px, .92fr);
    align-items: stretch;
}
.compact-hero[hidden] {
    display: none;
}
.hero-utility-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    min-width: 0;
    margin-top: 14px;
}
.hero-utility-actions .ghost-button {
    white-space: nowrap;
    min-height: 36px;
    padding: 8px 11px;
    font-size: 13px;
    border-radius: 999px;
}
.focus-scope-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card-soft);
    white-space: nowrap;
}
.scope-button {
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 9px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 700;
}
.scope-button.active {
    background: var(--card);
    color: var(--accent);
    box-shadow: 0 4px 14px rgba(31,41,51,.08);
}
.path-select-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(72px, auto);
    gap: 8px;
}
.path-select-row .small-button {
    min-height: 44px;
    padding-inline: 14px;
    border-radius: 12px;
    font-size: 13px;
}
.layout { grid-template-columns: minmax(560px, .62fr) minmax(420px, .38fr); }
.map-panel:has(.tree-root.plan-root) .map-quick-actions {
    display: none;
}

/* responsive layout repair */
@media (max-width: 1360px) {
    .compact-hero {
        grid-template-columns: 1fr;
    }
    .hero-utility-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 1250px) {
    .layout { grid-template-columns: 1fr; }
    .drawer {
        position: static;
        grid-column: 1 / -1;
        max-height: none;
    }
    .map-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }
    .map-toolbar-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 1120px) {
    .hero-utility-actions {
        width: auto;
    }
    .hero-utility-actions .ghost-button {
        min-height: 44px;
        padding-inline: 12px;
    }
}

@media (max-width: 980px) {
    .sidebar {
        position: static;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
    .drawer {
        width: 100%;
    }
    .tree {
        min-width: 0;
    }
    .tree-root {
        overflow-x: auto;
    }
    .node-card {
        width: 100%;
    }
}

@media (max-width: 720px) {
    html,
    body {
        overflow-x: clip;
    }
    .app-shell {
        width: 100%;
        padding: 6px 6px 24px;
    }
    .hero-panel {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
        padding: 14px;
        border-radius: 18px;
    }
    .hero-copy {
        display: grid;
        gap: 8px;
    }
    .hero-copy .pill {
        width: max-content;
    }
    .hero-copy h1 {
        font-size: 24px;
        line-height: 1.12;
        margin: 0;
        overflow-wrap: anywhere;
    }
    .hero-copy p {
        margin: 0;
        font-size: 13px;
    }
    .hero-actions {
        justify-content: flex-start;
    }
    .hero-actions .ghost-button {
        flex: 1 1 calc(50% - 8px);
    }
    .layout,
    .sidebar {
        grid-template-columns: 1fr;
    }
    .hero-utility-actions {
        width: 100%;
    }
    .scope-button {
        flex: 1 1 0;
    }
    .hero-utility-actions .ghost-button {
        min-height: 42px;
        width: auto;
    }
    .path-select-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .path-select-row .small-button {
        min-width: 54px;
        padding-inline: 10px;
    }
    .panel,
    .map-panel,
    .drawer {
        border-radius: 16px;
        padding: 16px;
    }
    .map-panel {
        padding: 9px;
    }
    .map-toolbar {
        align-items: stretch;
        flex-direction: column;
        grid-template-columns: 1fr;
        gap: 7px;
        padding-bottom: 8px;
        margin-bottom: 8px;
    }
    .map-toolbar h2 {
        margin: 0;
        font-size: 18px;
        line-height: 1.15;
    }
    .map-toolbar p {
        display: none;
    }
    .map-toolbar-actions,
    .view-switch {
        width: 100%;
    }
    .view-switch {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 3px;
        border-radius: 12px;
    }
    .view-switch:has(#atlasViewBtn) {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .view-button {
        min-height: 32px;
        padding: 6px 8px;
        border-radius: 9px;
        font-size: 12px;
    }
    .map-toolbar-actions > .primary-button {
        width: 100%;
    }
    .tree-root {
        min-height: 420px;
        padding: 4px 0 28px;
    }
    .tree {
        min-width: 0;
    }
    .tree ul {
        padding-left: 20px;
    }
    .tree ul::before {
        left: 8px;
    }
    .tree li::before {
        left: -12px;
        width: 12px;
    }
    .node-card {
        grid-template-columns: auto minmax(0, 1fr);
        gap: 8px;
        padding: 10px;
    }
    .node-main {
        grid-column: 2;
        grid-row: 2;
    }
    .node-side {
        grid-column: 2;
        grid-row: 1;
        justify-items: start;
        display: flex;
        align-items: center;
        min-width: 0;
    }
    .quick-status {
        flex: 0 0 auto;
    }
    .node-description {
        max-width: none;
    }
    .drawer-actions .primary-button,
    .drawer-actions .ghost-button {
        flex: 1 1 100%;
    }
    .tree-root.plan-root {
        min-height: 430px;
    }
    .visual-shell {
        min-height: 430px;
        height: calc(100vh - 186px);
        height: calc(100dvh - 186px);
        border-radius: 14px;
    }
    .visual-shell:not(.visual-fullscreen-fallback) {
        min-height: 480px;
        height: clamp(480px, 68dvh, 620px);
    }
    .drawer {
        scroll-margin-top: 12px;
    }
    .visual-controls {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: stretch;
        gap: 4px;
    }
    .visual-controls .ghost-button {
        flex: initial;
        min-width: 0;
        min-height: 44px;
        padding: 6px 5px;
        border-radius: 8px;
        font-size: 11px;
        line-height: 1.15;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .visual-controls .visual-branch-fold,
    .visual-controls .visual-select-toggle,
    .visual-controls .visual-bulk-connect,
    .visual-controls .visual-disconnect-button,
    .visual-controls .ghost-button[data-visual-action="reset-layout"],
    .visual-controls .ghost-button[data-visual-action="fullscreen"] {
        min-width: 0;
    }
    .visual-viewport {
        min-height: 0;
    }
    .visual-shell.visual-fullscreen-fallback {
        height: 100vh;
        height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
    }
    .visual-shell.visual-fullscreen-fallback .visual-controls {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px;
        align-items: stretch;
    }
    .visual-shell.visual-fullscreen-fallback .visual-controls .ghost-button {
        min-height: 44px;
        padding: 6px 5px;
        border-radius: 8px;
        font-size: 11px;
        line-height: 1.15;
        white-space: normal;
    }
    .visual-shell.visual-fullscreen-fallback .visual-side-panel {
        bottom: 8px;
        left: 8px;
        width: calc(100vw - 16px);
        max-width: none;
        border-radius: 14px;
        padding: 10px;
    }
    .scope-button {
        min-height: 44px;
    }
    .map-panel:has(.tree-root.plan-root) .map-toolbar {
        gap: 6px;
        padding-bottom: 6px;
        margin-bottom: 6px;
    }
}

@media (max-width: 420px) {
    .visual-controls,
    .visual-shell.visual-fullscreen-fallback .visual-controls {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .visual-controls .ghost-button,
    .visual-controls .visual-more-menu > summary {
        overflow-wrap: normal;
        word-break: normal;
    }
    .visual-controls-secondary .visual-zoom-readout {
        grid-column: span 1;
        justify-content: center;
        font-size: 11px;
    }
    .visual-controls-secondary .visual-zoom-readout strong {
        font-size: 12px;
    }
}

@media (max-width: 720px) {
    .visual-controls .ghost-button[data-visual-action="zoom-out"],
    .visual-controls .ghost-button[data-visual-action="zoom-in"] {
        display: inline-flex;
        width: auto;
        min-height: 44px;
        font-size: 22px;
    }
    .visual-shell:not(.visual-fullscreen-fallback) .visual-viewport,
    .visual-shell:not(.visual-fullscreen-fallback) .visual-svg-canvas {
        touch-action: pan-y;
        overscroll-behavior-y: auto;
    }
    .visual-shell:not(.visual-fullscreen-fallback) .visual-node-svg {
        touch-action: pan-y;
    }
    .visual-controls .visual-more-menu {
        position: relative;
    }
    .visual-controls .visual-more-menu > summary {
        height: 44px;
        min-height: 44px;
    }
    .visual-controls .visual-more-popover {
        left: calc(-100% - 4px);
        right: auto;
        top: calc(100% + 4px);
        min-width: 0;
        width: calc(400% + 12px);
    }
    .visual-controls .visual-more-popover .ghost-button {
        min-height: 44px;
        justify-content: center;
        font-size: 12px;
    }
}

@media (max-height: 560px) {
    .tree-root.plan-root { min-height: 240px; }
    .visual-shell:not(.visual-fullscreen-fallback) {
        min-height: 240px;
        height: clamp(240px, calc(100dvh - 120px), 520px);
    }
}

@media (pointer: coarse), (any-pointer: coarse) {
    .visual-shell:not(.visual-fullscreen-fallback) .visual-viewport,
    .visual-shell:not(.visual-fullscreen-fallback) .visual-svg-canvas,
    .visual-shell:not(.visual-fullscreen-fallback) .visual-node-svg {
        touch-action: pan-y;
        overscroll-behavior-y: auto;
    }
    .visual-shell:not(.visual-fullscreen-fallback) .visual-embedded-touch-hint,
    .atlas-shell:not(.atlas-fullscreen-fallback) .visual-embedded-touch-hint {
        position: absolute;
        z-index: 5;
        top: 64px;
        left: 50%;
        display: block;
        max-width: calc(100% - 24px);
        margin: 0;
        padding: 6px 10px;
        transform: translateX(-50%);
        border: 1px solid var(--line);
        border-radius: 999px;
        background: rgba(var(--card-rgb), .9);
        color: var(--muted);
        font-size: 11px;
        line-height: 1.25;
        text-align: center;
        width: max-content;
        white-space: normal;
        text-wrap: balance;
        pointer-events: none;
    }
    .view-button,
    .scope-button,
    .map-toolbar-actions .primary-button,
    .map-toolbar-actions .ghost-button,
    .map-control-group .primary-button,
    .map-control-group .ghost-button,
    .map-control-group .map-option-check,
    .visual-controls .ghost-button,
    .visual-controls .visual-more-menu > summary {
        min-height: 44px;
    }
    .toggle-button {
        width: 40px;
        height: 40px;
        border-radius: 11px;
    }
    .status-dot-button {
        min-width: 40px;
        min-height: 40px;
        padding: 9px;
    }
    .node-card.work-dragging { touch-action: none; }
    .visual-side-panel,
    body:has(.visual-fullscreen-fallback) .drawer {
        overscroll-behavior: contain;
    }
}
