/* ============================================================
   Opera Accessible Player — 京韵 · 戏曲无障碍播放器
   Theme: Traditional Chinese Opera Theater
   ============================================================ */

/* ------------------------------------------------------------------ */
/* 1. Design System — CSS Custom Properties                          */
/* ------------------------------------------------------------------ */
:root {
    /* Background hierarchy */
    --bg-theater: #090808;
    --bg-curtain: #100a08;
    --bg-stage: #141010;
    --bg-card: rgba(22, 10, 10, 0.72);
    --bg-glass: rgba(28, 12, 10, 0.55);
    --bg-input: rgba(18, 8, 8, 0.75);

    /* Accent — Peking Opera Red */
    --red: #c23a2b;
    --red-light: #d94a3a;
    --red-dark: #8c1f14;
    --red-glow: rgba(194, 58, 43, 0.35);
    --red-soft: rgba(194, 58, 43, 0.12);

    /* Accent — Imperial Gold */
    --gold: #d4a853;
    --gold-bright: #e8c84a;
    --gold-dim: rgba(212, 168, 83, 0.20);
    --gold-glow: rgba(212, 168, 83, 0.25);
    --gold-soft: rgba(212, 168, 83, 0.10);

    /* Accent — Jade */
    --jade: #5a9a7a;

    /* Text */
    --text-cream: #ede4d3;
    --text-body: #d5cec0;
    --text-muted: #8a7e70;
    --text-dim: #5e554a;

    /* Borders */
    --border-subtle: rgba(120, 90, 70, 0.18);
    --border-gold: rgba(212, 168, 83, 0.22);
    --border-red: rgba(194, 58, 43, 0.28);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-frame: 8px;

    /* Shadows */
    --shadow-card: 0 4px 24px rgba(0,0,0,0.5);
    --shadow-stage: 0 8px 40px rgba(0,0,0,0.65);
    --shadow-gold: 0 0 24px rgba(212,168,83,0.12);
    --shadow-red: 0 0 20px rgba(194,58,43,0.18);

    /* Typography */
    --font-display: "Noto Serif SC", "Source Han Serif SC", "SimSun", "STSong", serif;
    --font-body: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
    --font-mono: "SF Mono", "Cascadia Code", "Consolas", monospace;

    /* Transitions */
    --ease-silk: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 0.18s;
    --duration-normal: 0.3s;
    --duration-slow: 0.5s;
}

/* ------------------------------------------------------------------ */
/* 2. Reset & Base                                                    */
/* ------------------------------------------------------------------ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-theater);
    color: var(--text-body);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.55;
}

/* Silk-texture noise overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.04;
    background-image:
        repeating-conic-gradient(#c23a2b 0 0.0002%, transparent 0 0.0006%),
        repeating-conic-gradient(#d4a853 0 0.0003%, transparent 0 0.0008%);
    background-size: 200px 200px, 280px 280px;
    background-position: 0 0, 60px 30px;
}

/* ------------------------------------------------------------------ */
/* 3. Typography                                                      */
/* ------------------------------------------------------------------ */
.display-text {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.04em;
}

.serif-text {
    font-family: var(--font-display);
}

/* ------------------------------------------------------------------ */
/* 4. Decorative Utility Classes                                      */
/* ------------------------------------------------------------------ */

/* Gold bottom-border with fade-out edges */
.gold-rule {
    border: none;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--gold-dim) 15%,
        var(--gold) 50%,
        var(--gold-dim) 85%,
        transparent 100%
    );
}

/* Panel with glassmorphism */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

/* Gold decorative frame */
.gold-frame {
    border: 1px solid var(--border-gold);
    box-shadow:
        0 0 0 3px rgba(212,168,83,0.04),
        inset 0 0 0 1px rgba(212,168,83,0.03);
    border-radius: var(--radius-frame);
}

/* Corner ornament — used with ::before / ::after */
.corner-ornament::before,
.corner-ornament::after {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    pointer-events: none;
    z-index: 1;
}
.corner-ornament::before {
    top: -1px; left: -1px;
    border-top: 2px solid var(--gold);
    border-left: 2px solid var(--gold);
    border-radius: 4px 0 0 0;
}
.corner-ornament::after {
    bottom: -1px; right: -1px;
    border-bottom: 2px solid var(--gold);
    border-right: 2px solid var(--gold);
    border-radius: 0 0 4px 0;
}

/* Cloud motif simplified (CSS shape) */
.cloud-motif {
    display: inline-block;
    width: 28px;
    height: 10px;
    position: relative;
    opacity: 0.25;
}
.cloud-motif::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--gold);
    border-radius: 50%;
    box-shadow:
        8px -4px 0 3px var(--gold),
        16px 0 0 1px var(--gold);
}

/* Accent gradient text */
.accent-text {
    background: linear-gradient(135deg, var(--gold-bright), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ------------------------------------------------------------------ */
/* 5. Scrollbar                                                       */
/* ------------------------------------------------------------------ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-gold);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(212,168,83,0.45);
}

/* ------------------------------------------------------------------ */
/* 6. Header                                                          */
/* ------------------------------------------------------------------ */
.header {
    position: relative;
    z-index: 10;
    background: linear-gradient(180deg, #120a08 0%, var(--bg-theater) 100%);
    border-bottom: 1px solid var(--border-gold);
    padding: 0;
}
.header::after {
    content: "";
    display: block;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--red-dark) 20%,
        var(--gold) 50%,
        var(--red-dark) 80%,
        transparent 100%
    );
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 28px;
    max-width: 1600px;
    margin: 0 auto;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    font-size: 2rem;
    line-height: 1;
    filter: drop-shadow(0 0 8px rgba(212,168,83,0.3));
    animation: goldPulse 3s ease-in-out infinite;
}

.logo {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gold-bright);
    letter-spacing: 0.06em;
    text-shadow: 0 0 20px rgba(212,168,83,0.2);
    line-height: 1.3;
}

.header-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.header-decoration {
    display: flex;
    gap: 8px;
    margin-left: auto;
    align-items: center;
}

.header-tagline {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    padding: 4px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    background: var(--bg-glass);
}

/* ------------------------------------------------------------------ */
/* 7. Main Layout                                                     */
/* ------------------------------------------------------------------ */
.main-container {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 20px;
    padding: 20px 28px 28px;
    height: calc(100vh - 74px);
    height: calc(100dvh - 74px);
    min-height: 600px;
    max-width: 1600px;
    margin: 0 auto;
}

.player-section {
    flex: 1 1 65%;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.side-panel {
    flex: 0 0 390px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 100%;
}

/* ------------------------------------------------------------------ */
/* 8. Upload Area — "The Stage Entrance"                              */
/* ------------------------------------------------------------------ */
.video-input-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(194,58,43,0.08) 0%, transparent 60%),
        var(--bg-stage);
    border: 2px solid var(--border-gold);
    border-radius: var(--radius-lg);
    gap: 18px;
    padding: 44px;
    position: relative;
    transition:
        border-color var(--duration-normal) var(--ease-silk),
        box-shadow var(--duration-normal) var(--ease-silk);
}

.video-input-area::before {
    content: "";
    position: absolute;
    inset: 6px;
    border: 1px solid var(--border-subtle);
    border-radius: calc(var(--radius-lg) - 4px);
    pointer-events: none;
}

.video-input-area.drag-over {
    border-color: var(--gold);
    box-shadow: var(--shadow-gold), var(--shadow-red);
    background:
        radial-gradient(ellipse at 50% 30%, rgba(194,58,43,0.15) 0%, transparent 60%),
        var(--bg-stage);
}

.upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    padding: 36px 56px;
    border-radius: var(--radius-lg);
    transition:
        background var(--duration-fast) var(--ease-silk),
        transform var(--duration-fast) var(--ease-silk);
    color: var(--text-muted);
}
.upload-zone:hover {
    background: var(--gold-soft);
    color: var(--text-cream);
    transform: translateY(-2px);
}

.upload-icon {
    color: var(--gold);
    margin-bottom: 4px;
    transition: transform var(--duration-normal) var(--ease-silk);
}
.upload-zone:hover .upload-icon {
    transform: scale(1.06);
}

.upload-zone p {
    font-size: 1.05rem;
    color: var(--text-cream);
    font-weight: 500;
}
.upload-zone .hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.url-input-row {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 500px;
}
.url-input-row input {
    flex: 1;
    padding: 11px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-cream);
    font-size: 0.9rem;
    font-family: var(--font-body);
    outline: none;
    transition:
        border-color var(--duration-fast) var(--ease-silk),
        box-shadow var(--duration-fast) var(--ease-silk);
}
.url-input-row input::placeholder {
    color: var(--text-dim);
}
.url-input-row input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212,168,83,0.08);
}

/* ------------------------------------------------------------------ */
/* 9. Buttons                                                         */
/* ------------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 24px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
    transition:
        all var(--duration-fast) var(--ease-silk);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    user-select: none;
}

/* Ripple */
.btn::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at center, rgba(255,255,255,0.2) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.4s;
}
.btn:active::after {
    opacity: 1;
    transition: opacity 0s;
}

.btn:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* Primary — Opera Red */
.btn-primary {
    background: linear-gradient(135deg, var(--red-light), var(--red));
    color: #fff;
    border-color: rgba(255,255,255,0.1);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #e05040, #d04030);
    box-shadow: var(--shadow-red);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0);
}

/* Secondary — Dark glass */
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-body);
    border-color: var(--border-subtle);
}
.btn-secondary:hover {
    background: rgba(40,20,18,0.8);
    border-color: var(--border-gold);
    color: var(--text-cream);
}

/* Outline — Gold accent */
.btn-outline {
    background: transparent;
    color: var(--gold);
    border-color: var(--border-gold);
}
.btn-outline:hover {
    background: var(--gold-soft);
    border-color: var(--gold);
    box-shadow: var(--shadow-gold);
    color: var(--gold-bright);
}

/* Small variant */
.btn-sm {
    padding: 7px 16px;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------ */
/* 10. Video Player — "The Stage"                                    */
/* ------------------------------------------------------------------ */
.video-player-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.video-container {
    position: relative;
    flex: 1;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-gold);
    box-shadow:
        var(--shadow-stage),
        0 0 0 4px rgba(0,0,0,0.4);
}

/* Stage curtain top bar */
.video-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    z-index: 10;
    pointer-events: none;
    background: linear-gradient(180deg,
        rgba(0,0,0,0.7) 0%,
        rgba(0,0,0,0.3) 40%,
        transparent 100%
    );
    border-bottom: 1px solid rgba(212,168,83,0.08);
}

/* Curtain drapes */
.video-container::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    z-index: 11;
    pointer-events: none;
    background: linear-gradient(90deg,
        transparent 5%,
        rgba(194,58,43,0.5) 15%,
        rgba(194,58,43,0.7) 30%,
        rgba(194,58,43,0.3) 50%,
        rgba(194,58,43,0.7) 70%,
        rgba(194,58,43,0.5) 85%,
        transparent 95%
    );
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    outline: none;
}

/* Subtitle overlay */
.subtitle-overlay {
    position: absolute;
    bottom: 8%;
    left: 5%;
    right: 5%;
    text-align: center;
    pointer-events: none;
    z-index: 15;
}

.subtitle-original {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    text-shadow:
        0 2px 8px rgba(0,0,0,0.95),
        0 0 6px rgba(0,0,0,0.8),
        0 0 2px rgba(212,168,83,0.3);
    padding: 6px 18px;
    border-radius: 6px;
    background:
        linear-gradient(180deg,
            rgba(0,0,0,0.6) 0%,
            rgba(20,5,5,0.7) 100%
        );
    display: inline-block;
    margin-bottom: 6px;
    border: 1px solid rgba(212,168,83,0.2);
    letter-spacing: 0.04em;
    transition:
        opacity var(--duration-normal) var(--ease-silk),
        transform var(--duration-normal) var(--ease-silk);
}

.subtitle-translated {
    font-size: 0.95rem;
    color: var(--gold-bright);
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
    background:
        linear-gradient(180deg,
            rgba(0,0,0,0.5) 0%,
            rgba(10,5,0,0.6) 100%
        );
    display: inline-block;
    padding: 3px 14px;
    border-radius: 6px;
    font-style: italic;
    border: 1px solid rgba(212,168,83,0.12);
}

/* Subtitle change animation */
.subtitle-original.entering {
    animation: subtitleSlideUp 0.35s var(--ease-silk);
}
.subtitle-translated.entering {
    animation: subtitleSlideUp 0.35s var(--ease-silk) 0.05s both;
}

/* Control bar */
.video-controls-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 8px 0;
}

.status-text {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* Manual subtitle area */
.manual-subtitle-area {
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    backdrop-filter: blur(8px);
}
.manual-subtitle-area textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-cream);
    padding: 12px;
    font-size: 0.88rem;
    font-family: var(--font-body);
    resize: vertical;
    outline: none;
    transition: border-color var(--duration-fast) var(--ease-silk);
    line-height: 1.7;
}
.manual-subtitle-area textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212,168,83,0.06);
}
.manual-subtitle-area .btn {
    align-self: flex-start;
}

/* ------------------------------------------------------------------ */
/* 11. Character Panel — 3D Avatar "The Performer"                    */
/* ------------------------------------------------------------------ */
.character-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-card);
}

.panel-title {
    padding: 12px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gold);
    border-bottom: 1px solid var(--border-gold);
    background: rgba(20,8,8,0.6);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.03em;
}
.panel-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--border-gold), transparent);
}

.character-canvas-wrapper {
    flex: 1;
    min-height: 290px;
    position: relative;
    background:
        radial-gradient(ellipse at 50% 55%, rgba(194,58,43,0.06) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 60%, rgba(212,168,83,0.04) 0%, transparent 40%),
        #0d0a0a;
    overflow: hidden;
}
.character-canvas-wrapper canvas,
.character-canvas-wrapper iframe {
    display: block;
    width: 100% !important;
    height: 100% !important;
    border: none;
    position: relative;
    z-index: 1;
}

/* Stage spotlight effect */
.character-canvas-wrapper::before {
    content: "";
    position: absolute;
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 60%;
    background: radial-gradient(ellipse at center,
        rgba(255,220,160,0.05) 0%,
        transparent 70%
    );
    z-index: 0;
    pointer-events: none;
}

.character-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 14px;
    text-align: center;
    pointer-events: none;
    z-index: 0;
}
.character-placeholder p {
    font-size: 0.84rem;
    line-height: 1.7;
    color: var(--text-dim);
}
.placeholder-figure {
    opacity: 0.2;
    filter: drop-shadow(0 0 12px rgba(212,168,83,0.2));
}

.character-status {
    padding: 9px 18px;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    background: rgba(14,8,6,0.6);
    transition: color var(--duration-normal) var(--ease-silk);
}
.character-status.signing {
    color: var(--gold-bright);
    text-shadow: 0 0 8px rgba(212,168,83,0.25);
}

/* ------------------------------------------------------------------ */
/* 12. Subtitle Panel — "Program Notes"                               */
/* ------------------------------------------------------------------ */
.subtitle-panel {
    flex: 1;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    min-height: 0;
    box-shadow: var(--shadow-card);
}

.subtitle-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

.subtitle-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition:
        background var(--duration-fast) var(--ease-silk),
        border-color var(--duration-fast) var(--ease-silk),
        transform var(--duration-fast) var(--ease-silk);
    border: 1px solid transparent;
    position: relative;
    animation: subtitleSlideIn 0.35s var(--ease-silk) both;
}
.subtitle-item:hover {
    background: var(--gold-soft);
    border-color: var(--border-gold);
}
.subtitle-item.active {
    background: var(--red-soft);
    border-color: var(--red-glow);
    box-shadow: 0 0 12px rgba(194,58,43,0.1);
    transform: scale(1.01);
}

.subtitle-time {
    font-size: 0.72rem;
    color: var(--gold);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 50px;
    padding-top: 3px;
    font-weight: 500;
}

.subtitle-content {
    flex: 1;
    min-width: 0;
}
.subtitle-orig-text {
    font-size: 0.9rem;
    color: var(--text-cream);
    font-weight: 500;
    line-height: 1.45;
}
.subtitle-trans-text {
    font-size: 0.78rem;
    color: var(--gold);
    margin-top: 3px;
    font-style: italic;
    line-height: 1.4;
}

/* Sign indicator dot */
.subtitle-item .sign-dot {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
    opacity: 0;
    transition: opacity var(--duration-fast);
}
.subtitle-item.signing .sign-dot {
    opacity: 1;
    animation: goldPulse 1.2s ease-in-out infinite;
}

.empty-hint {
    text-align: center;
    color: var(--text-muted);
    padding: 48px 16px;
    font-size: 0.88rem;
    line-height: 1.8;
}

/* ------------------------------------------------------------------ */
/* 13. Loading Overlay — "Curtain"                                    */
/* ------------------------------------------------------------------ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.78);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    gap: 20px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Curtain panels */
.loading-overlay::before,
.loading-overlay::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    background:
        linear-gradient(180deg, var(--red-dark) 0%, #3a0505 100%);
    z-index: -1;
    transition: transform var(--duration-slow) var(--ease-silk);
}
.loading-overlay::before {
    left: 0;
    transform: translateX(0);
    border-right: 2px solid var(--gold-dim);
}
.loading-overlay::after {
    right: 0;
    transform: translateX(0);
    border-left: 2px solid var(--gold-dim);
}
.loading-overlay[style*="display: none"]::before {
    transform: translateX(-100%);
}
.loading-overlay[style*="display: none"]::after {
    transform: translateX(100%);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-gold);
    border-top-color: var(--gold-bright);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    position: relative;
}
.loading-spinner::after {
    content: "";
    position: absolute;
    inset: 4px;
    border: 2px solid transparent;
    border-bottom-color: var(--red-light);
    border-radius: 50%;
    animation: spin 1.2s linear infinite reverse;
}

.loading-overlay p {
    color: var(--text-cream);
    font-family: var(--font-display);
    font-size: 0.95rem;
    letter-spacing: 0.05em;
}

/* ------------------------------------------------------------------ */
/* 14. Toast — "Lantern" notification                                 */
/* ------------------------------------------------------------------ */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    background: linear-gradient(180deg, var(--red-dark), #5a0a05);
    color: #fff;
    padding: 10px 28px;
    border-radius: 20px;
    font-size: 0.86rem;
    font-weight: 500;
    z-index: 2000;
    pointer-events: none;
    box-shadow:
        0 4px 20px rgba(0,0,0,0.5),
        0 0 24px var(--red-glow);
    border: 1px solid var(--border-gold);
    transition: transform 0.4s var(--ease-spring);
    white-space: nowrap;
    font-family: var(--font-body);
}

/* Lantern tassel */
.toast::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #5a0a05;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* Toast variants */
.toast.toast-success {
    background: linear-gradient(180deg, #3a6b4a, #1a3a20);
    box-shadow: 0 4px 20px rgba(90,154,122,0.3);
}
.toast.toast-error {
    background: linear-gradient(180deg, #8c1f14, #4a0805);
    box-shadow: 0 4px 20px rgba(194,58,43,0.4);
}
.toast.toast-info {
    background: linear-gradient(180deg, #4a3a20, #2a1a08);
    box-shadow: 0 4px 20px rgba(212,168,83,0.25);
}

/* ------------------------------------------------------------------ */
/* 15. Keyframe Animations                                            */
/* ------------------------------------------------------------------ */

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes goldPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

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

@keyframes subtitleSlideIn {
    from {
        opacity: 0;
        transform: translateX(-12px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes lanternDrop {
    0% { transform: translateX(-50%) translateY(-120px); }
    60% { transform: translateX(-50%) translateY(8px); }
    80% { transform: translateX(-50%) translateY(-4px); }
    100% { transform: translateX(-50%) translateY(0); }
}

@keyframes stageLightFlicker {
    0%, 100% { opacity: 0.04; }
    50% { opacity: 0.07; }
}

@keyframes breathPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.003); }
}

@keyframes floatCloud {
    0% { transform: translateX(0); }
    100% { transform: translateX(-20px); }
}

@keyframes rippleEffect {
    0% { transform: scale(0); opacity: 0.6; }
    100% { transform: scale(4); opacity: 0; }
}

/* ------------------------------------------------------------------ */
/* 16. Responsive Design                                              */
/* ------------------------------------------------------------------ */

/* Large desktop: spacious layout */
@media (min-width: 1400px) {
    .main-container { gap: 24px; padding: 24px 40px 32px; }
    .side-panel { flex: 0 0 420px; }
    .character-canvas-wrapper { min-height: 320px; }
}

/* Standard desktop */
@media (max-width: 1200px) {
    .side-panel { flex: 0 0 340px; }
    .header-inner { padding: 12px 20px; }
    .header-decoration { display: none; }
    .logo { font-size: 1.2rem; }
}

/* Tablet — stack layout */
@media (max-width: 900px) {
    .main-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        gap: 14px;
        padding: 14px 16px;
    }
    .side-panel {
        flex: auto;
        max-height: none;
        flex-direction: column;
        gap: 12px;
    }
    .character-canvas-wrapper { min-height: 260px; }
    .character-panel { max-height: 340px; }
    .subtitle-panel { max-height: 320px; }
    .video-input-area { padding: 28px 20px; }
    .upload-zone { padding: 24px 32px; }
    .header-tagline { display: none; }
}

/* Small tablet / large phone */
@media (max-width: 600px) {
    .header-inner {
        flex-direction: column;
        gap: 6px;
        padding: 10px 14px;
        align-items: flex-start;
    }
    .logo { font-size: 1.1rem; }
    .header-sub { font-size: 0.7rem; }
    .main-container { padding: 10px; gap: 10px; }
    .side-panel { gap: 10px; }
    .character-canvas-wrapper { min-height: 220px; }
    .character-panel { max-height: 280px; }
    .subtitle-panel { max-height: 240px; }
    .video-input-area { padding: 20px 12px; gap: 12px; }
    .upload-zone { padding: 20px 24px; }
    .upload-zone p { font-size: 0.9rem; }
    .url-input-row { flex-direction: column; }
    .video-controls-bar { gap: 6px; }
    .btn { padding: 8px 14px; font-size: 0.82rem; }
    .subtitle-original { font-size: 1.1rem; }
    .subtitle-translated { font-size: 0.8rem; }
}

/* ------------------------------------------------------------------ */
/* 17. Focus Visible & Accessibility                                  */
/* ------------------------------------------------------------------ */
:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--gold);
    color: #000;
    padding: 8px 16px;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    z-index: 3000;
    font-weight: 600;
    text-decoration: none;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* Selection style */
::selection {
    background: rgba(194,58,43,0.3);
    color: var(--text-cream);
}
