:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --card: #151b23;
  --card-2: #10161d;
  --primary: #a3ff12;
  --secondary: #22c55e;
  --text: #ffffff;
  --muted: #9ca3af;
  --warning: #f59e0b;
  --missed: #ef4444;
  --line: rgba(255, 255, 255, 0.09);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(163, 255, 18, 0.11), transparent 28rem),
    linear-gradient(180deg, #0b0f14 0%, #0d1218 48%, #080b0f 100%);
  color: var(--text);
}

button, input, textarea, select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

.screen {
  padding: 18px 16px 22px;
}

.view { display: none; }
.view.active { display: block; }

.hero-card, .card, .tile, .meal-row, .setting-row, .history-day, .estimate-result {
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.01)), var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 20px;
  overflow: hidden;
  position: relative;
}

.hero-top, .section-head, .row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #0b0f14;
  font-weight: 950;
  box-shadow: 0 0 28px rgba(163, 255, 18, 0.36);
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.75rem; letter-spacing: 0; }
h2 { font-size: 1.15rem; margin: 24px 0 12px; }
h3 { font-size: 1rem; }
.tagline, .muted, small { color: var(--muted); }
.tagline { margin-top: 2px; }

.progress-wrap {
  display: grid;
  grid-template-columns: minmax(168px, 1fr);
  place-items: center;
  margin: 22px 0 10px;
}

.ring {
  --pct: 0;
  width: min(70vw, 255px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, #151b23 0 58%, transparent 59%),
    conic-gradient(var(--primary) calc(var(--pct) * 1%), rgba(255,255,255,0.08) 0);
  box-shadow: inset 0 0 30px rgba(0,0,0,0.35), 0 0 46px rgba(163,255,18,0.13);
}

.ring-inner {
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #0e1319;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
}

.daily-number {
  font-size: clamp(2.25rem, 13vw, 4.3rem);
  line-height: 0.95;
  font-weight: 950;
}

.goal-line {
  margin-top: 7px;
  color: var(--muted);
  font-weight: 700;
}

.remaining {
  margin-top: 12px;
  font-size: 1.8rem;
  font-weight: 900;
  text-align: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(163, 255, 18, 0.12);
  color: var(--primary);
  font-weight: 850;
  white-space: nowrap;
}

.status-pill.missed { background: rgba(239, 68, 68, 0.14); color: var(--missed); }
.status-pill.warn { background: rgba(245, 158, 11, 0.13); color: var(--warning); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.metric {
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px;
}

.metric strong {
  display: block;
  font-size: 1.3rem;
  margin-bottom: 2px;
}

.primary-btn, .secondary-btn, .danger-btn, .icon-btn {
  min-height: 48px;
  border-radius: 16px;
  font-weight: 850;
}

.primary-btn {
  width: 100%;
  background: var(--primary);
  color: #0b0f14;
}

.secondary-btn {
  background: rgba(255,255,255,0.075);
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-btn {
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.icon-btn {
  width: 48px;
  background: rgba(255,255,255,0.07);
  color: var(--text);
  border: 1px solid var(--line);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tile {
  min-height: 108px;
  padding: 14px;
  color: var(--text);
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.tile:active, .primary-btn:active, .secondary-btn:active, .icon-btn:active { transform: translateY(1px); }
.tile .emoji { font-size: 1.65rem; }
.tile strong { font-size: 1rem; }
.tile b { color: var(--primary); font-size: 1.25rem; }

.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
}

input, textarea, select {
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #0f151c;
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  border-color: rgba(163, 255, 18, 0.65);
  box-shadow: 0 0 0 4px rgba(163, 255, 18, 0.08);
}

.card {
  padding: 16px;
  margin-top: 12px;
}

.meal-list, .history-list, .settings-list, .saved-list, .insight-list {
  display: grid;
  gap: 10px;
}

.meal-row, .history-day, .setting-row {
  padding: 13px;
  display: grid;
  gap: 8px;
}

.meal-row-main {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.meal-actions, .button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meal-actions .secondary-btn, .meal-actions .danger-btn, .button-row .secondary-btn, .button-row .danger-btn {
  min-height: 40px;
  padding: 0 12px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  min-height: 42px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}

.tab.active {
  background: var(--primary);
  color: #0b0f14;
  font-weight: 900;
}

.estimate-result {
  padding: 16px;
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.breakdown {
  display: grid;
  gap: 8px;
}

.breakdown div {
  display: flex;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(760px, 100%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
  background: rgba(11, 15, 20, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
  z-index: 10;
}

.nav-btn {
  min-height: 58px;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 2px;
}

.nav-btn span { font-size: 1.2rem; line-height: 1; }
.nav-btn small { font-size: 0.72rem; font-weight: 800; }
.nav-btn.active { background: rgba(163, 255, 18, 0.13); color: var(--primary); }

.modal {
  width: min(92vw, 440px);
  border: 0;
  padding: 0;
  border-radius: 24px;
  background: transparent;
  color: var(--text);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.modal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.modal-body { display: grid; gap: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(18px);
  width: min(92vw, 420px);
  padding: 13px 16px;
  border-radius: 16px;
  background: #f9fafb;
  color: #0b0f14;
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 22px 10px;
}

.hidden { display: none !important; }

@media (min-width: 680px) {
  .screen { padding: 28px 24px 26px; }
  .quick-grid { grid-template-columns: repeat(3, 1fr); }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .hero-card { padding: 26px; }
}
