@font-face {
    font-family: "Bricolage Grotesque";
    src: url("fonts/bricolagegrotesque.woff2") format("woff2");
    font-style: normal;
    font-weight: 500 800;
    font-display: swap;
}
@font-face {
    font-family: "DM Sans";
    src: url("fonts/dmsans.woff2") format("woff2");
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
}
:root {
    color-scheme: light;
    --ink: #142735;
    --muted: #4c5e68;
    --line: #dbE5e7;
    --paper: #fff;
    --surface: #f3f6f7;
    --input: #f9fbfb;
    --teal: #086759;
    --navy: #102b38;
    --mint: #9fe4ce;
    --display: "Bricolage Grotesque", "Segoe UI", sans-serif;
    font: 100%/1.55 "DM Sans", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; color: var(--ink); background: var(--surface); }
a { color: var(--teal); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: wait; opacity: .68; }
input, select, textarea { color: var(--ink); }
:focus-visible { outline: 3px solid #138a76; outline-offset: 3px; }
.skip { position: absolute; z-index: 2; padding: .65rem 1rem; background: var(--paper); transform: translateY(-110%); }
.skip:focus { transform: none; }
.container { width: min(100% - 3rem, 1160px); margin-inline: auto; }

.site-header { background: var(--paper); border-bottom: 1px solid #dfe9e9; }
.header-inner, .footer-inner { display: flex; justify-content: space-between; align-items: center; }
.header-inner { min-height: 4.6rem; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .64rem; color: var(--ink); text-decoration: none; }
.brand img { width: 44px; height: 44px; background: #eaf4f2; border-radius: 13px; padding: 6px; }
.wordmark { font: 800 clamp(1.35rem, 3vw, 1.92rem)/1 var(--display); letter-spacing: -.058em; white-space: nowrap; }
.brand-accent { color: var(--teal); }
.saved-link { display: flex; align-items: center; gap: .52rem; color: var(--ink); text-decoration: none; border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: .52rem .84rem; font-weight: 700; font-size: .9rem; }
.saved-link:hover, .saved-link.is-current { border-color: #9abfb4; background: #ecf7f3; color: var(--teal); }
.bookmark { width: .65rem; height: .9rem; background: var(--teal); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 71%, 0 100%); }

.hero {
    color: #fff;
    background:
        radial-gradient(ellipse at 94% -75%, #147768 0%, #0c4a46 38%, transparent 72%),
        linear-gradient(118deg, #102738 5%, var(--navy) 60%, #103d42);
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: "";
    position: absolute;
    inset: 0 0 0 52%;
    background-image:
        linear-gradient(to right, #a3e9d11e 1px, transparent 1px),
        linear-gradient(to bottom, #a3e9d11e 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(110deg, transparent 7%, #000 100%);
    pointer-events: none;
}
.hero-inner { min-height: 234px; padding-block: 2.8rem; display: grid; grid-template-columns: minmax(0, 1fr) 286px; align-items: center; gap: 2.25rem; position: relative; z-index: 1; }
.hero-inner > :first-child:only-child { grid-column: 1 / -1; }
h1 { font: 740 clamp(2.1rem, 4.5vw, 4.15rem)/1 var(--display); margin: 0; letter-spacing: -.055em; text-wrap: balance; }
h1 span { color: var(--mint); }
.hero-description { color: #d8e9eb; margin: 1rem 0 0; font-size: clamp(1rem, 2vw, 1.12rem); max-width: 46ch; }
.country-control { padding: .85rem; border: 1px solid #d8f1e73a; border-radius: 14px; background: #112d37ad; }
.country-control label { color: #daefeb; display: block; font-size: .89rem; font-weight: 700; margin: 0 0 .45rem; }
.country-search, .country-control select { width: 100%; background-color: var(--paper); border: 1px solid transparent; border-radius: 8px; color: var(--ink); }
.country-search { padding: .53rem .68rem; min-height: 2.65rem; margin-bottom: .4rem; }
.country-search::placeholder { color: #52636e; }
.country-control :focus-visible { outline-color: #a3e8d0; }

.content { min-height: 55vh; padding-bottom: 3.5rem; }
.tabs { display: flex; gap: .35rem; padding-block: .65rem .55rem; margin-bottom: 1.25rem; border-bottom: 1px solid #d4e0e3; }
.tabs a { position: relative; padding: .62rem .96rem; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 700; white-space: nowrap; }
.tabs a:hover { background: #e4eef1; color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--teal); background: #dfeee9; }
.tabs a[aria-current="page"]::after { content: ""; position: absolute; bottom: -.6rem; left: 12%; right: 12%; height: 3px; border-radius: 3px 3px 0 0; background: var(--teal); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .93fr); gap: 1.35rem; align-items: start; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 24px #102d3b0b; }
.form-panel, .output, .history, .privacy { padding: clamp(1.1rem, 3vw, 1.7rem); }
.field-group + .field-group { margin-top: 1.2rem; }
h2 { margin: 0 0 1rem; font: 730 1.48rem/1.15 var(--display); letter-spacing: -.035em; }
h3 { font: 700 1.08rem/1.3 var(--display); letter-spacing: -.015em; margin: 1.15rem 0 .6rem; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .88rem .95rem; }
.field label, .split-header label { display: block; font-size: .9rem; font-weight: 700; margin-bottom: .35rem; }
.field small { display: block; color: var(--muted); margin-top: .35rem; font-size: .825rem; }
.field input, select, textarea { width: 100%; background-color: var(--input); border: 1px solid #c8d6db; border-radius: 8px; min-height: 2.9rem; padding: .55rem .72rem; }
.field input::placeholder { color: #637680; }
select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 46%, #395d64 48%, #395d64 65%, transparent 67%), linear-gradient(135deg, transparent 32%, #395d64 34%, #395d64 51%, transparent 53%);
    background-position: calc(100% - 18px) 52%, calc(100% - 12px) 52%;
    background-size: 6px 6px;
    background-repeat: no-repeat;
    padding-right: 2rem;
}
.money-input { display: flex; align-items: center; background-color: var(--input); border: 1px solid #c8d6db; border-radius: 8px; }
.money-input span { font-size: .875rem; color: var(--teal); font-weight: 700; margin-left: .72rem; flex-shrink: 0; }
.money-input input { border: 0; background: transparent; min-width: 0; font-variant-numeric: tabular-nums; }
.money-input:focus-within { outline: 3px solid #138a76; outline-offset: 3px; }
.money-input input:focus { outline: none; }
.field.full, .check { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: .65rem; font-size: .95rem; }
.check input { accent-color: var(--teal); margin: .25rem 0 0; width: 1.1rem; height: 1.1rem; flex: 0 0 auto; }
details.field-group { border: 1px solid var(--line); border-radius: 10px; }
details summary { cursor: pointer; padding: .72rem .82rem; font-size: .94rem; font-weight: 700; }
details .field-grid { padding: 0 .82rem .82rem; }

.form-actions { display: flex; gap: .58rem; flex-wrap: wrap; margin-top: 1.2rem; }
.primary, .secondary, .quiet { display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; min-height: 2.8rem; border: 1px solid transparent; padding: .57rem .94rem; font-weight: 700; text-decoration: none; }
.primary { color: #fff; background: var(--teal); }
.primary:hover { background: #064c43; }
.secondary { color: var(--teal); background: #eaf5f1; border-color: #cde3dc; }
.secondary:hover { background: #def0e9; }
.quiet { color: var(--muted); background: var(--paper); border-color: #ccdbe1; }
.quiet:hover { background: var(--surface); }

.output { min-height: 270px; }
.empty-result { min-height: 215px; display: grid; justify-items: center; align-content: center; text-align: center; padding: 1rem; }
.empty-result h2 { margin: .92rem 0 .35rem; }
.empty-result p { margin: 0; color: var(--muted); }
.result-mark { width: 3.15rem; height: 3.15rem; display: grid; place-items: center; background: #e5f2ee; color: var(--teal); border-radius: 14px; font-size: 1.2rem; font-weight: 700; }
.result-top { background: linear-gradient(118deg, #e6f3ef, #f0f7f6); border: 1px solid #d2e6e0; border-radius: 13px; padding: 1rem 1.12rem; color: #123e36; }
.result-top h2 { font: 700 .95rem/1.3 "DM Sans", system-ui, sans-serif; letter-spacing: normal; margin: 0; }
.result-total { font: 780 clamp(1.65rem, 4vw, 3rem)/1.05 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.035em; margin: .42rem 0 0; overflow-wrap: anywhere; }
.result-top p:not(.result-total) { margin: .57rem 0 0; }
.result-rows { list-style: none; margin: .7rem 0; padding: 0; }
.result-rows li { display: flex; justify-content: space-between; gap: .8rem; border-bottom: 1px solid var(--line); padding: .62rem .1rem; font-size: .95rem; }
.result-rows b { font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.result-rows small { display: block; color: var(--muted); }
.result-details { color: var(--muted); font-size: .9rem; margin-top: 1rem; }
.result-details summary { padding-left: 0; color: var(--ink); }
.result-details p { margin: .45rem 0; overflow-wrap: anywhere; }
.payments { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .62rem; margin-top: .66rem; }
.payment { padding: .74rem; border: 1px solid #e1e9eb; border-radius: 10px; background: var(--input); }
.payment p, .payment small { margin: 0; overflow-wrap: anywhere; }
.payment small { color: var(--muted); display: block; }
.payment strong { font: 740 1.2rem/1.3 var(--display); font-variant-numeric: tabular-nums; display: block; margin: .2rem 0; overflow-wrap: anywhere; }
.letter-preview { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--input); border: 1px solid var(--line); color: var(--ink); font: 1rem/1.65 Georgia, serif; margin: 0; border-radius: 10px; padding: 1.1rem; }

.notice { margin: .75rem 0 0; padding: .68rem .8rem; background: #e8f4ef; border-radius: 8px; color: #124c3e; }
.error { background: #fff0ed; color: #8c2717; }
.split-header { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.split-header p, .history-empty { margin: 0; color: var(--muted); }
.saved-row { padding: .9rem 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: .9rem; }
.saved-row h3 { margin: 0; }
.saved-row p { margin: .2rem 0 0; color: var(--muted); }
.saved-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.site-footer { background: #e9f0f2; border-top: 1px solid var(--line); }
.footer-inner { min-height: 4rem; gap: 1rem; flex-wrap: wrap; font-size: .9rem; }
.footer-inner span { font: 750 1.15rem/1 var(--display); letter-spacing: -.035em; }
.footer-inner div { display: flex; gap: 1rem; }

@media (max-width: 800px) {
    .workspace { grid-template-columns: 1fr; }
    .hero-inner { grid-template-columns: 1fr; gap: 1.2rem; min-height: 0; padding-block: 2rem 1.65rem; }
    .country-control { width: min(100%, 340px); }
}
@media (max-width: 500px) {
    .container { width: calc(100% - 1.5rem); }
    .header-inner { min-height: 4.15rem; gap: .45rem; }
    .brand { gap: .45rem; }
    .brand img { width: 38px; height: 38px; }
    .saved-link { padding-inline: .55rem; }
    .tabs { gap: .12rem; margin-bottom: 1rem; }
    .tabs a { padding: .52rem .46rem; font-size: .88rem; }
    .field-grid { grid-template-columns: 1fr; }
    .split-header, .saved-row { align-items: start; flex-direction: column; }
}
