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

:root {
  --color-bg:           #0f172a;
  --color-surface:      #111827;
  --color-surface-2:    #1a2236;
  --color-elevated:     #1e293b;
  --color-deep:         #0b1220;

  --color-text:         #f1f5f9;
  --color-text-sec:     #94a3b8;
  --color-text-muted:   #475569;

  --color-border:       rgba(255, 255, 255, 0.07);
  --color-border-strong:#334155;

  --color-green:        #10b981;
  --color-green-dim:    rgba(16, 185, 129, 0.15);
  --color-blue:         #3b82f6;
  --color-blue-dim:     rgba(59, 130, 246, 0.15);
  --color-amber:        #f59e0b;
  --color-amber-dim:    rgba(245, 158, 11, 0.15);
  --color-red:          #ef4444;
  --color-purple:       #a855f7;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --t: 0.15s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Header ─────────────────────────────────────── */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 36px 0 28px;
  text-align: center;
}

.header-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  line-height: 1;
}

.site-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.4px;
}

.site-title span {
  color: var(--color-green);
}

.site-subtitle {
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--color-text-sec);
}

/* ── Calculator card ──────────────────────────────── */
.calculator-card {
  background: var(--color-deep);
  border: 1px solid #1f2937;
  border-radius: var(--r-lg);
  padding: 24px;
  margin: 24px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-row .form-group {
  margin-bottom: 0;
}

label, legend {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-sec);
}

input[type="number"],
select {
  width: 100%;
  padding: 10px 12px;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--r-md);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--t);
  appearance: none;
  -webkit-appearance: none;
}

input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px var(--color-blue-dim);
}

input[type="number"]::placeholder {
  color: var(--color-text-muted);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

select option {
  background: var(--color-elevated);
  color: var(--color-text);
}

/* ── Radio / Fieldset ─────────────────────────────── */
.form-section {
  margin-bottom: 16px;
}

fieldset {
  border: none;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 9px 16px;
  background: var(--color-elevated);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--t), background var(--t);
  user-select: none;
  flex: 1;
  min-width: 110px;
}

.radio-label:has(input:checked) {
  border-color: var(--color-green);
  background: var(--color-green-dim);
}

.radio-label input[type="radio"] {
  accent-color: var(--color-green);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.radio-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-sec);
}

.radio-label:has(input:checked) .radio-text {
  color: var(--color-green);
}

/* ── Submit button ───────────────────────────────── */
.btn-calculate {
  width: 100%;
  padding: 13px;
  background: var(--color-green);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity var(--t), transform var(--t);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-calculate:hover  { opacity: 0.9; }
.btn-calculate:active { opacity: 0.8; transform: scale(0.99); }

/* ── Results ─────────────────────────────────────── */
.results {
  margin-bottom: 24px;
  animation: slideInFromBottom 0.25s ease;
}

.results-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--color-text);
  text-align: center;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.result-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  padding: 18px 10px;
  text-align: center;
  border-top: 3px solid transparent;
}

.result-calories { border-top-color: var(--color-amber); }
.result-protein  { border-top-color: #60a5fa; }
.result-fat      { border-top-color: #fbbf24; }
.result-carbs    { border-top-color: var(--color-green); }

.result-icon {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.result-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  margin-bottom: 4px;
}

.result-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-sec);
}

.results-note {
  margin-top: 12px;
  font-size: 0.825rem;
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1.5;
}

/* ── Info section ────────────────────────────────── */
.info-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.info-section h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 12px;
}

.info-section p {
  font-size: 0.875rem;
  color: var(--color-text-sec);
  margin-bottom: 10px;
  line-height: 1.6;
}

.info-section p:last-child {
  margin-bottom: 0;
}

.formula-block {
  background: var(--color-bg);
  border-left: 3px solid var(--color-blue);
  border-radius: 4px;
  padding: 12px 14px;
  margin: 10px 0;
}

.formula-block p {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: var(--color-text);
  margin-bottom: 6px;
  line-height: 1.5;
}

.formula-block p:last-child {
  margin-bottom: 0;
}

/* ── CTA ─────────────────────────────────────────── */
.cta-section {
  margin-bottom: 40px;
}

.cta-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.cta-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(16,185,129,0.07) 0%, rgba(59,130,246,0.07) 100%);
  pointer-events: none;
}

.cta-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.cta-text {
  font-size: 0.875rem;
  color: var(--color-text-sec);
  margin-bottom: 20px;
  line-height: 1.6;
}

.cta-button {
  display: inline-block;
  padding: 12px 28px;
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: opacity var(--t), transform var(--t);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  position: relative;
}

.cta-button:hover  { opacity: 0.9; transform: translateY(-1px); }
.cta-button:active { opacity: 0.8; transform: scale(0.98); }

/* ── Footer ──────────────────────────────────────── */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 18px 0;
  text-align: center;
}

.site-footer p {
  font-size: 0.775rem;
  color: var(--color-text-muted);
}

/* ── Animations ──────────────────────────────────── */
@keyframes slideInFromBottom {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 580px) {
  .site-title { font-size: 1.4rem; }

  .calculator-card { padding: 16px; }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .form-row .form-group {
    margin-bottom: 14px;
  }

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

  .info-section,
  .cta-card {
    padding: 18px 16px;
  }

  .radio-label {
    min-width: 90px;
  }
}
