* { box-sizing: border-box; }

:root {
    --bg: #f5f7f6;
    --surface: #ffffff;
    --text: #17201c;
    --muted: #617068;
    --primary: #2d6f4e;
    --primary-dark: #22563d;
    --border: #dfe7e2;
    --shadow: 0 14px 40px rgba(20, 45, 33, .08);
}

html {
    min-height: 100%;
    overflow-x: hidden;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    background: var(--bg);
}

.site-header,
.site-footer {
    padding-inline: max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right));
}

.site-header {
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: 1rem;
}

.site-footer {
    padding-top: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.container {
    width: min(100% - 2rem, 760px);
    margin-inline: auto;
}

.brand {
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
}

main {
    padding: 1.25rem max(0px, env(safe-area-inset-right)) 3rem max(0px, env(safe-area-inset-left));
    scroll-padding-top: calc(env(safe-area-inset-top) + 1rem);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: clamp(1.25rem, 5vw, 2.25rem);
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 .5rem;
    color: var(--primary);
    font-weight: 750;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 8vw, 3.3rem);
    line-height: 1.04;
    letter-spacing: -.045em;
}

.lead {
    margin: 1rem 0 1.5rem;
    color: var(--muted);
    font-size: 1.08rem;
    line-height: 1.65;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3.25rem;
    padding: .85rem 1.15rem;
    border: 0;
    border-radius: .9rem;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}

.button:hover { background: var(--primary-dark); }

.notice {
    margin-top: 1.25rem;
    padding: 1rem;
    border-radius: .9rem;
    background: #edf7f1;
    color: #24543a;
    line-height: 1.5;
}

.meta {
    color: var(--muted);
    font-size: .92rem;
    line-height: 1.5;
}

.status-ok { color: #216b43; }
.status-error { color: #a42f2f; }

.progress {
    height: 4px;
    margin: 0 0 1rem;
    overflow: hidden;
    border-radius: 999px;
    background: #dfe7e2;
}

.progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
    transition: width .3s ease;
}

.question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: clamp(1.25rem, 5vw, 2.25rem);
    box-shadow: var(--shadow);
}

.choice-grid {
    display: grid;
    gap: .75rem;
    margin-top: 1.5rem;
}

.choice-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 5rem;
    padding: 1rem 1.05rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: #fff;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.choice-card:hover,
.choice-card:focus-within {
    transform: translateY(-1px);
    border-color: #86aa97;
    box-shadow: 0 10px 26px rgba(20, 45, 33, .08);
}

.choice-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice-card:has(input:checked) {
    border-color: var(--primary);
    background: #f0f8f3;
}

.choice-content {
    display: grid;
    gap: .25rem;
    flex: 1;
}

.choice-content strong { font-size: 1.05rem; }
.choice-content small { color: var(--muted); line-height: 1.4; }
.choice-arrow { color: var(--primary); font-size: 1.35rem; }

.form-error {
    margin: 1rem 0;
    padding: .9rem 1rem;
    border-radius: .85rem;
    background: #fff1f1;
    color: #8a2929;
}

.trust-row {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    margin-top: 1.4rem;
}

.trust-row span {
    padding: .45rem .65rem;
    border-radius: 999px;
    background: #edf7f1;
    color: #24543a;
    font-size: .83rem;
    font-weight: 650;
}

.button-secondary {
    margin-top: 1rem;
    background: #e9efeb;
    color: var(--text);
}

.page-transition { animation: pageIn .28s ease both; }
@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.choice-form.is-submitting { pointer-events: none; opacity: .72; }

@media (max-width: 520px) {
    .site-header { padding-bottom: .55rem; }
    main { padding-top: .65rem; }
    .choice-card { min-height: 4.75rem; }
}

/* v0.2.2: etusivun tekstihierarkian viimeistely */
.site-header {
    padding-top: max(env(safe-area-inset-top), clamp(1.25rem, 4vw, 2rem));
    padding-bottom: clamp(.9rem, 3vw, 1.35rem);
}

.site-header .container {
    display: flex;
    justify-content: center;
}

.brand {
    display: inline-block;
    font-size: clamp(1.5rem, 6vw, 2rem);
    line-height: 1;
    letter-spacing: -.035em;
    text-align: center;
}

.trust-list {
    display: grid;
    gap: .7rem;
    margin: 1.35rem 0 0;
    padding: 0;
    list-style: none;
}

.trust-list li {
    position: relative;
    padding-left: 1.65rem;
    color: #24543a;
    font-size: .92rem;
    font-weight: 650;
    line-height: 1.35;
}

.trust-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--primary);
    font-weight: 900;
}

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

.choice-card {
    width: 100%;
    align-items: flex-start;
    gap: .9rem;
    min-height: 5.25rem;
    padding: 1rem;
    -webkit-tap-highlight-color: transparent;
}

.choice-radio {
    position: relative;
    flex: 0 0 1.45rem;
    width: 1.45rem;
    height: 1.45rem;
    margin-top: .08rem;
    border: 2px solid #9aa59f;
    border-radius: 50%;
    background: #fff;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.choice-radio::after {
    content: "";
    position: absolute;
    inset: .25rem;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0;
    transform: scale(.45);
    transition: opacity .16s ease, transform .16s ease;
}

.choice-card:has(input:checked) .choice-radio {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(45, 111, 78, .12);
}

.choice-card:has(input:checked) .choice-radio::after {
    opacity: 1;
    transform: scale(1);
}

.choice-content strong {
    display: block;
    font-size: 1.08rem;
    line-height: 1.25;
}

.choice-content small {
    display: block;
    margin-top: .22rem;
    font-size: .94rem;
}

.choice-arrow {
    align-self: center;
    flex: 0 0 auto;
}

@media (max-width: 520px) {
    .site-header { padding-top: max(env(safe-area-inset-top), 1.45rem); }
    .brand { font-size: 1.65rem; }
    .choice-card { border-radius: 1.05rem; }
}

/* v0.3: Tulot */
.step-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 .8rem;
}

.step-section,
.step-count {
    margin: 0;
    font-weight: 750;
}

.step-section {
    color: var(--text);
    font-size: 1.05rem;
}

.step-count {
    color: var(--muted);
    font-size: .92rem;
}

.income-form { margin-top: 1.5rem; }

.period-selector {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .65rem;
    margin: 0 0 1.35rem;
    padding: 0;
    border: 0;
}

.period-selector legend {
    grid-column: 1 / -1;
    margin-bottom: .25rem;
    color: var(--muted);
    font-size: .92rem;
    font-weight: 650;
}

.period-selector label { position: relative; }
.period-selector input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.period-selector span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 3.1rem;
    padding: .7rem .8rem;
    border: 1px solid var(--border);
    border-radius: .85rem;
    background: #fff;
    font-weight: 700;
    cursor: pointer;
}

.period-selector input:checked + span {
    border-color: var(--primary);
    background: #edf7f1;
    color: var(--primary-dark);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.period-selector label:focus-within span {
    outline: 3px solid rgba(45, 111, 78, .18);
    outline-offset: 2px;
}

.amount-field { display: grid; gap: .55rem; }
.amount-label { font-weight: 750; }

.amount-control {
    display: flex;
    align-items: center;
    min-height: 3.75rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: .95rem;
    background: #fff;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.amount-control:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 111, 78, .13);
}

.amount-control input {
    min-width: 0;
    flex: 1;
    padding: 1rem;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 1.25rem;
    font-weight: 750;
}

.amount-suffix {
    padding: 0 1rem 0 .5rem;
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}

.field-help {
    margin: .55rem 0 1.3rem;
    color: var(--muted);
    font-size: .88rem;
    line-height: 1.45;
}

.button-full { width: 100%; }



/* v0.3.1: tuloapuri ja pienten puhelinten tiivistys */
.income-intro strong { color: var(--text); }
.income-helper {
    display: grid;
    gap: 1.15rem;
    margin-top: 1.25rem;
    padding-top: 1.15rem;
    border-top: 1px solid var(--border);
}
.income-helper[hidden] { display: none; }
.helper-options { margin: 0; padding: 0; border: 0; }
.helper-options legend { margin-bottom: .25rem; font-weight: 750; }
.helper-help { margin-top: 0; margin-bottom: .75rem; }
.helper-choice {
    position: relative;
    display: flex;
    margin-top: .55rem;
}
.helper-choice input { position: absolute; opacity: 0; pointer-events: none; }
.helper-choice span {
    width: 100%;
    padding: .75rem .85rem;
    border: 1px solid var(--border);
    border-radius: .8rem;
    background: #fff;
    font-size: .94rem;
    font-weight: 650;
    line-height: 1.35;
    cursor: pointer;
}
.helper-choice input:checked + span {
    border-color: var(--primary);
    background: #edf7f1;
    color: var(--primary-dark);
    box-shadow: inset 0 0 0 1px var(--primary);
}
.helper-choice:focus-within span { outline: 3px solid rgba(45, 111, 78, .18); outline-offset: 2px; }
.bonus-field { gap: .45rem; }
.amount-control-small { min-height: 3.25rem; }
.amount-control-small input { padding-block: .75rem; font-size: 1.1rem; }
.income-estimate {
    display: grid;
    gap: .18rem;
    padding: .9rem 1rem;
    border-radius: .9rem;
    background: #edf7f1;
    color: #24543a;
}
.income-estimate span { font-size: .88rem; font-weight: 650; }
.income-estimate strong { font-size: 1.35rem; }
.income-estimate small { color: #416a54; }
.final-help { margin-bottom: 1rem; }
.compact-lead { margin-top: -.75rem; }

@media (max-width: 430px) {
    .container { width: min(100% - 1.35rem, 760px); }
    .site-header { padding-top: max(env(safe-area-inset-top), 1.05rem); padding-bottom: .55rem; }
    .brand { font-size: 1.55rem; }
    main { padding-top: .45rem; padding-bottom: 1.5rem; }
    .progress { margin-bottom: .7rem; }
    .step-heading { margin-bottom: .55rem; }
    .question-card { padding: 1.1rem; }
    .question-card h1 { font-size: clamp(1.75rem, 8.3vw, 2.15rem); line-height: 1.06; }
    .lead { margin: .75rem 0 1rem; font-size: 1rem; line-height: 1.5; }
    .choice-grid { gap: .55rem; margin-top: 1rem; }
    .choice-card { min-height: 4.25rem; padding: .75rem .85rem; }
    .choice-content small { font-size: .88rem; line-height: 1.3; }
    .income-form { margin-top: 1.05rem; }
    .period-selector { gap: .5rem; margin-bottom: 1rem; }
    .period-selector span { min-height: 2.75rem; padding: .55rem .45rem; font-size: .94rem; }
    .amount-control { min-height: 3.35rem; }
    .amount-control input { padding: .8rem; font-size: 1.12rem; }
    .income-helper { gap: .9rem; margin-top: 1rem; padding-top: 1rem; }
    .helper-choice span { padding: .65rem .75rem; font-size: .89rem; }
    .site-footer { padding-top: .55rem; }
    .site-footer .meta { font-size: .84rem; }
}

/* v1.7: asumispolku ja katkeamattomat rahasummat */
.money { white-space: nowrap; }

.housing-fields {
    display: grid;
    gap: 1rem;
    margin-top: 1.25rem;
}

.share-section {
    margin-top: 1.35rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border);
}

.share-section h2 {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.3;
}

.share-section .field-help { margin-bottom: .8rem; }
.share-field { max-width: 13rem; }

.housing-live-summary {
    display: grid;
    gap: .75rem;
    margin-top: 1.35rem;
    padding: 1rem;
    border-radius: .95rem;
    background: #edf7f1;
    color: #24543a;
}

.housing-live-summary > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.housing-live-summary span { font-size: .9rem; }
.housing-live-summary strong { white-space: nowrap; font-size: 1.05rem; }

.housing-share { margin-top: 1.25rem; }
.housing-share-bar {
    height: .7rem;
    overflow: hidden;
    border-radius: 999px;
    background: #dfe7e2;
}
.housing-share-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}
.housing-share-values {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: .7rem;
    color: var(--muted);
}
.housing-share-values strong { color: var(--text); }
.housing-personal-share { margin-top: 1rem; }

@media (max-width: 430px) {
    .housing-live-summary > div,
    .housing-share-values {
        align-items: flex-start;
        flex-direction: column;
        gap: .15rem;
    }

    .share-field { max-width: none; }
}


/* v1.7.2: tulojen jakautuminen ja asumiskulujen jakotapa */
.income-split-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
    margin-top: 1rem;
}
.income-split-summary > div {
    display: grid;
    gap: .2rem;
    padding: .9rem 1rem;
    border: 1px solid var(--border);
    border-radius: .9rem;
}
.income-split-summary span,
.income-split-summary small { color: var(--muted); }
.income-split-summary strong { font-size: 1.25rem; color: var(--primary-dark); }

.share-methods {
    display: grid;
    gap: .55rem;
    margin-bottom: 1rem;
}
.share-choice { position: relative; display: block; }
.share-choice input { position: absolute; opacity: 0; pointer-events: none; }
.share-choice > span {
    display: grid;
    gap: .18rem;
    padding: .8rem .9rem;
    border: 1px solid var(--border);
    border-radius: .85rem;
    background: #fff;
    cursor: pointer;
}
.share-choice strong { font-size: .96rem; }
.share-choice small { color: var(--muted); line-height: 1.35; }
.share-choice input:checked + span {
    border-color: var(--primary);
    background: #edf7f1;
    color: var(--primary-dark);
    box-shadow: inset 0 0 0 1px var(--primary);
}
.share-choice:focus-within > span { outline: 3px solid rgba(45, 111, 78, .18); outline-offset: 2px; }
.share-field[hidden] { display: none; }

@media (max-width: 430px) {
    .income-split-summary { grid-template-columns: 1fr; }
}

/* v1.8: omakoti- ja paritalon kuukausi- ja vuosikulut */
.housing-cost-group + .housing-cost-group {
    margin-top: 1.5rem;
    padding-top: 1.35rem;
    border-top: 1px solid var(--border);
}
.housing-cost-group h2 {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.3;
}
.housing-cost-group > .field-help { margin: .35rem 0 0; }
.field-help-inline { display: block; margin: -.3rem 0 0; }
