:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #667085;
  --line: #d9e2dc;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --mint: #cbe8d6;
  --sage: #6f8f72;
  --tomato: #d85c45;
  --blue: #4f78a7;
  --gold: #d8a642;
  --shadow: 0 18px 50px rgba(38, 50, 56, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

button, input, select { font: inherit; }

button {
  cursor: pointer;
  border: 0;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero {
  min-height: 310px;
  display: grid;
  grid-template-columns: 1fr minmax(240px, 320px);
  align-items: end;
  gap: 28px;
  padding: 42px;
  border-radius: 8px;
  color: white;
  background:
    linear-gradient(90deg, rgba(24, 38, 33, 0.86), rgba(24, 38, 33, 0.42)),
    url("https://images.unsplash.com/photo-1512621776951-a57141f2eefd?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.hero-main {
  display: grid;
  gap: 16px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 18px;
}

.app-logo {
  width: 92px;
  aspect-ratio: 1;
  border-radius: 22px;
  border: 3px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
  object-fit: cover;
}

.hero-side {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.icon-button {
  width: 46px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.icon-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.hero h1 {
  margin: 8px 0 12px;
  font-size: clamp(2.4rem, 6vw, 5.4rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 630px;
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.55;
}

.eyebrow, .panel-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
  font-weight: 800;
}

.target-panel, .summary, .profile, .budget, .log-section article {
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.target-panel {
  padding: 22px;
}

.target-panel strong {
  display: block;
  font-size: 3rem;
  line-height: 1;
  margin: 8px 0;
}

.dashboard, .log-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}

.summary, .profile, .budget, .log-section article {
  padding: 22px;
}

.summary-top, .section-title, .water-title, .log-item, .history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h2 {
  margin: 0;
  font-size: 1.35rem;
}

.meter-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 22px 0;
}

.ring {
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--tomato) var(--pct), #edf2ee 0);
  position: relative;
  flex: 0 0 auto;
}

.ring::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: white;
}

.ring span, .ring small {
  position: relative;
  display: block;
}

.ring span {
  font-size: 2rem;
  font-weight: 850;
}

.ring small {
  margin-top: 34px;
  color: var(--muted);
  font-weight: 700;
}

.progress-copy {
  display: grid;
  gap: 6px;
}

.progress-copy span, .math-note, .card p, .empty, .budget-card span {
  color: var(--muted);
  line-height: 1.5;
}

.water-buttons {
  display: grid;
  grid-template-columns: repeat(8, minmax(28px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.water-cup {
  height: 38px;
  border-radius: 8px;
  border: 1px solid #a8c6da;
  background: #eef7fb;
  color: var(--blue);
  font-weight: 900;
}

.water-cup.done {
  background: var(--blue);
  color: white;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 750;
  font-size: 0.86rem;
}

input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
}

.math-note {
  margin: 16px 0 0;
}

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

.budget-card {
  min-height: 86px;
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.budget-card strong {
  font-size: 1.28rem;
  color: var(--tomato);
}

.settings-view {
  margin-top: 18px;
}

.builder {
  margin-top: 30px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tab, .ghost-button, .primary-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 850;
}

.tab {
  background: #edf2ee;
  color: var(--ink);
}

.tab.active {
  background: var(--ink);
  color: white;
}

.ghost-button {
  background: #edf2ee;
  color: var(--ink);
}

.primary-button {
  background: var(--sage);
  color: white;
}

.meal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.card {
  min-height: 360px;
  display: grid;
  grid-template-rows: 150px auto 1fr auto;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.card:hover {
  border-color: #b9c9bd;
  box-shadow: 0 12px 32px rgba(38, 50, 56, 0.1);
  transform: translateY(-2px);
}

.card-cover {
  width: 100%;
  min-height: 150px;
  border-radius: 8px;
  background: var(--cover) center/cover;
}

.card h3 {
  margin: 0;
  font-size: 1.18rem;
}

.card p {
  margin: 0;
}

.components {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 5px;
}

.components span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f2efe7;
  color: #554f45;
  font-size: 0.74rem;
  font-weight: 750;
  line-height: 1.1;
}

.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calories {
  font-weight: 900;
  color: var(--tomato);
}

.log-section {
  align-items: start;
}

.compact {
  margin-bottom: 14px;
}

.today-log, .history {
  display: grid;
  gap: 10px;
}

.log-item, .history-item {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.remove {
  width: 34px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #f6ded8;
  color: #96351f;
  font-weight: 900;
}

.weight-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin: 16px 0;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 28, 26, 0.62);
}

.detail-overlay[hidden] {
  display: none;
}

.detail-panel {
  width: min(720px, 100%);
  max-height: min(860px, calc(100vh - 40px));
  overflow: auto;
  position: relative;
  border-radius: 8px;
  background: white;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.25);
}

.detail-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
}

.detail-cover {
  min-height: 260px;
  background: var(--detail-cover) center/cover;
}

.detail-body {
  display: grid;
  gap: 14px;
  padding: 24px;
}

.detail-body h3 {
  margin: 4px 0 0;
}

.detail-calorie-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.detail-calorie-row strong {
  color: var(--tomato);
  font-size: 1.35rem;
}

.measurement-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.measurement-list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.measurement-list strong {
  color: var(--ink);
}

.measurement-list span {
  color: var(--muted);
  text-align: right;
}

@media (max-width: 900px) {
  .hero, .dashboard, .log-section {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .hero {
    padding: 28px 20px;
    min-height: 420px;
  }

  .brand-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-logo {
    width: 76px;
    border-radius: 18px;
  }

  .hero-side {
    justify-items: start;
  }

  .meal-grid, .profile-grid, .budget-grid {
    grid-template-columns: 1fr;
  }

  .section-title, .summary-top, .meter-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabs {
    justify-content: flex-start;
  }

  .weight-entry {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    max-height: calc(100vh - 20px);
  }

  .detail-cover {
    min-height: 190px;
  }

  .detail-calorie-row, .measurement-list li {
    align-items: flex-start;
    flex-direction: column;
  }

  .measurement-list span {
    text-align: left;
  }
}
