/* ================================================================
   Bot Flow Editor — Visual flow builder styles
   Glassmorphism dark theme consistent with PromptLab
   ================================================================ */

/* === OVERLAY === */
.bfe-overlay {
    position: fixed;
    inset: 0;
    z-index: 6999;
    background: #000;
    display: none;
    flex-direction: column;
}
.bfe-overlay.active {
    display: flex;
}

/* === TOOLBAR === */
.bfe-toolbar {
    height: 52px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 2;
    padding-top: env(safe-area-inset-top);
    flex-shrink: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
}
.bfe-overlay.pinching .bfe-toolbar {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.bfe-toolbar-title {
    font-size: 15px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bfe-toolbar-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.2s;
    flex-shrink: 0;
}
.bfe-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}
.bfe-toolbar-btn:active {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(0.95);
}
.bfe-toolbar-btn svg {
    width: 18px;
    height: 18px;
}

.bfe-toolbar-separator {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.bfe-zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}
.bfe-zoom-level {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    min-width: 36px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    user-select: none;
    -webkit-user-select: none;
}

/* === CANVAS WRAPPER === */
.bfe-canvas-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
    touch-action: none;
    background: #0a0a0a;
    background-image:
        radial-gradient(circle, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 24px 24px;
    padding-top: env(safe-area-inset-top);
}

/* === CANVAS (transform target) === */
.bfe-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 2000px;
    height: 2000px;
    transform-origin: 0 0;
    /* transform set dynamically: translate(Xpx, Ypx) scale(S) */
}

/* === SVG EDGES === */
.bfe-edges-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: visible;
}
.bfe-edge-path {
    fill: none;
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 2;
    stroke-linecap: round;
    transition: stroke 0.2s, stroke-width 0.2s;
}
.bfe-edge-path.active {
    stroke: var(--accent);
    stroke-width: 2.5;
}
.bfe-edge-path.dragging {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 8 4;
}
.bfe-edge-path:hover {
    stroke: rgba(255, 255, 255, 0.3);
}

/* Edge arrowhead */
.bfe-edge-arrow {
    fill: rgba(255, 255, 255, 0.15);
    transition: fill 0.2s;
}
.bfe-edge-path.active + .bfe-edge-arrow,
.bfe-edge-arrow.active {
    fill: var(--accent);
}

/* Edge condition labels */
.bfe-edge-label {
    font-size: 10px;
    fill: rgba(255, 255, 255, 0.4);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}
.bfe-edge-label-bg {
    fill: rgba(10, 10, 10, 0.85);
    rx: 4;
    ry: 4;
}

/* === NODES CONTAINER === */
.bfe-nodes-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* === NODE BASE === */
.bfe-node {
    position: absolute;
    width: 200px;
    min-height: 60px;
    border-radius: 12px;
    background: rgba(28, 28, 30, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    padding: 12px 14px;
    cursor: grab;
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.1s;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}
.bfe-node:active {
    cursor: grabbing;
}
.bfe-node.dragging {
    cursor: grabbing;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    z-index: 100 !important;
    opacity: 0.92;
}
.bfe-node.selected {
    border-color: var(--accent);
    box-shadow:
        0 0 0 2px rgba(var(--accent-rgb), 0.3),
        0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Node type left accent border */
.bfe-node--start {
    border-left: 3px solid #00C853;
}
.bfe-node--message {
    border-left: 3px solid var(--accent);
}
.bfe-node--trigger {
    border-left: 3px solid #FF9800;
}
.bfe-node--decision {
    border-left: 3px solid #FFD600;
}
.bfe-node--action {
    border-left: 3px solid #AA00FF;
}
.bfe-node--end {
    border-left: 3px solid #FF1744;
}

/* Node header */
.bfe-node-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.bfe-node-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
    line-height: 1;
}
.bfe-node--start .bfe-node-icon {
    background: rgba(0, 200, 83, 0.15);
    color: #00C853;
}
.bfe-node--message .bfe-node-icon {
    background: rgba(var(--accent-rgb), 0.15);
    color: var(--accent);
}
.bfe-node--trigger .bfe-node-icon {
    background: rgba(255, 152, 0, 0.15);
    color: #FF9800;
}
.bfe-node--decision .bfe-node-icon {
    background: rgba(255, 214, 0, 0.15);
    color: #FFD600;
}
.bfe-node--action .bfe-node-icon {
    background: rgba(170, 0, 255, 0.15);
    color: #AA00FF;
}
.bfe-node--end .bfe-node-icon {
    background: rgba(255, 23, 68, 0.15);
    color: #FF1744;
}

.bfe-node-type {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.35);
}

.bfe-node-label {
    display: none;
}

/* Node body text */
.bfe-node-body {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
}

/* === NODE PORTS (hidden — edges connect directly to cards) === */
.bfe-node-port,
.bfe-node-port-in,
.bfe-node-port-yes,
.bfe-node-port-no,
.bfe-port-label,
.bfe-port-label-yes,
.bfe-port-label-no,
.bfe-node-ports,
.bfe-trigger-branches,
.bfe-action-label {
    display: none !important;
}

/* End node styling */
.bfe-node--end .bfe-node-body {
    color: rgba(255, 23, 68, 0.8);
    font-weight: 600;
}

/* Start node styling */
.bfe-node--start .bfe-node-body {
    color: rgba(0, 200, 83, 0.8);
    font-weight: 600;
}

/* === PORT PULSE ANIMATION === */
@keyframes bfe-port-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0); }
}

/* === BOTTOM SHEET === */
.bfe-bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 38vh;
    background: rgba(28, 28, 30, 0.97);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 2147483647 !important;
    padding-bottom: calc(env(safe-area-inset-bottom) + 50px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}
.bfe-bottom-sheet.active {
    transform: translateY(0);
}
.bfe-bottom-sheet.dragging {
    transition: none;
}

.bfe-sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
    margin: 8px auto 10px;
}

.bfe-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.bfe-sheet-title {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
}
.bfe-sheet-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    transition: all 0.2s;
}
.bfe-sheet-close:active {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(0.92);
}

.bfe-sheet-content {
    padding: 12px 20px 20px;
}

/* Sheet section label */
.bfe-sheet-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 6px;
    margin-top: 12px;
}
.bfe-sheet-label:first-child {
    margin-top: 0;
}

/* Sheet tabs (language) */
.bfe-lang-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}
.bfe-lang-tab {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all 0.2s;
}
.bfe-lang-tab:active {
    transform: scale(0.97);
}
.bfe-lang-tab.active {
    background: rgba(var(--accent-rgb), 0.12);
    border-color: var(--accent);
    color: var(--accent);
}

/* Sheet text input */
.bfe-sheet-input {
    width: 100%;
    height: 40px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.bfe-sheet-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Sheet textarea */
.bfe-sheet-textarea {
    width: 100%;
    min-height: 40px;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    resize: none;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    box-sizing: border-box;
    transition: border-color 0.2s;
    line-height: 1.5;
    field-sizing: content;
}
.bfe-sheet-textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.bfe-sheet-textarea::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

/* Variable chips */
.bfe-var-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.bfe-var-chip {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(var(--accent-rgb), 0.08);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    color: var(--accent);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
}
.bfe-var-chip:active {
    background: rgba(var(--accent-rgb), 0.2);
    transform: scale(0.95);
}

/* Trigger word chips */
.bfe-word-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.bfe-word-chip {
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(255, 152, 0, 0.08);
    border: 1px solid rgba(255, 152, 0, 0.2);
    color: #FF9800;
    display: flex;
    align-items: center;
    gap: 4px;
}
.bfe-word-chip-remove {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.4);
    transition: all 0.2s;
    line-height: 1;
}
.bfe-word-chip-remove:hover {
    background: rgba(255, 23, 68, 0.2);
    color: #FF1744;
}

/* Add word input row */
.bfe-add-word-row {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.bfe-add-word-input {
    flex: 1;
    height: 36px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 0 10px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
}
.bfe-add-word-input:focus {
    outline: none;
    border-color: var(--accent);
}
.bfe-add-word-btn {
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    background: var(--accent);
    border: none;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.bfe-add-word-btn:active {
    transform: scale(0.95);
    opacity: 0.9;
}

/* Message variant list */
.bfe-variant-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.bfe-variant-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.bfe-variant-item textarea {
    flex: 1;
}
.bfe-variant-remove {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 23, 68, 0.08);
    border: 1px solid rgba(255, 23, 68, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 23, 68, 0.6);
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 4px;
    transition: all 0.2s;
}
.bfe-variant-remove:active {
    background: rgba(255, 23, 68, 0.2);
}

.bfe-add-variant-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border-radius: 8px;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    background: transparent;
    color: rgba(255, 255, 255, 0.35);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 4px;
}
.bfe-add-variant-btn:active {
    border-color: var(--accent);
    color: var(--accent);
}

/* Condition editor */
.bfe-condition-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.bfe-condition-select {
    flex: 1;
    height: 40px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0 12px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    appearance: none;
    -webkit-appearance: none;
}
.bfe-condition-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* === ADD NODE MENU === */
.bfe-add-menu {
    position: absolute;
    top: 52px;
    right: 12px;
    background: rgba(28, 28, 30, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 6px;
    z-index: 5;
    display: none;
    min-width: 180px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.bfe-add-menu.active {
    display: block;
}
.bfe-add-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    transition: background 0.15s;
}
.bfe-add-menu-item:hover {
    background: rgba(255, 255, 255, 0.04);
}
.bfe-add-menu-item:active {
    background: rgba(255, 255, 255, 0.06);
}
.bfe-add-menu-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.bfe-add-menu-dot--start    { background: #00C853; }
.bfe-add-menu-dot--message  { background: var(--accent); }
.bfe-add-menu-dot--trigger  { background: #FF9800; }
.bfe-add-menu-dot--decision { background: #FFD600; }
.bfe-add-menu-dot--action   { background: #AA00FF; }
.bfe-add-menu-dot--end      { background: #FF1744; }

.bfe-add-menu-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 4px 8px;
}

/* === CONTEXT MENU (right-click / long-press) === */
.bfe-context-menu {
    position: absolute;
    background: rgba(28, 28, 30, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 4px;
    z-index: 20;
    display: none;
    min-width: 160px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}
.bfe-context-menu.active {
    display: block;
}
.bfe-context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    transition: background 0.15s;
}
.bfe-context-menu-item:active {
    background: rgba(255, 255, 255, 0.06);
}
.bfe-context-menu-item--danger {
    color: #FF1744;
}
.bfe-context-menu-item--danger:active {
    background: rgba(255, 23, 68, 0.1);
}
.bfe-context-menu-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 3px 8px;
}

/* === SELECTION BOX (multi-select drag) === */
.bfe-selection-box {
    position: absolute;
    border: 1.5px solid var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
    border-radius: 4px;
    pointer-events: none;
    z-index: 5;
    display: none;
}
.bfe-selection-box.active {
    display: block;
}

/* === TOAST / SNACKBAR === */
.bfe-toast {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    z-index: 15;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
.bfe-toast.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* === SHEET DELETE BUTTON === */
.bfe-sheet-delete {
    width: 100%;
    padding: 12px;
    margin-top: 20px;
    border-radius: 10px;
    background: rgba(255, 23, 68, 0.08);
    border: 1px solid rgba(255, 23, 68, 0.15);
    color: #FF1744;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
}
.bfe-sheet-delete:active {
    background: rgba(255, 23, 68, 0.2);
    transform: scale(0.98);
}

/* === TOOLBAR SAVE/RESET BUTTONS === */
.bfe-toolbar-btn--save {
    background: rgba(0, 200, 83, 0.12);
    border-color: rgba(0, 200, 83, 0.3);
    color: #00C853;
}
.bfe-toolbar-btn--save:hover {
    background: rgba(0, 200, 83, 0.2);
}
.bfe-toolbar-btn--save:active {
    background: rgba(0, 200, 83, 0.25);
}
.bfe-toolbar-btn--save.saved {
    color: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}
.bfe-toolbar-btn--reset {
    background: rgba(255, 152, 0, 0.08);
    border-color: rgba(255, 152, 0, 0.2);
    color: #FF9800;
}
.bfe-toolbar-btn--reset:hover {
    background: rgba(255, 152, 0, 0.15);
}
.bfe-toolbar-btn--reset:active {
    background: rgba(255, 152, 0, 0.2);
}

/* === CONFIRM DIALOG === */
.bfe-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.bfe-confirm-dialog {
    background: rgba(28, 28, 30, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 20px;
    max-width: 280px;
    width: 90%;
    text-align: center;
}
.bfe-confirm-title {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 8px;
}
.bfe-confirm-msg {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 18px;
    line-height: 1.4;
}
.bfe-confirm-buttons {
    display: flex;
    gap: 8px;
}
.bfe-confirm-btn {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
}
.bfe-confirm-btn--cancel {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
}
.bfe-confirm-btn--cancel:active {
    background: rgba(255, 255, 255, 0.1);
}
.bfe-confirm-btn--confirm {
    background: rgba(255, 23, 68, 0.15);
    color: #FF1744;
}
.bfe-confirm-btn--confirm:active {
    background: rgba(255, 23, 68, 0.3);
}
.bfe-confirm-btn--ok {
    background: rgba(var(--accent-rgb, 0, 122, 255), 0.15);
    color: var(--accent, #007AFF);
}
.bfe-confirm-btn--ok:active {
    background: rgba(var(--accent-rgb, 0, 122, 255), 0.3);
}

/* === UNDO BUTTON === */
.bfe-toolbar-btn--undo {
    opacity: 0.5;
}
.bfe-toolbar-btn--undo.has-undo {
    opacity: 1;
}

/* === EDGE HIT AREA === */
.bfe-edge-hit:hover + .bfe-edge-path {
    stroke: rgba(255, 23, 68, 0.5) !important;
    stroke-width: 3;
}

/* === EMPTY STATE === */
.bfe-empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.25);
    pointer-events: none;
    z-index: 0;
}
.bfe-empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}
.bfe-empty-state-text {
    font-size: 14px;
    line-height: 1.5;
}

/* === LOADING OVERLAY === */
.bfe-loading {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.bfe-loading.active {
    display: flex;
}
.bfe-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: bfe-spin 0.8s linear infinite;
}
@keyframes bfe-spin {
    to { transform: rotate(360deg); }
}

/* === RESPONSIVE === */
@media (max-width: 480px) {
    .bfe-node {
        width: 160px;
        padding: 10px 12px;
    }
    .bfe-node-body {
        font-size: 11px;
    }
    .bfe-node-label {
        font-size: 11px;
        max-width: 70px;
    }
    .bfe-toolbar {
        padding: 0 8px;
        gap: 6px;
    }
    .bfe-toolbar-title {
        font-size: 14px;
    }
    .bfe-bottom-sheet {
        max-height: 70vh;
    }
    .bfe-sheet-content {
        padding: 10px 16px 16px;
    }
    .bfe-zoom-controls {
        gap: 2px;
    }
    .bfe-add-menu {
        right: 8px;
        min-width: 160px;
    }
}

@media (max-width: 380px) {
    .bfe-node {
        width: 140px;
        padding: 8px 10px;
    }
    .bfe-toolbar-btn {
        width: 32px;
        height: 32px;
    }
    .bfe-toolbar-btn svg {
        width: 16px;
        height: 16px;
    }
}

/* === LIGHT THEME (Theme 15) === */
body.theme-light-text .bfe-overlay {
    background: #f2f2f7;
}
body.theme-light-text .bfe-toolbar {
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
body.theme-light-text .bfe-toolbar-title {
    color: rgba(0, 0, 0, 0.85) !important;
}
body.theme-light-text .bfe-toolbar-btn {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.7) !important;
}
body.theme-light-text .bfe-toolbar-btn:active {
    background: rgba(0, 0, 0, 0.08);
}
body.theme-light-text .bfe-toolbar-separator {
    background: rgba(0, 0, 0, 0.08);
}
body.theme-light-text .bfe-zoom-level {
    color: rgba(0, 0, 0, 0.4) !important;
}
body.theme-light-text .bfe-canvas-wrapper {
    background: #f2f2f7;
    background-image:
        radial-gradient(circle, rgba(0, 0, 0, 0.06) 1px, transparent 1px);
    background-size: 24px 24px;
}
body.theme-light-text .bfe-node {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid rgba(0, 0, 0, 0.08);
}
body.theme-light-text .bfe-node.selected {
    box-shadow:
        0 0 0 2px rgba(var(--accent-rgb), 0.3),
        0 8px 32px rgba(0, 0, 0, 0.1);
}
body.theme-light-text .bfe-node.dragging {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
body.theme-light-text .bfe-node-type {
    color: rgba(0, 0, 0, 0.35) !important;
}
body.theme-light-text .bfe-node-body {
    color: rgba(0, 0, 0, 0.65) !important;
}
body.theme-light-text .bfe-node--end .bfe-node-body {
    color: rgba(255, 23, 68, 0.8) !important;
}
body.theme-light-text .bfe-node--start .bfe-node-body {
    color: rgba(0, 200, 83, 0.8) !important;
}
body.theme-light-text .bfe-edge-path {
    stroke: rgba(0, 0, 0, 0.15);
}
body.theme-light-text .bfe-edge-path:hover {
    stroke: rgba(0, 0, 0, 0.3);
}
body.theme-light-text .bfe-edge-arrow {
    fill: rgba(0, 0, 0, 0.15);
}
body.theme-light-text .bfe-edge-label {
    fill: rgba(0, 0, 0, 0.4) !important;
}
body.theme-light-text .bfe-edge-label-bg {
    fill: rgba(242, 242, 247, 0.9);
}
body.theme-light-text .bfe-bottom-sheet {
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}
body.theme-light-text .bfe-sheet-handle {
    background: rgba(0, 0, 0, 0.15);
}
body.theme-light-text .bfe-sheet-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
body.theme-light-text .bfe-sheet-title {
    color: rgba(0, 0, 0, 0.85) !important;
}
body.theme-light-text .bfe-sheet-close {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.4) !important;
}
body.theme-light-text .bfe-sheet-close:active {
    background: rgba(0, 0, 0, 0.1);
}
body.theme-light-text .bfe-sheet-label {
    color: rgba(0, 0, 0, 0.45) !important;
}
body.theme-light-text .bfe-sheet-textarea,
body.theme-light-text .bfe-sheet-input {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.85) !important;
    -webkit-text-fill-color: rgba(0, 0, 0, 0.85) !important;
}
body.theme-light-text .bfe-sheet-textarea::placeholder {
    color: rgba(0, 0, 0, 0.3) !important;
    -webkit-text-fill-color: rgba(0, 0, 0, 0.3) !important;
}
body.theme-light-text .bfe-sheet-textarea:focus,
body.theme-light-text .bfe-sheet-input:focus {
    border-color: var(--accent);
}
body.theme-light-text .bfe-toast {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.85) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
body.theme-light-text .bfe-confirm-overlay {
    background: rgba(0, 0, 0, 0.3);
}
body.theme-light-text .bfe-confirm-dialog {
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(0, 0, 0, 0.08);
}
body.theme-light-text .bfe-confirm-title {
    color: rgba(0, 0, 0, 0.85) !important;
}
body.theme-light-text .bfe-confirm-msg {
    color: rgba(0, 0, 0, 0.5) !important;
}
body.theme-light-text .bfe-confirm-btn--cancel {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.6) !important;
}
body.theme-light-text .bfe-empty-state {
    color: rgba(0, 0, 0, 0.2) !important;
}
body.theme-light-text .bfe-loading {
    background: rgba(255, 255, 255, 0.6);
}
body.theme-light-text .bfe-loading-spinner {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: var(--accent);
}
body.theme-light-text .bfe-add-menu,
body.theme-light-text .bfe-context-menu {
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}
body.theme-light-text .bfe-add-menu-item,
body.theme-light-text .bfe-context-menu-item {
    color: rgba(0, 0, 0, 0.8) !important;
}
body.theme-light-text .bfe-add-menu-item:active,
body.theme-light-text .bfe-context-menu-item:active {
    background: rgba(0, 0, 0, 0.04);
}
body.theme-light-text .bfe-add-menu-separator,
body.theme-light-text .bfe-context-menu-separator {
    background: rgba(0, 0, 0, 0.06);
}

/* === PRINT / EXPORT (hide in print) === */
@media print {
    .bfe-toolbar,
    .bfe-bottom-sheet,
    .bfe-add-menu,
    .bfe-context-menu,
    .bfe-toast {
        display: none !important;
    }
    .bfe-canvas-wrapper {
        background: #fff;
    }
    .bfe-node {
        background: #fff;
        border-color: #ddd;
        color: #333;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .bfe-edge-path {
        stroke: #999;
    }
}
