:root {
    /* Crash Out brand — neon pink / yellow / cyan from client art */
    --bg: #f6f3f7;
    --surface: #ffffff;
    --surface-2: #fbf7fa;
    --border: #e8d5e0;
    --text: #1a1220;
    --muted: #6b5a66;
    --brand: #ff2d8a;
    --brand-hot: #ff007f;
    --brand-yellow: #ffe600;
    --brand-orange: #ff8a00;
    --brand-cyan: #22d3ee;
    --brand-soft: #ffe4f1;
    --brand-ink: #8b0450;
    --primary: #ff2d8a;
    --primary-hover: #e01274;
    --primary-text: #ffffff;
    --ghost: #f3e8ef;
    --ghost-hover: #ebd7e4;
    --ok: #2f6b4f;
    --ok-bg: #e7f2ec;
    --warn: #b45309;
    --warn-bg: #fff7ed;
    --info: #0891b2;
    --info-bg: #ecfeff;
    --danger: #be123c;
    --danger-bg: #fff1f2;
    --shadow: 0 1px 2px rgba(40, 8, 28, 0.05), 0 6px 18px rgba(255, 0, 127, 0.06);
    --radius: 10px;
    --radius-sm: 8px;
    --font: "IBM Plex Sans", "Segoe UI", sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
    --header-h: 72px;
    --sidebar-w: 232px;
    --max: 1280px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(circle at 12% -10%, rgba(255, 0, 127, 0.14), transparent 42%),
        radial-gradient(circle at 88% 0%, rgba(255, 230, 0, 0.12), transparent 36%),
        radial-gradient(circle at 70% 100%, rgba(34, 211, 238, 0.08), transparent 40%),
        linear-gradient(180deg, #fff7fb 0%, var(--bg) 42%, #f0eef4 100%);
    min-height: 100vh;
    line-height: 1.45;
}

img,
video {
    max-width: 100%;
    display: block;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700 !important;
    letter-spacing: -0.015em;
    color: var(--text);
}

h1 {
    font-size: 1.65rem;
    line-height: 1.2;
}

h2 {
    font-size: 1.25rem;
    line-height: 1.25;
}

h3 {
    font-size: 1.05rem;
    line-height: 1.3;
}

/* Sidebar Hamburger Button & Mobile Drawer Styles */
.sidebar-toggle-btn {
    display: none;
    position: fixed;
    top: 0.85rem;
    left: 0.85rem;
    z-index: 99;
    width: 40px;
    height: 40px;
    padding: 9px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 14px rgba(255, 0, 127, 0.12);
    cursor: pointer;
    flex-direction: column;
    justify-content: space-between;
    transition: background 0.15s ease, transform 0.15s ease;
}

.sidebar-toggle-btn:hover {
    background: var(--brand-soft);
    border-color: var(--brand);
}

.hamburger-line {
    display: block;
    width: 100%;
    height: 2.5px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(20, 10, 24, 0.45);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

button,
input,
textarea,
summary {
    font: inherit;
}

a {
    color: var(--info);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.busy-bar {
    position: fixed;
    inset: 0 0 auto 0;
    height: 3px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    background: transparent;
}

.busy-bar.htmx-request {
    opacity: 1;
}

.busy-bar-fill {
    height: 100%;
    width: 35%;
    background: linear-gradient(90deg, var(--brand-cyan), var(--brand-hot), var(--brand-yellow));
    animation: busy-slide 1.1s ease-in-out infinite;
}

@keyframes busy-slide {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
}

.app-shell {
    min-height: 100vh;
}

.site-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.15rem 0.9rem 1rem;
    background:
        linear-gradient(180deg, rgba(255, 252, 254, 0.98) 0%, rgba(255, 247, 251, 0.96) 55%, rgba(248, 240, 246, 0.98) 100%);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(255, 0, 127, 0.04);
    overflow-y: auto;
}

/* Sidebar Credits Badge Section */
.sidebar-credits-panel {
    display: block;
    margin: 0.5rem 0;
    padding: 0.75rem 0.85rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 240, 248, 0.95));
    border: 1px solid #fed7ea;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(255, 0, 127, 0.05);
    text-decoration: none;
    color: inherit;
    transition: all 0.18s ease;
    cursor: pointer;
}

.sidebar-credits-panel:hover {
    border-color: var(--brand);
    background: linear-gradient(135deg, #ffffff, #fff0f7);
    box-shadow: 0 4px 14px rgba(255, 0, 127, 0.14);
    transform: translateY(-1px);
    text-decoration: none;
}

.sidebar-credits-panel.active {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(255, 0, 127, 0.25);
    background: linear-gradient(135deg, #fff5fa, #ffe8f3);
}

.credits-panel-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--brand);
    margin-bottom: 0.25rem;
}

.credits-panel-icon {
    font-size: 0.9rem;
}

.credits-panel-val {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
}

.credits-panel-val strong {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.credits-unit {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 500;
}

.credits-panel-sub {
    font-size: 0.72rem;
    margin-top: 0.2rem;
}

.app-main {
    min-width: 0;
    min-height: 100vh;
    margin-left: var(--sidebar-w);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    padding: 0.15rem 0.35rem 0.35rem;
}

.home-wrap {
    max-width: var(--max);
    margin: 0 auto;
    padding: 1.5rem 1.25rem 2.5rem;
}

.home-hero {
    margin-bottom: 1.25rem;
}

.home-title {
    margin: 0.2rem 0 0.35rem;
    font-size: clamp(1.4rem, 3vw, 1.9rem);
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.9rem;
}

.catalog-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.05rem 1.1rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.catalog-card h2 {
    margin: 0.15rem 0 0;
    font-size: 1.15rem;
    line-height: 1.25;
}

.catalog-sub {
    margin: 0;
    color: var(--brand-ink);
    font-weight: 600;
    font-size: 0.88rem;
}

.catalog-card-top,
.catalog-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.catalog-meta {
    color: var(--muted);
    font-size: 0.82rem;
    margin-top: 0.25rem;
}

.catalog-actions {
    margin-top: auto;
    padding-top: 0.65rem;
}

.catalog-actions .btn {
    width: 100%;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--brand-hot);
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(255, 230, 0, 0.55);
    background: #0a0a0a;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-title {
    font-weight: 700;
    font-size: 0.98rem;
    letter-spacing: 0.01em;
}

.brand-title-crash {
    color: var(--text);
}

.brand-title-out {
    color: var(--brand-hot);
}

.brand-sub {
    display: block;
    font-size: 0.72rem;
    margin-top: 0.1rem;
}

.step-item.is-disabled,
.step-item:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.35);
}

.stage-queue .panel-header-compact {
    margin-bottom: 0.55rem;
}

.video-queue-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.video-queue-row {
    display: flex;
    align-items: stretch;
    gap: 0.3rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    overflow: hidden;
}

.video-queue-row.is-active {
    border-color: var(--brand-hot);
    background: var(--brand-soft);
    box-shadow: inset 0 0 0 1px #ff9fce;
}

.video-queue-select {
    appearance: none;
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: inherit;
    padding: 0.5rem 0.65rem;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
}

.video-queue-num {
    flex: 0 0 1.7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    margin-top: 0.05rem;
    border-radius: 999px;
    background: var(--brand-hot);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.video-add-details {
    position: relative;
}

.video-add-details > summary {
    list-style: none;
    cursor: pointer;
}

.video-add-details > summary::-webkit-details-marker {
    display: none;
}

.video-add-form {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    z-index: 20;
    width: min(20rem, 78vw);
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface, #fff);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.video-add-form .field {
    margin: 0;
}

.video-add-form label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    color: var(--muted);
}

.video-queue-select:hover {
    background: rgba(15, 118, 110, 0.05);
}

.video-queue-arrow,
.video-queue-delete {
    appearance: none;
    flex: 0 0 2.4rem;
    border: 0;
    border-left: 1px solid var(--border);
    background: var(--surface);
    color: var(--brand-ink);
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-icon {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    transition: transform 0.15s ease, stroke 0.15s ease;
}

.video-queue-delete:hover .delete-icon {
    transform: scale(1.1);
}

.video-queue-arrow:hover {
    background: var(--brand-soft);
    color: var(--brand);
}

.video-queue-delete {
    color: #b91c1c;
    font-size: 0.95rem;
}

.video-queue-delete:hover {
    background: #fef2f2;
    color: #991b1b;
}

.video-queue-row.is-active .video-queue-arrow,
.video-queue-row.is-active .video-queue-delete {
    border-left-color: #ff9fce;
    background: var(--brand-soft);
}

.video-queue-row.is-active .video-queue-delete:hover {
    background: #fef2f2;
}

.video-queue-copy {
    min-width: 0;
}

.video-queue-copy h3 {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.25;
}

.video-queue-copy p {
    margin: 0.12rem 0 0.3rem;
    color: var(--muted);
    font-size: 0.8rem;
}

.video-queue-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.stage-locked .locked-state {
    background: #f3f4f6;
    color: var(--muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-size: 0.8rem;
}

.status-chip .label {
    color: var(--muted);
}

.auth-badge {
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: var(--ghost);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.auth-badge.ok { background: var(--ok-bg); color: var(--ok); }
.auth-badge.warn { background: var(--warn-bg); color: var(--warn); }
.auth-badge.bad { background: var(--danger-bg); color: var(--danger); }

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.9rem;
    background: var(--ghost);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-weight: 550;
    font-size: 0.9rem;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.btn:hover {
    background: var(--ghost-hover);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-text);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-ghost {
    background: var(--surface);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--surface-2);
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}

.stepper-bar {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    max-width: var(--max);
    margin: 0 auto 0.65rem;
    overflow: hidden;
}

.stepper {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.55rem 0.85rem;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.7rem;
    cursor: pointer;
    color: var(--muted);
    flex: 0 0 auto;
}

.step-item:hover {
    background: var(--surface-2);
}

.step-item.active {
    background: var(--brand-soft);
    border-color: #ff9fce;
    color: var(--text);
}

.step-item.completed .step-num {
    background: var(--ok);
    color: #fff;
}

.step-num {
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--ghost);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 700;
}

.step-item.active .step-num {
    background: var(--primary);
    color: #fff;
}

.step-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
}

.step-title {
    font-size: 0.86rem;
    font-weight: 600;
    color: inherit;
}

.step-sub {
    font-size: 0.72rem;
}

.meta-strip {
    display: none !important;
}

.meta-sep {
    margin: 0 0.35rem;
    opacity: 0.5;
}

.meta-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.35rem;
    min-width: 0;
}

.meta-ep-label {
    white-space: nowrap;
}

.meta-title-edit {
    max-width: min(28rem, 55vw);
}

.meta-title-edit .ep-title-input {
    max-width: 22rem;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
}

.main-wrapper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1rem;
    padding: 0 0 2rem;
    max-width: var(--max);
    margin: 0 auto;
}

.main-wrapper-single {
    grid-template-columns: minmax(0, 1fr);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
}

.stage-card {
    padding: 1.15rem 1.2rem 1.35rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.panel-kicker {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.panel-title {
    margin: 0;
    font-size: clamp(1.2rem, 2.4vw, 1.55rem);
    line-height: 1.2;
}

.panel-desc {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: flex-end;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: var(--ghost);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }

.concept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.85rem;
}

.concept-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
}

@media (max-width: 1100px) {
    .concept-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .concept-grid-3 {
        grid-template-columns: 1fr;
    }
}

.pitch-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.pitch-card .pitch-sources {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-top: 0.15rem;
}

.pitch-card.pitch-sensitive {
    border-color: #d4a373;
    background: #fff8f0;
}

.badge-warn {
    background: #f3d2b3;
    color: #7a3e0c;
}

.concept-card[data-concept-card] {
    cursor: default;
    position: relative;
}

.concept-top-left {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    min-width: 0;
}

.concept-inline-form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
}

.concept-inline-block {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    min-width: 0;
}

.concept-inline-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
}

.concept-inline {
    width: 100%;
    margin: 0;
    padding: 0.15rem 0.2rem;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    box-shadow: none;
    outline: none;
    resize: none;
    overflow: hidden;
    font: inherit;
    color: inherit;
    text-align: left;
}

.concept-inline:hover {
    background: rgba(0, 0, 0, 0.02);
}

.concept-inline:focus {
    border-color: #c5ced8;
    background: #fff;
}

.concept-inline-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}

.concept-inline-hook {
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 500;
    line-height: 1.45;
}

.concept-inline-body {
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.45;
    min-height: 3.2rem;
}

.concept-inline-angle {
    min-height: 7.5rem;
    white-space: pre-wrap;
}

.concept-readonly {
    margin: 0;
    padding: 0.15rem 0.2rem;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.4;
    word-break: break-word;
}

.concept-inline-synopsis {
    color: var(--muted);
    font-size: 0.8rem;
    font-style: italic;
    line-height: 1.4;
}

.concept-inline-meta {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.concept-inline::placeholder {
    color: #b0b8c2;
    font-style: italic;
    font-weight: 400;
}

.concept-card {
    text-align: left;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 1rem 1.05rem;
    cursor: pointer;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 100%;
}

.concept-card:hover {
    border-color: #b7c0cc;
}

.concept-card.selected {
    border-color: #8fa0b3;
    background: #f3f6f9;
    box-shadow: inset 0 0 0 1px #8fa0b3;
}

.concept-card-empty {
    opacity: 0.55;
    cursor: default;
    background: #f3f4f6;
    border-style: dashed;
}

.concept-card-empty h3 {
    color: var(--muted);
    font-weight: 600;
}

.script-prompt-doc {
    margin: 0;
    padding: 1rem 1.05rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fafbfc;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: min(70vh, 720px);
    overflow: auto;
}

.script-edit-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.script-edit-hint {
    margin: 0;
}

.script-prompt-editor {
    width: 100%;
    min-height: min(55vh, 520px);
    margin: 0;
    padding: 1rem 1.05rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fafbfc;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.55;
    resize: vertical;
    box-sizing: border-box;
}

.script-prompt-editor:focus {
    outline: 2px solid color-mix(in srgb, var(--brand, #2f5d50) 35%, transparent);
    outline-offset: 1px;
}

.script-edit-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.script-clip-actions {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid color-mix(in srgb, var(--line, #d5d0c8) 80%, transparent);
}

.script-save-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.concept-card h3 {
    margin: 0.15rem 0 0.2rem;
    font-size: 1rem;
    line-height: 1.3;
}

.concept-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.concept-hook {
    color: var(--text) !important;
    font-size: 0.84rem !important;
    font-weight: 500;
}

.concept-premise {
    display: -webkit-box;
    -webkit-line-clamp: 8;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.concept-synopsis {
    font-size: 0.8rem !important;
    font-style: italic;
}

.concept-top {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.concept-meta {
    margin-top: 0.15rem;
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.4;
}

.merch-box,
.engine-banner {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    margin-bottom: 1rem;
}

.merch-quote {
    font-size: 1.15rem;
    font-weight: 650;
    margin-top: 0.35rem;
}

.scene-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.scene-chip-static {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.75rem;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.85rem;
}

.scene-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.9rem;
    align-items: stretch;
}

.scene-tab {
    appearance: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.7rem;
    background: var(--surface);
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-align: left;
    min-width: 0;
    min-height: 3.4rem;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.scene-tab-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.55rem;
    height: 1.65rem;
    border-radius: 999px;
    background: var(--ghost);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
}

.scene-tab-copy {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    min-width: 0;
}

.scene-tab-copy strong {
    font-size: 0.82rem;
    font-weight: 650;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scene-tab-copy span {
    color: var(--muted);
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scene-tab:hover {
    background: var(--surface-2);
    border-color: #b7c0cc;
}

.scene-tab.active {
    background: var(--brand-soft);
    border-color: #5eead4;
    box-shadow: inset 0 0 0 1px #5eead4;
}

.scene-tab.active .scene-tab-num {
    background: var(--brand);
    color: #fff;
}

.scene-tab.active .scene-tab-copy strong {
    color: var(--brand-ink);
}

.script-scene-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 0.9rem 1rem;
}

.script-scene-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 0.85rem;
}

.script-edit-form .script-scene-meta,
.script-edit-meta {
    justify-content: space-between;
    align-items: center;
}

.script-edit-heading {
    min-width: 0;
}

.script-edit-heading .panel-kicker {
    margin: 0;
}

.script-edit-heading .script-scene-title {
    margin: 0.1rem 0 0;
    font-size: 1.05rem;
}

.script-scene-title {
    margin: 0.15rem 0 0;
    font-size: 1.15rem;
    line-height: 1.25;
}

.script-detail-block {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.script-detail-block .label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.script-detail-block p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text);
}

.script-scene-panel .dialogue-list {
    margin-top: 0.35rem;
}

.muted { color: var(--muted); }

.dialogue-list,
.seeding-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.dialogue-line,
.seeding-card {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.seeding-card {
    grid-template-columns: 1fr;
}

.char-avatar-badge img {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.dialogue-meta,
.seeding-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin-bottom: 0.3rem;
}

.dialogue-char-name {
    font-weight: 650;
}

.dialogue-text {
    font-size: 0.95rem;
}

.dialogue-camera {
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.8rem;
}

.section-block {
    margin-top: 1.15rem;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.section-head h3 {
    margin: 0;
    font-size: 1rem;
}

.section-head p {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.scene-videos-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    align-items: stretch;
}

.scene-video-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.7rem;
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-width: 0;
    height: 100%;
}

.scene-video-head {
    display: flex;
    justify-content: space-between;
    gap: 0.4rem;
    align-items: flex-start;
    font-size: 0.86rem;
    min-height: 2.6rem;
}

.scene-video-head strong {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.25;
    font-size: 0.82rem;
    font-weight: 650;
}

.scene-video-head .badge {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.scene-video-frame,
.scene-video-placeholder {
    width: 100%;
    aspect-ratio: 9 / 16;
    flex: 0 0 auto;
    border-radius: 6px;
    overflow: hidden;
    background: #111827;
}

.scene-video-frame {
    position: relative;
    border: 1px solid #111827;
}

.scene-video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #111827;
}

.scene-video-placeholder {
    border: 1px dashed var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    color: var(--muted);
    background: #fafbfc;
    padding: 0.75rem;
    text-align: center;
    font-size: 0.85rem;
}

.scene-video-meta {
    min-height: 1.1rem;
    font-size: 0.75rem;
}

.scene-video-card > .btn {
    margin-top: auto;
    width: 100%;
}

.scene-video-placeholder.tall {
    aspect-ratio: 9 / 16;
    min-height: 280px;
}

.master-merged-wrapper {
    display: grid;
    grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
    gap: 1rem;
}

.master-merged-player-box {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #111827;
    aspect-ratio: 9 / 16;
}

.master-merged-player-box video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #111827;
}

.master-controls-pane {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.master-title-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
}

.master-title {
    font-weight: 700;
}

.timeline-scrubber-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
}

.timeline-scene-chip {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.45rem;
    cursor: pointer;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.78rem;
}

.timeline-scene-chip span {
    color: var(--muted);
}

.timeline-scene-chip.active,
.timeline-scene-chip:hover {
    border-color: #8fa0b3;
    background: #f3f6f9;
}

.master-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.master-actions .btn {
    flex: 1 1 140px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
}

.stat-box {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.65rem;
    background: var(--surface);
}

.stat-box .k {
    color: var(--muted);
    font-size: 0.72rem;
}

.stat-box .v {
    font-weight: 600;
    font-size: 0.86rem;
}

.advanced-box {
    margin-top: 1.15rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    background: var(--surface-2);
}

.advanced-box summary {
    cursor: pointer;
    font-weight: 600;
}

.character-panel {
    margin-top: 0.85rem;
}

.char-pills,
.download-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.vidu-char-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    background: var(--surface);
}

.vidu-char-top {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.vidu-char-identity {
    display: flex;
    gap: 0.65rem;
    align-items: center;
}

.vidu-char-identity img {
    width: 52px;
    height: 52px;
    border-radius: 999px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.voice-box {
    margin-top: 0.75rem;
}

.import-zone {
    margin-top: 0.85rem;
}

.merch-preview-grid {
    display: grid;
    grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
    gap: 1rem;
}

.mockup-img-frame {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-2);
}

.mockup-img-frame img {
    width: 100%;
    object-fit: cover;
}

.listing-box h4 {
    margin: 0.45rem 0;
}

.profit-line {
    font-weight: 650;
    margin-bottom: 0.35rem;
}

.meta-block {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.meta-block .label {
    color: var(--muted);
    font-size: 0.75rem;
    margin-bottom: 0.2rem;
}

.meta-block .value {
    font-size: 0.92rem;
}

.side-pane {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.side-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.side-head h3 {
    margin: 0;
    font-size: 0.95rem;
}

.family-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
}

.family-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.45rem;
    background: var(--surface-2);
    text-align: center;
}

.family-card img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.35rem;
}

.family-card strong {
    display: block;
    font-size: 0.78rem;
}

.family-card span {
    color: var(--muted);
    font-size: 0.72rem;
}

.empty-state {
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    text-align: center;
    color: var(--muted);
    background: var(--surface-2);
}

.completed-panel {
    text-align: center;
    padding: 2rem 1rem;
}

.completed-panel h2 {
    margin: 0 0 0.4rem;
}

.completed-actions {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.ep-title-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
}

.ep-title-input {
    min-width: 0;
    flex: 1;
    max-width: 22rem;
    font: inherit;
    font-weight: 700;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.15rem 0.35rem;
    margin: 0 -0.35rem;
    outline: none;
    cursor: default;
}

.ep-title-input.is-editing,
.ep-title-input:not([readonly]):focus {
    cursor: text;
    background: var(--surface);
    border-color: var(--border);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    line-height: 1;
    font-size: 0.95rem;
    user-select: none;
    padding: 0;
    flex-shrink: 0;
}

.icon-btn-pencil span {
    display: inline-block;
    transform: scaleX(-1);
}

.icon-btn:hover,
.ep-title-row:focus-within .icon-btn-pencil {
    color: var(--brand-ink);
    background: var(--ghost);
    border-color: var(--border);
}

.inline-edit summary {
    list-style: none;
}

.inline-edit summary::-webkit-details-marker {
    display: none;
}

.inline-edit-form {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.55rem;
    flex-wrap: wrap;
}

.inline-edit-form input,
.field input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.7rem;
    background: var(--surface);
}

.inline-edit-form input {
    min-width: 180px;
    flex: 1;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}

.field label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.settings-dialog,
.app-dialog {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0;
    width: min(560px, calc(100vw - 1.5rem));
    box-shadow: var(--shadow);
    background: var(--surface, #fff);
    color: var(--text);
}

.app-dialog {
    width: min(420px, calc(100vw - 1.5rem));
}

.settings-dialog::backdrop,
.app-dialog::backdrop {
    background: rgba(17, 24, 39, 0.35);
}

.app-dialog-sheet {
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.app-dialog-head h2 {
    margin: 0 0 0.35rem;
    font-size: 1.1rem;
}

.app-dialog-head p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

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

.btn-danger {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}

.btn-danger:hover {
    background: #991b1b;
    border-color: #991b1b;
    color: #fff;
}

.settings-sheet,
.settings-form {
    padding: 1rem 1.1rem;
}

.settings-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
}

.settings-head h2 {
    margin: 0 0 0.25rem;
    font-size: 1.15rem;
}

.settings-head p {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.prose-table-wrap {
    overflow-x: auto;
    margin: 0.85rem 0;
}

.prose-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.prose-table th,
.prose-table td {
    border: 1px solid var(--border);
    padding: 0.45rem 0.55rem;
    text-align: left;
}

.prose-table th {
    background: var(--surface-2);
}

.callout {
    border: 1px solid #cfd8e3;
    background: var(--info-bg);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.5rem;
}

.callout strong {
    display: block;
    margin-bottom: 0.2rem;
}

.callout p {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.45rem;
    margin-top: 0.35rem;
}

#toast-host {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 80;
    max-width: min(360px, calc(100vw - 2rem));
}

.toast {
    background: #1f2937;
    color: #fff;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-size: 0.88rem;
}

.toast[hidden] {
    display: none !important;
}

.toast.show {
    animation: toast-in 0.2s ease;
}

.toast-ok { background: var(--ok); }
.toast-error { background: var(--danger); }
.toast-info { background: #1f2937; }

@keyframes toast-in {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 1100px) {
    .scene-videos-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scene-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .main-wrapper {
        grid-template-columns: 1fr;
    }

    .side-pane {
        order: 2;
    }

    .master-merged-wrapper,
    .merch-preview-grid {
        grid-template-columns: 1fr;
    }

    .master-merged-player-box {
        max-width: 280px;
        margin: 0 auto;
        width: 100%;
    }
}

@media (max-width: 720px) {
    .header-actions {
        justify-content: stretch;
    }

    .header-actions .btn,
    .status-chip {
        flex: 1 1 auto;
    }

    .panel-header {
        flex-direction: column;
    }

    .panel-actions,
    .master-actions {
        width: 100%;
    }

    .panel-actions .btn,
    .master-actions .btn {
        flex: 1 1 100%;
    }

    .timeline-scrubber-bar {
        grid-template-columns: 1fr 1fr;
    }

    .field-row {
        grid-template-columns: 1fr;
    }

    .dialogue-line {
        grid-template-columns: 40px minmax(0, 1fr);
    }

    .meta-strip {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .brand-sub {
        display: none;
    }
}

@media (max-width: 520px) {
    .scene-videos-grid,
    .scene-tabs {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .step-info {
        display: none;
    }

    .family-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Episodes / Characters / production panels */
.site-nav {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1 1 auto;
    min-height: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.98rem;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-icon {
    width: 1.3rem;
    height: 1.3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.75;
    line-height: 1;
}

.nav-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.nav-label {
    min-width: 0;
}

.nav-link.active {
    color: var(--brand-ink);
    background: var(--brand-soft);
    border-color: #ff9fce;
    box-shadow: inset 3px 0 0 var(--brand-hot);
}

.nav-link.active .nav-icon {
    opacity: 1;
    color: var(--brand-hot);
}

.nav-link:hover {
    color: var(--brand-ink);
    background: var(--ghost);
}

.nav-engine {
    margin-left: 0.35rem;
}

.sidebar-foot {
    margin-top: auto;
    padding: 0.75rem 0.7rem 0.35rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar-foot-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.02em;
}

.sidebar-foot-meta {
    font-size: 0.72rem;
}

.brand-sub {
    font-size: 0.72rem;
    margin-top: 0.1rem;
}

.page-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.brand-hero {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    border: 2px solid var(--brand-hot);
    box-shadow: var(--shadow), 0 0 0 3px rgba(255, 230, 0, 0.35);
    margin-bottom: 0.95rem;
    min-height: 200px;
    background: #111;
}

.brand-hero-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    object-position: center 28%;
}

.brand-hero-shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(10, 6, 16, 0.82) 0%, rgba(10, 6, 16, 0.45) 48%, rgba(10, 6, 16, 0.15) 100%);
}

.brand-hero-copy {
    position: absolute;
    left: 1.1rem;
    bottom: 1rem;
    right: 1.1rem;
    color: #fff;
    max-width: 28rem;
}

.brand-hero-copy h1 {
    margin: 0;
    font-size: clamp(1.35rem, 2.6vw, 1.85rem);
    line-height: 1.15;
    color: #ffffff !important;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

.brand-hero-copy p {
    margin: 0.35rem 0 0.75rem;
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.92rem;
}

.brand-hero-copy .btn-primary {
    box-shadow: 0 0 0 2px rgba(255, 230, 0, 0.45);
}

.dashboard-page .dash-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
    margin-bottom: 0.9rem;
}

.dash-kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-height: 0;
}

.dash-kpi-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
}

.dash-kpi-value {
    font-size: 1.65rem;
    line-height: 1.1;
    color: var(--brand-hot);
}

.dash-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 1rem;
}

.dash-panel {
    padding: 1rem 1.1rem 1.15rem;
}

.dash-span-2 {
    grid-column: 1 / -1;
}

.dash-active-title {
    margin: 0.35rem 0 0.15rem;
    font-size: 1.15rem;
}

.dash-active-stage {
    margin: 0 0 0.75rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.dash-pipeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.45rem;
}

.dash-pipeline li {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.dash-pipe-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    background: var(--ghost);
    border: 2px solid var(--border);
    flex-shrink: 0;
}

.dash-pipeline li.is-done {
    color: var(--text);
}

.dash-pipeline li.is-done .dash-pipe-dot {
    background: var(--brand-hot);
    border-color: var(--brand-hot);
}

.dash-pipeline li.is-current {
    color: var(--brand-ink);
    font-weight: 700;
}

.dash-pipeline li.is-current .dash-pipe-dot {
    background: #fff;
    border-color: var(--brand-hot);
    box-shadow: 0 0 0 3px rgba(255, 45, 138, 0.2);
}

.dash-status-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dash-status-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}

.dash-status-list li:last-child {
    border-bottom: 0;
}

@media (max-width: 1100px) {
    .dashboard-page .dash-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 800px) {
    .dashboard-page .dash-kpis {
        grid-template-columns: 1fr 1fr;
    }

    .dash-grid {
        grid-template-columns: 1fr;
    }

    .brand-hero-img {
        height: 180px;
    }

    .brand-hero-shade {
        background: linear-gradient(180deg, rgba(10, 6, 16, 0.2) 0%, rgba(10, 6, 16, 0.85) 100%);
    }
}

.page-shell {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0.5rem 1.5rem 2rem;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.page-head h1 {
    margin: 0 0 0.2rem;
    font-size: 1.55rem;
    line-height: 1.2;
}

.page-head p {
    margin: 0;
    line-height: 1.35;
    font-size: 0.88rem;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.char-media-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
    width: 100%;
}

.char-media-box {
    margin: 0;
    width: 100%;
    min-width: 0;
    min-height: 3rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    box-sizing: border-box;
}

.char-media-box input[type="file"] {
    min-width: 0;
    flex: 1 1 auto;
    max-width: 100%;
}

.char-media-box .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.table-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.table-card {
    overflow: auto;
}

/* Table styling */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.data-table thead th {
    background: var(--surface-2);
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    border-bottom: 2px solid var(--border);
}

.data-table th,
.data-table td {
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

/* Ensure data-table body cells aren't overly bolded, but keep Sr. No. bold */
.data-table tbody td,
.data-table tbody .col-title,
.data-table tbody .ep-title-text {
    font-weight: 400 !important;
}

/* Explicitly enforce semi-bold styling for Sr. No. (col-num) values */
.data-table tbody td.col-num,
.data-table tbody .col-num {
    font-weight: 600 !important;
    color: var(--text) !important;
}

.data-table tbody td strong {
    font-weight: 400 !important;
}

.data-table.compact th,
.data-table.compact td {
    padding: 0.45rem 0.6rem;
}

.data-table tr.is-active,
.data-table tr.selected {
    background: var(--brand-soft) !important;
    box-shadow: inset 3px 0 0 var(--brand);
}

.data-table tbody tr:hover {
    background: rgba(255, 45, 138, 0.05);
}

.data-table tr.is-active:hover,
.data-table tr.selected:hover {
    background: var(--brand-soft) !important;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.input-sm {
    min-width: 10rem;
    padding: 0.35rem 0.55rem;
    font-size: 0.85rem;
}

.characters-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 1rem;
}

.char-nav {
    padding: 1rem;
}

.char-list {
    display: grid;
    gap: 0.5rem;
    margin-top: 1rem;
}

.char-list-item {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    padding: 0.45rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    border: 1px solid transparent;
}

.char-list-item img {
    width: 42px;
    height: auto;
    max-height: 74px;
    aspect-ratio: 9 / 16;
    object-fit: contain;
    object-position: center top;
    border-radius: 6px;
    background: var(--ghost);
}

.char-list-item.active,
.char-list-item:hover {
    border-color: var(--border);
    background: var(--surface-2);
}

.char-editor {
    padding: 1.25rem;
}

.char-editor-head {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.char-preview-frame {
    flex: 0 0 auto;
    width: clamp(72px, 18vw, 112px);
    max-width: 30%;
    border-radius: 8px;
    background: var(--ghost);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.char-preview {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(220px, 40vh);
    object-fit: contain;
    object-position: center top;
    border-radius: 8px;
}

.char-editor-meta {
    display: grid;
    gap: 0.35rem;
    min-width: 0;
    flex: 1 1 auto;
    padding-top: 0.15rem;
}

.char-editor-meta h1,
.char-editor-meta p {
    margin: 0;
}

.char-audio-player {
    width: 100%;
    max-width: min(22rem, 100%);
    margin-top: 0.25rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

.form-grid label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

.form-grid .input-speed {
    max-width: 7.5rem;
}

.form-grid .input-speed::-webkit-outer-spin-button,
.form-grid .input-speed::-webkit-inner-spin-button {
    opacity: 1;
    height: 1.1rem;
    margin-left: 0.25rem;
}

.form-grid label .input,
.form-grid label input,
.form-grid label textarea {
    font-weight: 400;
    color: var(--text);
}

.form-grid .full {
    grid-column: 1 / -1;
}

.note-form {
    display: grid;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.note-list {
    display: grid;
    gap: 0.65rem;
}

.note-item {
    padding: 0.55rem 0.65rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.note-item p {
    margin: 0.25rem 0 0;
    color: var(--text);
}

.gen-queue-panel {
    margin-top: 1rem;
    padding: 1rem;
}

.history-block {
    margin-top: 0.5rem;
}

.history-block ul {
    margin: 0.25rem 0 0;
    padding-left: 1.1rem;
}

.autosave-ok {
    color: var(--ok);
    font-size: 0.8rem;
}

.studio-tools,
.tool-block {
    margin-top: 0.75rem;
}

.tool-block {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.75rem;
    background: var(--surface-2);
}

.tool-block summary {
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.tool-list {
    margin: 0.35rem 0 0.65rem;
    padding-left: 1.1rem;
}

.tool-list li {
    margin: 0.25rem 0;
}

.dash-queue-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.dash-queue-link {
    color: inherit;
    text-decoration: none;
    min-width: 0;
}

.dash-queue-link:hover strong {
    color: var(--brand-hot);
}

.notify-box {
    margin-bottom: 0.75rem;
}

.dialogue-text-edit {
    width: 100%;
    margin-top: 0.35rem;
}

.mono {
    font-family: var(--mono);
    font-size: 0.78rem;
}

@media (max-width: 980px) {
    .sidebar-toggle-btn {
        display: flex;
    }

    .sidebar-backdrop {
        display: block;
    }

    .site-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 90;
        width: 260px;
        max-width: 85vw;
        height: 100vh;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 1.25rem;
        padding: 1.25rem 1rem;
        border-right: 1px solid var(--border);
        border-bottom: 0;
        box-shadow: 8px 0 28px rgba(255, 0, 127, 0.12);
        background: linear-gradient(180deg, #fffcfd 0%, #fff7fb 55%, #fbf2f8 100%);
        overflow-y: auto;
        transform: translateX(-105%);
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .site-sidebar.sidebar-open {
        transform: translateX(0);
    }

    .site-sidebar .brand {
        flex: 0 0 auto;
        padding: 0.25rem 0.35rem;
    }

    .site-nav {
        flex: 1 1 auto;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0.4rem;
    }

    .nav-link {
        padding: 0.6rem 0.85rem;
        border-radius: var(--radius-sm);
        display: flex;
        align-items: center;
        gap: 0.65rem;
    }

    .nav-icon {
        display: inline-block;
    }

    .sidebar-foot {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
        margin-top: auto;
        padding-top: 1rem;
        border-top: 1px solid var(--border);
        width: 100%;
    }

    .sidebar-user {
        display: flex;
        flex-direction: column;
    }

    .sidebar-logout {
        margin-top: 0;
        padding: 0.5rem 0.75rem;
        border-radius: var(--radius-sm);
    }

    .app-main {
        margin-left: 0;
        padding-top: 3.5rem; /* Space for the hamburger toggle button */
        min-height: 100vh;
    }
}

@media (max-width: 900px) {
    .characters-layout {
        grid-template-columns: 1fr;
    }

    .page-head {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .char-media-row {
        grid-template-columns: 1fr;
    }

    .char-editor-head {
        flex-wrap: wrap;
    }

    .char-preview-frame {
        max-width: 40%;
    }
}

/* Auth pages */
.auth-body {
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    background: #120814;
}

.auth-shell {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
}

.auth-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.auth-backdrop-img {
    position: absolute;
    inset: -4%;
    width: 108%;
    height: 108%;
    max-width: none;
    object-fit: cover;
    object-position: center 22%;
    filter: blur(6px) saturate(1.05);
}

.auth-backdrop-shade {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(18, 8, 20, 0.55) 0%, rgba(18, 8, 20, 0.42) 45%, rgba(18, 8, 20, 0.62) 100%),
        radial-gradient(circle at 50% 40%, rgba(255, 0, 127, 0.12), transparent 55%);
}

.auth-brand {
    padding: 0;
    justify-content: center;
    max-width: 100%;
}

.auth-brand .brand-copy {
    min-width: 0;
}

.auth-brand .brand-title {
    font-size: clamp(0.9rem, 2.8vw, 1.05rem);
}

.auth-brand .brand-title-crash {
    color: #fff;
}

.auth-brand .brand-sub {
    color: rgba(255, 255, 255, 0.78);
}

.auth-tagline {
    margin: 0;
    width: 100%;
    max-width: 100%;
    color: rgba(255, 255, 255, 0.88);
    font-size: clamp(0.84rem, 2.4vw, 0.95rem);
    line-height: 1.45;
    text-align: center;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
    padding: 0 0.25rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.auth-main {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 4vw, 2.5rem) clamp(0.75rem, 3.5vw, 2rem);
    box-sizing: border-box;
}

.auth-center {
    width: 100%;
    max-width: min(380px, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.65rem, 2vw, 0.9rem);
    min-width: 0;
    box-sizing: border-box;
}

.auth-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: rgba(255, 252, 254, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(10, 4, 16, 0.28), var(--shadow);
    backdrop-filter: blur(8px);
    padding: clamp(1.1rem, 3.5vw, 1.75rem) clamp(1rem, 3.2vw, 1.6rem);
}

.auth-card-head h1 {
    margin: 0;
    font-size: clamp(1.2rem, 4vw, 1.45rem);
}

.auth-card-head p {
    margin: 0.35rem 0 0;
    overflow-wrap: anywhere;
}

.auth-form {
    margin-top: 1.1rem;
    width: 100%;
    min-width: 0;
}

.auth-form .field {
    width: 100%;
    min-width: 0;
}

.field-label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
}

.input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.7rem;
    background: var(--surface);
    color: var(--text);
}

.input:focus {
    outline: 2px solid rgba(255, 45, 138, 0.25);
    border-color: #ff9fce;
}

.auth-submit {
    width: 100%;
    margin-top: 0.35rem;
}

.auth-switch {
    margin: 1rem 0 0;
    font-size: 0.88rem;
    overflow-wrap: anywhere;
}

.auth-alert {
    margin-top: 0.9rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid #fecdd3;
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 0.88rem;
    font-weight: 600;
}

.settings-alert {
    margin-bottom: 1rem;
}

.sidebar-user {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    margin-bottom: 0.45rem;
}

.sidebar-user-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
}

.sidebar-user-email {
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-logout {
    margin-top: 0.15rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

.settings-panel {
    padding: 1rem 1.05rem 1.1rem;
}

.settings-panel-wide {
    grid-column: 1 / -1;
}

.settings-panel .panel-header {
    margin-bottom: 0.75rem;
}

.settings-panel h2 {
    margin: 0;
    font-size: 1.05rem;
}

.settings-secure-note {
    margin: 0.35rem 0 0;
    font-size: 0.82rem;
    max-width: 42rem;
}

.settings-form .field {
    margin-bottom: 0.7rem;
}

.settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.settings-actions-split {
    justify-content: space-between;
    align-items: center;
}

.settings-key-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem 0.7rem;
    margin-bottom: 0.85rem;
}

.settings-key-mask {
    min-width: 0;
    overflow-wrap: anywhere;
}

.settings-clear-key {
    flex: 0 0 auto;
}

.settings-form select.input {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 16px) calc(50% - 3px),
        calc(100% - 10px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 2rem;
    cursor: pointer;
}

.status-chip.status-ok {
    background: var(--ok-bg);
    border-color: #b7e0c8;
    color: var(--ok);
    font-weight: 600;
}

.settings-vidu-row {
    margin-bottom: 0.15rem;
}

@media (max-width: 900px) {
    .auth-backdrop-img {
        filter: blur(5px) saturate(1.05);
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .auth-brand .brand-mark {
        width: 36px;
        height: 36px;
    }

    .auth-card {
        border-radius: 12px;
    }

    .auth-submit {
        min-height: 2.6rem;
    }
}

@media (min-width: 900px) {
    .auth-center {
        max-width: min(400px, 92vw);
    }
}

@media (min-width: 1280px) {
    .auth-center {
        max-width: min(420px, 32vw);
    }
}
