:root {
  --cream: #19161b;
  --paper: #26212b;
  --ink: #fff4eb;
  --green: #4d3b49;
  --lime: #c4d6a4;
  --line: #4c3d4c;
  --muted: #d0becb;
  --peach: #ffb782;
  background: var(--cream);
}
body { background: radial-gradient(ellipse at top, #29202a, var(--cream) 72%); }
main { max-width: 650px; padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
.screen-title { margin: 8px 0 18px; }
.screen-title p { color: var(--muted); margin-bottom: 8px; }
.screen-title h1 { font-size: clamp(38px, 10vw, 62px); letter-spacing: -.055em; }
.navigation {
  position: fixed; inset: auto 0 0; z-index: 20; width: min(100%, 650px);
  margin: 0 auto; padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  border: 1px solid var(--line); border-radius: 18px 18px 0 0; background: #2a212b;
}
.navigation button[aria-pressed] {
  display: grid; justify-items: center; gap: 4px; padding: 6px 2px;
  color: var(--ink); background: transparent; border: 0; box-shadow: none; margin: 0;
}
.navigation button[aria-pressed=true] { color: var(--peach); }
.navigation svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
section, .diary-panel, .feed-post, .backup-panel, #nutrition-summary details {
  background: var(--paper); border-color: var(--line); box-shadow: none;
}
button, #scan, .feed-post summary {
  color: #21151a; background: var(--peach); border-color: transparent; box-shadow: none; border-radius: 12px;
}
input, textarea, select, .meal-picker select, .profile-settings select, #favorites-meal {
  background: #201820; border-color: var(--line); color: var(--ink);
}
.week-heading, #week-days, #recipe-filters { display: flex; align-items: center; gap: 5px; margin-bottom: 12px; }
.week-heading { justify-content: space-between; }
#week-days button { flex: 1 1 0; min-width: 0; padding-inline: 1px; }
#week-days strong { display: block; }
.week-heading button, #week-days button, #recipe-filters button { background: #352936; color: var(--ink); }
#week-days button[aria-pressed=true], #recipe-filters button[aria-pressed=true] { background: var(--peach); color: #21151a; }
#day-overview { background: var(--paper); border-radius: 20px; padding: 14px; }
.overview-top { display: flex; align-items: center; gap: clamp(10px, 4vw, 24px); }
.calorie-ring {
  flex: 0 0 clamp(110px, 35vw, 165px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--lime) var(--ratio), var(--line) 0);
}
.calorie-ring div {
  display: grid; place-content: center; text-align: center; width: 84%; aspect-ratio: 1; border-radius: 50%; background: var(--paper);
}
.calorie-ring strong { font-size: clamp(24px, 8vw, 42px); }
.overview-numbers p + p { margin-top: 8px; }
.overview-macros { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
.overview-macros p { display: flex; justify-content: space-between; gap: 8px; margin: 6px 0; }
.overview-macros progress { width: 100%; height: 9px; accent-color: var(--lime); }
#open-food { width: 100%; margin-top: 12px; font-size: 17px; min-height: 48px; }
#nutrition-summary > h2, #nutrition-summary > ul, #diary-target { display: none; }
#diary-view .panels { grid-template-columns: minmax(0, 1fr); }
#diary-view .quick-panel { grid-row: auto; }
#feed-view .feed-posts { grid-template-columns: minmax(0, 1fr); }
.feed-feature img { width: 100%; height: auto; aspect-ratio: 1.16; object-fit: cover; }
.recipe-controls input { width: 100%; margin-bottom: 8px; }
#recipe-filters { flex-wrap: wrap; }
#profile-dashboard { margin-bottom: 12px; }
#profile-dashboard button { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 12px; background: #382c39; color: var(--ink); margin: 0; text-align: left; }
#profile-dashboard button + button { margin-top: 8px; }
.keyboard-done { z-index: 100; }
.profile-metrics { display: grid; gap: 12px; margin-bottom: 12px; }
.profile-metrics strong { font-size: 24px; }
.profile-metrics a { color: var(--lime); }
#profile-water progress { display: block; width: 100%; margin: 10px 0; accent-color: var(--lime); }
.water-stepper { display: flex; align-items: center; justify-content: center; gap: 18px; }
.water-stepper button { min-width: 42px; font-size: 20px; }

#meal-overview { display: grid; gap: 8px; margin-top: 12px; }
#meal-overview button { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0; padding: 10px 12px; background: var(--paper); color: var(--ink); text-align: left; }
#meal-overview button span:last-child { flex-shrink: 0; }
#profile-weight-chart { display: block; width: 100%; height: 120px; margin-top: 8px; }
@media (max-width: 360px) { .overview-top { gap: 8px; } .overview-numbers { font-size: 14px; } }
#diary-view .screen-title { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px; align-items: center; }
#diary-view .screen-title p { grid-column: 1 / -1; }
#diary-view .screen-title h1 { font-size: clamp(29px, 9vw, 55px); }
.week-heading { margin: 0; font-size: clamp(11px, 3vw, 15px); }
.week-heading button { min-height: 34px; min-width: 32px; margin: 0; padding: 4px 8px; font-size: 20px; }
#meal-overview button { min-height: 52px; }
.diary-details { margin-top: 12px; }
.diary-details > summary { padding: 8px 0; color: var(--muted); cursor: pointer; }
#food-window { box-sizing: border-box; width: min(100% - 16px, 620px); max-height: calc(100dvh - 24px); padding: 14px; background: var(--cream); color: var(--ink); border: 1px solid var(--line); border-radius: 20px; }
#food-window::backdrop { background: #120d15c9; }
.food-window-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.food-window-title h2 { margin: 0; }
body:has(#food-window[open]) { overflow: hidden; }
#food-window .panels { grid-template-columns: minmax(0, 1fr); }
#food-window .quick-panel { grid-row: auto; }
.recipe-compact h2 { margin-bottom: 6px; }
#profile-view .screen-title { position: relative; padding-right: 48px; }
#open-profile-settings { position: absolute; top: 0; right: 0; width: 38px; min-height: 38px; padding: 0; font-size: 22px; background: #382c39; color: var(--ink); }
#profile-settings-window { width: min(100% - 16px, 620px); max-height: calc(100dvh - 24px); padding: 14px; background: var(--cream); color: var(--ink); border: 1px solid var(--line); border-radius: 20px; }
#profile-settings-window::backdrop { background: #120d15c9; }
#profile-settings-window .profile-card { margin-top: 12px; }
body:has(#profile-settings-window[open]) { overflow: hidden; }
html body, html body::before, html body::after { background: #19161b; }
#week-days { touch-action: pan-y; }
#profile-settings-window > details { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
#profile-settings-window > details > summary { cursor: pointer; padding: 8px; font-weight: 700; }
.diary-panel { margin-top: 12px; }

.day-disclosure > summary, .recipe-search-toggle > summary {
  display: grid;
  place-items: center;
  width: 40px;
  height: 38px;
  border-radius: 12px;
  background: #352936;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}
.day-disclosure > summary::-webkit-details-marker,
.recipe-search-toggle > summary::-webkit-details-marker { display: none; }
.day-disclosure > summary { margin: 8px auto 0; font-size: 21px; }
.day-disclosure[open] > summary { transform: rotate(180deg); }
.recipe-search-toggle > summary { margin: 0 0 8px auto; }

#meal-overview button { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; }
#meal-overview img { width: 54px; height: 42px; object-fit: cover; border-radius: 8px; }
#feed-view .screen-title { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
#feed-view .screen-title > p { grid-column: 1 / -1; }
#feed-view .recipe-search-toggle { display: contents; }
#feed-view .recipe-search-toggle > summary { grid-column: 2; grid-row: 2; margin: 0; }
#feed-view .recipe-search-toggle > label { grid-column: 1 / -1; margin: 0; }
#recipe-search { width: 100%; }
.recipe-card > img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
.recipe-card details h3 { margin-top: 12px; }
.recipe-card li { padding: 5px 0; border: 0; }

.identity-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.identity-fields label:last-child { grid-column: 1 / -1; }
.identity-fields input, .identity-fields textarea { width: 100%; min-width: 0; font-size: 16px; }
#profile-settings-window .profile-identity { margin: 12px 0; }
.profile-fold { margin: 12px 0; padding: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; }
.profile-fold > summary { cursor: pointer; padding: 5px; font-weight: 700; }
.profile-goals { margin-top: 12px; }
#profile-goals-form input { width: 100%; }
