* {
    box-sizing: border-box;
}

/* Global Scrollbar Styling (Firefox) */
* {
    scrollbar-width: auto;
    scrollbar-color: #44475a #1e1e24;
}

/* Global Scrollbar Styling (Chromium) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #1e1e24;
}

::-webkit-scrollbar-thumb {
    background: #44475a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6272a4;
}

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    /* Modern viewport height for mobile */
    font-family: 'Segoe UI', system-ui;
    background: #121212;
    color: #ececec;
    overflow: hidden;
    position: fixed;
    /* Verhindert das Scrollen des gesamten Bodys auf Mobilgeräten */
    width: 100%;
    user-select: none;
}

/* Re-enable text selection where it makes sense */
.CodeMirror,
.CodeMirror *,
#panel-inspector,
#panel-inspector *,
input[type="text"],
input[type="number"],
input:not([type="range"]):not([type="checkbox"]),
textarea,
[contenteditable],
.node-input,
.color-picker-section,
.variable-value,
.runtime-var-value {
    user-select: text;
}

/* Global Header */

#global-header {
    background: #1e1e24;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
    z-index: 100;
    flex-shrink: 0;
}

.header-logo-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    position: relative;
    /* Für den Glow-Effekt */
}

.header-logo-container::before {
    content: "";
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    /* Grösser als das Logo (32px) für mehr Ausstrahlung */
    height: 40px;
    background-image: url('../Icon.png');
    background-size: contain;
    background-repeat: no-repeat;
    filter: blur(7px) brightness(1.4) saturate(1.8);
    /* Stärkerer Blur und Leuchtkraft */
    opacity: 0.9;
    z-index: 0;
    pointer-events: none;
}

.header-logo-img {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    /* Über dem Glow */
}

.header-text-group {
    display: flex;
    flex-direction: column;
    /* Stapelt Headline und Subheadline wieder untereinander */
    justify-content: center;
}

.header-logo {
    font-weight: bold;
    font-size: 18px;
    color: #bd93f9;
    line-height: 1.1;
}

.header-subheadline {
    font-size: 10px;
    color: #888;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.playback-controls {
    display: flex;
    width: auto;
    min-width: 120px;
    gap: 8px;
}

.btn-header-icon {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    padding: 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    position: relative;
}

.btn-header-icon:hover {
    color: #fff;
    background: #333;
}

#btn-language {
    min-width: 62px;
}

#btn-validate {
    min-width: 140px;
}

#notif-badge {
    display: none;
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff5555;
    color: white;
    border-radius: 50%;
    padding: 1px 5px;
    font-size: 9px;
    font-weight: bold;
    line-height: 1.2;
}

/* Buttons & Inputs */
button {
    font-family: inherit;
}

.btn-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 4px 16px;
    min-width: 128px;
    height: 34px;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
    font-family: inherit;
    color: #282a36;
}

.btn-primary {
    background: #8be9fd;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-secondary {
    background: transparent;
    color: #fff;
    border: 0px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-start {
    background: #50fa7b;
}

.btn-pause-style {
    background: #f1fa8c !important;
}

.btn-reset-style {
    background: #7f90ff !important;
}

.btn-stop-style {
    background: #ff5555 !important;
}

.btn-disabled {
    background: #444 !important;
    color: #888 !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}

#toggle-btn,
#pause-btn,
#stop-btn {
    flex: 1;
}

.close-btn {
    background: none;
    border: none;
    color: #888;
    /* helles Grau */
    font-size: 18px;
    /* größerer Pfeil */
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    /* verhindert zusätzliche Lücke */
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.close-btn:hover {
    background: #ff5555;
    /* dezenter roten Hover-Effekt */
    color: white;
}

/* Main Container (Desktop Grid) */
#app-container {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 350px 8px 1fr 8px 320px;
    overflow: hidden;
    position: relative;
}

.resizer {
    background: transparent;
    width: 8px;
    cursor: col-resize;
    z-index: 20;
    display: flex;
    justify-content: center;
    position: relative;
}

.resizer::before {
    content: '';
    width: 2px;
    height: 100%;
    background: #333;
    transition: background 0.2s;
}

.resizer:hover::before,
.resizer.dragging::before {
    background: #bd93f9;
}

/* Panels */
.panel {
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    height: 100%;
    overflow: hidden;
    min-width: 0;
    /* Ermöglicht das Schrumpfen unter die Inhaltsgröße */
}

.panel:last-child {
    border-right: none;
}

.panel-header {
    background: #282a36;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    height: 40px;
    flex-shrink: 0;
    min-width: 0;
    /* Verhindert das Rausdrücken des Headers */
}

.panel-title {
    font-weight: bold;
    font-size: 13px;
    color: #f8f8f2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}

.panel-tabs {
    display: flex;
    gap: 2px;
    height: 100%;
}

.panel-tab {
    padding: 0 14px;
    display: flex;
    align-items: center;
    font-size: 11px;
    color: #666;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    user-select: none;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-tab:hover {
    color: #aaa;
}

.panel-tab.active {
    color: #bd93f9;
    border-bottom-color: #bd93f9;
}

/* Editor View Switching */
.editor-view {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.editor-view.active {
    display: block;
}

/* Node Editor Container */
#node-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    padding: 0;
    background: #141418;
    cursor: default;
    user-select: none;
    touch-action: none;
}

#node-container.panning {
    cursor: grabbing;
}

#node-canvas {
    transform-origin: 0 0;
    will-change: transform;
    display: inline-flex;
    padding: 30px 20px 80px 20px;
}

#node-zoom-toolbar {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(20, 20, 24, 0.92);
    border: 1px solid #333;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 12px;
    z-index: 10;
    pointer-events: all;
}

#node-zoom-toolbar button {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 3px;
}

#node-zoom-toolbar button:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

#node-zoom-label {
    color: #ccc;
    min-width: 38px;
    text-align: center;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
}

#node-zoom-label:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

/* Node Graph */
.node-graph {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-width: 300px;
}

/* Sequence — vertical list of steps */
.node-sequence {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

/* Step wrapper — holds a node + connector */
.step-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Vertical connector between steps */
.step-connector {
    width: 2px;
    height: 20px;
    background: #44475a;
    flex-shrink: 0;
}

/* Node card */
.node-item,
.node-item-container {
    background: #21222c;
    border: 1px solid #44475a;
    border-radius: 8px;
    width: fit-content;
    min-width: 280px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.node-item-container.node-type-parallel {
    min-width: 320px;
}

.node-item:hover,
.node-item-container:hover {
    border-color: #6272a4;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.node-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px;
    border-radius: 7px 7px 0 0;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #f8f8f2;
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

.node-header-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.node-header-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-breakpoint {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
}

.btn-breakpoint:hover,
.btn-breakpoint.bp-active {
    opacity: 1;
}

.node-header-bp-spacer {
    display: inline-block;
    width: 14px;
    flex-shrink: 0;
}

.node-actions-sep {
    display: inline-block;
    width: 1px;
    height: 10px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 2px;
    align-self: center;
    flex-shrink: 0;
}

.node-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.node-header-icon svg {
    display: block;
}

.node-header-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}

.node-item:hover .node-header-actions {
    opacity: 1;
}

.node-header-actions button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 13px;
    line-height: 1;
}

.node-header-actions button:hover {
    color: #333;
    background: rgba(255, 255, 255, 0.3);
}

.node-header-actions .btn-entity-header-delete {
    color: #de1414aa;
}

.node-header-actions .btn-entity-header-delete:hover {
    background-color: #de1414aa;
    color: white;
}

.node-header-actions .btn-wrap {
    color: #888;
    font-size: 11px;
}

.node-header-actions .btn-wrap:hover {
    color: #bd93f9;
    background: rgba(189, 147, 249, 0.15);
}

.node-header-actions .btn-unwrap {
    color: #888;
    font-size: 11px;
}

.node-header-actions .btn-unwrap:hover {
    color: #ff79c6;
    background: rgba(255, 121, 198, 0.15);
}

.node-body {
    padding: 10px;
    font-size: 11px;
    color: #ccc;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Node type colors — direct child selector prevents color leaking into nested nodes */
.node-type-action>.node-header {
    background: #6272a4;
}

.node-type-delay>.node-header {
    background: #e6ac00;
    color: #1a1a1a;
}

.node-type-parallel>.node-header {
    background: #ff79c6;
}

.node-type-repeat>.node-header {
    background: #50fa7b;
    color: #1a1a1a;
}

.node-type-choose>.node-header {
    background: #8be9fd;
    color: #1a1a1a;
}

.node-type-if>.node-header {
    background: #ffb86c;
    color: #1a1a1a;
}

.node-type-wait>.node-header {
    background: #bd93f9;
}

.node-type-variables>.node-header {
    background: #44475a;
}

.node-type-header>.node-header {
    background: #282a36;
    border-bottom: 1px solid #6272a4;
}

/* Node form fields */
.node-field {
    display: flex;
    align-items: center;
    gap: 6px;
}

.node-field-label {
    font-size: 10px;
    color: #888;
    min-width: 55px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.node-input {
    width: 100%;
    background: #191a21;
    border: 1px solid #44475a;
    color: #8be9fd;
    font-size: 11px;
    padding: 4px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    outline: none;
    transition: border-color 0.2s;
}

.node-input:focus {
    border-color: #bd93f9;
}

.node-select {
    width: 100%;
    background: #191a21;
    border: 1px solid #44475a;
    color: #8be9fd;
    font-size: 11px;
    padding: 4px 6px;
    border-radius: 4px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.node-select:focus {
    border-color: #bd93f9;
}

/* Data fields (key-value pairs) */
.node-data-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

.node-data-row .node-input {
    flex: 1;
}

.node-data-row .node-input-key {
    flex: 0.6;
    color: #ffb86c;
}

.node-data-row .btn-remove-field {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    line-height: 1;
}

.node-data-row .btn-remove-field:hover {
    color: #ff5555;
}

.btn-add-field {
    background: none;
    border: 1px dashed #44475a;
    color: #666;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    transition: 0.2s;
    width: 100%;
    text-align: center;
}

.btn-add-field:hover {
    border-color: #6272a4;
    color: #aaa;
}

/* Parallel / Choose branches */
.node-branches {
    display: flex;
    gap: 16px;
    padding: 10px;
    justify-content: center;
    width: max-content;
    min-height: 50px;
}

.node-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-width: 300px;
    /* Give branches enough space for nodes */
    position: relative;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding: 8px 4px;
}

.node-branch-label {
    font-size: 9px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    padding: 2px 8px;
    background: #282a36;
    border-radius: 3px;
    border: 1px solid #44475a;
}

/* Add-step button (between steps) */
.node-add-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #282a36;
    border: 1px dashed #44475a;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    line-height: 1;
}

.node-add-btn:hover {
    border-color: #50fa7b;
    color: #50fa7b;
    background: #1a2e1a;
}

/* Add step dropdown menu – rendered on document.body, smart-positioned via JS */
.node-add-menu {
    position: fixed;
    background: #282a36;
    border: 1px solid #44475a;
    border-radius: 6px;
    padding: 4px 0;
    z-index: 9999;
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    display: none;
}

.node-add-menu.open {
    display: block;
}

.node-add-menu-item {
    padding: 6px 12px;
    font-size: 11px;
    color: #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.node-add-menu-item:hover {
    background: #44475a;
    color: #fff;
}

.node-add-menu-title {
    padding: 4px 12px 2px;
    font-size: 9px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid #383a47;
    margin-bottom: 2px;
}

.node-add-menu-item .menu-icon {
    width: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Empty state */
.node-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #555;
    gap: 12px;
    font-size: 13px;
}

.node-empty .node-add-btn {
    width: 40px;
    height: 40px;
    font-size: 20px;
}

/* Section divider inside nodes */
.node-section-label {
    font-size: 9px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-top: 4px;
    border-top: 1px solid #333;
    margin-top: 2px;
}

.panel-content {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent parent scrolling from fighting with child editors */
}

.panel-content.scrollable {
    overflow-y: auto;
    overflow-x: hidden;
}

.editor-actions {
    display: flex;
    gap: 2px;
    align-items: center;
}

.btn-editor-icon {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    display: flex;
    align-items: center;
}

.btn-editor-icon:hover {
    color: #f8f8f2;
    background: #444;
}

.panel-tools {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Editor Specific */
.CodeMirror {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    width: 100%;
    font-size: 13px;
    z-index: 5;
    /* Increased from 1 */
    /* Ensure Firefox shows scrollbars on dark background */
    scrollbar-color: #44475a #1e1e24;
    scrollbar-width: thin;
}

.CodeMirror textarea {
    overflow: hidden !important;
}

/* Force CodeMirror scrollbars to be visible and interactive */
.CodeMirror-vscrollbar,
.CodeMirror-hscrollbar {
    z-index: 10 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.CodeMirror.disabled-dim {
    opacity: 0.95;
    filter: none;
    transition: opacity 0.3s ease;
}

/* Gutter & Breakpoint Column Styling */
.CodeMirror-gutters {
    background-color: #21222c !important;
    /* Etwas dunkler als Dracula bg #282a36 */
    border-right: 1px solid #44475a !important;
    min-width: 50px;
}

.CodeMirror-gutter.breakpoints {
    width: 24px;
    background: rgba(255, 255, 255, 0.02);
}

.CodeMirror-linenumber {
    min-width: 25px !important;
    text-align: right;
    color: #6272a4 !important;
    padding-right: 10px !important;
}

.CodeMirror-activeline-gutter {
    background: rgba(68, 71, 90, 0.4) !important;
}

/* Preview Specific */
#room {
    flex-grow: 1;
    background: #111114;
    position: relative;
    overflow: hidden;
    cursor: default;
    user-select: none;
    touch-action: none;
}

#room.panning {
    cursor: grabbing;
}

#simulation-room {
    position: absolute;
    top: 0;
    left: 0;
    width: 800px;
    height: 800px;
    transform-origin: 0 0;
    will-change: transform;
}

#simulation-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#sim-zoom-toolbar {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(20, 20, 24, 0.92);
    border: 1px solid #333;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 12px;
    z-index: 10;
    pointer-events: all;
}

#sim-zoom-toolbar button {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 3px;
}

#sim-zoom-toolbar button:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

#sim-zoom-label {
    color: #ccc;
    min-width: 38px;
    text-align: center;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
}

#sim-zoom-label:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.dropdown-small {
    background: #1e1e24;
    color: #fff;
    border: 1px solid #444;
    padding: 2px 5px;
    font-size: 11px;
    border-radius: 3px;
}

/* Inspector Specific */
.inspector-section {
    border-bottom: 1px solid #444;
    display: flex;
    flex-direction: column;
}

.section-title {
    padding: 8px 15px;
    background: #21222c;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    color: #aaa;
    border-bottom: 1px solid #444;
}

/* Color Picker */
#color-tool {
    padding: 15px;
    background: #282a36;
}

/* ---- Inspector inline color picker (cp-* IDs) ---- */

.cp-sv-canvas {
    display: block;
    width: 100%;
    height: 150px;
    border-radius: 4px;
    cursor: crosshair;
    margin-bottom: 8px;
}

.cp-hue-canvas {
    display: block;
    width: 100%;
    height: 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 8px;
}

.cp-preview-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.cp-swatch-preview {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid #555;
    flex-shrink: 0;
}

.cp-hex-input {
    flex: 1;
    background: #1e1e24;
    border: 1px solid #555;
    color: #f8f8f2;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 12px;
    font-family: monospace;
    width: 100%;
}

.cp-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
}

.cp-tab {
    flex: 1;
    padding: 4px;
    background: #1e1e24;
    border: 1px solid #444;
    color: #aaa;
    font-size: 11px;
    text-align: center;
    cursor: pointer;
    border-radius: 4px;
}

.cp-tab.active {
    background: #bd93f9;
    color: #282a36;
    border-color: #bd93f9;
    font-weight: bold;
}

.cp-input-group {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 4px 6px;
    align-items: center;
    margin-bottom: 8px;
}

.cp-section-label {
    font-size: 10px;
    color: #888;
    margin-bottom: 4px;
    margin-top: 4px;
}

.cp-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 8px;
}

.cp-swatch-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
    transition: transform 0.1s;
}

.cp-swatch-dot:hover { transform: scale(1.2); }

.cp-swatch-dot-replacing {
    transform: scale(1.35);
    box-shadow: 0 0 0 2px #bd93f9, 0 0 6px rgba(189, 147, 249, 0.5);
    position: relative;
    z-index: 1;
}

/* ---- Floating popup color picker ---- */

.cp-popup {
    position: fixed;
    z-index: 9999;
    background: #282a36;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 10px;
    width: 260px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    display: none;
}

.cp-popup .cp-tabs {
    margin-top: 8px;
    margin-bottom: 4px;
}

.cp-popup .cp-input-group {
    margin-bottom: 4px;
}

.cp-popup-sv {
    display: block;
    width: 100%;
    height: 150px;
    border-radius: 4px;
    cursor: crosshair;
    margin-bottom: 8px;
}

.cp-popup-hue {
    display: block;
    width: 100%;
    height: 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 8px;
}

.cp-popup-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.cp-popup-swatch-preview {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid #555;
    flex-shrink: 0;
}

.cp-popup-hex {
    flex: 1;
    background: #1e1e2e;
    border: 1px solid #555;
    color: #f8f8f2;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 12px;
    font-family: monospace;
    width: 100%;
}

.cp-popup-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
}

.cp-popup-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
    transition: transform 0.1s;
}

.cp-popup-dot:hover { transform: scale(1.2); }

/* ---- Color swatch triggers (replace native inputs) ---- */

.tl-color-swatch,
.node-color-swatch,
.cp-wall-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid #555;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s;
    display: inline-block;
}

.tl-color-swatch:hover,
.node-color-swatch:hover,
.cp-wall-swatch:hover { border-color: #bd93f9; }

.input-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

input[type="text"],
input[type="number"] {
    background: #1e1e24;
    border: 1px solid #555;
    color: #fff;
    padding: 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 11px;
    width: 100%;
}


label {
    font-size: 10px;
    color: #aaa;
    min-width: 25px;
}

.snippets-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.code-snippet {
    background: #1e1e24;
    padding: 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 10px;
    color: #bd93f9;
    cursor: pointer;
    border: 1px solid #444;
    text-align: center;
    transition: 0.2s;
}

.code-snippet:hover {
    background: #bd93f922;
}

.color-favorites {
    display: flex;
    gap: 5px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.favorite-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #fff;
    cursor: pointer;
}

.favorite-add {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px dashed #aaa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #aaa;
    background: none;
}

/* Entities */
.entity-list {
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.entity-item {
    background: #1e1e24;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #444;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    cursor: grab;
    transition: 0.2s;
}

.entity-item:active {
    cursor: grabbing;
}

.entity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.entity-body {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 10px;
    color: #aaa;
}

.entity-badge {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #666;
    display: inline-block;
    background: #222;
}

.entity-id {
    font-family: monospace;
    color: #8be9fd;
    flex-shrink: 1;
    min-width: 0;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.entity-info {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-width: 0;
}

.entity-actions {
    flex-shrink: 0;
}

.entity-actions button {
    background: none;
    color: #555;
    border: none;
    padding: 4px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
}

.entity-actions button:hover {
    color: #ccc;
}

.entity-group {
    border-left: 3px solid #bd93f9;
}

.entity-child {
    margin-left: 20px;
    border-left: 2px solid #6272a4;
    opacity: 0.8;
}

.drag-over {
    border: 2px dashed #50fa7b !important;
    background: #282a36 !important;
}

.btn-icon {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: #ccc;
}

.btn-icon.active {
    color: #fff;
}

/* Variables */
.var-item {
    background: #1e1e24;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #444;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.var-key {
    color: #ffb86c;
    font-weight: bold;
}

.var-val {
    color: #f8f8f2;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Lamps */
.lamp {
    position: absolute;
    width: 65px;
    height: 65px;
    background: #222;
    border-radius: 50%;
    border: 2px solid #444;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transform: translate(-50%, -50%);
    transition: background-color 0s linear, box-shadow 0s linear;
}

.lamp-label {
    position: absolute;
    bottom: -20px;
    font-size: 10px;
    color: #888;
    font-weight: bold;
    pointer-events: none;
    text-align: center;
    width: max-content;
    max-width: 140px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
}

.lamp-label.hidden {
    display: none;
}

/* Mobile Tabs Navigation */
#mobile-tabs {
    display: none;
    background: #1e1e24;
    border-top: 1px solid #444;
    flex-shrink: 0;
}

.mobile-tab {
    flex: 1;
    padding: 15px;
    background: none;
    border: none;
    color: #aaa;
    font-weight: bold;
    font-size: 14px;
    border-top: 3px solid transparent;
    cursor: pointer;
}

.mobile-tab.active {
    color: #50fa7b;
    border-top-color: #50fa7b;
    background: #282a36;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: #282a36;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
    opacity: 0;
    transform: translateY(20px);
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    max-width: 90vw;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    border-left: 4px solid #50fa7b;
}

.toast.error {
    border-left: 4px solid #ff5555;
    background: #3d1b1b;
}

/* Notification Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #282a36;
    border: 1px solid #444;
    border-radius: 8px;
    width: 600px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 15px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 15px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notif-item {
    background: #1e1e24;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 10px;
    position: relative;
}

.notif-item.error {
    border-left: 4px solid #ff5555;
}

.notif-item.success {
    border-left: 4px solid #50fa7b;
}

.notif-item.info {
    border-left: 4px solid #8be9fd;
}

.notif-time {
    font-size: 10px;
    color: #888;
    margin-bottom: 5px;
}

.notif-text {
    font-family: monospace;
    font-size: 12px;
    color: #f8f8f2;
    white-space: pre-wrap;
    word-break: break-all;
}

.notif-delete {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 16px;
}

.notif-delete:hover {
    color: #ff5555;
}

/* Responsive Media Queries */
@media (max-width: 900px) {
    #app-container {
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
        height: 0;
    }

    .resizer {
        display: none;
    }

    .panel {
        display: none;
        flex-direction: column;
        height: 100%;
        width: 100%;
        overflow: hidden;
    }

    .panel.active {
        display: flex;
    }

    #mobile-tabs {
        display: flex;
        flex-shrink: 0;
    }

    /* ── Global Header ── */
    #global-header {
        flex-wrap: wrap;
        gap: 6px;
        padding: 6px 12px;
        flex-shrink: 0;
        justify-content: space-between;
    }

    /* Hide the subheadline — too long for mobile */
    .header-subheadline {
        display: none;
    }

    .header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        align-items: center;
        flex: 1;
        justify-content: flex-end;
    }

    /* Playback takes its own full row */
    .playback-controls {
        order: 10;
        width: 100%;
        gap: 6px;
    }

    /* Validate sits before playback row */
    #btn-validate {
        order: 1;
        flex: 1;
        min-width: 0;
    }

    /* Icon buttons stay on first row */
    #btn-notifications {
        order: 2;
    }

    #btn-language {
        order: 3;
    }

    .btn-header {
        flex: 1;
        padding: 10px 8px;
        font-size: 11px;
        min-width: 0;
    }

    #toast-container {
        bottom: 100px;
    }

    /* ── Simulation Panel Header: two rows ── */
    #panel-preview .panel-header {
        flex-direction: column;
        height: auto;
        padding: 0 10px;
        align-items: stretch;
        gap: 0;
    }

    /* Row 1: title + thin separator */
    #panel-preview .panel-title {
        height: 36px;
        display: flex;
        align-items: center;
        border-bottom: 1px solid #333;
        flex-shrink: 0;
    }

    /* Row 2: all tools, horizontally scrollable */
    #panel-preview .panel-tools {
        overflow-x: auto;
        overflow-y: visible;
        flex-wrap: nowrap;
        padding: 5px 0 7px;
        gap: 6px;
        /* hide scrollbar visually but keep it functional */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    #panel-preview .panel-tools::-webkit-scrollbar {
        display: none;
    }

    /* Move toggle buttons to the front for easy reach */
    #btn-toggle-entities {
        order: -2;
    }

    #btn-toggle-labels {
        order: -1;
    }

    /* Narrower select dropdowns */
    #sel-color-curve {
        max-width: 80px;
        font-size: 10px;
    }

    #sel-blend-mode {
        max-width: 90px;
        font-size: 10px;
    }
}

/* Touch devices (phones/tablets): no hover → sliders always visible, but narrower */
@media (hover: none) {
    .slider-container .premium-slider {
        max-width: 200px;
        opacity: 1;
        pointer-events: auto;
        /* Prevent the scrollable toolbar from intercepting horizontal drag —
           the browser treats the touch as a slider interaction, not a scroll. */
        touch-action: none;
    }

    /* Narrower tracks to save space */
    .slider-container .premium-slider.slider-wide {
        width: 60px;
    }

    .slider-container .premium-slider:not(.slider-wide) {
        width: 50px;
    }
}

/* Smart UI Components */
.node-field-smart {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.node-smart-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.node-slider {
    flex: 1;
    height: 6px;
    background: #444;
    border-radius: 3px;
    appearance: none;
    outline: none;
}

.node-slider::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    background: #bd93f9;
    border-radius: 50%;
    cursor: pointer;
}


.node-input-override {
    width: 100px !important;
    font-size: 10px !important;
    padding: 4px 6px !important;
    color: #bd93f9 !important;
    border-color: #444 !important;
}

.node-input-override:focus {
    border-color: #bd93f9 !important;
}

.node-props-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 10px;
    margin-top: 10px;
    border-left: 2px solid #bd93f9;
}

.node-combo-container {
    width: 100%;
}

.node-smart-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.node-input-mode {
    background: #444;
    color: #bd93f9;
    border: none;
    border-radius: 4px;
    font-size: 9px;
    padding: 2px 4px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
}

.node-input-mode:focus {
    outline: none;
    background: #6272a4;
}

/* Visibility & Group States in Simulator */
.lamp.is-hidden-ghost {
    opacity: 0.25;
    border: 1px dashed rgba(255, 255, 255, 0.4);
    filter: grayscale(0.5);
    pointer-events: none;
    /* Deactivate interaction for ghost entities */
}

.lamp.is-group-master {
    border: 2px solid #bd93f9;
    box-shadow: 0 0 10px rgba(189, 147, 249, 0.3);
}

.lamp.is-group-master::after {
    content: '📁';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 12px;
    background: #282a36;
    border-radius: 50%;
    padding: 2px;
}

/* Variable Insert Button (Dracula Theme) */
.btn-var-insert {
    background: #44475a;
    color: #50fa7b;
    /* Dracula Green */
    border: 1px solid #6272a4;
    border-radius: 3px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 10px;
    flex-shrink: 0;
}

.btn-var-insert:hover {
    background: #50fa7b;
    color: #282a36;
    border-color: #50fa7b;
    transform: scale(1.1);
}

.btn-var-insert:active {
    transform: scale(0.9);
}

.btn-var-insert {
    width: 24px !important;
    height: auto !important;
    /* Managed by stretch */
    border: none !important;
    border-right: 1px solid #6272a4 !important;
    border-radius: 0 !important;
    margin-right: 12px !important;
    background: #44475a;
}

.btn-var-insert:hover {
    background: #bd93f9 !important;
    /* Dracula Purple for active feel */
    color: #282a36 !important;
    transform: none !important;
}

/* Variable-specific Item Overrides */
#variable-list .entity-item {
    flex-direction: row !important;
    /* Side-by-side */
    align-items: stretch !important;
    padding: 0 !important;
    /* Button will take its own space */
    min-height: 40px;
}



#variable-list .entity-info {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#variable-list .btn-var-insert {
    width: 30px !important;
    /* Slightly wider for the arrow */
    font-size: 16px !important;
}

/* Disable editing during simulation */
body.simulation-running .color-picker-section,
body.simulation-running .node-input,
body.simulation-running .node-slider,
body.simulation-running .node-color-swatch,
body.simulation-running .tl-color-swatch,
body.simulation-running .node-input-mode,
body.simulation-running .node-select,
body.simulation-running .btn-var-insert,
body.simulation-running .btn-var-save,
body.simulation-running .node-add-btn,
body.simulation-running .btn-add-field,
body.simulation-running .btn-remove-field,
body.simulation-running .btn-entity-header-delete,
body.simulation-running .btn-move-up,
body.simulation-running .btn-move-down {
    pointer-events: none !important;
    opacity: 0.6;
    filter: grayscale(0.5);
    cursor: default;
}

/* Allow scrolling in node editor but no interaction with fields */
body.simulation-running .node-editor-content {
    pointer-events: auto;
    /* Re-enable for scroll */
}

body.simulation-running .node-field,
body.simulation-running .node-field-smart,
body.simulation-running .node-header,
body.simulation-running .node-header-actions,
body.simulation-running .btn-breakpoint {
    pointer-events: auto !important;
}

/* Block code-inserting actions in inspector; entity/group actions remain enabled */
body.simulation-running .code-snippet,
body.simulation-running .favorite-add {
    pointer-events: none !important;
    opacity: 0.4;
    filter: grayscale(0.5);
    cursor: default;
}

/* Floating Tooltip */
.floating-tooltip {
    position: fixed;
    z-index: 10000;
    background: #44475a;
    color: #f8f8f2;
    padding: 6px 12px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    pointer-events: none;
    border: 1px solid #6272a4;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    white-space: pre-wrap;
    max-width: 300px;
}

.breakpoints {
    width: 24px;
    cursor: pointer;
}

.breakpoint-marker {
    color: rgba(255, 85, 85, 1);
    font-size: 16px;
    text-align: center;
    line-height: 1;
    filter: drop-shadow(0 0 2px rgba(255, 85, 85, 0.5));
    cursor: pointer;
}

.breakpoint-hint {
    color: rgba(255, 125, 125, 0.4);
    font-size: 16px;
    text-align: center;
    line-height: 1;
    transition: color 0.2s;
    cursor: pointer;
}

.breakpoint-hint:hover,
.breakpoint-hint.force-hover {
    color: rgba(255, 85, 85, 1);
}

/* Active Breakpoint/Step Highlighting */
.node-item.is-executing {
    border: 2px solid #ff5555 !important;
    box-shadow: 0 0 20px rgba(255, 85, 85, 0.5) !important;
    z-index: 100;
}

.cm-active-step-line {
    background: rgba(255, 85, 85, 0.25) !important;
}

/* Debug Mode Visual Cues */
body.simulation-running #panel-editor {
    outline: 1px solid rgba(255, 85, 85, 0.3);
}

body.simulation-running .panel-header {
    border-bottom: 1px solid rgba(255, 85, 85, 0.4);
    background: linear-gradient(90deg, #343746 0%, #442c2c 100%);
}

body.simulation-running .panel-tab.active {
    border-bottom-color: #ff5555;
}

/* Dropdown Menu Styles */
.dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: fixed;
    margin-top: 4px;
    background: #282a36;
    border: 1px solid #444;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    min-width: 200px;
    overflow: hidden;
    animation: fadeInScale 0.15s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.dropdown-menu.active {
    display: block;
}

.dropdown-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: rgba(189, 147, 249, 0.15);
}

.dropdown-item .item-title {
    color: #f8f8f2;
    font-size: 13px;
    font-weight: 600;
}

.dropdown-item .item-desc {
    color: #888;
    font-size: 11px;
    margin-top: 2px;
}

.dropdown-divider {
    height: 1px;
    background: #444;
    margin: 4px 0;
}

.dropdown-item.cancel {
    text-align: center;
    align-items: center;
    color: #ff5555;
}

.dropdown-item.cancel:hover {
    background: rgba(255, 85, 85, 0.1);
}

.dropdown-item.mode-item {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
}

.dropdown-item.mode-item>div {
    display: flex;
    flex-direction: column;
}

.mode-item-icon {
    flex-shrink: 0;
    opacity: 0.6;
}

.dropdown-item.mode-item:hover .mode-item-icon {
    opacity: 0.9;
}

.dropdown-item.mode-item .item-desc {
    margin-top: 1px;
}

.dropdown-item.mode-item.active {
    background: rgba(189, 147, 249, 0.1);
}

.dropdown-item.mode-item.active .mode-item-icon {
    opacity: 1;
    color: #bd93f9;
}

.dropdown-item.mode-item.active .item-title {
    color: #bd93f9;
}

.dropdown-item.mode-item.active::after {
    content: '✓';
    margin-left: auto;
    color: #bd93f9;
    font-size: 12px;
    flex-shrink: 0;
}

/* Premium Slider in Simulation Header */
.slider-container {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #444;
    height: 28px;
    box-sizing: border-box;
}

.slider-icon {
    color: #ffb86c;
    flex-shrink: 0;
}

.slider-icon.ambient-icon {
    color: #8be9fd;
}

.premium-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    background: #44475a;
    border-radius: 2px;
    outline: none;
    margin: 0;
    cursor: pointer;
    transition: background 0.3s;
}

.premium-slider.slider-wide {
    width: 120px;
}

.premium-slider:hover {
    background: #6272a4;
}

.premium-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffb86c;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(255, 184, 108, 0.5);
    transition: transform 0.1s ease;
}

.premium-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.premium-slider.ambient-slider::-webkit-slider-thumb {
    background: #8be9fd;
    box-shadow: 0 0 5px rgba(139, 233, 253, 0.5);
}

.premium-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: none;
    border-radius: 50%;
    background: #ffb86c;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(255, 184, 108, 0.5);
    transition: transform 0.1s ease;
}

.premium-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.premium-slider.ambient-slider::-moz-range-thumb {
    background: #8be9fd;
    box-shadow: 0 0 5px rgba(139, 233, 253, 0.5);
}

.slider-textbox {
    max-width: 64px;
    min-width: 36px;
    background: #282a36;
    border: 1px solid #44475a;
    border-radius: 3px;
    color: #f8f8f2;
    font-size: 10px;
    font-family: monospace;
    text-align: center;
    padding: 1px 2px;
    height: 18px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.slider-textbox:focus {
    border-color: #bd93f9;
    box-shadow: 0 0 4px rgba(189, 147, 249, 0.3);
}

.slider-textbox:hover {
    border-color: #6272a4;
}

/* Collapsible slider tracks: hidden by default, expand on hover / active edit */
.slider-container .premium-slider {
    max-width: 0;
    opacity: 0;
    pointer-events: none;
    transition: max-width 0.22s ease, opacity 0.18s ease;
}

.slider-container:hover .premium-slider,
.slider-container:focus-within .premium-slider {
    max-width: 200px;
    /* larger than any actual slider width; lets width prop take over */
    opacity: 1;
    pointer-events: auto;
}

.slider-container:hover {
    border-color: #666;
    background: rgba(255, 255, 255, 0.08);
}

/* ═══════════════════════════════════════════════════════════
   TIMELINE EDITOR
   ═══════════════════════════════════════════════════════════ */

:root {
    --tl-col-w: 150px;
    --tl-row-h: 36px;
    --tl-ruler-h: 28px;
    --tl-bracket-h: 18px;
}

#view-timeline {
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    padding: 0;
}

#view-timeline.active {
    display: flex;
}

/* ─── Timeline Meta Bar ─────────────────────────────────── */
#tl-meta-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: #1a1a1e;
    border-bottom: 1px solid #2a2a30;
    flex-shrink: 0;
    font-size: 11px;
    color: #aaa;
}

.tl-meta-field {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    flex: 1;
}

.tl-meta-field-mode {
    flex: 0 0 auto;
}

.tl-meta-field-desc {
    flex: 1.5;
}

.tl-meta-label {
    color: #666;
    font-size: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.tl-meta-input {
    flex: 1;
    min-width: 0;
    background: #252530;
    border: 1px solid #333;
    border-radius: 3px;
    color: #e0e0e0;
    font-size: 11px;
    padding: 2px 6px;
    height: 22px;
}

.tl-meta-input:focus {
    outline: none;
    border-color: #6272a4;
}

.tl-meta-select {
    background: #252530;
    border: 1px solid #333;
    border-radius: 3px;
    color: #e0e0e0;
    font-size: 11px;
    padding: 1px 4px;
    height: 22px;
    cursor: pointer;
}

.tl-meta-select:focus {
    outline: none;
    border-color: #6272a4;
}

.simulation-running .tl-meta-input,
.simulation-running .tl-meta-select {
    pointer-events: none;
    opacity: 0.5;
}

#tl-container {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #141418;
    font-size: 11px;
    color: #ccc;
}

/* ─── Header Row (Corner + Ruler) ─────────────────────── */
#tl-header-row {
    display: flex;
    height: 32px;
    flex-shrink: 0;
    border-bottom: 1px solid #2a2a30;
}

#tl-corner {
    width: var(--tl-col-w);
    flex-shrink: 0;
    border-right: 1px solid #2a2a30;
    background: #1a1a1e;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 6px;
    overflow: hidden;
}

/* ─── Loop Controls ────────────────────────────────────── */
.tl-loop-btn {
    height: 20px;
    width: 20px;
    padding: 0;
    background: #252530;
    border: 1px solid #333;
    border-radius: 3px;
    color: #777;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    user-select: none;
    flex-shrink: 0;
}

.tl-loop-btn:hover {
    background: #2e2e3e;
    border-color: #6272a4;
    color: #eee;
}

.tl-loop-btn.active {
    background: #3a2e5a;
    border-color: #bd93f9;
    color: #bd93f9;
}

.tl-loop-btn.active:hover {
    background: #4a3a6e;
}

.tl-loop-step-btn {
    height: 20px;
    width: 20px;
    padding: 0;
    background: #252530;
    border: 1px solid #333;
    border-radius: 3px;
    color: #666;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    user-select: none;
    flex-shrink: 0;
}

.tl-loop-step-btn:hover:not(:disabled) {
    background: #2e2e3e;
    border-color: #bd93f9;
    color: #bd93f9;
}

.tl-loop-step-btn:disabled,
.tl-loop-count-inline:disabled,
.tl-loop-inf-btn:disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.tl-loop-count-inline {
    width: 24px;
    min-width: 24px;
    max-width: 24px;
    height: 20px;
    box-sizing: border-box;
    background: #252530;
    border: 1px solid #444;
    border-radius: 3px;
    color: #aaa;
    font-size: 10px;
    text-align: center;
    padding: 0;
    flex-shrink: 0;
    -moz-appearance: textfield;
}

.tl-loop-count-inline::-webkit-inner-spin-button,
.tl-loop-count-inline::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tl-loop-count-inline:not(:disabled) {
    border-color: #bd93f9;
    color: #bd93f9;
}

.tl-loop-count-inline:focus {
    outline: none;
    border-color: #ff79c6;
}

.tl-loop-inf-btn {
    height: 20px;
    width: 20px;
    padding: 0;
    background: #252530;
    border: 1px solid #444;
    border-radius: 3px;
    color: #555;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    user-select: none;
    flex-shrink: 0;
}

.tl-loop-inf-btn:hover:not(:disabled) {
    border-color: #bd93f9;
    color: #bd93f9;
}

.tl-loop-inf-btn.active {
    background: #3a2e5a;
    border-color: #bd93f9;
    color: #bd93f9;
}

/* ─── Floating Zoom Toolbar ────────────────────────────── */
#tl-zoom-toolbar {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(20, 20, 24, 0.92);
    border: 1px solid #333;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 12px;
    z-index: 10;
    pointer-events: all;
}

#tl-zoom-toolbar button {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 3px;
}

#tl-zoom-toolbar button:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

#tl-zoom-label {
    color: #ccc;
    min-width: 38px;
    text-align: center;
    cursor: default;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 11px;
    user-select: none;
    white-space: nowrap;
}

#tl-ruler-scroll {
    flex: 1;
    overflow: hidden;
    background: #1a1a1e;
    display: flex;
    align-items: flex-end;
    cursor: grab;
    user-select: none;
}

#tl-ruler {
    position: relative;
    height: var(--tl-ruler-h);
    min-width: 100%;
}

.tl-tick {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.tl-tick::before {
    content: '';
    display: block;
    width: 1px;
    height: 8px;
    background: #444;
    margin-top: 4px;
}

.tl-tick-label {
    font-size: 9px;
    color: #666;
    margin-left: 3px;
    margin-top: 2px;
    white-space: nowrap;
    user-select: none;
}

.tl-tick.medium::before {
    background: #5a5a68;
    height: 13px;
    margin-top: 1px;
    width: 1px;
}

.tl-tick.major::before {
    background: #555;
    height: 12px;
    margin-top: 0;
}

.tl-tick.major .tl-tick-label {
    color: #888;
    font-size: 10px;
    margin-top: 0;
}

/* ─── Body (Entity Col + Scroll Area) ─────────────────── */
#tl-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#tl-entity-col {
    width: var(--tl-col-w);
    flex-shrink: 0;
    overflow: hidden;
    border-right: 1px solid #2a2a30;
    background: #1a1a1e;
}

.tl-entity-label {
    height: var(--tl-row-h);
    display: flex;
    align-items: center;
    padding: 0 6px 0 10px;
    font-size: 11px;
    color: #bbb;
    border-bottom: 1px solid #222;
    user-select: none;
    gap: 4px;
}

.tl-entity-label:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #eee;
}

.tl-entity-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tl-entity-actions {
    display: none;
    align-items: center;
    gap: 1px;
    flex-shrink: 0;
}

.tl-entity-label:hover .tl-entity-actions {
    display: flex;
}

.tl-entity-action-btn {
    background: none;
    border: none;
    color: #777;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 11px;
    line-height: 1;
    border-radius: 3px;
    transition: background 0.1s, color 0.1s;
}

.tl-entity-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #eee;
}

.tl-entity-action-btn.tl-entity-delete:hover {
    background: rgba(255, 85, 85, 0.18);
    color: #ff5555;
}

/* Marquee selection rectangle */
.tl-marquee {
    position: absolute;
    background: rgba(189, 147, 249, 0.07);
    border: 1px solid rgba(189, 147, 249, 0.55);
    border-radius: 2px;
    pointer-events: none;
    z-index: 50;
}

/* Selected block highlight */
.tl-block-selected {
    outline: 2px solid #bd93f9;
    outline-offset: 1px;
    z-index: 2;
}

.tl-drag-handle {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding: 0 4px 0 0;
    color: #444;
    opacity: 0;
    cursor: grab;
    transition: opacity 0.15s, color 0.15s;
    user-select: none;
}
.tl-entity-label:hover .tl-drag-handle { opacity: 1; color: #777; }
.tl-drag-handle:active { cursor: grabbing; color: #bd93f9; }
.tl-entity-label.tl-dragging { opacity: 0.35; }

.tl-drop-indicator {
    height: 2px;
    background: #bd93f9;
    border-radius: 1px;
    pointer-events: none;
    flex-shrink: 0;
}

.tl-entity-rename-input {
    width: 100%;
    background: #1e1e26;
    border: 1px solid #5a5aaa;
    color: #eee;
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 3px;
    outline: none;
    box-sizing: border-box;
}

/* ─── Scroll Area ──────────────────────────────────────── */
#tl-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: scroll;
    /* must stay scroll so scrollLeft is settable */
    position: relative;
    background: #141418;
    scrollbar-width: none;
    /* Firefox: hide native scrollbar (custom row used) */
}

/* Rows alternate slightly for readability */
.tl-row {
    height: var(--tl-row-h);
    position: relative;
    border-bottom: 1px solid #1e1e24;
}

.tl-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.01);
}

/* ─── Blocks ───────────────────────────────────────────── */
.tl-block {
    position: absolute;
    top: 4px;
    height: 28px;
    border-radius: 4px;
    cursor: grab;
    overflow: hidden;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: border-color 0.1s, box-shadow 0.1s;
    min-width: 4px;
}

.tl-block:hover {
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.tl-block.selected {
    border-color: #bd93f9;
    box-shadow: 0 0 8px rgba(189, 147, 249, 0.4);
    z-index: 3;
}

.tl-block-inner {
    margin-left: auto;
    padding: 0 12px 0 4px;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    pointer-events: none;
    user-select: none;
}

.tl-block-handle {
    position: absolute;
    right: 0;
    top: 0;
    width: 8px;
    height: 100%;
    cursor: ew-resize;
    background: rgba(255, 255, 255, 0.08);
    opacity: 0;
    transition: opacity 0.15s;
}

.tl-block:hover .tl-block-handle {
    opacity: 1;
}

.tl-block-badge {
    position: absolute;
    top: 2px;
    right: 10px;
    font-size: 9px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 3px;
    padding: 0 3px;
    pointer-events: none;
    line-height: 14px;
    user-select: none;
}

/* ─── Repeat Bracket ───────────────────────────────────── */
.tl-repeat-bracket {
    position: absolute;
    border: 1px dashed rgba(139, 233, 253, 0.35);
    border-radius: 4px;
    pointer-events: none;
    z-index: 1;
    box-sizing: border-box;
}

.tl-repeat-label {
    position: absolute;
    top: -14px;
    left: 4px;
    font-size: 9px;
    font-weight: 700;
    color: rgba(139, 233, 253, 0.7);
    background: #141418;
    padding: 0 3px;
    border-radius: 2px;
    white-space: nowrap;
    user-select: none;
}

/* ─── Playback Cursor ──────────────────────────────────── */
#tl-cursor {
    position: absolute;
    top: 0;
    width: 2px;
    background: #ff5555;
    pointer-events: none;
    display: none;
    z-index: 10;
}

#tl-cursor::before {
    content: '';
    position: absolute;
    top: 0;
    left: -4px;
    width: 10px;
    height: 10px;
    background: #ff5555;
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    transform: rotate(180deg);
}

/* ─── Continuation Zone (light holds last state in gaps) ── */
.tl-continuation-zone {
    position: absolute;
    top: 4px;
    height: 28px;
    pointer-events: none;
    box-sizing: border-box;
    border-left: 2px dashed rgba(255, 255, 255, 0.15);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0 3px 3px 0;
}

/* ─── Insert Ghost ─────────────────────────────────────── */
#tl-insert-ghost {
    position: absolute;
    top: 0;
    width: 1px;
    background: rgba(189, 147, 249, 0.45);
    pointer-events: none;
    display: none;
    z-index: 9;
    transform: translateX(-50%);
}

#tl-insert-ghost::after {
    content: attr(data-time);
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 9px;
    font-weight: 600;
    color: rgba(189, 147, 249, 0.95);
    white-space: nowrap;
    background: rgba(16, 16, 22, 0.88);
    padding: 1px 4px;
    border-radius: 2px;
    border: 1px solid rgba(189, 147, 249, 0.25);
}

/* ─── Instant Change Marker (transition: 0) ────────────── */
.tl-block-instant {
    width: 16px !important;
    min-width: 16px !important;
    border-radius: 3px;
    border: 1.5px solid rgba(255, 255, 255, 0.65) !important;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.18), inset 0 0 4px rgba(0, 0, 0, 0.25);
    overflow: visible;
}

/* Diagonal stripes signal "zero time passes" */
.tl-block-instant::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: repeating-linear-gradient(-45deg,
            transparent 0 2px,
            rgba(0, 0, 0, 0.28) 2px 3.5px);
    pointer-events: none;
    z-index: 2;
}

/* Bright top-edge accent line */
.tl-block-instant::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border-top: 2px solid rgba(255, 255, 255, 0.55);
    pointer-events: none;
    z-index: 3;
}

.tl-block-instant .tl-block-ramp {
    width: 100% !important;
}

/* No label — too narrow */
.tl-block-instant .tl-block-inner {
    display: none;
}

/* ─── Block Ghost (create preview) ─────────────────────── */
.tl-block-ghost {
    opacity: 0.45;
    pointer-events: none !important;
    border-style: dashed !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    cursor: default !important;
}


/* ─── Empty State ──────────────────────────────────────── */
#tl-empty-state {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    color: #555;
    font-size: 12px;
    pointer-events: none;
}

/* ─── Block Popover ────────────────────────────────────── */
.tl-popover {
    position: fixed;
    background: #1e1e24;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 10px;
    z-index: 2000;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    font-size: 12px;
    color: #ccc;
}

.tl-popover-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.tl-popover-row:last-child {
    margin-bottom: 0;
}

.tl-popover-label {
    font-size: 10px;
    color: #888;
    flex-shrink: 0;
    width: 80px;
}


.tl-popover input[type="number"] {
    background: #2a2a32;
    border: 1px solid #444;
    border-radius: 4px;
    color: #eee;
    padding: 3px 6px;
    font-size: 11px;
    width: 70px;
    outline: none;
}

.tl-popover input[type="number"]:focus {
    border-color: #6272a4;
}

.tl-popover-delete {
    width: 100%;
    padding: 5px 0;
    background: rgba(255, 85, 85, 0.12);
    border: 1px solid rgba(255, 85, 85, 0.3);
    border-radius: 4px;
    color: #ff7070;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 4px;
}

.tl-popover-delete:hover {
    background: rgba(255, 85, 85, 0.25);
}

/* ─── Vertical Scrollbar (scroll area) ────────────────── */
#tl-scroll-area::-webkit-scrollbar {
    width: 6px;
    height: 0px;
    /* horizontal handled by dedicated row */
}

#tl-scroll-area::-webkit-scrollbar-track {
    background: #141418;
}

#tl-scroll-area::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

#tl-scroll-area::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ─── Dedicated Horizontal Scrollbar Row ──────────────── */
#tl-hscroll-row {
    display: flex;
    flex-shrink: 0;
    height: 12px;
    border-top: 1px solid #222;
    background: #141418;
}

#tl-hscroll-corner {
    width: var(--tl-col-w);
    flex-shrink: 0;
    border-right: 1px solid #2a2a30;
    background: #1a1a1e;
}

#tl-hscroll {
    flex: 1;
    overflow-x: scroll;
    overflow-y: hidden;
}

/* single pixel dummy — its width drives the scroll range */
#tl-hscroll-inner {
    height: 1px;
}

#tl-hscroll::-webkit-scrollbar {
    height: 10px;
}

#tl-hscroll::-webkit-scrollbar-track {
    background: #1a1a1e;
}

#tl-hscroll::-webkit-scrollbar-thumb {
    background: #3a3a48;
    border-radius: 5px;
    border: 2px solid #1a1a1e;
}

#tl-hscroll::-webkit-scrollbar-thumb:hover {
    background: #5a5a72;
}

/* Firefox */
#tl-hscroll {
    scrollbar-width: thin;
    scrollbar-color: #3a3a48 #1a1a1e;
}

/* ─── Block: Ramp Zone (transition area) ───────────────── */
.tl-block-ramp {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
    min-width: 0;
}

/* ─── Block: Hold Zone (solid color) ───────────────────── */
.tl-block-hold {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    display: flex;
    align-items: center;
    overflow: hidden;
}

/* ─── Block: Left Handle (transition resize) ────────────── */
.tl-block-handle-left {
    position: absolute;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
    background: rgba(255, 255, 255, 0.0);
    opacity: 0;
    transition: opacity 0.12s;
    z-index: 3;
}

/* Visible grip line on hover */
.tl-block-handle-left::after {
    content: '';
    position: absolute;
    top: 15%;
    bottom: 15%;
    left: 2px;
    width: 2px;
    border-radius: 1px;
    background: rgba(255, 255, 255, 0.75);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

.tl-block:hover .tl-block-handle-left {
    opacity: 1;
}

/* ─── Pre-Zone (initial delay visualisation) ────────────── */
.tl-pre-zone {
    position: absolute;
    top: 4px;
    height: 28px;
    background: repeating-linear-gradient(-45deg,
            rgba(255, 255, 255, 0.035) 0 3px,
            transparent 3px 6px);
    border-radius: 4px 0 0 4px;
    pointer-events: none;
    box-sizing: border-box;
}

/* ─── Add Entity Button ─────────────────────────────────── */
.tl-add-entity-btn {
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: #444;
    margin: 6px 8px 4px;
    border: 1px dashed #2e2e36;
    border-radius: 4px;
    transition: color 0.15s, border-color 0.15s;
    user-select: none;
    flex-shrink: 0;
}

.tl-add-entity-btn:hover {
    color: #bd93f9;
    border-color: #bd93f9;
}

/* ─── Add Entity Input ──────────────────────────────────── */
.tl-add-entity-input {
    width: calc(100% - 16px);
    margin: 6px 8px 4px;
    background: #2a2a32;
    border: 1px solid #6272a4;
    border-radius: 4px;
    color: #eee;
    padding: 3px 6px;
    font-size: 11px;
    outline: none;
    box-sizing: border-box;
    display: block;
}

/* ─── Create Block Button (new block popover) ───────────── */
.tl-popover-create {
    width: 100%;
    padding: 5px 0;
    margin-top: 6px;
    background: rgba(80, 200, 120, 0.14);
    border: 1px solid rgba(80, 200, 120, 0.35);
    border-radius: 4px;
    color: #80d4a0;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s;
}

.tl-popover-create:hover {
    background: rgba(80, 200, 120, 0.28);
}

/* ============================================================
   Modal footer + shared modal button helpers
   ============================================================ */

.modal-footer {
    padding: 10px 15px;
    border-top: 1px solid #444;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.modal-close-btn:hover { color: #ff5555; background: rgba(255,85,85,0.15); }

.btn-modal-save {
    padding: 6px 16px;
    background: #bd93f9;
    color: #1a1a1a;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-modal-save:hover { background: #caa8ff; }

.btn-modal-danger {
    background: #c0392b;
    color: #f8f8f2;
}
.btn-modal-danger:hover { background: #e74c3c; }

.btn-modal-cancel {
    padding: 6px 14px;
    background: #282a36;
    color: #aaa;
    border: 1px solid #555;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-modal-cancel:hover { background: #44475a; color: #f8f8f2; }

/* ============================================================
   Library Panel (Bibliothek Tab)
   ============================================================ */

#view-library {
    overflow-y: auto;
    padding: 10px;
}

#library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}

/* Slot card */
.lib-slot-card {
    background: #21222c;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    transition: border-color 0.15s;
}
.lib-slot-card:hover { border-color: #bd93f9; }
.lib-slot-card.lib-slot-active { border-color: #50fa7b; }

.lib-slot-empty {
    border-style: dashed;
    opacity: 0.55;
}
.lib-slot-empty:hover { opacity: 1; }

/* Card header row */
.lib-slot-header {
    display: flex;
    align-items: center;
    gap: 6px;
}
.lib-slot-name {
    font-size: 13px;
    font-weight: 600;
    color: #f8f8f2;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lib-slot-icon-btns {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}
.lib-icon-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 3px 4px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
}
.lib-icon-btn:hover { color: #f8f8f2; background: rgba(255,255,255,0.08); }

/* Description */
.lib-slot-desc {
    font-size: 11px;
    color: #777;
    line-height: 1.35;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mini timeline canvas */
.lib-mini-timeline {
    width: 100%;
    border-radius: 3px;
    display: block;
}

/* Meta chips */
.lib-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.lib-meta-chip {
    font-size: 10px;
    padding: 2px 6px;
    background: #1a1a1a;
    border: 1px solid #3a3a4a;
    border-radius: 4px;
    color: #999;
    font-family: monospace;
}

/* Action buttons */
.lib-actions {
    display: flex;
    gap: 6px;
}
.lib-btn {
    flex: 1;
    padding: 5px 8px;
    font-size: 11px;
    border-radius: 5px;
    border: 1px solid #555;
    background: #282a36;
    color: #ccc;
    cursor: pointer;
    transition: background 0.15s;
}
.lib-btn:hover { background: #44475a; }
.lib-btn.lib-btn-primary {
    border-color: #bd93f9;
    color: #bd93f9;
}
.lib-btn.lib-btn-primary:hover { background: rgba(189,147,249,0.15); }

/* Inspector entity rename / delete buttons */
.entity-action-btn {
    opacity: 0.4;
    transition: opacity 0.15s, color 0.15s;
}
.entity-action-btn:hover { opacity: 1; }
.entity-delete-btn:hover { color: #ff5555 !important; }
.entity-action-btn:disabled {
    opacity: 0.15;
    pointer-events: none;
}

/* Drag-to-reorder drop indicator */
.entity-drop-indicator {
    height: 2px;
    background: #bd93f9;
    border-radius: 1px;
    margin: 0 4px;
    pointer-events: none;
}