:root {
    color-scheme: light;

    --bg: #f5f7fa;
    --bg-elevated: #ffffff;
    --bg-inset: #f7f9fc;
    --border: #e4e8ef;
    --border-strong: #d0d7e2;
    --text: #16202e;
    --text-muted: #5f6b7c;
    --accent: #2563eb;
    --accent-strong: #1d4ed8;
    --accent-soft: #eef4ff;
    --ok: #15803d;
    --warn: #b45309;
    --danger: #b91c1c;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(900px 500px at 15% -10%, rgba(37, 99, 235, 0.07), transparent 60%),
        var(--bg);
    color: var(--text);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.page {
    max-width: 860px;
    margin: 0 auto;
    padding: 40px 20px 64px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header */

.masthead {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.masthead-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 650;
    letter-spacing: -0.01em;
    text-decoration: none;
    color: var(--text);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    flex: none;
}

.brand-name {
    line-height: 1;
}

.masthead-sub {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

/* Language switcher */

.lang-switch {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 999px;
    flex: none;
}

.lang-link {
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.lang-link:hover {
    color: var(--text);
}

.lang-link.is-active {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

/* Cards */

main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-muted {
    background: transparent;
    box-shadow: none;
}

.card-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    padding: 48px 24px;
}

.card-title {
    margin: 0 0 6px;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-subtitle {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
}

.card-hint {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.steps {
    margin: 0;
    padding-left: 20px;
    color: var(--text-muted);
    font-size: 14px;
    display: grid;
    gap: 4px;
}

/* Landing */

.page-landing {
    max-width: 760px;
}

.landing {
    display: flex;
    flex-direction: column;
    gap: 36px;
    padding: 12px 0 8px;
}

.landing-hero {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
}

.landing-mark {
    font-size: 42px;
    line-height: 1;
    filter: saturate(1.05);
}

.landing-title {
    margin: 0;
    font-size: 42px;
    font-weight: 720;
    letter-spacing: -0.035em;
    line-height: 1.05;
}

.landing-lead {
    margin: 0;
    max-width: 36ch;
    font-size: 22px;
    font-weight: 550;
    letter-spacing: -0.02em;
    line-height: 1.35;
    color: var(--text);
}

.landing-text {
    margin: 0;
    max-width: 58ch;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1.65;
}

.trust-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 14px;
}

.trust-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    align-items: start;
    padding: 18px 18px 18px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.trust-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    font-size: 20px;
    line-height: 1;
}

.trust-title {
    margin: 2px 0 4px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.trust-text {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.55;
}

/* Forms */

.form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.field-inline {
    max-width: 260px;
}

.field-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.field-input {
    width: 100%;
    padding: 11px 13px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-input::placeholder {
    color: #9aa5b4;
}

.field-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field-textarea {
    resize: vertical;
    min-height: 130px;
    font-family: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
    font-size: 13px;
    line-height: 1.7;
}

.field-select {
    appearance: none;
    cursor: pointer;
}

.field-note {
    font-size: 12px;
    color: var(--text-muted);
    min-height: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
}

/* Buttons */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
    white-space: nowrap;
}

.button:hover {
    background: var(--bg-inset);
    border-color: #b9c2d0;
}

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

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

.button-primary:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.button-small {
    padding: 6px 11px;
    font-size: 13px;
}

.button-icon {
    padding: 6px 10px;
    font-size: 15px;
    line-height: 1;
}

/* Alerts and results */

.alert {
    margin-top: 16px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.result {
    margin-top: 20px;
    padding: 18px;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ok);
}

.result-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.result-input {
    flex: 1 1 260px;
    font-family: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
    font-size: 13px;
}

.result-note {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

/* File set header */

.set-kicker {
    margin: 0 0 4px;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

.set-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.dot-sep::before {
    content: "·";
    margin: 0 8px;
    color: var(--border-strong);
}

.badge {
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    white-space: nowrap;
}

.badge-processing {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.badge-ready {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.badge-partial {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.badge-failed {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.progress {
    height: 4px;
    margin: 18px 0 4px;
    background: #eaeef4;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), #3b82f6);
    border-radius: 999px;
    transition: width 0.4s ease;
}

/* File list */

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

.file-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-inset);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.file-row:hover {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
}

.file-icon {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: #fff;
    border: 1px solid var(--border);
    font-size: 20px;
    line-height: 1;
    box-shadow: inset 0 0 0 2px transparent;
}

.file-icon.is-active {
    border-color: #bfdbfe;
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.18);
    animation: pulse 1.2s ease-in-out infinite;
}

.file-icon.is-ready {
    border-color: #bbf7d0;
    box-shadow: inset 0 0 0 2px rgba(21, 128, 61, 0.12);
}

.file-icon.is-failed {
    border-color: #fecaca;
    box-shadow: inset 0 0 0 2px rgba(185, 28, 28, 0.1);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.file-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta {
    font-size: 12.5px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-row.is-unavailable {
    opacity: 0.72;
}

.file-row.is-unavailable .file-name {
    color: var(--text-muted);
    font-weight: 400;
    text-decoration: line-through;
    text-decoration-color: var(--border-strong);
}

.file-error {
    font-size: 12.5px;
    color: var(--danger);
}

.file-error:empty {
    display: none;
}

.file-actions {
    flex: none;
    display: flex;
    gap: 7px;
}

.poll-note {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 18px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

/* Spinner */

.spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid #dfe5ee;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex: none;
}

.spinner-lg {
    width: 26px;
    height: 26px;
    border-width: 3px;
}

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

/* Preview overlay */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 50;
}

.overlay-panel {
    width: min(960px, 100%);
    max-height: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(16, 24, 40, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.overlay-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.overlay-title {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.overlay-actions {
    display: flex;
    gap: 8px;
    flex: none;
}

.overlay-body {
    flex: 1 1 auto;
    min-height: 220px;
    padding: 18px;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-inset);
}

.overlay-body img,
.overlay-body video {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-sm);
    background: #fff;
}

.overlay-body audio {
    width: 100%;
}

.overlay-pdf {
    width: 100%;
    height: 70vh;
    border: none;
    border-radius: var(--radius-sm);
    background: #fff;
}

.overlay-fallback {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 32px;
}

.overlay-body pre {
    margin: 0;
    width: 100%;
    align-self: flex-start;
    font-family: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
    font-size: 12.5px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
}

.overlay-message {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

/* Footer */

.footer {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.footer-note {
    margin: 0;
    font-size: 12.5px;
    color: var(--text-muted);
}

.footer-link {
    color: var(--accent);
    text-decoration: none;
}

.footer-link:hover {
    text-decoration: underline;
}

.is-hidden {
    display: none !important;
}

@media (max-width: 620px) {
    .page {
        padding: 24px 14px 40px;
    }

    .card {
        padding: 18px;
    }

    .landing {
        padding: 8px 0;
        gap: 28px;
    }

    .landing-title {
        font-size: 34px;
    }

    .landing-lead {
        font-size: 19px;
    }

    .landing-mark {
        font-size: 36px;
    }

    .file-row {
        align-items: flex-start;
    }

    .file-actions {
        flex-direction: column;
    }
}
