:root {
    --bg-primary: #fafafa;
    --bg-secondary: #f0f0f0;
    --bg-tertiary: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #e0e0e0;
    --accent-primary: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #dbeafe;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-light: #fee2e2;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #0f0f0f;
        --bg-secondary: #1a1a1a;
        --bg-tertiary: #262626;
        --text-primary: #f5f5f5;
        --text-secondary: #c0c0c0;
        --text-tertiary: #808080;
        --border-color: #333333;
        --accent-primary: #3b82f6;
        --accent-hover: #1e40af;
        --accent-light: #1e3a8a;
        --success: #10b981;
        --success-hover: #059669;
        --danger: #f87171;
        --danger-light: #450a0a;
    }
}

:root[data-theme="dark"] {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #262626;
    --text-primary: #f5f5f5;
    --text-secondary: #c0c0c0;
    --text-tertiary: #808080;
    --border-color: #333333;
    --accent-primary: #3b82f6;
    --accent-hover: #1e40af;
    --accent-light: #1e3a8a;
    --danger: #f87171;
    --danger-light: #450a0a;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    height: 60px;
}

.logo {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-primary);
    letter-spacing: -0.5px;
}

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

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

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

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

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

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

[hidden] {
    display: none !important;
}

.login-gate {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.login-box {
    text-align: center;
    padding: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    min-width: 280px;
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 8px;
}

.login-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.container {
    display: flex;
    height: calc(100vh - 60px);
    gap: 0;
}

.sidebar-left {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-title {
    padding: 16px 16px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.media-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.empty-state {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
    line-height: 1.8;
}

.media-item {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    gap: 12px;
    align-items: center;
}

.media-item:hover {
    background: var(--accent-light);
    border-color: var(--accent-primary);
}

.media-item.active {
    background: var(--accent-light);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.media-thumbnail {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: 600;
}

.media-info {
    flex: 1;
    min-width: 0;
}

.media-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-duration {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    padding: 20px;
    gap: 16px;
    overflow: hidden;
}

.preview-section {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

#previewVideo {
    max-width: 100%;
    max-height: 100%;
    display: none;
}

#previewVideo.active {
    display: block;
}

.preview-placeholder {
    color: var(--text-tertiary);
    font-size: 14px;
}

.preview-placeholder.hidden {
    display: none;
}

.timeline-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.timeline-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timeline-container {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 6px;
    overflow: hidden;
    height: 90px;
    border: 1px solid var(--border-color);
    user-select: none;
}

.timeline-frames {
    display: flex;
    height: 90px;
    align-items: stretch;
    gap: 1px;
    padding: 4px;
    background: var(--bg-secondary);
    position: relative;
}

.frame {
    flex: 1;
    background: linear-gradient(to bottom, #667eea 0%, #764ba2 50%, #667eea 100%);
    background-size: cover;
    background-position: center;
    border-radius: 2px;
    opacity: 0.4;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.frame.selected {
    opacity: 1;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.timeline-handle {
    position: absolute;
    top: 0;
    width: 10px;
    margin-left: -5px;
    height: 100%;
    cursor: ew-resize;
    z-index: 10;
}

.timeline-handle::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-primary);
    transform: translateX(-50%);
    border-radius: 2px;
}

.timeline-selection {
    position: absolute;
    top: 0;
    height: 100%;
    background: var(--accent-primary);
    opacity: 0.15;
    border-left: 3px solid var(--accent-primary);
    border-right: 3px solid var(--accent-primary);
    pointer-events: none;
}

.timeline-playhead {
    position: absolute;
    width: 2px;
    height: 100%;
    background: white;
    z-index: 5;
    pointer-events: none;
    display: none;
}

.timeline-info {
    display: flex;
    gap: 20px;
    font-size: 13px;
    align-items: center;
}

.time-display {
    display: flex;
    gap: 8px;
    align-items: center;
}

.time-value {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-secondary);
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    color: var(--accent-primary);
    font-weight: 600;
    min-width: 75px;
    text-align: center;
}

input.time-value {
    cursor: text;
}

input.time-value:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.time-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.sidebar-right {
    width: 240px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px;
    gap: 24px;
}

.control-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.current-video {
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.video-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 600;
}

.video-details {
    flex: 1;
    min-width: 0;
}

.video-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-all;
    line-height: 1.4;
}

.video-info {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.status-box {
    padding: 12px;
    background: var(--accent-light);
    border-radius: 6px;
    font-size: 13px;
    color: var(--accent-primary);
    border-left: 3px solid var(--accent-primary);
    line-height: 1.6;
    margin-top: auto;
}

.status-box.error {
    background: var(--danger-light);
    color: var(--danger);
    border-left-color: var(--danger);
}

.upload-button {
    width: 100%;
    padding: 14px 16px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
}

.upload-button:hover:not(:disabled) {
    background: var(--success-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.upload-button:disabled {
    background: var(--border-color);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s;
    z-index: 100;
}

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

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

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

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}