:root {
    color-scheme: light;
    --brand-color: #1b4d8c;
    --brand-accent: #2f8f6b;
    --neutral-light: #f5f7fb;
    --neutral-dark: #121820;
    --font-body: "Inter", "Segoe UI", Arial, sans-serif;
    --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    --space-unit: 0.5rem;
    --max-content-width: 900px;
    --bg: var(--neutral-light);
    --surface-bg: #ffffff;
    --input-bg: #ffffff;
    --text: #17202a;
    --text-muted: #52606d;
    --border: #d9e2ec;
    --input-border: #bcccdc;
    --button-bg: var(--brand-color);
    --button-hover: #163f72;
    --button-text: #ffffff;
    --link-color: var(--brand-color);
    --link-hover: #163f72;
    --message-bg: #eef5ff;
    --message-border: #bfd3f2;
    --badge-bg: #d9f2e3;
    --badge-text: #17603a;
    --error-bg: #fff4f2;
    --error-text: #b42318;
    --focus-ring: rgba(47, 143, 107, 0.28);
}

.light-theme {
    color-scheme: light;
    --bg: var(--neutral-light);
    --surface-bg: #ffffff;
    --input-bg: #ffffff;
    --text: #17202a;
    --text-muted: #52606d;
    --border: #d9e2ec;
    --input-border: #bcccdc;
    --button-bg: var(--brand-color);
    --button-hover: #163f72;
    --button-text: #ffffff;
    --link-color: var(--brand-color);
    --link-hover: #163f72;
    --message-bg: #eef5ff;
    --message-border: #bfd3f2;
    --badge-bg: #d9f2e3;
    --badge-text: #17603a;
    --error-bg: #fff4f2;
    --error-text: #b42318;
    --focus-ring: rgba(47, 143, 107, 0.28);
}

.dark-theme {
    color-scheme: dark;
    --bg: var(--neutral-dark);
    --surface-bg: #2a2a2a;
    --input-bg: #2a2a2a;
    --text: #eaeaea;
    --text-muted: rgba(234, 234, 234, 0.75);
    --border: #444;
    --input-border: #444;
    --button-bg: var(--brand-color);
    --button-hover: #2561ad;
    --button-text: #ffffff;
    --link-color: #4fc3f7;
    --link-hover: #81d4fa;
    --message-bg: #1d2b3a;
    --message-border: #36506b;
    --badge-bg: #244d38;
    --badge-text: #c8f2d8;
    --error-bg: #3a2424;
    --error-text: #ffb4ab;
    --focus-ring: rgba(79, 195, 247, 0.3);
}

body {
    font-family: var(--font-body);
    line-height: 1.6;
    margin: 0;
    color: var(--text);
    background: var(--bg);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

.site-header {
    background: var(--surface-bg);
    border-bottom: 1px solid var(--border);
    padding: calc(var(--space-unit) * 2) calc(var(--space-unit) * 3);
}

.site-brand {
    margin: 0 0 0.5rem;
    font-size: 1.4rem;
}

a {
    color: var(--link-color);
}

a:hover {
    color: var(--link-hover);
}

.site-header a {
    text-decoration: none;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
}

main {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: calc(var(--space-unit) * 3);
}

.panel,
.card {
    background: var(--surface-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    max-width: 100%;
}

.page-intro {
    max-width: 42rem;
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-muted);
}

.workflow-list {
    margin: 1rem 0;
    padding-left: 1.25rem;
}

.workflow-list li {
    margin-bottom: 0.45rem;
}

.account-section {
    border-top: 1px solid var(--border);
    margin-top: 1.25rem;
    padding-top: 1.1rem;
}

.account-section h3,
.account-claim h4 {
    margin-bottom: 0.35rem;
}

.account-claim {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 0.85rem;
    padding: 0.9rem;
}

.account-claim p {
    margin: 0.35rem 0;
}

.term-list {
    display: grid;
    gap: 0.25rem 1rem;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    margin: 0.35rem 0 1rem;
    padding-left: 1.2rem;
}

.form-stack {
    display: grid;
    gap: 0.95rem;
    margin-top: 1rem;
}

.form-field {
    display: grid;
    gap: 0.35rem;
}

.field-heading {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.field-label,
.form-fieldset legend {
    font-weight: 700;
}

.required-marker {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.help-text {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.field-errors {
    list-style: none;
    margin: 0.2rem 0 0;
    padding: 0;
    color: var(--error-text);
    font-size: 0.92rem;
}

.field-errors li + li {
    margin-top: 0.25rem;
}

.form-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

.form-section-title {
    margin: 0.5rem 0 0;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-top: 0.25rem;
}

.button-link {
    align-items: center;
    background: var(--button-bg);
    border: 0;
    border-radius: 8px;
    color: var(--button-text);
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    line-height: 1.2;
    padding: 0.65rem 0.9rem;
    text-decoration: none;
}

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

.button-link.secondary {
    background: transparent;
    border: 1px solid var(--input-border);
    color: var(--link-color);
}

.button-link.secondary:hover {
    background: var(--message-bg);
    color: var(--link-hover);
}

.secondary-action {
    font-weight: 700;
}

.notice {
    background: var(--message-bg);
    border: 1px solid var(--message-border);
    border-radius: 8px;
    margin: 1rem 0;
    padding: 0.75rem 0.9rem;
}

.notice p {
    margin: 0;
}

.notice p + p {
    margin-top: 0.45rem;
}

.notice-error {
    background: var(--error-bg);
    border-color: color-mix(in srgb, var(--error-text) 35%, var(--border));
    color: var(--error-text);
}

.option-list {
    display: grid;
    gap: 0.65rem;
    margin-top: 0.35rem;
}

.option-row {
    align-items: flex-start;
    background: color-mix(in srgb, var(--surface-bg) 90%, var(--message-bg));
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    display: grid;
    gap: 0.65rem;
    grid-template-columns: auto 1fr;
    min-width: 0;
    padding: 0.7rem 0.8rem;
}

.option-row:has(input:checked) {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.option-row input {
    margin-top: 0.25rem;
}

.option-row > span {
    min-width: 0;
}

.option-title {
    display: block;
    font-weight: 700;
}

.option-description {
    color: var(--text-muted);
    display: block;
    font-size: 0.92rem;
    margin-top: 0.15rem;
}

.field-group {
    margin-bottom: 0.9rem;
}

.field-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.field-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
}

.messages {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.messages li {
    background: var(--message-bg);
    border: 1px solid var(--message-border);
    border-radius: 8px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.6rem;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--badge-bg);
    color: var(--badge-text);
    font-size: 0.9rem;
    font-weight: 600;
}

button,
input[type="submit"] {
    background: var(--button-bg);
    color: var(--button-text);
    border: 0;
    border-radius: 8px;
    padding: 0.65rem 0.9rem;
    cursor: pointer;
}

button:hover,
input[type="submit"]:hover {
    background: var(--button-hover);
}

button + button {
    margin-left: 0.5rem;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
select,
textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.65rem;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: var(--input-bg);
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--brand-accent);
    height: 1rem;
    width: 1rem;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.button-link:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.site-footer {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: calc(var(--space-unit) * 3);
    color: var(--text-muted);
    font-size: 0.92rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

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

.footer-links a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.legal-page {
    background: var(--surface-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: clamp(1rem, 3vw, 2rem);
    width: 100%;
}

.legal-page h2 {
    margin-top: 0;
}

.legal-page h3 {
    margin-top: 1.7rem;
}

.legal-note {
    border-left: 4px solid var(--brand-accent);
    margin: 0 0 1.5rem;
    padding: 0.7rem 0 0.7rem 1rem;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--brand-accent) 10%, transparent);
}

.legal-details {
    display: grid;
    grid-template-columns: minmax(9rem, 13rem) 1fr;
    gap: 0.5rem 1rem;
}

.legal-details dt {
    color: var(--text-muted);
    font-weight: 700;
}

.legal-details dd {
    margin: 0;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

ul {
    padding-left: 1.2rem;
}

p,
li,
label,
.option-description {
    overflow-wrap: break-word;
}

@media (max-width: 640px) {
    main {
        max-width: 22rem;
        margin: 0;
        padding: 1rem;
        width: auto;
    }

    .site-header,
    .site-footer {
        padding: 1rem;
    }

    .site-footer {
        margin: 0;
        max-width: 22rem;
    }

    .site-nav {
        gap: 0.5rem 0.65rem;
    }

    .panel,
    .card,
    .legal-page {
        max-width: 100%;
        width: 100%;
    }

    .term-list {
        grid-template-columns: 1fr;
    }

    .option-row {
        grid-template-columns: 1rem minmax(0, 1fr);
    }

    .legal-details {
        grid-template-columns: 1fr;
    }

    button,
    input[type="submit"],
    .button-link {
        width: 100%;
        margin: 0.35rem 0 0;
    }

    .action-row {
        align-items: stretch;
        flex-direction: column;
    }

    button + button {
        margin-left: 0;
    }
}
