:root {
    --bg-color: #000000;
    --panel-bg: #000000;
    --primary: #6366f1;
    --accent: #a855f7;
    --text: #f1f5f9;
    --border: rgba(255, 255, 255, 0.1);
    --glass: blur(16px);
}

body {
    background: var(--bg-color);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    margin: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    /* background-image: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 40%); */
}

.app-container {
    width: 98%;
    max-width: 1800px;
    height: 96vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.panel {
    background: var(--panel-bg);
    border: none;
    backdrop-filter: var(--glass);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* === LEFT PANEL === */
.left-panel {
    justify-content: stretch;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
}

.visual-wrapper {
    width: 100%;
    flex-grow: 1;
    /* Match the height of the chat box */
    background: #000;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.05);
    position: relative;
    overflow: hidden;
    margin-bottom: 0;
    /* Align with bottom of chat */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Removed Noir / dark vignette to keep face bright and clear */

.avatar-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: high-quality;
}

.video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(226, 232, 240, 0.9);
    font-size: 0.95rem;
    letter-spacing: 0.3px;
    background: rgba(0, 0, 0, 0.25);
    pointer-events: none;
    text-align: center;
    padding: 16px;
}

/* legacy: avatar-image removed from UI */

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    background: transparent;
    display: none;
    z-index: 2;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: high-quality;
}

.lang-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 10px;
}

.lang-control label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #94a3b8;
}

.lang-control select {
    background: transparent;
    border: none;
    color: white;
    flex-grow: 1;
    outline: none;
    font-size: 1rem;
    cursor: pointer;
}

.lang-control select option {
    background: #111;
}

/* Compact version for footer (below chat input) */
.lang-control.compact {
    padding: 8px 10px;
    background: #000;
    border: none;
}

.lang-control.compact label {
    min-width: 78px;
}

/* Left panel status */
.status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    color: #cbd5e1;
    font-size: 0.9rem;
}

.status-text {
    color: #cbd5e1;
}

/* === RIGHT PANEL === */
.right-panel {
    padding: 0;
    /* Important for full width chat */
    gap: 0;
}

/* Story Section */
.story-section {
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border);
    transition: all 0.3s ease;
}

.story-header {
    padding: 15px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.story-header h3 {
    margin: 0;
    font-size: 0.9rem;
    letter-spacing: 1px;
    color: #94a3b8;
}

.story-header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.story-subtitle {
    font-size: 0.8rem;
    color: rgba(148, 163, 184, 0.85);
}

.story-header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: #e2e8f0;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
}

.header-btn.secondary {
    background: rgba(99, 102, 241, 0.18);
}

.story-content {
    padding: 0 24px 20px 24px;
    display: block;
}

.story-section.collapsed .story-content {
    display: none;
}

textarea {
    width: 100%;
    height: 80px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: white;
    padding: 10px;
    font-family: inherit;
    resize: none;
    box-sizing: border-box;
    margin-bottom: 12px;
}

.action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-btn {
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.file-btn:hover {
    color: white;
}

.primary-btn {
    background: white;
    color: black;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.story-error {
    margin: 8px 0 12px 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.08);
    color: rgba(254, 202, 202, 0.95);
    font-size: 0.9rem;
}

/* Chat */
.chat-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 20px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.ai-msg {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.07);
    color: #cbd5e1;
    border-bottom-left-radius: 4px;
}

.user-msg {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.input-area {
    display: flex;
    gap: 10px;
    background: #000;
    padding: 8px;
    border-radius: 12px;
    border: none;
}

.chat-footer-controls {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.audio-control.compact {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.audio-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: #e2e8f0;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 108px;
    text-align: center;
}

.audio-btn[aria-pressed="true"] {
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(99, 102, 241, 0.45);
}

#chat-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: white;
    padding: 8px;
    outline: none;
    font-size: 1rem;
}

.send-btn {
    background: var(--primary);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic-btn {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: #e2e8f0;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic-icon {
    width: 18px;
    height: 18px;
    display: block;
}

.mic-btn[aria-pressed="true"] {
    background: rgba(99, 102, 241, 0.25);
}

/* Loader */
.loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}