:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --background: #f8fafc;
  --card: #ffffff;
  --text: #172033;
  --muted: #64748b;
  --border: #cbd5e1;
  --danger: #b91c1c;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  padding: 16px 16px 92px;
  color: var(--text);
  background: var(--background);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { min-height: 44px; }
button, summary { -webkit-tap-highlight-color: transparent; }
.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.18em; }
.icon-title { margin-right: 7px; }
.status-icon, .feedback-icon, .confirmation-icon { margin-right: 6px; }

.app-shell {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 20px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 8px 24px rgb(15 23 42 / 8%);
}
.app-shell[aria-busy="true"] { min-height: 220px; }
.load-error { margin: 0; color: var(--danger); font-size: 14px; }

.app-header { margin-bottom: 22px; }
.brand-name { margin: 0; color: var(--primary); font-size: 28px; font-weight: 850; letter-spacing: -0.05em; }
.brand-tagline { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.app-view[hidden] { display: none; }
.view-heading { margin-bottom: 20px; }
.view-heading h1 { margin: 0; font-size: 21px; letter-spacing: -0.02em; }
.view-heading p { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.4; }

.form-section { padding: 18px 0; border-top: 1px solid #e2e8f0; }
.form-section:first-of-type { padding-top: 0; border-top: 0; }
.form-section h2 { margin: 0 0 13px; font-size: 16px; }
.field-grid { display: grid; gap: 14px; }
.grid-full { grid-column: 1 / -1; }
.field { min-width: 0; }
label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 700; }
.input-with-unit { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: #fff; transition: border-color .2s, box-shadow .2s; }
.input-with-unit:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(37 99 235 / 15%); }
.input-with-unit > span { padding: 0 11px; color: var(--muted); font-size: 14px; font-weight: 700; white-space: nowrap; }
.input-with-unit input { width: 100%; min-width: 0; min-height: 46px; padding: 10px 11px; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 16px; }
.unit-after input { padding-right: 4px; }
.compact-input { max-width: 230px; }
select { width: 100%; min-height: 46px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: #fff; }
.field-help { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.choice-grid { display: grid; gap: 9px; }
.choice-button, .segment-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: #fff; cursor: pointer; font-weight: 750; }
.choice-button.is-selected, .segment-button.is-selected { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.segment-control { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.form-error { margin: 14px 0 0; padding: 10px 12px; border-radius: 8px; color: var(--danger); background: #fef2f2; font-size: 14px; }
.form-actions { display: grid; gap: 4px; margin-top: 20px; }
.btn-primary, .btn-outline, .btn-copy, .btn-text, .btn-danger { border-radius: 10px; cursor: pointer; font-weight: 750; }
.btn-primary { width: 100%; padding: 12px; border: 1px solid var(--primary); color: #fff; background: var(--primary); font-size: 16px; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { width: 100%; padding: 10px 12px; border: 1px solid #93c5fd; color: var(--primary-dark); background: #fff; }
.btn-text { justify-self: center; padding: 8px 12px; border: 0; color: var(--primary-dark); background: transparent; font-size: 14px; }
.btn-danger { padding: 10px 12px; border: 1px solid #fecaca; color: var(--danger); background: #fff; }
.saved-message, .feedback-message { display: flex; align-items: center; margin: 12px 0 0; color: #15803d; font-size: 13px; font-weight: 700; }
.feedback-message[data-status="info"] { color: var(--muted); }
.feedback-message[data-status="error"] { color: var(--danger); }

.result-modal, .confirmation-modal { width: min(calc(100% - 32px), 580px); max-height: calc(100dvh - 32px); margin: auto; overflow: auto; border: 1px solid #bfdbfe; border-radius: 16px; box-shadow: 0 24px 64px rgb(15 23 42 / 25%); }
.result-modal { padding: 20px; background: var(--primary-soft); }
.confirmation-modal { padding: 20px; background: var(--card); }
.result-modal::backdrop, .confirmation-modal::backdrop { background: rgb(15 23 42 / 50%); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.modal-title, .confirmation-modal h2 { margin: 0; font-size: 16px; font-weight: 800; }
.modal-close { display: grid; width: 36px; min-height: 36px; place-items: center; padding: 0; border: 0; border-radius: 50%; color: var(--text); background: rgb(255 255 255 / 70%); cursor: pointer; font-size: 26px; line-height: 1; }
.modal-close .icon { width: 20px; height: 20px; vertical-align: 0; }
.confirmation-modal > p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.confirmation-modal > p { display: flex; align-items: flex-start; }
.result-eyebrow { margin: 0; color: #1e40af; font-size: 13px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
.result-price { margin: 4px 0; color: var(--primary-dark); font-size: clamp(38px, 12vw, 52px); font-weight: 850; letter-spacing: -0.06em; }
.exact-price { margin: 0 0 12px; color: #475569; font-size: 13px; }
.result-subtitle { margin: 18px 0 8px; font-size: 15px; }
.job-summary { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; color: #334155; font-size: 14px; }
.job-summary li { display: flex; align-items: center; gap: 7px; }
.summary-icon { width: 16px; height: 16px; color: var(--primary-dark); }
.result-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.result-totals div { padding: 11px; border-radius: 10px; background: #fff; }
.result-totals div:last-child { grid-column: 1 / -1; }
.result-totals dt, .cost-breakdown dt { color: var(--muted); font-size: 12px; line-height: 1.3; }
.result-totals dd, .cost-breakdown dd { margin: 4px 0 0; color: var(--text); font-size: 15px; font-weight: 800; }
.cost-breakdown { margin-top: 12px; padding: 12px; border-radius: 10px; background: #fff; }
.cost-breakdown dl { display: grid; gap: 10px; margin: 0; }
.cost-breakdown div { display: flex; justify-content: space-between; gap: 12px; }
.cost-breakdown dd { text-align: right; }

.more-card { margin-top: 14px; padding: 18px; border: 1px solid #dbe5f0; border-radius: 14px; background: #fafafa; }
.more-card h2 { margin: 0 0 10px; font-size: 16px; }
.more-card p { margin: 0 0 10px; color: #475569; font-size: 13px; line-height: 1.45; }
.more-card p:last-child { margin-bottom: 0; }
.donation-details { margin-top: 12px; padding: 14px; border-radius: 10px; background: #fff; }
.donation-method { margin: 0 0 12px !important; color: var(--text) !important; font-size: 14px !important; font-weight: 800; }
.donation-label { margin: 12px 0 4px !important; color: var(--muted) !important; font-size: 12px !important; font-weight: 700; text-transform: uppercase; }
.donation-details code, .donation-concept { display: block; margin: 0; color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 15px; font-weight: 800; letter-spacing: .04em; }
.donation-concept { letter-spacing: 0; }
.btn-copy { width: 100%; margin-top: 9px; padding: 9px; border: 1px solid #bfdbfe; color: var(--primary-dark); background: var(--primary-soft); font-size: 14px; }
.demo-message { margin: 10px 0 0 !important; padding: 8px; border-radius: 6px; color: #92400e !important; background: #fef3c7; font-size: 12px !important; font-weight: 700; }
.reset-card { border-color: #fecaca; }
.reset-confirmation { margin-top: 12px; padding: 12px; border-radius: 9px; background: #fff; }
.confirmation-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.bottom-nav { position: fixed; z-index: 5; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); border-top: 1px solid #dbe5f0; background: rgb(255 255 255 / 96%); box-shadow: 0 -4px 16px rgb(15 23 42 / 7%); backdrop-filter: blur(12px); }
.nav-button { display: grid; min-height: 54px; grid-template-rows: 19px min-content; align-content: center; justify-items: center; gap: 3px; padding: 5px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 750; line-height: 1.1; text-align: center; }
.nav-button .icon { width: 19px; height: 19px; line-height: 1; }
.nav-button.is-active { color: var(--primary-dark); background: var(--primary-soft); }

:focus-visible { outline: 3px solid rgb(37 99 235 / 35%); outline-offset: 2px; }

@media (min-width: 640px) {
  body { padding: 32px; }
  .app-shell { padding: 30px; }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-actions { grid-template-columns: 1fr auto; align-items: center; }
  .btn-text { justify-self: end; }
  .bottom-nav { position: static; width: min(760px, 100%); margin: 18px auto 0; border: 1px solid #dbe5f0; border-radius: 14px; box-shadow: none; }
}
