:root {
    color-scheme: light;
    --paper: #f7f7f2;
    --surface: #fffefa;
    --ink: #27352d;
    --muted: #5f6c62;
    --green: #245542;
    --green-dark: #173e30;
    --line: #d9dfd5;
    --control-line: #7d8c7b;
    --soft-green: #eef3eb;
    --warm: #f5eadb;
    --warm-ink: #765025;
    --danger: #8b3431;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--paper);
    line-height: 1.6;
}

/* Paper shell and resilient content defaults. */
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; overflow-wrap: anywhere; }
:where(.site-main, .site-main *, .header-inner > *, .footer-inner > *) { min-width: 0; }
a { color: var(--green); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
.skip-link { position: fixed; top: .75rem; left: 1rem; z-index: 10; padding: .65rem 1rem; background: var(--surface); border: 1px solid var(--green); border-radius: 8px; transform: translateY(-200%); }
.skip-link:focus { transform: none; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
h1, h2, h3 { margin: 0 0 .75rem; line-height: 1.2; letter-spacing: -.025em; }
h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: clamp(1.35rem, 2.5vw, 1.75rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }
ul, ol { padding-inline-start: 1.4rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.75rem 0; }
mark { background: var(--warm); color: var(--warm-ink); padding: .08em .2em; border-radius: 4px; }
code, pre { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
code { font-size: .9em; }
pre {
    max-width: 100%; margin: 1rem 0; padding: 1rem;
    overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--paper); font-size: .8125rem; line-height: 1.6;
}
pre code { font: inherit; white-space: inherit; }
dl { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: .6rem 1rem; margin: 1rem 0; }
dt { font-weight: 650; }
dd { margin: 0; color: var(--muted); }
audio { display: block; width: 100%; max-width: 100%; height: 44px; }

.header-inner, .site-main, .footer-inner { width: min(1120px, calc(100% - 3rem)); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.header-inner { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem; min-height: 88px; padding-block: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; min-height: 44px; color: var(--ink); font-size: 1.05rem; font-weight: 750; text-decoration: none; }
.brand-mark {
    display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--soft-green); color: var(--green); font-size: 1.5rem; font-weight: 500;
}
.site-nav { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem; margin-inline-start: auto; }
.site-nav a:not(.button):not(.nav-cta) { display: inline-flex; align-items: center; min-height: 36px; padding: .4rem .65rem; border-radius: 8px; color: var(--muted); font-size: .9rem; text-decoration: none; }
.site-nav a:not(.button):not(.nav-cta):hover,
.site-nav a[aria-current="page"]:not(.button):not(.nav-cta) { background: var(--soft-green); color: var(--green); }
.nav-account { max-width: 16rem; color: var(--muted); font-size: .875rem; }
.site-main { flex: 1; padding-block: 3rem 4rem; }
.site-main > * + * { margin-top: 2rem; }
.site-footer { border-top: 1px solid var(--line); padding-block: 1.5rem; color: var(--muted); font-size: .875rem; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem 1.5rem; }
.footer-inner p { margin: 0; }
.footer-inner a { color: inherit; }

/* Shared typography, actions, and card surfaces. */
.eyebrow, .preview-label { margin: 0 0 .8rem; color: var(--green); font-size: .75rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.muted, .field-hint { color: var(--muted); }
.lead { max-width: 56ch; color: var(--muted); font-size: 1.125rem; line-height: 1.75; }
.page-heading { margin-bottom: 2rem; }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; }
.page-heading > .page-actions, .hero-copy .page-actions { margin-top: 1.5rem; }
button, input, select, textarea { font: inherit; }
.button, .nav-cta, button, input[type="submit"], input[type="button"], input[type="reset"] {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: 44px; max-width: 100%; padding: .7rem 1.15rem;
    border: 1px solid transparent; border-radius: 8px;
    background: var(--green); color: #fff; font-weight: 650; line-height: 1.35;
    text-align: center; text-decoration: none; cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease;
}
:where(.button, .nav-cta, button, input[type="submit"], input[type="button"], input[type="reset"]):not(:disabled):hover { background: var(--green-dark); text-decoration: none; }
.button.secondary { background: var(--surface); border-color: var(--control-line); color: var(--green); }
.button.secondary:hover { background: var(--soft-green); border-color: var(--green); }
.button.ghost { background: transparent; color: var(--green); }
.button.ghost:hover { background: var(--soft-green); }
.button.danger { background: var(--danger); color: #fff; }
.button.danger:hover { background: #702724; }
:where(button, input, select, textarea):disabled { opacity: .6; cursor: not-allowed; }

.panel, .auth-card, .consent-card, .preview-card, .feature, .summary-card, .account-summary, .job-card,
.site-main > :where(section, article):not([class]) {
    padding: clamp(1.25rem, 3vw, 2rem);
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.panel + .panel { margin-top: 1.5rem; }
.settings-grid > .panel { margin-top: 0; }
.panel form { display: grid; gap: 1rem; }
.panel form + form { margin-top: 1.25rem; }
.job-card + .job-card { margin-top: 1rem; }
.panel-heading, .job-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.panel-heading h2, .job-heading h2, .job-heading h3 { margin-bottom: 0; }
.feature-grid, .summary-grid, .settings-grid, .form-grid, .audio-grid { display: grid; gap: 1.25rem; }
.feature-grid, .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings-grid, .form-grid, .audio-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.summary-card h2 { font-size: 1rem; }
.summary-card p { margin-bottom: .5rem; }
.summary-card p:last-child { margin-bottom: 0; }

/* Landing: a quiet editorial hero and a real, native-audio preview. */
.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; gap: clamp(2rem, 5vw, 4rem); padding-block: 1rem; }
.hero h1, .auth-intro h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
.hero h1 { max-width: 14ch; font-size: clamp(2.5rem, 5vw, 4.1rem); line-height: 1.1; letter-spacing: -.04em; }
.hero-copy .lead { max-width: 43ch; margin-top: 1.25rem; }
.preview-card { padding: clamp(1.5rem, 3vw, 2.5rem); box-shadow: 0 12px 36px rgb(31 55 39 / 5%); }
.preview-label { font-size: .7rem; }
.sample-reading { margin: 1rem 0 .4rem; color: var(--warm-ink); font-size: clamp(1.8rem, 3vw, 2.3rem); font-weight: 600; letter-spacing: .06em; }
.sample-spelling { margin-bottom: 1.25rem; color: var(--muted); font-size: 1.15rem; }
.sample-audio { margin-block: 1.25rem; }
.sample-example { margin: 1.35rem 0 .45rem; font-size: 1.1rem; }
.sample-meaning { color: var(--muted); font-size: .925rem; }
.preview-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .8125rem; }
.feature-grid { margin-block: 3rem; }
.feature p { color: var(--muted); font-size: .95rem; }
.onboarding-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; padding: 0; margin: 0; list-style: none; }
.onboarding-steps li { display: flex; align-items: flex-start; gap: .85rem; }
.onboarding-steps p { color: var(--muted); font-size: .925rem; }
.step-number { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: var(--soft-green); color: var(--green); font-size: .9rem; font-weight: 750; }

/* Authentication and native, explicitly labelled controls. */
.auth-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; gap: clamp(2rem, 5vw, 4.5rem); max-width: 980px; margin-inline: auto; }
.auth-intro { padding-top: 1.25rem; }
.auth-intro .onboarding-steps { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; margin-block: 2rem; }
.login-layout { max-width: 480px; margin-inline: auto; }
.consent-card { max-width: 640px; margin-inline: auto; }
form { margin: 0; }
.auth-card form, .consent-card form { display: grid; gap: 1.25rem; }
.form-grid > :where(fieldset, .page-actions, .notice, .error) { grid-column: 1 / -1; }
label { display: block; font-size: .9375rem; font-weight: 600; }
.field-label { display: block; margin-bottom: .4rem; font-size: .9375rem; font-weight: 600; }
.field-hint { display: block; margin: .45rem 0 0; font-size: .8125rem; font-weight: 400; }
input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="reset"], [type="hidden"]),
select, textarea {
    display: block; width: 100%; min-height: 44px; padding: .7rem .85rem;
    border: 1px solid var(--control-line); border-radius: 8px;
    background: #fff; color: var(--ink); line-height: 1.5;
}
label > :where(input:not([type="checkbox"], [type="radio"], [type="hidden"]), select, textarea) { margin-top: .4rem; }
textarea { min-height: 128px; max-width: 100%; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
:where(input, select, textarea):focus-visible { border-color: var(--green); }
.checkbox-label, .radio-option { display: flex; align-items: flex-start; gap: .65rem; min-height: 44px; padding-block: .55rem; font-weight: 400; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { flex: 0 0 20px; width: 20px; height: 20px; margin: .15rem 0 0; accent-color: var(--green); }
fieldset { margin: 0; padding: 1rem 1.25rem; border: 1px solid var(--line); border-radius: 10px; }
legend { padding-inline: .4rem; font-size: .9375rem; font-weight: 650; }
.deck-options .radio-option + .radio-option { border-top: 1px solid var(--line); }

/* Account, setup, feedback, and job detail pages. */
.status { display: inline-flex; align-items: center; max-width: 100%; padding: .3rem .7rem; border-radius: 999px; background: #edf0e9; color: var(--muted); font-size: .8125rem; font-weight: 650; line-height: 1.4; }
.status.success { background: var(--soft-green); color: var(--green); }
.status.pending { background: var(--warm); color: var(--warm-ink); }
.status.neutral { background: #edf0e9; color: var(--muted); }
.notice, .error { margin: 1.25rem 0; padding: 1rem 1.25rem; border: 1px solid var(--line); border-radius: 10px; background: var(--soft-green); }
.notice.warning { background: var(--warm); border-color: #e2ccab; color: var(--warm-ink); }
.error { background: #fbefec; border-color: #e4c7c2; color: var(--danger); }
.notice a, .error a { color: inherit; }
.connect-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; gap: 1.5rem; }
.account-summary h2 { font-size: 1.2rem; }
.setup-step + .setup-step { margin-top: 1.75rem; padding-top: 1.75rem; border-top: 1px solid var(--line); }
.setup-step ol li + li { margin-top: .8rem; }
.setup-step details:not(.instructions-details) { margin-block: 1rem; }
.setup-step details > summary { cursor: pointer; font-weight: 600; }
.instructions-details p { margin-top: 1rem; }
.step-heading { display: flex; align-items: center; gap: .85rem; margin-bottom: 1rem; }
.step-heading h2 { margin: 0; }
.copy-block { display: flex; align-items: flex-start; gap: .75rem; margin: 1rem 0; }
.copy-block pre { flex: 1; min-height: 44px; margin: 0; }
.instructions-details { margin: 1.25rem 0; padding-inline: 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.instructions-details > summary { min-height: 44px; padding: .8rem .25rem; font-weight: 650; cursor: pointer; }
.instructions-details[open] > summary { border-bottom: 1px solid var(--line); }
.instructions-details > pre { max-height: 26rem; overflow: auto; }
.empty-state { padding: 2.5rem 1.5rem; border: 1px dashed #aab6a9; border-radius: 12px; background: var(--surface); text-align: center; }
.empty-state p { max-width: 48ch; margin-inline: auto; color: var(--muted); }
.empty-state .page-actions { justify-content: center; margin-top: 1.25rem; }
.job-list { display: grid; gap: 1rem; margin: 0; padding: 0; list-style: none; }
.job-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; padding: 1.1rem 1.25rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.job-row > :first-child { flex: 1 1 14rem; }
.job-row p { margin-bottom: 0; }
.audio-clip { padding: 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.audio-clip p { font-size: .875rem; }
.audio-clip audio { margin-top: .75rem; }
.danger-zone { border-color: #e4c7c2; }
.danger-zone h2 { color: var(--danger); }
.danger-zone p { max-width: 65ch; }
.danger-zone form { margin-top: 1rem; }

@media (max-width: 900px) {
    .header-inner { gap: .75rem 1rem; }
    .site-nav { order: 2; flex: 1 1 100%; margin-inline-start: 0; }
    .nav-account { margin-inline-start: auto; }
    .hero, .auth-layout, .connect-layout { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
    .hero h1 { max-width: 18ch; }
    .preview-card { width: 100%; max-width: 640px; }
    .auth-intro { padding-top: 0; }
}

@media (max-width: 680px) {
    .header-inner, .site-main, .footer-inner { width: calc(100% - 2rem); }
    .site-main { padding-block: 2rem 3rem; }
    .nav-account { max-width: 100%; flex: 1 1 8rem; text-align: right; }
    .hero { padding-block: 0; }
    .feature-grid, .summary-grid, .settings-grid, .form-grid, .audio-grid, .onboarding-steps { grid-template-columns: minmax(0, 1fr); }
    .feature-grid { margin-block: 2rem; }
    .page-actions { align-items: stretch; }
    .page-actions > :where(.button, button, input[type="submit"]) { flex: 1 1 10rem; }
    .copy-block { flex-direction: column; align-items: stretch; }
    .copy-block pre { width: 100%; }
    .job-row { align-items: flex-start; }
    dl { grid-template-columns: minmax(0, 1fr); gap: .25rem; }
    dt:not(:first-child) { margin-top: .5rem; }
    .footer-inner { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
