:root {
  --bg-1: #f6f2ea;
  --bg-2: #eadccc;
  --ink: #1f2724;
  --muted: #42524b;
  --card: rgba(255, 255, 255, 0.92);
  --panel: #ffffff;
  --panel-soft: rgba(255, 255, 255, 0.82);
  --surface: #ffffff;
  --stroke: #d9cdbf;
  --accent: #0f6a5f;
  --accent-2: #c07a2f;
  --glow-1: rgba(255, 255, 255, 0.85);
  --glow-2: rgba(192, 122, 47, 0.22);
  --addon-bg: rgba(234, 220, 204, 0.45);
  --gauge-red: #c4533f;
  --gauge-yellow: #d1a236;
  --gauge-track: rgba(74, 90, 82, 0.2);
  --shadow: 0 30px 70px rgba(31, 39, 36, 0.16);
  --radius: 24px;
  --space-xs: 8px;
  --space-s: 12px;
  --space-m: 20px;
  --space-l: 32px;
  --space-xl: 48px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Gill Sans", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(
      circle at 12% 20%,
      var(--glow-1) 0,
      rgba(255, 255, 255, 0) 55%
    ),
    radial-gradient(
      circle at 88% 0%,
      var(--glow-2) 0,
      rgba(192, 122, 47, 0) 52%
    ),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
}

h1,
h2 {
  font-family: "Fraunces", "Georgia", serif;
  margin: 0;
}

p {
  margin: 0;
  line-height: 1.6;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  --page-pad-x: var(--space-m);
  --page-pad-top: var(--space-l);
  padding: var(--page-pad-top) var(--page-pad-x) 80px;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  position: relative;
}

.hero {
  max-width: 720px;
  display: grid;
  gap: var(--space-s);
  animation: rise 0.8s ease both;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.brand-icon {
  width: 28px;
  height: 28px;
  display: block;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.72rem;
  color: var(--muted);
}

.hero h1 {
  font-size: clamp(2.2rem, 4vw, 3.6rem);
}

.rotating-word {
  display: inline-block;
  color: var(--accent);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
}

.rotating-word.is-fading {
  opacity: 0;
  transform: translateY(0.12em);
}

[data-theme="dark"] .rotating-word {
  color: var(--accent-2);
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease,
    border-color 0.2s ease;
  box-shadow: 0 12px 24px rgba(31, 39, 36, 0.12);
}

.theme-toggle--floating {
  position: absolute;
  top: var(--page-pad-top);
  right: var(--page-pad-x);
  z-index: 5;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(31, 39, 36, 0.16);
}

.theme-toggle:focus-visible {
  outline: 3px solid rgba(15, 106, 95, 0.25);
  outline-offset: 3px;
}

.theme-icon {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.theme-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-icon-moon svg {
  stroke: none;
  fill: currentColor;
}

.theme-icon-moon {
  opacity: 0;
  transform: translateY(4px);
}

.theme-icon-sun {
  opacity: 1;
  transform: translateY(0);
}

.lead {
  font-size: 1.05rem;
  color: var(--muted);
}

.summary {
  font-size: 0.98rem;
  color: var(--muted);
  max-width: 640px;
}

.main {
  display: grid;
  gap: var(--space-xl);
}

.section-divider {
  width: 100%;
  height: 72px;
  margin: -8px 0 0;
}

.section-divider svg {
  width: 100%;
  height: 100%;
  display: block;
}

.section-divider path {
  fill: rgba(255, 255, 255, 0.7);
}

.calculator {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  padding: var(--space-l);
  box-shadow: var(--shadow);
  display: grid;
  gap: var(--space-l);
  grid-template-areas:
    "inputs"
    "helper"
    "result"
    "diagnosis"
    "cta";
  animation: rise 0.9s ease both;
  animation-delay: 0.05s;
}

.inputs {
  display: grid;
  gap: var(--space-m);
  grid-area: inputs;
}

.inputs h2 {
  font-size: 1.5rem;
}

.inputs-grid {
  display: grid;
  gap: var(--space-m);
}

.field label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--surface);
  font-size: 1rem;
  color: var(--ink);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.field input::placeholder {
  color: #a99986;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 106, 95, 0.2);
}

.input-group {
  display: flex;
  align-items: stretch;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--surface);
  overflow: hidden;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.input-group input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--ink);
}

.input-group .addon {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 0.92rem;
  color: var(--muted);
  background: var(--addon-bg);
}

.input-group .addon.prefix {
  border-right: 1px solid var(--stroke);
}

.input-group .addon.suffix {
  border-left: 1px solid var(--stroke);
}

.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 106, 95, 0.2);
}

.input-group input:focus {
  outline: none;
  box-shadow: none;
}

.field .helper {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  opacity: 0.85;
  line-height: 1.45;
}

.result {
  display: grid;
  gap: var(--space-s);
  padding-top: var(--space-m);
  border-top: 1px dashed rgba(74, 90, 82, 0.25);
  grid-area: result;
}

.result h2 {
  font-size: 1.4rem;
}

.result-helper {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  opacity: 0.85;
  grid-area: helper;
  align-self: center;
}

.result-value {
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
}

.result-value .value {
  font-family: "Fraunces", "Georgia", serif;
  font-size: clamp(2.6rem, 6vw, 4rem);
  color: var(--accent);
  transition: opacity 0.25s ease;
}

.result-value .unit {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  color: var(--muted);
}

.gauge {
  margin-top: var(--space-xs);
  display: flex;
  justify-content: center;
  position: relative;
}

.gauge svg {
  width: min(100%, 320px);
  height: auto;
}

.gauge-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 18px;
  pointer-events: none;
}

.gauge-overlay .result-value {
  justify-content: center;
}

.gauge-track,
.gauge-fill {
  fill: none;
  stroke-width: 14;
  stroke-linecap: round;
}

.gauge-track {
  stroke: var(--gauge-track);
}

.gauge-fill {
  transition:
    stroke-dasharray 0.6s ease,
    stroke 0.2s ease;
}

.gauge-tick {
  stroke: rgba(74, 90, 82, 0.35);
  stroke-width: 2;
  stroke-linecap: round;
}

.diagnosis {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--stroke);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  grid-area: diagnosis;
  transition:
    color 0.2s ease,
    border-color 0.2s ease,
    background-color 0.2s ease;
}

.cta-row {
  grid-area: cta;
  display: flex;
  justify-content: flex-start;
}

.cta-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
  box-shadow: 0 16px 32px rgba(15, 106, 95, 0.2);
}

.cta-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 36px rgba(15, 106, 95, 0.25);
}

.cta-button:focus-visible {
  outline: 3px solid rgba(15, 106, 95, 0.25);
  outline-offset: 3px;
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-l) var(--space-m);
  background: rgba(16, 20, 18, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
  overflow-y: auto;
}

.modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-overlay {
  position: absolute;
  inset: 0;
}

.modal-dialog {
  position: relative;
  width: min(100%, 560px);
  background: var(--panel);
  border-radius: 20px;
  padding: 28px;
  border: 1px solid var(--stroke);
  box-shadow: 0 30px 70px rgba(18, 24, 21, 0.2);
  display: grid;
  gap: var(--space-m);
  margin: var(--space-l) 0;
}

.modal-dialog h2 {
  margin: 0;
  font-size: 1.6rem;
}

.modal-lead {
  color: var(--muted);
  margin: 0;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: rgba(15, 106, 95, 0.08);
  color: var(--accent);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-close:focus-visible {
  outline: 2px solid rgba(15, 106, 95, 0.25);
  outline-offset: 2px;
}

.modal-form {
  display: grid;
  gap: var(--space-s);
}

.form-grid {
  display: grid;
  gap: var(--space-s);
}

.field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--surface);
  font-size: 1rem;
  color: var(--ink);
  resize: vertical;
  min-height: 120px;
}

.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 106, 95, 0.2);
}

.form-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.form-error {
  margin: 0;
  font-size: 0.88rem;
  color: var(--gauge-red);
  min-height: 1.1em;
}

.form-success {
  margin: 0;
  font-size: 0.88rem;
  color: var(--accent);
  min-height: 1.1em;
}

.form-hidden {
  position: absolute;
  left: -9999px;
}

.column-divider {
  display: none;
}

.calculator.is-low .diagnosis {
  color: var(--gauge-red);
  border-color: rgba(196, 83, 63, 0.35);
}

.calculator.is-mid .diagnosis {
  color: #8a6a14;
  border-color: rgba(209, 162, 54, 0.35);
}

.calculator.is-high .diagnosis {
  color: #2f7d5c;
  border-color: rgba(15, 106, 95, 0.3);
}

.calculator.is-calculating .value {
  opacity: 0.6;
}

.calculator.is-invalid .value {
  color: var(--muted);
}

.calculator.is-invalid .gauge-fill,
.calculator.is-invalid .gauge-tick {
  opacity: 0;
}

.principles {
  display: grid;
  gap: var(--space-s);
  max-width: 680px;
  animation: rise 0.9s ease both;
  animation-delay: 0.12s;
}

.principles h2 {
  font-size: 1.4rem;
}

.principles ul {
  display: grid;
  gap: 10px;
  margin-top: var(--space-xs);
}

.principles li {
  padding-left: 18px;
  position: relative;
  color: var(--muted);
}

.principles li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent-2);
}

.faq {
  display: grid;
  gap: var(--space-m);
  max-width: 860px;
  animation: rise 0.9s ease both;
  animation-delay: 0.18s;
}

.faq h2 {
  font-size: 1.4rem;
}

.faq-list {
  display: grid;
  gap: var(--space-s);
}

.faq-item {
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: var(--card);
}

.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  color: var(--muted);
  font-weight: 600;
}

.faq-item[open] summary::after {
  content: "-";
}

.faq-item summary:focus-visible {
  outline: 2px solid rgba(15, 106, 95, 0.35);
  outline-offset: 4px;
  border-radius: 12px;
}

.faq-content {
  padding: 0 16px 14px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.faq-content p {
  margin: 0;
}

.faq-content p + p {
  margin-top: 10px;
}

.footer {
  border-top: 1px solid rgba(74, 90, 82, 0.18);
  padding-top: var(--space-l);
  display: grid;
  gap: var(--space-m);
  color: var(--muted);
}

.footer-content {
  display: grid;
  gap: var(--space-m);
}

.footer-name {
  font-family: "Fraunces", "Georgia", serif;
  font-size: 1.2rem;
  color: var(--ink);
}

.footer-legal,
.footer-location {
  margin: 6px 0 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.footer-title {
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: var(--space-xs);
}

.footer-nav ul {
  display: grid;
  gap: 8px;
}

.footer-nav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.footer-nav a:hover {
  color: var(--accent);
}

.footer-cta .cta-button {
  padding: 10px 20px;
  font-size: 0.95rem;
}

.footer-bottom {
  font-size: 0.85rem;
  color: var(--muted);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 600px) {
  .page {
    --page-pad-x: var(--space-l);
    --page-pad-top: var(--space-xl);
    padding: var(--page-pad-top) var(--page-pad-x) 96px;
  }

  .inputs-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-2 {
    grid-column: 1 / -1;
  }

  .result {
    gap: var(--space-m);
  }
}

@media (min-width: 960px) {
  .page {
    --page-pad-x: 48px;
    --page-pad-top: 56px;
    padding: var(--page-pad-top) var(--page-pad-x) 120px;
  }

  .main {
    gap: 64px;
  }

  .hero h1 {
    font-size: clamp(2.6rem, 3.4vw, 4rem);
  }

  .calculator {
    padding: 40px;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    grid-template-areas:
      "inputs result"
      "helper diagnosis"
      ". cta";
    align-items: start;
  }

  .inputs {
    max-width: 520px;
  }

  .result {
    padding-top: 0;
    border-top: 0;
    border-left: 0;
    padding-left: var(--space-l);
  }

  .column-divider {
    display: block;
    grid-column: 2;
    grid-row: 1 / -1;
    justify-self: start;
    align-self: stretch;
    width: 0;
    border-left: 1px dashed rgba(74, 90, 82, 0.25);
    pointer-events: none;
  }

  .diagnosis {
    margin-left: var(--space-l);
  }

  .cta-row {
    margin-left: var(--space-l);
  }

  .gauge svg {
    width: min(100%, 380px);
  }

  .footer-content {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr) minmax(0, 0.9fr);
    align-items: start;
  }

  .footer-cta {
    justify-self: end;
    text-align: right;
  }
}

/* ====== Typography scale (override) ====== */
body {
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hero h1 {
  letter-spacing: -0.02em;
}

.lead {
  font-size: clamp(1.08rem, 1.2vw, 1.22rem);
  line-height: 1.55;
}

.summary {
  font-size: 1.02rem;
  line-height: 1.7;
  max-width: 60ch;
}

.eyebrow {
  font-size: 0.82rem;
  letter-spacing: 0.22em;
}

.field label {
  font-size: 0.98rem;
}

.field .helper,
.result-helper,
.form-hint {
  font-size: 0.92rem;
  line-height: 1.55;
}

.faq-content {
  font-size: 1.02rem;
  line-height: 1.7;
}

.result h2,
.principles h2,
.faq h2 {
  font-size: 1.55rem;
}

@media (min-height: 760px) {
  .modal {
    align-items: center;
  }

  .modal-dialog {
    margin: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

[data-theme="dark"] {
  --bg-1: #0f1412;
  --bg-2: #0b0f0e;
  --ink: #eef3ef;
  --muted: #a3b3ac;
  --card: rgba(20, 24, 22, 0.92);
  --panel: #141a17;
  --panel-soft: rgba(20, 24, 22, 0.85);
  --surface: #101513;
  --stroke: #2b3631;
  --accent: #4ec3ad;
  --accent-2: #d2954d;
  --glow-1: rgba(78, 195, 173, 0.18);
  --glow-2: rgba(210, 149, 77, 0.12);
  --addon-bg: rgba(35, 46, 41, 0.6);
  --gauge-track: rgba(255, 255, 255, 0.18);
  --shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .theme-icon-moon {
  opacity: 1;
  transform: translateY(0);
}

[data-theme="dark"] .theme-icon-sun {
  opacity: 0;
  transform: translateY(-4px);
}
