:root {
  color-scheme: light;
  --bg: #f5f8fc;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #dce3ec;
  --line-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --success-line: #bbf7d0;
  --danger: #b42318;
  --danger-soft: #fff5f4;
  --shadow: 0 18px 50px rgba(30, 41, 59, 0.08);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -120px, rgba(37, 99, 235, 0.11), transparent 420px),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.site-header {
  height: 68px;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(203, 213, 225, 0.85);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  width: min(1320px, calc(100% - 40px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  font-weight: 760;
  letter-spacing: -0.02em;
  font-size: 18px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #1d4ed8, #3b82f6);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.24);
}
.brand-mark svg { width: 23px; height: 23px; }
.brand-mark path:first-child { fill: rgba(255,255,255,.18); stroke: #fff; stroke-width: 1.8; }
.brand-mark path:last-child { fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; }
.github-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.github-button:hover { border-color: #94a3b8; box-shadow: 0 5px 14px rgba(15,23,42,.08); transform: translateY(-1px); }
.github-button svg { width: 18px; height: 18px; fill: currentColor; }

main { padding: 42px 0 58px; }
.hero { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }
.hero-copy { text-align: center; max-width: 800px; margin: 0 auto 28px; }
.hero-copy h1 {
  margin: 0;
  color: #111827;
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1.03;
  letter-spacing: -0.045em;
}
.hero-copy p {
  margin: 13px auto 0;
  max-width: 720px;
  font-size: 18px;
  line-height: 1.6;
  color: #475467;
}

.calculator-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(380px, .82fr);
  gap: 22px;
  align-items: start;
}
.calculator-card, .result-card, .comparison-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.calculator-card { padding: 24px; }
.result-card { overflow: hidden; position: sticky; top: 90px; }
.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.card-heading.compact { margin-bottom: 8px; }
.card-heading > div:first-child { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-heading h2 { margin: 0; font-size: 18px; letter-spacing: -0.015em; }
.step-number {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}
.optional-label { color: var(--muted); font-size: 13px; }
.section-helper { margin: 0 0 14px 36px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.section-divider { height: 1px; background: var(--line); margin: 22px 0; }

.unit-switch { display: inline-flex; padding: 3px; background: #eef2f7; border-radius: 10px; }
.unit-button {
  min-width: 42px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #667085;
  font-weight: 700;
  font-size: 13px;
}
.unit-button.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 4px rgba(15,23,42,.09); }

.field-grid { display: grid; gap: 14px; }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span:first-child, .installation-fieldset legend { font-size: 13px; color: #344054; font-weight: 650; }
.field small { font-weight: 500; color: var(--muted); }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease;
}
input:hover, select:hover { border-color: #a8b3c4; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.09); outline: none; }
.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.input-with-unit:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.09); }
.input-with-unit input { border: 0; border-radius: 0; box-shadow: none; min-width: 0; }
.input-with-unit input:focus { box-shadow: none; }
.input-with-unit > span:last-child { padding: 0 12px; color: var(--muted); font-size: 13px; font-weight: 650; border-left: 1px solid var(--line); }
.currency-input { grid-template-columns: auto minmax(0,1fr); }
.currency-input > span:first-child { padding-left: 12px; color: var(--muted); font-weight: 650; }
.currency-input input { padding-left: 8px; }
.custom-sheet-fields { margin-top: 14px; padding: 14px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius-md); }

.secondary-button, .icon-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: #344054;
}
.secondary-button {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 700;
}
.secondary-button:hover { border-color: #94a3b8; background: var(--surface-soft); }
.secondary-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.openings-list { display: grid; gap: 10px; }
.opening-row {
  display: grid;
  grid-template-columns: 1fr 1fr 84px 40px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}
.compact-field { gap: 5px; }
.compact-field input { min-height: 40px; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 9px; }
.icon-button:hover { color: var(--danger); background: var(--danger-soft); border-color: #fecdca; }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.installation-fieldset { border: 0; padding: 0; margin: 16px 0 0; }
.installation-fieldset legend { margin-bottom: 8px; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-soft); }
.segmented-control label { position: relative; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span {
  display: grid; place-items: center; min-height: 38px; border-radius: 8px; font-size: 13px; font-weight: 700; color: #475467; cursor: pointer;
}
.segmented-control input:checked + span { color: var(--primary); background: var(--surface); box-shadow: 0 1px 4px rgba(15,23,42,.09); }
.segmented-control input:focus-visible + span { outline: 3px solid rgba(37, 99, 235, .22); outline-offset: 2px; }
.form-error { min-height: 20px; margin-top: 12px; color: var(--danger); font-size: 13px; font-weight: 600; }
.primary-button {
  width: 100%;
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow: 0 10px 24px rgba(37, 99, 235, .24);
  font-weight: 760;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 13px 28px rgba(37,99,235,.3); filter: saturate(1.05); }
.primary-button:active { transform: translateY(0); }
.primary-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.result-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px;
  background: linear-gradient(135deg, #f4fff7, #f9fffb);
  border-bottom: 1px solid var(--success-line);
}
.success-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #dcfce7; color: var(--success); }
.success-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow { display: block; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.result-heading h2 { margin: 3px 0 0; font-size: 18px; letter-spacing: -.015em; }
.result-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 24px 22px; border-bottom: 1px solid var(--line); }
.result-hero > div + div { border-left: 1px solid var(--line); padding-left: 18px; }
.result-label { display: block; color: #475467; font-size: 13px; font-weight: 650; margin-bottom: 5px; }
.sheets-result { display: flex; align-items: baseline; gap: 7px; color: var(--success); }
.sheets-result strong { font-size: 50px; line-height: 1; letter-spacing: -.045em; }
.sheets-result span { font-size: 14px; font-weight: 750; }
.result-subtext { display: block; margin-top: 5px; font-size: 13px; color: var(--muted); }
.area-summary strong { display: block; font-size: 27px; letter-spacing: -.03em; }
.area-summary > span:last-child { display: block; margin-top: 5px; font-size: 12px; color: var(--muted); }
.breakdown-card { margin: 20px 22px 0; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px; background: #fcfdff; }
.breakdown-title { font-size: 13px; font-weight: 780; margin-bottom: 10px; }
.breakdown-list { margin: 0; display: grid; gap: 9px; }
.breakdown-list > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 12.5px; color: #475467; }
.breakdown-list dt, .breakdown-list dd { margin: 0; }
.breakdown-list dd { font-variant-numeric: tabular-nums; color: #344054; font-weight: 650; }
.breakdown-total { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.breakdown-total dt, .breakdown-total dd { color: var(--text) !important; font-weight: 800 !important; }
.visual-reference { padding: 19px 22px 22px; }
.visual-title { font-size: 13px; font-weight: 780; margin-bottom: 2px; }
.visual-reference svg { width: 100%; max-height: 240px; display: block; }
.diagram-wall { fill: url(#wallShade); stroke: #9aa7b7; stroke-width: 1.2; }
.diagram-floor { fill: #edf2f8; stroke: #9aa7b7; stroke-width: 1.2; }
.diagram-opening { fill: #dbeafe; stroke: #7d8b9c; stroke-width: 1.1; }
.dimension-line { fill: none; stroke: #64748b; stroke-width: 1.15; stroke-linecap: round; }
.visual-reference text { fill: #475569; font-size: 13px; font-weight: 700; }

.comparison-section { margin-top: 22px; padding: 24px; box-shadow: 0 12px 36px rgba(30,41,59,.055); }
.comparison-heading { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 16px; }
.comparison-heading h2 { margin: 4px 0 0; font-size: 21px; letter-spacing: -.02em; }
.comparison-heading p { margin: 0; max-width: 420px; color: var(--muted); font-size: 13px; line-height: 1.5; text-align: right; }
.comparison-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.comparison-card { position: relative; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px; background: var(--surface-soft); }
.comparison-card.recommended { border-color: #86efac; background: var(--success-soft); }
.recommended-badge { position: absolute; top: 12px; right: 12px; padding: 4px 7px; border-radius: 999px; background: #dcfce7; color: var(--success); font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.comparison-size { margin: 0; font-size: 18px; font-weight: 820; }
.comparison-coverage { margin-top: 3px; font-size: 12px; color: var(--muted); }
.comparison-number { margin-top: 16px; font-size: 29px; line-height: 1; font-weight: 850; letter-spacing: -.04em; }
.comparison-number span { font-size: 12px; color: var(--muted); font-weight: 650; letter-spacing: 0; }
.comparison-meta { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.comparison-meta strong { color: #344054; }

footer { padding: 24px 20px 34px; text-align: center; color: #98a2b3; font-size: 12px; }

@media (max-width: 980px) {
  .calculator-shell { grid-template-columns: 1fr; }
  .result-card { position: static; }
}

@media (max-width: 720px) {
  .site-header { height: 62px; }
  .header-inner, .hero { width: min(100% - 24px, 1240px); }
  .brand { font-size: 15px; }
  .brand-mark { width: 32px; height: 32px; }
  .github-button { padding: 0 11px; }
  .github-button span { display: none; }
  main { padding-top: 30px; }
  .hero-copy { margin-bottom: 22px; }
  .hero-copy h1 { font-size: clamp(34px, 10vw, 46px); }
  .hero-copy p { font-size: 15px; }
  .calculator-card { padding: 18px; }
  .three-columns, .two-columns, .comparison-grid { grid-template-columns: 1fr; }
  .options-grid { grid-template-columns: 1fr 1fr; }
  .opening-row { grid-template-columns: 1fr 1fr 70px 40px; }
  .result-hero { grid-template-columns: 1fr; }
  .result-hero > div + div { border-left: 0; border-top: 1px solid var(--line); padding: 16px 0 0; }
  .comparison-heading { align-items: start; flex-direction: column; gap: 8px; }
  .comparison-heading p { text-align: left; }
}

@media (max-width: 520px) {
  .card-heading { align-items: flex-start; }
  .card-heading.compact { align-items: center; }
  .secondary-button { padding: 0 9px; }
  .section-helper { margin-left: 0; }
  .opening-row { grid-template-columns: 1fr 1fr; }
  .quantity-field { grid-column: 1 / 2; }
  .opening-row .icon-button { justify-self: end; }
  .options-grid { grid-template-columns: 1fr; }
  .segmented-control { grid-template-columns: 1fr; }
  .result-heading, .result-hero { padding-left: 18px; padding-right: 18px; }
  .breakdown-card { margin-left: 18px; margin-right: 18px; }
  .visual-reference { padding-left: 18px; padding-right: 18px; }
  .comparison-section { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
