:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
    color: #172033;
    background: #f3f5f8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

a {
    color: #305cba;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 24px;
    color: #fff;
    background: #172033;
}

.brand {
    color: inherit;
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
}

.version {
    color: #b9c3d6;
    font-size: 0.85rem;
}

.container {
    width: min(960px, calc(100% - 32px));
    margin: 40px auto;
}

.page-heading,
.record-header,
.record-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

h1,
h2,
p {
    margin-top: 0;
}

.record-list {
    display: grid;
    gap: 12px;
}

.record-card,
.record-detail,
.empty-state,
.panel {
    border: 1px solid #dde2ea;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 18px rgb(23 32 51 / 6%);
}

.record-card {
    padding: 18px 20px;
    color: inherit;
    text-decoration: none;
}

.record-card:hover {
    border-color: #9fb5df;
}

.record-main,
.record-meta {
    display: flex;
    gap: 8px;
}

.record-main {
    flex-direction: column;
}

.record-meta {
    align-items: center;
}

.record-detail,
.empty-state,
.panel {
    padding: 28px;
}

.panel {
    margin-bottom: 18px;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.panel-heading h2,
.panel-heading p {
    margin-bottom: 4px;
}

.connection-state {
    flex: none;
    padding: 5px 10px;
    border-radius: 999px;
    color: #7c2929;
    background: #fdecec;
    font-size: 0.8rem;
    font-weight: 700;
}

.connection-state.is-ready {
    color: #11643c;
    background: #dff5e8;
}

.token-row,
.form-actions {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.field {
    display: grid;
    gap: 7px;
    color: #3d4960;
    font-size: 0.9rem;
    font-weight: 650;
}

.field.grow {
    flex: 1;
}

.field input {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid #bec7d5;
    border-radius: 8px;
    color: #172033;
    background: #fff;
    font: inherit;
    font-weight: 400;
}

.field input:focus {
    border-color: #305cba;
    outline: 3px solid rgb(48 92 186 / 16%);
}

.upload-form {
    display: grid;
    gap: 18px;
}

.checkbox-field {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    width: fit-content;
    cursor: pointer;
}

.checkbox-field input {
    width: 18px;
    height: 18px;
}

.button {
    min-height: 42px;
    padding: 9px 16px;
    border: 1px solid #305cba;
    border-radius: 8px;
    color: #fff;
    background: #305cba;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.button:hover {
    background: #254b9b;
}

.button:disabled {
    cursor: wait;
    opacity: 0.6;
}

.button-secondary {
    color: #305cba;
    background: #fff;
}

.button-secondary:hover {
    background: #f0f4fc;
}

.button-danger {
    border-color: #a63535;
    background: #a63535;
}

.button-danger:hover {
    background: #852929;
}

.form-status {
    min-height: 1.4em;
    margin: 0;
    color: #536078;
}

.form-status.is-error {
    color: #922f2f;
}

.form-status.is-success {
    color: #11643c;
}

.list-title {
    margin-top: 34px;
}

.back-link {
    margin-bottom: 16px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 10px;
    border-radius: 999px;
    color: #32405c;
    background: #e8edf5;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-completed {
    color: #11643c;
    background: #dff5e8;
}

.badge-failed,
.badge-submit_failed {
    color: #922f2f;
    background: #fde5e5;
}

.badge-processing {
    color: #1c5299;
    background: #e2edff;
}

.metadata {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 28px 0;
}

.metadata div {
    min-width: 0;
}

.metadata dt {
    margin-bottom: 4px;
    color: #66728a;
    font-size: 0.8rem;
}

.metadata dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.muted {
    color: #66728a;
}

.message {
    margin: 20px 0;
    padding: 16px;
    border-radius: 8px;
}

.message p {
    margin: 6px 0 0;
}

.polling-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: #384760;
    background: #edf2fa;
}

.polling-message.is-error {
    color: #7c2929;
    background: #fdecec;
}

.polling-message[hidden] {
    display: none;
}

.error-message {
    color: #7c2929;
    background: #fdecec;
}

.transcript {
    margin-top: 28px;
}

.transcript pre {
    max-height: 60vh;
    margin: 0;
    padding: 18px;
    overflow: auto;
    border-radius: 8px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: #f7f8fa;
    font: inherit;
}

.record-actions {
    margin-top: 36px;
    padding-top: 28px;
    border-top: 1px solid #dde2ea;
}

.action-panel {
    margin-top: 16px;
    padding: 18px;
    border: 1px solid #dde2ea;
    border-radius: 10px;
    background: #f9fafc;
}

.rename-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.danger-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px 20px;
    border-color: #edcaca;
    background: #fff8f8;
}

.danger-panel p {
    margin: 5px 0 0;
    color: #715252;
}

.delete-status {
    grid-column: 1 / -1;
}

@media (max-width: 640px) {
    .container {
        margin-top: 24px;
    }

    .record-card,
    .record-header,
    .panel-heading,
    .token-row,
    .form-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .field.grow,
    .button,
    .rename-form {
        width: 100%;
    }

    .rename-form {
        align-items: stretch;
        flex-direction: column;
    }

    .danger-panel {
        grid-template-columns: 1fr;
    }

    .delete-status {
        grid-column: auto;
    }

    .metadata {
        grid-template-columns: 1fr;
    }
}
