:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;
    --primary-text: #ffffff;
    --success: #15803d;
    --success-soft: #f0fdf4;
    --success-border: #bbf7d0;
    --danger: #b91c1c;
    --danger-soft: #fef2f2;
    --danger-border: #fecaca;
    --info: #1d4ed8;
    --info-soft: #eff6ff;
    --info-border: #bfdbfe;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.08);
    --radius: 16px;
    --radius-sm: 10px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1120;
        --surface: #111827;
        --surface-2: #0f172a;
        --text: #e5e7eb;
        --muted: #94a3b8;
        --border: #1f2937;
        --border-strong: #334155;
        --primary: #3b82f6;
        --primary-hover: #60a5fa;
        --primary-soft: rgba(59, 130, 246, 0.12);
        --success: #4ade80;
        --success-soft: rgba(34, 197, 94, 0.1);
        --success-border: rgba(34, 197, 94, 0.3);
        --danger: #f87171;
        --danger-soft: rgba(239, 68, 68, 0.1);
        --danger-border: rgba(239, 68, 68, 0.3);
        --info: #93c5fd;
        --info-soft: rgba(59, 130, 246, 0.1);
        --info-border: rgba(59, 130, 246, 0.3);
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
        color-scheme: dark;
    }
}

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: var(--bg);
    background-image: radial-gradient(ellipse 80% 50% at 50% -10%, var(--primary-soft), transparent);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.card {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}

@media (max-width: 480px) {
    .card { padding: 20px; }
}

/* Header */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.brand-logo {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 10px;
}
.brand h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}
.brand p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.section + .section { margin-top: 20px; }

.section-title {
    margin: 0 0 10px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

/* Drop zone */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 32px 16px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}
.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
}
#file-input:focus-visible + .dropzone {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.dropzone-icon {
    width: 40px;
    height: 40px;
    color: var(--primary);
    margin-bottom: 4px;
}
.dropzone strong { font-weight: 600; }
.dropzone .link { color: var(--primary); }
.dropzone small { color: var(--muted); font-size: 0.8rem; }

/* File lists */
.file-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 220px;
    overflow-y: auto;
}
.file-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: 0.9rem;
}
.file-list li + li { border-top: 1px solid var(--border); }
.file-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--muted);
}
.file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-size {
    flex-shrink: 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn-block { width: 100%; margin-top: 16px; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

/* Share link */
.link-row {
    display: flex;
    gap: 8px;
}
.link-row input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: 0.85rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    text-overflow: ellipsis;
}
.link-row input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.link-row .btn { flex-shrink: 0; }

@media (max-width: 400px) {
    .link-row { flex-direction: column; }
}

/* Status banners */
.alert {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    border: 1px solid;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}
.alert p { margin: 0; }
.alert .alert-sub { margin-top: 2px; font-size: 0.8rem; opacity: 0.85; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.alert-info { background: var(--info-soft); border-color: var(--info-border); color: var(--info); }
.alert-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }

.live-dot {
    position: relative;
    width: 10px;
    height: 10px;
    margin: 6px 4px 0;
    flex-shrink: 0;
    border-radius: 50%;
    background: currentColor;
}
.live-dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
    from { transform: scale(1); opacity: 0.6; }
    to { transform: scale(2.6); opacity: 0; }
}

.spinner {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress */
.progress-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}
.progress-head .section-title { margin: 0; }
#progress-text { font-weight: 600; font-variant-numeric: tabular-nums; }
.progress-track {
    height: 8px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}
#progress-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), #6366f1);
    transition: width 0.3s ease;
}
#speed-text {
    min-height: 1.2em;
    margin: 8px 0 0;
    font-size: 0.8rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.footer {
    margin-top: 16px;
    font-size: 0.78rem;
    color: var(--muted);
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
