body {
    background-color: #282c34;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', 'Apple Symbols', 'Segoe UI Symbol', 'Segoe UI Emoji', 'Noto Sans Symbols', 'Noto Sans Symbols 2', sans-serif;
    color: #abb2bf;
    margin: 0;
    padding: 0;
}

h1,
h2 {
    background-color: #383c44;
    padding: 1rem 1rem 1rem 4rem;
    position: sticky;
    top: 0;
    font-size: 1.5rem;
    z-index: 10;
    transition: padding-left 0.2s ease;
}

h1 {
    margin-top: 0;
    box-shadow: black 0 0 10px;
    min-height: 2rem;
}

em {
    color: #abb2bf;
}

@media only screen and (max-width: 768px) {

    h1, h2, h3 {
        top: var(--btns-bottom, 4rem);
    }
}

p {
    margin: .4rem 1rem;
}

#script-content.first-block-is-cue {
    padding-top: var(--first-cue-padding, 4rem);
}

.trigger-group {
    display: flex;
    align-items: flex-start;
    gap: 0;
}

.trigger-group .trigger {
    flex: 1;
    min-width: 0;
}

.trigger {
    display: flex;
    flex-direction: column;
    border-radius: 5px;
    background-color: #383c44;
    margin: 1rem 1rem;
    padding: 0.5rem;
    box-shadow: black 0 0 10px;
    cursor: pointer;
    border-left: 5px #383c44 solid;
    position: relative;
}

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

.trigger-marked {
    border-left: 5px #e5c07b solid;
}

.trigger-armed {
    border-left: 5px #98c379 solid;
    box-shadow: black 0 0 10px, 0 0 0 1px #98c37955, 0 0 16px #98c37933;
}

.trigger-info {
    flex: 1;
    min-width: 0;
}

.trigger-note {
    display: flex;
    border: 2px #e06c75 solid;
    border-radius: 5px;
    padding: 3px;
    font-weight: bold;
    max-width: 40%;
    margin: 0 1rem;
}

.trigger:hover {
    background-color: #2e323a;
}

.trigger:hover .trigger-action-btn {
    color: #abb2bf;
    border-color: #5c6370;
}

.trigger:hover .trigger-move-btn {
    color: #abb2bf;
}

.trigger:active {
    box-shadow: none;
    background-color: #383c44;
}

.trigger-mic { display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem; }

.trigger-mic span {
    margin-right: 0.4rem;
    display: inline-block;
}

.trigger-mic .mic-group {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid #4b5263;
    border-radius: 4px;
    padding: 0 0.3rem 0 0;
    overflow: hidden;
    margin-right: 0;
}
.trigger-mic .mic-group-name {
    font-weight: 700;
    padding: 0.05rem 0.4rem;
    font-size: inherit;
    background: rgba(255,255,255,0.06);
}
.trigger-mic .mic-group-sep { color: #5c6370; font-size: 0.85em; }
.trigger-mic .mic-chip { border-radius: 3px; padding: 0.05rem 0.35rem; font-size: inherit; font-weight: 500; margin-right: 0 !important; }
.trigger-mic .mic-all-off { color: #e06c75; font-style: italic; }

.trigger-mic-auto-tag {
    font-size: 0.65rem;
    color: #636d83;
    border: 1px solid #4b5263;
    border-radius: 3px;
    padding: 0 0.25rem;
    margin-right: 0.35rem !important;
    vertical-align: middle;
    letter-spacing: 0.03em;
}

.trigger-light {
    font-size: 0.82rem;
    margin-top: 0.1rem;
}

.trigger-osc {
    font-size: 0.78rem;
    margin-top: 0.1rem;
    color: #61afef;
    font-family: monospace;
    opacity: 0.8;
}

.trigger-cue-midi,
.trigger-cue-osc {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.15rem;
}

.cue-msg-chip {
    display: inline-flex;
    align-items: stretch;
    font-size: 0.72rem;
    font-family: monospace;
    border-radius: 3px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    padding: 0;
}

.cue-msg-chip--midi {
    color: #abb2bf;
    background: rgba(229, 192, 123, 0.07);
    border: 1px solid rgba(229, 192, 123, 0.25);
}

.cue-msg-chip--osc {
    color: #abb2bf;
    background: rgba(97, 175, 239, 0.07);
    border: 1px solid rgba(97, 175, 239, 0.25);
}

.cue-type-badge {
    display: flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0 0.38em;
    line-height: 1;
}

.cue-msg-chip--midi .cue-type-badge {
    background: rgba(229, 192, 123, 0.32);
    color: #e5c07b;
}

.cue-msg-chip--osc .cue-type-badge {
    background: rgba(97, 175, 239, 0.32);
    color: #61afef;
}

.cue-msg-content {
    padding: 0.05rem 0.4rem;
    display: flex;
    align-items: center;
}

.cue-msg-chip--unknown.cue-msg-chip--midi {
    border-color: rgba(224, 108, 117, 0.5);
    background: rgba(224, 108, 117, 0.07);
}
.cue-msg-chip--unknown.cue-msg-chip--midi .cue-type-badge {
    background: rgba(224, 108, 117, 0.28);
    color: #e06c75;
}
.cue-msg-chip--unknown.cue-msg-chip--osc {
    border-color: rgba(224, 108, 117, 0.5);
    background: rgba(224, 108, 117, 0.07);
}
.cue-msg-chip--unknown.cue-msg-chip--osc .cue-type-badge {
    background: rgba(224, 108, 117, 0.28);
    color: #e06c75;
}

/* ── Cue message dialog cards ──────────────────────────────────────── */
.cue-msg-card {
    border: 1px solid #383c44;
    border-radius: 5px;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.5rem;
    background: #21252b;
}

.cue-msg-card-header {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: 0.4rem;
}

.cue-msg-card-header input {
    flex: 1;
    background: #383c44;
    color: #abb2bf;
    border: 1px solid #4b5263;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    box-sizing: border-box;
}

.cue-msg-card-remove {
    background: none;
    border: 1px solid #4b5263;
    color: #e06c75;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    flex-shrink: 0;
}

.cue-msg-card-remove:hover { background: rgba(224,108,117,0.12); }

.trigger-number {
    font-size: 3rem;
    font-weight: bold;
    color: #abb2bf;
    padding-right: 1rem;
}

.trigger-tc-badge {
    position: absolute;
    bottom: 0.35rem;
    right: 0.5rem;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: #e5c07b;
    opacity: 0.8;
    pointer-events: none;
}

.trigger-tc-badge--derived {
    font-style: italic;
    opacity: 0.7;
}

.trigger-number-input {
    width: 4.2rem;
    background: #2c313a;
    color: #abb2bf;
    border: 1px solid #61afef;
    border-radius: 3px;
    font-size: 0.78rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    padding: 0.1rem 0.3rem;
    text-align: center;
}
.trigger-number-input.tc-input-invalid { border-color: #e06c75; color: #e06c75; }

#header-shield {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 0;
    background: #383c44;
    z-index: 11;
    pointer-events: none;
}

.buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: calc(100vw - 1rem);
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 20;
}

.button {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 5px;
    font-weight: bold;
    box-shadow: #223 0 0 5px;
    margin: 0rem 0.5rem;
    background-color: #282c34;
    border: black 1px solid;
    box-sizing: border-box;
}

.t-icon {
    vertical-align: middle;
    flex-shrink: 0;
}

.button:hover {
    background-color: #383c44;
}

.button:active {
    background-color: #282c34;
    box-shadow: none;
}

.emoji-button {
    font-size: 2rem;
    line-height: 3rem;
}

.emergency {
    background-color: #e06c75;
    border: none;
    border-radius: 1.5rem;
    box-shadow: #b03c45 0 0 10px;
}

.emergency:hover {
    background-color: #f07c85;
    box-shadow: #b03c45 0 0 10px;
}

.emergency:active {
    background-color: #b03c45;
    box-shadow: none;
}

.emergency img {
    height: 3rem;
    pointer-events: none;
}

.clock {
    line-height: 3rem;
    font-size: 2.5rem;
    margin-right: 1rem;
    background-color: #282c34;
    border-radius: 5px;
    padding: 0 0.5rem;
    box-shadow: inset black 0 0 10px;
    ;
    width: 10rem;
    text-align: center;
}

.no-shadow {
    box-shadow: none;
}

.color-red {
    color: #e06c75;
}

.color-green {
    color: #98c379;
}

.color-yellow {
    color: #e5c07b;
}

.color-blue {
    color: #61afef;
}

.color-purple {
    color: #c678dd;
}

.color-cyan {
    color: #56b6c2;
}

.color-darkred {
    color: #b03c45;
}

.color-darkgreen {
    color: #68b349;
}

.color-darkyellow {
    color: #b5904b;
}

.color-darkblue {
    color: #317fbf;
}

.color-darkpurple {
    color: #9648ad;
}

.color-darkcyan {
    color: #268692;
}

.trigger-move-btns {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-left: 0.4rem;
}

.trigger-move-btn {
    background: transparent;
    border: none;
    color: #5c6370;
    cursor: pointer;
    font-size: 0.65rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 3px;
}

.trigger-move-btn:hover {
    background: #4b5263;
    color: #abb2bf;
}

.trigger-actions {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.4rem;
    padding: 0 0.1rem;
}

.trigger-action-btn {
    background: transparent;
    border: 1px solid #4b5263;
    color: #5c6370;
    cursor: pointer;
    font-size: 0.78rem;
    padding: 2px 8px;
    border-radius: 3px;
    font-family: inherit;
}

.trigger-action-btn:hover {
    background: #282c34;
    color: #abb2bf;
}

.trigger-action-btn:active {
    background: #1e2127;
}

.trigger-action-btn-active {
    border-color: #e5c07b;
    color: #e5c07b;
}
.trigger-action-btn-active:hover { color: #e5c07b; }
.trigger:hover .trigger-action-btn-active {
    border-color: #e5c07b;
    color: #e5c07b;
}

.trigger-action-btn-danger {
    border-color: #e06c75 !important;
    color: #e06c75 !important;
}
.trigger-action-btn-danger:hover {
    background: #e06c75 !important;
    color: #282c34 !important;
}
.trigger-action-btn-wav-warning {
    border-color: #d19a66 !important;
    color: #d19a66 !important;
}
.trigger-action-btn-wav-warning::after { content: ' ⚠'; font-size: 0.7em; }
.waveform-btn.waveform-btn-wav-warning { background: #d19a6633 !important; color: #d19a66 !important; }
.trigger-wav-warning {
    font-size: 0.75rem;
    color: #d19a66;
    background: #d19a6612;
    border-bottom: 1px solid #d19a6630;
    padding: 0.18rem 0.6rem;
}

/* ── Pick mode ─────────────────────────────────────────────────────── */
body.trigger-pick-mode .trigger {
    border-left: 5px #e5c07b solid !important;
    cursor: crosshair;
}
body.trigger-pick-mode .trigger:hover { background-color: #3e422c; }
body.trigger-pick-mode .trigger-actions { pointer-events: none; }
body.trigger-pick-mode .waveform-wrapper { pointer-events: none; }

/* ── Show-Lock mode ────────────────────────────────────────────────── */
.button.lock-button.active {
    background-color: rgba(229,192,123,0.15);
    border-color: #e5c07b;
    color: #e5c07b;
}
body.show-locked .trigger-move-btns { pointer-events: none !important; }
body.show-locked .insert-zone      { pointer-events: none !important; }
body.show-locked .insert-hotspot   { pointer-events: none !important; }
body.show-locked .trigger          { user-select: none; }
body.show-locked .trigger button,
body.show-locked .trigger input,
body.show-locked .trigger select   { cursor: not-allowed !important; }

#lock-hint {
    position: fixed;
    background: #21252b;
    color: #e5c07b;
    border: 1px solid #e5c07b44;
    border-radius: 6px;
    padding: 0.35rem 0.65rem;
    font-size: 0.82rem;
    pointer-events: none;
    z-index: 9999;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.12s;
}

/* ── Filtered pick mode (Auto-Cue: only eligible triggers highlight) ── */
body.trigger-pick-mode-filtered .trigger-pick-eligible {
    border-left: 5px #e5c07b solid !important;
    cursor: crosshair;
}
body.trigger-pick-mode-filtered .trigger-pick-eligible:hover { background-color: #3e422c; }
body.trigger-pick-mode-filtered .trigger:not(.trigger-pick-eligible) {
    opacity: 0.45;
    cursor: default;
}
body.trigger-pick-mode-filtered .trigger-actions { pointer-events: none; }
body.trigger-pick-mode-filtered .waveform-wrapper { pointer-events: none; }

/* ── Controlled indicator ──────────────────────────────────────────── */
.trigger-controlled-indicator {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.7rem;
    color: #e5c07b;
    vertical-align: middle;
    opacity: 0.85;
}

/* ── Adjust dialog volume inline input ─────────────────────────────── */
.dialog-volume-inline {
    width: 5rem !important;
    padding: 0.2rem 0.4rem !important;
    font-size: 0.9rem;
    display: inline-block;
    vertical-align: middle;
}

.waveform-wrapper {
    margin-top: 0.5rem;
    width: 100%;
}

.waveform-container {
    border-radius: 3px;
    overflow: hidden;
    width: 100%;
    position: relative;
}

.waveform-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 5;
}

.ws-inactive {
    position: absolute;
    top: 0; height: 100%;
    background: rgba(0,0,0,0.36);
    pointer-events: none;
}

.ws-fade {
    position: absolute;
    top: 0; height: 100%;
    pointer-events: none;
}
.ws-fade-in  { background: rgba(97,175,239,0.3);  clip-path: polygon(0% 100%, 100% 0%, 100% 100%); }
.ws-fade-out { background: rgba(224,108,117,0.3); clip-path: polygon(0% 0%, 100% 100%, 0% 100%); }

.ws-bar {
    position: absolute;
    top: 0; height: 100%;
    width: 2px;
    transform: translateX(-50%);
    pointer-events: none;
}
.ws-bar-start { background: rgba(97,175,239,0.9); }
.ws-bar-end   { background: rgba(224,108,117,0.9); }

.ws-grip {
    position: absolute;
    width: 14px; height: 10px;
    transform: translateX(-50%);
    pointer-events: none;
    opacity: 0.3;
    transition: opacity 0.12s;
}
.ws-grip-top { top: 0;    border-radius: 0 0 4px 4px; }
.ws-grip-bot { bottom: 0; border-radius: 4px 4px 0 0; }
.ws-grip-start { background: #61afef; }
.ws-grip-end   { background: #e06c75; }
body.shift-held .ws-grip { pointer-events: all; opacity: 1; cursor: ew-resize; }
body.shift-held .ws-grip:hover { filter: brightness(1.3); }

.waveform-btn.waveform-btn-active        { background: #61afef; color: #282c34; }
.waveform-btn.waveform-btn-active:hover  { background: #71bfff; }
.waveform-btn.waveform-btn-active:active { background: #317fbf; }

.waveform-controls {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.3rem;
    align-items: center;
}

.waveform-btn {
    background: #4b5263;
    border: none;
    border-radius: 4px;
    color: #abb2bf;
    cursor: pointer;
    padding: 0.15rem 0.55rem;
    font-size: 0.9rem;
    line-height: 1.6;
    font-family: inherit;
    user-select: none;
}

.waveform-btn:hover  { background: #5c6370; }
.waveform-btn:active { background: #282c34; }

.volume-slider {
    -webkit-appearance: none;
    flex: 1;
    min-width: 60px;
    max-width: 120px;
    height: 4px;
    background: #4b5263;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    margin: 0 0.2rem;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    background: #61afef;
    border-radius: 50%;
    cursor: pointer;
}
.volume-slider:hover::-webkit-slider-thumb { background: #71bfff; }

.volume-label {
    font-size: 0.8rem;
    color: #5c6370;
    min-width: 2.5rem;
    text-align: right;
    user-select: none;
}

/* ── Insert zones ──────────────────────────────────────────────────── */
.insert-zone {
    height: 1.6rem;
    margin: -0.8rem 0;
    position: relative;
    z-index: 5;
    pointer-events: none;
}

.insert-hotspot {
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    height: 100%;
    pointer-events: all;
    display: flex;
    align-items: center;
    padding-left: 0.4rem;
}

.insert-btn {
    width: 1.4rem;
    height: 1.4rem;
    background: #98c379;
    color: #282c34;
    border: none;
    border-radius: 50%;
    font-size: 1.1rem;
    line-height: 1.4rem;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 0;
    font-weight: bold;
    flex-shrink: 0;
}

.insert-hotspot:hover .insert-btn { opacity: 1; }
body.shift-held .insert-hotspot:hover .insert-btn { background: #61afef; }

/* ── Add-trigger dialog ────────────────────────────────────────────── */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-box {
    background: #282c34;
    border: 1px solid #4b5263;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    padding: 1.5rem;
    min-width: 420px;
    max-width: 580px;
    max-height: 85vh;
    overflow-y: auto;
}

.dialog-box.dialog-box-scrollable {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dialog-scroll-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.5rem 1.5rem 0.75rem;
}

.dialog-box-scrollable .dialog-actions {
    margin-top: 0;
    padding: 0.85rem 1.5rem;
    border-top: 1px solid #383c44;
    flex-shrink: 0;
}

.dialog-box h3 {
    margin: 0 0 1.2rem;
    font-size: 1.1rem;
    color: #abb2bf;
    padding: 0;
    background: none;
    position: static;
}

.dialog-field {
    margin-bottom: 1rem;
}

.dialog-field > label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.82rem;
    color: #5c6370;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dialog-field input[type="text"],
.dialog-field input[type="number"],
.dialog-select {
    width: 100%;
    background: #383c44;
    color: #abb2bf;
    border: 1px solid #4b5263;
    padding: 0.45rem 0.7rem;
    border-radius: 5px;
    font-size: 0.95rem;
    font-family: inherit;
    box-sizing: border-box;
}

.dialog-select {
    appearance: none;
    cursor: pointer;
}

.dialog-field input[type="text"]:focus,
.dialog-field input[type="number"]:focus,
.dialog-select:focus { outline: none; border-color: #61afef; }

.tc-input { font-family: 'SF Mono', 'Fira Code', monospace; letter-spacing: 0.05em; }
.tc-input-invalid { border-color: #e06c75 !important; color: #e06c75; }

/* ── Searchable audio select ─────────────────────────────── */
.audio-select-wrap { position: relative; }
.audio-select-input-row {
    display: flex; align-items: center;
    background: #383c44; border: 1px solid #4b5263; border-radius: 5px; overflow: visible;
}
.audio-select-input-row:focus-within { border-color: #61afef; }
.audio-select-input {
    flex: 1; background: transparent; color: #abb2bf; border: none;
    padding: 0.45rem 0.7rem; font-size: 0.95rem; font-family: inherit; outline: none;
    min-width: 0;
}
.audio-select-arrow {
    color: #5c6370; padding: 0 0.6rem; cursor: pointer; user-select: none;
    font-size: 0.7rem; flex-shrink: 0;
}
.audio-select-dropdown {
    position: absolute; top: calc(100% + 2px); left: 0; right: 0;
    background: #2c313a; border: 1px solid #4b5263; border-radius: 5px;
    max-height: 200px; overflow-y: auto; z-index: 200;
    box-shadow: 0 4px 16px #00000055;
}
.audio-select-option {
    padding: 0.38rem 0.7rem; cursor: pointer; font-size: 0.9rem; color: #abb2bf;
}
.audio-select-option:hover,
.audio-select-option.selected { background: #3e4451; color: #fff; }
.audio-drop-active .audio-select-input-row {
    border-color: #98c379; background: #1e3a2a;
}

.dialog-tc-derived {
    width: 100%;
    background: #2c3038;
    color: #636d7e;
    border: 1px dashed #3e4451;
    padding: 0.45rem 0.7rem;
    border-radius: 5px;
    font-size: 0.95rem;
    font-family: monospace;
    box-sizing: border-box;
    cursor: default;
    font-style: italic;
}

.dialog-check-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.dialog-check-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    background: #383c44;
}

.dialog-check-group label:hover { background: #4b5263; }
.dialog-check-group input[type="checkbox"] { cursor: pointer; }

.dialog-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
}
.mic-chip-sep {
    width: 100%;
    font-size: 0.72rem;
    color: #5c6370;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0.35rem 0 0.05rem;
}
.mic-select-chip {
    --chip-col: #abb2bf;
    background: #2c313a;
    border: 1px solid #4b5263;
    color: #5c6370;
    padding: 0.22rem 0.6rem;
    border-radius: 4px;
    font-size: 0.88rem;
    font-family: inherit;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.mic-select-chip:hover { background: #383c44; color: #abb2bf; }
.mic-select-chip.active {
    background: #383c44;
    border-color: var(--chip-col);
    color: var(--chip-col);
}

.dialog-loop-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    cursor: pointer;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.dialog-btn {
    background: #4b5263;
    color: #abb2bf;
    border: none;
    padding: 0.5rem 1.2rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
}

.dialog-btn:hover { background: #5c6370; }
.dialog-btn-primary { background: #98c379; color: #282c34; }
.dialog-btn-primary:hover { background: #a8d389; }
.dialog-btn-danger { background: #e06c75; color: #282c34; }
.dialog-btn-danger:hover { background: #f07c85; }

/* ── Auto-Cue waveform marker ──────────────────────────────────────── */
.ws-auto-marker {
    position: absolute;
    top: 0; height: 100%;
    width: 2px;
    transform: translateX(-50%);
    pointer-events: none;
    background: rgba(152, 195, 121, 0.9);
    z-index: 6;
}
.shift-held .ws-auto-marker {
    pointer-events: auto;
    cursor: ew-resize;
    width: 8px;
}
.ws-auto-marker-label {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.62rem;
    color: #98c379;
    background: rgba(40, 44, 52, 0.8);
    padding: 1px 3px;
    border-radius: 2px;
    white-space: nowrap;
    font-family: monospace;
    line-height: 1.3;
}

@keyframes outro-pending-blink {
    0%, 100% { border-left-color: #e06c75; }
    50%       { border-left-color: rgba(224,108,117,0.15); }
}
.trigger-outro-pending {
    border-left: 5px #e06c75 solid !important;
    animation: outro-pending-blink 0.7s ease-in-out infinite;
}

.loop-dialog {
    background: #2c313a;
    border: 1px solid #4b5263;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    min-width: 260px;
    overflow: hidden;
}
.loop-dialog-option {
    display: block;
    width: 100%;
    background: none;
    border: none;
    border-bottom: 1px solid #383c44;
    color: #abb2bf;
    text-align: left;
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
}
.loop-dialog-option:last-child { border-bottom: none; }
.loop-dialog-option:hover { background: #383c44; }
.loop-dialog-option strong { display: block; }
.loop-dialog-option small { color: #5c6370; font-size: 0.78rem; }
.loop-dialog-danger { color: #e06c75 !important; }
.loop-dialog-danger:hover { background: rgba(224,108,117,0.15) !important; }

.parse-error-banner {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: #e06c75;
    color: #282c34;
    padding: 0.6rem 2.5rem 0.6rem 1rem;
    z-index: 99999;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.parse-error-banner strong { display: block; margin-bottom: 0.25rem; }
.parse-error-banner ul { margin: 0; padding-left: 1.25rem; }
.parse-error-banner li { font-family: monospace; font-size: 0.8rem; }
.parse-error-close {
    position: absolute; top: 0.4rem; right: 0.75rem;
    background: none; border: none; font-size: 1.3rem;
    cursor: pointer; color: #282c34; line-height: 1;
}
.trigger-parse-error {
    background: rgba(224,108,117,0.15);
    border-left: 4px solid #e06c75;
    color: #e06c75;
    font-family: monospace;
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
    margin: 0.25rem 0;
    border-radius: 0 4px 4px 0;
}

.tc-display {
    line-height: 3rem;
    font-size: 1.4rem;
    font-family: monospace;
    margin-right: 1rem;
    background-color: #282c34;
    border-radius: 5px;
    padding: 0 0.5rem;
    box-shadow: inset black 0 0 10px;
    color: #e5c07b;
    letter-spacing: 0.05em;
}
/* ── Scene Sidebar ─────────────────────────────────────────────────────── */
.sidebar-toggle-button {
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 101;
    margin: 0;
    transition: opacity 0.2s ease;
}
#scene-sidebar.open ~ .sidebar-toggle-button {
    opacity: 0;
    pointer-events: none;
}
#scene-sidebar.open ~ #script-content h1,
#scene-sidebar.open ~ #script-content h2 {
    padding-left: calc(240px + 1rem);
}
#scene-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    background: #1e2127;
    border-right: 1px solid #3e4451;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
}
#scene-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 16px rgba(0,0,0,0.5);
}
.scene-sidebar-header {
    padding: 0.85rem 1rem;
    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #5c6370;
    border-bottom: 1px solid #3e4451;
    flex-shrink: 0;
}
#scene-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.4rem 0;
}
#scene-list::-webkit-scrollbar { width: 4px; }
#scene-list::-webkit-scrollbar-track { background: transparent; }
#scene-list::-webkit-scrollbar-thumb { background: #3e4451; border-radius: 2px; }
.scene-link {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: #abb2bf;
    text-align: left;
    padding: 0.45rem 1rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    line-height: 1.3;
    border-left: 3px solid transparent;
    box-sizing: border-box;
}
.scene-link:hover {
    background: #2c313a;
    color: #e5c07b;
    border-left-color: #e5c07b;
}
.scene-link.scene-link-active {
    color: #e5c07b;
    border-left-color: #e5c07b;
}
.scene-link-sub {
    padding-left: 1.75rem;
    font-size: 0.78rem;
    color: #5c6370;
}
.scene-link-sub:hover { color: #abb2bf; }

/* ── Search Bar ────────────────────────────────────────────────────────── */
#search-bar {
    position: fixed;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: #2c313a;
    border: 1px solid #4b5263;
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
#search-bar.hidden { display: none; }
#search-input {
    background: #1e2127;
    border: 1px solid #3e4451;
    border-radius: 4px;
    color: #abb2bf;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.3rem 0.6rem;
    width: 220px;
    outline: none;
}
#search-input:focus { border-color: #61afef; }
#search-count {
    font-size: 0.78rem;
    color: #5c6370;
    min-width: 4rem;
    text-align: center;
}
#search-prev, #search-next, #search-close {
    background: none;
    border: none;
    color: #abb2bf;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    line-height: 1;
}
#search-prev:hover, #search-next:hover { background: #3e4451; }
#search-close { color: #5c6370; font-size: 1.2rem; }
#search-close:hover { color: #e06c75; background: none; }

mark.search-highlight {
    background: rgba(229, 192, 123, 0.3);
    color: inherit;
    border-radius: 2px;
}
mark.search-current {
    background: #e5c07b;
    color: #282c34;
    border-radius: 2px;
}

/* ── Inline Text Editor ─────────────────────────────────────────────────────── */

/* Pencil cursor while Shift is held over editable content */
body.shift-held #script-content [data-block-idx]:not(.trigger):not(.trigger-group) {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16'><path d='M2 14l1-4L11.5 1l2.5 2.5-8.5 8.5z' fill='%23e5c07b'/><path d='M14 3.5l-2-2 1.5-1 2 2z' fill='%23c07b20'/></svg>") 0 14, text;
}

/* Shared text/font base for both editor types */
.inline-editor {
    color: #abb2bf;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', 'Apple Symbols', 'Segoe UI Symbol', 'Segoe UI Emoji', 'Noto Sans Symbols', 'Noto Sans Symbols 2', sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    outline: none;
    box-sizing: border-box;
}
.inline-editor::placeholder { color: #5c6370; font-style: italic; }

/* Wrapper for existing-block editor — carries all the visual chrome */
.editor-wrapper {
    position: fixed;
    z-index: 200;
    background: #2c313a;
    border: 1.5px solid #e5c07b;
    border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.6);
    display: flex;
    align-items: flex-start;
}
.editor-wrapper .inline-editor {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    padding: 0.4rem 1rem;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: visible;
    min-height: 1.6em;
    cursor: text;
}
.editor-role-name {
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    border-radius: 3px;
    padding: 0 2px;
    transition: background 0.12s;
}
.editor-role-name:hover {
    background: rgba(255,255,255,0.1);
}
.editor-role-name::after {
    content: ' ';
}
.br-marker {
    color: #4b5263;
    font-size: 0.78em;
    user-select: none;
    pointer-events: none;
    letter-spacing: -0.05em;
}
.editor-stage-inline, .editor-stage-text {
    color: #7c8898;
    font-style: italic;
}
.editor-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px;
    border-left: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.editor-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 22px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    color: #5c6370;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.editor-btn:hover {
    color: #abb2bf;
    border-color: #4b5263;
    background: rgba(255,255,255,0.06);
}
.editor-btn-delete:hover {
    color: #e06c75;
    border-color: rgba(224,108,117,0.4);
    background: rgba(224,108,117,0.08);
}

/* New-block editor: wrapper holds the contenteditable + action buttons */
.empty-script-state {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 4rem 2rem 2rem;
    color: #5c6370;
}
.empty-script-buttons {
    display: flex;
    gap: 0.75rem;
}
.empty-script-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    background: #2c313a;
    border: 1px solid #383c44;
    border-radius: 5px;
    color: #abb2bf;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.empty-script-btn:hover { background: #353b45; border-color: #4a505a; }
.empty-script-hint {
    font-size: 0.82rem;
    color: #4a505a;
}
.empty-script-hint-link {
    color: #61afef;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.new-block-wrapper {
    display: flex;
    align-items: flex-start;
    margin: 0.3rem 0;
    background: #252c23;
    border: 1.5px solid #98c379;
    border-radius: 4px;
}
.new-block-controls {
    border-left-color: rgba(152, 195, 121, 0.2);
}
.inline-editor-new {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    padding: 0.4rem 1rem;
    min-height: 1.6em;
    white-space: pre-wrap;
    word-break: break-word;
}
.inline-editor-new:empty::before {
    content: attr(data-placeholder);
    color: #5c6370;
    font-style: italic;
    pointer-events: none;
}
.ac-ghost {
    color: #e5c07b;
    pointer-events: none;
    user-select: none;
}
.role-confirmed {
    font-weight: bold;
    user-select: none;
    cursor: pointer;
    border-radius: 2px;
    padding: 0 1px;
    transition: background 0.1s;
}
.role-confirmed:hover {
    background: rgba(255,255,255,0.1);
}
.role-separator {
    color: #5c6370;
    user-select: none;
    pointer-events: none;
}
/* Separator in the existing-block editor */
.editor-role-separator {
    color: #5c6370;
    user-select: none;
    pointer-events: none;
}
/* "/" separator between role names in the rendered script view */
.role-name-sep {
    color: #5c6370;
}
