/* BuildCalc — design system (no external fonts, no framework) */
:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #e9e9e5;
  --text: #141414;
  --muted: #4b4f54;
  --border: #d2d3ce;
  --primary: #ffcd11;
  --primary-700: #e0b000;
  --primary-ink: #141414;
  --accent: #141414;
  --danger: #c62828;
  --danger-bg: #fdecec;
  --success: #1b7f3b;
  --shadow: 0 1px 2px rgb(20 20 20 / .08), 0 8px 24px -12px rgb(20 20 20 / .2);
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --maxw: 1120px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --surface: #1b1d20;
    --surface-2: #25282c;
    --text: #f2f2ef;
    --muted: #a4a8ad;
    --border: #33373d;
    --primary: #ffcd11;
    --primary-700: #ffe055;
    --primary-ink: #141414;
    --accent: #ffcd11;
    --danger: #ff7b7b;
    --danger-bg: #3a1c1c;
    --shadow: 0 1px 2px rgb(0 0 0 / .45), 0 8px 24px -12px rgb(0 0 0 / .65);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--primary-700); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.75rem, 2.5vw + 1rem, 2.5rem); }
h2 { font-size: clamp(1.3rem, 1vw + 1rem, 1.6rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
small { color: var(--muted); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.container { width: min(100% - 2rem, var(--maxw)); margin-inline: auto; }
.skip-link { position: absolute; left: 1rem; top: -4rem; background: var(--primary); color: var(--primary-ink); padding: .6rem 1rem; border-radius: var(--radius-sm); z-index: 100; font-weight: 600; }
.skip-link:focus { top: 1rem; }

/* ---------- header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; gap: 1rem; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.brand-picture { display: inline-flex; align-items: center; }
.brand-logo { height: 36px; width: auto; display: block; }
@media (max-width: 640px) { .brand-logo { height: 30px; } }
.nav-toggle { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); color: var(--text); cursor: pointer; }
.nav-toggle svg { width: 22px; height: 22px; }
.site-nav { display: none; position: absolute; inset-inline: 0; top: 100%; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); padding: .5rem 1rem 1rem; }
.site-nav.is-open { display: block; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.site-nav a { display: block; padding: .7rem .75rem; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-weight: 500; }
.site-nav a:hover, .site-nav a[aria-current="page"] { background: var(--surface-2); color: var(--primary); }
.lang-switch { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .7rem; border: 1px solid var(--border); border-radius: 999px; font-size: .9rem; font-weight: 600; color: var(--text); text-decoration: none; white-space: nowrap; }
.lang-switch:hover { border-color: var(--primary); }
@media (min-width: 820px) {
  .nav-toggle { display: none; }
  .site-nav { display: block; position: static; margin-left: auto; background: none; border: 0; box-shadow: none; padding: 0; }
  .site-nav ul { flex-direction: row; align-items: center; gap: .25rem; }
  .site-nav li:last-child { margin-left: .5rem; }
}

/* ---------- layout ---------- */
main { flex: 1; padding-block: 1.5rem 3rem; }
.page-head { margin-bottom: 1.25rem; }
.page-head .lead, .hero .lead { font-size: 1.1rem; color: var(--muted); max-width: 65ch; }
.breadcrumb { font-size: .875rem; color: var(--muted); margin-bottom: .75rem; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; padding: 0; margin: 0; }
.breadcrumb li + li::before { content: "/"; margin-right: .35rem; color: var(--border); }
.calc-layout { display: grid; gap: 1.25rem; align-items: start; }
@media (min-width: 900px) {
  .calc-layout { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 1.75rem; }
  .results { position: sticky; top: 76px; }
}
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
@media (min-width: 600px) { .card { padding: 1.5rem; } }
.section { margin-top: 2.5rem; }
.prose { max-width: 72ch; }
.prose p { color: var(--text); }
.prose h3 { margin-top: 1.25rem; }
.prose code { font-family: var(--mono); background: var(--surface-2); padding: .1em .35em; border-radius: 4px; font-size: .92em; }
.guide-steps, .guide-list { margin: 0 0 1rem; padding-left: 1.35rem; display: grid; gap: .45rem; }
.formula-box { list-style: none; margin: 0 0 1.1rem; padding: .85rem 1rem; background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius-sm); display: grid; gap: .4rem; }
.formula-box code { background: none; padding: 0; font-size: .9rem; }
.example-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 680px) { .example-grid { grid-template-columns: 1fr 1fr; } }
.example-card h3 { margin-bottom: .45rem; }
.example-card p { margin: 0 0 .65rem; font-size: .95rem; }
.example-card p:last-child { margin-bottom: 0; }
.example-calc { font-family: var(--mono); font-size: .84rem !important; background: var(--surface-2); border-radius: var(--radius-sm); padding: .55rem .75rem; line-height: 1.5; }
.example-result { font-weight: 700; color: var(--text); }

/* ---------- forms ---------- */
.calc-form fieldset { border: 0; padding: 0; margin: 0 0 1.25rem; min-width: 0; }
.calc-form legend, .calc-form label { font-weight: 600; font-size: .95rem; }
.calc-form legend { padding: 0; margin-bottom: .5rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: .35rem; }
.field .unit { color: var(--muted); font-weight: 500; }
.field input[type="number"], .field input[type="text"], .field select {
  width: 100%; min-height: 46px; padding: .6rem .8rem; font: inherit; font-size: 1.05rem;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); outline: none; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.field-help { margin: .35rem 0 0; font-size: .85rem; color: var(--muted); }
.field-error { margin: .35rem 0 0; font-size: .875rem; color: var(--danger); font-weight: 600; }
.field-grid { display: grid; gap: .9rem 1rem; grid-template-columns: 1fr; margin-bottom: 1rem; }
@media (min-width: 540px) { .field-grid { grid-template-columns: 1fr 1fr; } .field-grid .field { margin-bottom: 0; } .field-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.check { display: flex; align-items: center; gap: .6rem; font-weight: 500 !important; min-height: 44px; cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--primary); }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.segmented label { position: relative; cursor: pointer; display: inline-flex; border-radius: 999px; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { padding: .5rem 1rem; border-radius: 999px; font-weight: 600; font-size: .95rem; min-height: 40px; display: inline-flex; align-items: center; color: var(--muted); transition: background .15s, color .15s; }
.segmented input:checked + span { background: var(--primary); color: var(--primary-ink); }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.radio-list { display: grid; gap: .5rem; }
@media (min-width: 540px) { .radio-list { grid-template-columns: 1fr 1fr; } }
.radio-card { display: flex; align-items: center; gap: .65rem; padding: .7rem .85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-weight: 500 !important; background: var(--surface); min-height: 44px; }
.radio-card:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.radio-card:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.radio-card input { accent-color: var(--primary); width: 1.15rem; height: 1.15rem; margin: 0; flex-shrink: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .5rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 46px; padding: .65rem 1.2rem; font: inherit; font-weight: 700; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-700); color: var(--primary-ink); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { min-height: 38px; padding: .4rem .85rem; font-size: .9rem; }
.error-summary { background: var(--danger-bg); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); padding: .7rem .9rem; border-radius: var(--radius-sm); font-weight: 600; margin-bottom: 1rem; }

/* ---------- results ---------- */
.results h2 { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: 1.2rem; }
.results-placeholder { color: var(--muted); margin: 0; padding: 1rem 0; }
.results[data-state="invalid"] .results-placeholder { color: var(--danger); }
.result-primary { background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 14%, var(--surface)), color-mix(in srgb, var(--primary) 4%, var(--surface))); border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border)); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.result-label { display: block; font-size: .9rem; color: var(--muted); font-weight: 600; }
.result-value { display: block; font-size: clamp(1.7rem, 2vw + 1rem, 2.3rem); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.result-rows { margin: 0; display: grid; gap: .4rem; }
.result-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.result-row dt { color: var(--muted); font-size: .95rem; }
.result-row dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.result-row dd small { display: block; font-weight: 400; font-size: .8rem; }
.result-warning { background: var(--danger-bg); color: var(--danger); padding: .6rem .8rem; border-radius: var(--radius-sm); font-weight: 600; }
.result-steps { margin-top: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .9rem; background: var(--surface-2); }
.result-steps summary { cursor: pointer; font-weight: 700; }
.result-steps ol { margin: .6rem 0 .2rem; padding-left: 1.2rem; font-family: var(--mono); font-size: .82rem; line-height: 1.5; }
.result-steps li + li { margin-top: .4rem; }
.result-disclaimer { margin: 1rem 0 0; font-size: .8rem; color: var(--muted); }
.results-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.results[data-state="empty"] .results-actions, .results[data-state="invalid"] .results-actions { display: none; }

/* mobile sticky result bar (hidden on desktop where results are beside the form) */
.result-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; align-items: center; gap: .75rem; padding: .65rem 1rem calc(.65rem + env(safe-area-inset-bottom)); background: var(--primary); color: var(--primary-ink); text-decoration: none; box-shadow: 0 -4px 16px rgb(0 0 0 / .18); }
.result-bar-label { font-size: .75rem; opacity: .9; flex: 1; line-height: 1.2; }
.result-bar-value { font-size: 1.15rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.result-bar-cta { font-weight: 800; }
body:has(.result-bar:not([hidden])) main { padding-bottom: 5rem; }
@media (min-width: 900px) { .result-bar { display: none !important; } }
@media print { .result-bar { display: none !important; } }

/* ---------- home ---------- */
.hero { padding-block: 1.5rem 2rem; }
.hero h1 { max-width: 20ch; }
.card-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .card-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); } }
.calc-card { display: flex; flex-direction: column; gap: .5rem; text-decoration: none; color: var(--text); transition: transform .15s, border-color .15s; }
.calc-card:hover { transform: translateY(-2px); border-color: var(--primary); color: var(--text); }
.calc-card .icon { width: 44px; height: 44px; border-radius: 10px; background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--primary); display: grid; place-items: center; }
.calc-card .icon svg { width: 26px; height: 26px; }
.calc-card p { color: var(--muted); margin: 0; flex: 1; }
.calc-card .cta { color: var(--primary); font-weight: 700; }
.feature-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .feature-grid { grid-template-columns: 1fr 1fr; } }
.feature h3 { margin-bottom: .25rem; }
.feature p { color: var(--muted); margin: 0; }

/* ---------- faq ---------- */
.faq details { border-bottom: 1px solid var(--border); padding: .6rem 0; }
.faq summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }
.faq p { margin: .5rem 0 .3rem; color: var(--muted); }
.related ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .6rem; }
.related a { display: inline-block; padding: .55rem .95rem; min-height: 40px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; font-weight: 600; background: var(--surface); transition: border-color .15s, color .15s; }
.related a:hover { border-color: var(--primary); color: var(--primary-700); }

/* ---------- monetization slots (inactive unless enabled in config) ---------- */
.ad-slot { margin: 1.5rem 0; min-height: 90px; display: grid; place-items: center; border: 1px dashed var(--border); border-radius: var(--radius-sm); color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.ad-banner-wrap { margin: 1.75rem 0; display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.ad-banner-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ad-banner-box { width: 300px; max-width: 100%; min-height: 250px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ad-native-box { width: 100%; max-width: 720px; min-height: 90px; display: flex; justify-content: center; overflow: hidden; }
.affiliate-box { border-left: 4px solid var(--accent); }
.affiliate-box small { display: block; margin-top: .5rem; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 1.5rem 0 2rem; font-size: .9rem; color: var(--muted); }
.site-footer .footer-inner { display: flex; flex-direction: column; gap: .75rem; }
.site-footer nav ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.site-footer a { color: var(--muted); }
@media (min-width: 640px) { .site-footer .footer-inner { flex-direction: row; justify-content: space-between; align-items: flex-start; } }

/* ---------- redirect / 404 ---------- */
.center-page { text-align: center; padding: 4rem 1rem; }
.lang-choice { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-top: 1.5rem; }

/* ---------- home redesign ---------- */
.hero-home { display: flex; align-items: center; justify-content: space-between; gap: 2rem; border-left: 5px solid var(--primary); background: var(--surface); border-radius: var(--radius); padding: 2rem; margin: 1.5rem 0 2rem; box-shadow: var(--shadow); }
.hero-content { max-width: 640px; }
.hero-actions { margin-top: 1.25rem; }
.hero-mark { flex-shrink: 0; opacity: .95; }
.hero-mark img { display: block; width: 96px; height: auto; }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: 1rem; }
.step-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.step-num { display: inline-block; font-size: .8rem; font-weight: 800; letter-spacing: .06em; color: #141414; background: var(--primary); padding: .2rem .55rem; border-radius: 4px; margin-bottom: .65rem; }
.step-card h3 { margin: 0 0 .4rem; font-size: 1.05rem; }
.step-card p { margin: 0; color: var(--muted); font-size: .95rem; }
.home-example { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-top: 1rem; box-shadow: var(--shadow); }
.home-example-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.home-example-head h3 { margin: 0; font-size: 1.1rem; }
.example-badge { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); border: 1px solid var(--border); padding: .2rem .6rem; border-radius: 4px; color: var(--text); }
.home-example-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.home-example-step { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .9rem 1rem; display: flex; flex-direction: column; gap: .35rem; }
.home-example-result { border-color: var(--primary); }
.example-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.home-example-step code { font-size: .92rem; background: none; padding: 0; color: var(--text); }
.home-example-foot { display: flex; justify-content: flex-start; }
@media (max-width: 640px) { .hero-home { flex-direction: column; align-items: flex-start; padding: 1.5rem; } .hero-mark { display: none; } }

/* ---------- history ---------- */
.history-panel { margin-top: 1.5rem; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.history-head h2 { margin: 0; font-size: 1.1rem; }
.history-empty { margin: 0; color: var(--muted); font-size: .92rem; }
.history-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .65rem; }
.history-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; padding: .75rem .9rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; }
.history-meta { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--muted); }
.history-sys { font-weight: 700; color: var(--text); background: var(--surface); border: 1px solid var(--border); padding: .1rem .45rem; border-radius: 4px; }
.history-preview { flex: 1 1 220px; font-size: .88rem; color: var(--text); }
.history-actions { display: flex; gap: .4rem; }

/* ---------- print ---------- */
@media print {
  .site-header, .site-footer, .breadcrumb, .form-actions, .results-actions, .ad-slot, .affiliate-box, .skip-link, .section, .history-panel { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #999; }
  .calc-layout { grid-template-columns: 1fr; }
  .results { position: static; }
  .result-steps { background: none; }
}
