:root {
    --bg-dark: #1a1b26;
    --panel-bg: #24283b;
    --primary: #7aa2f7;
    --primary-hover: #7dcfff;
    --primary-soft: rgba(122, 162, 247, 0.16);
    --accent: #bb9af7;
    --text-main: #c0caf5;
    --text-muted: #7f88b2;
    --border: #414868;
    --success: #9ece6a;
    --warning: #e0af68;
    --danger: #f7768e;
    --surface-deep: #16161e;
}

body {
    margin: 0; 
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background:
        radial-gradient(circle at top, rgba(122, 162, 247, 0.16), transparent 32%),
        radial-gradient(circle at 85% 15%, rgba(187, 154, 247, 0.12), transparent 26%),
        linear-gradient(180deg, #1f2335 0%, var(--bg-dark) 40%, var(--surface-deep) 100%);
    color: var(--text-main);
    display: flex; 
    flex-direction: column; 
    align-items: center;
    min-height: 100vh;
}

.video-header {
    width: 100%; 
    max-width: 1200px;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 20px; 
    box-sizing: border-box;
    border-bottom: 1px solid var(--border);
    margin-bottom: 40px;
}

.video-header h1 { 
    margin: 0; 
    font-size: 1.5rem; 
    color: var(--text-main);
}

.nav-links a { 
    color: var(--text-muted); 
    text-decoration: none; 
    margin-left: 20px; 
    font-size: 1rem;
    transition: color 0.2s;
}

.nav-links a:hover { 
    color: var(--primary); 
}

.video-main {
    width: 100%; 
    max-width: 800px;
    padding: 0 20px; 
    box-sizing: border-box;
}

.upload-panel, .result-panel {
    background: linear-gradient(135deg, rgba(36, 40, 59, 0.94), rgba(31, 35, 53, 0.92));
    border-radius: 16px;
    padding: 50px 40px;
    border: 2px dashed var(--border);
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.upload-panel.dragover {
    border-color: var(--primary);
    background-color: #292e42;
    transform: scale(1.02);
}

.icon-upload { 
    font-size: 4rem; 
    margin-bottom: 15px; 
}

#uploadPrompt h2 {
    margin-bottom: 10px;
    font-size: 1.5rem;
}

#uploadPrompt p {
    color: var(--text-muted);
}

#videoPlayer { 
    width: 100%; 
    max-height: 400px; 
    border-radius: 8px; 
    margin-bottom: 15px; 
    background: #000; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

#fileInfo { 
    color: var(--text-main); 
    margin-bottom: 20px; 
    font-weight: 500;
}

.progress-bar-container {
    width: 100%; 
    height: 20px; 
    background: var(--bg-dark);
    border-radius: 10px; 
    overflow: hidden; 
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.progress-bar {
    height: 100%; 
    background: linear-gradient(90deg, var(--primary), var(--primary-hover), var(--accent)); 
    width: 0%;
    transition: width 0.2s; 
    font-size: 12px; 
    line-height: 20px; 
    color: white;
    font-weight: bold;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.action-buttons-top {
    margin-bottom: 24px;
}

.action-buttons-bottom {
    margin-top: 30px;
}

.btn {
    padding: 12px 28px; 
    border: none; 
    border-radius: 8px;
    font-size: 1.1rem; 
    cursor: pointer; 
    font-weight: 600;
    transition: all 0.2s;
}

.btn.primary { 
    background: var(--primary); 
    color: white; 
    box-shadow: 0 10px 24px rgba(122, 162, 247, 0.24);
}

.btn.primary:hover:not(:disabled) { 
    background: var(--primary-hover); 
    transform: translateY(-2px);
}

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

.btn.secondary:hover:not(:disabled) { 
    background: rgba(65, 72, 104, 0.64); 
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 10px;
}

.success-title {
    color: var(--success);
    font-size: 1.8rem;
    margin-bottom: 30px;
    margin-top: 0;
}

.result-item {
    display: flex; 
    align-items: center; 
    margin-bottom: 15px;
    background: var(--bg-dark); 
    padding: 12px; 
    border-radius: 8px;
    border: 1px solid var(--border);
}

.result-item label { 
    width: 100px; 
    text-align: right; 
    margin-right: 15px; 
    color: var(--text-muted);
    font-weight: bold;
}

.result-item input {
    flex: 1; 
    padding: 10px; 
    border: 1px solid var(--border);
    background: var(--panel-bg); 
    color: white; 
    border-radius: 6px; 
    outline: none;
    font-family: monospace;
}

.result-item button {
    margin-left: 15px; 
    padding: 10px 20px;
    background: var(--primary); 
    color: white; 
    border: none; 
    border-radius: 6px; 
    cursor: pointer;
    font-weight: bold;
}

.result-item button:hover {
    background: var(--primary-hover);
}

.metadata-grid {
    display: flex; 
    justify-content: center; 
    gap: 30px; 
    margin-top: 30px; 
    margin-bottom: 30px;
    padding: 20px; 
    background: var(--bg-dark); 
    border-radius: 8px;
    border: 1px solid var(--border);
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.meta-item span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.meta-item b {
    font-size: 1.2rem;
    color: var(--text-main);
}

.rss-notify {
    background: rgba(158, 206, 106, 0.08);
    border: 1px solid rgba(158, 206, 106, 0.24);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.rss-notify p {
    margin-top: 0;
    color: var(--success);
    font-weight: bold;
}

.rss-link { 
    display: inline-block; 
    color: white; 
    font-weight: bold; 
    text-decoration: none;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    padding: 10px 20px;
    border-radius: 6px;
    transition: background 0.2s;
}

.rss-link:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--accent));
}

.mt-10 { 
    margin-top: 30px; 
}

.queue-item {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.queue-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 5px;
}

.queue-item-title {
    font-weight: bold;
    color: var(--primary);
    word-break: break-all;
}

.queue-item-size {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.queue-item-status {
    font-size: 0.9rem;
    font-weight: bold;
}

.status-pending { color: var(--text-muted); }
.status-uploading { color: var(--warning); }
.status-success { color: var(--success); }
.status-error { color: var(--danger); }

.queue-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.queue-inputs input, .queue-inputs textarea, .queue-result input {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--panel-bg);
    color: white;
    box-sizing: border-box;
}

.queue-result {
    background: rgba(158, 206, 106, 0.08);
    padding: 10px;
    border-radius: 6px;
    display: none;
    flex-direction: column;
    gap: 10px;
}

.queue-result-row {
    display: flex;
    gap: 10px;
}

.queue-result-row input {
    flex: 1;
}

.queue-result-row button {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    padding: 0 15px;
}

.history-panel {
    margin-top: 24px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.session-stats-panel {
    margin-top: 24px;
    padding: 18px 20px;
    border-radius: 14px;
    background: rgba(22, 22, 30, 0.56);
    border: 1px solid rgba(122, 162, 247, 0.16);
    text-align: left;
}

.session-stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.session-stats-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-main);
}

.session-stats-note {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.session-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.session-stat-card {
    padding: 14px;
    border-radius: 12px;
    background: rgba(31, 35, 53, 0.88);
    border: 1px solid rgba(122, 162, 247, 0.12);
}

.session-stat-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.session-stat-value {
    display: block;
    color: var(--text-main);
    font-size: 1.2rem;
    font-weight: 700;
}

.history-panel[hidden] {
    display: none;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.history-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.history-clear-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: bold;
}

.history-clear-btn:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
}

.history-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 24px 12px 12px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
}

.history-thumb,
.history-thumb-fallback {
    width: 84px;
    height: 84px;
    border-radius: 12px;
    flex-shrink: 0;
    background: #1f2335;
    border: 1px solid rgba(122, 162, 247, 0.12);
}

.history-thumb {
    object-fit: cover;
}

.history-thumb-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    font-size: 1.6rem;
    font-weight: bold;
}

.history-content {
    min-width: 0;
    flex: 1;
}

.history-title {
    margin: 0 0 6px;
    font-weight: bold;
    color: var(--text-main);
    word-break: break-word;
}

.history-link {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-decoration: none;
    word-break: break-all;
    margin-bottom: 6px;
}

.history-link:hover {
    color: var(--primary);
}

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

.history-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.history-action {
    border: none;
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: bold;
    text-decoration: none;
    font-size: 0.9rem;
}

.history-action.copy {
    background: var(--primary);
    color: white;
}

.history-action.open {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
}

@media (max-width: 640px) {
    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .history-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .session-stats-grid {
        grid-template-columns: 1fr;
    }

    .history-thumb,
    .history-thumb-fallback {
        width: 100%;
        height: 180px;
    }

    .history-actions {
        width: 100%;
    }
}
