:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-soft: #0a1627;
  --surface: #101d30;
  --surface-2: #14243a;
  --surface-3: #192c45;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f6f8fb;
  --muted: #9aa9bc;
  --lime: #baff63;
  --lime-2: #89e442;
  --orange: #ff9a42;
  --blue: #66b5ff;
  --pink: #ff7191;
  --danger: #ff6b6b;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
  --radius: 24px;
  --radius-small: 16px;
  font-family: ui-rounded, "SF Pro Rounded", "SF Pro Display", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 75% -10%, rgba(82, 139, 255, 0.12), transparent 34rem),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
label.file-button {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
label.file-button:focus-visible {
  outline: 3px solid rgba(186, 255, 99, 0.38);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 248px;
  flex-direction: column;
  padding: 28px 20px;
  border-right: 1px solid var(--border);
  background: rgba(7, 17, 31, 0.93);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 15px 7px 15px 7px;
  color: #13200a;
  background: linear-gradient(145deg, var(--lime), #7fd936);
  box-shadow: 0 10px 25px rgba(137, 228, 66, 0.2);
  font-size: 1.35rem;
  font-weight: 950;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.side-nav {
  display: grid;
  gap: 8px;
  margin-top: 44px;
}

.nav-button {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 15px;
  padding: 0 15px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.96rem;
  font-weight: 750;
  text-align: left;
}

.nav-button span {
  width: 22px;
  color: currentColor;
  font-size: 1.05rem;
  text-align: center;
}

.nav-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-button.active {
  color: var(--lime);
  background: rgba(186, 255, 99, 0.1);
}

.sidebar-target {
  display: grid;
  gap: 5px;
  margin-top: auto;
  border: 1px solid rgba(186, 255, 99, 0.18);
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(145deg, rgba(186, 255, 99, 0.1), rgba(186, 255, 99, 0.025));
}

.sidebar-target span,
.sidebar-target small {
  color: var(--muted);
  font-size: 0.78rem;
}

.sidebar-target strong {
  color: var(--lime);
  font-size: 1.18rem;
}

.main-content {
  width: min(1180px, calc(100% - 248px));
  margin-left: 248px;
  padding: 22px 34px 70px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  margin: -22px -34px 20px;
  padding: 14px 34px;
  border-bottom: 1px solid transparent;
  background: linear-gradient(to bottom, rgba(7, 17, 31, 0.96), rgba(7, 17, 31, 0.83), transparent);
  backdrop-filter: blur(14px);
}

.date-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.date-button,
.dialog-close {
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  font-size: 1.6rem;
  line-height: 1;
}

.date-button {
  min-height: 38px;
  border-radius: 13px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button,
.secondary-button,
.text-button {
  border: 0;
  cursor: pointer;
  font-weight: 850;
}

.primary-button {
  min-height: 48px;
  border-radius: 15px;
  padding: 0 20px;
  color: #13200a;
  background: linear-gradient(145deg, var(--lime), var(--lime-2));
  box-shadow: 0 10px 25px rgba(137, 228, 66, 0.17);
}

.primary-button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.primary-button.compact {
  min-height: 40px;
  padding: 0 16px;
}

.primary-button.full {
  width: 100%;
}

.secondary-button,
label.secondary-button {
  display: inline-grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface-2);
}

.text-button {
  padding: 8px 0;
  color: var(--lime);
  background: transparent;
  font-size: 0.9rem;
}

.app-view {
  display: none;
}

.app-view.active {
  display: block;
  animation: view-in 220ms ease-out;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.meal-banner {
  position: relative;
  min-height: 210px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.meal-banner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.meal-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(5, 14, 26, 0.96) 0%, rgba(5, 14, 26, 0.78) 41%, rgba(5, 14, 26, 0.05) 75%);
}

.meal-banner-copy {
  position: relative;
  z-index: 1;
  max-width: 520px;
  padding: 42px;
}

.eyebrow {
  display: inline-block;
  color: var(--lime);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.eyebrow.dark {
  color: var(--lime);
}

h1,
h2,
p {
  margin-top: 0;
}

.meal-banner h1,
.view-title h1 {
  margin: 8px 0 10px;
  font-size: clamp(2rem, 4vw, 3.35rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.meal-banner p,
.view-title p {
  margin-bottom: 0;
  color: #c0cad7;
  font-size: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(340px, 1.6fr) repeat(3, minmax(150px, 0.7fr));
  gap: 14px;
  margin-top: 18px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(20, 36, 58, 0.96), rgba(13, 27, 45, 0.96));
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.13);
}

.calorie-card {
  grid-row: span 2;
  padding: 22px;
}

.card-heading,
.section-heading,
.macro-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.card-heading h2,
.section-heading h2,
.history-card h2,
.weight-card h2,
.streak-card h2,
.install-card h2,
.data-card h2 {
  margin: 3px 0 0;
  font-size: 1.18rem;
  letter-spacing: -0.025em;
}

.status-pill,
.food-state,
.entries-count {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.76rem;
  font-weight: 800;
}

.calorie-content {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-top: 16px;
}

.calorie-ring {
  position: relative;
  display: grid;
  width: 142px;
  height: 142px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--lime) var(--progress), rgba(255, 255, 255, 0.075) 0deg);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.18), 0 16px 30px rgba(0, 0, 0, 0.2);
}

.calorie-ring::before {
  position: absolute;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: #101d30;
  content: "";
}

.ring-center {
  position: relative;
  z-index: 1;
  display: grid;
  text-align: center;
}

.ring-center strong {
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.05em;
}

.ring-center span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.75rem;
}

.calorie-remaining {
  display: grid;
  gap: 3px;
}

.calorie-remaining strong {
  color: var(--lime);
  font-size: 2.2rem;
  letter-spacing: -0.05em;
}

.calorie-remaining span {
  font-weight: 800;
}

.calorie-remaining small {
  margin-top: 7px;
  color: var(--muted);
}

.macro-card {
  min-height: 118px;
  padding: 18px;
}

.macro-card .macro-top {
  align-items: baseline;
}

.macro-top span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.macro-top strong {
  font-size: 1.32rem;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  margin: 20px 0 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.07);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 300ms ease;
}

.protein-card .progress-track span { background: var(--lime); }
.carbs-card .progress-track span { background: var(--orange); }
.fat-card .progress-track span { background: var(--blue); }

.macro-card small {
  color: var(--muted);
  font-size: 0.76rem;
}

.section-block {
  margin-top: 34px;
}

.section-heading {
  margin-bottom: 16px;
}

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

.quick-food {
  position: relative;
  min-height: 152px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.quick-food:hover {
  border-color: rgba(186, 255, 99, 0.32);
  background: var(--surface-2);
  transform: translateY(-3px);
}

.quick-food-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  color: #10200c;
  background: var(--quick-color, var(--lime));
  font-size: 1.1rem;
  font-weight: 900;
}

.quick-food strong,
.quick-food small {
  display: block;
}

.quick-food strong {
  margin-top: 20px;
  font-size: 0.95rem;
  line-height: 1.15;
}

.quick-food small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
}

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

.meal-group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(16, 29, 48, 0.82);
}

.meal-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
}

.meal-group-header > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meal-emoji {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.055);
}

.meal-group-header strong {
  font-size: 0.96rem;
}

.meal-group-header small {
  color: var(--muted);
  font-size: 0.82rem;
}

.meal-add-button {
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--lime);
  background: rgba(186, 255, 99, 0.07);
  cursor: pointer;
  font-size: 1.2rem;
}

.meal-entry {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
}

.entry-name strong,
.entry-name small {
  display: block;
}

.entry-name strong {
  font-size: 0.9rem;
}

.entry-name small,
.entry-macros {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
}

.entry-calories {
  font-size: 0.9rem;
  font-weight: 850;
  white-space: nowrap;
}

.entry-delete {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
}

.entry-delete:hover {
  color: var(--danger);
  background: rgba(255, 107, 107, 0.09);
}

.meal-empty {
  padding: 0 18px 16px 62px;
  color: #738399;
  font-size: 0.8rem;
}

.view-title {
  padding: 16px 0 28px;
}

.view-title h1 {
  margin-top: 8px;
}

.history-card {
  padding: 24px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.legend i {
  width: 18px;
  height: 2px;
  background: var(--lime);
}

.week-chart {
  display: grid;
  height: 290px;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 12px;
  margin-top: 28px;
  padding: 28px 12px 0;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(to top, transparent calc(100% - 1px), rgba(255,255,255,.045) 0) 0 33.333% / 100% 33.333%;
}

.chart-day {
  display: grid;
  height: 100%;
  grid-template-rows: 1fr 34px;
  align-items: end;
  gap: 8px;
  text-align: center;
}

.chart-bar-wrap {
  display: flex;
  height: 100%;
  align-items: flex-end;
  justify-content: center;
}

.chart-bar {
  position: relative;
  width: min(48px, 70%);
  min-height: 3px;
  border-radius: 12px 12px 4px 4px;
  background: linear-gradient(to top, #5baa2d, var(--lime));
  box-shadow: 0 8px 18px rgba(137, 228, 66, 0.13);
}

.chart-bar span {
  position: absolute;
  top: -24px;
  left: 50%;
  color: var(--muted);
  font-size: 0.68rem;
  transform: translateX(-50%);
  white-space: nowrap;
}

.chart-day.today .chart-label {
  color: var(--lime);
  font-weight: 850;
}

.chart-label {
  color: var(--muted);
  font-size: 0.75rem;
}

.history-grid,
.settings-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr;
  gap: 16px;
  margin-top: 16px;
}

.weight-card,
.streak-card,
.install-card,
.data-card {
  padding: 24px;
}

.weight-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
}

.weight-input-row input,
.setting-field input,
.form-grid input,
.form-grid select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
}

.weight-input-row input {
  width: 130px;
  height: 48px;
  padding: 0 14px;
  font-size: 1.1rem;
  font-weight: 800;
}

.weight-input-row > span {
  color: var(--muted);
}

.weight-card p,
.streak-card p,
.install-card p,
.data-card p {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.streak-card strong {
  display: block;
  margin-top: 28px;
  color: var(--lime);
  font-size: 4rem;
  line-height: 0.85;
  letter-spacing: -0.08em;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 24px;
}

.setting-field label,
.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.setting-field > div {
  position: relative;
}

.setting-field input {
  height: 52px;
  padding: 0 48px 0 14px;
  font-size: 1.03rem;
  font-weight: 800;
}

.setting-field div span {
  position: absolute;
  top: 50%;
  right: 14px;
  color: var(--muted);
  font-size: 0.75rem;
  transform: translateY(-50%);
}

.settings-form .full {
  grid-column: 1 / -1;
}

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.file-button {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 850;
}

.custom-food-list {
  display: grid;
  gap: 10px;
}

.custom-food-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--surface);
}

.custom-food-row strong,
.custom-food-row small {
  display: block;
}

.custom-food-row small {
  margin-top: 4px;
  color: var(--muted);
}

.custom-food-row button {
  border: 0;
  color: var(--danger);
  background: transparent;
  cursor: pointer;
}

.empty-card {
  border: 1px dashed rgba(255, 255, 255, 0.13);
  border-radius: 18px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.mobile-nav {
  display: none;
}

.app-dialog {
  width: min(920px, calc(100% - 28px));
  max-height: min(820px, calc(100dvh - 28px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 0;
  color: var(--text);
  background: #0d192b;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55);
}

.app-dialog::backdrop {
  background: rgba(2, 7, 14, 0.78);
  backdrop-filter: blur(8px);
}

.dialog-shell {
  overflow: auto;
  max-height: min(820px, calc(100dvh - 28px));
  padding: 24px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.dialog-header h2 {
  margin: 4px 0 0;
  font-size: 1.55rem;
  letter-spacing: -0.035em;
}

.dialog-close {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 13px;
  font-size: 1.45rem;
}

.meal-selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 22px;
  padding-bottom: 2px;
}

.meal-choice {
  min-height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.meal-choice.active {
  border-color: rgba(186, 255, 99, 0.28);
  color: #14210c;
  background: var(--lime);
}

.search-field {
  display: flex;
  height: 50px;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.045);
}

.search-field span {
  color: var(--muted);
  font-size: 1.2rem;
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 1rem;
}

.search-field input::placeholder,
.form-grid input::placeholder {
  color: #697a91;
}

.food-picker-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  margin-top: 16px;
}

.food-results {
  display: grid;
  max-height: 460px;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

.food-result {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 10px 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  text-align: left;
}

.food-result:hover,
.food-result.selected {
  border-color: rgba(186, 255, 99, 0.32);
  background: rgba(186, 255, 99, 0.065);
}

.food-result strong,
.food-result small {
  display: block;
}

.food-result strong {
  font-size: 0.9rem;
}

.food-result small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.73rem;
}

.food-result-calories {
  color: var(--lime);
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.selected-food-panel {
  min-height: 340px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  background: var(--surface);
}

.selection-placeholder {
  display: grid;
  height: 100%;
  min-height: 300px;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.selection-placeholder strong {
  color: var(--text);
}

.selected-food-name h3 {
  margin: 8px 0 4px;
  font-size: 1.2rem;
}

.selected-food-name p {
  color: var(--muted);
  font-size: 0.8rem;
}

.quantity-field {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.quantity-input {
  position: relative;
}

.quantity-input input {
  width: 100%;
  height: 54px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 58px 0 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  font-size: 1.15rem;
  font-weight: 850;
}

.quantity-input span {
  position: absolute;
  top: 50%;
  right: 14px;
  color: var(--muted);
  transform: translateY(-50%);
}

.nutrition-preview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.nutrition-preview div {
  display: grid;
  gap: 3px;
  border-radius: 12px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.04);
}

.nutrition-preview span {
  color: var(--muted);
  font-size: 0.68rem;
}

.nutrition-preview strong {
  font-size: 0.9rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 24px 0;
}

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

.form-grid input,
.form-grid select {
  height: 50px;
  padding: 0 13px;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100% - 32px));
  border: 1px solid rgba(186, 255, 99, 0.25);
  border-radius: 15px;
  padding: 14px 17px;
  color: var(--text);
  background: #183023;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
}

@media (max-width: 1080px) {
  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .calorie-card {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .quick-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 780px) {
  body {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }

  .sidebar {
    display: none;
  }

  .main-content {
    width: 100%;
    margin-left: 0;
    padding: 14px 16px 40px;
  }

  .topbar {
    min-height: 58px;
    margin: -14px -16px 14px;
    padding: 10px 16px;
  }

  .meal-banner {
    min-height: 190px;
    border-radius: 24px;
  }

  .meal-banner-overlay {
    background: linear-gradient(90deg, rgba(5, 14, 26, 0.96) 0%, rgba(5, 14, 26, 0.73) 58%, rgba(5, 14, 26, 0.18) 100%);
  }

  .meal-banner img {
    object-position: 63% center;
  }

  .meal-banner-copy {
    max-width: 78%;
    padding: 28px 24px;
  }

  .meal-banner h1 {
    font-size: 2.15rem;
  }

  .meal-banner p {
    font-size: 0.9rem;
  }

  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .calorie-card {
    padding: 18px;
  }

  .calorie-content {
    gap: 18px;
  }

  .calorie-ring {
    width: 126px;
    height: 126px;
  }

  .calorie-ring::before {
    width: 98px;
    height: 98px;
  }

  .calorie-remaining strong {
    font-size: 1.9rem;
  }

  .macro-card {
    min-height: 106px;
    padding: 14px;
  }

  .macro-top {
    display: grid;
    gap: 4px;
  }

  .progress-track {
    margin-top: 13px;
  }

  .quick-grid {
    display: flex;
    overflow-x: auto;
    margin-right: -16px;
    padding: 0 16px 6px 0;
    scroll-snap-type: x mandatory;
  }

  .quick-food {
    width: 162px;
    min-width: 162px;
    scroll-snap-align: start;
  }

  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: rgba(7, 17, 31, 0.96);
    backdrop-filter: blur(18px);
  }

  .mobile-nav .nav-button {
    display: grid;
    min-height: 54px;
    place-items: center;
    gap: 2px;
    padding: 5px;
    font-size: 0.7rem;
    text-align: center;
  }

  .mobile-nav .nav-button span {
    font-size: 1rem;
  }

  .history-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-form {
    grid-template-columns: repeat(2, 1fr);
    padding: 18px;
  }

  .week-chart {
    height: 250px;
    gap: 5px;
    padding-inline: 0;
  }

  .food-picker-layout {
    grid-template-columns: 1fr;
  }

  .food-results {
    max-height: 280px;
  }

  .selected-food-panel {
    min-height: auto;
  }

  .selection-placeholder {
    min-height: 140px;
  }

  .dialog-shell {
    padding: 18px;
  }

  .toast {
    right: 16px;
    bottom: calc(86px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 470px) {
  .primary-button.compact {
    width: 42px;
    padding: 0;
    font-size: 0;
  }

  .primary-button.compact span {
    font-size: 1.2rem;
  }

  .date-button {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .calorie-card {
    grid-column: auto;
  }

  .macro-card {
    min-height: auto;
  }

  .macro-top {
    display: flex;
  }

  .meal-entry {
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    padding-inline: 14px;
  }

  .entry-macros {
    display: none;
  }

  .settings-form,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .wide-field {
    grid-column: auto;
  }

  .weight-input-row {
    flex-wrap: wrap;
  }

  .weight-input-row .primary-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.auth-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 5%, rgba(186, 255, 99, 0.14), transparent 28rem),
    radial-gradient(circle at 90% 90%, rgba(102, 181, 255, 0.12), transparent 30rem),
    #07111f;
}

.auth-card {
  display: grid;
  width: min(480px, 100%);
  justify-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 30px;
  padding: clamp(30px, 7vw, 54px);
  color: var(--text);
  background: linear-gradient(145deg, rgba(20, 36, 58, 0.98), rgba(10, 22, 39, 0.98));
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-logo {
  display: grid;
  width: 72px;
  height: 72px;
  margin-bottom: 24px;
  place-items: center;
  border-radius: 24px 11px 24px 11px;
  color: #13200a;
  background: linear-gradient(145deg, var(--lime), var(--lime-2));
  box-shadow: 0 18px 36px rgba(137, 228, 66, 0.22);
  font-size: 2rem;
  font-weight: 950;
}

.auth-card h1 {
  margin: 12px 0 14px;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1;
  letter-spacing: -0.055em;
}

.auth-card p {
  max-width: 380px;
  margin: 0;
  color: #c0cad7;
  font-size: 1rem;
  line-height: 1.6;
}

.auth-button {
  display: grid;
  width: 100%;
  min-height: 50px;
  grid-template-columns: 30px minmax(0, 1fr) 30px;
  align-items: center;
  padding: 0 14px;
  font-size: 0.94rem;
  text-decoration: none;
  transition: filter 160ms ease, transform 160ms ease;
}

.auth-options {
  display: grid;
  width: 100%;
  gap: 10px;
  margin-top: 28px;
}

.provider-icon {
  font-size: 1rem;
  text-align: left;
}

.provider-arrow {
  font-size: 1.35rem;
  text-align: right;
}

.auth-card > small {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.78rem;
}

.sidebar-account {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.account-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  color: #13200a;
  background: var(--lime);
  font-weight: 950;
}

.account-copy {
  min-width: 0;
}

.account-copy strong,
.account-copy small,
.mobile-account-head strong,
.mobile-account-head small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy strong,
.mobile-account-head strong {
  font-size: 0.82rem;
}

.account-copy small,
.mobile-account-head small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.67rem;
}

.sidebar-account > a {
  color: var(--muted);
  text-decoration: none;
}

.sync-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.67rem;
}

.sync-line i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7f8da0;
}

.sync-line[data-status="synced"] i { background: var(--lime); }
.sync-line[data-status="saving"] i { background: var(--orange); }
.sync-line[data-status="error"] i { background: var(--danger); }

.sidebar-target {
  margin-top: 12px;
}

.mobile-account-card {
  display: none;
  margin-top: 16px;
  padding: 20px;
}

.mobile-account-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-account-card .secondary-button {
  margin-top: 18px;
  text-decoration: none;
}

@media (max-width: 780px) {
  .mobile-account-card {
    display: block;
  }
}
