:root {
    color: #172033;
    background: #f6f8fe;
    font: 16px/1.55 system-ui, sans-serif;
    --accent: #4338a1;
    --line: #dbe2ef;
    --muted: #465671;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: .16em; }
p, h1, h2, h3, h4 { margin: 0; }

.page-width {
    width: min(880px, calc(100% - 2rem));
    margin-inline: auto;
}

.site-header {
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.site-links, .toolbar, .preview-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem 1rem;
}

.site-links, .preview-actions { justify-content: space-between; }
.site-links { min-height: 64px; padding-block: .65rem; }
.site-links a { font-size: .9rem; font-weight: 650; }
.site-links .brand { font-size: 1.1rem; font-weight: 800; text-decoration: none; }
.workspace { padding-block: clamp(1.5rem, 5vw, 3rem); }
.page-heading { display: grid; gap: .7rem; margin-bottom: 1.4rem; }
h1 { font-size: clamp(1.9rem, 5vw, 2.75rem); line-height: 1.15; letter-spacing: -.035em; }
h2 { font-size: clamp(1.25rem, 4vw, 1.6rem); }

.privacy-note {
    max-width: 72ch;
    border-left: 3px solid #5865c7;
    border-radius: 6px;
    background: #eaf0ff;
    padding: .7rem .95rem;
    color: #263664;
    font-size: .9rem;
}

form { display: grid; justify-items: start; gap: 1.35rem; }
.form-card, .goal { margin: 0; min-width: 0; width: 100%; }
.form-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    padding: clamp(.9rem, 3vw, 1.45rem);
}

legend {
    padding-inline: .3rem;
    font-size: 1.1rem;
    font-weight: 750;
}

fieldset > legend span, label span, .field-note {
    color: var(--muted);
    font-size: .85rem;
    font-weight: 500;
}

.fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .95rem;
}

label { display: block; min-width: 0; font-size: .93rem; font-weight: 650; }
input, textarea {
    display: block;
    width: 100%;
    min-width: 0;
    margin-top: .35rem;
    border: 1px solid #aebbd1;
    border-radius: 8px;
    background: #fff;
    color: inherit;
    font: 400 1rem/1.35 system-ui, sans-serif;
    padding: .62rem .72rem;
}

input[type="date"] { min-height: 45px; }
textarea { resize: vertical; }

button {
    min-height: 44px;
    border: 1px solid #b7c1d6;
    border-radius: 9px;
    background: #fff;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: .48rem .9rem;
}
button:hover { background: #edf1ff; }
button:disabled { opacity: .65; cursor: default; }
:focus-visible { outline: 3px solid #365cdf; outline-offset: 3px; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: #332779; }

.goal {
    display: grid;
    gap: .9rem;
    margin-block: 1.15rem .85rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8faff;
    padding: .9rem;
}
.goal legend { font-size: .96rem; }
.goal button { justify-self: start; }

.field-note { margin-top: .9rem; }
[data-goal-status]:empty { margin: 0; }
#bep-preview { margin-block: 2rem 1rem; }
.preview-help { margin-top: .35rem; }

.plan-document {
    margin-top: 1rem;
    padding: clamp(1rem, 4vw, 2rem);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: #172033;
    overflow-wrap: anywhere;
}

.plan-document h2 { padding-bottom: .7rem; border-bottom: 2px solid currentColor; }
.plan-document h3 { margin-top: 1.15rem; font-size: 1.05em; }
.plan-document h4 { margin-bottom: .3rem; font-size: 1em; }
.plan-document dl {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: .18em .85em;
    margin-block: .6em;
}
.plan-document dt { font-weight: 700; }
.plan-document dd { margin: 0; white-space: pre-wrap; }
.plan-document p { white-space: pre-wrap; }
.plan-document ol { list-style: none; margin: .55em 0; padding: 0; }
.plan-document li { padding: .6em 0; border-top: 1px solid var(--line); }
.plan-signature { margin-top: 1.4rem; }

@media (max-width: 570px) {
    .fields { grid-template-columns: minmax(0, 1fr); }
}

@media screen and (max-width: 400px) {
    .plan-document dl { display: block; }
    .plan-document dd { margin-bottom: .55em; }
}

@page { size: A4; margin: 13mm; }
@media print {
    :root { background: #fff; color: #000; font-size: 11pt; }
    .site-header, .page-heading, form, .preview-actions, .field-note, noscript { display: none !important; }
    .page-width { width: auto; }
    .workspace, #bep-preview, .plan-document { margin: 0; padding: 0; }
    .plan-document { border: 0; border-radius: 0; color: #000; }
    .plan-document h2 { font-size: 17pt; }
    .plan-document h3 { break-after: avoid; }
    .plan-document li, .plan-signature { break-inside: avoid; }
}
