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

:root {
    --bg: #0f1115;
    --surface: #1a1d23;
    --surface2: #242830;
    --border: #2e333b;
    --text: #e4e7eb;
    --text-dim: #8b919a;
    --accent: #6c5ce7;
    --accent-hover: #7f71ed;
    --green: #00b894;
    --red: #e17055;
    --yellow: #fdcb6e;
    --blue: #74b9ff;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}
.logo-img {
    height: 28px;
    width: auto;
}

.nav-links a {
    color: var(--text-dim);
    text-decoration: none;
    margin-left: 20px;
    font-size: 0.9rem;
}

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

main { max-width: 1300px; margin: 0 auto; padding: 24px; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-dim);
}
.empty-state h2 { color: var(--text); margin-bottom: 12px; }
.empty-state pre {
    background: var(--surface);
    padding: 12px 20px;
    border-radius: var(--radius);
    display: inline-block;
    margin: 16px 0;
    font-size: 0.9rem;
}

/* Progress / navigation dots */
.progress-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.clip-nav-dots { display: flex; gap: 6px; }

.dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: transparent;
    cursor: pointer;
    padding: 0;
}
.dot.active { border-color: var(--accent); background: var(--accent); }
.dot.skipped { border-color: var(--text-dim); background: var(--text-dim); opacity: 0.4; }
.dot.published { border-color: var(--green); background: var(--green); }

/* Review layout with sidebar */
.review-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 20px;
    max-width: 1200px;
}
@media (max-width: 900px) {
    .review-layout { grid-template-columns: 1fr; }
    .clip-sidebar { order: 2; }
}

/* Clip sidebar */
.clip-sidebar {
    position: sticky;
    top: 70px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
}
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.sidebar-count { font-size: 0.75rem; color: var(--text-dim); }
.clip-list { display: flex; flex-direction: column; gap: 8px; }

.clip-thumb {
    display: block;
    background: var(--surface);
    border: 2px solid transparent;
    border-radius: var(--radius);
    padding: 6px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}
.clip-thumb:hover { border-color: var(--border); }
.clip-thumb.active { border-color: var(--accent); }
.clip-thumb.skipped { opacity: 0.4; }
.clip-thumb.published { border-color: var(--green); }

.thumb-img {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}
.thumb-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.thumb-duration {
    position: absolute;
    bottom: 3px;
    right: 3px;
    background: rgba(0,0,0,0.75);
    color: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
}
.thumb-number {
    position: absolute;
    top: 3px;
    left: 3px;
    background: var(--accent);
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
}
.thumb-title {
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    margin-bottom: 3px;
}
.thumb-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}
.thumb-score {
    font-size: 0.65rem;
    color: var(--accent);
    font-weight: 600;
}

/* Clip main content */
.clip-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    min-width: 0;
}
@media (max-width: 768px) {
    .clip-main { grid-template-columns: 1fr; }
}

.video-panel video {
    width: 100%;
    border-radius: var(--radius);
    background: #000;
}

.info-panel h2 { font-size: 1.3rem; margin-bottom: 8px; }

.meta {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    font-size: 0.85rem;
}

.score {
    background: var(--accent);
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.duration, .timestamps { color: var(--text-dim); }

.status-badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-badge.skipped { background: var(--surface2); color: var(--text-dim); }
.status-badge.published { background: var(--green); color: #fff; }

.reason, .hook {
    background: var(--surface);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.caption-section { margin-bottom: 16px; }
.caption-section label { display: block; margin-bottom: 6px; font-size: 0.9rem; }

textarea {
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); }

.caption-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s;
}

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

.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-secondary:hover { background: var(--border); }

.btn-publish { background: var(--green); color: #fff; }
.btn-publish:hover { opacity: 0.9; }

.btn-download { background: var(--blue); color: #fff; }
.btn-download:hover { opacity: 0.9; }

.btn-skip { background: var(--surface2); color: var(--text-dim); }
.btn-skip:hover { background: var(--border); }

.btn-nav { background: var(--surface); color: var(--text); }
.btn-nav:hover { background: var(--surface2); }
.btn-nav:disabled { opacity: 0.3; cursor: not-allowed; }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.navigation { display: flex; gap: 8px; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: opacity 0.3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

/* Settings */
.settings-page { max-width: 500px; }
.settings-page h2 { margin-bottom: 20px; }

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.9rem;
    color: var(--text-dim);
}
.form-group input {
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 0.9rem;
}
.form-group input:focus { outline: none; border-color: var(--accent); }

/* Dashboard — Submit */
.submit-section { margin-bottom: 40px; }
.submit-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}
.submit-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    flex-shrink: 0;
}
.submit-header h2 { margin-bottom: 2px; }
.submit-subtitle {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.submit-form {
    display: flex;
    gap: 10px;
}
.submit-form input[type="text"] {
    flex: 1;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 0.95rem;
}
.submit-form input[type="text"]:focus { outline: none; border-color: var(--accent); }
.submit-form input[type="text"]::placeholder { color: var(--text-dim); }

.submit-main-row { display: flex; gap: 10px; }
.submit-main-row input[type="text"] { flex: 1; }
.submit-options {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-dim);
}
.input-sm {
    width: 80px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 8px;
    font-size: 0.85rem;
}
.input-sm:focus, .select-sm:focus { outline: none; border-color: var(--accent); }
.select-sm {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

/* Dashboard — Jobs list */
.jobs-section h2 { margin-bottom: 12px; }
.jobs-list { display: flex; flex-direction: column; gap: 10px; }

.job-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}
.job-card:hover { border-color: var(--accent); }

.job-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.job-badge {
    background: var(--surface2);
    color: var(--text-dim);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.job-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.job-timestamp {
    font-size: 0.75rem;
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
}
.job-card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.job-source { font-size: 0.8rem; color: var(--text-dim); word-break: break-all; }
.job-meta { font-size: 0.8rem; color: var(--text-dim); }

/* Strategy tag */
.strategy-tag {
    background: var(--surface2);
    color: var(--blue);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.job-tags { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.status-badge.done { background: var(--green); color: #fff; }
.status-badge.failed { background: var(--red); color: #fff; }
.status-badge.pending,
.status-badge.downloading,
.status-badge.extracting_audio,
.status-badge.transcribing,
.status-badge.identifying_clips,
.status-badge.cutting,
.status-badge.generating_captions { background: var(--yellow); color: #1a1d23; }

/* Job detail page */
.job-page {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 32px;
    align-items: start;
}
@media (max-width: 768px) {
    .job-page { grid-template-columns: 1fr; }
    .pipeline-sidebar { order: -1; }
}
.job-detail { min-width: 0; }
.job-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.job-detail-header h2 { font-size: 1.2rem; }
.job-source-detail {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 20px;
    word-break: break-all;
}

/* Pipeline sidebar */
.pipeline-sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: sticky;
    top: 80px;
}
.pipeline-sidebar h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 14px;
}
.pipeline-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
}
.pipeline-steps::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border);
}
.pipeline-step {
    position: relative;
    padding-left: 26px;
    padding-bottom: 16px;
}
.pipeline-step:last-child { padding-bottom: 0; }
.pipeline-step::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg);
    z-index: 1;
}
.pipeline-step.completed::before {
    border-color: var(--green);
    background: var(--green);
}
.pipeline-step.active::before {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.25);
}
.step-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dim);
    line-height: 1.3;
}
.pipeline-step.completed .step-name,
.pipeline-step.active .step-name { color: var(--text); }
.step-desc {
    font-size: 0.72rem;
    color: var(--text-dim);
    opacity: 0.7;
    line-height: 1.4;
    margin-top: 2px;
}

.progress-section { margin-bottom: 24px; }
.progress-text { margin-bottom: 8px; font-size: 0.9rem; }
.progress-bar-track {
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}
.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.5s;
}
.progress-label { font-size: 0.8rem; color: var(--text-dim); }

.error-box {
    background: rgba(225, 112, 85, 0.1);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 0.85rem;
}
.error-box pre {
    margin-top: 8px;
    white-space: pre-wrap;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.btn-lg { padding: 12px 24px; font-size: 1rem; }

/* Review extras */
.back-link { color: var(--text-dim); text-decoration: none; font-size: 0.85rem; }
.back-link:hover { color: var(--text); }
.source-tag { color: var(--text-dim); font-style: italic; }
.strategy-tag {
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 3px;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
}

.empty-state a { color: var(--accent); }

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    width: 340px;
    text-align: center;
}
.login-icon {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    margin-bottom: 16px;
}
.login-logo {
    color: var(--text);
    font-size: 1.5rem;
    margin-bottom: 6px;
}
.login-tagline {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 24px;
}
.login-box form { display: flex; flex-direction: column; gap: 12px; }
.login-box input[type="password"] {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 0.95rem;
    text-align: center;
}
.login-box input[type="password"]:focus { outline: none; border-color: var(--accent); }
.login-box input[type="password"]::placeholder { color: var(--text-dim); }

/* Flash messages */
.flash-container { max-width: 1100px; margin: 0 auto; padding: 12px 24px 0; }
.flash {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 8px;
}
.flash-error { background: rgba(225, 112, 85, 0.15); border: 1px solid var(--red); color: var(--red); }
.flash-info { background: rgba(0, 184, 148, 0.15); border: 1px solid var(--green); color: var(--green); }

/* Spinner */
.btn-spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* Job card with delete */
.job-card-wrapper {
    display: flex;
    align-items: stretch;
    gap: 0;
}
.job-card-wrapper .job-card {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.job-delete-form {
    display: flex;
}
.btn-icon {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0 12px;
    font-size: 1rem;
    transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--red); color: #fff; }

/* Disk info bar */
.disk-info {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 20px;
    padding: 8px 14px;
    background: var(--surface);
    border-radius: var(--radius);
}

/* Settings sections */
.settings-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}
.settings-section h3 { margin-bottom: 12px; }
.disk-detail {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 12px;
    line-height: 1.8;
}

/* Logout link */
.nav-logout { color: var(--text-dim); opacity: 0.6; }
.nav-logout:hover { opacity: 1; }

/* Keyboard shortcut hint */
.kbd-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 8px;
}
.kbd-hint kbd {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: inherit;
    font-size: 0.75rem;
}

/* Usage / Costs page */
.usage-page { max-width: 800px; }
.usage-page h2 { margin-bottom: 20px; }
.usage-page h3 { margin: 28px 0 14px; }

.usage-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 8px;
}
@media (max-width: 640px) { .usage-cards { grid-template-columns: 1fr; } }

.usage-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.usage-card-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 6px;
}
.usage-card-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--green);
}
.usage-card:first-child .usage-card-value { color: var(--accent); font-size: 2rem; }
.usage-card-detail {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 6px;
    line-height: 1.5;
}

.usage-table-wrap { overflow-x: auto; }
.usage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.usage-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.usage-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.usage-table th.num, .usage-table td.num { text-align: right; }
.usage-table .detail { font-size: 0.7rem; color: var(--text-dim); }
.usage-table .job-id-cell { font-weight: 600; font-size: 0.8rem; white-space: nowrap; }
.usage-table .video-title-cell { color: var(--text-dim); }
.usage-table .total-cell { font-weight: 600; color: var(--accent); }
.usage-table tbody tr:hover { background: var(--surface); }

.empty-hint { color: var(--text-dim); font-size: 0.9rem; margin: 20px 0; }

/* History page */
.history-page { max-width: 1000px; }
.history-page h2 { margin-bottom: 4px; }
.history-subtitle { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 20px; }
.history-table-wrap { overflow-x: auto; }
.archived-row { opacity: 0.5; }
.archived-tag {
    background: var(--surface2);
    color: var(--text-dim);
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.timestamp-cell { font-size: 0.8rem; color: var(--text-dim); white-space: nowrap; }
.error-cell { max-width: 250px; }
.error-summary {
    font-size: 0.75rem;
    color: var(--red);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.error-detail {
    font-size: 0.7rem;
    color: var(--text-dim);
    white-space: pre-wrap;
    margin-top: 6px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface);
    padding: 8px;
    border-radius: 4px;
}

.usage-footnote {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-dim);
}
