/* Ideal body weight calculator — form rows + results + prose fixes */

/* Hero spacing: shared .hero--ibw rules in styles.css */

.hero.hero--ibw .hero-stack {
  align-items: stretch;
  width: 100%;
}

.hero.hero--ibw .hero-copy {
  width: 100%;
  max-width: none;
  margin-inline: auto;
  text-align: center;
  align-self: stretch;
}

.hero.hero--ibw .hero-copy .h1-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.06em;
  line-height: 1.08;
  font-size: clamp(1.65rem, 5vw, 2.55rem);
  margin-inline: auto;
  width: 100%;
  color: #fff;
}

.hero.hero--ibw .hero-copy .h1-line {
  display: block;
  text-align: center;
  width: 100%;
}

.hero.hero--ibw h1 {
  color: #fff !important;
}

.hero.hero--ibw .hero-lead {
  text-align: center;
  margin-inline: auto;
  max-width: 62ch;
}

.prose--ibw .quick-answer {
  text-align: left;
}

.prose--ibw .quick-answer h2 {
  text-align: left;
  margin-top: 0;
}

.prose--ibw .quick-answer p {
  text-align: left;
  max-width: none;
  margin-inline: 0;
}

.ibw-form-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
}

.ibw-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.95fr) minmax(180px, 1.15fr);
  gap: 1rem 1.25rem;
  align-items: start;
  padding: 1.05rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ibw-row:last-of-type {
  border-bottom: none;
  padding-bottom: 0.35rem;
}

.ibw-row-label {
  min-width: 0;
  min-height: 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  text-align: left;
}

.ibw-row-label .field-label {
  text-align: left;
  width: 100%;
}

.ibw-row-label .field-note {
  text-align: left;
  width: 100%;
}

.ibw-control-box {
  min-height: 3.25rem;
  display: flex;
  align-items: stretch;
  width: 100%;
}

.ibw-control-box > .ibw-unit-shell,
.ibw-control-box > .seg--ibw {
  flex: 1 1 auto;
  width: 100%;
}

.ibw-row .seg--ibw {
  padding: 4px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.045);
  min-height: 3.25rem;
  align-items: center;
}

.ibw-row .seg--ibw label {
  min-height: 2.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ibw-row-label .field-label {
  margin-bottom: 0.2rem;
}

.ibw-row-label .field-note {
  margin-top: 0.25rem;
}

.ibw-row-control {
  min-width: 0;
}

.ibw-unit-shell {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.045);
  overflow: hidden;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  min-height: 3.25rem;
}

.ibw-unit-shell:focus-within {
  border-color: var(--teal-400);
  box-shadow: 0 0 0 4px rgba(53, 224, 196, 0.15);
}

.ibw-unit-shell input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #fff;
  padding: 0.82rem 0.95rem;
  font-size: 0.99rem;
  font-weight: 550;
  font-family: inherit;
  min-height: 3.25rem;
}

.ibw-unit-shell input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.ibw-unit-shell input[type="number"]::-webkit-inner-spin-button,
.ibw-unit-shell input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
  height: 1.75rem;
}

.ibw-unit-shell input:focus {
  outline: none;
}

.ibw-unit-shell input::placeholder {
  color: #7f97ac;
  font-weight: 500;
}

.ibw-unit-meta {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0 0.35rem 0 0.15rem;
  flex-shrink: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.12);
}

.ibw-unit-meta .unit-chip {
  min-width: 2.1rem;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 650;
  color: #c5d7e6;
}

.ibw-unit-swap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #9fb6c9;
  cursor: pointer;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

.ibw-unit-swap:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.ibw-unit-swap:focus-visible {
  outline: 3px solid var(--teal-400);
  outline-offset: 1px;
}

.ibw-unit-swap svg {
  width: 16px;
  height: 16px;
}

/* Results live inside the dark calc card — always use light text */
.results--ibw {
  margin-top: 1.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.ibw-result-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.ibw-result-hero .field-note {
  color: #9fb6c9;
}

.ibw-result-hero .ibw-big {
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff !important;
  line-height: 1.1;
}

.ibw-result-hero .ibw-sub {
  color: #d7e6f2 !important;
  font-size: 0.95rem;
  margin-top: 0.35rem;
}

.ibw-gauge {
  width: 100%;
  max-width: 280px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.ibw-gauge > i {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal-400), var(--gold-400));
  transition: width 0.35s var(--ease);
}

.results--ibw .fwd-metric {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
}

.results--ibw .fwd-metric span {
  color: #9fb6c9;
}

.results--ibw .fwd-metric b {
  color: #fff !important;
}

.ibw-formula-chip {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.5;
  color: #ffffff !important;
  background: rgba(60, 147, 255, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.35);
  border-radius: 12px;
  padding: 0.8rem 0.95rem;
  margin: 0.75rem 0 1rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.results--ibw > .field-note {
  color: #9fb6c9;
}

.ibw-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin: 0.85rem 0;
  list-style: none;
  padding: 0;
}

.ibw-compare li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.88rem;
}

.ibw-compare li span {
  color: #b7c9d8;
}

.ibw-compare li b {
  color: #fff !important;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.ibw-compare li.is-primary {
  border-color: rgba(53, 224, 196, 0.45);
  background: rgba(53, 224, 196, 0.12);
}

.ibw-adj-block {
  margin-top: 0.85rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(249, 115, 22, 0.4);
  background: rgba(249, 115, 22, 0.12);
}

.ibw-adj-block h3 {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  color: #fff !important;
}

.ibw-adj-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 1rem;
}

.ibw-adj-metrics div span {
  display: block;
  font-size: 0.75rem;
  color: #d4b8a4;
  margin-bottom: 0.15rem;
}

.ibw-adj-metrics div b {
  color: #fff !important;
  font-size: 1.05rem;
  font-weight: 650;
}

.ibw-tip {
  margin: 0.75rem 0 0;
  font-size: 0.86rem;
  color: #e8d5c8 !important;
  line-height: 1.5;
}

.ibw-note-soft {
  margin: 0.75rem 0 0;
  font-size: 0.86rem;
  color: #9fb6c9;
}

/* Light theme: inputs on dark calc card stay readable */
html:not([data-theme="dark"]) .ibw-unit-shell {
  background: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

html:not([data-theme="dark"]) .ibw-unit-shell input {
  color: #0f172a;
}

html:not([data-theme="dark"]) .ibw-unit-shell input::placeholder {
  color: #94a3b8;
}

html:not([data-theme="dark"]) .ibw-unit-meta {
  background: rgba(15, 23, 42, 0.04);
  border-left-color: rgba(15, 23, 42, 0.1);
}

html:not([data-theme="dark"]) .ibw-unit-meta .unit-chip {
  color: #334155;
}

html:not([data-theme="dark"]) .ibw-unit-swap {
  color: #64748b;
}

html:not([data-theme="dark"]) .ibw-unit-swap:hover {
  color: #0f172a;
  background: rgba(15, 23, 42, 0.06);
}

html:not([data-theme="dark"]) .ibw-row {
  border-bottom-color: rgba(255, 255, 255, 0.14);
}

/* Prose: shorter headings + readable formula boxes + table */
.prose--ibw h2 {
  font-size: clamp(1.2rem, 2.6vw, 1.45rem);
  margin-top: 2.2rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.prose--ibw .quick-answer h2 {
  font-size: clamp(1.15rem, 2.5vw, 1.35rem);
}

.prose--ibw h3 {
  font-size: 1.05rem;
}

.prose--ibw .formula-viz {
  overflow-x: visible;
  background: #101b29;
  border: 1px solid #2a4057;
  box-shadow: none;
}

.prose--ibw .formula-viz .fv-title {
  color: #62b6ff;
  margin-bottom: 0.65rem;
}

.prose--ibw .fv-equation {
  display: block;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: #eaf2f8 !important;
  font-size: 0.92rem;
  line-height: 1.7;
}

.prose--ibw .fv-equation span {
  display: block;
  color: #eaf2f8 !important;
}

.prose--ibw .fv-equation b,
.prose--ibw .fv-equation sub {
  color: #ffffff !important;
}

html:not([data-theme="dark"]) .prose--ibw .formula-viz {
  background: #ffffff;
  border: 1px solid #e3eaf0;
  box-shadow: var(--shadow-sm);
}

html:not([data-theme="dark"]) .prose--ibw .formula-viz .fv-title {
  color: #1f63b8;
}

html:not([data-theme="dark"]) .prose--ibw .fv-equation,
html:not([data-theme="dark"]) .prose--ibw .fv-equation span,
html:not([data-theme="dark"]) .prose--ibw .fv-equation b,
html:not([data-theme="dark"]) .prose--ibw .fv-equation sub {
  color: #0b1622 !important;
}

.prose--ibw .table-wrap {
  margin-block: 1.25rem;
}

.prose--ibw .data-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
}

.prose--ibw .data-table th,
.prose--ibw .data-table td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  color: var(--text-900);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.prose--ibw .data-table thead th {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-700);
  font-weight: 700;
  background: var(--paper-tint);
}

html[data-theme="dark"] .prose--ibw .data-table thead th {
  color: #c3d5e4;
  background: #142335;
}

html[data-theme="dark"] .prose--ibw .data-table td {
  color: #eaf2f8;
}

.prose--ibw .data-table tbody tr:last-child td {
  border-bottom: 0;
}

html:not([data-theme="dark"]) .ibw-row .seg--ibw {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.14);
}

html:not([data-theme="dark"]) .hero.hero--ibw .hero-copy .h1-stack {
  color: #fff;
}

@media (max-width: 640px) {
  .hero.hero--ibw .hero-copy .h1-stack {
    font-size: clamp(1.35rem, 6.2vw, 1.75rem);
  }

  .hero.hero--ibw .hero-lead {
    font-size: 0.92rem;
    line-height: 1.48;
    max-width: 36ch;
  }

  .ibw-row-label {
    min-height: 0;
    align-items: flex-start;
    text-align: left;
  }

  .ibw-row-label .field-label,
  .ibw-row-label .field-note {
    text-align: left;
  }

  .ibw-row {
    grid-template-columns: 1fr;
    gap: 0.55rem;
    padding: 0.95rem 0;
  }

  .ibw-compare {
    grid-template-columns: 1fr;
  }

  .ibw-adj-metrics {
    grid-template-columns: 1fr;
  }

  .ibw-result-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .ibw-gauge {
    max-width: 100%;
  }

  .prose--ibw .data-table th,
  .prose--ibw .data-table td {
    white-space: normal;
    font-size: 0.86rem;
    padding: 0.6rem 0.65rem;
  }
}
