:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --panel: #fffdf9;
  --ink: #1c2520;
  --muted: #66736c;
  --line: #ded8ce;
  --accent: #0f7b6c;
  --accent-dark: #095e53;
  --accent-soft: #dff3ee;
  --warm: #f4b860;
  --danger: #ba3b46;
  --shadow: 0 24px 70px rgba(36, 43, 38, 0.12);
  --page-bg:
    radial-gradient(circle at top left, rgba(15, 123, 108, 0.14), transparent 34rem),
    linear-gradient(135deg, #f9f7f2 0%, var(--bg) 48%, #eef5f1 100%);
  --header-bg: rgba(255, 253, 249, 0.7);
  --header-border: rgba(222, 216, 206, 0.86);
  --active-text: #fff;
  --primary-text: #fff;
  --surface: rgba(255, 253, 249, 0.86);
  --surface-soft: rgba(255, 253, 249, 0.82);
  --surface-strong: #fff;
  --surface-muted: #f4f0e8;
  --field-bg: #fff;
  --feature-bg:
    linear-gradient(145deg, #ecfaf6, #fffdf9 68%),
    radial-gradient(circle at top right, rgba(244, 184, 96, 0.26), transparent 16rem);
  --preview-featured-bg:
    linear-gradient(160deg, #ecfaf6, #fffdf9 72%),
    radial-gradient(circle at top right, rgba(244, 184, 96, 0.3), transparent 18rem);
  --callout-bg: #fff6e4;
  --clear-bg: #ece6dc;
  --clear-hover-bg: #e2d9cc;
  --save-hover-bg: #cbe9e2;
  --result-featured-bg: linear-gradient(180deg, #effaf6, #fff);
  --pill-bg: #fff3d8;
  --pill-text: #82510d;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090f0d;
  --panel: #111a17;
  --ink: #f2f7f4;
  --muted: #9aaaa4;
  --line: #2a3833;
  --accent: #21c7a8;
  --accent-dark: #65e2ce;
  --accent-soft: #173f38;
  --danger: #ff7a86;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  --page-bg:
    radial-gradient(circle at top left, rgba(33, 199, 168, 0.16), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(244, 184, 96, 0.08), transparent 30rem),
    linear-gradient(135deg, #050807 0%, var(--bg) 55%, #0e1714 100%);
  --header-bg: rgba(17, 26, 23, 0.78);
  --header-border: rgba(255, 255, 255, 0.1);
  --active-text: #08100d;
  --primary-text: #05100d;
  --surface: rgba(17, 26, 23, 0.86);
  --surface-soft: rgba(17, 26, 23, 0.82);
  --surface-strong: #0f1815;
  --surface-muted: #0c1411;
  --field-bg: #0c1411;
  --feature-bg:
    linear-gradient(145deg, rgba(23, 63, 56, 0.96), rgba(17, 26, 23, 0.94) 68%),
    radial-gradient(circle at top right, rgba(244, 184, 96, 0.16), transparent 16rem);
  --preview-featured-bg:
    linear-gradient(160deg, rgba(23, 63, 56, 0.95), rgba(17, 26, 23, 0.96) 72%),
    radial-gradient(circle at top right, rgba(244, 184, 96, 0.18), transparent 18rem);
  --callout-bg: rgba(244, 184, 96, 0.12);
  --clear-bg: #26332f;
  --clear-hover-bg: #33433e;
  --save-hover-bg: #20534a;
  --result-featured-bg: linear-gradient(180deg, rgba(23, 63, 56, 0.86), #0f1815);
  --pill-bg: rgba(244, 184, 96, 0.16);
  --pill-text: #ffd88f;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--page-bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 0;
}

.brand,
.site-header a,
.primary-link,
.secondary-link {
  text-decoration: none;
}

.brand {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 950;
}

.site-header nav {
  display: flex;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--header-border);
  border-radius: 999px;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
}

.site-header nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
}

.site-header nav a.active,
.site-header nav a:hover {
  background: var(--ink);
  color: var(--active-text);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid var(--header-border);
  border-radius: 50%;
  background: var(--header-bg);
  color: var(--ink);
  box-shadow: 0 12px 30px rgba(36, 43, 38, 0.1);
  backdrop-filter: blur(14px);
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle-icon {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 18%, transparent);
}

.theme-toggle-icon::before {
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background: var(--header-bg);
  content: "";
  opacity: 0;
  transform: translate(8px, -8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

:root[data-theme="dark"] .theme-toggle-icon::before {
  opacity: 1;
  transform: translate(5px, -5px);
}

.page {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 28px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0;
}

.calculator-page {
  padding-top: 44px;
}

.home-page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 70px 0 56px;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(320px, 1.08fr) minmax(300px, 0.92fr);
  align-items: center;
  gap: 42px;
  min-height: 560px;
}

.home-copy h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(3.6rem, 7vw, 6.7rem);
  line-height: 0.9;
}

.home-copy p:not(.eyebrow) {
  max-width: 40rem;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.75;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 20px;
  border-radius: 999px;
  font-weight: 950;
}

.primary-link {
  background: var(--accent);
  color: var(--primary-text);
  box-shadow: 0 16px 28px rgba(15, 123, 108, 0.22);
}

.primary-link:hover {
  background: var(--accent-dark);
}

.secondary-link {
  border: 1px solid var(--line);
  background: var(--header-bg);
  color: var(--ink);
}

.secondary-link:hover {
  background: var(--surface-strong);
}

.home-panel {
  display: grid;
  gap: 14px;
  width: 100%;
  min-width: 0;
}

.home-photo {
  position: relative;
  width: 100%;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  border: 1px solid rgba(222, 216, 206, 0.92);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.home-photo::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, transparent 62%, rgba(28, 37, 32, 0.16));
  pointer-events: none;
}

.home-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.preview-card {
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 140px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(36, 43, 38, 0.09);
}

.preview-card.featured {
  min-height: 220px;
  align-content: center;
  border-color: rgba(15, 123, 108, 0.28);
  background: var(--preview-featured-bg);
}

.preview-card span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 900;
  text-transform: uppercase;
}

.preview-card small {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 850;
}

.preview-icon {
  display: grid;
  place-items: center;
  width: min(100%, 126px);
  aspect-ratio: 1;
  margin-top: 8px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, var(--surface-strong), var(--accent-soft)),
    linear-gradient(135deg, rgba(15, 123, 108, 0.16), rgba(244, 184, 96, 0.24));
  color: var(--accent-dark);
}

.featured .preview-icon {
  width: min(100%, 154px);
}

.preview-icon svg {
  width: 68%;
  height: 68%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4.5;
}

.feature-section {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.feature-section article {
  min-height: 220px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface-soft);
}

.feature-number {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 950;
}

.feature-section h2 {
  margin: 42px 0 10px;
  font-size: 1.35rem;
}

.feature-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.blog-page,
.about-page,
.article-page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 62px 0 56px;
}

.blog-hero,
.about-hero {
  max-width: 780px;
}

.blog-hero h1,
.about-hero h1 {
  margin: 0;
  font-size: clamp(3rem, 7vw, 5.8rem);
  line-height: 0.94;
}

.blog-hero p:last-child,
.about-hero p {
  max-width: 42rem;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.75;
}

.about-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.5fr);
  align-items: end;
  gap: 28px;
  max-width: none;
}

.about-card,
.about-grid article,
.about-note {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(36, 43, 38, 0.08);
}

.about-card {
  min-height: 280px;
  padding: 24px;
  background: var(--feature-bg);
}

.about-card span {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.about-card strong {
  display: block;
  margin-top: 54px;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.03;
}

.about-card p {
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 38px;
}

.about-grid article {
  min-height: 300px;
  padding: 24px;
}

.about-grid h2 {
  margin: 48px 0 12px;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  line-height: 1.08;
}

.about-grid p,
.about-note p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.about-note {
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) minmax(280px, 1fr) auto;
  align-items: center;
  gap: 22px;
  margin-top: 16px;
  padding: 24px;
}

.about-note h2 {
  margin: 0;
  font-size: 1.6rem;
}

.post-list {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 0.9fr;
  gap: 16px;
  margin-top: 38px;
}

.post-card {
  display: flex;
  flex-direction: column;
  min-height: 310px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 18px 48px rgba(36, 43, 38, 0.08);
}

.main-post {
  background: var(--feature-bg);
}

.main-post:hover {
  transform: translateY(-3px);
  transition: transform 160ms ease;
}

.muted-post {
  opacity: 0.76;
}

.post-category {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.post-card h2 {
  margin: 48px 0 12px;
  font-size: clamp(1.5rem, 3vw, 2.35rem);
  line-height: 1.05;
}

.post-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.read-link {
  margin-top: auto;
  color: var(--accent-dark);
  font-weight: 950;
}

.article-page {
  display: grid;
  place-items: start center;
}

.article {
  width: min(820px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.back-link {
  display: inline-flex;
  margin-bottom: 34px;
  color: var(--accent-dark);
  font-weight: 900;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.article h1 {
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 4.8rem);
  line-height: 0.96;
}

.article-intro {
  margin: 22px 0 34px;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1.7;
}

.article h2 {
  margin: 34px 0 10px;
  font-size: 1.55rem;
}

.article p {
  color: var(--muted);
  line-height: 1.78;
}

.article-callout {
  margin: 34px 0;
  padding: 20px;
  border-left: 5px solid var(--warm);
  border-radius: 18px;
  background: var(--callout-bg);
  line-height: 1.65;
}

.article-cta {
  margin-top: 4px;
}

.intro {
  align-self: start;
  padding: 28px 8px 0;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.intro h1 {
  max-width: 9ch;
  margin: 0;
  font-size: clamp(3.2rem, 7vw, 5.8rem);
  line-height: 0.92;
}

.intro > p:not(.eyebrow) {
  max-width: 34rem;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.calculator-visual {
  width: min(100%, 320px);
  margin-top: 34px;
  color: var(--accent-dark);
}

.calculator-visual svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.visual-plate {
  fill: rgba(223, 243, 238, 0.82);
  stroke: rgba(15, 123, 108, 0.42);
  stroke-width: 5;
}

.visual-plate-inner {
  fill: var(--surface-strong);
  stroke: rgba(15, 123, 108, 0.28);
  stroke-width: 4;
}

.visual-fork,
.visual-chart,
.visual-leaf,
.visual-leaf-line {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visual-fork,
.visual-leaf {
  stroke-width: 7;
}

.visual-chart,
.visual-leaf-line {
  stroke-width: 6;
}

.visual-leaf {
  fill: rgba(244, 184, 96, 0.2);
  stroke: #0f7b6c;
}

.visual-chart {
  stroke: #d39434;
}

.calculator,
.result {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.calculator {
  padding: 28px;
}

.form-row {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.form-row label,
.form-row legend {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.form-row > label > span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.gender-row {
  padding: 0;
  border: 0;
}

input,
select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--field-bg);
  color: var(--ink);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

input {
  padding: 0 16px;
}

select {
  padding: 0 46px 0 16px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 123, 108, 0.14);
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-muted);
}

.radio-label {
  position: relative;
}

.radio-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.radio-label span {
  display: grid;
  min-height: 44px;
  place-items: center;
  border-radius: 13px;
  color: var(--muted);
  font-weight: 800;
  transition:
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.radio-label input:checked + span {
  background: var(--panel);
  color: var(--accent-dark);
  box-shadow: 0 10px 24px rgba(28, 37, 32, 0.11);
}

.input-with-unit {
  position: relative;
}

.input-with-unit input {
  padding-right: 64px;
}

.input-with-unit span {
  position: absolute;
  top: 50%;
  right: 16px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  transform: translateY(-50%);
  pointer-events: none;
}

.error-message {
  min-height: 1.25rem;
  margin: 0 0 14px;
  color: var(--danger);
  font-size: 0.92rem;
  font-weight: 700;
}

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.calculate-button,
.clear-button,
.save-button {
  border: 0;
  border-radius: 16px;
  font-weight: 900;
}

.calculate-button {
  min-height: 56px;
  background: var(--accent);
  color: var(--primary-text);
  box-shadow: 0 16px 28px rgba(15, 123, 108, 0.22);
}

.calculate-button:hover {
  background: var(--accent-dark);
}

.clear-button {
  min-width: 96px;
  min-height: 56px;
  background: var(--clear-bg);
  color: var(--ink);
}

.clear-button:hover {
  background: var(--clear-hover-bg);
}

.result {
  grid-column: 1 / -1;
}

.result[hidden] {
  display: none;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 0;
}

.result-header h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.save-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.save-button:hover {
  background: var(--save-hover-bg);
}

.save-icon {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-top-width: 5px;
  border-radius: 3px;
}

.result-copy {
  max-width: 780px;
  margin: 10px 24px 22px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.result-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 0 24px 24px;
}

.result-row {
  display: grid;
  min-height: 180px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-strong);
}

.result-row:first-child {
  border-color: rgba(15, 123, 108, 0.28);
  background: var(--result-featured-bg);
}

.result-label {
  display: grid;
  align-content: start;
  gap: 6px;
  color: var(--ink);
  font-weight: 900;
}

.rate {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.result-value {
  align-self: end;
  display: grid;
  gap: 6px;
}

.calories {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 950;
  line-height: 1;
}

.percent {
  justify-self: start;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-text);
  font-size: 0.82rem;
  font-weight: 900;
}

.unit {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

@media (max-width: 900px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .page {
    grid-template-columns: 1fr;
    padding: 32px 0;
  }

  .home-page {
    padding-top: 42px;
  }

  .home-hero,
  .feature-section,
  .post-list,
  .about-hero,
  .about-grid,
  .about-note {
    grid-template-columns: 1fr;
  }

  .home-hero {
    min-height: auto;
  }

  .home-photo {
    max-height: 620px;
  }

  .intro {
    padding-top: 0;
  }

  .intro h1 {
    max-width: 12ch;
  }

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

@media (max-width: 560px) {
  .site-header {
    width: min(100% - 20px, 1120px);
  }

  .site-header nav {
    width: 100%;
  }

  .site-header nav a {
    justify-content: center;
    flex: 1;
  }

  .home-page {
    width: min(100% - 20px, 1120px);
    padding-top: 32px;
  }

  .blog-page,
  .about-page,
  .article-page {
    width: min(100% - 20px, 1120px);
    padding-top: 32px;
  }

  .article {
    padding: 24px;
    border-radius: 24px;
  }

  .home-copy h1 {
    font-size: 3.3rem;
  }

  .home-photo {
    aspect-ratio: 1 / 1.08;
    border-radius: 22px;
  }

  .preview-grid {
    grid-template-columns: 1fr;
  }

  .page {
    width: min(100% - 20px, 1120px);
    padding: 20px 0;
  }

  .calculator,
  .result {
    border-radius: 22px;
  }

  .calculator {
    padding: 20px;
  }

  .actions,
  .result-list {
    grid-template-columns: 1fr;
  }

  .clear-button {
    width: 100%;
  }

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