/* ─── APPEARANCE PANEL ──────────────────────────── */
.appearance-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: var(--z-appearance, 500);
    justify-content: center;
    align-items: center;
}
.appearance-overlay.open {
    display: flex;
}
.appearance-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: 0 8px 32px var(--shadow-xl);
    width: 480px;
    max-width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.5rem;
}
.appearance-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.appearance-panel-header h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--charcoal);
    margin: 0;
}
.appearance-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--slate);
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.15s;
}
.appearance-panel-close:hover {
    color: var(--charcoal);
}
.appearance-theme-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.appearance-theme-card {
    border: 2px solid var(--border-light);
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: none;
    text-align: left;
    width: 100%;
    font-family: 'Open Sans', sans-serif;
}
.appearance-theme-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px var(--shadow-primary);
}
.appearance-theme-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}
.appearance-theme-swatches {
    display: flex;
    gap: 4px;
    margin-bottom: 0.5rem;
}
.appearance-theme-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(128,128,128,0.3);
}
.appearance-theme-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--charcoal);
    margin-bottom: 0.15rem;
}
.appearance-theme-desc {
    font-size: 0.65rem;
    color: var(--slate);
    line-height: 1.4;
}
.appearance-mode-toggle {
    display: flex;
    background: var(--border-light);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 1rem;
    gap: 2px;
}
.appearance-mode-btn {
    flex: 1;
    padding: 0.4rem 0.75rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--slate);
    background: none;
    transition: background 0.15s, color 0.15s;
}
.appearance-mode-btn.active {
    background: var(--bg-surface);
    color: var(--charcoal);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.appearance-mode-btn:hover:not(.active) {
    color: var(--charcoal);
}
.appearance-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--slate);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    margin-top: 0.25rem;
}

/* Hide graph area when in script view */
.script-view-active .graph-area {
    display: none;
}

/* ─── SCRIPT EDITOR ──────────────────────────────── */
.script-area {
    display: none;
    flex: 1;
    min-height: 100vh;
    padding: 1rem 2rem;
    overflow-y: auto;
    background: var(--cream);
}

.script-view-active .script-area {
    display: block;
}

.script-container {
    width: 100%;
    height: 100%;
    background: var(--bg-surface);
    border-radius: 0;
    padding: 1.5rem 2rem;
    box-shadow: none;
    min-height: calc(100vh - 80px);
}

.script-header {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0;
    padding-bottom: 0.75rem;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── Script Formatting Toolbar ── */
.script-format-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0.4rem 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--bg-surface);
    flex-wrap: wrap;
}

.script-format-toolbar .fmt-divider {
    width: 1px;
    height: 1.2rem;
    background: var(--border-light);
    margin: 0 0.3rem;
}

.script-format-toolbar button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--charcoal);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Open Sans', sans-serif;
    transition: background 0.12s, color 0.12s;
    position: relative;
}

.script-format-toolbar button:hover {
    background: var(--primary-tint-sm);
    color: var(--primary);
}

.script-format-toolbar button.active {
    background: var(--primary-tint);
    color: var(--primary);
}

.script-format-toolbar button .i {
    width: 14px;
    height: 14px;
}

.script-format-toolbar .fmt-heading-btn {
    font-size: 0.75rem;
    width: auto;
    padding: 0 0.4rem;
    font-weight: 700;
}

/* Phone formatting toolbar - compact */
.phone-script-wrap .script-format-toolbar {
    margin-bottom: 0.5rem;
    padding: 0.25rem 0.35rem;
    gap: 1px;
}

.phone-script-wrap .script-format-toolbar button {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.8rem;
}

.script-save-indicator {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--slate);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.script-save-indicator.saving {
    color: var(--primary);
}

.script-save-indicator.saved {
    color: var(--color-success);
}

.script-save-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.script-save-indicator.saving .script-save-dot {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.script-editor {
    width: 100%;
    height: calc(100% - 110px);
    min-height: 500px;
    border: 2px dashed transparent;
    border-radius: 8px;
    outline: none;
    touch-action: pan-y;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--charcoal);
    background: transparent;
    resize: none;
    transition: border-color 0.15s, background 0.15s;
}

.script-editor.drag-over {
    border-color: var(--primary);
    background: var(--primary-tint-sm);
}

/* Rich text formatting inside script editor */
.script-editor h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0.75rem 0 0.4rem;
    line-height: 1.3;
}

.script-editor h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--charcoal);
    margin: 0.6rem 0 0.3rem;
    line-height: 1.35;
}

.script-editor h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--slate);
    margin: 0.5rem 0 0.25rem;
    line-height: 1.4;
}

.script-editor blockquote {
    border-left: 3px solid var(--primary);
    margin: 0.5rem 0;
    padding: 0.4rem 0 0.4rem 1rem;
    color: var(--slate);
    font-style: italic;
    background: var(--primary-tint-sm);
    border-radius: 0 6px 6px 0;
}

.script-editor ul,
.script-editor ol {
    margin: 0.3rem 0;
    padding-left: 1.5rem;
}

.script-editor li {
    margin: 0.15rem 0;
}

.script-editor hr {
    border: none;
    border-top: 2px solid var(--border-light);
    margin: 1rem 0;
}

.script-editor a {
    color: var(--primary);
    text-decoration: underline;
}

/* contenteditable divs don't support ::placeholder — use :empty::before instead */
.script-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--slate);
    opacity: 0.6;
    pointer-events: none;
    display: block;
    font-style: italic;
}

/* Dropped node blocks in script */
.script-block {
    display: inline-block;
    width: 100%;
    margin: 0.75rem 0;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: var(--cream);
    cursor: pointer;
    transition: all 0.15s;
}

.script-block:hover {
    box-shadow: 0 2px 8px var(--shadow-md);
}

.script-block.role-anchor {
    background: var(--anchor-light);
}

.script-block.role-pillar {
    background: var(--pillar-light);
}

.script-block.role-subpoint {
    background: var(--subpoint-light);
}

.script-block.role-support {
    background: var(--support-light);
}

.script-block.role-garden,
.script-block.role-unassigned {
    background: var(--garden-light);
}

.script-block-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.script-block-role {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

.role-anchor .script-block-role {
    background: var(--anchor-color);
    color: var(--on-brand);
}

.role-pillar .script-block-role {
    background: var(--pillar-color);
    color: var(--on-brand);
}

.role-subpoint .script-block-role {
    background: var(--subpoint-color);
    color: var(--on-brand);
}

.role-support .script-block-role {
    background: var(--support-color);
    color: var(--on-brand);
}

.role-garden .script-block-role,
.role-unassigned .script-block-role {
    background: var(--garden-color);
    color: var(--on-brand);
}

.script-block-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--charcoal);
}

.script-block-notes {
    font-size: 0.78rem;
    color: var(--slate);
    line-height: 1.5;
    margin-top: 0.35rem;
}

.script-drop-zone {
    min-height: 60px;
    border: 2px dashed var(--border-medium);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--slate);
    font-size: 0.85rem;
    margin: 1rem 0;
    transition: all 0.15s;
}

.script-drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-tint-sm);
}

/* Script block expand/convert buttons */
.script-block-actions {
    display: flex;
    gap: 0.4rem;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s;
}

.script-block:hover .script-block-actions {
    opacity: 1;
}

.script-block-expand,
.script-block-convert {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--border-medium);
    border-radius: 4px;
    background: var(--bg-surface);
    color: var(--slate);
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    transition: all 0.15s;
}

.script-block-expand:hover,
.script-block-convert:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.script-block-expand {
    display: none;
}

.script-block-notes.truncated {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.script-block-notes.expanded {
    display: block;
    -webkit-line-clamp: unset;
}

.script-block-source {
    display: inline-block;
    font-size: 0.65rem;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
    margin-top: 0.35rem;
    opacity: 0.7;
}

.script-block-source:hover {
    opacity: 1;
}

.script-block.converted {
    border-left-width: 1px;
    background: transparent;
    padding: 0.25rem 0.5rem;
}

.script-block.converted .script-block-header,
.script-block.converted .script-block-notes {
    display: inline;
}

.script-block.converted .script-block-role {
    display: none;
}

/* Script outline in right panel */
.script-outline {
    padding: 0.5rem;
}

.script-outline-item {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    cursor: grab;
    transition: background 0.15s;
    font-size: 0.78rem;
}

.script-outline-item:hover {
    background: var(--cream);
}

.script-outline-item:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    background: var(--cream);
}

.script-outline-item[data-role="anchor"] { padding-left: 0.5rem; font-weight: 600; }
.script-outline-item[data-role="pillar"] { padding-left: 1.2rem; }
.script-outline-item[data-role="subpoint"] { padding-left: 2rem; font-size: 0.75rem; color: var(--slate); }
.script-outline-item[data-role="unassigned"] { padding-left: 0.5rem; font-size: 0.75rem; color: var(--slate); }
.script-outline-item[data-role="garden"] { padding-left: 0.5rem; font-size: 0.75rem; color: var(--slate); }

.script-outline-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-top: 0.35rem;
    flex-shrink: 0;
}

.script-outline-item[data-role="anchor"] .script-outline-dot { background: var(--anchor-color); }
.script-outline-item[data-role="pillar"] .script-outline-dot { background: var(--pillar-color); }
.script-outline-item[data-role="subpoint"] .script-outline-dot { background: var(--subpoint-color); }
.script-outline-item[data-role="support"] .script-outline-dot { background: var(--support-color); }
.script-outline-item[data-role="unassigned"] .script-outline-dot { background: var(--garden-color); }
.script-outline-item[data-role="garden"] .script-outline-dot { background: var(--garden-color); }

.script-outline-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.script-outline-item[data-role="subpoint"] .script-outline-text,
.script-outline-item[data-role="unassigned"] .script-outline-text,
.script-outline-item[data-role="garden"] .script-outline-text {
    font-weight: 400;
}

.script-outline-item.script-outline-empty {
    opacity: 0.5;
    cursor: not-allowed;
}

.script-outline-item.script-outline-empty .script-outline-dot {
    background: var(--slate) !important;
}

.script-outline-preview {
    font-size: 0.65rem;
    color: var(--slate);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0.15rem;
}

.script-outline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.script-outline-header:hover .script-outline-text {
    color: var(--primary);
}

.outline-expand-icon {
    font-size: 0.6rem;
    color: var(--slate);
    transition: transform 0.15s;
    margin-left: 0.5rem;
}

.script-outline-expanded {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--cream);
    border-radius: 4px;
    font-size: 0.72rem;
}

.outline-field {
    margin-bottom: 0.4rem;
}

.outline-field:last-child {
    margin-bottom: 0;
}

.outline-drag-hint {
    font-size: 0.65rem;
    color: var(--primary);
    font-style: italic;
    margin-bottom: 0.5rem;
}

.script-outline-parent {
    margin-bottom: 0.25rem;
}

.script-outline-parent .script-outline-expanded {
    padding-left: 1rem;
}

.script-outline-child {
    padding-left: 0.5rem !important;
    font-size: 0.72rem;
    margin-top: 0.15rem;
    border-left: 2px solid var(--border-light);
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
}

.script-outline-child:hover {
    background: var(--primary-tint-xs);
}

.outline-field-label {
    font-weight: 600;
    color: var(--slate);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.script-outline-section-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--slate);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    padding-left: 0.25rem;
    border-top: 1px solid var(--border-light);
    padding-top: 0.75rem;
}

.outline-field-value {
    color: var(--charcoal);
    line-height: 1.4;
    margin-left: 0.3rem;
}

/* ─── NODE STYLES ──────────────────────────────── */
/* Outer wrapper — just positioning, no clip-path so the label can live outside */
.graph-node {
    position: absolute;
    cursor: pointer;
    user-select: none;
    pointer-events: all;
}

/* Unassigned ideas always float in front of structural hexagons */
.graph-node.role-unassigned:hover,
.graph-node.role-unassigned.selected { z-index: 50 !important; }

/* Structural hexagons (anchor/pillar/subpoint) stay behind unassigned ideas
   even when hovered or selected — base unassigned z-index is 20 */
.graph-node:not(.role-unassigned):hover,
.graph-node:not(.role-unassigned).selected { z-index: 15 !important; }

/* Any node being actively dragged rises above everything temporarily */
.graph-node.is-dragging { z-index: 100 !important; }

.graph-node.role-anchor    { width: 180px; }
.graph-node.role-pillar    { width: 150px; }
.graph-node.role-subpoint  { width: 150px; }
.graph-node.role-support   { width: 46px; }
.graph-node.role-support .node-hex { background: var(--support-color); }
.graph-node.role-support .node-header {
    font-size: 0.8rem;
    font-weight: 700;
    -webkit-line-clamp: 1;
    line-height: 1;
}
.graph-node.role-support .node-role-label { display: none; }
/* Unassigned nodes: compact surface cards matching app UI */
.graph-node.role-unassigned {
    width: 110px;
}

.graph-node.role-unassigned .node-hex {
    aspect-ratio: unset;
    clip-path: none;
    background: var(--bg-surface) !important;
    border: 1.5px solid var(--border-medium);
    border-radius: 8px;
    filter: none;
    box-shadow: 0 1px 4px var(--shadow-sm);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.graph-node.role-unassigned:hover .node-hex {
    border-color: var(--primary-light);
    box-shadow: 0 2px 8px var(--shadow-md);
}

.graph-node.role-unassigned .node-inner {
    position: relative;
    inset: auto;
    clip-path: none;
    background: transparent !important;
    padding: 0.45rem 0.55rem;
    text-align: left;
    align-items: flex-start;
    justify-content: flex-start;
}

.graph-node.role-unassigned .node-header {
    -webkit-line-clamp: 4;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--charcoal);
    line-height: 1.35;
}

/* ── Affinity-mapping cluster containers ───────────────── */
#clustersContainer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
    pointer-events: none;
}

#clusterHeadersContainer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 3;
    pointer-events: none;
}

.cluster-header-wrapper {
    position: absolute;
    pointer-events: none;
}

.cluster-container {
    position: absolute;
    border-radius: 8px;
    border: 1.5px solid var(--border-medium);
    background: transparent;
    pointer-events: all;
    cursor: move;
    box-sizing: border-box;
    transition: border-color 0.15s;
    user-select: none;
}

.cluster-container:hover {
    border-color: var(--primary-light);
}

.cluster-name {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--charcoal);
    outline: none;
    cursor: text;
    min-width: 20px;
    margin: 6px 8px;
    padding: 0.2rem 0.5rem;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-medium);
    border-radius: 6px;
    white-space: nowrap;
    overflow: hidden;
    max-width: 180px;
    text-overflow: ellipsis;
    pointer-events: all;
}

.cluster-name:focus {
    background: var(--bg-surface);
    opacity: 1;
    cursor: text;
}

.cluster-name:empty::before {
    content: 'Group name…';
    opacity: 0.45;
}

.cluster-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    gap: 0.3rem;
    pointer-events: all;
}

.cluster-promote-btn,
.cluster-delete-btn {
    font-size: 0.6rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.25);
    cursor: pointer;
    background: var(--bg-surface);
    color: var(--slate);
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    line-height: 1.6;
}

.cluster-promote-btn:hover {
    background: var(--pillar-light);
    border-color: var(--pillar-color);
    color: var(--pillar-color);
}

.cluster-delete-btn:hover {
    background: var(--color-danger-light);
    border-color: var(--color-danger);
    color: var(--color-danger);
}

/* ── Draw-to-create preview rectangle ── */
.cluster-draw-preview {
    position: absolute;
    border: 2px dashed var(--primary);
    border-radius: 8px;
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    pointer-events: none;
    z-index: 999;
    box-sizing: border-box;
}

/* Cluster resize is handled via edge-proximity on mousemove — no handle elements needed */

/* ── Convert-node-to-group hover button ── */
.node-to-group-btn {
    display: none;
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 0.58rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--primary-light);
    background: var(--bg-surface);
    color: var(--primary);
    cursor: pointer;
    pointer-events: all;
    z-index: 10;
    transition: background 0.12s;
}
.graph-node.role-unassigned.selected .node-to-group-btn { display: block; }
.node-to-group-btn:hover { background: var(--primary-lightest); }

/* Canvas cursor in draw mode */
.graph-area.draw-cluster-mode { cursor: crosshair !important; }
.graph-area.draw-cluster-mode * { cursor: crosshair !important; }

/* Hexagon shape child — carries clip-path, background, shadow */
.node-hex {
    width: 100%;
    aspect-ratio: 2 / 1.732;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    position: relative;
    filter: drop-shadow(0 2px 10px var(--shadow-md));
    transition: transform 0.15s, filter 0.15s;
}

.graph-node:hover  .node-hex { filter: drop-shadow(0 4px 18px var(--shadow-lg)); }

.node-source-warning-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.65rem;
    line-height: 1;
    z-index: 5;
}

/* ── Selected: scale up + vivid role-coloured ring + glow ── */
.graph-node.selected {
    transform: scale(1.1);
    transition: transform 0.15s ease;
    z-index: 50 !important;
}
.graph-node.selected.role-anchor .node-hex {
    background: var(--anchor-color);
    filter: drop-shadow(0 0 12px var(--anchor-color)) drop-shadow(0 0 30px var(--anchor-color));
}
.graph-node.selected.role-pillar .node-hex {
    background: var(--pillar-color);
    filter: drop-shadow(0 0 12px var(--pillar-color)) drop-shadow(0 0 30px var(--pillar-color));
}
.graph-node.selected.role-subpoint .node-hex {
    background: var(--subpoint-color);
    filter: drop-shadow(0 0 12px var(--subpoint-color)) drop-shadow(0 0 30px var(--subpoint-color));
}
.graph-node.selected.role-subpoint[data-subpoint-idx="0"] .node-hex {
    background: var(--subpoint-0-color);
    filter: drop-shadow(0 0 12px var(--subpoint-0-color)) drop-shadow(0 0 30px var(--subpoint-0-color));
}
.graph-node.selected.role-subpoint[data-subpoint-idx="1"] .node-hex {
    background: var(--subpoint-1-color);
    filter: drop-shadow(0 0 12px var(--subpoint-1-color)) drop-shadow(0 0 30px var(--subpoint-1-color));
}
.graph-node.selected.role-subpoint[data-subpoint-idx="2"] .node-hex {
    background: var(--subpoint-2-color);
    filter: drop-shadow(0 0 12px var(--subpoint-2-color)) drop-shadow(0 0 30px var(--subpoint-2-color));
}
.graph-node.selected.role-unassigned .node-hex {
    background: var(--bg-surface) !important;
    border-color: var(--primary);
    filter: none;
    box-shadow: 0 0 0 2px var(--primary-tint-lg), 0 2px 8px var(--shadow-md);
}
.graph-node.selected.role-garden .node-hex {
    background: var(--garden-color);
    filter: drop-shadow(0 0 12px var(--garden-color)) drop-shadow(0 0 24px var(--garden-color));
}
.graph-node.selected.role-support .node-hex {
    background: var(--support-color);
    filter: drop-shadow(0 0 12px var(--support-color)) drop-shadow(0 0 24px var(--support-color));
}

.graph-node.role-anchor    .node-hex { background: var(--anchor-color); }
.graph-node.role-pillar    .node-hex { background: var(--pillar-color); }
.graph-node.role-subpoint  .node-hex { background: var(--subpoint-color); }
.graph-node.role-subpoint[data-subpoint-idx="0"] .node-hex { background: var(--subpoint-0-color); }
.graph-node.role-subpoint[data-subpoint-idx="1"] .node-hex { background: var(--subpoint-1-color); }
.graph-node.role-subpoint[data-subpoint-idx="2"] .node-hex { background: var(--subpoint-2-color); }

/* Inner content layer — 2 px inset inside .node-hex */
.node-inner {
    position: absolute;
    inset: 2px;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 1.0rem;
    text-align: center;
}

.graph-node.role-anchor    .node-inner { background: var(--anchor-light); }
.graph-node.role-pillar    .node-inner { background: var(--pillar-light); }
.graph-node.role-subpoint  .node-inner { background: var(--subpoint-light); }
.graph-node.role-subpoint[data-subpoint-idx="0"] .node-inner { background: var(--subpoint-0-light); }
.graph-node.role-subpoint[data-subpoint-idx="1"] .node-inner { background: var(--subpoint-1-light); }
.graph-node.role-subpoint[data-subpoint-idx="2"] .node-inner { background: var(--subpoint-2-light); }

.graph-node.link-target-valid .node-hex {
    animation: pulse-pillar 1s ease-in-out infinite;
}

.graph-node.link-target-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

@keyframes pulse-pillar {
    0%, 100% { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--pillar-color) 60%, transparent)); }
    50% { filter: drop-shadow(0 0 12px color-mix(in srgb, var(--pillar-color) 25%, transparent)); }
}

/* Role label — pinned flush to the hex bottom, no layout height added */
.node-role-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 1px;
    width: fit-content;
    white-space: nowrap;
    font-size: 0.52rem;
    font-weight: 400;
    font-family: 'Open Sans', sans-serif;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
    padding: 0.13rem 0.38rem;
    border-radius: 3px;
}
.role-anchor   .node-role-label { background: var(--anchor-light);   color: var(--anchor-color); }
.role-pillar   .node-role-label { background: var(--pillar-light);   color: var(--pillar-color); }
.role-subpoint .node-role-label { background: var(--subpoint-light); color: var(--subpoint-color); }
.role-subpoint[data-subpoint-idx="0"] .node-role-label { background: var(--subpoint-0-light); color: var(--subpoint-0-color); }
.role-subpoint[data-subpoint-idx="1"] .node-role-label { background: var(--subpoint-1-light); color: var(--subpoint-1-color); }
.role-subpoint[data-subpoint-idx="2"] .node-role-label { background: var(--subpoint-2-light); color: var(--subpoint-2-color); }
.role-support  .node-role-label { background: var(--support-light);  color: var(--support-color); }

.node-header {
    font-family: 'Open Sans', sans-serif;
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--charcoal);
    line-height: 1.2;
    margin-bottom: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.node-header.anchor-header { font-size: 0.75rem; }

/* Subheader hidden by default — only revealed when zoomed in */
.node-subheader {
    display: none;
    font-size: 0.62rem;
    font-weight: 400;
    color: var(--slate);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Zoom-dependent text density */
#graphWorld.zoom-low .node-header    { -webkit-line-clamp: 1; }
#graphWorld.zoom-high .node-header   { -webkit-line-clamp: 4; }

/* Subheader hover tooltip */
#subheaderTooltip {
    position: fixed;
    z-index: 9999;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: var(--slate);
    line-height: 1.4;
    max-width: 300px;
    box-shadow: 0 3px 10px var(--shadow-md);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s ease;
}
#subheaderTooltip.visible { opacity: 1; }

/* ─── RIGHT PANEL ──────────────────────────────── */
.right-panel {
    width: 340px;
    flex-shrink: 0;
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-light);
    box-shadow: -2px 0 8px var(--shadow-sm);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

/* ─── RESIZE HANDLES ──────────────────────────── */
.resize-handle {
    position: absolute;
    top: 0;
    width: 8px;
    height: 100%;
    cursor: ew-resize;
    z-index: 200;
    background: transparent;
}
.resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 36px;
    border-radius: 3px;
    background: var(--border-medium);
    transition: background 0.15s, height 0.15s;
}
.resize-handle:hover::after, .resize-handle.dragging::after {
    background: var(--primary);
    height: 56px;
}
.sidebar .resize-handle { right: -4px; }
.right-panel .resize-handle { left: -4px; }
@media (max-width: 1024px) { .resize-handle { display: none; } }

/* ─── MOBILE PANEL PULL TAB ───────────────────── */
.panel-pull-tab {
    position: absolute;
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    padding: 1rem 0;
    background: var(--primary);
    color: var(--on-brand);
    border: none;
    border-radius: 6px 0 0 6px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    writing-mode: vertical-lr;
    text-orientation: mixed;
    box-shadow: -3px 2px 10px var(--shadow-md);
    transition: background 0.15s;
    z-index: 1;
}
.panel-pull-tab:hover { opacity: 0.85; }
/* Hide pull-tab when panel is open (.active set by toggleRightPanel) */
.panel-pull-tab.active { display: none !important; }
@media (max-width: 1024px) { .panel-pull-tab { display: flex; } }

.panel-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 64px;
    padding: 0 1rem 0.35rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--topbar-bg, var(--bg-surface));
    flex-shrink: 0;
}

.panel-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: relative;
    top: -3px;
}

.panel-title-role {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    margin-left: 0.5rem;
    vertical-align: middle;
    color: var(--on-brand);
    flex-shrink: 0;
}

/* Panel header accent per role */
#panelHeader[data-role="anchor"]   { background: color-mix(in srgb, var(--anchor-color) 6%, var(--cream)); }
#panelHeader[data-role="pillar"]   { background: color-mix(in srgb, var(--pillar-color) 6%, var(--cream)); }
#panelHeader[data-role="subpoint"] { background: color-mix(in srgb, var(--subpoint-color) 6%, var(--cream)); }
#panelHeader[data-role="unassigned"],
#panelHeader[data-role="garden"]   { background: color-mix(in srgb, var(--garden-color) 6%, var(--cream)); }

.panel-action-btn {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--charcoal);
    opacity: 0.7;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    transition: all 0.2s ease;
}

.panel-action-btn:hover { opacity: 1; border-color: var(--primary); color: var(--primary); }

.panel-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ─── PANEL TABS ─────────────────────────────── */
.panel-tabs-bar {
    display: flex;
    border-bottom: 2px solid var(--border-light);
    background: var(--bg-surface);
    flex-shrink: 0;
}
.panel-tab {
    flex: 1;
    padding: 0.6rem 0.5rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--slate);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    letter-spacing: 0.02em;
}
.panel-tab:hover { color: var(--primary); }
.panel-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 5%, var(--bg-surface));
}
.panel-view-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Node Detail Editor */
.node-detail {
    padding: 1rem;
}

.detail-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--slate);
    font-size: 0.8rem;
    line-height: 1.6;
}

.detail-label {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--slate);
    margin-bottom: 0.3rem;
    margin-top: 0.75rem;
}

.detail-label:first-child { margin-top: 0; }

.detail-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--border-light);
    border-radius: 6px;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.82rem;
    color: var(--charcoal);
    background: var(--bg-surface);
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.detail-input:focus { border-color: var(--primary); }

textarea.detail-input {
    resize: vertical;
    font-family: 'Open Sans', sans-serif;
    transition: height 0.2s ease;
}

textarea.sidebar-narrative-textarea {
    transition: height 0.2s ease;
}

textarea.auto-resize {
    resize: none;
    overflow: hidden;
    min-height: 0;
    line-height: 1.45;
}

/* Story field — visually distinct from Notes (delivery guidance) */
.detail-label-story {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--story-color);
    margin-bottom: 0.3rem;
    margin-top: 0.75rem;
}
.detail-input-story {
    border-color: color-mix(in srgb, var(--story-color) 35%, var(--border-light));
    background: color-mix(in srgb, var(--story-color) 4%, var(--bg-surface));
}
.detail-input-story:focus {
    border-color: var(--story-color);
}
.detail-label-data {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--data-color);
    margin-bottom: 0.3rem;
    margin-top: 0.75rem;
}
.detail-input-data {
    border-color: color-mix(in srgb, var(--data-color) 35%, var(--border-light));
    background: color-mix(in srgb, var(--data-color) 4%, var(--bg-surface));
}
.detail-input-data:focus {
    border-color: var(--data-color);
}
.detail-label-counterpoint {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--counterpoint-color);
    margin-bottom: 0.3rem;
    margin-top: 0.75rem;
}
.detail-input-counterpoint {
    border-color: color-mix(in srgb, var(--counterpoint-color) 35%, var(--border-light));
    background: color-mix(in srgb, var(--counterpoint-color) 4%, var(--bg-surface));
}
.detail-input-counterpoint:focus {
    border-color: var(--counterpoint-color);
}
.detail-label-transitions {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--transitions-color);
    margin-top: 0.75rem;
}
.detail-input-transitions {
    border-color: color-mix(in srgb, var(--transitions-color) 35%, var(--border-light));
    background: color-mix(in srgb, var(--transitions-color) 4%, var(--bg-surface));
}
.detail-input-transitions:focus {
    border-color: var(--transitions-color);
}
.detail-label-steps {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--steps-color);
    margin-top: 0.75rem;
}
.detail-input-steps {
    border-color: color-mix(in srgb, var(--steps-color) 35%, var(--border-light));
    background: color-mix(in srgb, var(--steps-color) 4%, var(--bg-surface));
}
.detail-input-steps:focus {
    border-color: var(--steps-color);
}

/* Sidebar ARC / VOICE inline textareas */
.sidebar-narrative-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.4rem 0.5rem;
    border: 1.5px solid var(--border-light);
    border-radius: 5px;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.78rem;
    color: var(--charcoal);
    background: var(--bg-surface);
    resize: vertical;
    min-height: 60px;
    line-height: 1.45;
    outline: none;
    transition: border-color 0.2s;
    margin-top: 0.2rem;
}
.sidebar-narrative-textarea:focus { border-color: var(--primary); }
.sidebar-narrative-textarea::placeholder { color: var(--slate); opacity: 0.7; }

.sidebar-narrative-input,
.sidebar-narrative-select {
    width: 100%;
    box-sizing: border-box;
    padding: 0.35rem 0.5rem;
    border: 1.5px solid var(--border-light);
    border-radius: 5px;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.8rem;
    color: var(--charcoal);
    background: var(--bg-surface);
    outline: none;
    transition: border-color 0.2s;
    margin-top: 0.2rem;
}
.sidebar-narrative-input:focus,
.sidebar-narrative-select:focus { border-color: var(--primary); }
.sidebar-narrative-input::placeholder { color: var(--slate); opacity: 0.7; }

.role-buttons {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.role-btn {
    padding: 0.3rem 0.6rem;
    border: 1.5px solid var(--border-light);
    border-radius: 5px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--bg-surface);
    color: var(--charcoal);
    transition: all 0.15s;
}

.role-btn:hover { border-color: var(--primary); color: var(--primary); }
.role-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.role-btn.active-anchor { background: var(--anchor-color); color: var(--on-brand); border-color: var(--anchor-color); }
.role-btn.active-pillar { background: var(--pillar-color); color: var(--on-brand); border-color: var(--pillar-color); }
.role-btn.active-subpoint { background: var(--subpoint-color); color: var(--on-brand); border-color: var(--subpoint-color); }
.role-btn.active-garden { background: var(--garden-color); color: var(--on-brand); border-color: var(--garden-color); }

/* ── Transform Menu ── */
.transform-menu { margin-top: 0.3rem; }
.transform-section-label {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.6rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--slate); margin: 0.6rem 0 0.25rem; opacity: 0.8;
}
.transform-section-label:first-child { margin-top: 0; }
.transform-buttons { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.transform-btn {
    padding: 0.28rem 0.55rem;
    border: 1.5px solid var(--border-light);
    border-radius: 5px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.65rem; font-weight: 600;
    cursor: pointer; background: var(--bg-surface);
    color: var(--charcoal); transition: all 0.15s;
    display: inline-flex; align-items: center; gap: 0.25rem;
}
.transform-btn:hover { border-color: var(--primary); color: var(--primary); }
.transform-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.transform-btn.active { background: var(--primary); color: var(--on-brand); border-color: var(--primary); }
.transform-btn.active-anchor { background: var(--anchor-color); color: var(--on-brand); border-color: var(--anchor-color); }
.transform-btn.active-pillar { background: var(--pillar-color); color: var(--on-brand); border-color: var(--pillar-color); }
.transform-btn.active-subpoint { background: var(--subpoint-color); color: var(--on-brand); border-color: var(--subpoint-color); }
.transform-btn.active-garden { background: var(--garden-color); color: var(--on-brand); border-color: var(--garden-color); }
.transform-target-picker {
    margin-top: 0.4rem; padding: 0.5rem;
    background: var(--bg-panel); border-radius: 6px;
    border: 1.5px solid var(--border-light);
}
.transform-target-picker .detail-label { margin-bottom: 0.3rem; }
.transform-target-list {
    max-height: 160px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 0.25rem;
}
.transform-target-item {
    padding: 0.35rem 0.5rem; border-radius: 5px;
    border: 1.5px solid var(--border-light);
    background: var(--bg-surface); cursor: pointer;
    font-size: 0.75rem; font-family: 'Open Sans', sans-serif;
    color: var(--charcoal); transition: all 0.15s;
}
.transform-target-item:hover { border-color: var(--primary); background: var(--primary-tint-xs); }
.transform-target-item .target-role {
    font-size: 0.6rem; font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    text-transform: uppercase; opacity: 0.6; margin-left: 0.3rem;
}
.transform-cancel-btn {
    margin-top: 0.4rem; padding: 0.25rem 0.5rem;
    border: none; background: none;
    color: var(--slate); font-size: 0.7rem; cursor: pointer;
    font-family: 'Montserrat', sans-serif;
}
.transform-cancel-btn:hover { color: var(--charcoal); }

.pillar-select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1.5px solid var(--border-light);
    border-radius: 6px;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.8rem;
    color: var(--charcoal);
    background: var(--bg-surface);
    outline: none;
    margin-top: 0.5rem;
}

.pillar-select:focus { border-color: var(--pillar-color); }

.delete-btn {
    margin-top: 0.75rem;
    padding: 0.3rem 0.75rem;
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 5px;
    font-size: 0.72rem;
    color: var(--color-danger);
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    transition: all 0.15s;
}

.delete-btn:hover { background: var(--color-danger); color: white; border-color: var(--color-danger); }

/* Node List */
.node-list-section {
    padding: 0.75rem;
}

.node-list-group-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--slate);
    margin: 0.75rem 0 0.35rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-lighter);
}

.node-list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.node-list-item:hover { background: var(--cream); }
.node-list-item.selected { background: var(--primary-tint-sm); }

.node-list-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.node-list-label {
    flex: 1;
    font-size: 0.78rem;
    color: var(--charcoal);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.node-list-badge {
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

/* Garden section */
.garden-section {
    border-top: 1px solid var(--border-light);
    background: var(--cream);
}

.garden-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
}

.garden-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--garden-color);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.garden-toggle { font-size: 0.7rem; color: var(--slate); }

.garden-items { padding: 0 0.75rem 0.75rem; }

.garden-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.4rem;
    cursor: pointer;
    transition: all 0.15s;
}

.garden-card:hover { border-color: var(--primary); }

.garden-card-header {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--charcoal);
}

.garden-restore {
    font-size: 0.65rem;
    color: var(--primary);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    margin-top: 0.2rem;
}

/* ─── MODAL ──────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--bg-overlay);
    z-index: 1000;
}
/* Confirm modal must appear above other modals (e.g. session picker) */
#confirmModal.modal-overlay {
    z-index: 1020;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 40px var(--shadow-xl);
}

.modal h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--charcoal);
    margin-bottom: 0.75rem;
}

.modal p { font-size: 0.85rem; color: var(--slate); margin-bottom: 1.5rem; line-height: 1.5; }

.modal-actions { display: flex; gap: 0.75rem; }

.modal-btn {
    flex: 1;
    padding: 0.65rem;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    border: 1.5px solid var(--border-medium);
    background: var(--bg-surface);
    color: var(--charcoal);
    transition: all 0.2s;
}

.modal-btn:hover { border-color: var(--primary); color: var(--primary); }

.modal-btn.danger {
    background: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
}

.modal-btn.danger:hover { background: transparent; color: var(--color-danger); }

.modal-btn.primary {
    background: var(--primary);
    color: var(--on-brand);
    border-color: var(--primary);
}

.modal-btn.primary:hover { background: var(--primary-mid); border-color: var(--primary-mid); }

/* ─── IMPORT MODAL ─────────────────────────────────── */
.import-modal.import-modal {
    width: 540px;
    max-width: 92vw;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
.import-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.4rem 0.8rem;
    border-bottom: 1px solid var(--border-lighter);
}
.import-modal-header h3 { margin: 0; font-size: 1rem; color: var(--charcoal); }
.import-modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 1.1rem; color: var(--slate); padding: 0.2rem 0.4rem;
    border-radius: 4px; line-height: 1;
}
.import-modal-close:hover { background: var(--border-lighter); color: var(--charcoal); }
.import-tabs {
    display: flex;
    gap: 0;
    padding: 0 1.4rem;
    border-bottom: 1px solid var(--border-lighter);
    background: var(--cream);
}
.import-tab {
    padding: 0.6rem 1.1rem;
    background: none;
    border: none;
    border-bottom: 2.5px solid transparent;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--slate);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
}
.import-tab:hover { color: var(--charcoal); }
.import-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.import-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem 1.4rem;
}
.import-pane { display: none; }
.import-pane.active { display: flex; flex-direction: column; gap: 0.75rem; }
.import-hint {
    font-size: 0.78rem;
    color: var(--slate);
    margin: 0;
    line-height: 1.5;
}
.import-hint code {
    background: var(--cream);
    border: 1px solid var(--border-light);
    border-radius: 3px;
    padding: 0.1rem 0.3rem;
    font-size: 0.75rem;
}
.import-textarea {
    width: 100%;
    min-height: 160px;
    padding: 0.7rem;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
    resize: vertical;
    box-sizing: border-box;
    color: var(--charcoal);
    background: var(--bg-surface);
    transition: border-color 0.15s;
}
.import-textarea:focus { outline: none; border-color: var(--primary-light); }
.import-file-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.import-file-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-medium);
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--charcoal);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    white-space: nowrap;
}
.import-file-btn:hover { border-color: var(--primary-light); background: var(--primary-tint-xs); }
.import-file-btn input[type=file] { display: none; }
.import-file-name {
    font-size: 0.75rem;
    color: var(--slate);
    font-style: italic;
}
.import-options {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    font-size: 0.78rem;
    color: var(--charcoal);
}
.import-options label { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.import-options select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.78rem;
    background: var(--bg-surface);
    color: var(--charcoal);
}
.import-preview {
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid var(--border-lighter);
    border-radius: 8px;
    background: var(--cream);
}
.import-preview-empty {
    padding: 0.8rem 1rem;
    font-size: 0.75rem;
    color: var(--slate);
    font-style: italic;
}
.import-preview-list {
    list-style: none;
    margin: 0;
    padding: 0.4rem 0;
}
.import-preview-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.22rem 0.9rem;
    font-size: 0.77rem;
    color: var(--charcoal);
    border-bottom: 1px solid var(--border-lighter);
}
.import-preview-item:last-child { border-bottom: none; }
.import-preview-role {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    flex-shrink: 0;
}
.ipr-anchor   { background: var(--anchor-color);   color: var(--on-brand); }
.ipr-pillar   { background: var(--pillar-color);   color: var(--on-brand); }
.ipr-subpoint { background: var(--subpoint-color); color: var(--on-brand); }
.ipr-unassigned { background: var(--border-light); color: var(--slate); }
.ipr-garden   { background: var(--garden-light);   color: var(--garden-color); }
.import-modal-footer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.75rem 1.4rem;
    border-top: 1px solid var(--border-lighter);
    background: var(--cream);
}
.import-count {
    font-size: 0.77rem;
    color: var(--slate);
    text-align: center;
}
.import-count strong { color: var(--primary); }
.import-footer-btns { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }

.import-ncs-notice {
    background: var(--color-success-light);
    border: 1px solid var(--color-success-border);
    color: var(--color-success-text);
    font-size: 0.76rem;
    font-weight: 600;
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
}
body.dark-mode .import-ncs-notice {
    background: color-mix(in srgb, var(--story-color) 15%, transparent);
    border-color: color-mix(in srgb, var(--story-color) 30%, transparent);
    color: var(--story-color);
}
.import-ncs-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    font-size: 0.74rem;
    color: var(--slate);
    padding: 0.3rem 0.1rem 0;
}
.import-ncs-sub {
    font-size: 0.68rem;
    color: var(--slate);
    font-style: italic;
    margin-left: 0.3rem;
}
.import-ncs-apply-note {
    width: 100%;
    font-size: 0.68rem;
    font-style: italic;
    color: var(--color-success-text);
    margin-top: 0.15rem;
}
.import-json-info {
    background: var(--cream);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.78rem;
    color: var(--charcoal);
    line-height: 1.6;
}
.import-json-info strong { color: var(--primary); }
.import-json-warn {
    background: var(--color-warning-light);
    border: 1px solid var(--color-warning-border);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    color: var(--color-warning-text);
}
body.dark-mode .import-json-warn {
    background: color-mix(in srgb, var(--color-warning) 10%, transparent);
    border-color: color-mix(in srgb, var(--color-warning) 30%, transparent);
    color: var(--color-warning);
}
.restore-summary {
    background: var(--cream);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
    text-align: left;
}

.restore-detail {
    font-size: 0.8rem;
    color: var(--charcoal);
    padding: 0.2rem 0;
    line-height: 1.5;
}

.restore-detail strong { color: var(--primary); }

/* ─── MOBILE ──────────────────────────────── */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 50px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    z-index: 200;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

.hamburger {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--charcoal);
}

.mobile-brand {
    font-family: 'Raleway', sans-serif;
    font-size: 0.85rem;
    font-weight: 200;
    color: var(--primary);
}

.dark-mode-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    color: var(--charcoal);
}

.dark-mode-toggle:hover { opacity: 1; }

.panel-close-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--charcoal);
    opacity: 0.6;
    padding: 0.2rem 0.4rem;
    line-height: 1;
}
.panel-close-btn:hover { opacity: 1; }

.panel-open-btn {
    background: var(--primary);
    color: var(--on-brand);
    border: none;
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
    min-height: 36px;
    transition: opacity 0.15s;
}
.panel-open-btn:hover, .panel-open-btn.active { opacity: 0.8; }

@media (max-width: 1024px) {
    .mobile-header { display: flex; }
    #desktopDarkToggle { display: none; }
    /* Slim tool rail on tablets — icons only, 40px wide */
    .tool-rail {
        width: 40px;
        padding: 4px;
    }
    .tool-rail-item {
        width: 32px;
        height: 32px;
    }
    .tool-rail-item .tool-rail-icon {
        width: 18px;
        height: 18px;
    }
    .tool-rail-item[data-tool="narrative-action-cycle"] .tool-rail-icon {
        width: 22px;
        height: 22px;
    }
    .tool-rail-item .tool-rail-hotkey { display: none; }
    .tool-rail-logo { width: 28px; height: 28px; margin-bottom: 10px; }
    .tool-rail-logo svg { width: 28px; height: 28px; }
    .tool-rail-divider { margin: 4px 0; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 300;
        left: 40px;
        top: 50px;
        height: calc(100dvh - 50px);
        width: min(300px, 80vw);
    }

    .sidebar.open { transform: translateX(0); }

    .main-area {
        margin-left: 40px;
        margin-right: 0;
        margin-top: 50px;
    }

    .right-panel {
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 250;
        top: 50px;
        height: calc(100vh - 50px);
        width: min(340px, 85vw);
    }

    .right-panel.open { transform: translateX(0); }

    .panel-close-btn { display: block; }

    .view-toggle-bar { left: 0; right: 0; }

    .graph-node.role-anchor { width: 150px; }
    .graph-node.role-pillar, .graph-node.role-subpoint { width: 115px; }
    .graph-node.role-support { width: 40px; }

    /* Script block actions: always visible (no hover on touch) */
    .script-block-actions { opacity: 1; position: static; margin-top: 0.3rem; }

    /* Mobile backdrop — shown when a panel is open */
    .sidebar.open ~ .mobile-backdrop,
    .right-panel.open ~ .mobile-backdrop { display: block; }

    /* Outline insert-to-script button: visible in script view on mobile */
    .script-view-active .outline-insert-btn { display: inline-flex; }

    /* Fix: FAB and zoom controls anchored to viewport, not canvas */
    .fab-add       { position: fixed; bottom: 1.25rem; right: 1.25rem; top: auto; }
    .fab-group     { position: fixed; bottom: 4.25rem; right: 1.25rem; top: auto; }
    .zoom-controls { position: fixed; bottom: 1.25rem; left:  1.25rem; top: auto; }

    /* Fix: pull-tab anchored to right edge of viewport, vertically centred */
    .panel-pull-tab {
        position: fixed; left: auto; right: 0;
        top: 50%; transform: translateY(-50%);
    }
}

@media (max-width: 600px) {
    .type-cards { grid-template-columns: 1fr 1fr; }
    /* FAB bottom/right now handled by 1024px fixed rule above */
}

/* ── Phone Outline Touch Mode ─────────────────────────────────── */
@media (max-width: 600px) {
    /* Hide desktop-only chrome inside outline */
    .node-list-drag-handle,
    .merged-expand-icon,
    .outline-section-drop-zone { display: none; }

    /* Phone outline rows */
    .phone-outline-row {
        display: flex; align-items: center; gap: 0.5rem;
        padding: 0 0.75rem; min-height: 48px;
        cursor: pointer; position: relative;
        border-bottom: 1px solid var(--border-light);
        transition: background 0.1s;
    }
    .phone-outline-row:active { background: rgba(0,0,0,0.04); }
    .phone-outline-row.phone-selected {
        background: var(--primary-tint-sm);
    }
    .phone-indent-1 { padding-left: 1.5rem; }

    .phone-row-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
    .phone-row-label {
        flex: 1; font-size: 0.82rem; color: var(--charcoal);
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }

    /* Action strip */
    .phone-action-strip {
        display: flex; align-items: center; gap: 0.3rem;
        padding: 0.4rem 0.75rem; overflow-x: auto;
        -webkit-overflow-scrolling: touch; scrollbar-width: none;
        background: var(--bg-surface); border-top: 1px solid var(--border-light);
        border-bottom: 2px solid var(--border-medium);
    }
    .phone-action-strip::-webkit-scrollbar { display: none; }

    /* Pillar picker row (secondary) */
    .phone-subpillar-row {
        display: flex; align-items: center; gap: 0.3rem;
        padding: 0.35rem 0.75rem; overflow-x: auto;
        -webkit-overflow-scrolling: touch; scrollbar-width: none;
        background: var(--cream);
        border-bottom: 2px solid var(--border-medium);
    }
    .phone-subpillar-row::-webkit-scrollbar { display: none; }
    .phone-subpillar-label {
        font-size: 0.62rem; color: var(--slate);
        font-family: 'Montserrat', sans-serif; font-weight: 700; flex-shrink: 0;
    }

    .phone-strip-sep {
        width: 1px; height: 22px;
        background: var(--border-medium); flex-shrink: 0; margin: 0 0.15rem;
    }

    /* Chips */
    .phone-role-chip {
        display: inline-flex; align-items: center; gap: 0.2rem;
        padding: 0 0.6rem; height: 34px; border-radius: 17px;
        border: 1.5px solid var(--border-medium); background: var(--bg-surface);
        font-size: 0.68rem; font-family: 'Montserrat', sans-serif; font-weight: 700;
        color: var(--charcoal); white-space: nowrap; cursor: pointer; flex-shrink: 0;
        transition: all 0.1s;
    }
    .phone-role-chip:active { opacity: 0.7; transform: scale(0.95); }
    .phone-role-chip:disabled { opacity: 0.3; pointer-events: none; }

    .phone-chip-anchor  { border-color: var(--anchor-color);          color: var(--anchor-color); }
    .phone-chip-pillar  { border-color: var(--pillar-color);          color: var(--pillar-color); }
    .phone-chip-sub     { border-color: var(--subpoint-color); color: var(--subpoint-color); }
    .phone-chip-garden  { border-color: var(--garden-color);          color: var(--garden-color); }
    .phone-chip-unsig   { border-color: var(--slate);                 color: var(--slate); }
    .phone-chip-delete  { border-color: var(--color-danger);           color: var(--color-danger); }

    /* Reorder buttons */
    .phone-reorder-btn {
        display: inline-flex; align-items: center; justify-content: center;
        width: 36px; height: 34px; border-radius: 8px;
        border: 1.5px solid var(--border-medium); background: var(--bg-surface);
        font-size: 1rem; cursor: pointer; flex-shrink: 0; color: var(--charcoal);
        transition: all 0.1s;
    }
    .phone-reorder-btn:active { background: var(--primary-tint-sm); border-color: var(--primary); }
    .phone-reorder-btn:disabled { opacity: 0.3; pointer-events: none; }

    /* Slot hint text */
    .phone-slot-hint {
        font-size: 0.62rem; color: var(--slate); padding: 0.2rem 0.75rem 0.2rem 1.5rem;
        font-style: italic; font-family: 'Montserrat', sans-serif;
    }

    /* ── Phone tab bar (Outline | Script) ─────────────────── */
    .phone-tab-bar {
        display: flex; position: sticky; top: 0; z-index: 5;
        background: var(--bg-surface);
        border-bottom: 2px solid var(--border-light);
        flex-shrink: 0;
    }
    .phone-tab {
        flex: 1; padding: 0.7rem 0; border: none; background: transparent;
        font-size: 0.78rem; font-family: 'Montserrat', sans-serif; font-weight: 700;
        color: var(--slate); cursor: pointer;
        border-bottom: 2.5px solid transparent; margin-bottom: -2px;
        transition: color 0.15s, border-color 0.15s;
    }
    .phone-tab.phone-tab-active { color: var(--primary); border-bottom-color: var(--primary); }

    /* ── Phone script editor inside panel ─────────────────── */
    .phone-script-wrap {
        display: flex; flex-direction: column;
        flex: 1 1 0; overflow: hidden;
    }
    .phone-script-wrap .script-editor {
        flex: 1 1 0; overflow-y: auto; padding: 0.85rem 0.9rem;
        -webkit-overflow-scrolling: touch; touch-action: pan-y;
        min-height: 0;
    }
    .phone-script-footer {
        display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
        padding: 0.4rem 0.75rem; border-top: 1px solid var(--border-light);
        font-size: 0.65rem; color: var(--slate); flex-shrink: 0;
    }

    /* ── Phone Details / Info tab content ──────────────────── */
    .phone-sidebar-content {
        flex: 1 1 0; overflow-y: auto; padding-bottom: 2rem;
        -webkit-overflow-scrolling: touch; touch-action: pan-y;
    }
    .phone-empty-details {
        display: flex; align-items: center; justify-content: center;
        flex: 1 1 0; padding: 2rem 1.5rem; text-align: center;
    }
    .phone-empty-details-inner { max-width: 220px; }
    .phone-empty-details-icon  { font-size: 1.6rem; margin-bottom: 0.5rem; }
    .phone-empty-details-title {
        font-size: 0.85rem; font-family: 'Montserrat', sans-serif;
        font-weight: 700; color: var(--charcoal); margin-bottom: 0.25rem;
    }
    .phone-empty-details-hint  { font-size: 0.75rem; color: var(--slate); }

    /* Shrink tab labels to fit 4 tabs comfortably */
    .phone-tab { font-size: 0.72rem; padding: 0.65rem 0; }
}

/* ── Phone Full-Screen Outline Layout ─────────────────────────── */
/* On ≤600px the right-panel is ALWAYS full-screen and the canvas is
   ALWAYS hidden: no JS class needed, no flash of canvas on load.
*/
@media (max-width: 600px) {
    /* Prevent iOS Safari from auto-zooming when tapping an input.
       Safari zooms in whenever a focused field has font-size < 16px.
       Setting to 1rem (16px) stops the zoom without disabling user scaling. */
    input, textarea, select { font-size: 1rem !important; }

    /* ── Mobile Bottom Tab Bar controls visibility ──────────── */
    /* mainArea visible on Journey/Think tabs; rightPanel visible on Ideas/Write */
    .panel-pull-tab    { display: none !important; }
    .fab-controls, .level-filter-menu, .zoom-controls { display: none !important; }
    .outline-add-trigger {
        display: block !important;
        position: sticky; top: 0; z-index: 10;
        margin-top: 0; border-radius: 0;
    }
    .hamburger         { display: none !important; }

    /* Wider sidebar drawer on small phones */
    .sidebar { width: min(360px, 92vw) !important; }

    /* Right panel always-visible on phone: never show backdrop for it */
    .right-panel.open ~ .mobile-backdrop { display: none !important; }

    /* ── Main area — full-screen on phone when visible ────── */
    .main-area {
        position: fixed !important;
        top: 50px !important;     /* below mobile header */
        left: 0 !important;
        right: 0 !important;
        bottom: 56px !important;  /* above bottom tab bar */
        margin: 0 !important;
        padding: 1rem !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        z-index: 100;
    }

    /* ── Right panel — full-screen on phone when visible ──── */
    .right-panel {
        position: fixed !important;
        top: 50px !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 56px !important;  /* above bottom tab bar */
        width: 100% !important;
        max-width: 100% !important;
        transform: none !important;
        border-left: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        z-index: 200 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    .panel-close-btn              { display: none !important; }
    .right-panel .resize-handle   { display: none !important; }

    /* ── Visibility toggling via body.mobile-tab-* classes ── */
    /* Default: hide mainArea, show rightPanel (backwards-compat before JS loads) */
    .main-area { display: none !important; }

    /* Journey & Think tabs → show mainArea, hide rightPanel */
    body.mobile-tab-journey .main-area,
    body.mobile-tab-think .main-area {
        display: block !important;
    }
    body.mobile-tab-journey .right-panel,
    body.mobile-tab-think .right-panel {
        display: none !important;
    }

    /* Ideas & Write tabs → show rightPanel, hide mainArea */
    body.mobile-tab-ideas .right-panel,
    body.mobile-tab-write .right-panel {
        display: flex !important;
        flex-direction: column !important;
    }
    body.mobile-tab-ideas .main-area,
    body.mobile-tab-write .main-area {
        display: none !important;
    }

    /* Panel body scrolls to fill remaining height */
    #panelBody {
        flex: 1 1 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Mobile notice inside panel header */
    .mobile-notice {
        position: relative;
        border-bottom: 1px solid var(--border-light);
    }

}

@media (max-width: 768px) {
    .graph-node.role-anchor { width: 140px !important; }
    .graph-node.role-pillar,
    .graph-node.role-subpoint { width: 110px !important; }
    .graph-node.role-unassigned { width: 100px !important; }
    .import-modal { max-width: 95vw; }
}

@media (max-width: 480px) {
    .graph-node.role-anchor { width: 120px !important; }
    .graph-node.role-pillar,
    .graph-node.role-subpoint { width: 100px !important; }
    .graph-node.role-unassigned { width: 90px !important; }
    .view-toggle-bar { height: 40px; }
    .view-toggle-btn { font-size: 0.65rem; padding: 0.25rem 0.7rem; }
    .undo-btn, .redo-btn { width: 28px; height: 28px; font-size: 0.85rem; }
    .setup-area .type-card { padding: 0.6rem; }
    .quick-add-inline { max-width: 85vw; }
    .quick-add-role-chips { gap: 0.2rem; }
    .role-chip { font-size: 0.52rem; padding: 0.1rem 0.35rem; }
}

/* Mobile overlay backdrop */
.mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 249;
}

/* Outline "Insert into script" button — hidden by default, shown on mobile in script view */
.outline-insert-btn {
    display: none;
    align-items: center;
    font-size: 0.6rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    border: 1.5px solid var(--primary);
    color: var(--primary);
    background: transparent;
    cursor: pointer;
    margin-left: 0.3rem;
    flex-shrink: 0;
    white-space: nowrap;
    line-height: 1.4;
}
.outline-insert-btn:hover { background: var(--primary); color: var(--on-brand); }

/* ── Outline "New Idea" add bar (Fix 2) ──────────────────── */
.outline-add-trigger {
    display: none; width: 100%;
    margin: 0.85rem 0 0.6rem;
    padding: 0.75rem 1rem;
    font-size: 0.88rem; font-family: 'Montserrat', sans-serif; font-weight: 700;
    color: var(--on-brand); background: var(--primary);
    border: none; border-radius: 8px;
    cursor: pointer; letter-spacing: 0.03em; text-align: center;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 35%, transparent);
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.outline-add-trigger:hover {
    background: var(--primary-dark, color-mix(in srgb, var(--primary) 80%, #000));
    box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 45%, transparent);
}
.outline-add-trigger:active { transform: scale(0.97); }
.outline-add-bar {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-surface);
}
.outline-add-input {
    flex: 1; border: none; border-bottom: 1.5px solid var(--border-medium);
    background: transparent; font-size: 0.78rem;
    font-family: 'Montserrat', sans-serif; outline: none; padding: 0.2rem 0;
    color: var(--charcoal);
}
.outline-add-input:focus { border-bottom-color: var(--primary); }

/* ── Mobile phone notice banner (Fix 3) ──────────────────── */
.mobile-notice {
    display: none;
    align-items: flex-start; gap: 0.6rem;
    padding: 0.55rem 0.85rem;
    background: var(--primary-light);
    border-bottom: 1px solid var(--primary-mid);
    font-size: 0.72rem; font-family: 'Montserrat', sans-serif;
    line-height: 1.45; color: var(--charcoal);
    position: relative; z-index: 45;
}
.mobile-notice-text { flex: 1; }
.mobile-notice-outline-btn {
    font-weight: 700; color: var(--primary); background: none;
    border: none; cursor: pointer; font-size: 0.72rem;
    font-family: 'Montserrat', sans-serif; padding: 0; text-decoration: underline;
}
.mobile-notice-dismiss {
    background: none; border: none; cursor: pointer;
    font-size: 1rem; color: var(--slate); padding: 0 0 0 0.4rem;
    flex-shrink: 0; line-height: 1;
}

.empty-graph-hint {
    position: absolute;
    top: 42%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--charcoal);
    max-width: 460px;
}

.empty-graph-hint .welcome-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.empty-graph-hint .welcome-byline {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--slate);
    margin-bottom: 1.25rem;
}

.empty-graph-hint .welcome-intro {
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--slate);
    margin-bottom: 1.5rem;
}

.empty-graph-hint .welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: center;
}

.welcome-action-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 280px;
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--border-medium);
    border-radius: 10px;
    background: var(--bg-surface);
    font-family: 'Open Sans', sans-serif;
    font-size: 0.82rem;
    color: var(--charcoal);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.welcome-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 2px 10px var(--shadow-sm);
}

.welcome-action-icon {
    font-size: 1.1rem;
    width: 1.6rem;
    text-align: center;
    flex-shrink: 0;
}

/* Featured action buttons (starter cards + brainstorm) */
.welcome-action-featured {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 6%, var(--bg-surface));
    font-weight: 600;
    flex-wrap: wrap;
}
.welcome-action-featured:hover {
    background: color-mix(in srgb, var(--primary) 14%, var(--bg-surface));
    box-shadow: 0 3px 14px color-mix(in srgb, var(--primary) 20%, transparent);
}
body.dark-mode .welcome-action-featured {
    background: color-mix(in srgb, var(--primary) 10%, var(--topbar-bg));
}
body.dark-mode .welcome-action-featured:hover {
    background: color-mix(in srgb, var(--primary) 18%, var(--topbar-bg));
}

.welcome-action-sub {
    display: block;
    width: 100%;
    font-size: 0.68rem;
    font-weight: 400;
    color: var(--slate);
    margin-top: 1px;
    padding-left: 2.2rem;
}

/* ── Brainstorm prompt overlay ── */
.brainstorm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    background: color-mix(in srgb, var(--canvas-bg, #F0F2F5) 85%, transparent);
    backdrop-filter: blur(4px);
    animation: brainstormFadeIn 0.3s ease;
}
@keyframes brainstormFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.brainstorm-card {
    width: 440px;
    max-width: 90%;
    background: var(--bg-surface);
    border: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: 0 12px 48px var(--shadow-lg);
    animation: brainstormSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes brainstormSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
body.dark-mode .brainstorm-card {
    background: var(--topbar-bg);
    border-color: color-mix(in srgb, var(--primary) 30%, transparent);
    box-shadow: 0 12px 48px var(--shadow-xl), 0 0 32px color-mix(in srgb, var(--primary) 8%, transparent);
}

.brainstorm-progress {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 14px;
}

.brainstorm-question {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--charcoal);
    line-height: 1.5;
    margin-bottom: 8px;
}

.brainstorm-hint {
    font-family: 'Open Sans', sans-serif;
    font-size: 0.78rem;
    color: var(--slate);
    font-style: italic;
    margin-bottom: 16px;
    line-height: 1.5;
}

.brainstorm-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border-light);
    border-radius: 10px;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.88rem;
    color: var(--charcoal);
    background: var(--warm-white);
    resize: vertical;
    min-height: 70px;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 14px;
    box-sizing: border-box;
}
.brainstorm-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}
.brainstorm-input::placeholder { color: var(--slate); opacity: 0.6; }
body.dark-mode .brainstorm-input { background: var(--bg-panel); border-color: var(--border-medium); }
body.dark-mode .brainstorm-input:focus { border-color: var(--primary); }

.brainstorm-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.brainstorm-add-btn {
    flex: 1;
    padding: 10px 16px;
    background: var(--primary);
    color: var(--on-brand);
    border: none;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.brainstorm-add-btn:hover { background: var(--primary-mid); }
.brainstorm-skip-btn {
    padding: 10px 16px;
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--slate);
    cursor: pointer;
    transition: background 0.15s;
}
.brainstorm-skip-btn:hover { background: var(--cream); }

.brainstorm-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid var(--border-lighter);
    font-family: 'Open Sans', sans-serif;
    font-size: 0.72rem;
    color: var(--slate);
}
.brainstorm-exit-btn {
    background: none;
    border: none;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--slate);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.brainstorm-exit-btn:hover { color: var(--charcoal); background: var(--cream); }

/* Brainstorm done state */
.brainstorm-done { text-align: center; }
.brainstorm-done-emoji { font-size: 2.4rem; margin-bottom: 10px; }
.brainstorm-done-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}
.brainstorm-done-detail {
    font-family: 'Open Sans', sans-serif;
    font-size: 0.82rem;
    color: var(--slate);
    margin-bottom: 6px;
    line-height: 1.5;
}
.brainstorm-done .brainstorm-actions {
    justify-content: center;
    margin-top: 16px;
}

.welcome-guide-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 280px;
    padding: 0.8rem 1rem;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    font-family: 'Open Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--on-brand);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    margin-bottom: 0.4rem;
}
.welcome-guide-btn:hover {
    filter: brightness(1.15);
    box-shadow: 0 2px 12px var(--shadow-md);
}
.welcome-guide-btn .i { stroke: var(--on-brand); }

/* ─── GUIDE BAR ───────────────────────────────────── */
.guide-bar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark, #094A56));
    border-bottom: none;
    padding: 0.75rem 1rem;
    font-family: 'Open Sans', sans-serif;
    position: relative;
    z-index: 20;
    color: var(--on-brand);
    box-shadow: 0 2px 12px var(--shadow-primary);
}
.guide-bar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.guide-progress-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}
.guide-progress-label {
    font-size: 0.78rem;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    color: var(--on-brand);
    white-space: nowrap;
}
.guide-progress-step {
    font-size: 0.7rem;
    color: var(--on-brand-muted);
    white-space: nowrap;
}
.guide-progress-track {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.25);
    border-radius: 2px;
    overflow: hidden;
    min-width: 60px;
}
.guide-progress-fill {
    height: 100%;
    background: var(--bg-surface);
    border-radius: 2px;
    transition: width 0.3s ease;
}
.guide-bar-body {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.guide-message {
    font-size: 0.85rem;
    color: var(--on-brand);
    line-height: 1.4;
    flex: 1;
    min-width: 200px;
}
.guide-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.guide-next-btn {
    padding: 0.35rem 0.75rem;
    border: 1.5px solid rgba(255,255,255,0.6);
    border-radius: 6px;
    background: rgba(255,255,255,0.15);
    color: var(--on-brand);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.guide-next-btn:hover {
    background: rgba(255,255,255,0.25);
}
.guide-next-btn.ready {
    background: var(--bg-surface);
    color: var(--primary);
    border-color: var(--bg-surface);
    animation: guideNextPulse 2s ease-in-out infinite;
}
.guide-next-btn.ready:hover {
    background: rgba(255,255,255,0.9);
}
@keyframes guideNextPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb, 13, 92, 107), 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(var(--primary-rgb, 13, 92, 107), 0); }
}
.guide-helper-toggle {
    padding: 0.3rem 0.6rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--on-brand-muted);
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: underline;
    white-space: nowrap;
}
.guide-helper-toggle:hover {
    color: var(--on-brand);
}
.guide-dismiss-btn {
    padding: 0.2rem 0.5rem;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.6);
    font-size: 0.72rem;
    cursor: pointer;
    white-space: nowrap;
}
.guide-dismiss-btn:hover {
    color: var(--on-brand);
    text-decoration: underline;
}
.guide-helper-text {
    margin-top: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: rgba(255,255,255,0.12);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--on-brand);
    line-height: 1.45;
}
@media (max-width: 600px) {
    .guide-bar-body { flex-direction: column; }
    .guide-progress-wrap { flex-wrap: wrap; }
}

/* ─── INLINE DOUBLE-CLICK ADD ──────────────────── */
.quick-add-inline {
    position: absolute;
    background: var(--bg-surface);
    border: 1.5px solid var(--primary);
    border-radius: 10px;
    padding: 0.75rem;
    box-shadow: 0 6px 24px var(--shadow-lg);
    z-index: 50;
    min-width: 230px;
    transform: translate(-50%, -50%);
    pointer-events: all;
}
.quick-add-inline-input {
    display: block; width: 100%; border: none; outline: none;
    font-family: 'Open Sans', sans-serif; font-size: 0.88rem; color: var(--charcoal);
    background: transparent; padding: 0.25rem 0;
    border-bottom: 1.5px solid var(--border-light); margin-bottom: 0.5rem; box-sizing: border-box;
}
.quick-add-inline-input:focus { border-bottom-color: var(--primary); }
.quick-add-role-chips { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.role-chip {
    padding: 0.15rem 0.45rem; border-radius: 8px; border: 1.5px solid var(--border-medium);
    font-family: 'Montserrat', sans-serif; font-size: 0.6rem; font-weight: 700;
    cursor: pointer; background: transparent; color: var(--slate); transition: all 0.15s;
}
.role-chip.chip-unassigned.active { background: var(--border-medium); color: white; border-color: var(--border-medium); }
.role-chip.chip-anchor.active    { background: var(--anchor-color);  color: var(--on-brand); border-color: var(--anchor-color); }
.role-chip.chip-pillar.active    { background: var(--pillar-color);  color: var(--on-brand); border-color: var(--pillar-color); }
.role-chip.chip-subpoint.active  { background: var(--subpoint-color);color: var(--on-brand); border-color: var(--subpoint-color); }
.role-chip.chip-group.active     { background: var(--primary);       color: var(--on-brand); border-color: var(--primary); }
.quick-add-hint { font-size: 0.58rem; color: var(--slate); margin-top: 0.35rem; font-family: 'Montserrat', sans-serif; opacity: 0.7; }

/* ─── HEX DRAG-CONNECT HIGHLIGHT ────────────────── */
.graph-node.drop-target-active .node-hex {
    filter: drop-shadow(0 0 14px color-mix(in srgb, var(--primary) 85%, transparent)) !important;
    transform: scale(1.07);
}

/* ─── OUTLINE DRAG-DROP ──────────────────────────── */
.node-list-drag-handle { color: var(--border-medium); font-size: 0.7rem; flex-shrink: 0; cursor: grab; user-select: none; padding: 0 0.1rem; }
.node-list-item.drag-active { opacity: 0.35; }
.node-list-item.drag-insert-before { border-top: 2px solid var(--primary); }
.node-list-item.drag-insert-after  { border-bottom: 2px solid var(--primary); }
.node-list-pillar-group.drag-insert-before { border-top: 2px solid var(--primary); border-radius: 0; }
.node-list-pillar-group.drag-insert-after  { border-bottom: 2px solid var(--primary); border-radius: 0; }
/* Support items — nested under subpoints */
.node-list-support-group {
    padding-left: 1rem;
    border-left: 2px solid var(--border-light);
    margin: 0.15rem 0 0.15rem 1.25rem;
}
.node-list-support-group .node-list-item {
    font-size: 0.75rem;
    opacity: 0.8;
    flex-wrap: wrap;
}
.node-list-support-group .node-list-label {
    white-space: normal;
    text-overflow: unset;
    line-height: 1.3;
    flex-basis: calc(100% - 2.5rem);
}
.node-list-support-group .merged-expand-icon {
    margin-left: 0;
}
.node-list-support-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--slate);
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.1rem 0 0.1rem 0.25rem;
    opacity: 0.7;
}
.outline-garden-drop {
    border: 1.5px dashed var(--garden-color); border-radius: 6px;
    padding: 0.35rem 0.6rem; font-size: 0.68rem; color: var(--garden-color);
    font-family: 'Montserrat', sans-serif; font-weight: 600; text-align: center;
    margin-bottom: 0.5rem; cursor: default; transition: all 0.15s;
}
.outline-garden-drop.drag-over { background: var(--garden-light); border-style: solid; }
.outline-section-drop-zone {
    border: 1.5px dashed var(--border-medium);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.68rem;
    color: var(--slate);
    text-align: center;
    margin: 0.1rem 0 0.6rem;
    opacity: 0.55;
    cursor: copy;
    transition: all 0.15s;
    font-style: italic;
}
.outline-section-drop-zone.drag-over {
    opacity: 1;
    background: var(--primary-tint-sm);
    border-color: var(--primary);
    border-style: solid;
    color: var(--primary);
}
.outline-section-drop-zone.unassigned-drop-zone { border-color: var(--slate); color: var(--slate); opacity: 1; }
.outline-section-drop-zone.unassigned-drop-zone.drag-over { background: color-mix(in srgb, var(--slate) 8%, transparent); border-color: var(--slate); color: var(--slate); }
.outline-section-drop-zone.garden-drop-zone { border-color: var(--garden-color); color: var(--garden-color); }
.outline-section-drop-zone.garden-drop-zone.drag-over { background: var(--garden-light); border-color: var(--garden-color); color: var(--garden-color); }
.outline-section-drop-zone.anchor-drop-zone { border-color: var(--anchor-color); color: var(--anchor-color); }
.outline-section-drop-zone.anchor-drop-zone.drag-over { background: color-mix(in srgb, var(--anchor-color) 8%, transparent); border-color: var(--anchor-color); color: var(--anchor-color); }
.outline-section-drop-zone.pillar-drop-zone { border-color: var(--pillar-color); color: var(--pillar-color); }
.outline-section-drop-zone.pillar-drop-zone.drag-over { background: color-mix(in srgb, var(--pillar-color) 8%, transparent); border-color: var(--pillar-color); color: var(--pillar-color); }
.outline-section-drop-zone.subpoint-drop-zone { border-color: var(--subpoint-color); color: var(--subpoint-color); margin-left: 1rem; }
.outline-section-drop-zone.subpoint-drop-zone.drag-over { background: color-mix(in srgb, var(--subpoint-color) 8%, transparent); border-color: var(--subpoint-color); color: var(--subpoint-color); }
/* Canvas-to-outline drag highlights */
.outline-section-drop-zone.canvas-drag-over { opacity: 1; border-style: solid; }
.outline-section-drop-zone.anchor-drop-zone.canvas-drag-over { background: color-mix(in srgb, var(--anchor-color) 8%, transparent); border-color: var(--anchor-color); color: var(--anchor-color); }
.outline-section-drop-zone.pillar-drop-zone.canvas-drag-over { background: color-mix(in srgb, var(--pillar-color) 8%, transparent); border-color: var(--pillar-color); color: var(--pillar-color); }
.outline-section-drop-zone.subpoint-drop-zone.canvas-drag-over { background: color-mix(in srgb, var(--subpoint-color) 8%, transparent); border-color: var(--subpoint-color); color: var(--subpoint-color); }
.outline-section-drop-zone.garden-drop-zone.canvas-drag-over { background: var(--garden-light); border-color: var(--garden-color); color: var(--garden-color); }
.outline-section-drop-zone.unassigned-drop-zone.canvas-drag-over { background: color-mix(in srgb, var(--slate) 8%, transparent); border-color: var(--slate); color: var(--slate); }
.node-list-pillar-group.canvas-drag-over { background: color-mix(in srgb, var(--pillar-color) 8%, transparent); border-radius: 6px; }
.graph-area.canvas-drop-active { outline: 2px dashed var(--primary); outline-offset: -4px; background: color-mix(in srgb, var(--primary) 4%, transparent); }
.detail-input.drag-over { border-color: var(--primary) !important; background: color-mix(in srgb, var(--primary) 6%, transparent) !important; }

/* Welcome button → outline highlight */
@keyframes outlinePulse {
    0%, 100% { box-shadow: -4px 0 12px var(--shadow-md); }
    50% { box-shadow: -4px 0 20px var(--shadow-md), 0 0 0 3px var(--primary); }
}
.right-panel.outline-highlight-pulse {
    animation: outlinePulse 0.8s ease 2;
}
@keyframes dragHintWiggle {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(6px); }
    40% { transform: translateX(-4px); }
    60% { transform: translateX(3px); }
    80% { transform: translateX(-1px); }
}
.node-list-item.outline-drag-hint {
    box-shadow: 0 0 0 2px var(--primary);
    border-radius: 6px;
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    animation: dragHintWiggle 0.6s ease 0.3s 1;
}
.node-list-drag-handle.outline-drag-hint-handle {
    color: var(--primary) !important;
    transform: scale(1.4);
    transition: transform 0.3s, color 0.3s;
}
.outline-section-drop-zone.outline-drag-hint-zone {
    opacity: 1;
    border-color: var(--primary);
    border-style: solid;
    background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.node-list-subgroup { padding-left: 1rem; }
.node-list-pillar-group { margin-bottom: 0.15rem; }

/* ─── DISCOVERY SECTION (pipeline reference content) ───── */
.discovery-divider {
    border: none; border-top: 1px dashed var(--border-light);
    margin: 0.75rem 0 0.5rem;
}
.discovery-section-title {
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--slate); padding: 0 0.5rem;
    margin-bottom: 0.3rem; display: flex; align-items: center; gap: 0.35rem;
}
.discovery-group {
    margin-bottom: 0.35rem;
}
.discovery-group-header {
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; padding: 0.35rem 0.5rem; cursor: pointer;
    user-select: none; display: flex; align-items: center; gap: 0.3rem;
}
.discovery-group-header .discovery-chevron {
    font-size: 0.55rem; transition: transform 0.15s ease;
}
.discovery-group-header.collapsed .discovery-chevron {
    transform: rotate(-90deg);
}
.discovery-group-items {
    padding: 0; overflow: hidden;
}
.discovery-group-header.collapsed + .discovery-group-items {
    display: none;
}
.discovery-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.45rem 0.5rem 0.45rem 0.75rem; cursor: grab;
    font-size: 0.78rem; color: var(--charcoal); border-radius: 6px;
    transition: background 0.15s;
}
.discovery-item:hover { background: var(--cream); }
.discovery-item.drag-active { opacity: 0.4; }
.discovery-item.discovery-expanded { background: var(--cream); border-radius: 6px 6px 0 0; }
.discovery-item .discovery-check {
    font-size: 0.6rem; color: var(--sage); flex-shrink: 0; margin-right: -2px; opacity: 0.85;
}
.discovery-item .discovery-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.discovery-item .discovery-label {
    flex: 1; min-width: 0; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.discovery-item .discovery-tag {
    font-size: 0.58rem; color: var(--slate); opacity: 0.7;
    flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.04em;
}
.discovery-expand-body {
    padding: 0.3rem 0.75rem 0.5rem 2rem;
    background: var(--cream); border-radius: 0 0 6px 6px; margin-bottom: 2px;
    font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5;
    white-space: pre-wrap; word-break: break-word;
}
.discovery-empty-note {
    font-size: 0.7rem; color: var(--slate); opacity: 0.6;
    padding: 0.35rem 0.5rem 0.35rem 0.75rem; font-style: italic;
}

/* ─── DISCOVERY SUB-GROUP HEADINGS ───────────────── */
.discovery-subgroup { margin-left: 0.5rem; }
.discovery-subgroup-header {
    font-size: 0.6rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; padding: 0.3rem 0.5rem; cursor: pointer;
    user-select: none; display: flex; align-items: center; gap: 0.3rem;
    color: var(--slate); opacity: 0.85;
}
.discovery-subgroup-header .discovery-chevron {
    font-size: 0.5rem; transition: transform 0.15s ease;
}
.discovery-subgroup-header.collapsed .discovery-chevron {
    transform: rotate(-90deg);
}
.discovery-subgroup-items { padding: 0; overflow: hidden; }
.discovery-subgroup-header.collapsed + .discovery-subgroup-items {
    display: none;
}

.discovery-subsubgroup { margin-left: 0.4rem; }
.discovery-subsubgroup-header {
    font-size: 0.55rem; font-weight: 500;
    letter-spacing: 0.03em; padding: 0.25rem 0.5rem; cursor: pointer;
    user-select: none; display: flex; align-items: center; gap: 0.25rem;
    color: var(--slate); opacity: 0.7; font-style: italic;
}
.discovery-subsubgroup-header .discovery-chevron {
    font-size: 0.45rem; transition: transform 0.15s ease;
}
.discovery-subsubgroup-header.collapsed .discovery-chevron {
    transform: rotate(-90deg);
}
.discovery-subsubgroup-items { padding: 0; overflow: hidden; }
.discovery-subsubgroup-header.collapsed + .discovery-subsubgroup-items {
    display: none;
}

/* ─── MERGED OUTLINE PANEL ───────────────────────── */
.merged-outline-node { margin-bottom: 1px; }
.merged-expand-icon {
    margin-left: auto; font-size: 0.6rem; color: var(--slate);
    cursor: pointer; flex-shrink: 0; padding: 0 0.15rem; user-select: none;
}
.merged-item-fields {
    padding: 0.3rem 0.5rem 0.4rem 2rem;
    background: var(--cream); border-radius: 0 0 4px 4px; margin-bottom: 2px;
}
.merged-field-row {
    display: flex; align-items: baseline; gap: 0.4rem;
    padding: 0.2rem 0.3rem; border-radius: 3px;
    font-size: 0.72rem; cursor: grab; color: var(--text-secondary);
}
.merged-field-row:hover { background: var(--primary-tint-xs); }
.outline-details-btn {
    background: none; border: 1px solid transparent; padding: 0.1rem 0.4rem;
    font-size: 0.65rem; color: var(--slate); cursor: pointer;
    flex-shrink: 0; opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s, border-color 0.15s;
    line-height: 1; border-radius: 3px; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 0.25rem;
}
.node-list-item:hover .outline-details-btn,
.node-list-item.selected .outline-details-btn { opacity: 1; }
.outline-details-btn:hover {
    color: var(--primary);
    background: var(--primary-tint-xs);
    border-color: var(--primary);
}
.merged-field-dot {
    width: 5px; height: 5px; border-radius: 50%; background: var(--border-medium);
    flex-shrink: 0; margin-top: 3px;
}

/* ─── STRUCTURE MAP VIEW ─────────────────────────── */
.structure-view-overlay {
    position: absolute; inset: 0; background: var(--warm-white); z-index: 8;
    overflow: auto; padding: 3.5rem 2rem 2rem;
    display: flex; flex-direction: column; align-items: center;
}
.structure-view-toolbar {
    position: absolute; top: 0.75rem; left: 0; right: 0;
    display: flex; align-items: center; justify-content: center; gap: 1rem; z-index: 10;
}
.structure-view-back-btn {
    padding: 0.4rem 0.9rem; background: var(--bg-surface); border: 1.5px solid var(--border-light);
    border-radius: 20px; font-family: 'Montserrat', sans-serif; font-size: 0.72rem; font-weight: 600;
    cursor: pointer; color: var(--charcoal); box-shadow: 0 2px 8px var(--shadow-sm); transition: all 0.2s;
}
.structure-view-back-btn:hover { border-color: var(--primary); color: var(--primary); }
.structure-view-label { font-family: 'Montserrat', sans-serif; font-size: 0.8rem; font-weight: 700; color: var(--primary); }
.view-structure-btn {
    position: absolute; bottom: 1rem; left: 50%; transform: translateX(-50%);
    padding: 0.4rem 1rem; background: var(--primary); color: var(--on-brand); border: none;
    border-radius: 20px; font-family: 'Montserrat', sans-serif; font-size: 0.72rem; font-weight: 700;
    cursor: pointer; box-shadow: 0 2px 8px var(--shadow-primary); z-index: 10;
    white-space: nowrap; transition: all 0.2s;
}
.view-structure-btn:hover { background: var(--primary-mid); }

/* ─── PRESENTATION MODE ─────────────────────────── */
.presentation-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--warm-white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.presentation-slide {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.presentation-slide-inner {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Hexagonal accent — left side of content slides */
.presentation-hex-accent {
    position: absolute;
    top: 0;
    left: -5%;
    width: 48%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}
.presentation-hex-accent svg {
    width: 100%;
    height: 100%;
}

/* Content layout — left (over hex) */
.presentation-content-left {
    position: relative;
    z-index: 1;
    width: 42%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 7.5rem 3rem 3.5rem;
    color: var(--on-brand);
}

/* Content layout — right (talking points) */
.presentation-content-right {
    position: relative;
    z-index: 1;
    width: 58%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 6rem 3rem 3rem;
}

.presentation-role-label {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.85;
    margin-bottom: 0.75rem;
}

.presentation-header {
    font-family: 'Montserrat', sans-serif;
    font-size: 3.2rem;
    font-weight: 700;
    line-height: 1.15;
}
.presentation-header[contenteditable]:hover { outline: 1px dashed var(--border-medium); outline-offset: 4px; cursor: text; }
.presentation-header[contenteditable]:focus { outline: 2px solid var(--primary); outline-offset: 4px; }

.presentation-talking-points-editable {
    font-family: 'Open Sans', sans-serif;
    font-size: 1.3rem;
    line-height: 1.8;
    color: var(--charcoal);
    white-space: pre-wrap;
    min-height: 2em;
}
.presentation-talking-points-editable:hover { outline: 1px dashed var(--border-medium); outline-offset: 4px; cursor: text; }
.presentation-talking-points-editable:focus { outline: 2px solid var(--primary); outline-offset: 4px; }
.presentation-talking-points-editable:empty::before { content: 'Click to add talking points...'; color: var(--slate); font-style: italic; }

.presentation-talking-points {
    list-style: none;
    padding: 0;
    margin: 0;
}

.presentation-talking-points li {
    font-family: 'Open Sans', sans-serif;
    font-size: 1.45rem;
    line-height: 1.55;
    color: var(--charcoal);
    padding: 0.75rem 0;
    padding-left: 2rem;
    position: relative;
}

.presentation-talking-points li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 1.5rem;
    width: 12px;
    height: 12px;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    background: var(--tp-accent, var(--primary));
    opacity: 0.6;
}

/* Title & Thank You slides */
.presentation-title-slide {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    height: 100%;
}

.presentation-title-text {
    font-family: 'Montserrat', sans-serif;
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
    margin-bottom: 1rem;
    max-width: 55%;
}

.presentation-author-text {
    font-family: 'Open Sans', sans-serif;
    font-size: 1.4rem;
    color: var(--slate);
}

.presentation-date-text {
    font-family: 'Open Sans', sans-serif;
    font-size: 1.1rem;
    color: var(--slate);
    margin-top: 0.3rem;
}

.presentation-thankyou-text {
    font-family: 'Montserrat', sans-serif;
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary);
}

.presentation-deco-hex {
    width: 90px;
    height: 90px;
    margin-bottom: 2rem;
}

/* Navigation controls */
.presentation-nav {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 10;
}

.presentation-nav-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1.5px solid var(--border-light);
    background: var(--bg-surface);
    color: var(--charcoal);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    box-shadow: 0 2px 8px var(--shadow-sm);
}

.presentation-nav-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.presentation-nav-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.presentation-slide-counter {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--slate);
    min-width: 60px;
    text-align: center;
}

/* Progress bar */
.presentation-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--border-lighter);
    z-index: 10;
}

.presentation-progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

/* Exit button */
.presentation-exit-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid var(--border-light);
    background: var(--bg-surface);
    color: var(--charcoal);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    box-shadow: 0 2px 8px var(--shadow-sm);
}

.presentation-exit-btn:hover {
    border-color: var(--color-danger);
    color: var(--color-danger);
}

/* Slide entrance animation */
.presentation-slide-enter {
    animation: presSlideIn 0.3s ease forwards;
}

@keyframes presSlideIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Hex-to-slide zoom transition */
.hex-zoom-overlay {
    position: fixed;
    inset: 0;
    z-index: 1001;
    pointer-events: none;
    overflow: hidden;
}
.hex-zoom-clone {
    position: absolute;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    transition: all 0.55s cubic-bezier(0.4, 0, 0.15, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--on-brand);
    font-weight: 600;
    overflow: hidden;
}
.hex-zoom-clone.zoom-active {
    clip-path: polygon(0% 0%, 70% 0%, 100% 50%, 70% 100%, 0% 100%, 0% 50%);
}
.hex-zoom-label {
    font-size: inherit;
    padding: 0 10%;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.hex-zoom-clone.zoom-active .hex-zoom-label {
    opacity: 0;
}
.presentation-overlay.fade-reveal {
    opacity: 0;
    transition: opacity 0.25s ease;
}
.presentation-overlay.fade-reveal.visible {
    opacity: 1;
}

/* Responsive — tablet */
@media (max-width: 768px) {
    .presentation-slide-inner {
        flex-direction: column;
    }

    .presentation-hex-accent {
        width: 100%;
        height: 35%;
        top: 0;
        left: 0;
    }

    .presentation-hex-accent { border-radius: 0; }

    .presentation-content-left {
        width: 100%;
        height: 35%;
        padding: 2rem 1.5rem 1rem;
        justify-content: flex-end;
    }

    .presentation-content-right {
        width: 100%;
        height: 65%;
        padding: 1.5rem;
        overflow-y: auto;
    }

    .presentation-header { font-size: 2rem; }
    .presentation-role-label { font-size: 0.8rem; }
    .presentation-talking-points li { font-size: 1.15rem; }
    .presentation-title-text { font-size: 2.2rem; }
    .presentation-author-text { font-size: 1.1rem; }
    .presentation-thankyou-text { font-size: 2.8rem; }

    .presentation-nav { bottom: 1rem; }
    .presentation-exit-btn { top: 0.75rem; right: 0.75rem; }
}

/* Responsive — phone */
@media (max-width: 480px) {
    .presentation-content-left { padding: 1.5rem 1rem 0.5rem; }
    .presentation-content-right { padding: 1rem; }
    .presentation-header { font-size: 1.5rem; }
    .presentation-talking-points li { font-size: 1rem; }
    .presentation-title-text { font-size: 1.6rem; }
    .presentation-thankyou-text { font-size: 2.2rem; }
}


/* ══════════════════════════════════════════════════════════════
   MOBILE BOTTOM TAB BAR (phone ≤600px)
   ══════════════════════════════════════════════════════════════ */

.mobile-bottom-bar {
    display: none;             /* hidden on desktop/tablet */
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    z-index: 300;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-light);
    box-shadow: 0 -1px 6px var(--shadow-sm);
    flex-direction: row;
    align-items: stretch;
    /* Safe area for phones with home indicator */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (max-width: 600px) {
    .mobile-bottom-bar { display: flex !important; }
    /* On phones, hide tool rail — bottom bar handles navigation */
    .tool-rail { display: none !important; }
    .main-area { margin-left: 0 !important; margin-bottom: 56px; }
    /* Phone: fully hide sidebar when closed — overflow:visible on base rule
       can leak content when translateX(-100%) lands right at viewport edge */
    .sidebar { display: none !important; left: 0 !important; overflow: hidden !important; }
    .sidebar.open { display: flex !important; transform: translateX(0) !important; }
    /* Hide mobile header undo/redo on phone — save space */
    .mobile-header .undo-btn,
    .mobile-header .redo-btn { display: none; }
}

.mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: transparent;
    color: var(--slate);
    font: 500 0.6rem/1 'Montserrat', sans-serif;
    cursor: pointer;
    padding: 6px 0;
    position: relative;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.mobile-tab.active {
    color: var(--primary);
}
.mobile-tab:active {
    background: var(--primary-tint-sm);
}
.mobile-tab-icon {
    width: 22px;
    height: 22px;
}
.mobile-tab span:not(.mobile-tab-badge) {
    font-size: 0.6rem;
    letter-spacing: 0.02em;
}

/* Badge on Ideas tab */
.mobile-tab-badge {
    display: none;
    position: absolute;
    top: 4px; right: 50%;
    transform: translateX(12px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--rose);
    color: var(--on-brand);
    font: 600 0.55rem/16px 'Montserrat', sans-serif;
    text-align: center;
}

/* ── Mobile Tool Header (Think tab) ────────────────────────── */
.mobile-tool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0 0.75rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0.75rem;
}
.mobile-tool-header span {
    font: 600 0.95rem/1.2 'Montserrat', sans-serif;
    color: var(--charcoal);
}
.mobile-tool-header button {
    border: 1.5px solid var(--border-medium);
    background: transparent;
    color: var(--primary);
    font: 500 0.75rem/1 'Montserrat', sans-serif;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
}

/* ══════════════════════════════════════════════════════════════
   MOBILE MORE SHEET (slide-up bottom sheet)
   ══════════════════════════════════════════════════════════════ */

.mobile-more-sheet {
    position: fixed;
    inset: 0;
    z-index: 400;
}
.mobile-more-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
    opacity: 0;
    transition: opacity 0.2s;
}
.mobile-more-sheet.open .mobile-more-backdrop {
    opacity: 1;
}
.mobile-more-content {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: var(--bg-panel);
    border-radius: 16px 16px 0 0;
    padding: 0.5rem 1rem 1.5rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    max-height: 75vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.25s ease-out;
    box-shadow: 0 -4px 20px var(--shadow-md);
}
.mobile-more-sheet.open .mobile-more-content {
    transform: translateY(0);
}
.mobile-more-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-medium);
    margin: 0 auto 0.75rem;
}
.mobile-more-section {
    margin-bottom: 1rem;
}
.mobile-more-label {
    font: 600 0.7rem/1 'Montserrat', sans-serif;
    color: var(--slate);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}
.mobile-more-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}
.mobile-more-tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0.6rem 0.25rem;
    border: 1.5px solid var(--border-light);
    border-radius: 10px;
    background: var(--bg-surface);
    color: var(--charcoal);
    font: 500 0.65rem/1.2 'Montserrat', sans-serif;
    cursor: pointer;
    transition: all 0.12s;
    -webkit-tap-highlight-color: transparent;
}
.mobile-more-tool:active {
    background: var(--primary-tint-sm);
}
.mobile-more-tool.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-tint-sm);
}
.mobile-more-tool .i-lg {
    width: 20px; height: 20px;
}
.mobile-more-actions {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.mobile-more-actions button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--charcoal);
    font: 400 0.85rem/1.3 'Open Sans', sans-serif;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.mobile-more-actions button:active {
    background: var(--primary-tint-sm);
}
.mobile-more-actions button .i {
    width: 18px; height: 18px;
    color: var(--slate);
}

/* A11y: Focus indicators for elements with outline:none */
.graph-script:focus-visible,
.graph-node-edit-text:focus-visible,
.outline-tree-item input:focus-visible,
.outline-tree-label textarea:focus-visible,
.outline-tree-node-title:focus-visible,
.outline-tree-node-role-selector:focus-visible,
.structure-map-search input:focus-visible,
.quick-add-inline-input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
