:root {
  --ink: #171717;
  --muted: #66635c;
  --paper: #f7f4eb;
  --card: #fffef9;
  --line: #ded9cc;
  --yellow: #f2c500;
  --yellow-light: #fff2a8;
  --green: #24704a;
  --red: #b33a2f;
  --shadow: 0 20px 70px rgb(27 24 15 / 8%);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
svg { fill: currentColor; }

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 100;
  padding: 10px 14px;
  background: white;
  color: black;
  border-radius: 8px;
  transform: translateY(-180%);
}
.skip-link:focus { transform: translateY(0); }

.page-shell { width: min(1160px, calc(100% - 40px)); margin-inline: auto; }
.hero {
  position: relative;
  min-height: 630px;
  color: white;
  overflow: hidden;
  background: #111;
}
.hero__backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgb(12 12 11 / 98%) 0%, rgb(16 16 14 / 88%) 52%, rgb(16 16 14 / 72%) 100%),
    url("assets/fafi-une-oficial.jpg") center / cover;
  filter: saturate(.65);
}
.hero::after {
  content: "";
  position: absolute;
  right: -160px;
  top: 64px;
  width: 490px;
  height: 490px;
  border: 86px solid rgb(242 197 0 / 14%);
  border-radius: 50%;
}
.topbar {
  position: relative;
  z-index: 2;
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgb(255 255 255 / 18%);
}
.brand img { display: block; width: min(310px, 54vw); height: auto; }
.unofficial-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid rgb(255 255 255 / 38%);
  border-radius: 999px;
  font-size: .79rem;
  font-weight: 700;
  letter-spacing: .025em;
  background: rgb(0 0 0 / 25%);
  backdrop-filter: blur(8px);
}
.unofficial-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); }
.hero__content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, .65fr);
  align-items: end;
  gap: 88px;
  padding-block: 104px 98px;
}
.hero__copy { max-width: 700px; }
.eyebrow {
  margin: 0 0 14px;
  color: var(--yellow);
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.eyebrow--dark { color: #8d7100; }
h1, h2, p { margin-top: 0; }
h1 {
  max-width: 680px;
  margin-bottom: 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.25rem, 7vw, 6.5rem);
  line-height: .92;
  letter-spacing: -.055em;
}
.hero__lead { max-width: 650px; margin-bottom: 30px; color: #dedbd3; font-size: clamp(1.04rem, 2vw, 1.25rem); }
.primary-link {
  display: inline-flex;
  gap: 16px;
  align-items: center;
  color: var(--yellow);
  font-weight: 800;
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
}
.weight-card {
  padding: 26px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 18px;
  background: rgb(18 18 17 / 72%);
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px rgb(0 0 0 / 24%);
}
.weight-card__header { display: flex; justify-content: space-between; margin-bottom: 18px; font-size: .9rem; font-weight: 750; }
.weight-card__header span:last-child { color: var(--yellow); }
.weight-bar { display: flex; height: 9px; overflow: hidden; border-radius: 999px; background: #393936; }
.weight-bar__process { width: 60%; background: var(--yellow); }
.weight-bar__exam { width: 40%; background: #fff; }
.weight-card__legend { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; margin-top: 20px; }
.weight-card__legend p { margin: 0; display: grid; }
.weight-card__legend strong { font-family: Georgia, serif; font-size: 1.7rem; }
.weight-card__legend span { color: #aaa79f; font-size: .82rem; }

.main-content { padding-block: 0 96px; }
.intro-strip {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: -28px;
  padding: 16px 20px;
  border: 1px solid #e2d587;
  border-radius: 14px;
  background: #fff8cf;
  box-shadow: 0 14px 40px rgb(57 47 4 / 10%);
}
.intro-strip svg { flex: 0 0 auto; color: #786000; }
.intro-strip p { margin: 0; font-size: .9rem; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 76px 0 26px; }
.section-heading h2, .scale-section h2, .method-section h2 { margin: 0; font-family: Georgia, serif; font-size: clamp(2rem, 4.2vw, 3.3rem); line-height: 1; letter-spacing: -.035em; }
.text-button, .icon-button {
  border: 0;
  cursor: pointer;
  font-weight: 800;
}
.text-button { display: inline-flex; gap: 8px; align-items: center; padding: 10px; background: transparent; color: #49463f; }
.text-button:hover { color: #000; }

.calculator-grid { display: grid; grid-template-columns: 1.08fr .92fr; gap: 24px; align-items: start; }
.calculator-card {
  min-width: 0;
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.calculator-card--inverse { background: #1b1b19; color: white; border-color: #1b1b19; }
.card-heading { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; margin-bottom: 34px; }
.step-number { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: #5d4b00; background: var(--yellow); font-size: .8rem; font-weight: 900; }
.card-heading h2 { margin-bottom: 6px; font-family: Georgia, serif; font-size: clamp(1.6rem, 3vw, 2.25rem); line-height: 1.07; letter-spacing: -.025em; }
.card-heading p { margin: 0; color: var(--muted); font-size: .9rem; }
.calculator-card--inverse .card-heading p { color: #aaa79f; }
fieldset { min-width: 0; padding: 0; border: 0; margin: 0; }
legend { width: 100%; margin-bottom: 14px; color: #5e5a51; font-size: .76rem; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }
.calculator-card--inverse legend { color: #c8c3b8; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.score-field { display: grid; gap: 7px; align-content: start; min-width: 0; color: #34322d; font-size: .88rem; font-weight: 750; }
.calculator-card--inverse .score-field { color: #f0ede5; }
.input-wrap {
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid #d8d3c7;
  border-radius: 12px;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.input-wrap:focus-within { border-color: #967a00; box-shadow: 0 0 0 3px rgb(242 197 0 / 23%); }
.input-wrap input { width: 100%; min-width: 0; padding: 13px 4px 13px 14px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 1.05rem; font-weight: 760; }
.input-wrap input::placeholder { color: #a9a59d; }
.input-wrap > span { flex: 0 0 auto; padding: 0 13px 0 7px; color: #8a867c; font-size: .82rem; font-weight: 650; }
.has-error .input-wrap { border-color: var(--red); box-shadow: 0 0 0 3px rgb(179 58 47 / 12%); }
.field-error { min-height: 1.05em; color: var(--red); font-size: .75rem; font-weight: 650; }
.field-help { color: #aaa79f; font-size: .77rem; font-weight: 500; }
.exam-fieldset { margin-top: 22px; padding-top: 22px; border-top: 1px solid #e6e1d6; }
.score-field--wide { max-width: 250px; }
.linked-process {
  display: grid;
  gap: 5px;
  margin-bottom: 26px;
  padding: 18px 20px;
  border: 1px solid #474742;
  border-radius: 14px;
  background: #242421;
}
.linked-process > span { color: #c8c3b8; font-size: .76rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.linked-process > strong { color: var(--yellow); font-family: Georgia, serif; font-size: 2rem; line-height: 1.15; }
.linked-process > strong small { color: #a9a59d; font-family: inherit; font-size: .85rem; }
.linked-process p { margin: 2px 0 0; color: #aaa79f; font-size: .77rem; }

.result-panel { margin-top: 28px; padding: 24px; border-radius: 17px; background: #f0ede4; transition: background .2s; }
.result-panel.has-error { background: #fff0ed; }
.result-panel__top { display: flex; justify-content: space-between; gap: 20px; align-items: center; }
.result-label { display: block; margin-bottom: 3px; color: #69665e; font-size: .75rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.result-score { display: flex; align-items: baseline; gap: 7px; margin: 0; }
.result-score strong { font-family: Georgia, serif; font-size: clamp(2.5rem, 7vw, 4rem); line-height: 1; letter-spacing: -.05em; }
.result-score span { color: #79756c; font-weight: 700; }
.grade-badge { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; color: white; background: #51504d; }
.grade-badge span { margin-bottom: -8px; font-size: .67rem; font-weight: 800; text-transform: uppercase; }
.grade-badge strong { font-family: Georgia, serif; font-size: 2.3rem; line-height: 1; }
.grade-1 { background: #585754; }
.grade-2, .grade-3 { background: #8c6f00; }
.grade-4 { background: #356b4f; }
.grade-5 { background: #184f39; }
.result-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.result-breakdown p { display: grid; margin: 0; padding: 12px 14px; border: 1px solid #ddd7c9; border-radius: 10px; background: rgb(255 255 255 / 50%); }
.result-breakdown span { color: #77736a; font-size: .73rem; }
.progress-track { height: 6px; margin-top: 18px; overflow: hidden; border-radius: 999px; background: #dad5c8; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--yellow); transition: width .35s ease; }
.result-message { margin: 12px 0 0; color: #5f5b52; font-size: .84rem; }
.card-actions { display: flex; justify-content: flex-end; align-items: stretch; gap: 10px; margin-top: 16px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 46px; padding: 11px 14px; border: 1px solid #d6d0c2; border-radius: 11px; background: transparent; color: #4e4a42; }
.icon-button:hover { background: #f1eee5; }

.target-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.target-options label { position: relative; cursor: pointer; }
.target-options input { position: absolute; opacity: 0; pointer-events: none; }
.target-options span { display: grid; place-items: center; min-height: 72px; border: 1px solid #474742; border-radius: 11px; background: #242421; transition: border-color .18s, background .18s, color .18s; }
.target-options strong { font-family: Georgia, serif; font-size: 1.75rem; line-height: 1; }
.target-options small { color: #9c998f; font-size: .65rem; }
.target-options input:checked + span { color: #171717; border-color: var(--yellow); background: var(--yellow); }
.target-options input:checked + span small { color: #5d4c00; }
.target-options input:focus-visible + span { outline: 3px solid white; outline-offset: 3px; }
.inverse-result { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; margin-top: 28px; padding: 24px; border-radius: 16px; }
.inverse-result__icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; font-size: 1.3rem; font-weight: 900; }
.inverse-result .result-label { color: inherit; opacity: .7; }
.inverse-result p { margin: 0; }
.inverse-result #inverse-main { margin: 2px 0 4px; }
.inverse-result #inverse-main strong { font-family: Georgia, serif; font-size: clamp(1.7rem, 5vw, 2.6rem); line-height: 1; }
.inverse-result #inverse-main span { font-weight: 700; }
.inverse-result #inverse-explanation { font-size: .82rem; opacity: .75; }
.is-possible { color: #d7f8e5; background: #184a35; }
.is-possible .inverse-result__icon { color: #143f2e; background: #c5f2d7; }
.is-impossible, .is-invalid { color: #ffe3df; background: #5a2823; }
.is-impossible .inverse-result__icon, .is-invalid .inverse-result__icon { color: #5a2823; background: #ffd4ce; }
.formula-details { margin-top: 18px; border-top: 1px solid #3b3b37; }
.formula-details summary { padding: 18px 0 4px; cursor: pointer; color: #d0ccc3; font-size: .84rem; font-weight: 800; }
.formula-details div { margin-top: 12px; padding: 14px; border-radius: 10px; color: #ccc8be; background: #252522; font-size: .82rem; }
.formula-details p:last-child { margin-bottom: 0; }

.scale-section { display: grid; grid-template-columns: minmax(0, 1fr) minmax(390px, .9fr); gap: clamp(50px, 10vw, 120px); align-items: center; margin-top: 108px; }
.scale-copy > p:not(.eyebrow) { max-width: 560px; margin: 22px 0; color: var(--muted); }
.rounding-note { display: flex; gap: 12px; max-width: 600px; padding: 16px; border-left: 4px solid var(--yellow); background: #eee9dc; }
.rounding-note svg { flex: 0 0 auto; margin-top: 2px; color: #826900; }
.rounding-note p { margin: 0; font-size: .83rem; }
.grade-scale { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.grade-row { display: grid; grid-template-columns: 70px 1fr; align-items: center; min-height: 78px; padding: 12px 22px; border-bottom: 1px solid #e7e2d7; }
.grade-row:last-child { border-bottom: 0; }
.grade-row > strong { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: white; background: #565551; font-family: Georgia, serif; font-size: 1.35rem; }
.grade-row span { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.grade-row b { font-size: .94rem; }
.grade-row small { color: #77736a; font-size: .78rem; }
.grade-row--2 > strong, .grade-row--3 > strong { background: #8c6f00; }
.grade-row--4 > strong { background: #356b4f; }
.grade-row--5 > strong { background: #184f39; }

.method-section { margin-top: 110px; padding-top: 62px; border-top: 1px solid var(--line); }
.method-section > div { margin-bottom: 34px; }
.method-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; margin: 0; padding: 0; list-style: none; }
.method-list li { min-width: 0; }
.method-list li > span { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 18px; border-radius: 50%; color: #5c4c00; background: var(--yellow); font-weight: 900; }
.method-list p { display: grid; gap: 7px; margin: 0; }
.method-list small { color: var(--muted); font-size: .83rem; }

footer { padding: 46px 0; color: #d4d0c7; background: #171716; }
.footer-grid { display: grid; grid-template-columns: 1.1fr 1.2fr .75fr; gap: 50px; align-items: start; }
.footer-brand { display: flex; gap: 16px; align-items: center; }
.footer-brand img { width: 56px; height: auto; }
.footer-brand p, .disclaimer p { margin: 5px 0 0; color: #97948c; font-size: .78rem; }
.footer-brand .author-credit { margin-top: 8px; }
.author-credit span { color: #f0ede5; font-weight: 750; }
.disclaimer strong, .source-links strong { display: block; margin-bottom: 8px; color: #f0ede5; font-size: .83rem; }
.source-links { display: grid; gap: 6px; }
.source-links a { color: #c9b95f; font-size: .78rem; text-underline-offset: 3px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 999px; color: white; background: #111; box-shadow: 0 8px 30px rgb(0 0 0 / 25%); font-size: .86rem; font-weight: 750; opacity: 0; transform: translate(-50%, 20px); pointer-events: none; transition: .2s; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

@media (max-width: 920px) {
  .hero__content { grid-template-columns: 1fr; gap: 42px; padding-block: 78px 72px; }
  .weight-card { max-width: 520px; }
  .calculator-grid { grid-template-columns: 1fr; }
  .scale-section { grid-template-columns: 1fr; gap: 36px; }
  .method-list { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .source-links { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .page-shell { width: min(100% - 24px, 1160px); }
  .hero { min-height: auto; }
  .topbar { min-height: 88px; align-items: center; }
  .brand img { width: 210px; }
  .unofficial-pill { max-width: 130px; border: 0; padding: 0; background: transparent; font-size: .66rem; }
  .hero__content { padding-block: 64px 72px; }
  h1 { font-size: clamp(3.25rem, 17vw, 4.8rem); }
  .intro-strip { align-items: flex-start; }
  .section-heading { align-items: flex-start; flex-direction: column; margin-top: 58px; }
  .calculator-card { border-radius: 18px; }
  .field-grid { grid-template-columns: 1fr; }
  .score-field--wide { max-width: none; }
  .card-actions { flex-direction: column; }
  .icon-button { width: 100%; }
  .target-options { grid-template-columns: 1fr 1fr; }
  .scale-section, .method-section { margin-top: 78px; }
  .grade-row { grid-template-columns: 56px 1fr; padding-inline: 16px; }
  .grade-row span { display: grid; gap: 2px; }
  .method-list { grid-template-columns: 1fr; }
  .method-list li { display: grid; grid-template-columns: auto 1fr; gap: 14px; }
  .method-list li > span { margin: 0; }
  .footer-grid { grid-template-columns: 1fr; gap: 30px; }
  .source-links { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
