:root {
  --brand: #018181;
  --brand-dark: #006060;
  --accent: #f39c12;
  --white: #fff;
  --black: #0b1111;
  --muted: #435050;
  --line: #c8d8d8;
  --surface: #f4fafa;
  --danger: #9b1c1c;
  --success: #006b52;
  --shadow: 0 18px 50px rgb(0 96 96 / 10%);
  --radius: 18px;
  --max-width: 1120px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  margin: 0;
  color: var(--black);
  background: var(--white);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

a {
  color: var(--brand-dark);
  text-underline-offset: .2em;
  text-decoration-thickness: .09em;
}

a:hover {
  text-decoration-thickness: .16em;
}

:focus-visible {
  outline: 3px solid var(--black);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--accent);
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: .75rem;
  left: .75rem;
  padding: .75rem 1rem;
  color: var(--white);
  background: var(--black);
  border-radius: 8px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  min-height: 72px;
  padding: .75rem max(1.25rem, calc((100% - var(--max-width)) / 2));
  background: rgb(255 255 255 / 95%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: var(--brand-dark);
  font-size: 1.15rem;
  font-weight: 800;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.site-header nav {
  display: flex;
  gap: 1.5rem;
}

.site-header nav a {
  color: var(--black);
  font-weight: 650;
  text-decoration: none;
}

.site-header nav a:hover {
  color: var(--brand-dark);
}

.hero {
  background:
    radial-gradient(circle at 90% 20%, rgb(243 156 18 / 14%) 0 8rem, transparent 8.1rem),
    linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: var(--white);
}

.hero__content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(2.75rem, 6vw, 4.75rem) 1.25rem;
}

.hero h1 {
  max-width: 850px;
  margin: .2rem 0 1.25rem;
  font-size: clamp(2.5rem, 7vw, 5.25rem);
  line-height: 1.02;
  letter-spacing: -.055em;
}

.hero__lead {
  max-width: 720px;
  margin: 0;
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  line-height: 1.5;
}

.source-note {
  max-width: 760px;
  margin: 1.5rem 0 0;
  font-size: .95rem;
}

.hero a {
  color: var(--white);
}

.eyebrow {
  margin: 0 0 .45rem;
  color: var(--brand-dark);
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.hero .eyebrow,
.reassurance .eyebrow {
  padding-left: .65rem;
  color: var(--white);
  border-left: 4px solid var(--accent);
}

.external-label {
  white-space: nowrap;
  font-size: .82em;
}

.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(4rem, 8vw, 7rem) 1.25rem;
}

.section-heading {
  max-width: 790px;
  margin-bottom: 2.25rem;
}

.section-heading h2,
.reassurance h2 {
  margin: 0 0 .8rem;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.1;
  letter-spacing: -.035em;
}

.section-heading p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr);
  gap: 2rem;
  align-items: start;
}

.calculator-card,
.before-result,
.results {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.calculator-card {
  padding: clamp(1.25rem, 4vw, 2.25rem);
  background: var(--white);
}

fieldset {
  margin: 0;
  padding: 0 0 2rem;
  border: 0;
}

fieldset + fieldset {
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

legend {
  width: 100%;
  margin-bottom: 1.25rem;
  padding: 0;
  color: var(--black);
  font-size: 1.15rem;
  font-weight: 800;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.field {
  min-width: 0;
}

.field--wide {
  margin-top: 1rem;
}

label {
  display: block;
  margin-bottom: .45rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 50px;
  padding: .75rem .9rem;
  color: var(--black);
  background: var(--white);
  border: 2px solid #829999;
  border-radius: 10px;
}

input:hover,
select:hover {
  border-color: var(--brand);
}

input[aria-invalid="true"] {
  border-color: var(--danger);
}

.input-suffix {
  position: relative;
}

.input-suffix input {
  padding-right: 3.5rem;
}

.input-suffix > span {
  position: absolute;
  top: 50%;
  right: .85rem;
  color: var(--muted);
  font-weight: 750;
  transform: translateY(-50%);
  pointer-events: none;
}

.field-help,
.field-error {
  margin: .4rem 0 0;
  font-size: .86rem;
  line-height: 1.4;
}

.field-help {
  color: var(--muted);
}

.field-error {
  min-height: 1.2em;
  color: var(--danger);
  font-weight: 700;
}

.privacy-inline {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin: 0 0 1.25rem;
  color: var(--brand-dark);
  font-size: .9rem;
  font-weight: 700;
}

.privacy-inline svg {
  flex: none;
  fill: currentColor;
}

.primary-button,
.secondary-button {
  min-height: 50px;
  padding: .8rem 1.2rem;
  border: 2px solid var(--brand-dark);
  border-radius: 10px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  color: var(--white);
  background: var(--brand-dark);
}

.primary-button:hover {
  background: var(--brand);
}

.secondary-button {
  color: var(--brand-dark);
  background: var(--white);
}

.secondary-button:hover {
  background: var(--surface);
}

.before-result {
  position: sticky;
  top: 96px;
  padding: 2rem;
  background: var(--surface);
}

.before-result h3 {
  margin: 0 0 1rem;
  font-size: 1.55rem;
  line-height: 1.2;
}

.important-notice {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  margin-top: 1.25rem;
  padding: 1.15rem 1.25rem;
  color: var(--black);
  background: #fff8ea;
  border: 1px solid #d78300;
  border-left: 6px solid var(--accent);
  border-radius: 12px;
}

.important-notice svg {
  flex: none;
  margin-top: .1rem;
  fill: var(--brand-dark);
}

.important-notice h3 {
  margin: 0 0 .25rem;
  font-size: 1.05rem;
}

.important-notice p {
  margin: 0;
}

.check-list {
  margin: 1.25rem 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  position: relative;
  margin: .7rem 0;
  padding-left: 1.8rem;
}

.check-list li::before {
  position: absolute;
  top: .05rem;
  left: 0;
  color: var(--brand-dark);
  content: "\2713";
  font-weight: 900;
}

.muted {
  color: var(--muted);
}

.results {
  margin-top: 2rem;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  background: var(--white);
}

.results__header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.results__header h3 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.25rem);
}

.result-summary {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: #fff8ea;
  border-left: 5px solid var(--accent);
  border-radius: 0 10px 10px 0;
}

.result-summary p {
  margin: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.metric {
  min-height: 150px;
  padding: 1.25rem;
  background: var(--surface);
  border-radius: 12px;
}

.metric__label,
.metric span:last-child {
  display: block;
  color: var(--muted);
  font-size: .86rem;
}

.metric__value {
  display: block;
  margin: .35rem 0;
  color: var(--brand-dark);
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  line-height: 1.1;
}

.weekly-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin: 1rem 0;
  padding: 1.4rem;
  color: var(--white);
  background: var(--brand-dark);
  border-radius: 12px;
}

.weekly-result .metric__label {
  color: var(--white);
  opacity: .82;
}

.weekly-result strong {
  display: block;
  margin-top: .25rem;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  line-height: 1.15;
}

.weekly-result p {
  max-width: 500px;
  margin: 0;
}

.chart-card {
  margin: 1.5rem 0;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.chart-card figcaption {
  display: flex;
  flex-direction: column;
  margin-bottom: .75rem;
}

.chart-card figcaption span {
  color: var(--muted);
  font-size: .9rem;
}

.chart-legend {
  display: flex;
  gap: 1.25rem;
  margin-bottom: .4rem;
  color: var(--muted);
  font-size: .8rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}

.legend-band,
.legend-point {
  display: inline-block;
  flex: none;
}

.legend-band {
  width: 24px;
  height: 9px;
  background: rgb(1 129 129 / 25%);
  border: 1px solid var(--brand);
}

.legend-point {
  width: 11px;
  height: 11px;
  background: var(--accent);
  border: 2px solid var(--black);
  border-radius: 50%;
}

#weight-chart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 280px;
}

.clinical-note {
  padding: 1.35rem;
  background: #f7f7f7;
  border-radius: 12px;
}

.clinical-note h3 {
  margin-top: 0;
  font-size: 1.2rem;
}

.clinical-note p:last-child {
  margin-bottom: 0;
}

.table-section {
  max-width: none;
  background: var(--surface);
}

.table-section > * {
  max-width: var(--max-width);
  margin-right: auto;
  margin-left: auto;
}

.table-wrapper {
  overflow-x: auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

caption {
  padding: 1rem;
  font-weight: 800;
  text-align: left;
}

th,
td {
  padding: 1rem;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--white);
  background: var(--brand-dark);
}

tbody tr:nth-child(even) {
  background: var(--surface);
}

.table-note {
  margin-top: 1rem;
  color: var(--muted);
  font-size: .9rem;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.content-grid article {
  padding: 1.4rem;
  background: var(--surface);
  border-top: 4px solid var(--brand);
  border-radius: 0 0 12px 12px;
}

.content-grid h3 {
  margin-top: 0;
  font-size: 1.14rem;
}

.content-grid p {
  margin-bottom: 0;
  color: var(--muted);
}

details {
  border-top: 1px solid var(--line);
}

details:last-child {
  border-bottom: 1px solid var(--line);
}

summary {
  padding: 1.15rem 2.5rem 1.15rem 0;
  color: var(--brand-dark);
  font-weight: 800;
}

details > p,
details > ul {
  max-width: 850px;
  margin-top: 0;
  padding-bottom: 1rem;
}

.source-list li {
  margin-bottom: .55rem;
}

.reassurance {
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  gap: clamp(2rem, 7vw, 6rem);
  align-items: center;
  max-width: none;
  padding-right: max(1.25rem, calc((100% - var(--max-width)) / 2));
  padding-left: max(1.25rem, calc((100% - var(--max-width)) / 2));
  color: var(--white);
  background: var(--brand-dark);
}

.reassurance p:last-child {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
}

.site-footer {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 2rem;
  padding: 3rem max(1.25rem, calc((100% - var(--max-width)) / 2));
  color: var(--white);
  background: var(--black);
}

.site-footer > div:first-child {
  max-width: 600px;
}

.brand--footer {
  color: var(--white);
}

.site-footer nav {
  display: flex;
  align-items: start;
  gap: 1rem;
}

.footer-link {
  padding: 0;
  color: var(--white);
  background: transparent;
  border: 0;
  text-decoration: underline;
  text-underline-offset: .2em;
}

.copyright {
  grid-column: 1 / -1;
  margin: 0;
  color: #b8c4c4;
  font-size: .85rem;
}

dialog {
  width: min(680px, calc(100% - 2rem));
  max-height: 85vh;
  padding: 0;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgb(0 0 0 / 35%);
}

dialog::backdrop {
  background: rgb(0 0 0 / 65%);
}

.dialog-content {
  padding: 1.5rem;
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-title {
  margin: 0;
  color: var(--black);
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.2;
}

.dialog-close {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--black);
  background: var(--surface);
  border: 0;
  border-radius: 50%;
  font-size: 1.8rem;
  line-height: 1;
}

.noscript {
  position: fixed;
  z-index: 100;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  padding: 1rem;
  color: var(--white);
  background: var(--danger);
  border-radius: 10px;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .site-header nav {
    display: none;
  }

  .calculator-layout,
  .content-grid,
  .reassurance {
    grid-template-columns: 1fr;
  }

  .before-result {
    position: static;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: auto;
  }

  .weekly-result {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 600px) {
  .hero__content {
    padding-top: 3.5rem;
    padding-bottom: 3.5rem;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .results__header {
    align-items: stretch;
    flex-direction: column;
  }

  .secondary-button {
    width: 100%;
  }

  .chart-card {
    margin-right: -.5rem;
    margin-left: -.5rem;
    padding: .75rem;
  }

  .site-footer {
    grid-template-columns: 1fr;
  }

  .site-footer nav {
    flex-direction: column;
  }

  .copyright {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (forced-colors: active) {
  .primary-button,
  .weekly-result,
  th {
    border: 2px solid ButtonText;
  }
}

@media print {
  .site-header,
  .primary-button,
  .secondary-button,
  .before-result,
  .site-footer,
  dialog {
    display: none !important;
  }

  .hero {
    color: var(--black);
    background: var(--white);
  }

  .section {
    padding: 1.5rem 0;
  }
}