:root {
  color-scheme: light;
  --paper: #f6f2ea;
  --ink: #1d2522;
  --muted: #69736f;
  --line: #ded6c9;
  --surface: #ffffff;
  --leaf: #2e8f68;
  --mint: #9bd7bd;
  --sun: #f0b84b;
  --coral: #e7785f;
  --deep: #203c38;
  --shadow: 0 18px 48px rgba(31, 52, 47, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(150deg, rgba(155, 215, 189, 0.38), transparent 36%),
    linear-gradient(330deg, rgba(240, 184, 75, 0.24), transparent 42%),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell,
.auth-screen {
  width: min(100%, 680px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
}

[hidden] {
  display: none !important;
}

.topbar,
.date-strip,
.section-head,
.stat-grid,
.summary-band,
.entry-form,
.meal-row,
.top-actions {
  display: flex;
  align-items: center;
}

.topbar,
.section-head {
  justify-content: space-between;
  gap: 14px;
}

.top-actions {
  gap: 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--leaf);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.15rem, 9vw, 3.9rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.08rem;
}

.icon-button,
.text-button,
.primary-button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: var(--deep);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 24px rgba(31, 52, 47, 0.1);
}

.icon-button span {
  font-size: 1.45rem;
  line-height: 1;
}

.date-strip {
  gap: 10px;
  margin: 22px 0 16px;
}

.date-strip input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
}

.summary-band,
.entry-panel,
.meal-list-section,
.settings-card,
.auth-card {
  border: 1px solid rgba(222, 214, 201, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-screen {
  display: grid;
  align-items: center;
}

.auth-card {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.auth-card h1 {
  font-size: clamp(2.6rem, 12vw, 4.8rem);
}

.auth-copy {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

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

.auth-message {
  min-height: 1.4em;
  color: var(--leaf);
  font-weight: 850;
}

body[aria-busy="true"] button,
body[aria-busy="true"] input,
body[aria-busy="true"] select {
  opacity: 0.72;
}

.summary-band {
  gap: 18px;
  padding: 18px;
  align-items: stretch;
}

.gauge-wrap {
  position: relative;
  flex: 0 0 152px;
  display: grid;
  place-items: center;
  min-height: 152px;
}

.gauge {
  width: 148px;
  height: 148px;
  transform: rotate(-90deg);
}

.gauge circle {
  fill: none;
  stroke-linecap: round;
  stroke-width: 10;
}

.gauge-track {
  stroke: #e8dfd1;
}

.gauge-range {
  stroke: rgba(155, 215, 189, 0.68);
  stroke-dasharray: 91 302;
  stroke-dashoffset: -210;
}

.gauge-progress {
  stroke: var(--leaf);
  stroke-dasharray: 0 302;
  transition: stroke-dasharray 260ms ease, stroke 260ms ease;
}

body[data-zone="low"] .gauge-progress {
  stroke: var(--sun);
}

body[data-zone="range"] .gauge-progress {
  stroke: var(--leaf);
}

body[data-zone="high"] .gauge-progress {
  stroke: var(--coral);
}

.gauge-label {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
}

.gauge-label strong {
  font-size: 2rem;
}

.gauge-label span {
  width: 96px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2;
}

.summary-copy {
  display: grid;
  align-content: center;
  flex: 1;
  min-width: 0;
}

.summary-copy p {
  color: var(--deep);
  font-size: 1.05rem;
  font-weight: 800;
}

.progress-rail {
  position: relative;
  height: 16px;
  margin: 18px 0;
  overflow: hidden;
  border-radius: 8px;
  background: #e8dfd1;
}

.progress-target,
.progress-fill {
  position: absolute;
  inset-block: 0;
  border-radius: inherit;
}

.progress-target {
  left: 72.7%;
  right: 0;
  background: rgba(155, 215, 189, 0.72);
}

.progress-fill {
  left: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--sun), var(--leaf));
  transition: width 260ms ease, background 260ms ease;
}

body[data-zone="high"] .progress-fill {
  background: linear-gradient(90deg, var(--leaf), var(--coral));
}

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

.stat-grid div {
  min-width: 0;
  border-radius: 8px;
  padding: 12px;
  background: #f7f4ee;
}

.stat-grid span,
label,
.section-head span,
.meal-meta,
.empty-state span {
  color: var(--muted);
  font-size: 0.84rem;
}

.stat-grid strong {
  display: block;
  margin-top: 2px;
  font-size: 1.35rem;
}

.entry-panel,
.meal-list-section {
  margin-top: 16px;
  padding: 16px;
}

.entry-form {
  display: grid;
  grid-template-columns: 1fr 0.78fr;
  gap: 12px;
  margin-top: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.wide {
  grid-column: 1 / -1;
}

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

.input-with-unit {
  position: relative;
}

.input-with-unit input {
  padding-right: 42px;
}

.input-with-unit span {
  position: absolute;
  right: 13px;
  top: 50%;
  color: var(--muted);
  font-weight: 800;
  transform: translateY(-50%);
}

.primary-button {
  grid-column: 1 / -1;
  color: white;
  background: var(--deep);
  font-weight: 850;
  box-shadow: 0 12px 26px rgba(32, 60, 56, 0.2);
}

.text-button {
  min-height: 38px;
  padding: 0 8px;
  color: var(--leaf);
  background: transparent;
  font-weight: 800;
}

.meal-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.meal-row {
  gap: 12px;
  min-height: 66px;
  border-radius: 8px;
  padding: 12px;
  background: #f7f4ee;
}

.meal-badge {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: var(--deep);
  background: rgba(155, 215, 189, 0.62);
  font-weight: 900;
}

.meal-main {
  flex: 1;
  min-width: 0;
}

.meal-title {
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meal-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meal-protein {
  font-size: 1.2rem;
  font-weight: 900;
}

.delete-button {
  border: 0;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.8);
}

.empty-state {
  display: grid;
  gap: 4px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px 14px;
  text-align: center;
}

.settings-dialog {
  width: min(92vw, 420px);
  border: 0;
  padding: 0;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(29, 37, 34, 0.36);
  backdrop-filter: blur(5px);
}

.settings-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  border: 0;
  padding: 0;
  margin: 0;
}

.segmented legend {
  grid-column: 1 / -1;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--deep);
  font-weight: 900;
}

.segmented input:checked + span {
  border-color: var(--leaf);
  background: var(--leaf);
  color: white;
}

.settings-summary {
  border-radius: 8px;
  padding: 12px;
  color: var(--deep);
  background: #f7f4ee;
  font-weight: 800;
}

@media (max-width: 560px) {
  .summary-band {
    display: grid;
    grid-template-columns: 1fr;
  }

  .gauge-wrap {
    min-height: 138px;
  }

  .gauge {
    width: 136px;
    height: 136px;
  }
}

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