/* Workspace Background */
.bg-dot-pattern {
    background-image: radial-gradient(circle, #cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0;
}

:is(.dark) .bg-dot-pattern {
    background-image: radial-gradient(circle, #334155 1px, transparent 1px);
}

/* Grab cursors for panning workspace */
.cursor-grab {
    cursor: grab;
}

.cursor-grabbing {
    cursor: grabbing !important;
}

/* Node Rendering Styles (in DOM) */
.tree-node {
    position: absolute;
    min-width: 200px;
    max-width: 280px;
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    border: 2px solid transparent;
    user-select: none;
    transition: box-shadow 0.2s, border-color 0.2s;
    z-index: 10;
}

:is(.dark) .tree-node {
    background: #1e293b;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.tree-node:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.tree-node.selected {
    border-color: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
    z-index: 15;
}

.tree-node.outcome {
    border-left: 4px solid #3b82f6;
    background: #f8fafc;
}

:is(.dark) .tree-node.outcome {
    background: #0f172a;
}

/* Port connections (for dropping incoming links) */
.node-port {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    z-index: 20;
    transition: all 0.2s;
}

:is(.dark) .node-port {
    background: #1e293b;
    border-color: #475569;
}

.node-port.top {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
}

.node-port.bottom {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
}

.node-port:hover,
.node-port.active {
    border-color: #22c55e;
    background: #dcfce7;
    transform: translateX(-50%) scale(1.5);
}

/* SVG Pathing */
.link-path {
    fill: none;
    stroke: #94a3b8;
    stroke-width: 3;
    pointer-events: visibleStroke;
    cursor: pointer;
    transition: stroke 0.2s, stroke-width 0.2s;
}

:is(.dark) .link-path {
    stroke: #475569;
}

.link-path:hover,
.link-path.selected {
    stroke: #22c55e;
    stroke-width: 4;
}

/* Branch text label over path */
.link-label {
    fill: #475569;
    font-size: 12px;
    font-weight: 500;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: central;
}

/* A rect rendered behind text for readability */
.link-label-bg {
    fill: white;
}

:is(.dark) .link-label {
    fill: #cbd5e1;
}

:is(.dark) .link-label-bg {
    fill: #0f172a;
}

.link-group.selected .link-label-bg {
    fill: #dcfce7;
}

:is(.dark) .link-group.selected .link-label-bg {
    fill: #14532d;
}

/* Markdown prose rendering */
.prose h1 {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.prose h2 {
    font-size: 1.125rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.prose p {
    margin-bottom: 0.5rem;
    word-break: break-word;
}

.prose p:last-child {
    margin-bottom: 0;
}

.prose a {
    color: #22c55e;
    text-decoration: underline;
}

.prose img {
    max-width: 100%;
    border-radius: 0.375rem;
    margin: 0.5rem 0;
}

.prose strong {
    font-weight: 600;
}

.prose em {
    font-style: italic;
}

.prose ul {
    list-style-type: disc;
    padding-left: 1.25rem;
    margin-bottom: 0.5rem;
}

/* Toast */
.toast-visible {
    opacity: 1 !important;
    transform: translate(-50%, -10px) !important;
}

/* Custom scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.4);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 114, 128, 0.6);
}