/* ── Base ─────────────────────────────────────────────────────────────────── */
:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-input: #232633;
    --border: #2e3247;
    --text: #e4e6ef;
    --text-dim: #8b8fa3;
    --accent: #6c5ce7;
    --accent-hover: #7e6ff0;
    --success: #2ecc71;
    --error: #e74c3c;
    --warning: #f39c12;
    --running: #3498db;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

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

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

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

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--accent);
}

/* ── Container ───────────────────────────────────────────────────────────── */
.container {
    max-width: 720px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

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

.label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.input-field {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.input-field:focus {
    border-color: var(--accent);
}

.textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

select.input-field {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8fa3' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    font-family: inherit;
    color: var(--text);
}

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

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

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

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

.btn-ghost:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

.btn-full {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}

.btn-download {
    background: var(--bg-input);
    border: 1px solid var(--border);
    flex: 1;
    min-width: 180px;
}

.btn-download:hover {
    border-color: var(--accent);
    background: var(--bg);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
}

.btn-sm:hover {
    border-color: var(--accent);
}

.download-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.audio-parts {
    margin-top: 0.75rem;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.audio-parts summary {
    cursor: pointer;
    padding: 0.5rem 0;
}

.audio-parts-grid {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

/* ── Progress ────────────────────────────────────────────────────────────── */
.progress-bar-container {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.3rem;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.progress-percent {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: right;
    margin-bottom: 1rem;
}

/* ── Timeline ────────────────────────────────────────────────────────────── */
.timeline {
    position: relative;
    padding-left: 0;
}

.tl-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
    position: relative;
}

/* Connecting line between nodes */
.tl-step:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 14px;
    top: 36px;
    bottom: -4px;
    width: 2px;
    background: var(--border);
    transition: background 0.3s;
}

.tl-step.done:not(:last-child)::after {
    background: var(--success);
    opacity: 0.4;
}

.tl-step.running:not(:last-child)::after {
    background: var(--running);
    opacity: 0.4;
}

/* Node circle */
.tl-node {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid var(--border);
    background: var(--bg);
    transition: all 0.3s;
    z-index: 1;
}

.tl-num {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dim);
    transition: color 0.3s;
}

/* States */
.tl-step.running .tl-node {
    border-color: var(--running);
    background: rgba(52, 152, 219, 0.15);
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.3);
}

.tl-step.running .tl-num {
    color: var(--running);
}

.tl-step.done .tl-node {
    border-color: var(--success);
    background: rgba(46, 204, 113, 0.15);
}

.tl-step.done .tl-num {
    color: var(--success);
}

.tl-step.done .tl-name {
    color: var(--text-dim);
}

.tl-step.failed .tl-node {
    border-color: var(--error);
    background: rgba(231, 76, 60, 0.15);
}

.tl-step.failed .tl-num {
    color: var(--error);
}

/* Pulse animation for running */
@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(52, 152, 219, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0); }
}

.tl-step.running .tl-node {
    animation: pulse-ring 1.5s ease infinite;
}

/* Content */
.tl-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
    padding-top: 0.25rem;
}

.tl-name {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.3;
}

.tl-detail {
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.3;
}

.tl-detail:empty { display: none; }

/* Elapsed time */
.tl-time {
    font-size: 0.75rem;
    color: var(--text-dim);
    white-space: nowrap;
    min-width: 44px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    padding-top: 0.3rem;
}

.tl-time:empty { display: none; }

/* Mini progress bar */
.tl-bar {
    width: 100%;
    height: 3px;
    background: var(--bg);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.tl-bar-fill {
    height: 100%;
    background: var(--running);
    border-radius: 2px;
    transition: width 0.4s ease;
    width: 0%;
}

/* ── Result ───────────────────────────────────────────────────────────────── */
.result-title {
    color: var(--success);
}

/* ── Error ────────────────────────────────────────────────────────────────── */
.error-msg {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(231,76,60,0.1);
    border-radius: 6px;
}

/* ── History ──────────────────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.history-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    color: var(--text-dim);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.history-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.history-table tbody tr:hover {
    background: var(--bg-input);
}

.empty-row {
    text-align: center;
    color: var(--text-dim);
    padding: 2rem !important;
}

.status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.completed        { background: rgba(46,204,113,0.15); color: var(--success); }
.status-badge.running          { background: rgba(52,152,219,0.15); color: var(--running); }
.status-badge.failed           { background: rgba(231,76,60,0.15);  color: var(--error); }
.status-badge.queued           { background: rgba(243,156,18,0.15); color: var(--warning); }
.status-badge.awaiting_review  { background: rgba(139,92,246,0.15); color: #8b5cf6; }

.history-actions {
    display: flex;
    gap: 0.3rem;
}

.history-actions .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-title {
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.login-card .input-field {
    margin-bottom: 0.75rem;
    text-align: center;
    font-size: 1rem;
}

/* ── Lucide Icon Sizes ────────────────────────────────────────────────────── */
.icon-14 { width: 14px; height: 14px; vertical-align: -2px; }
.icon-16 { width: 16px; height: 16px; vertical-align: -3px; }
.icon-20 { width: 20px; height: 20px; vertical-align: -4px; }
.icon-24 { width: 24px; height: 24px; vertical-align: -5px; }

/* ── Restore Banner ──────────────────────────────────────────────────────── */
.restore-banner {
    background: rgba(108, 92, 231, 0.1);
    border-bottom: 1px solid var(--accent);
    padding: 0.6rem 2rem;
}

.restore-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    color: var(--accent);
}

.restore-inner .btn-sm {
    margin-left: auto;
}

/* ── Progress Header ─────────────────────────────────────────────────────── */
.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.progress-header .card-title {
    margin-bottom: 0;
}

.timer {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* (old .step-* classes removed — replaced by .tl-* timeline) */

/* ── Channel Dropdown disabled options ───────────────────────────────────── */
select.input-field option:disabled {
    color: var(--text-dim);
    font-style: italic;
}

.optgroup-separator {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* ── Warning Banner (amber) ──────────────────────────────────────────────── */
.warning-banner {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
}

.warning-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: #f59e0b;
    margin-bottom: 0.5rem;
}

.warning-text {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin: 0 0 0.75rem 0;
    line-height: 1.5;
}

.warning-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.warning-note {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.btn-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.btn-warning:hover { background: rgba(245, 158, 11, 0.25); }

.skipped-details {
    margin-top: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
}

.skipped-details pre {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

/* ── Expiry Notice ───────────────────────────────────────────────────────── */
.expiry-notice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.6rem 1rem;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 6px;
    font-size: 0.8rem;
    color: #f87171;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .header { padding: 0.75rem 1rem; }
    .container { margin: 1rem auto; }
    .card { padding: 1rem; }
    .download-buttons { flex-direction: column; }
    .btn-download { min-width: auto; }
    .progress-header { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
}
