:root {
    --c-bg: #f1f5f9;
    --c-surface: #ffffff;
    --c-header: #0f172a;
    --c-header-light: #1e293b;
    --c-accent: #d97706;
    --c-accent-light: #fef3c7;
    --c-success: #059669;
    --c-success-light: #d1fae5;
    --c-error: #dc2626;
    --c-error-light: #fee2e2;
    --c-text: #1e293b;
    --c-text-sec: #64748b;
    --c-text-muted: #94a3b8;
    --c-border: #e2e8f0;
    --c-border-light: #f1f5f9;
    --font-display: 'Outfit', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'Space Mono', monospace;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: var(--font-body);
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────── */

header {
    background: var(--c-header);
    border-bottom: 3px solid var(--c-accent);
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-logo {
    width: 40px;
    height: 40px;
    background: var(--c-accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
}

.header-brand h1 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.header-subtitle {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--c-text-muted);
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.header-stats {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-text-muted);
    font-weight: 500;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.stat-cost .stat-value {
    color: var(--c-accent);
    font-size: 20px;
}

.stat-divider {
    width: 1px;
    height: 32px;
    background: rgba(255, 255, 255, 0.15);
}

/* ── Main ───────────────────────────────────── */

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}

/* ── Upload Zone ────────────────────────────── */

.upload-zone {
    background: var(--c-surface);
    border: 2px dashed var(--c-border);
    border-radius: var(--radius);
    padding: 48px 32px 36px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    margin-bottom: 24px;
}

.upload-zone::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg, transparent, transparent 8px, var(--c-border-light) 8px, var(--c-border-light) 9px);
    opacity: 0.5;
    pointer-events: none;
}

.upload-zone:hover {
    border-color: var(--c-accent);
    background: #fffdf7;
}

.upload-zone.drag-over {
    border-color: var(--c-accent);
    background: var(--c-accent-light);
    transform: scale(1.005);
}

.upload-zone.uploading {
    border-color: var(--c-accent);
    border-style: solid;
    pointer-events: none;
}

.upload-zone.upload-error {
    border-color: var(--c-error);
    background: var(--c-error-light);
}

.upload-zone.upload-error .upload-label {
    color: var(--c-error);
}

.upload-icon {
    color: var(--c-text-muted);
    margin-bottom: 12px;
    transition: color 0.25s;
    position: relative;
}

.upload-zone:hover .upload-icon,
.upload-zone.drag-over .upload-icon {
    color: var(--c-accent);
}

.upload-label {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--c-text);
    margin-bottom: 4px;
    position: relative;
}

.upload-hint {
    font-size: 13px;
    color: var(--c-text-muted);
    margin-bottom: 20px;
    position: relative;
}

.upload-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
}

.upload-zone input[type="file"] { display: none; }

.lang-select {
    font-family: var(--font-body);
    padding: 8px 14px;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--c-text);
    background: var(--c-surface);
    cursor: pointer;
}

.btn-browse {
    font-family: var(--font-display);
    padding: 9px 22px;
    background: var(--c-header);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-browse:hover { background: var(--c-header-light); }

/* ── Queue Progress Bar ─────────────────────── */

.queue-bar {
    background: var(--c-surface);
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    display: none;
}

.queue-bar.active {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.queue-info { margin-bottom: 8px; }

.queue-text {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
}

.queue-track {
    height: 4px;
    background: var(--c-border-light);
    border-radius: 2px;
    overflow: hidden;
}

.queue-fill {
    height: 100%;
    background: var(--c-accent);
    border-radius: 2px;
    width: 0;
    transition: width 0.5s ease;
}

.queue-bar.limit-reached .queue-fill { background: var(--c-error); }
.queue-bar.limit-reached .queue-text { color: var(--c-error); }

/* ── File List ──────────────────────────────── */

.file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-card {
    background: var(--c-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.2s;
    border-left: 3px solid transparent;
}

.file-card:hover { box-shadow: var(--shadow-md); }

.file-card[data-status="processing"] {
    border-left-color: var(--c-accent);
}

.file-card[data-status="processing"] .file-header {
    animation: processingPulse 2s ease-in-out infinite;
}

@keyframes processingPulse {
    0%, 100% { background: var(--c-surface); }
    50% { background: #fffbeb; }
}

.file-card[data-status="done"] { border-left-color: var(--c-success); }
.file-card[data-status="error"] { border-left-color: var(--c-error); }
.file-card[data-status="limit"] { border-left-color: #f59e0b; }

.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.file-header:hover { background: #fafbfc; }

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.file-chevron {
    font-size: 16px;
    color: var(--c-text-muted);
    transition: transform 0.25s;
    flex-shrink: 0;
    width: 12px;
    display: inline-block;
}

.file-card.expanded .file-chevron { transform: rotate(90deg); }

.file-name {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 400;
    color: var(--c-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-det-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--c-accent);
    background: var(--c-accent-light);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.file-det-count.none {
    color: var(--c-text-muted);
    background: var(--c-border-light);
}

/* ── Status Badges ──────────────────────────── */

.file-badge {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge-pending     { background: var(--c-border-light); color: var(--c-text-muted); }
.badge-queued      { background: var(--c-border-light); color: var(--c-text-sec); }
.badge-transcribed { background: #dbeafe; color: #1d4ed8; }
.badge-processing  { background: var(--c-accent-light); color: #92400e; }
.badge-done        { background: var(--c-success-light); color: #065f46; }
.badge-error       { background: var(--c-error-light); color: var(--c-error); }
.badge-limit       { background: #fef3c7; color: #92400e; }

/* ── File Body (expandable) ─────────────────── */

.file-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.file-card.expanded .file-body { max-height: 5000px; }

.file-body > .no-ads {
    padding: 12px 20px 20px;
    font-size: 13px;
    color: var(--c-text-muted);
    font-style: italic;
}

/* ── Ad Cards ───────────────────────────────── */

.det-card {
    margin: 0 16px 12px;
    padding: 14px 16px;
    background: var(--c-bg);
    border-radius: 8px;
    border-left: 3px solid var(--c-accent);
}

.det-card:first-child { margin-top: 4px; }
.det-card:last-child  { margin-bottom: 16px; }

.det-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.det-brand {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    color: var(--c-text);
}

.det-type {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--c-border-light);
    color: var(--c-text-sec);
}

.det-type.type-live-read     { background: #dbeafe; color: #1d4ed8; }
.det-type.type-produced-spot { background: #fae8ff; color: #9333ea; }
.det-type.type-sponsorship   { background: var(--c-accent-light); color: #92400e; }

.det-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 8px;
}

.det-time {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--c-text-sec);
}

.det-duration {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--c-text-muted);
    background: var(--c-surface);
    padding: 1px 6px;
    border-radius: 3px;
}

.det-confidence {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--c-text-muted);
}

.det-summary {
    font-size: 13px;
    color: var(--c-text-sec);
    line-height: 1.5;
    margin-bottom: 4px;
}

.det-expandable { margin-top: 6px; }

.det-toggle {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--c-accent);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-weight: 600;
}

.det-toggle:hover { text-decoration: underline; }

.det-text {
    font-size: 12px;
    color: var(--c-text-muted);
    line-height: 1.6;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, margin 0.3s ease;
}

.det-text.visible {
    max-height: 500px;
    margin-top: 6px;
}

/* ── Spinner ────────────────────────────────── */

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--c-border);
    border-top-color: var(--c-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

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

/* ── Responsive ─────────────────────────────── */

@media (max-width: 640px) {
    .header-inner {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    .header-stats { justify-content: center; }
    .upload-zone { padding: 32px 20px 28px; }
    .upload-controls { flex-direction: column; }
    .file-name { max-width: 180px; }
}
