* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #f7f5f2;
    --bg-card: #ffffff;
    --bg-sidebar: #fefdfb;
    --bg-stage-top: #faf8f5;
    --bg-stage-bottom: #f0ede8;
    --text: #2d2a26;
    --text2: #7a756f;
    --text3: #b0a99f;
    --accent: #c47d4e;
    --accent-light: #f3e8de;
    --accent2: #5b7fc7;
    --border: #e8e3dd;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow2: 0 4px 12px rgba(0,0,0,0.08);
    --shadow3: 0 8px 24px rgba(0,0,0,0.10);
    --radius: 12px;
    --green: #5aad60;
    --orange: #e09040;
    --red: #d45;
    --font: "Noto Sans SC", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

[data-theme="dark"] {
    --bg: #151518;
    --bg-card: #1e1e22;
    --bg-sidebar: #1a1a1e;
    --bg-stage-top: #18181c;
    --bg-stage-bottom: #121215;
    --text: #e0ddd8;
    --text2: #9a9590;
    --text3: #6a655f;
    --accent: #c47d4e;
    --accent-light: #2e2218;
    --accent2: #6b8fd7;
    --border: #2e2e33;
    --shadow: 0 1px 3px rgba(0,0,0,0.2);
    --shadow2: 0 4px 12px rgba(0,0,0,0.25);
    --shadow3: 0 8px 24px rgba(0,0,0,0.3);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

.app { display: flex; height: 100vh; }

/* ── Sidebar ── */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    flex-shrink: 0;
    gap: 14px;
    overflow-y: auto;
}

.logo {
    display: flex; align-items: center; gap: 10px;
    font-size: 1.05rem; font-weight: 600;
    color: var(--text); letter-spacing: -0.3px;
}
.logo-icon {
    width: 36px; height: 36px;
    background: var(--accent-light);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
}

.section { display: flex; flex-direction: column; gap: 8px; }
.section-label {
    font-size: 0.72rem; font-weight: 600;
    color: var(--text2); text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* ── Category filter ── */
.category-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}
.category-chip {
    padding: 4px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 0.65rem;
    color: var(--text2);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font);
    white-space: nowrap;
}
.category-chip:hover { border-color: var(--accent); color: var(--accent); }
.category-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ── Avatar grid (3-column) ── */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-height: calc(100vh - 420px);
    overflow-y: auto;
    padding: 2px;
}
.avatar-grid::-webkit-scrollbar { width: 3px; }
.avatar-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.avatar-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 6px 8px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 5px;
    box-shadow: var(--shadow);
}
.avatar-card:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow2);
    border-color: var(--border);
}
.avatar-card.active {
    border-color: var(--accent);
    background: var(--accent-light);
}
.avatar-card img {
    width: 48px; height: 48px;
    border-radius: 50%;
    object-fit: cover;
}
.avatar-name {
    font-size: 0.68rem; font-weight: 500;
    text-align: center; line-height: 1.2;
    color: var(--text);
    overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; width: 100%;
}
.avatar-tag {
    font-size: 0.55rem;
    color: var(--text3);
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 8px;
    line-height: 1.3;
}

/* ── Avatar info banner ── */
.avatar-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--accent-light);
    border-radius: 10px;
    border: 1px solid rgba(196, 125, 78, 0.2);
    transition: all 0.2s ease;
}
.avatar-info.hidden { display: none; }
.avatar-info-img {
    width: 44px; height: 44px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}
.avatar-info-detail {
    flex: 1; min-width: 0;
}
.avatar-info-name {
    font-size: 0.82rem; font-weight: 600;
    color: var(--text);
}
.avatar-info-desc {
    font-size: 0.68rem;
    color: var(--text2);
    margin-top: 1px;
}
.avatar-info-voice {
    font-size: 0.62rem;
    color: var(--accent);
    margin-top: 2px;
}
.info-preview-btn {
    display: flex; align-items: center; gap: 4px;
    padding: 6px 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.72rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}
.info-preview-btn:hover { background: #b06e42; }
.info-preview-btn.playing {
    background: var(--text2);
}

/* ── Drop zone ── */
.drop-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.drop-zone.drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
    border-radius: 10px;
    background: rgba(196, 125, 78, 0.04);
}
.drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(196, 125, 78, 0.12);
    border-radius: 10px;
    z-index: 20;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.drop-zone.drag-over .drop-overlay {
    display: flex;
}
.drop-overlay-text {
    padding: 12px 24px;
    background: var(--accent);
    color: #fff;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow3);
}

/* ── Upload ── */
.upload-btn {
    background: none;
    border: 1.5px dashed var(--border);
    border-radius: 8px;
    padding: 8px;
    font-size: 0.75rem;
    color: var(--text2);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font);
}
.upload-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Engine ── */
.engine-row { display: flex; gap: 6px; }
.engine-option {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; gap: 2px;
    padding: 8px 4px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    box-shadow: var(--shadow);
}
.engine-option input { display: none; }
.engine-option.active { border-color: var(--accent); background: var(--accent-light); }
.engine-name { font-size: 0.75rem; font-weight: 600; color: var(--text); }
.engine-desc { font-size: 0.6rem; color: var(--text2); }

/* ── Status ── */
.sidebar-status {
    margin-top: auto;
    display: flex; align-items: center; gap: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text3);
}
.dot.on { background: var(--green); }
.dot.off { background: var(--red); }
.sidebar-status span:nth-child(2) { font-size: 0.7rem; color: var(--text2); }
.stats-btn {
    margin-left: auto;
    width: 28px; height: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center; justify-content: center;
    color: var(--text2);
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.stats-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Stats modal ── */
.stats-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 500;
    display: flex;
    align-items: center; justify-content: center;
}
.stats-modal.hidden { display: none; }
.stats-modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 28px;
    width: 90%; max-width: 400px;
    position: relative;
    box-shadow: var(--shadow3);
}
.stats-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none; border: none;
    font-size: 1.3rem;
    color: var(--text2);
    cursor: pointer;
    line-height: 1;
}
.stats-close:hover { color: var(--text); }
.stats-title {
    font-size: 1rem; font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.stats-card {
    text-align: center;
    padding: 12px 8px;
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
}
.stats-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
}
.stats-label {
    font-size: 0.65rem;
    color: var(--text2);
    margin-top: 2px;
}
.stats-section-label {
    font-size: 0.72rem; font-weight: 600;
    color: var(--text2);
    margin-bottom: 8px;
}
.stats-top-chars {
    display: flex; flex-direction: column; gap: 6px;
}
.stats-char-row {
    display: flex; align-items: center; gap: 10px;
    font-size: 0.78rem;
}
.stats-char-name {
    flex: 1;
    color: var(--text);
}
.stats-char-bar {
    height: 6px;
    background: var(--accent);
    border-radius: 3px;
    min-width: 4px;
    transition: width 0.3s ease;
}
.stats-char-count {
    font-size: 0.68rem;
    color: var(--text2);
    min-width: 24px;
    text-align: right;
}

/* ── Main ── */
.main {
    flex: 1; display: flex;
    flex-direction: column; min-width: 0;
    background: linear-gradient(180deg, var(--bg-stage-top) 0%, var(--bg-stage-bottom) 100%);
}

/* ── Tabs ── */
.tabs {
    display: flex; gap: 2px;
    padding: 16px 24px 0;
}
.tab {
    padding: 10px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    color: var(--text2);
    font-size: 0.85rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}
.tab-title {
    font-weight: 600;
    font-size: 0.85rem;
}
.tab-sub {
    font-size: 0.62rem;
    color: var(--text3);
    font-weight: 400;
}
.tab.active {
    background: var(--bg-stage-top);
    color: var(--accent);
    border-color: var(--accent);
    border-bottom: 1px solid var(--bg-stage-top);
    position: relative;
    z-index: 1;
}
.tab.active .tab-title { color: var(--accent); }
.tab.active .tab-sub { color: var(--accent); opacity: 0.7; }

/* ── Theme toggle ── */
.theme-toggle {
    margin-left: auto;
    align-self: center;
    width: 36px; height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center; justify-content: center;
    color: var(--text2);
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: block; }
[data-theme="dark"] .scene-card { background: linear-gradient(135deg, #222228 0%, #1c1c20 100%); }
[data-theme="dark"] .loading { background: rgba(21,21,24,0.88); }
[data-theme="dark"] .input-bar { background: rgba(26,26,30,0.8); }

/* ── Stage ── */
.stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 24px;
    gap: 14px;
    overflow-y: auto;
}

/* ── Video wrap ── */
.video-wrap {
    position: relative;
    width: 100%; max-width: 480px;
    min-height: 280px;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow2);
    display: flex; align-items: center; justify-content: center;
    transition: box-shadow 0.3s ease;
}
.video-wrap.playing {
    box-shadow: 0 0 0 2px rgba(196, 125, 78, 0.25), 0 4px 20px rgba(196, 125, 78, 0.15);
}
.video-wrap video {
    width: 100%; height: auto;
    display: none;
    border-radius: var(--radius);
}
.video-wrap video.visible { display: block; }

/* ── Placeholder with scene templates ── */
.placeholder {
    display: flex; flex-direction: column;
    align-items: center;
    padding: 24px;
    width: 100%;
}
.placeholder.hidden { display: none; }

.scene-templates {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 420px;
}
.scene-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 8px 14px;
    background: linear-gradient(135deg, #fefcfa 0%, #f8f4ef 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}
.scene-card:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow2);
    border-color: var(--accent);
}
.scene-card:active {
    transform: scale(0.98);
}
.scene-icon {
    font-size: 1.6rem;
    line-height: 1;
    margin-bottom: 2px;
}
.scene-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}
.scene-desc {
    font-size: 0.62rem;
    color: var(--text3);
    line-height: 1.3;
}

/* ── Loading with step progress ── */
.loading {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(6px);
    z-index: 10; border-radius: var(--radius);
    gap: 14px;
}
.loading.hidden { display: none; }

.step-progress {
    display: flex;
    align-items: center;
    gap: 0;
}
.step-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.3s ease;
    flex-shrink: 0;
}
.step-dot.active {
    background: var(--accent);
    box-shadow: 0 0 8px rgba(196, 125, 78, 0.4);
    animation: stepPulse 1.2s ease-in-out infinite;
}
.step-dot.done {
    background: var(--green);
    box-shadow: none;
    animation: none;
}
.step-line {
    width: 32px; height: 2px;
    background: var(--border);
    transition: background 0.3s ease;
}
.step-line.done {
    background: var(--green);
}

@keyframes stepPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; }
}

.loading p { font-size: 0.82rem; color: var(--text2); }
.loading-timer { font-size: 0.72rem; color: var(--text3); }

.badge {
    position: absolute; top: 10px; right: 10px;
    background: var(--accent);
    color: #fff;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 5;
}
.badge.hidden { display: none; }

/* ── Share button ── */
.share-btn {
    position: absolute;
    bottom: 10px; right: 54px;
    width: 36px; height: 36px;
    background: var(--accent2);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center; justify-content: center;
    box-shadow: var(--shadow2);
    z-index: 5;
    transition: all 0.2s ease;
}
.share-btn:hover { background: #4a6db5; transform: scale(1.08); }
.share-btn.hidden { display: none; }
.share-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Download button ── */
.download-btn {
    position: absolute;
    bottom: 10px; right: 10px;
    width: 36px; height: 36px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center; justify-content: center;
    box-shadow: var(--shadow2);
    z-index: 5;
    transition: all 0.2s ease;
}
.download-btn:hover { background: #b06e42; transform: scale(1.08); }
.download-btn.hidden { display: none; }

/* ── Fullscreen button ── */
.fullscreen-btn {
    position: absolute;
    bottom: 10px; left: 10px;
    width: 36px; height: 36px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center; justify-content: center;
    box-shadow: var(--shadow2);
    z-index: 5;
    transition: all 0.2s ease;
}
.fullscreen-btn:hover { background: #b06e42; transform: scale(1.08); }
.fullscreen-btn.hidden { display: none; }

/* ── LLM box ── */
.llm-box {
    max-width: 480px; width: 100%;
    padding: 14px 18px;
    background: var(--bg-card);
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.65;
    border-left: 3px solid var(--accent);
    box-shadow: var(--shadow);
    color: var(--text);
}
.llm-box.hidden { display: none; }

/* ── Chat history bubbles ── */
.chat-history {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}
.chat-history::-webkit-scrollbar { width: 3px; }
.chat-history::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.chat-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.6;
    max-width: 85%;
    word-break: break-word;
}
.chat-bubble.user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble.ai {
    align-self: flex-start;
    background: var(--bg);
    color: var(--text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

.clear-chat-btn {
    margin-top: 8px;
    align-self: center;
    padding: 5px 14px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 0.7rem;
    color: var(--text2);
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s ease;
}
.clear-chat-btn:hover { border-color: var(--red); color: var(--red); }
.clear-chat-btn.hidden { display: none; }

/* ── History panel ── */
.history-panel {
    max-width: 480px; width: 100%;
    display: flex; flex-direction: column; gap: 8px;
}
.history-panel.hidden { display: none; }
.history-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 2px;
    -webkit-overflow-scrolling: touch;
}
.history-list::-webkit-scrollbar { height: 3px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.history-item {
    flex: 0 0 100px;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    background: var(--bg-card);
    box-shadow: var(--shadow);
}
.history-item:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow2); }
.history-item.active { border-color: var(--accent); }
.history-item video {
    width: 100%; height: 64px;
    object-fit: cover;
    display: block;
    pointer-events: none;
}
.history-meta {
    padding: 3px 6px;
    font-size: 0.58rem;
    color: var(--text2);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Samples ── */
.samples {
    max-width: 480px; width: 100%;
    display: flex; flex-direction: column; gap: 8px;
}
.samples.hidden { display: none; }
.samples-label {
    font-size: 0.72rem; font-weight: 600;
    color: var(--text2); text-transform: uppercase;
    letter-spacing: 0.5px;
}
.samples-list { display: flex; flex-wrap: wrap; gap: 6px; }
.sample-chip {
    padding: 7px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.78rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font);
    box-shadow: var(--shadow);
}
.sample-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
    transform: scale(1.03);
}

/* ── Input bar ── */
.input-bar {
    padding: 14px 24px 20px;
    border-top: 1px solid var(--border);
    display: flex; gap: 10px;
    justify-content: center;
    background: rgba(254, 253, 251, 0.8);
    backdrop-filter: blur(8px);
}
.input-wrap {
    position: relative;
    width: 100%; max-width: 380px;
}
.input-bar textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    padding: 13px 16px 13px;
    font-size: 0.9rem;
    resize: none;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow);
}
.input-bar textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(196, 125, 78, 0.1);
}
.input-bar textarea::placeholder { color: var(--text3); }

.char-count {
    position: absolute;
    bottom: 6px; right: 12px;
    font-size: 0.62rem;
    color: var(--text3);
    pointer-events: none;
    transition: color 0.2s ease;
}
.char-count.warn { color: var(--orange); }
.char-count.error { color: var(--red); font-weight: 600; }

/* ── Subtitle toggle ── */
.subtitle-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    align-self: center;
}
.subtitle-toggle input { display: none; }
.subtitle-slider {
    width: 32px; height: 18px;
    background: var(--border);
    border-radius: 9px;
    position: relative;
    transition: background 0.2s ease;
}
.subtitle-slider::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.subtitle-toggle input:checked + .subtitle-slider {
    background: var(--accent);
}
.subtitle-toggle input:checked + .subtitle-slider::after {
    transform: translateX(14px);
}
.subtitle-label {
    font-size: 0.72rem;
    color: var(--text2);
    white-space: nowrap;
}

#send-btn {
    padding: 12px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: var(--shadow);
    align-self: flex-start;
}
#send-btn:hover:not(:disabled) { background: #b06e42; transform: translateY(-1px); box-shadow: var(--shadow2); }
#send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Shortcuts help ── */
.shortcuts-help {
    position: fixed;
    bottom: 16px; right: 16px;
    z-index: 200;
    cursor: pointer;
}
.shortcuts-icon {
    display: flex;
    align-items: center; justify-content: center;
    width: 28px; height: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text2);
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}
.shortcuts-help:hover .shortcuts-icon {
    border-color: var(--accent);
    color: var(--accent);
}
.shortcuts-tooltip {
    display: none;
    position: absolute;
    bottom: 36px; right: 0;
    background: var(--text);
    color: var(--bg);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.72rem;
    white-space: nowrap;
    box-shadow: var(--shadow3);
    pointer-events: none;
}
.shortcuts-help:hover .shortcuts-tooltip,
.shortcuts-help.active .shortcuts-tooltip {
    display: block;
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 28px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: var(--bg);
    padding: 12px 28px;
    border-radius: 24px;
    font-size: 0.82rem;
    z-index: 999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: var(--shadow3);
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.hidden { display: none; }

/* ── Hamburger (hidden on desktop) ── */
.hamburger {
    display: none;
    position: fixed;
    top: 12px; left: 12px;
    z-index: 200;
    width: 40px; height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    align-items: center; justify-content: center;
    box-shadow: var(--shadow2);
    color: var(--accent);
    transition: all 0.2s ease;
}
.hamburger:hover { background: var(--accent-light); }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 99;
}

/* ── Mobile ── */
@media (max-width: 767px) {
    .hamburger { display: flex; }

    .app { flex-direction: column; height: 100vh; }

    .sidebar {
        position: fixed;
        top: 0; left: 0;
        width: 280px;
        height: 100vh;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
        padding-top: 56px;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }

    .avatar-grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: none;
        gap: 8px;
        padding: 4px 2px;
        -webkit-overflow-scrolling: touch;
    }
    .avatar-card {
        flex: 0 0 76px;
        min-width: 76px;
    }

    .main {
        flex: 1;
        min-height: 0;
        padding-top: 48px;
    }

    .tabs { padding: 8px 14px 0; }
    .tab-sub { display: none; }

    .stage {
        padding: 12px 14px;
        justify-content: flex-start;
    }

    .video-wrap { max-width: 100%; min-height: 200px; }

    .scene-templates {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .scene-card { padding: 12px 6px 10px; }

    .input-bar {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        padding: 10px 12px calc(env(safe-area-inset-bottom, 8px) + 8px);
        background: var(--bg-sidebar);
        border-top: 1px solid var(--border);
        z-index: 50;
    }
    .input-wrap { max-width: none; flex: 1; }
    .input-bar textarea { max-width: none; }

    .llm-box, .samples, .history-panel { max-width: 100%; }
}
