:root {
  --bg: #f5efe3;
  --panel: rgba(255, 252, 246, 0.88);
  --panel-solid: #fffaf2;
  --ink: #1f2b28;
  --muted: #62706b;
  --line: rgba(38, 57, 50, 0.12);
  --shadow: 0 22px 50px rgba(33, 39, 34, 0.12);
  --green: #2f6b55;
  --green-soft: #dbeadd;
  --orange: #c9652d;
  --orange-soft: #f5d8c8;
  --gold: #bc8a2f;
  --gold-soft: #f2e3bc;
  --blue: #3e6f8c;
  --blue-soft: #d4e7f1;
  --danger: #a9413a;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(201, 101, 45, 0.2), transparent 30%),
    radial-gradient(circle at top right, rgba(62, 111, 140, 0.16), transparent 28%),
    linear-gradient(180deg, #fffdf8 0%, var(--bg) 48%, #efe5d5 100%);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), rgba(35, 44, 39, 0.03) calc(100% - 1px)),
    linear-gradient(transparent 0, transparent calc(100% - 1px), rgba(35, 44, 39, 0.02) calc(100% - 1px));
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 85%);
}

.topbar,
.shell {
  width: min(1240px, calc(100% - 2rem));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 1.3rem;
  color: #fff;
  background: linear-gradient(135deg, var(--green), #4d8b72);
  box-shadow: var(--shadow);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
}

.topnav,
.top-actions,
.hero-actions,
.range-switch,
.split-forms,
.macro-grid,
.grid,
.row,
.inline-stats {
  display: grid;
  gap: 1rem;
}

.topnav {
  grid-auto-flow: column;
  gap: 0.5rem;
  justify-content: center;
}

.topnav a,
.chip,
.button {
  border-radius: 999px;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.topnav a {
  padding: 0.7rem 1rem;
  color: var(--muted);
  border: 1px solid transparent;
}

.topnav a.is-active,
.topnav a:hover {
  color: var(--ink);
  border-color: rgba(47, 107, 85, 0.16);
  background: rgba(255, 255, 255, 0.55);
}

.top-actions {
  grid-auto-flow: column;
  gap: 0.75rem;
}

.lang-switch {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 0.35rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(47, 107, 85, 0.12);
}

.lang-chip {
  min-width: 3rem;
  padding: 0.72rem 0.9rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.lang-chip.is-active {
  background: linear-gradient(135deg, var(--green), #4d8b72);
  color: #fff;
}

.shell {
  padding: 0.75rem 0 3rem;
}

.hero-card,
.panel {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero-card::before,
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.45), transparent 35%, transparent 100%);
  pointer-events: none;
}

.hero-card,
.panel {
  padding: 1.35rem;
}

.hero-card {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 1.4rem;
}

.hero-card--wide {
  grid-template-columns: 1.15fr 0.85fr;
  align-items: stretch;
}

.hero-card--stats {
  grid-template-columns: 1.2fr auto;
  align-items: end;
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  max-width: 12ch;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(2rem, 4.7vw, 3.7rem);
  line-height: 0.98;
}

h2 {
  font-size: 1.15rem;
}

.lede,
.panel-header span,
.metric-tile small,
.callout p,
.inline-stats span,
.metric-panel small,
.weekly-item small {
  color: var(--muted);
}

.lede {
  margin: 1rem 0 0;
  max-width: 62ch;
  line-height: 1.55;
}

.hero-actions,
.range-switch {
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
}

.button,
button,
.chip {
  border: none;
  cursor: pointer;
  font-weight: 700;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.92rem 1.25rem;
  background: linear-gradient(135deg, var(--green), #3f8469);
  color: #fff;
  box-shadow: 0 12px 30px rgba(47, 107, 85, 0.18);
}

.button:hover,
button:hover,
.chip:hover {
  transform: translateY(-1px);
}

.button.ghost {
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: none;
  border: 1px solid rgba(47, 107, 85, 0.14);
}

.chip {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  border: 1px solid rgba(47, 107, 85, 0.12);
}

.chip.is-active {
  background: linear-gradient(135deg, var(--orange), #d67b48);
  color: #fff;
  border-color: transparent;
}

.hero-summary,
.macro-grid,
.grid {
  position: relative;
  z-index: 1;
}

.hero-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.metric-tile,
.metric-panel {
  padding: 1rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
}

.metric-tile span,
.metric-panel span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
}

.metric-tile strong,
.metric-panel strong {
  display: block;
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  line-height: 1;
}

.metric-tile.accent {
  background: linear-gradient(145deg, rgba(201, 101, 45, 0.16), rgba(255, 255, 255, 0.82));
}

.metric-note {
  margin-top: 0.45rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.macro-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1.35rem;
}

.macro-grid--stats {
  margin-bottom: 1.2rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-header.secondary {
  margin-top: 0.2rem;
}

.meter {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(35, 44, 39, 0.08);
}

.meter-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 0.3s ease;
}

.meter-fill--orange {
  background: linear-gradient(90deg, var(--orange), #e28a52);
}

.meter-fill--green {
  background: linear-gradient(90deg, var(--green), #5ea388);
}

.meter-fill--gold {
  background: linear-gradient(90deg, var(--gold), #d6a545);
}

.meter-fill--blue {
  background: linear-gradient(90deg, var(--blue), #5f95b5);
}

.macro-card p {
  margin: 0.8rem 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 1.35rem;
}

.grid--balanced {
  align-items: start;
}

.grid--stats {
  align-items: stretch;
}

.chart-block,
.chart {
  min-height: 220px;
}

.chart {
  position: relative;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  padding: 0.75rem;
}

.chart--tall {
  min-height: 280px;
}

.chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-empty {
  height: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.inline-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1rem;
}

.inline-stats div,
.callout,
.weekly-item {
  padding: 1rem;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.inline-stats strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.2rem;
}

.callout strong {
  display: block;
  margin-bottom: 0.45rem;
}

.callout .button {
  margin-top: 0.5rem;
}

.split-forms {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

form,
label,
.stacked-form {
  display: grid;
  gap: 0.38rem;
}

form,
.stacked-form {
  gap: 0.92rem;
}

.row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

input,
textarea,
pre {
  width: 100%;
  border-radius: 18px;
}

input,
textarea {
  border: 1px solid rgba(47, 107, 85, 0.14);
  background: rgba(255, 255, 255, 0.8);
  padding: 0.92rem 1rem;
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
}

.tips,
.events,
.weekly-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}

.tips li,
.events li {
  padding: 1rem;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  line-height: 1.5;
}

.events strong,
.events span,
.events time {
  display: block;
}

.events time {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.weekly-item strong,
.weekly-item span,
.weekly-item small {
  display: block;
}

.weekly-item span {
  margin: 0.35rem 0;
}

.result-panel {
  margin-top: 1rem;
}

.api-key {
  max-width: 360px;
  margin-bottom: 1rem;
}

pre {
  margin: 0;
  min-height: 200px;
  overflow: auto;
  padding: 1rem;
  background: #1a2220;
  color: #e6f2ed;
}

.table-wrap {
  overflow: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

.stats-table th,
.stats-table td {
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid rgba(38, 57, 50, 0.1);
  text-align: left;
}

.stats-table th {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stats-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.52);
}

.chart-label {
  font-size: 11px;
  fill: rgba(31, 43, 40, 0.68);
}

.chart-grid {
  stroke: rgba(31, 43, 40, 0.09);
  stroke-width: 1;
}

.chart-target {
  stroke: rgba(201, 101, 45, 0.9);
  stroke-width: 2;
  stroke-dasharray: 6 6;
}

.chart-series {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  opacity: 0.12;
}

.chart-point {
  stroke: #fffaf2;
  stroke-width: 2;
}

.bar {
  rx: 8;
  ry: 8;
}

.bar--food {
  fill: rgba(201, 101, 45, 0.78);
}

.bar--protein {
  fill: rgba(47, 107, 85, 0.78);
}

.bar--activity {
  fill: rgba(62, 111, 140, 0.78);
}

@media (max-width: 1080px) {
  .topbar,
  .shell {
    width: min(100% - 1rem, 1080px);
  }

  .topbar,
  .top-actions,
  .topnav,
  .range-switch {
    grid-auto-flow: row;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-card--wide,
  .hero-card--stats,
  .macro-grid,
  .grid,
  .split-forms,
  .row,
  .inline-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .hero-summary {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: none;
  }

  .button,
  button,
  .chip,
  .topnav a {
    width: 100%;
  }
}
