// tutorials/tutorial.scss
// All styles extracted from inline JS Object.assign(el.style, {...}) calls.

// === Overlay ===
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    // No background-color here — set exclusively via JS setMode()
    // to avoid CSS/inline conflicts
    z-index: 9997; // Z.OVERLAY — below highlight (9998)
    touch-action: none;
    overscroll-behavior: contain;

    &--transparent {
        background-color: transparent !important;
    }
}

.tutorial-peek-btn {
    position: fixed;
    z-index: 10003; // Z.CONTAINER + 1
    bottom: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

// === Container / Avatar ===
// Container is a direct child of body (sibling of overlay, not inside it)
// so it needs its own fixed positioning to center on screen.
.tutorial-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002; // Z.CONTAINER — above overlay and highlight
    pointer-events: none; // Let clicks pass through to overlay

    > * {
        pointer-events: auto; // But children (bubble, avatar) are clickable
    }

    &--no-avatar {
        // Bubble is on body now, not inside container — no overrides needed
        .tutorial-arrow { display: none; }
    }
}

.tutorial-img-wrapper {
    position: relative;
    flex-shrink: 0;
    align-self: flex-end;
}

.tutorial-avatar {
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.tutorial-avatar-video {
    object-fit: contain;
    display: block;
    pointer-events: none;
}

// === Bubble ===
.tutorial-bubble {
    background-color: #ffffff;
    border-radius: 16px;
    padding: clamp(1rem, 3vw, 2rem) clamp(1.2rem, 4vw, 2.5rem);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: fixed;
    z-index: 10003; // Above container (10002) so bubble is never cut by avatar
    color: #1a1a1a;
    font-family: "Outfit", sans-serif;
    opacity: 0;
    transform: scale(0.8);
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    flex-direction: column;
    pointer-events: auto;

    &--mobile {
        position: relative;
        right: auto;
        left: auto;
        margin-right: 0;
        margin-left: 0;
        bottom: auto;
        top: auto;
        padding: 0.8rem 1rem;
        font-size: 13px;
        max-width: 90vw;
        min-width: 0;
        width: 100%;
    }

    &--chat {
        position: relative;
        top: auto;
        bottom: auto;
        left: auto;
        right: auto;
        transform: none;
        margin-left: 0;
        margin-right: 0;
        display: grid;
        grid-template-columns: 100px 1fr;
        gap: 1rem;
        align-items: start;
    }

    &--left {
        left: auto;
        right: 100%;
        margin-left: 0;
        margin-right: clamp(10px, 3vw, 20px);
        transform-origin: bottom right;
    }

    &--right {
        right: auto;
        left: 100%;
        margin-right: 0;
        margin-left: clamp(10px, 3vw, 20px);
        transform-origin: bottom left;
    }

    &--top {
        left: 0;
        right: 0;
        margin-left: auto;
        margin-right: auto;
        top: auto;
        transform: none;
        transform-origin: bottom center;
    }
}

.tutorial-arrow {
    position: absolute;
    right: -18px;
    bottom: 18px;
    width: 0;
    height: 0;
    border-top: 14px solid transparent;
    border-bottom: 14px solid transparent;
    border-left: 20px solid #ffffff;

    &--left {
        right: -18px;
        left: auto;
        border-top: 14px solid transparent;
        border-bottom: 14px solid transparent;
        border-left: 20px solid #ffffff;
        border-right: none;
    }

    &--right {
        right: auto;
        left: -18px;
        border-top: 14px solid transparent;
        border-bottom: 14px solid transparent;
        border-right: 20px solid #ffffff;
        border-left: none;
    }

    &--top {
        left: 50%;
        right: auto;
        bottom: -18px;
        transform: translateX(-50%);
        border-left: 14px solid transparent;
        border-right: 14px solid transparent;
        border-top: 20px solid #ffffff;
        border-bottom: none;
    }

    &--bottom {
        top: -18px;
        bottom: auto;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        border-left: 14px solid transparent;
        border-right: 14px solid transparent;
        border-bottom: 20px solid #ffffff;
        border-top: none;
    }

    &--hidden {
        display: none;
    }
}

// === Close button (top-right of bubble) ===
.tutorial-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: none;
    color: #aaa;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
    z-index: 2;
    padding: 0;

    &:hover {
        color: #333;
    }
}

.tutorial-text {
    margin: 0;
    max-height: clamp(150px, 40vh, 300px);
    overflow-y: auto;
}

.tutorial-options {
    margin-top: 1rem;
    display: none;
    flex-direction: column;
    gap: 0.5rem;
}

.tutorial-btn-row {
    margin-top: 1.2rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tutorial-action-btn {
    padding: 0.75rem 1.5rem;
    min-height: 44px;
    background-color: #07499e;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.tutorial-pause-btn {
    padding: 0.75rem 1rem;
    min-height: 44px;
    background-color: transparent;
    color: #07499e;
    border: 2px solid #07499e;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: none;
}

.tutorial-back-btn {
    padding: 0.75rem 1rem;
    min-height: 44px;
    background-color: transparent;
    color: #07499e;
    border: 2px solid #07499e;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: none;
}

// === Chat mode avatar ===
.tutorial-chat-avatar {
    width: 100px;
    height: 100px;
    min-width: 100px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #07499e;
    flex-shrink: 0;
    align-self: center;

    img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: top center;
    }
}

// === Cursor ===
.tutorial-cursor {
    position: fixed;
    z-index: 10000; // Z.CURSOR
    pointer-events: none;
    left: 0;
    top: 0;
    opacity: 0;

    &--mobile {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background-color: #4a6cf7;
        border: 3px solid #ffffff;
        box-shadow: 0 2px 8px rgba(74, 108, 247, 0.5);
        transform: translate(-50%, -50%);
    }
}

// === Highlight ===
.tutorial-highlight-svg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9998; // Z.HIGHLIGHT — above overlay (9997)
    pointer-events: none;
}

// === Options ===
.tutorial-option-btn {
    padding: 0.75rem 1rem;
    min-height: 44px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    transition: background-color 0.2s ease, transform 0.1s ease;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
}

// === AutoNext ===
.tutorial-auto-next-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: clamp(3px, 0.8vw, 5px);
    width: 0%;
    background-color: #07499e;
    border-radius: 0 0 16px 16px;
    transition: none;
}

// === Click Pulse ===
@keyframes tutorial-pulse-ring {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(var(--pulse-scale, 3));
        opacity: 0;
    }
}

.tutorial-pulse-ring {
    position: fixed;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid #ff4444;
    pointer-events: none;
    z-index: 10001; // Z.PULSE
    transform: translate(-50%, -50%);
    animation: tutorial-pulse-ring var(--pulse-duration, 0.7s) var(--pulse-delay, 0s) ease-out forwards;
}

// === Element Picker (dev only) ===
.tutorial-picker-highlight {
    position: fixed;
    border: 2px solid #6c8aff;
    border-radius: 4px;
    pointer-events: none;
    z-index: 100001;
    display: none;
    transition: all 0.08s ease;
    box-shadow: 0 0 0 3px rgba(108, 138, 255, 0.2);
}

.tutorial-picker-label {
    position: fixed;
    background: #1a1a2e;
    color: #6c8aff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-family: monospace;
    pointer-events: none;
    z-index: 100002;
    display: none;
    white-space: nowrap;
}

// === Step Builder Panel (dev only) ===
// Panel positioning and base look
.tutorial-step-builder-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100vh;
    overflow-y: auto;
    z-index: 10010;
    background: linear-gradient(170deg, #1e1e2e 0%, #161625 100%);
    color: #e0e4ec;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);

    &:empty { display: none; }
}

// === [data-sb] scoped styles ===
// Override Kompo wrapper styles for the dark step builder theme.
// Kompo wraps fields in .vlField > .vlFormControl > input with white backgrounds.
// We use !important sparingly where Kompo specificity can't be beaten otherwise.

[data-sb] {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 13px;
    line-height: 1.5;
}

[data-sb] *,
[data-sb] *::before,
[data-sb] *::after {
    box-sizing: border-box;
}

// --- Override Kompo wrappers ---
[data-sb] .vlField,
[data-sb] .vlFormControl,
[data-sb] .vlInputWrapper,
[data-sb] .vlToggle {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: auto !important;
}

[data-sb] .vlFieldLabel {
    color: #7a7f8e !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
    margin-bottom: 4px !important;
}

// --- Inputs ---
[data-sb] input,
[data-sb] select,
[data-sb] textarea {
    background: rgba(255, 255, 255, 0.06) !important;
    color: #e0e4ec !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 8px !important;
    padding: 8px 10px !important;
    font-size: 13px !important;
    font-family: inherit !important;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none !important;
    width: 100% !important;
}

[data-sb] input:focus,
[data-sb] select:focus,
[data-sb] textarea:focus {
    border-color: #6c8aff !important;
    box-shadow: 0 0 0 2px rgba(108, 138, 255, 0.15) !important;
}

[data-sb] input[type="number"] {
    width: 72px !important;
}

[data-sb] input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    accent-color: #6c8aff;
    cursor: pointer;
}

[data-sb] select {
    cursor: pointer;
    appearance: none !important;
    padding-right: 24px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
}

// --- Kompo Collapse/Collapsible overrides ---
[data-sb] .vlCollapse,
[data-sb] .vlCollapsible {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

[data-sb] .vlCollapseHeader,
[data-sb] .vlCollapsibleHeader {
    padding: 8px 0 !important;
    background: transparent !important;
}

// --- Kompo Toggle override ---
[data-sb] .vlToggleWrapper {
    background: transparent !important;
}

[data-sb] .vlToggleLabel {
    color: #b0b4c0 !important;
    font-size: 12px !important;
}

// --- Buttons ---
[data-sb] .sb-btn {
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 9px 16px;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

[data-sb] .sb-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

[data-sb] .sb-btn:active {
    transform: translateY(0);
}

[data-sb] .sb-btn-blue  { background: #4a6cf7; color: #fff; }
[data-sb] .sb-btn-green { background: #2ecc71; color: #fff; }
[data-sb] .sb-btn-red   { background: #e74c3c; color: #fff; }
[data-sb] .sb-btn-yellow { background: #f1c40f; color: #1a1a2e; }

[data-sb] .sb-btn-ghost {
    background: rgba(255, 255, 255, 0.06);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-sb] .sb-btn-ghost:hover {
    background: rgba(255, 255, 255, 0.12);
}

[data-sb] .sb-btn-sm {
    padding: 7px 12px;
    font-size: 13px;
}

[data-sb] .sb-btn-icon {
    padding: 7px 10px;
    font-size: 16px;
    min-width: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

// --- Step list items ---
[data-sb] .sb-step-list-inner {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

[data-sb] .sb-step-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 12px;

    &:hover { background: rgba(108, 138, 255, 0.1); }
    &.sb-active {
        background: rgba(108, 138, 255, 0.2);
        border: 1px solid rgba(108, 138, 255, 0.3);
    }
}

[data-sb] .sb-step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;

    .sb-active & { background: #6c8aff; color: #fff; }
}

[data-sb] .sb-step-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #b0b4c0;
}

[data-sb] .sb-step-icons {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
    font-size: 11px;
    color: #7a7f8e;
}

// --- Cards ---
[data-sb] .sb-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

// --- Spectator exit ---
.sb-spectator-exit {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100001;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

// --- Labels & rows ---
[data-sb] .sb-label {
    font-size: 14px;
    color: #7a7f8e;
    min-width: 65px;
    flex-shrink: 0;
}

[data-sb] .sb-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

// --- Section headers ---
[data-sb] .sb-section-header {
    font-size: 14px;
    font-weight: 700;
    color: #6c8aff;
    cursor: pointer;
    padding: 12px 0 8px;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

[data-sb] .sb-section-header:hover {
    color: #8aa4ff;
}

[data-sb] .sb-section-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: 4px;
}

// --- Code blocks ---
[data-sb] .sb-code {
    font-family: "Fira Code", "Cascadia Code", "JetBrains Mono", monospace;
}

[data-sb] .sb-selector {
    color: #2ecc71;
    font-size: 12px;
    word-break: break-all;
    font-family: "Fira Code", monospace;
}

// --- Scrollbar ---
[data-sb] ::-webkit-scrollbar       { width: 6px; }
[data-sb] ::-webkit-scrollbar-track  { background: transparent; }
[data-sb] ::-webkit-scrollbar-thumb  { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
[data-sb] ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

// --- Resize handles ---
[data-sb] .sb-resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    cursor: nwse-resize;
    bottom: 0;
    right: 0;
    z-index: 2;
}

[data-sb] .sb-resize-handle::after {
    content: "";
    position: absolute;
    right: 3px;
    bottom: 3px;
    width: 8px;
    height: 8px;
    border-right: 2px solid rgba(255, 255, 255, 0.15);
    border-bottom: 2px solid rgba(255, 255, 255, 0.15);
}

[data-sb] .sb-resize-left {
    position: absolute;
    width: 6px;
    top: 40px;
    bottom: 0;
    left: 0;
    cursor: ew-resize;
    z-index: 2;
}

[data-sb] .sb-resize-top {
    position: absolute;
    height: 6px;
    top: 0;
    left: 0;
    right: 0;
    cursor: ns-resize;
    z-index: 2;
}

// --- Option rows ---
[data-sb] .sb-option-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 4px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

// --- Badge ---
[data-sb] .sb-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(108, 138, 255, 0.15);
    color: #6c8aff;
    font-weight: 600;
}

// --- Responsive ---
@media (max-width: 600px) {
    [data-sb] input,
    [data-sb] select,
    [data-sb] textarea {
        font-size: 14px;
        padding: 8px;
    }

    [data-sb] .sb-btn {
        font-size: 13px;
        padding: 8px 12px;
    }

    [data-sb] .sb-btn-sm {
        font-size: 12px;
        padding: 6px 10px;
    }

    [data-sb] .sb-step-btn {
        font-size: 12px;
        padding: 6px 10px;
    }

    [data-sb] .sb-row {
        gap: 6px;
        margin-bottom: 8px;
    }

    [data-sb] .sb-label {
        font-size: 12px;
        min-width: 50px;
    }

    [data-sb] .sb-section-header {
        font-size: 12px;
    }
}

// ─── Step Builder ───
.sb-wrapper {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 99997;
    display: flex;
    flex-direction: row-reverse;
}
.sb {
    width: 420px;
    height: 100vh;
    background: linear-gradient(170deg, #1e1e2e 0%, #161625 100%);
    color: #e0e4ec;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(255,255,255,0.06);
    box-shadow: -4px 0 24px rgba(0,0,0,0.4);
    outline: none;
    flex-shrink: 0;
}
.sb * { box-sizing: border-box; }

// Resize handle
.sb-resize { position: absolute; width: 6px; top: 0; bottom: 0; left: 0; cursor: ew-resize; z-index: 2; }
.sb-resize:hover { background: rgba(108,138,255,0.2); }

// Header
.sb-header { height: 44px; min-height: 44px; padding: 0 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid rgba(255,255,255,0.06); background: rgba(255,255,255,0.02); }
.sb-header-title { font-size: 14px; font-weight: 700; flex: 1; }
.sb-hbtn { background: none; border: 1px solid rgba(255,255,255,0.1); color: #aaa; border-radius: 6px; width: 28px; height: 28px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; transition: all 0.15s; }
.sb-hbtn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sb-hbtn--danger:hover { color: #e74c3c; border-color: #e74c3c; }

// Steps
.sb-steps { border-bottom: 1px solid rgba(255,255,255,0.06); padding: 8px 14px; flex-shrink: 0; }
.sb-steps-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.sb-steps-count { font-size: 11px; font-weight: 600; color: #7a7f8e; text-transform: uppercase; letter-spacing: 0.3px; }
.sb-steps-list { max-height: 200px; overflow-y: auto; }
.sb-step { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 6px; cursor: pointer; transition: background 0.15s; border: 1px solid transparent; }
.sb-step:hover { background: rgba(108,138,255,0.1); }
.sb-step--active { background: rgba(108,138,255,0.2); border-color: rgba(108,138,255,0.3); }
.sb-step-num { width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.sb-step--active .sb-step-num { background: #6c8aff; color: #fff; }
.sb-step-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #b0b4c0; font-size: 12px; }
.sb-step-icons { display: flex; gap: 3px; font-size: 11px; color: #7a7f8e; flex-shrink: 0; }
.sb-step-actions { display: flex; gap: 4px; margin-top: 6px; }

// Detail zone
.sb-detail { flex: 1; overflow-y: auto; padding: 8px 14px; }
.sb-detail::-webkit-scrollbar { width: 5px; }
.sb-detail::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

// Cards
.sb-card { background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.06); border-radius: 8px; margin-bottom: 6px; overflow: hidden; }
.sb-card--open { background: rgba(255,255,255,0.04); }
.sb-card-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; cursor: pointer; user-select: none; font-size: 11px; font-weight: 600; color: #6c8aff; text-transform: uppercase; letter-spacing: 0.3px; }
.sb-card-head:hover { background: rgba(255,255,255,0.03); }
.sb-chevron { font-size: 10px; color: #555; }
.sb-card-body { padding: 8px 12px 12px; }

// Inputs
.sb-input { background: rgba(255,255,255,0.06); color: #e0e4ec; border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; padding: 7px 10px; font-size: 13px; font-family: inherit; outline: none; width: 100%; transition: border-color 0.2s; }
.sb-input:focus { border-color: #6c8aff; box-shadow: 0 0 0 2px rgba(108,138,255,0.15); }
.sb-input--num { width: 72px; }
.sb-input--sm { width: auto; min-width: 80px; }
.sb-textarea { resize: vertical; min-height: 60px; font-family: "Fira Code", monospace; font-size: 12px; }
select.sb-input { cursor: pointer; appearance: none; padding-right: 24px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }

// Labels, rows
.sb-lbl { font-size: 11px; color: #7a7f8e; min-width: 50px; flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; display: block; }
.sb-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.sb-row--pick .sb-input { flex: 1; }
.sb-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: #b0b4c0; cursor: pointer; margin-right: 12px; }
.sb-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: #6c8aff; cursor: pointer; }

// Pick button
.sb-pick { background: rgba(108,138,255,0.15); color: #6c8aff; border: 1px solid rgba(108,138,255,0.3); border-radius: 6px; padding: 6px 10px; font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.15s; }
.sb-pick:hover { background: rgba(108,138,255,0.25); }
.sb-pick--danger { background: rgba(231,76,60,0.15); color: #e74c3c; border-color: rgba(231,76,60,0.3); }
.sb-pick--danger:hover { background: rgba(231,76,60,0.25); }

// Buttons
.sb-btn { border: none; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; padding: 6px 12px; transition: all 0.15s; font-family: inherit; white-space: nowrap; }
.sb-btn:hover { filter: brightness(1.15); }
.sb-btn-sm { padding: 4px 8px; font-size: 11px; }
.sb-btn-green { background: #2ecc71; color: #fff; }
.sb-btn-ghost { background: rgba(255,255,255,0.06); color: #ccc; border: 1px solid rgba(255,255,255,0.1); }
.sb-btn-ghost:hover { background: rgba(255,255,255,0.12); }

// Options row
.sb-opt-row { display: flex; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.sb-opt-row .sb-input { flex: 1; }

// Code output
.sb-code { background: rgba(0,0,0,0.3); color: #8bc78b; padding: 10px 12px; border-radius: 6px; font-family: "Fira Code", monospace; font-size: 10px; line-height: 1.6; overflow: auto; max-height: 200px; white-space: pre-wrap; border: 1px solid rgba(255,255,255,0.04); }

// Undo/Redo buttons
.sb-hbtn:disabled { opacity: 0.3; cursor: default; }
.sb-hbtn:disabled:hover { background: none; color: #aaa; }

// History drawer
.sb-history-drawer { width: 0; height: 100vh; background: linear-gradient(170deg, #1e1e2e, #161625); border-right: 1px solid rgba(255,255,255,0.08); transition: width 0.25s ease; overflow: hidden; flex-shrink: 0; }
.sb-history-drawer--open { width: 240px; overflow-y: auto; }
.sb-history-header { padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 12px; font-weight: 600; color: #6c8aff; }
.sb-history-list { padding: 6px; }
.sb-history-item { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 11px; color: #b0b4c0; transition: background 0.15s; }
.sb-history-item:hover { background: rgba(108,138,255,0.1); }
.sb-history-item--current { color: #6c8aff; font-weight: 600; cursor: default; }
.sb-history-item--current::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #6c8aff; flex-shrink: 0; }
.sb-history-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-history-time { font-size: 9px; color: #7a7f8e; flex-shrink: 0; }

// Drag & Drop
.sb-step--drag-over { border-color: #6c8aff; background: rgba(108,138,255,0.15); }

// Context menu
.sb-context-menu { position: fixed; z-index: 100010; background: linear-gradient(170deg, #2a2a3d, #1e1e2e); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 4px; min-width: 160px; box-shadow: 0 8px 30px rgba(0,0,0,0.5); font-size: 12px; }
.sb-ctx-item { padding: 6px 12px; border-radius: 6px; cursor: pointer; color: #b0b4c0; transition: background 0.1s; }
.sb-ctx-item:hover { background: rgba(255,255,255,0.06); }
.sb-ctx-item--green { color: #2ecc71; }
.sb-ctx-item--red { color: #e74c3c; }
.sb-ctx-item--disabled { opacity: 0.3; pointer-events: none; }
.sb-ctx-sep { height: 1px; background: rgba(255,255,255,0.06); margin: 3px 8px; }

// Branch tabs
.sb-branch-tabs { display: flex; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; }
.sb-branch-tab { font-size: 10px; padding: 2px 8px; border-radius: 4px; cursor: pointer; color: #7a7f8e; border-bottom: 2px solid transparent; transition: all 0.15s; }
.sb-branch-tab:hover { color: #e0e4ec; }
.sb-branch-tab--active { color: #e0e4ec; background: rgba(255,255,255,0.06); }

// Branch bar on step items
.sb-step-branch-bar { width: 3px; height: 18px; border-radius: 2px; flex-shrink: 0; }

// Modified dot
.sb-step-modified { color: #f1c40f; font-size: 8px; }

// Waypoint rows
.sb-wp-row { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }

// Anchor badge
.sb-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-family: "Fira Code", monospace; background: rgba(108,138,255,0.15); color: #6c8aff; }

// Color input
.sb-color-input { width: 36px; height: 36px; border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; padding: 2px; cursor: pointer; background: transparent; }

@media (max-width: 600px) {
    .sb { width: 100vw; }
}

// ─── Timeline ───
.sb-timeline { border-top: 1px solid rgba(255,255,255,0.06); flex-shrink: 0; padding: 6px 14px; }
.sb-timeline-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sb-timeline-strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; }
.sb-timeline-strip::-webkit-scrollbar { height: 4px; }
.sb-timeline-strip::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.sb-timeline-thumb { position: relative; width: 70px; height: 52px; border-radius: 6px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); cursor: pointer; overflow: hidden; flex-shrink: 0; }
.sb-timeline-thumb.sb-active { border-color: #6c8aff; }
.sb-timeline-thumb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.5; }
.sb-timeline-thumb-num { position: absolute; top: 2px; left: 4px; font-size: 9px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.sb-timeline-capture { position: absolute; bottom: 2px; right: 2px; font-size: 10px; background: none; border: none; cursor: pointer; opacity: 0; transition: opacity 0.15s; padding: 2px; color: #ccc; }
.sb-timeline-thumb:hover .sb-timeline-capture { opacity: 0.7; }
.sb-timeline-thumb-icons { position: absolute; bottom: 2px; left: 4px; display: flex; gap: 2px; font-size: 9px; color: #7a7f8e; }
.sb-timeline-modified { position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: #f1c40f; }

// ─── Path Preview ───
.sb-path-preview { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 99996; }

// ─── Graph View ───
.sb-graph-modal { position: fixed; inset: 0; z-index: 100000; background: rgba(10,10,20,0.92); backdrop-filter: blur(6px); display: flex; flex-direction: column; font-family: system-ui, -apple-system, sans-serif; outline: none; }
.sb-graph-header { display: flex; align-items: center; padding: 12px 20px; border-bottom: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; }
.sb-graph-title { font-size: 16px; font-weight: 700; color: #e0e4ec; flex: 1; }
.sb-graph-container { flex: 1; overflow: auto; position: relative; }
.sb-graph-arrows { position: absolute; top: 0; left: 0; pointer-events: none; }
.sb-graph-node { position: absolute; width: 160px; height: 72px; border-radius: 8px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); cursor: pointer; display: flex; flex-direction: column; justify-content: center; padding: 8px 10px 8px 16px; transition: all 0.15s; overflow: hidden; }
.sb-graph-node:hover { background: rgba(108,138,255,0.1); border-color: rgba(108,138,255,0.3); }
.sb-graph-node--active { background: rgba(108,138,255,0.2); border-color: #6c8aff; }
.sb-graph-node-branch { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.sb-graph-node-num { font-size: 10px; font-weight: 700; color: #6c8aff; }
.sb-graph-node-text { font-size: 11px; color: #b0b4c0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-graph-node-icons { font-size: 10px; color: #7a7f8e; display: flex; gap: 3px; }
