:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: #f3f6fb;
    color: #172033;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
}

.page-shell {
    width: min(960px, calc(100% - 32px));
    margin: 48px auto;
}

.panel,
.result-card {
    background: #fff;
    border: 1px solid #dce3f0;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgb(26 44 80 / 7%);
}

.panel {
    padding: clamp(24px, 5vw, 48px);
}

.eyebrow {
    margin: 0 0 10px;
    color: #51617b;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

h1,
h2 {
    margin-top: 0;
}

h1 {
    margin-bottom: 14px;
    font-size: clamp(2rem, 5vw, 3rem);
}

.description {
    max-width: 720px;
    color: #4a5870;
    line-height: 1.6;
}

.run-button {
    margin-top: 12px;
    padding: 13px 20px;
    border: 0;
    border-radius: 10px;
    background: #1c63d5;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.run-button:hover:not(:disabled) {
    background: #164faa;
}

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

.run-button.is-loading {
    cursor: progress;
}

.progress,
.error-message {
    margin-top: 22px;
    padding: 14px 16px;
    border-radius: 10px;
}

.progress {
    position: fixed;
    z-index: 100;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    width: min(680px, calc(100% - 40px));
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    border: 1px solid #9fc0ef;
    box-shadow: 0 12px 34px rgb(23 32 51 / 24%);
    background: #edf4ff;
    color: #1c4f9a;
}

#progress-title,
#progress-detail,
#progress-elapsed {
    display: block;
}

#progress-detail {
    margin-top: 3px;
}

#progress-elapsed {
    margin-top: 6px;
    color: #345f9d;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
}

.spinner {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
    border: 4px solid #a7c4ef;
    border-top-color: #1c63d5;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.error-message {
    background: #fff0f1;
    color: #a31e31;
}

.results {
    display: grid;
    gap: 20px;
    margin-top: 24px;
}

.result-card {
    padding: 26px;
}

.result-card h2 {
    margin-bottom: 16px;
    font-size: 1.25rem;
}

.result-card pre {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #28354b;
    font: inherit;
    line-height: 1.65;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.data-form {
    display: grid;
    gap: 26px;
    margin-top: 32px;
}

.form-section {
    padding-top: 26px;
    border-top: 1px solid #dce3f0;
}

.checkbox-field {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: -12px;
    cursor: pointer;
}

.checkbox-field input {
    width: 17px;
    height: 17px;
    margin-top: 2px;
    flex: none;
    accent-color: #2f6bff;
    cursor: pointer;
}

.checkbox-field span {
    font-weight: 600;
    line-height: 1.45;
}

.checkbox-field small {
    display: block;
    font-weight: 400;
    color: #65738a;
}

.section-heading {
    margin-bottom: 18px;
}

.section-heading h2 {
    margin-bottom: 6px;
    font-size: 1.3rem;
}

.section-heading p,
.field small,
.weekly-table small {
    color: #65738a;
    line-height: 1.45;
}

.section-heading p {
    margin: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.field {
    display: grid;
    gap: 7px;
    font-weight: 650;
}

.field b,
.required-note b,
.weekly-table b {
    color: #bc2441;
}

.field input,
.field select,
.weekly-table input,
.weekly-table select {
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    border: 1px solid #b9c5d8;
    border-radius: 8px;
    background: #fff;
    color: #172033;
    font: inherit;
}

.field input:focus,
.field select:focus,
.weekly-table input:focus,
.weekly-table select:focus {
    outline: 3px solid rgb(28 99 213 / 18%);
    border-color: #1c63d5;
}

.field input:invalid:not(:placeholder-shown),
.field select:invalid {
    border-color: #c13a4b;
}

.field small,
.weekly-table small {
    display: block;
    font-size: 0.78rem;
    font-weight: 400;
}

.field code {
    color: #334b70;
    font-family: ui-monospace, Consolas, monospace;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid #dce3f0;
    border-radius: 10px;
}

.weekly-table {
    width: 100%;
    min-width: 930px;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.weekly-table th,
.weekly-table td {
    padding: 10px;
    border-bottom: 1px solid #e5eaf3;
    text-align: left;
    vertical-align: top;
}

.weekly-table th {
    background: #f6f8fc;
    color: #34415a;
    font-size: 0.82rem;
}

.weekly-table tr:last-child td {
    border-bottom: 0;
}

.weekly-table input,
.weekly-table select {
    min-width: 88px;
    min-height: 38px;
}

.weekly-table td:last-child input {
    min-width: 170px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.form-actions .run-button {
    margin-top: 0;
}

.required-note {
    color: #65738a;
    font-size: 0.9rem;
}

@media (max-width: 640px) {
    .page-shell {
        width: min(100% - 20px, 960px);
        margin: 20px auto;
    }

    .panel,
    .result-card {
        border-radius: 12px;
    }
}

.json-editor textarea {
    width: 100%;
    min-height: 38rem;
    padding: 12px;
    border: 1px solid #b9c5d8;
    border-radius: 8px;
    background: #fff;
    color: #172033;
    resize: vertical;
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 0.88rem;
    line-height: 1.5;
    tab-size: 2;
}

.json-editor textarea:focus {
    outline: 3px solid rgb(28 99 213 / 18%);
    border-color: #1c63d5;
}
.model-settings {
    padding-top: 26px;
    border-top: 1px solid #dce3f0;
}

.model-settings .section-heading {
    margin-bottom: 18px;
}
.show-prompt-button {
    padding: 7px 10px;
    border: 1px solid #b9c5d8;
    border-radius: 7px;
    background: #f6f8fc;
    color: #1c63d5;
    font: inherit;
    font-size: 0.86rem;
    cursor: pointer;
}

.show-prompt-button:hover,
.show-prompt-button:focus-visible {
    border-color: #1c63d5;
    background: #eaf1ff;
}

.prompt-dialog {
    width: min(960px, calc(100% - 32px));
    max-height: min(82vh, 900px);
    padding: 0;
    border: 1px solid #cbd6e8;
    border-radius: 14px;
    box-shadow: 0 24px 80px rgb(23 32 51 / 28%);
}

.prompt-dialog::backdrop {
    background: rgb(23 32 51 / 55%);
}

.prompt-dialog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    border-bottom: 1px solid #dce3f0;
}

.prompt-dialog__header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.dialog-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: #eef2f8;
    color: #34415a;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

#prompt-dialog-content {
    max-height: calc(min(82vh, 900px) - 76px);
    margin: 0;
    padding: 22px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #172033;
    font: 0.88rem/1.55 "Cascadia Code", Consolas, monospace;
}
.cost-summary {
    padding: 20px 22px;
    border: 1px solid #b8d3c5;
    border-radius: 12px;
    background: #f1faf4;
    color: #214d32;
}

.cost-summary h2,
.cost-summary p {
    margin: 0;
}

.cost-summary h2 {
    margin-bottom: 6px;
    font-size: 1.05rem;
}
.cancel-button {
    padding: 12px 18px;
    border: 1px solid #c44b5a;
    border-radius: 10px;
    background: #fff;
    color: #a31e31;
    cursor: pointer;
    font: inherit;
    font-weight: 650;
}

.cancel-button:hover:not(:disabled) {
    background: #fff0f1;
}

.cancel-button:disabled {
    cursor: wait;
    opacity: 0.65;
}
.result-card > .show-prompt-button {
    margin-bottom: 18px;
}

.result-answer {
    padding: 20px 22px;
    border: 1px solid #dce3f0;
    border-radius: 12px;
    background: #f9fbff;
}

.result-answer__label {
    margin: 0 0 5px;
    color: #63738b;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.result-answer h2 {
    margin-bottom: 14px;
}
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.prompt-editor-button {
    flex: 0 0 auto;
    margin-top: 4px;
    padding: 10px 14px;
    border: 1px solid #b9c5d8;
    border-radius: 9px;
    background: #f6f8fc;
    color: #1c63d5;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.prompt-editor-button:hover {
    border-color: #1c63d5;
    background: #eaf1ff;
}

.prompt-editor-dialog {
    width: min(1120px, calc(100% - 32px));
    max-height: min(90vh, 1000px);
    padding: 0;
    border: 1px solid #cbd6e8;
    border-radius: 14px;
    box-shadow: 0 24px 80px rgb(23 32 51 / 28%);
}

.prompt-editor-dialog::backdrop {
    background: rgb(23 32 51 / 55%);
}

#prompt-editor-subtitle {
    margin: 4px 0 0;
    color: #65738a;
    font-size: 0.88rem;
}

.prompt-editor-dialog__body {
    display: grid;
    gap: 16px;
    padding: 22px;
    overflow: auto;
}

.prompt-editor-textarea textarea {
    min-height: min(58vh, 650px);
    padding: 14px;
    border: 1px solid #b9c5d8;
    border-radius: 9px;
    resize: vertical;
    color: #172033;
    font: 0.88rem/1.55 "Cascadia Code", Consolas, monospace;
}

.prompt-editor-dialog__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

#prompt-editor-status {
    margin: 0;
    color: #65738a;
    font-size: 0.88rem;
}

.prompt-editor-dialog__footer .run-button {
    margin-top: 0;
}

@media (max-width: 640px) {
    .page-header,
    .prompt-editor-dialog__footer {
        align-items: stretch;
        flex-direction: column;
    }
}