:root {
    color-scheme: light dark;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, 0.1);
    --ok-bg: rgba(22, 163, 74, 0.14);
    --ok-text: #15803d;
    --err-bg: rgba(220, 38, 38, 0.14);
    --err-text: #b91c1c;
    --radius: 16px;
    --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1120;
        --surface: #111827;
        --surface-alt: #1e293b;
        --border: #273549;
        --text: #f8fafc;
        --muted: #94a3b8;
        --accent: #3b82f6;
        --accent-hover: #60a5fa;
        --accent-soft: rgba(59, 130, 246, 0.16);
        --ok-bg: rgba(34, 197, 94, 0.18);
        --ok-text: #4ade80;
        --err-bg: rgba(248, 113, 113, 0.18);
        --err-text: #f87171;
        --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    }
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
    padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.container {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.app-header {
    padding: 4px 2px;
}

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

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--accent-soft);
    display: grid;
    place-items: center;
    font-size: 24px;
    flex-shrink: 0;
}

h1 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 650;
}

.subtitle {
    margin: 2px 0 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.subtitle code,
.file-sub code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82em;
    background: var(--surface-alt);
    padding: 1px 6px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.upload-card,
.history-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.dropzone {
    border: 2px dashed var(--border);
    border-radius: 14px;
    background: var(--surface-alt);
    padding: 24px 16px;
    text-align: center;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    cursor: pointer;
}

.dropzone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.dropzone-icon {
    font-size: 34px;
    line-height: 1;
    margin-bottom: 8px;
}

.dropzone-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 650;
}

.dropzone-hint {
    margin: 4px 0 18px;
    font-size: 0.84rem;
    color: var(--muted);
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 20px;
    border-radius: 12px;
    font-size: 0.96rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: transform 0.08s ease, background-color 0.15s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    flex: 1 1 190px;
}

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

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    flex: 0 1 140px;
}

.overall-progress {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.86rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.progress-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: var(--accent);
    transition: width 0.15s linear;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.badge {
    min-width: 28px;
    height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.readonly-note {
    margin: 4px 0 12px;
    font-size: 0.82rem;
    color: var(--muted);
}

.empty-state {
    margin: 8px 0 2px;
    font-size: 0.9rem;
    color: var(--muted);
    text-align: center;
    padding: 18px 8px;
    border-radius: 12px;
    background: var(--surface-alt);
}

.file-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.file-list:empty {
    margin-top: 0;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
}

.thumb,
.thumb-placeholder {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    flex-shrink: 0;
    object-fit: cover;
    background: var(--border);
}

.thumb-placeholder {
    display: grid;
    place-items: center;
    font-size: 22px;
}

.file-meta {
    min-width: 0;
    flex: 1;
}

.file-name {
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-sub {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-progress-track {
    margin-top: 6px;
    height: 5px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.file-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.12s linear;
}

.status-pill {
    font-size: 0.75rem;
    font-weight: 650;
    padding: 4px 9px;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
    background: var(--accent-soft);
    color: var(--accent);
}

.status-pill.ok {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.status-pill.err {
    background: var(--err-bg);
    color: var(--err-text);
}

@media (max-width: 480px) {
    .action-row {
        flex-direction: column;
    }
    .btn {
        width: 100%;
        flex: none;
    }
}
