:root {
    --ink: #1e2a39;
    --muted: #657184;
    --paper: #fbfaf7;
    --surface: #ffffff;
    --line: #d9dde3;
    --past: #344256;
    --current: #d7813a;
    --future: #aeb6c1;
    --accent: #376b62;
    --accent-soft: #e9f1ee;
    --warning: #8a5b19;
    --error: #a63e3e;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 12% 4%, rgba(55, 107, 98, 0.09), transparent 28rem),
        var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.55;
}

button,
input {
    font: inherit;
}

.site-header {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
    padding: 24px 0;
}

.site-brand {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
}

.site-brand__mark {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    color: #fff;
    border-radius: 9px;
    background: var(--accent);
}

.page-shell {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
}

.intro {
    max-width: 760px;
    padding: clamp(48px, 8vw, 92px) 0 72px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 500;
    letter-spacing: -0.035em;
}

h1 {
    max-width: 700px;
    font-size: clamp(3.25rem, 9vw, 6.4rem);
    line-height: 0.96;
}

h2 {
    font-size: clamp(2rem, 5vw, 3.4rem);
    line-height: 1;
}

.intro__lead {
    max-width: 660px;
    margin: 26px 0 36px;
    color: #485566;
    font-size: clamp(1.05rem, 2vw, 1.24rem);
}

.birth-form {
    display: grid;
    grid-template-columns: minmax(220px, 310px) minmax(190px, 1fr);
    gap: 14px 12px;
    align-items: end;
    padding: 24px;
    border: 1px solid rgba(55, 107, 98, 0.2);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 18px 60px rgba(35, 49, 65, 0.07);
    backdrop-filter: blur(8px);
}

.birth-form__field label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.87rem;
    font-weight: 750;
}

.birth-form input {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    color: var(--ink);
    border: 1px solid #b8c0ca;
    border-radius: 10px;
    background: #fff;
}

.birth-form input:focus-visible,
.button:focus-visible,
.calendar-frame:focus-visible {
    outline: 3px solid rgba(215, 129, 58, 0.48);
    outline-offset: 3px;
}

.button {
    min-height: 48px;
    padding: 11px 19px;
    border: 0;
    border-radius: 10px;
    font-weight: 760;
    cursor: pointer;
    transition: transform 140ms ease, background-color 140ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button--primary {
    color: #fff;
    background: var(--accent);
}

.button--primary:hover {
    background: #2c5b53;
}

.privacy-note {
    grid-column: 1 / -1;
    margin: 1px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.45;
}

.form-message {
    margin: 10px 0 0;
    font-size: 0.85rem;
}

.form-message--error {
    color: var(--error);
}

.form-message--warning {
    padding: 10px 13px;
    color: var(--warning);
    border: 1px solid #ead6b6;
    border-radius: 8px;
    background: #fff8e9;
}

.calendar-result {
    margin-bottom: 72px;
    padding: clamp(24px, 4vw, 48px);
    border: 1px solid #e2e4e5;
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 24px 90px rgba(35, 49, 65, 0.09);
}

.calendar-result--pending .calendar-frame,
.calendar-result--pending .week-detail,
.calendar-result--pending .legend,
.calendar-result--pending .scale-note {
    visibility: hidden;
}

.result-heading {
    display: flex;
    gap: 24px;
    align-items: end;
    justify-content: space-between;
}

.button--print {
    color: var(--accent);
    border: 1px solid #aec5bf;
    background: #f3f8f6;
}

.summary {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 28px 0 24px;
}

.summary div {
    min-width: 150px;
    padding: 10px 13px;
    border-left: 3px solid #bad0ca;
    background: #f7f9f8;
}

.summary dt {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.summary dd {
    margin: 2px 0 0;
    font-weight: 720;
}

.calendar-frame {
    overflow-x: auto;
    padding: 17px 18px 18px;
    border: 1px solid #dfe2e5;
    border-radius: 14px;
    background: #fcfcfb;
    scrollbar-color: #9ca7b4 #edf0f2;
}

.calendar-axis {
    display: grid;
    min-width: 678px;
    grid-template-columns: 50px 1fr;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.calendar-grid {
    min-width: 678px;
}

.calendar-row {
    position: relative;
    display: grid;
    grid-template-columns: 34px repeat(53, 8px);
    gap: 2px;
    align-items: center;
    min-height: 10px;
    padding: 1px 8px;
    border-left: 2px solid transparent;
}

.calendar-row--18-44 {
    background: rgba(55, 107, 98, 0.012);
}

.calendar-row--45-59 {
    background: rgba(55, 107, 98, 0.022);
}

.calendar-row--60s {
    background: rgba(55, 107, 98, 0.035);
}

.calendar-row--70s {
    background: rgba(55, 107, 98, 0.07);
}

.calendar-row--80s {
    background: rgba(55, 107, 98, 0.115);
}

.calendar-boundary {
    min-width: 678px;
    margin: 9px 8px 5px;
    padding: 0 0 5px 36px;
    border-bottom: 2px solid currentColor;
    font-size: 0.65rem;
    font-weight: 720;
}

.calendar-boundary--60 {
    color: #397458;
}

.calendar-boundary--18 {
    color: #56718b;
}

.calendar-boundary--45 {
    color: #4f7b71;
}

.calendar-boundary--70 {
    color: #b95f3e;
}

.calendar-boundary--80 {
    margin-top: 11px;
    color: #aa700d;
    border-bottom-width: 3px;
    background: linear-gradient(to right, transparent 0 34px, rgba(232, 168, 79, 0.09) 34px 100%);
}

.calendar-age {
    color: #667181;
    font-variant-numeric: tabular-nums;
    font-size: 0.58rem;
    font-weight: 720;
}

.calendar-week {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 1.5px;
}

.calendar-week--past {
    border: 1px solid var(--past);
    background: var(--past);
}

.calendar-week--future {
    border: 1px solid var(--future);
    background: transparent;
}

.calendar-week--current {
    position: relative;
    z-index: 1;
    border: 1px solid #9d4d18;
    outline: 2px solid #f1bb77;
    outline-offset: 1px;
    background: var(--current);
}

.calendar-week--current::after {
    position: absolute;
    inset: 2px;
    content: "";
    border-radius: 50%;
    background: #fff;
}

.calendar-week--missing {
    visibility: hidden;
}

.calendar-marker {
    position: absolute;
    right: 0;
    top: calc(100% + 1px);
    z-index: 2;
    color: #607068;
    font-size: 0.52rem;
    font-weight: 750;
}

.week-detail {
    min-height: 1.4em;
    margin: 11px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #e3e5e7;
    color: #4c5969;
    font-size: 0.82rem;
}

.legend span {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.legend__cell {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 2px;
}

.legend__cell--past {
    background: var(--past);
}

.legend__cell--current {
    border: 2px solid #9d4d18;
    outline: 1px solid #f1bb77;
    background: radial-gradient(circle, #fff 0 24%, var(--current) 28%);
}

.legend__cell--future {
    border: 1px solid var(--future);
}

.scale-note {
    max-width: 760px;
    margin: 17px 0 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.weekend-note {
    max-width: 760px;
    margin: 8px 0 0;
    color: #7b8390;
    font-size: 0.75rem;
}

.site-footer {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
    padding: 0 0 42px;
    color: var(--muted);
    font-size: 0.8rem;
}

@media (max-width: 640px) {
    .site-header,
    .page-shell,
    .site-footer {
        width: min(100% - 24px, 1120px);
    }

    .intro {
        padding-top: 36px;
    }

    h1 {
        font-size: clamp(3rem, 16vw, 4.5rem);
    }

    .birth-form {
        grid-template-columns: 1fr;
        padding: 18px;
    }

    .button--primary {
        width: 100%;
    }

    .calendar-result {
        margin-right: -4px;
        margin-left: -4px;
        padding: 20px 12px;
        border-radius: 18px;
    }

    .result-heading {
        align-items: start;
        flex-direction: column;
    }

    .button--print {
        width: 100%;
    }

    .calendar-frame {
        padding-right: 10px;
        padding-left: 10px;
    }
}

@page {
    size: A3 landscape;
    margin: 9mm;
}

@media print {
    :root {
        --ink: #000;
        --muted: #333;
        --past: #171717;
        --future: #777;
        --current: #fff;
    }

    html,
    body {
        width: 100%;
        min-height: 0;
        background: #fff;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .site-header,
    .site-footer,
    .intro,
    .button--print,
    .week-detail {
        display: none !important;
    }

    .page-shell {
        width: 100%;
        margin: 0;
    }

    .calendar-result {
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .result-heading {
        display: block;
    }

    .result-heading h2 {
        font-size: 17pt;
    }

    .eyebrow {
        margin-bottom: 1mm;
        color: #222;
        font-size: 6pt;
    }

    .summary {
        gap: 5mm;
        margin: 3mm 0;
    }

    .summary div {
        min-width: 34mm;
        padding: 1mm 2mm;
        border-left: 0.7mm solid #333;
        background: #fff;
    }

    .summary dt {
        font-size: 5pt;
    }

    .summary dd {
        font-size: 7pt;
    }

    .calendar-frame {
        overflow: visible;
        padding: 2mm;
        border: 0.25mm solid #777;
        border-radius: 0;
    }

    .calendar-axis,
    .calendar-grid {
        min-width: 0;
    }

    .calendar-axis {
        grid-template-columns: 9mm 1fr;
        margin-bottom: 1mm;
        font-size: 4.5pt;
    }

    .calendar-row {
        grid-template-columns: 7mm repeat(53, 1.45mm);
        gap: 0.32mm;
        min-height: 1.62mm;
        padding: 0.08mm 1mm;
        break-inside: avoid;
    }

    .calendar-row--18-44,
    .calendar-row--45-59,
    .calendar-row--60s,
    .calendar-row--70s,
    .calendar-row--80s {
        background: #fff;
    }

    .calendar-boundary {
        min-width: 0;
        margin: 0.6mm 1mm 0.35mm;
        padding: 0 0 0.45mm 7mm;
        color: #000;
        border-bottom: 0.25mm solid #000;
        font-size: 4.5pt;
        background: #fff;
        break-inside: avoid;
    }

    .calendar-boundary--80 {
        border-bottom-width: 0.7mm;
    }

    .calendar-age {
        color: #111;
        font-size: 4.2pt;
    }

    .calendar-week {
        width: 1.45mm;
        height: 1.45mm;
        border-radius: 0;
    }

    .calendar-week--past {
        border: 0.18mm solid #000;
        background: #171717 !important;
    }

    .calendar-week--future {
        border: 0.18mm solid #777;
    }

    .calendar-week--current {
        border: 0.35mm double #000;
        outline: 0.2mm solid #000;
        outline-offset: 0.12mm;
        background: #fff !important;
    }

    .calendar-week--current::after {
        display: none;
    }

    .calendar-marker {
        color: #000;
        font-size: 3.8pt;
    }

    .legend {
        gap: 4mm;
        margin-top: 2.5mm;
        padding-top: 2.5mm;
        border-color: #777;
        color: #111;
        font-size: 6pt;
    }

    .legend__cell {
        width: 2.2mm;
        height: 2.2mm;
    }

    .scale-note {
        max-width: none;
        margin-top: 2mm;
        color: #222;
        font-size: 6pt;
        line-height: 1.3;
    }

    .weekend-note {
        margin-top: 1mm;
        color: #333;
        font-size: 5pt;
    }
}
