:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --bg-hover: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
    --border: #333333;
    --shadow: rgba(0, 0, 0, 0.5);
    /* Aliases for shorthand usage */
    --bg: var(--bg-primary);
    --surface: var(--bg-secondary);
    --primary: var(--accent);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Header */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1.25rem;
}

.header-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
    min-width: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.logo span {
    color: var(--accent);
}

.auth-panel {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    order: 3;
    flex-shrink: 0;
}

.auth-summary {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 180px;
}

.auth-badge {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.auth-user {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.auth-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.token-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.auth-menu-wrap {
    position: relative;
}

.auth-avatar-btn {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid rgba(99, 102, 241, 0.35);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.24));
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.auth-avatar-btn:hover,
.auth-avatar-btn:focus-visible {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.24);
    outline: none;
}

.auth-menu {
    position: absolute;
    top: calc(100% + 0.65rem);
    right: 0;
    min-width: 250px;
    padding: 0.9rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.96);
    box-shadow: 0 18px 42px rgba(2, 6, 23, 0.35);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    z-index: 220;
}

.auth-menu.open {
    display: flex !important;
}

.auth-panel.menu-open .auth-avatar-btn {
    border-color: var(--accent);
    box-shadow: 0 16px 36px rgba(99, 102, 241, 0.22);
}

.auth-menu #auth-logout-btn,
.auth-menu #buy-more-btn {
    width: 100%;
    justify-content: center;
}

.token-balance-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.16);
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
}

.token-balance-badge.low {
    background: rgba(234, 179, 8, 0.14);
    border-color: rgba(234, 179, 8, 0.45);
    color: #fde68a;
}

.auth-notice {
    margin: 1rem 2rem 0;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(99, 102, 241, 0.35);
    background: rgba(99, 102, 241, 0.1);
    border-radius: 10px;
}

.auth-notice-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.auth-notice-copy {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.auth-notice-links {
    display: flex;
    gap: 1rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}

.auth-notice-links a,
.site-footer-links a,
.legal-back-link {
    color: #c7d2fe;
    text-decoration: none;
}

.auth-notice-links a:hover,
.site-footer-links a:hover,
.legal-back-link:hover {
    color: #e0e7ff;
    text-decoration: underline;
}

.billing-notice {
    margin: 1rem 2rem 0;
    padding: 1rem;
    border: 1px solid rgba(234, 179, 8, 0.35);
    background: rgba(234, 179, 8, 0.08);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.billing-notice-title {
    font-weight: 600;
    color: #fde68a;
}

.billing-notice-copy {
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin-top: 0.2rem;
}

.status-bar {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    margin-left: auto;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* Project Selector */
.project-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    order: 2;
    margin-right: 0;
    padding-right: 0;
    border-right: none;
    min-width: 0;
}

.status-bar {
    order: 2;
}

.project-selector select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    min-width: 180px;
    width: 220px;
    cursor: pointer;
}

.project-selector select:hover {
    border-color: var(--accent);
}

.project-selector select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

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

.project-actions button {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.project-actions button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.project-selector.disabled {
    opacity: 0.55;
}

.project-selector.disabled select,
.project-selector.disabled button {
    pointer-events: none;
}

/* Project Modal */
.project-list {
    max-height: 400px;
    overflow-y: auto;
}

.project-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.project-item:hover {
    background: var(--bg-tertiary);
}

.project-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-left: 3px solid var(--accent);
}

.project-info {
    flex: 1;
}

.project-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.project-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.project-item-actions {
    display: flex;
    gap: 0.5rem;
}

.project-item-actions button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.project-item-actions button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.project-item-actions button.danger:hover {
    border-color: var(--error);
    color: var(--error);
}

.new-project-form {
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.new-project-form input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.new-project-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.project-versions-header {
    margin-bottom: 1rem;
}

.project-versions-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.project-versions-project {
    font-size: 1rem;
    font-weight: 600;
}

.project-versions-create {
    display: grid;
    gap: 0.65rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
    margin-bottom: 1rem;
}

.project-versions-help {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.project-versions-list {
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.project-versions-empty {
    padding: 1rem;
    color: var(--text-secondary);
    text-align: center;
}

.project-version-item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.project-version-item:last-child {
    border-bottom: none;
}

.project-version-main {
    flex: 1;
    min-width: 0;
}

.project-version-topline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.35rem;
}

.project-version-date,
.project-version-meta,
.project-version-summary,
.project-version-note.muted {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.project-version-note {
    margin-bottom: 0.35rem;
}

.project-version-actions {
    display: flex;
    align-items: center;
}

.project-version-actions button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    cursor: pointer;
}

.project-version-actions button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Navigation Tabs */
.tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
}

.tab {
    padding: 1rem 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-weight: 500;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Main Content */
main {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

.site-footer {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.site-footer-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.legal-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 2.5rem 2rem 4rem;
}

.legal-header {
    margin-bottom: 2rem;
}

.legal-eyebrow {
    display: inline-block;
    margin-bottom: 0.75rem;
    color: var(--accent-hover);
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.legal-header h1 {
    font-size: 2.2rem;
    margin-bottom: 0.75rem;
}

.legal-header p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.legal-content {
    display: grid;
    gap: 1rem;
}

.legal-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem 1.35rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.legal-section h2 {
    font-size: 1.05rem;
    margin-bottom: 0.65rem;
}

.legal-section p,
.legal-section li {
    color: var(--text-secondary);
    line-height: 1.65;
}

.legal-section ul {
    margin: 0.75rem 0 0 1.25rem;
}

.legal-section li + li,
.legal-section p + p {
    margin-top: 0.55rem;
}

.legal-contact {
    color: var(--text-primary);
    font-weight: 600;
}

.panel {
    display: none;
}

.panel.active {
    display: block;
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

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

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
    margin-left: 8px;
    top: 50%;
    transform: translateY(-50%);
    right: 12px;
}

@keyframes btn-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

.generation-progress {
    background: var(--bg-secondary);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    display: none;
}

.generation-progress.active {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

/* Frame/Clip Cards */
.media-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
}

.media-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.media-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.media-thumbnail {
    aspect-ratio: 16/9;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
}

.media-thumbnail img,
.media-thumbnail video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-info {
    padding: 0.75rem;
}

.media-name {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.media-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.media-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border);
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.upload-zone-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.upload-zone-text {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.upload-zone-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

select.form-control {
    cursor: pointer;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
}
.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: var(--success);
}
.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: var(--error);
}

/* Comparison Results */
.comparison-result {
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.comparison-result.excellent {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.comparison-result.good {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.comparison-result.warning {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.comparison-result.poor {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.score-display {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.score-display.excellent { color: var(--success); }
.score-display.good { color: var(--success); }
.score-display.warning { color: var(--warning); }
.score-display.poor { color: var(--error); }

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.metric {
    text-align: center;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
}

.lightbox-content img,
.lightbox-content video {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
}

/* Timeline Styles */
.timeline-track {
    min-height: 120px;
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    overflow-x: auto;
    transition: all 0.2s;
}

.timeline-track.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.timeline-track:empty::before {
    content: "Drop clips here";
    color: var(--text-muted);
}

.timeline-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 80px;
}

.timeline-clip {
    flex-shrink: 0;
    width: 160px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    cursor: grab;
    transition: all 0.2s;
    position: relative;
}

.timeline-clip:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.timeline-clip.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.timeline-clip-thumb {
    width: 100%;
    height: 80px;
    object-fit: cover;
    background: var(--bg);
}

.timeline-clip-info {
    padding: 0.5rem;
    font-size: 0.75rem;
}

.timeline-clip-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    font-weight: 500;
}

.timeline-clip-duration {
    color: var(--text-muted);
}

.timeline-clip-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.timeline-clip-controls label {
    margin: 0;
}

.timeline-clip-controls .timeline-hold-select,
.timeline-clip-controls .timeline-trim-input {
    padding: 0.15rem 0.25rem;
    font-size: 0.65rem;
    min-width: 2.5rem;
}

.timeline-clip-controls .timeline-trim-input {
    width: 3.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.timeline-clip-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 10;
    pointer-events: auto;
}

.timeline-clip-remove:hover {
    background: rgba(220, 38, 38, 1);
    transform: scale(1.15);
}

.timeline-clip:hover .timeline-clip-remove {
    display: flex;
}

.timeline-clip-number {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    color: white;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timeline-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    min-height: 100px;
}

.pool-clip {
    width: 220px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    cursor: grab;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}

.pool-clip:hover {
    border-color: var(--accent);
}

.pool-clip.in-timeline {
    opacity: 0.4;
    border-style: dashed;
}

.pool-clip-thumb {
    width: 100%;
    height: 124px;
    object-fit: cover;
    background: var(--bg);
}

.pool-clip-info {
    padding: 0.65rem 0.75rem 0.5rem;
    font-size: 0.82rem;
    flex: 1;
}

.pool-clip-name {
    color: var(--text-primary);
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.35;
    min-height: 3.25em;
    margin-bottom: 0.35rem;
}

.pool-clip-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.pool-clip-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0 0.75rem 0.75rem;
}

.pool-clip-actions .btn {
    flex: 1;
    min-width: 0;
}

.pool-clip.dragging {
    opacity: 0.5;
}

/* Player Progress Dots */
.player-progress-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.player-progress-dot:hover {
    background: var(--text-muted);
    transform: scale(1.2);
}

.player-progress-dot.active {
    background: var(--primary);
    transform: scale(1.4);
    box-shadow: 0 0 10px var(--primary);
    animation: pulse 1s ease-in-out infinite;
}

.player-progress-dot.past {
    background: var(--success);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 10px var(--primary); }
    50% { box-shadow: 0 0 20px var(--primary); }
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.25rem;
}

/* Script Panel Styles */
.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.project-card:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.project-card-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.project-card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.project-card-progress {
    margin-top: 0.5rem;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.project-card-progress-bar {
    height: 100%;
    background: var(--success);
    transition: width 0.3s;
}

.character-tag, .location-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
}

.character-tag {
    border-color: var(--primary);
    color: var(--primary);
}

.location-tag {
    border-color: var(--accent);
    color: var(--accent);
}

/* Scene Cards */
.scene-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s;
}

.scene-card:hover {
    border-color: var(--primary);
}

.scene-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.scene-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

.scene-title {
    font-weight: 600;
    color: var(--text-primary);
}

.scene-location {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.scene-status {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.scene-status.pending { background: var(--border); color: var(--text-muted); }
.scene-status.ready { background: rgba(99, 102, 241, 0.2); color: var(--primary); }
.scene-status.in_progress { background: rgba(234, 179, 8, 0.2); color: var(--warning); }
.scene-status.complete { background: rgba(16, 185, 129, 0.2); color: var(--success); }

.scene-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0.5rem 0;
}

.scene-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.scene-meta-item {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.scene-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.onboarding-modal-content {
    border: 1px solid rgba(99, 102, 241, 0.35);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.onboarding-hero {
    margin-bottom: 1rem;
}

.onboarding-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.onboarding-copy {
    color: var(--text-secondary);
    line-height: 1.5;
}

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

.onboarding-stat {
    padding: 0.9rem 1rem;
    border-radius: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
}

.onboarding-stat-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.onboarding-stat-value {
    font-size: 1rem;
    font-weight: 600;
}

.onboarding-checklist {
    display: grid;
    gap: 0.75rem;
}

.onboarding-step {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.95rem 1rem;
    border-radius: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
}

.onboarding-step.complete {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.08);
}

.onboarding-step-badge {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 700;
    flex-shrink: 0;
}

.onboarding-step.complete .onboarding-step-badge {
    background: var(--success);
}

.onboarding-step-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.onboarding-step-copy {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.45;
}

.buy-more-summary {
    margin-bottom: 1rem;
}

.buy-more-balance {
    font-size: 1rem;
    margin-bottom: 0.4rem;
}

.buy-more-copy {
    color: var(--text-secondary);
    line-height: 1.45;
}

.buy-more-packages {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.9rem;
}

.buy-package-card {
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, var(--bg-secondary), var(--bg-primary));
}

.buy-package-name {
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.buy-package-tokens {
    color: var(--accent);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.buy-package-price {
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
}

.buy-more-result {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(99, 102, 241, 0.35);
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-secondary);
}

.admin-list {
    display: grid;
    gap: 0.75rem;
}

.admin-row {
    padding: 0.9rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
}

.admin-row-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.45rem;
    flex-wrap: wrap;
}

.admin-row-title {
    font-weight: 600;
}

.admin-row-meta {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.45;
}

.admin-row-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.admin-tag {
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.78rem;
}

/* Success Button */
.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.lightbox-close:hover {
    opacity: 1;
}

/* Prompts Viewer */
.prompts-content {
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 1.5rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 600px;
    overflow-y: auto;
}

.prompts-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px var(--shadow);
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast.success {
    border-color: var(--success);
}

.toast.error {
    border-color: var(--error);
}

.toast.loading {
    border-color: var(--accent);
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner.sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

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

/* Scene Builder / Asset Library Styles */
.asset-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.asset-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    text-align: center;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.asset-tab:hover {
    background: var(--bg);
}

.asset-tab.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
    font-weight: 500;
}

.grid-3.compact {
    gap: 0.75rem;
}

.asset-card {
    position: relative;
    border: 2px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    aspect-ratio: 1;
}

.asset-card:hover {
    border-color: var(--primary);
    transform: scale(1.02);
}

.asset-card.selected {
    border-color: var(--success);
    box-shadow: 0 0 0 2px var(--success);
}

.asset-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.asset-pdf-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(15, 23, 42, 0.9));
    color: white;
    text-align: center;
}

.asset-pdf-icon {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    background: rgba(239, 68, 68, 0.9);
}

.asset-pdf-name {
    font-size: 0.72rem;
    line-height: 1.2;
    word-break: break-word;
    max-width: 100%;
}

.asset-card-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    padding: 0.5rem 0.25rem 0.25rem;
    font-size: 0.7rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Frames tab: larger asset cards so thumbnails are easier to identify */
.assets-grid-large {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.25rem;
}

.assets-grid-large .asset-card {
    min-width: 140px;
    min-height: 140px;
}

.assets-grid-large .asset-card img {
    min-height: 140px;
}

.assets-grid-large .asset-card .asset-pdf-thumb {
    min-height: 140px;
}

.assets-grid-large .asset-card-label {
    font-size: 0.8rem;
    padding: 0.5rem 0.35rem 0.35rem;
    white-space: normal;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.asset-card-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.asset-card:hover .asset-card-delete {
    display: flex;
}

.asset-card-check {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--success);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.asset-card.selected .asset-card-check {
    display: flex;
}

.selected-assets-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 100px;
    padding: 0.5rem;
    border: 2px dashed var(--border);
    border-radius: 8px;
    background: var(--bg);
}

.selected-asset {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid var(--primary);
}

.selected-asset img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.selected-asset .asset-pdf-thumb {
    gap: 0.25rem;
    padding: 0.35rem;
}

.selected-asset .asset-pdf-icon {
    font-size: 0.6rem;
    padding: 0.2rem 0.35rem;
}

.selected-asset .asset-pdf-name {
    font-size: 0.55rem;
    line-height: 1.1;
}

.selected-asset-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--error);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.selected-asset-type {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 0.6rem;
    text-align: center;
    padding: 2px;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge.available {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.badge.unavailable {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.generate-ai-inline {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-bottom: 0.9rem;
    padding: 0.15rem 0;
    border-bottom: 1px solid transparent;
}

.generate-ai-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.18);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
}

.generate-ai-copy {
    color: var(--text-muted);
    font-size: 0.78rem;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* (Spinner defined above - see .spinner class) */

/* Comparison View */
.comparison-frames {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.comparison-frame {
    background: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
}

.comparison-frame-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    font-weight: 500;
}

.comparison-frame-image {
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comparison-frame-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Responsive */
@media (max-width: 1200px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .comparison-frames { grid-template-columns: 1fr; }
    .metrics-grid { grid-template-columns: 1fr; }
    header { flex-direction: column; gap: 1rem; }
    .header-brand { width: 100%; }
    .status-bar { order: 2; width: 100%; margin-left: 0; }
    .auth-panel { order: 3; margin-left: 0; width: 100%; justify-content: flex-end; }
    .project-selector { width: 100%; }
    .project-selector select { width: min(100%, 320px); }
    .tabs { overflow-x: auto; }
    .site-footer { padding: 0 2rem 2rem; flex-direction: column; align-items: flex-start; }
    .legal-page { padding: 2rem 1rem 3rem; }
    .legal-header h1 { font-size: 1.8rem; }
}

/* Workflow Guide */
.workflow-steps {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.workflow-step {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    white-space: nowrap;
}

.workflow-step-number {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.workflow-arrow {
    color: var(--text-muted);
    font-size: 1.5rem;
}

/* Sound Studio Styles */
.sound-browser-tab {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.sound-browser-tab.active {
    background: var(--accent);
    color: white;
}

.voice-item {
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    transition: background 0.2s;
}

.voice-item:hover {
    background: var(--bg-hover);
}

.voice-item.selected {
    background: var(--accent);
    color: white;
}

.voice-item .voice-icon {
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.voice-item .voice-info {
    flex: 1;
}

.voice-item .voice-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.voice-item .voice-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.voice-item.selected .voice-desc {
    color: rgba(255,255,255,0.7);
}

.library-item {
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    background: var(--bg-tertiary);
}

.library-item:hover {
    background: var(--bg-hover);
}

.library-item .lib-icon {
    font-size: 1.2rem;
}

.library-item .lib-info {
    flex: 1;
    min-width: 0;
}

.library-item .lib-name {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-item .lib-duration {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.library-drop-zone.drag-over {
    background: rgba(var(--accent-rgb, 100, 149, 237), 0.15);
    border: 2px dashed var(--accent);
}

/* Audio Tracks */
.audio-track {
    display: flex;
    border-bottom: 1px solid var(--border);
    min-height: 50px;
}

.audio-track:last-child {
    border-bottom: none;
}

.audio-track-header {
    width: 80px;
    min-width: 80px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.audio-track-content {
    flex: 1;
    position: relative;
    min-height: 50px;
    background: repeating-linear-gradient(
        90deg,
        var(--bg-tertiary) 0px,
        var(--bg-tertiary) 1px,
        transparent 1px,
        transparent 50px
    );
}

.audio-clip {
    position: absolute;
    height: 40px;
    top: 5px;
    background: var(--accent);
    border-radius: 4px;
    cursor: move;
    display: flex;
    align-items: center;
    padding: 0 0.5rem 0 28px;
    font-size: 0.7rem;
    color: white;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: opacity 0.2s, transform 0.1s;
}

.audio-clip::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    background: rgba(255,255,255,0.15);
    border-left: 1px solid rgba(255,255,255,0.25);
    pointer-events: none;
    border-radius: 0 4px 4px 0;
}

.audio-clip:hover::after {
    background: rgba(255,255,255,0.3);
    border-left: 1px solid rgba(255,255,255,0.5);
}

.audio-clip:hover {
    opacity: 0.9;
}

.audio-clip.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.audio-clip .clip-play-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(255,255,255,0.3);
    border: none;
    border-radius: 4px;
    width: 18px;
    height: 18px;
    font-size: 9px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

.audio-clip .clip-play-btn:hover {
    background: rgba(255,255,255,0.5);
}

.audio-clip .clip-delete-btn {
    position: absolute;
    top: 2px;
    right: 4px;
    background: rgba(255,0,0,0.7);
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    color: white;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.audio-clip:hover .clip-delete-btn {
    display: flex;
}

.audio-clip.selected {
    outline: 2px solid white;
    outline-offset: 1px;
}

.audio-clip[data-track="dialogue"] {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.audio-clip[data-track="narration"] {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.audio-clip[data-track="ambient"] {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
}

.audio-clip[data-track="sfx"] {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.audio-clip[data-track="music"] {
    background: linear-gradient(135deg, #ec4899, #db2777);
}

.track-volume {
    -webkit-appearance: none;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
}

.track-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

/* Scene markers on audio timeline */
.scene-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--warning);
    opacity: 0.7;
}

.scene-marker-label {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.6rem;
    color: var(--text-primary);
    background: var(--warning);
    padding: 0 3px;
    border-radius: 2px;
    white-space: nowrap;
}

/* ====================================================================
   Frame Picker - Thumbnail / List Toggle
   ==================================================================== */

.frame-picker-wrapper {
    position: relative;
}

.frame-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.frame-view-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    line-height: 1;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.frame-view-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.frame-view-toggle.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.frame-thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem;
    max-height: 320px;
    overflow-y: auto;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.frame-thumb-grid::-webkit-scrollbar {
    width: 6px;
}

.frame-thumb-grid::-webkit-scrollbar-track {
    background: transparent;
}

.frame-thumb-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.frame-thumb-grid::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.frame-thumb-item {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-secondary);
    transition: all 0.15s ease;
    position: relative;
}

.frame-thumb-item:hover {
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.frame-thumb-item.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.frame-thumb-item.selected::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--accent);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: bold;
    z-index: 1;
}

.frame-thumb-item img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
    background: var(--bg-tertiary);
}

.frame-thumb-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 0.7rem;
    z-index: 1;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.frame-thumb-name {
    font-size: 0.68rem;
    padding: 3px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
    text-align: center;
    background: var(--bg-secondary);
}

.frame-thumb-item.selected .frame-thumb-name {
    color: var(--accent);
    font-weight: 500;
}

/* Empty state for thumbnail grid */
.frame-thumb-grid .frame-thumb-empty {
    grid-column: 1 / -1;
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ====================================================================
   Accessibility
   ==================================================================== */

/* Skip to content link */
.sr-only {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    z-index: 10000;
    font-size: 1rem;
    border-radius: 4px;
}

/* Focus visible outlines for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 4px;
}

.modal:focus-visible {
    outline: none;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
