:root {
    color-scheme: dark;

    --bg: #0d1017;
    --bg-elevated: #151a23;
    --bg-inset: #0f131a;
    --border: #232a36;
    --border-strong: #2f3948;
    --text: #e6eaf2;
    --text-muted: #8d97a8;
    --accent: #4c8dff;
    --accent-strong: #3b7af0;
    --ok: #35c07f;
    --warn: #e0a33a;
    --danger: #ef5d5d;
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
}

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

body {
    min-height: 100vh;
    background:
        radial-gradient(900px 500px at 15% -10%, rgba(76, 141, 255, 0.12), 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;
    text-decoration: none;
    color: var(--text);
    width: fit-content;
}

.brand-mark {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--accent), #8f5cff);
}

.brand-name {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.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-inset);
    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(--border-strong);
    color: var(--text);
}

/* 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;
}

.card-muted {
    background: transparent;
}

.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;
}

/* 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-inset);
    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:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(76, 141, 255, 0.18);
}

.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-inset);
    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: #1b212c;
    border-color: #3a4557;
}

.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: rgba(239, 93, 93, 0.1);
    border: 1px solid rgba(239, 93, 93, 0.35);
    color: #ffb4b4;
}

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

.result-label {
    font-size: 13px;
    font-weight: 500;
    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-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.mono {
    font-family: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
    font-size: 17px;
    color: var(--accent);
}

.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: rgba(224, 163, 58, 0.12);
    border-color: rgba(224, 163, 58, 0.4);
    color: #f0c274;
}

.badge-ready {
    background: rgba(53, 192, 127, 0.12);
    border-color: rgba(53, 192, 127, 0.4);
    color: #6fdca8;
}

.badge-partial {
    background: rgba(224, 163, 58, 0.12);
    border-color: rgba(224, 163, 58, 0.4);
    color: #f0c274;
}

.badge-failed {
    background: rgba(239, 93, 93, 0.12);
    border-color: rgba(239, 93, 93, 0.4);
    color: #ff9d9d;
}

.progress {
    height: 4px;
    margin: 18px 0 4px;
    background: var(--bg-inset);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), #8f5cff);
    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;
}

.file-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 2px;
    border-top: 1px solid var(--border);
}

.file-row:first-child {
    border-top: none;
}

.file-icon {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-strong);
}

.file-icon.is-active {
    background: var(--accent);
    animation: pulse 1.2s ease-in-out infinite;
}

.file-icon.is-ready {
    background: var(--ok);
}

.file-icon.is-failed {
    background: var(--danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.75); }
}

.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-error {
    font-size: 12.5px;
    color: #ff9d9d;
}

.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 var(--border-strong);
    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(6, 8, 12, 0.82);
    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-strong);
    border-radius: var(--radius);
    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);
}

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

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

.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 {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

/* Footer */

.footer {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

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

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

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

    .card {
        padding: 18px;
    }

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

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