.mindmap-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 560px;
    position: relative;
    background: #f4f7fb;
    overflow: hidden;
}

.mindmap-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .55rem .75rem;
    border-bottom: 1px solid #dce3eb;
    background: #fff;
    z-index: 20;
}

.mindmap-toolbar button:disabled {
    cursor: not-allowed;
}

.mindmap-status {
    margin-left: auto;
    color: #64748b;
    font-size: .8rem;
    min-width: 7rem;
    text-align: right;
}

.mindmap-format-tools .btn.active {
    color: #fff;
    background: #6c757d;
}

.mindmap-node-format {
    position: absolute;
    z-index: 10;
    padding: .25rem;
    border: 1px solid #cbd5e1;
    border-radius: .5rem;
    background: #fff;
    box-shadow: 0 5px 16px rgb(15 23 42 / 18%);
    transform: translate(-50%, -100%);
}

.mindmap-node-format[hidden] {
    display: none;
}

.mindmap-node-format::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    border: 6px solid transparent;
    border-top-color: #fff;
    transform: translateX(-50%);
}

.mindmap-node-add {
    position: absolute;
    inset: 0;
    z-index: 9;
    pointer-events: none;
}

.mindmap-node-add[hidden] {
    display: none;
}

.mindmap-add-handle {
    position: absolute;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid #0d6efd;
    border-radius: 50%;
    background: #fff;
    color: #0d6efd;
    font: 700 17px/1 sans-serif;
    box-shadow: 0 2px 7px rgb(15 23 42 / 18%);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: opacity .12s ease, transform .12s ease;
}

.mindmap-add-handle.is-visible {
    opacity: .72;
    pointer-events: auto;
}

.mindmap-add-handle:hover,
.mindmap-add-handle:focus-visible {
    background: #0d6efd;
    color: #fff;
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1.12);
}

.mindmap-colour-apply {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.mindmap-colour-apply:disabled {
    opacity: 1;
    color: #212529;
    background: #f8f9fa;
}

.mindmap-colour-apply {
    position: relative;
    min-width: 2rem;
}

.mindmap-colour-mark {
    position: absolute;
    right: .3rem;
    bottom: .2rem;
    left: .3rem;
    height: 3px;
    border-radius: 2px;
}

.mindmap-swatches {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    padding: 0 .35rem;
    border-right: 1px solid #dee2e6;
    border-left: 1px solid #dee2e6;
    background: #f8f9fa;
}

.mindmap-swatch {
    width: 1rem;
    height: 1rem;
    padding: 0;
    border: 1px solid rgb(15 23 42 / 25%);
    border-radius: 50%;
    background: var(--swatch-colour);
    cursor: pointer;
}

.mindmap-swatch.is-current {
    outline: 2px solid #0d6efd;
    outline-offset: 1px;
}

.mindmap-swatch.is-applied {
    box-shadow: inset 0 0 0 2px #fff, 0 0 0 1px #212529;
}

.mindmap-swatch:hover,
.mindmap-swatch:focus-visible {
    transform: scale(1.18);
}

.mindmap-highlight-icon {
    padding: 0 .15rem;
    background: #fff3a3;
}

.mindmap-style-control {
    width: 180px;
    flex: 0 0 180px;
}

.mindmap-style-control .form-select {
    min-width: 105px;
}

.mindmap-zoom-value {
    min-width: 4.25rem;
    font-variant-numeric: tabular-nums;
}

.mindmap-workspace {
    flex: 1;
    overflow: auto;
    position: relative;
    cursor: grab;
    background-color: #f8fafc;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 24px 24px;
}

.mindmap-workspace.is-panning {
    cursor: grabbing;
    user-select: none;
}

.mindmap-canvas {
    width: 4000px;
    height: 2400px;
    position: relative;
    transform-origin: 0 0;
}

.mindmap-connections,
.mindmap-nodes {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.mindmap-connections {
    overflow: visible;
    pointer-events: none;
}

.mindmap-branch {
    fill: none;
    stroke: #94a3b8;
    stroke-width: 3;
}

.mindmap-node {
    box-sizing: border-box;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 180px;
    min-height: 64px;
    padding: .65rem 1rem;
    border: 2px solid #8aa4c2;
    border-radius: 14px;
    background: #fff;
    color: #1e293b;
    box-shadow: 0 3px 9px rgb(15 23 42 / 10%);
    cursor: pointer;
    overflow: visible;
    overflow-wrap: anywhere;
    text-align: center;
    line-height: 1.25;
    user-select: none;
    z-index: 2;
}

.mindmap-node.is-root {
    width: 220px;
    min-height: 70px;
    border-radius: 999px;
    border-color: #0d6efd;
    background: #0d6efd;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
}

.mindmap-canvas.is-branch-style .mindmap-node:not(.is-root) {
    align-items: flex-end;
    justify-content: flex-start;
    min-height: 40px;
    padding: .25rem .45rem .4rem;
    border: 0;
    border-bottom: 3px solid var(--node-accent, #8aa4c2);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    text-align: left;
    overflow: visible;
}

.mindmap-canvas.is-branch-style .mindmap-node:not(.is-root).is-selected {
    outline-offset: 2px;
}

.mindmap-canvas.is-branch-style .mindmap-node-input {
    text-align: left;
}

.mindmap-node.is-selected {
    outline: 4px solid rgb(13 110 253 / 22%);
    outline-offset: 3px;
}

.mindmap-node.is-dragging {
    opacity: .45;
}

.mindmap-node.is-drop-target {
    outline: 4px solid rgb(25 135 84 / 32%);
    border-color: #198754;
}

.mindmap-node.is-drop-child {
    outline-color: rgb(25 135 84 / 38%);
    border-color: #198754;
}

.mindmap-node.is-drop-sibling {
    outline-color: rgb(13 110 253 / 38%);
    border-color: #0d6efd;
}

.mindmap-node.is-drop-between {
    outline-color: rgb(111 66 193 / 42%);
    border-color: #6f42c1;
}

.mindmap-node.is-drop-top {
    box-shadow: inset 0 5px 0 #0d6efd, 0 3px 9px rgb(15 23 42 / 10%) !important;
}

.mindmap-node.is-drop-bottom {
    box-shadow: inset 0 -5px 0 #0d6efd, 0 3px 9px rgb(15 23 42 / 10%) !important;
}

.mindmap-node.is-drop-left {
    box-shadow: inset 5px 0 0 #6f42c1, 0 3px 9px rgb(15 23 42 / 10%) !important;
}

.mindmap-node.is-drop-right {
    box-shadow: inset -5px 0 0 #198754, 0 3px 9px rgb(15 23 42 / 10%) !important;
}

.mindmap-node.is-invalid-target {
    cursor: not-allowed;
}

.mindmap-node-input {
    width: 100%;
    min-width: 0;
    border: 0;
    border-radius: 5px;
    padding: .15rem .3rem;
    background: #fff;
    color: #1e293b;
    text-align: center;
    outline: 2px solid #0d6efd;
}

.mindmap-welcome {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgb(248 250 252 / 94%);
}

.mindmap-welcome[hidden] {
    display: none;
}

.mindmap-welcome-card {
    width: min(100%, 560px);
    padding: 2rem;
    border: 1px solid #dce3eb;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 16px 45px rgb(15 23 42 / 12%);
}

.mindmap-welcome-card h1 {
    font-size: 1.8rem;
}

@media (max-width: 700px) {
    .mindmap-page {
        min-height: 650px;
    }

    .mindmap-toolbar {
        align-items: stretch;
    }

    .mindmap-toolbar .btn-group {
        flex-wrap: wrap;
    }

    .mindmap-status {
        width: 100%;
        margin-left: 0;
        text-align: left;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mindmap-node {
        scroll-behavior: auto;
    }
}
