/* Mind map — Note methods (polished UI) */

.mind-map-page {
    min-height: calc(100vh - 56px);
    padding: clamp(1rem, 4vw, 2rem);
    box-sizing: border-box;
    background: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(61, 214, 140, 0.12), transparent 55%),
        linear-gradient(180deg, #0a0f14 0%, #000000 45%);
}

.mind-map-inner {
    max-width: 920px;
    margin: 0 auto;
}

.mind-map-back {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    padding: 0.4rem 0.65rem;
    border-radius: 10px;
    background: transparent;
    border: 1px solid transparent;
    color: #5ee9a8;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.mind-map-back:hover {
    background: rgba(61, 214, 140, 0.08);
    border-color: rgba(61, 214, 140, 0.2);
    text-decoration: none;
}

.mind-map-back:focus-visible {
    outline: 2px solid rgba(61, 214, 140, 0.55);
    outline-offset: 2px;
}

.mind-map-page h1 {
    color: #f8fafc;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0 0 0.4rem 0;
    font-size: clamp(1.4rem, 4vw, 1.85rem);
    text-shadow: 0 1px 24px rgba(61, 214, 140, 0.12);
}

.mind-map-lede {
    color: #94a3b8;
    margin: 0 0 1.25rem 0;
    font-size: 0.95rem;
    line-height: 1.55;
    max-width: 52ch;
}

.mind-map-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.85rem;
    padding: 0.55rem 0.65rem;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.mind-map-title-input {
    flex: 1 1 200px;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.5rem 0.65rem;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.6);
    color: #f1f5f9;
    font-size: 0.95rem;
    font-family: inherit;
}

.mind-map-title-input::placeholder {
    color: #64748b;
}

.mind-map-title-input:focus {
    outline: none;
    border-color: rgba(61, 214, 140, 0.55);
    box-shadow: 0 0 0 2px rgba(61, 214, 140, 0.15);
}

.mind-map-save-status {
    font-size: 0.85rem;
    color: #94a3b8;
    flex: 1 1 120px;
    min-width: 0;
}

.mind-map-save-status.is-error {
    color: #f87171;
}

.mind-map-save-status.is-ok {
    color: #3dd68c;
}

.mind-map-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.35rem;
    padding: 0.5rem 0.65rem;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.mind-map-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1.05rem;
    border-radius: 11px;
    border: 1px solid rgba(61, 214, 140, 0.5);
    background: linear-gradient(145deg, #26a066 0%, #34d399 55%, #3dd68c 100%);
    color: #041208;
    font-weight: 700;
    font-size: 0.88rem;
    letter-spacing: 0.01em;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 2px 12px rgba(61, 214, 140, 0.25);
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.15s ease;
}

.mind-map-toolbar-btn:hover {
    filter: brightness(1.05);
    box-shadow: 0 4px 20px rgba(61, 214, 140, 0.32);
}

.mind-map-toolbar-btn:active {
    transform: translateY(1px);
}

.mind-map-toolbar-btn:focus-visible {
    outline: 2px solid rgba(52, 211, 153, 0.85);
    outline-offset: 2px;
}

.mind-map-toolbar-icon {
    font-weight: 800;
    opacity: 0.95;
}

.mind-map-toolbar-btn--secondary {
    background: rgba(15, 23, 42, 0.6);
    color: #a7f3d0;
    border-color: rgba(61, 214, 140, 0.28);
    box-shadow: none;
}

.mind-map-toolbar-btn--secondary:hover {
    background: rgba(61, 214, 140, 0.12);
    border-color: rgba(61, 214, 140, 0.45);
}

.mind-map-board {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mind-map-center-card {
    position: relative;
    border: 1px solid rgba(61, 214, 140, 0.38);
    border-radius: 18px;
    padding: 1.1rem 1.2rem 1.15rem;
    background: linear-gradient(165deg, rgba(61, 214, 140, 0.14) 0%, rgba(15, 23, 42, 0.55) 100%);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(61, 214, 140, 0.08) inset,
        0 1px 0 rgba(255, 255, 255, 0.06) inset;
    overflow: hidden;
}

.mind-map-center-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(61, 214, 140, 0.55), transparent);
    opacity: 0.85;
    pointer-events: none;
}

.mind-map-center-badge {
    display: inline-block;
    margin-bottom: 0.45rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #34d399;
    background: rgba(61, 214, 140, 0.12);
    border: 1px solid rgba(61, 214, 140, 0.28);
}

.mind-map-center-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

.mind-map-topic-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.7rem 0.85rem;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(0, 0, 0, 0.35);
    color: #f8fafc;
    font-size: 1.2rem;
    font-weight: 600;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mind-map-topic-input::placeholder {
    color: #64748b;
}

.mind-map-topic-input:hover {
    border-color: rgba(61, 214, 140, 0.25);
}

.mind-map-topic-input:focus {
    outline: none;
    border-color: rgba(61, 214, 140, 0.55);
    box-shadow: 0 0 0 3px rgba(61, 214, 140, 0.12);
}

/* Visual link hub → branches */
.mind-map-connector {
    height: 20px;
    width: 2px;
    margin: 0 auto;
    background: linear-gradient(to bottom, rgba(61, 214, 140, 0.45), rgba(61, 214, 140, 0.12));
    border-radius: 2px;
}

.mind-map-canvas {
    border-radius: 16px;
    padding: 1rem 1rem 1.15rem;
    background-color: rgba(8, 12, 18, 0.65);
    background-image: radial-gradient(rgba(61, 214, 140, 0.09) 1px, transparent 1px);
    background-size: 18px 18px;
    border: 1px solid rgba(61, 214, 140, 0.12);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.mind-map-branches {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.mind-map-branch {
    position: relative;
    border-radius: 14px;
    padding: 0.75rem 0.85rem 0.85rem;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.mind-map-branch:hover {
    border-color: rgba(61, 214, 140, 0.28);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(61, 214, 140, 0.06);
    background: rgba(255, 255, 255, 0.045);
}

.mind-map-branch--root::before {
    content: "";
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 12px;
    background: linear-gradient(to bottom, rgba(61, 214, 140, 0.5), rgba(61, 214, 140, 0.15));
    border-radius: 2px;
    pointer-events: none;
}

.mind-map-branch--nested {
    margin-top: 0.25rem;
}

/* Depth tint: deeper = cooler / subtler */
.mind-map-branch[data-depth="1"] {
    border-color: rgba(94, 234, 212, 0.16);
    background: rgba(15, 23, 42, 0.35);
}

.mind-map-branch[data-depth="2"],
.mind-map-branch[data-depth="3"],
.mind-map-branch[data-depth="4"] {
    border-color: rgba(125, 211, 252, 0.12);
    background: rgba(15, 23, 42, 0.42);
}

.mind-map-branch-head {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    margin-bottom: 0.45rem;
}

.mind-map-drag-handle {
    flex-shrink: 0;
    width: 1.65rem;
    min-height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(0, 0, 0, 0.25);
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 1;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.mind-map-drag-handle:active {
    cursor: grabbing;
}

.mind-map-drag-handle:focus-visible {
    outline: 2px solid rgba(61, 214, 140, 0.45);
    outline-offset: 2px;
}

.mind-map-collapse-btn {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid rgba(61, 214, 140, 0.25);
    border-radius: 10px;
    background: rgba(61, 214, 140, 0.08);
    color: #6ee7b7;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.mind-map-collapse-btn:hover {
    background: rgba(61, 214, 140, 0.16);
    border-color: rgba(61, 214, 140, 0.45);
}

.mind-map-collapse-icon {
    font-size: 0.7rem;
    line-height: 1;
}

.mind-map-branch-children--collapsed {
    display: none !important;
}

body.mind-map-exporting .mind-map-branch-children.mind-map-branch-children--collapsed {
    display: flex !important;
    flex-direction: column;
    gap: 0.55rem;
}

.mind-map-branch--dragging {
    opacity: 0.55;
}

.mind-map-branch--drop-target {
    outline: 2px dashed rgba(61, 214, 140, 0.55);
    outline-offset: 2px;
    background: rgba(61, 214, 140, 0.06);
}

.mind-map-toolbar-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

.mind-map-branch-remove {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: 10px;
    background: rgba(248, 113, 113, 0.08);
    color: #fca5a5;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
}

.mind-map-branch-remove:hover {
    background: rgba(248, 113, 113, 0.2);
    border-color: rgba(248, 113, 113, 0.4);
}

.mind-map-branch-remove:active {
    transform: scale(0.96);
}

.mind-map-branch-remove:focus-visible {
    outline: 2px solid rgba(248, 113, 113, 0.5);
    outline-offset: 2px;
}

.mind-map-branch-label {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.45rem 0.5rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: #f1f5f9;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mind-map-branch-label::placeholder {
    color: #64748b;
}

.mind-map-branch-label:hover {
    border-color: rgba(148, 163, 184, 0.15);
}

.mind-map-branch-label:focus {
    outline: none;
    border-color: rgba(61, 214, 140, 0.4);
    box-shadow: 0 0 0 2px rgba(61, 214, 140, 0.1);
}

.mind-map-branch-subrow {
    margin: 0.4rem 0 0.55rem;
}

.mind-map-add-sub-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.38rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(61, 214, 140, 0.35);
    background: rgba(61, 214, 140, 0.07);
    color: #6ee7b7;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}

.mind-map-add-sub-btn:hover {
    background: rgba(61, 214, 140, 0.16);
    border-color: rgba(61, 214, 140, 0.55);
}

.mind-map-add-sub-btn:active {
    transform: scale(0.98);
}

.mind-map-add-sub-btn:focus-visible {
    outline: 2px solid rgba(52, 211, 153, 0.55);
    outline-offset: 2px;
}

.mind-map-branch-children {
    margin-top: 0.55rem;
    padding-left: 0.9rem;
    border-left: 2px solid rgba(61, 214, 140, 0.22);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.mind-map-branch-detail {
    width: 100%;
    box-sizing: border-box;
    min-height: 76px;
    padding: 0.55rem 0.65rem;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.1);
    resize: vertical;
    background: rgba(0, 0, 0, 0.22);
    color: #cbd5e1;
    font-size: 0.88rem;
    line-height: 1.5;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mind-map-branch-detail::placeholder {
    color: #64748b;
}

.mind-map-branch-detail:hover {
    border-color: rgba(148, 163, 184, 0.18);
}

.mind-map-branch-detail:focus {
    outline: none;
    border-color: rgba(61, 214, 140, 0.3);
    box-shadow: 0 0 0 2px rgba(61, 214, 140, 0.08);
}

.mind-map-branches-empty {
    text-align: center;
    padding: 2rem 1.25rem;
    color: #94a3b8;
    font-size: 0.92rem;
    line-height: 1.5;
    border: 1px dashed rgba(61, 214, 140, 0.28);
    border-radius: 14px;
    background: rgba(61, 214, 140, 0.03);
}

.mind-map-branches-empty::before {
    content: "🗺️";
    display: block;
    font-size: 1.75rem;
    margin-bottom: 0.6rem;
    filter: grayscale(0.2);
    opacity: 0.85;
}

@media (prefers-reduced-motion: reduce) {
    .mind-map-branch,
    .mind-map-toolbar-btn,
    .mind-map-back,
    .mind-map-add-sub-btn,
    .mind-map-branch-remove {
        transition: none;
    }

    .mind-map-toolbar-btn:active,
    .mind-map-add-sub-btn:active,
    .mind-map-branch-remove:active {
        transform: none;
    }
}

@media (max-width: 520px) {
    .mind-map-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .mind-map-toolbar-btn {
        justify-content: center;
    }
}
