:root {
    --bg: #121212;
    --surface: #1e1e1e;
    --surface-hover: #2c2c2c;
    --primary: #4caf50;
    --primary-hover: #388e3c;
    --text: #ffffff;
    --text-muted: #a0a0a0;
    --danger: #cf6679;
    --success: #03dac6;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.5);
    --radius: 8px;
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    overflow-x: hidden;
    font-size: 15px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

h1, h2, h3 { margin-top: 0; font-weight: 600; }
h1 { font-size: 1.3rem; margin-bottom: 0.8rem; }
h2 { font-size: 1rem; margin-bottom: 0.6rem; }
h3 { font-size: 0.9rem; margin-bottom: 0.4rem; }

label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

button {
    background-color: var(--primary);
    color: #000;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    font-weight: bold;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
button:active { transform: scale(0.98); }

.nav-btn {
    padding: 0.8rem;
}

button.danger { background-color: transparent; color: var(--danger); border: 1px solid var(--danger); }
button.danger:hover { background-color: var(--danger); color: #fff; }

button.secondary { background-color: transparent; color: var(--primary); border: 1px solid var(--primary); }
button.secondary:hover { background-color: var(--primary); color: #000; }

.btn-blackout {
    background: #222;
    color: #fff;
    border: 2px solid #555;
    font-size: 0.95rem;
    padding: 0.6rem;
    letter-spacing: 0.05em;
    transition: background 0.15s, border-color 0.15s;
}
.btn-blackout:hover { background: #111; border-color: #888; }
.btn-blackout.active {
    background: #cf6679;
    border-color: #cf6679;
    color: #fff;
}

.btn-tiny {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    border-radius: 4px;
    background: var(--success);
    color: #000;
    border: none;
    transition: all 0.2s ease;
}
.btn-tiny:hover { opacity: 0.85; filter: brightness(1.1); }
.btn-tiny:active { transform: scale(0.95); }

.btn-micro {
    padding: 0.15rem 0.35rem;
    font-size: 0.68rem;
    border-radius: 3px;
    background: #2a2a2a;
    color: var(--text-muted);
    border: 1px solid #444;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-micro:hover {
    background: #383838;
    color: #fff;
    border-color: #666;
}
.btn-micro:active {
    transform: scale(0.95);
}

#btnUploadFont {
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input[type="text"], input[type="file"], input[type="number"], select, textarea {
    background: #000;
    border: 1px solid #333;
    color: var(--text);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
    width: 100%;
    margin-bottom: 0.5rem;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}
input[type="text"]:focus, select:focus, textarea:focus, input[type="number"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
    outline: none;
}
input[type="number"] { -moz-appearance: textfield; }

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #333;
    outline: none;
    margin-bottom: 0.3rem;
    cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid #000;
}

/* Color picker */
.color-swatch-wrapper {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid #333;
    cursor: pointer;
}
.color-swatch-wrapper input[type="color"] {
    position: absolute;
    top: -8px; left: -8px;
    width: calc(100% + 16px);
    height: calc(100% + 16px);
    border: none;
    padding: 0;
    cursor: pointer;
}

/* Layout */
.dashboard {
    display: grid;
    grid-template-columns: 300px 1fr 320px;
    gap: 0.8rem;
}

.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    box-shadow: var(--shadow);
    margin-bottom: 0.8rem;
}

h1 { font-size: 1.3rem; margin-bottom: 0.8rem; }
h2 { font-size: 1rem; margin-bottom: 0.6rem; }
h3 { font-size: 0.9rem; margin-bottom: 0.4rem; }

/* ---- Layout Utilities ---- */
.btn-row {
    display: flex;
    gap: 0.5rem;
}
.btn-row > * { flex: 1; }
.full-width-btn { width: 100%; }

.inline-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.inline-row-small {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

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

.divider-top {
    border-top: 1px solid #333;
    padding-top: 0.8rem;
    margin-top: 0.2rem;
}

.muted-text { color: var(--text-muted); font-size: 0.8em; margin-bottom: 0.8rem; }
.muted-text-small { color: var(--text-muted); font-size: 0.75rem; font-weight: normal; margin-left: 0.5rem; }
.muted-text-tiny { color: var(--text-muted); font-size: 0.6rem; font-weight: normal; text-transform: none; letter-spacing: 0; margin-left: 0.2rem; }
.status-text { font-size: 0.85em; margin-top: 0.5rem; }

.link-right { float: right; color: var(--primary); font-size: 0.85rem; text-decoration: none; }
.hotkey-hint { font-size: 0.7rem; color: var(--text-muted); font-weight: normal; margin-left: 0.5rem; }

/* Show list */
#showsList {
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: #333 #111;
}
#showsList::-webkit-scrollbar {
    width: 6px;
}
#showsList::-webkit-scrollbar-track {
    background: #111;
    border-radius: 3px;
}
#showsList::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}
#showsList::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.list-item {
    padding: 0.3rem 0.6rem;
    background: #000;
    margin-bottom: 0.2rem;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid transparent;
    gap: 0.4rem;
    font-size: 0.85rem;
}
.list-item:hover { background: var(--surface-hover); }
.list-item.active { border-left-color: var(--primary); }
.list-item .btn-group { display: flex; gap: 0.3rem; flex-shrink: 0; }
.list-item .btn-group button { padding: 0.3rem 0.6rem; font-size: 0.75rem; }

.show-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    flex: 1;
}

.show-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    font-weight: 500;
}

.show-name-text:hover {
    color: var(--primary);
}

.btn-rename-show {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.85rem;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.6;
    border-radius: 3px;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.btn-rename-show:hover {
    opacity: 1;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.show-rename-container {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
}

.show-rename-input {
    flex: 1;
    min-width: 0;
    padding: 0.25rem 0.5rem;
    font-size: 0.82rem;
    background: #111;
    border: 1px solid var(--primary);
    border-radius: 4px;
    color: #fff;
    outline: none;
    box-shadow: 0 0 4px rgba(255, 179, 0, 0.3);
}

.show-rename-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.78rem;
    border-radius: 3px;
    cursor: pointer;
    line-height: 1;
}

/* ---- Preview Screen ---- */
.preview-screen {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border: 2px solid #333;
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    margin-bottom: 1rem;
    transition: aspect-ratio 0.2s ease;
}
.preview-screen.ratio-4-3 {
    aspect-ratio: 4 / 3;
}
.preview-screen.ratio-16-10 {
    aspect-ratio: 16 / 10;
}

/* Zone boundary dashed indicator */
.zone-boundary {
    position: absolute;
    border: 1px dashed rgba(76, 175, 80, 0.4);
    pointer-events: none;
    z-index: 2;
    transition: all 0.15s ease;
}

/* Text zone inside preview */
.preview-screen .projector-zone {
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: opacity 0.5s ease, transform 0.15s ease, top 0.15s ease, bottom 0.15s ease, left 0.15s ease, right 0.15s ease;
    z-index: 3;
    overflow: hidden;
}

/* Logo overlay inside preview */
.logo-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
}
.logo-overlay.visible { opacity: 1; }
.logo-overlay img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Blackout overlay inside preview */
.blackout-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #000;
    opacity: 0;
    pointer-events: none;
    z-index: 4; /* Below logo overlay (5) and text overlay (25) */
    transition: opacity 0.2s;
}
.blackout-overlay.active { opacity: 1; }

/* ---- Settings Grid ---- */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem 1rem;
    margin-top: 0.5rem;
}
.settings-grid.dense-grid {
    gap: 0.3rem 0.8rem;
}
.settings-grid .full-width { grid-column: 1 / -1; }

.slider-row { margin-bottom: 0.2rem; }
.slider-row .slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.1rem;
}
.slider-row .slider-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 3.5em;
    text-align: right;
}

.color-picker-row { gap: 1.5rem; margin-top: 0.2rem; }
.color-row { display: flex; align-items: center; gap: 0.6rem; }
.color-row .color-label { font-size: 0.85rem; color: var(--text-muted); }

.slide-counter {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.5rem;
}

/* ---- Projector (fullscreen display) ---- */
.projector-body {
    background: #000;
    color: #fff;
    margin: 0; padding: 0;
    overflow: hidden;
    width: 100vw; height: 100vh;
    position: relative;
    cursor: none;
}

.projector-zone {
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
    transition: opacity 0.5s ease, top 0.3s ease, bottom 0.3s ease, left 0.3s ease, right 0.3s ease;
}

.slide-speaker {
    text-transform: uppercase;
    font-weight: bold;
    opacity: 0.75;
    margin-bottom: 0.2em;
}

.slide-text {
    font-weight: 500;
    text-shadow: 0 4px 12px rgba(0,0,0,0.8);
    white-space: pre-line;
}

/* Projector logo overlay */
.proj-logo-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    box-sizing: border-box;
    overflow: hidden;
}
.proj-logo-overlay.visible { opacity: 1; }
.proj-logo-overlay img {
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
}

/* Projector text overlay */
.proj-text-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 25; /* Between logo and blackout */
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    box-sizing: border-box;
    overflow: hidden;
}
.proj-text-overlay.visible { opacity: 1; }
.proj-text-overlay div {
    width: 100%;
    box-sizing: border-box;
}

/* Projector blackout */
.proj-blackout {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #000;
    opacity: 0;
    pointer-events: none;
    z-index: 15; /* Below logo and text overlay, but above slide text */
    transition: opacity 0.2s;
}
.proj-blackout.active { opacity: 1; }

/* Fullscreen overlay prompt */
.fullscreen-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.92);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    cursor: pointer;
    transition: opacity 0.3s;
}
.fullscreen-overlay h2 { color: #fff; font-size: 2rem; margin-bottom: 0.5rem; }
.fullscreen-overlay p { color: #aaa; font-size: 1.1rem; }
.fullscreen-overlay.hidden { opacity: 0; pointer-events: none; }

/* ---- Logo Gallery ---- */
.logo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    background: #000;
    border-radius: var(--radius);
    padding: 0.5rem;
    border: 1px solid #222;
}
.logo-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem;
    border-radius: 6px;
    border: 2px solid transparent;
    background: #111;
    cursor: pointer;
    transition: border-color 0.15s;
}
.logo-item:hover { border-color: #555; }
.logo-item.selected { border-color: var(--primary); }
.logo-item img {
    width: 100%;
    height: 50px;
    object-fit: contain;
    border-radius: 4px;
}
.logo-item .logo-name {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}
.logo-item .logo-del {
    font-size: 0.65rem;
    padding: 0.1rem 0.3rem;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 3px;
}
.logo-item .logo-del:hover { background: var(--danger); color: #fff; }

/* ---- Character Colors Grid ---- */
.char-colors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.4rem 0.6rem;
}

/* ---- Coming Up Preview Line ---- */
.coming-up-line {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.6rem;
    background: #000;
    border-left: 4px solid var(--primary);
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    align-items: start;
}
.coming-up-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    flex-shrink: 0;
    padding-top: 1px;
}
.coming-up-text {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.35;
    word-break: break-word;
    max-height: 5.5em;
    overflow-y: auto;
    max-width: 100%;
}
.coming-up-item {
    margin-bottom: 0.35rem;
    line-height: 1.35;
}
.coming-up-item:last-child {
    margin-bottom: 0;
}
.coming-up-slide-num {
    color: var(--success, #03dac6);
    font-weight: 700;
    margin-right: 0.45rem;
    display: inline-block;
    letter-spacing: 0.02em;
}
.coming-up-slide-text {
    color: var(--text);
}
.char-color-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: #000;
    border: 1px solid #222;
    border-radius: var(--radius);
    padding: 0.35rem 0.5rem;
}
.char-color-item span {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.72rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.char-color-item select.char-font-select {
    max-width: 95px;
    flex: 0 1 95px;
    margin: 0;
    padding: 0.2rem 0.25rem;
    font-size: 0.7rem;
    background: #181818;
    color: #eee;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    cursor: pointer;
}
.char-color-item select.char-font-select:focus {
    border-color: var(--primary);
    outline: none;
}
.char-color-item .color-swatch-wrapper {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}
.char-spacing-btn {
    flex-shrink: 0;
    padding: 0 0.45rem;
    height: 28px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    color: #aaa;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.char-spacing-btn:hover,
.char-spacing-btn.active {
    background: #0d2a1a;
    border-color: var(--primary);
    color: var(--primary);
}
.char-wrapper {
    grid-column: auto;
    transition: background 0.15s, border-color 0.15s;
    border-radius: var(--radius);
}
.char-wrapper.expanded {
    grid-column: 1 / -1 !important;
    background: #0d1a12;
    border: 1px solid var(--primary);
    padding: 0.6rem;
}
.char-spacing-panel {
    display: none;
    background: #080e0a;
    border: 1px solid #1c3d28;
    border-radius: 6px;
    padding: 0.8rem 1rem 0.7rem;
    margin-top: 0.5rem;
}
.char-spacing-panel.open { display: block; }
.char-spacing-panel .sp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.65rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid #162e1e;
}
.char-spacing-panel .sp-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.char-spacing-panel .sp-close {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 0.3rem;
    line-height: 1;
}
.char-spacing-panel .sp-close:hover { color: #fff; }
.char-spacing-panel .sp-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.6rem;
}
.char-spacing-panel .sp-row:last-child { margin-bottom: 0; }
.char-spacing-panel .sp-label {
    min-width: 105px;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
}
.char-spacing-panel .sp-slider-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.char-spacing-panel .sp-slider-wrap input[type=range] {
    flex: 1;
    min-width: 140px;
    accent-color: var(--primary);
    cursor: pointer;
    height: 6px;
}
.char-spacing-panel .sp-num-input {
    width: 62px;
    padding: 0.25rem 0.35rem;
    background: #151515;
    border: 1px solid #333;
    border-radius: 4px;
    color: #fff;
    font-size: 0.82rem;
    text-align: right;
    font-family: inherit;
    flex-shrink: 0;
}
.char-spacing-panel .sp-num-input:focus {
    border-color: var(--primary);
    outline: none;
}
.char-spacing-panel .sp-unit {
    min-width: 22px;
    font-size: 0.74rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.char-spacing-panel .sp-reset {
    font-size: 0.75rem;
    padding: 0.2rem 0.45rem;
    background: #181818;
    border: 1px solid #333;
    border-radius: 4px;
    color: #888;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
}
.char-spacing-panel .sp-reset:hover { border-color: var(--primary); color: var(--primary); }

.char-spacing-panel .sp-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 0.8rem;
    padding-top: 0.6rem;
    border-top: 1px solid #162e1e;
}
.char-spacing-panel .sp-apply-btn {
    background: var(--primary);
    color: #000;
    border: none;
    border-radius: 4px;
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}
.char-spacing-panel .sp-apply-btn:hover {
    filter: brightness(1.15);
}
.char-spacing-panel .sp-apply-btn.applied {
    background: #00e676;
    color: #000;
}
.char-spacing-panel .sp-reset-all-btn {
    background: #181818;
    color: #aaa;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
}
.char-spacing-panel .sp-reset-all-btn:hover {
    color: #fff;
    border-color: #555;
}

/* Split controls for font size slider + font selector */
.font-control-split-row {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
    margin-bottom: 0.6rem;
}
.font-control-split-row .slider-col {
    flex: 1.2;
    min-width: 0;
}
.font-control-split-row .font-family-col {
    flex: 1;
    min-width: 0;
}
.font-control-split-row .font-family-col select.slide-font-select {
    width: 100%;
    margin: 0;
    padding: 0.35rem 0.5rem;
    font-size: 0.78rem;
    background: #181818;
    color: #eee;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    cursor: pointer;
}
.font-control-split-row .font-family-col select.slide-font-select:focus {
    border-color: var(--primary);
    outline: none;
}

/* ---- Projector Stage & Warping ---- */
.projector-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    transform-origin: 0 0 0;
    will-change: transform;
    pointer-events: none;
}

/* ---- Calibration Grid (White Screen, Crosshairs, Proportions) ---- */
.proj-test-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.proj-test-grid.visible {
    opacity: 1;
    pointer-events: auto;
}
.calibration-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ---- 4-Corner Projection Mapping Dashboard Widget ---- */
.quad-editor-container {
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: var(--radius);
    padding: 0.9rem 0.8rem 0.7rem;
    margin-bottom: 0.8rem;
}
/* Aspect Ratio Button Controls */
.btn-aspect-ratio {
    padding: 0.22rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 4px;
    border: 1px solid #333;
    background: #111;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-aspect-ratio:hover {
    color: #fff;
    border-color: #555;
    background: #1e1e1e;
}
.btn-aspect-ratio.active {
    background: #03dac6;
    color: #000;
    border-color: #03dac6;
}

.quad-canvas-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio default */
    background: #050505;
    border: 1px solid #222;
    border-radius: 4px;
    overflow: visible;
    touch-action: none;
    user-select: none;
    transition: padding-top 0.2s ease;
}
.quad-canvas-wrapper.ratio-4-3 {
    padding-top: 75%; /* 4:3 Aspect Ratio */
}
.quad-canvas-wrapper.ratio-16-10 {
    padding-top: 62.5%; /* 16:10 Aspect Ratio */
}
.quad-editor-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}
.quad-corner-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    z-index: 10;
    border: 2px solid #000;
    box-shadow: 0 0 5px rgba(0,0,0,0.9);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    touch-action: none;
}
.quad-corner-handle.handle-tl { background: #03dac6; }
.quad-corner-handle.handle-tr { background: #4caf50; }
.quad-corner-handle.handle-br { background: #ffb74d; }
.quad-corner-handle.handle-bl { background: #cf6679; }

.quad-corner-handle:hover {
    transform: translate(-50%, -50%) scale(1.35);
    box-shadow: 0 0 8px #fff;
    filter: brightness(1.2);
}
.quad-corner-handle:active, .quad-corner-handle.dragging {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.5);
    background: #ffffff !important;
    box-shadow: 0 0 10px var(--primary);
}

/* Draggable Edge Lines & Hit Areas */
.quad-edge-line {
    stroke: transparent;
    stroke-width: 14px;
    cursor: grab;
    pointer-events: stroke;
    transition: stroke 0.15s ease;
}
.quad-edge-line.edge-top, .quad-edge-line.edge-bottom {
    cursor: ns-resize;
}
.quad-edge-line.edge-left, .quad-edge-line.edge-right {
    cursor: ew-resize;
}
.quad-edge-line:hover, .quad-edge-line.dragging {
    stroke: rgba(3, 218, 198, 0.45);
}

/* Edge Midpoint Drag Handles */
.quad-edge-handle {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: grab;
    z-index: 9;
    border: 1.5px solid #03dac6;
    background: #111;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    touch-action: none;
    border-radius: 3px;
}
.quad-edge-handle.handle-edge-top, .quad-edge-handle.handle-edge-bottom {
    width: 20px;
    height: 8px;
    cursor: ns-resize;
}
.quad-edge-handle.handle-edge-left, .quad-edge-handle.handle-edge-right {
    width: 8px;
    height: 20px;
    cursor: ew-resize;
}
.quad-edge-handle:hover {
    transform: translate(-50%, -50%) scale(1.3);
    background: #03dac6;
    border-color: #ffffff;
    box-shadow: 0 0 8px #03dac6;
}
.quad-edge-handle:active, .quad-edge-handle.dragging {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.4);
    background: #ffffff !important;
    border-color: #03dac6 !important;
    box-shadow: 0 0 12px #03dac6;
}

/* Corner Precision Input Cards */
.corners-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.6rem;
}
.corner-card {
    background: #181818;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 0.5rem;
}
.corner-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.3rem;
}
.corner-tag {
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    background: #282828;
}
.corner-tag.tl { color: #03dac6; border-left: 2px solid #03dac6; }
.corner-tag.tr { color: #4caf50; border-left: 2px solid #4caf50; }
.corner-tag.br { color: #ffb74d; border-left: 2px solid #ffb74d; }
.corner-tag.bl { color: #cf6679; border-left: 2px solid #cf6679; }

.corner-inputs-row {
    display: flex;
    gap: 0.4rem;
}
.corner-coord-group {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.2rem;
}
.corner-coord-group label {
    font-size: 0.65rem;
    margin: 0;
    color: var(--text-muted);
}
.corner-coord-group input[type="number"] {
    width: 100%;
    padding: 0.25rem 0.3rem;
    font-size: 0.75rem;
    margin: 0;
    text-align: center;
}

/* Toggle Switch */
.toggle-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}
.toggle-switch-row label {
    margin: 0;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text);
    text-transform: none;
    letter-spacing: normal;
}
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider-switch {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #333;
    transition: .3s;
    border-radius: 22px;
}
.slider-switch:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}
.switch input:checked + .slider-switch {
    background-color: var(--success);
}
.switch input:checked + .slider-switch:before {
    transform: translateX(18px);
    background-color: #000;
}

/* Script Parsing Options Panel */
.parsing-options-box {
    background: #161616;
    border: 1px solid #262626;
    border-radius: 6px;
    padding: 0.6rem;
    margin-top: 0.6rem;
    margin-bottom: 0.6rem;
}
.parsing-options-box summary {
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    color: var(--text-muted);
}
.parsing-options-box summary:hover {
    color: var(--text);
}

/* ---- Multi-Column Simultaneous Dialogue ---- */
.multi-column-grid {
    display: grid;
    width: 100%;
    height: auto;
    max-height: 100%;
    align-self: center;
    align-items: stretch;
    justify-content: center;
    gap: 0;
}
.multi-column-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
}
.multi-column-grid.cols-3 {
    grid-template-columns: 1fr 1fr 1fr;
}
.dialogue-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 1.5vw;
    box-sizing: border-box;
    text-align: center;
}
/* Thin grey divider line between columns, strictly bounded by the dialogue block height */
.dialogue-column:not(:last-child) {
    border-right: 1.5px solid rgba(160, 160, 160, 0.55);
}
.preview-screen .dialogue-column:not(:last-child) {
    border-right: 1px solid rgba(160, 160, 160, 0.55);
}
.multi-column-grid.cols-2 .slide-text {
    font-size: 0.88em;
}
.multi-column-grid.cols-3 .slide-text {
    font-size: 0.78em;
}

/* Slide Editor Multi-Column Boxes */
.col-edit-box {
    background: #181818;
    padding: 0.6rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border: 1px solid #333;
}
.col-edit-header {
    font-size: 0.75rem;
    font-weight: bold;
    margin-bottom: 0.3rem;
    display: block;
}

@media (max-width: 900px) {
    .dashboard { grid-template-columns: 1fr; }
    .nav-btn {
        padding: 2.5rem 1rem !important;
        font-size: 1.2rem !important;
    }
}

/* ---- Help & Documentation Modal ---- */
.help-modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.help-modal-content {
    background: #181818;
    border: 1px solid #3d3252;
    border-radius: 12px;
    max-width: 860px;
    width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(199, 146, 234, 0.2);
    overflow: hidden;
}
.help-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.4rem;
    border-bottom: 1px solid #2d263b;
    background: #1f182a;
    flex-shrink: 0;
}
.help-modal-body {
    padding: 1.2rem 1.4rem;
    overflow-y: auto;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text);
    scroll-behavior: smooth;
}
.help-quick-nav {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid #282828;
    position: sticky;
    top: 0;
    background: #181818;
    z-index: 2;
}
.help-nav-pill {
    background: #242424;
    border: 1px solid #3a3a3a;
    color: #c792ea;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}
.help-nav-pill:hover {
    background: #3d2c56;
    border-color: #7b4fb5;
    color: #fff;
}
.help-section {
    margin-bottom: 1.4rem;
    background: #131313;
    border: 1px solid #262626;
    border-radius: 8px;
    padding: 1rem 1.2rem;
}
.help-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin-top: 0;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid #222;
    padding-bottom: 0.5rem;
}
.help-hotkey-table {
    width: 100%;
    border-collapse: collapse;
}
.help-hotkey-table tr {
    border-bottom: 1px solid #202020;
}
.help-hotkey-table tr:last-child {
    border-bottom: none;
}
.help-hotkey-table td {
    padding: 0.5rem 0.4rem;
    vertical-align: middle;
}
.help-hotkey-table td.key-col {
    white-space: nowrap;
    width: 190px;
}
kbd {
    background: #252528;
    border: 1px solid #44444a;
    border-bottom: 2px solid #555560;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
    color: #03dac6;
    display: inline-block;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    line-height: 1.2;
}
.help-feature-list {
    margin: 0;
    padding-left: 1.2rem;
}
.help-feature-list li {
    margin-bottom: 0.55rem;
    color: #cccccc;
}
.help-feature-list li strong {
    color: #ffffff;
}


