body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

.playground-canvas {
    min-height: calc(100vh - 160px);
    height: calc(100vh - 160px);
    background-color: #181a1d;
    background-image: radial-gradient(#3d4147 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: auto;
    cursor: grab;
}

.playground-canvas.is-panning {
    cursor: grabbing;
}

.playground-canvas.is-initializing .playground-world {
    visibility: hidden;
}

.playground-canvas.playground-drag-over {
    outline: 2px dashed #0dcaf0;
    outline-offset: -4px;
    background-color: #1f2328;
}

.playground-upload-progress {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 420px;
    max-width: calc(100% - 40px);
    z-index: 100;
    background: #212529;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #0dcaf0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.playground-upload-name {
    display: inline-block;
    max-width: 140px;
    font-size: 0.85rem;
}

.playground-world {
    position: relative;
    transform-origin: 0 0;
}

.playground-canvas-space {
    width: 100%;
    height: 100%;
}

.playground-builder-text-file-preview {
    overflow: hidden;
    padding: 6px;
    border: 1px solid rgba(107, 114, 128, 0.45);
    border-radius: 5px;
    background: rgba(13, 17, 23, 0.55);
}

.playground-text-file-content {
    height: calc(100% - 22px);
    margin: 0;
    overflow: auto;
    color: #e5e7eb;
    font: 11px/1.4 monospace;
    white-space: pre-wrap;
    user-select: text;
}

.playground-builder-text-to-array {
    overflow: hidden;
    padding: 6px;
    border: 1px solid rgba(107, 114, 128, 0.45);
    border-radius: 5px;
    background: rgba(13, 17, 23, 0.55);
}

.playground-text-array-preview {
    height: calc(100% - 104px);
    margin: 0;
    overflow: auto;
    color: #e5e7eb;
    font: 11px/1.4 monospace;
    white-space: pre-wrap;
    user-select: text;
}

.playground-builder-iterator {
    overflow: hidden;
    padding: 6px;
    border: 1px solid rgba(107, 114, 128, 0.45);
    border-radius: 5px;
    background: rgba(13, 17, 23, 0.55);
}

.playground-iterator-preview {
    height: calc(100% - 58px);
    margin: 0;
    overflow: auto;
    color: #e5e7eb;
    font: 11px/1.4 monospace;
    white-space: pre-wrap;
    user-select: text;
}

.playground-edges {
    z-index: 0;
    pointer-events: none;
}

.playground-edge {
    fill: none;
    stroke: #ff5a36;
    stroke-width: 3;
    pointer-events: stroke;
    cursor: pointer;
}

.playground-edge:hover {
    stroke: #ffc107;
    stroke-width: 5;
}

.playground-edge-preview {
    fill: none;
    stroke: #ff8b72;
    stroke-width: 4;
    stroke-dasharray: 8 4;
    filter: drop-shadow(0 0 4px #ff8b72);
    pointer-events: none;
}

.playground-canvas-item {
    cursor: grab;
    user-select: none;
    touch-action: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.playground-port {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    padding: 0;
    border: 2px solid #ff5a36;
    border-radius: 50%;
    background: #181a1d;
    transform: translateY(-50%);
    z-index: 3;
    cursor: crosshair;
}

.playground-port:hover {
    background: #ff5a36;
    transform: translateY(-50%) scale(1.4);
}

.playground-input-port-row {
    position: absolute;
    left: -27px;
    height: 22px;
    z-index: 4;
}

.playground-input-port-row .playground-input-port {
    left: 0;
}

.playground-port-label {
    position: absolute;
    right: 0;
    top: calc(50% + 13px);
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(24, 26, 29, 0.88);
    color: #ffb09e;
    font-size: 11px;
    white-space: nowrap;
    transform: translateY(-50%);
    pointer-events: none;
}

.playground-input-port {
    left: -27px;
}

.playground-builder-gen-picker {
    z-index: 30;
}

.playground-builder-gen-picker .playground-gen-picker-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 6px;
    padding: 8px;
    border: 1px solid #0dcaf0;
    border-radius: 12px;
    background: #1b1d22;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    z-index: 40;
}

.playground-builder-gen-picker .playground-gen-picker-info {
    position: absolute;
    top: 0;
    left: calc(100% + 16px);
    width: 240px;
    padding: 10px;
    border: 1px solid #0dcaf0;
    border-radius: 12px;
    background: #1b1d22;
    color: #e5e7eb;
    font-size: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    z-index: 41;
}

.playground-gen-picker-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    cursor: pointer;
}

.playground-gen-picker-row:hover {
    background: rgba(13, 202, 240, 0.08);
}

.playground-gen-picker-row.is-selected {
    outline: 1px solid #0dcaf0;
    background: rgba(13, 202, 240, 0.12);
}

.playground-gen-picker-row .playground-gen-picker-meta {
    color: #9ca3af;
    font-size: 11px;
}

.playground-gen-picker-row .playground-gen-picker-badge {
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 4px;
    background: #0d6efd;
    color: #fff;
    font-size: 10px;
}

.playground-gen-picker-row .playground-gen-picker-star {
    color: #6b7280;
    margin-left: auto;
}

.playground-builder-input-label[data-label-side="left"] {
    width: 0 !important;
    overflow: visible !important;
}

.playground-output-port {
    right: -27px;
}

.playground-node-duplicate {
    position: absolute;
    top: 2px;
    right: 24px;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #adb5bd;
    font-size: 13px;
    line-height: 16px;
    z-index: 5;
    cursor: pointer;
}

.playground-node-duplicate:hover {
    color: #0dcaf0;
    background: rgba(255, 255, 255, 0.08);
}

.playground-canvas-item.is-dragging {
    cursor: grabbing;
    z-index: 10;
}

.playground-node {
    width: 280px;
    min-height: 120px;
}

.playground-prompt-node {
    width: 240px;
    min-height: 120px;
}

.playground-builder-node {
    box-sizing: border-box;
    min-height: 120px;
    overflow: visible;
    border-width: 2px !important;
    border-radius: 16px;
    background: #191b1f !important;
}

.playground-builder-node .card-body {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: clip;
    overflow-clip-margin: 30px;
}

.playground-builder-node .playground-node-card-body-external-ports {
    overflow: visible;
}

.playground-node-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 42px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 2;
    pointer-events: none;
}

.playground-node-title {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: auto;
}

.playground-node-body {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 42px 0 32px 0;
    overflow: clip;
    overflow-clip-margin: 30px;
}

.playground-node-body-external-ports {
    overflow: visible;
}

.playground-node-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 2;
    pointer-events: none;
}

.playground-builder-component {
    position: absolute;
}

.playground-builder-header {
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: #f1f2f4;
}

.playground-builder-textarea textarea,
.playground-builder-text-input textarea {
    width: 100%;
    height: 100%;
    padding: 9px;
    resize: vertical;
    border: 1px solid #6c757d;
    border-radius: 5px;
    color: #f1f2f4;
    background: #292929;
}

.playground-builder-output-label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    color: #9aa6b5;
    font-size: .72rem;
}

.playground-prompt-preview {
    max-height: 90px;
    overflow: hidden;
    white-space: pre-wrap;
}

.playground-node .form-select {
    min-width: 0;
}

.playground-inspector {
    position: fixed;
    top: 0;
    right: 0;
    width: min(440px, 100vw);
    height: 100vh;
    z-index: 1050;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.45);
}

.playground-inspector.is-open {
    transform: translateX(0);
}

.playground-inspector-body {
    height: calc(100vh - 73px);
    overflow-y: auto;
}

.playground-canvas-item.is-selected {
    outline: 2px solid #0dcaf0;
    outline-offset: 3px;
}

.playground-canvas-marquee {
    position: absolute;
    border: 1px solid #0dcaf0;
    background: rgba(13, 202, 240, 0.12);
    pointer-events: none;
    z-index: 90;
}

.playground-node .card-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.playground-node-output {
    position: relative;
}

.playground-output-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    z-index: 5;
    cursor: pointer;
}

.playground-output-nav:hover {
    background: rgba(0, 0, 0, 0.8);
}

.playground-output-prev {
    left: 4px;
}

.playground-output-next {
    right: 4px;
}

.playground-output-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 13px;
    line-height: 18px;
    text-align: center;
    z-index: 6;
    cursor: pointer;
}

.playground-output-delete:hover {
    background: #dc3545;
}

.playground-provenance-toggle {
    position: absolute;
    top: 2px;
    right: 46px;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #0dcaf0;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    z-index: 6;
    cursor: pointer;
}

.playground-provenance-toggle svg {
    display: block;
    margin: 2px auto 0;
}

.playground-provenance-toggle.is-off {
    color: #6c757d;
}

.playground-model-picker {
    position: relative;
    display: flex;
    gap: 4px;
    align-items: flex-start;
}

.playground-model-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 30;
    padding: 6px;
    background: #1f2124;
    border: 1px solid #454b52;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.playground-model-list {
    max-height: 260px;
    overflow-y: auto;
}

.playground-model-item {
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playground-model-item:hover {
    background: rgba(13, 202, 240, 0.15);
}

.playground-model-item.is-active {
    background: rgba(13, 202, 240, 0.3);
}

.playground-file-input {
    width: 240px;
}

.playground-file-node {
    width: 180px;
    min-height: 190px;
    z-index: 1;
}



.playground-file-preview,
.playground-file-placeholder,
.playground-model-preview {
    display: block;
    width: 100%;
    height: 110px;
    object-fit: cover;
    background: #111;
}

.playground-model-preview {
    cursor: grab;
    touch-action: none;
}

.playground-model-preview:active {
    cursor: grabbing;
}

.playground-model-preview-inspector {
    height: 360px;
}

.playground-export-img-thumb {
    width: 64px;
    height: 64px;
    padding: 2px;
    border: 2px solid #495057;
    border-radius: 4px;
    background: #111;
}

.playground-export-img-thumb:hover,
.playground-export-img-thumb.is-selected {
    border-color: #0dcaf0;
}

.playground-export-img-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.playground-file-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
}

.queue-json {
    max-height: 420px;
    overflow: auto;
    white-space: pre-wrap;
    color: #d7e3f4;
}

.navbar-brand {
    letter-spacing: 0.5px;
}

.card {
    border: none;
    border-radius: 12px;
}

.btn-danger {
    background-color: #ff0000;
    border-color: #ff0000;
}

.btn-danger:hover {
    background-color: #cc0000;
    border-color: #cc0000;
}

/* Stage 9D color palette indicators */
.palette-border-blue { border-color: #4a9eff !important; }
.palette-text-blue { color: #4a9eff !important; }
.palette-border-green { border-color: #2ecc71 !important; }
.palette-text-green { color: #2ecc71 !important; }
.palette-border-gold { border-color: #f1c40f !important; }
.palette-text-gold { color: #f1c40f !important; }
.palette-border-purple { border-color: #9b59b6 !important; }
.palette-text-purple { color: #9b59b6 !important; }
.palette-border-red { border-color: #e74c3c !important; }
.palette-text-red { color: #e74c3c !important; }
.palette-border-orange { border-color: #e67e22 !important; }
.palette-text-orange { color: #e67e22 !important; }
.palette-border-silver { border-color: #bdc3c7 !important; }
.palette-text-silver { color: #bdc3c7 !important; }

/* Stage 9D start frame preview border states */
.sf-preview-has-start { border: 2px solid #198754 !important; }
.sf-preview-no-start { border: 2px solid #555 !important; }

/* Stage 9D gallery thumb states */
.sf-thumb-selected { border: 2px solid #0d6efd !important; }
.sf-thumb-unselected { border: 2px solid transparent !important; }
.sf-thumb-none-selected { border: 2px solid #198754 !important; }
.sf-thumb-none-unselected { border: 2px dashed #666 !important; }

.bg-secondary {
    background-color: #1f1f1f !important;
}

.text-muted {
    color: #aaaaaa !important;
}

.form-control, .form-select {
    background-color: #2a2a2a;
    border-color: #444;
    color: #fff;
}

.form-control:focus, .form-select:focus {
    background-color: #2a2a2a;
    border-color: #ff0000;
    color: #fff;
    box-shadow: 0 0 0 0.25rem rgba(255, 0, 0, 0.25);
}

.form-control::placeholder {
    color: #888;
}

.ai-model-tester .form-label {
    color: #f8f9fa;
    font-weight: 600;
}

.ai-model-tester .form-text {
    color: #bfc7d5;
}

.ai-model-tester .text-secondary {
    color: #adb5bd !important;
}

.playground-i2v-slots-pad {
    margin-top: 8px;
    padding: 6px;
    border: 1px solid rgba(220, 53, 69, 0.45);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.25);
}

.playground-i2v-slots {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
}

.playground-i2v-slot {
    position: relative;
    width: auto;
    aspect-ratio: 1 / 1;
    border: 1px dashed #6c757d;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.25);
    overflow: visible;
}

.playground-i2v-slot.is-filled {
    border-style: solid;
    border-color: #dc3545;
}

.playground-i2v-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
    display: block;
}

.playground-i2v-slot-num {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 11px;
    color: #ffb09e;
    text-shadow: 0 1px 2px #000;
    pointer-events: none;
}

.playground-i2v-slot.playground-input-port {
    cursor: crosshair;
}

.playground-i2v-slot.playground-input-port:hover {
    border-color: #ff5a36;
    border-style: solid;
}

.playground-i2v-slot-unlink {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #dc3545;
    color: #fff;
    font-size: 11px;
    line-height: 14px;
    z-index: 6;
    cursor: pointer;
}

.playground-i2v-slot-unlink:hover {
    background: #ff5a36;
}

.playground-edge-provenance {
    stroke: #0dcaf0;
    stroke-dasharray: 5 5;
    stroke-width: 1.5;
    pointer-events: none;
    opacity: 0.7;
}

.playground-multi-label-toggle {
    padding: 0 6px;
    border: 1px solid #6c757d;
    border-radius: 4px;
    background: transparent;
    color: #ffc107;
    font-size: 11px;
    line-height: 16px;
    cursor: pointer;
    vertical-align: baseline;
}

.playground-multi-label-toggle:hover {
    border-color: #ffc107;
}

.playground-multi-slot-text {
    width: 100%;
    height: 100%;
    padding: 14px 4px 2px;
    font-size: 9px;
    line-height: 1.2;
    color: #adb5bd;
    overflow: hidden;
    word-break: break-word;
}

.playground-i2v-slot.is-filled:has(.playground-multi-slot-text) {
    border-style: solid;
    border-color: #ffc107;
}



/* Playground V2 vertical sidebar with collapse */
.playground-v2-layout {
    overflow: hidden;
    height: calc(100vh - 56px);
}
.playground-v2-layout .playground-world {
    min-width: 1920px;
    min-height: 1080px;
}
.playground-v2-sidebar {
    width: 220px;
    min-width: 220px;
    background: transparent;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, min-width 0.2s ease;
    overflow: hidden;
}
.playground-v2-sidebar.collapsed {
    width: 44px;
    min-width: 44px;
}
.playground-v2-sidebar.collapsed .playground-v2-sidebar-project,
.playground-v2-sidebar.collapsed .playground-v2-sidebar-title,
.playground-v2-sidebar.collapsed .playground-v2-sidebar-body {
    display: none;
}
.playground-v2-sidebar.collapsed .playground-v2-sidebar-toggle .playground-v2-toggle-text {
    display: none;
}
.playground-v2-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
}
.playground-v2-sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #adb5bd;
}
.playground-v2-sidebar-toggle {
    padding: 2px 6px;
    line-height: 1;
}
.playground-v2-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}
.playground-v2-sidebar-section + .playground-v2-sidebar-section {
    margin-top: 14px;
}
.playground-v2-sidebar-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 8px;
}
.playground-v2-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.playground-v2-main .playground-canvas {
    flex: 1;
    height: 100%;
    min-height: 0;
}
.playground-canvas-zoom-controls {
    position: absolute;
    right: 18px;
    bottom: 18px;
    z-index: 5000;
    display: flex;
    overflow: hidden;
    border: 1px solid #495057;
    border-radius: 6px;
    background: #212529;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.playground-canvas-zoom-controls button {
    min-width: 34px;
    height: 32px;
    border: 0;
    border-right: 1px solid #495057;
    background: transparent;
    color: #f8f9fa;
}
.playground-canvas-zoom-controls button:last-child {
    border-right: 0;
}
.playground-canvas-zoom-controls button:hover {
    background: #343a40;
}
.playground-canvas-zoom-controls .playground-canvas-zoom-label {
    min-width: 58px;
    font-size: 0.8rem;
}
.playground-canvas-history-row {
    display: flex;
    gap: 8px;
    padding: 3px 10px;
    line-height: 1.4;
}
.playground-canvas-history-time {
    color: #868e96;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.playground-canvas-history-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.playground-builder-project-history {
    position: absolute;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 6px;
    border: 1px solid #495057;
    border-radius: 4px;
    background: #212529;
    color: #dee2e6;
    font-size: 0.75rem;
}
.playground-project-history-title {
    flex: 0 0 auto;
    margin-bottom: 4px;
    color: #f8f9fa;
    font-weight: 600;
}
.playground-project-history-list {
    min-height: 0;
    overflow-y: auto;
}

/* Edge Value Delivery — port flash animation */
@keyframes pg2-port-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    50%  { box-shadow: 0 0 8px 4px rgba(34, 197, 94, 0.4); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.pg2-port-flash {
    animation: pg2-port-pulse 0.6s ease-out 2;
    border-color: #22c55e !important;
    background: #22c55e !important;
}
.pg2-port-value {
    display: block;
    font-size: 10px;
    color: #9ca3af;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pg2-received-badge {
    font-size: 9px;
    color: #22c55e;
    margin-left: 4px;
}

.pg2-context-menu {
    position: fixed;
    z-index: 5000;
    min-width: 220px;
    padding: 6px;
    border: 1px solid #4b5563;
    border-radius: 6px;
    background: #20252b;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
}
.pg2-context-menu button {
    padding: 9px 14px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #e5e7eb;
    text-align: left;
    font-size: 16px;
}
.pg2-context-menu button:hover:not(:disabled) { background: #2f3640; }
.pg2-context-menu button:disabled { color: #6b7280; cursor: not-allowed; }
