:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #16181d;
  --muted: #646b7a;
  --line: #e2e5eb;
  --accent: #2f6f4f;
  --accent-soft: #e8f2ec;
  --warn-bg: #fdf4e3;
  --warn-line: #e5c98a;
  --warn-text: #6b4e12;
  --danger: #b3261e;
  --protein: #2f6f4f;
  --carbs: #b07d2b;
  --fat: #4a6fa5;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --card: #181b21;
    --text: #e9ecf1;
    --muted: #98a1b2;
    --line: #2b3039;
    --accent: #6bbf95;
    --accent-soft: #1c2a23;
    --warn-bg: #2a2413;
    --warn-line: #6b5a2a;
    --warn-text: #e8d3a0;
    --danger: #f2857c;
    --protein: #6bbf95;
    --carbs: #d9a94e;
    --fat: #7fa4d9;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1rem 4rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.wrap { max-width: 720px; margin: 0 auto; }

header { text-align: center; margin-bottom: 1.75rem; }
h1 { margin: 0; font-size: 2.1rem; font-weight: 700; letter-spacing: -0.03em; }
h1 span { color: var(--accent); }
.sub { margin: 0.4rem 0 0; color: var(--muted); }

form, section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}

section { margin-top: 1.25rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

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

@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 0.35rem; }

label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.hint { font-weight: 400; opacity: 0.75; }

input, select, button {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  width: 100%;
}

input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  margin-top: 1.25rem;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

button:hover { filter: brightness(1.07); }
button[disabled] { opacity: 0.6; cursor: progress; }

.error {
  margin: 1rem 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.headline { text-align: center; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.headline-value { font-size: 3rem; font-weight: 700; letter-spacing: -0.03em; color: var(--accent); }
.headline-unit { display: block; color: var(--muted); font-size: 0.9rem; }
.headline-note { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.9rem; }

.warning {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn-text);
  border-radius: 8px;
  font-size: 0.88rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.stat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem;
  text-align: center;
}

.stat-label { display: block; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { display: block; font-size: 1.4rem; font-weight: 600; margin-top: 0.2rem; }
.stat-sub { display: block; font-size: 0.78rem; color: var(--muted); }

h2 { font-size: 1rem; margin: 1.75rem 0 0.75rem; }

.macro { margin-bottom: 0.9rem; }
.macro-top { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 0.3rem; }
.macro-name { font-weight: 600; }
.macro-detail { color: var(--muted); }

.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; }

.macro-protein .bar > span { background: var(--protein); }
.macro-carbs .bar > span { background: var(--carbs); }
.macro-fat .bar > span { background: var(--fat); }

.range { margin-top: 1.25rem; padding: 0.75rem 0.9rem; background: var(--accent-soft); border-radius: 8px; font-size: 0.9rem; }
.disclaimer { color: var(--muted); font-size: 0.8rem; margin-bottom: 0; }
