:root {
  color-scheme: light;
  --ink: #17221d;
  --muted: #66736c;
  --line: #dfe7e2;
  --paper: #f5f7f4;
  --card: #ffffff;
  --green: #236b4b;
  --green-soft: #dcefe4;
  --red: #9f3030;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
header { height: 72px; display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 1.15rem; font-weight: 750; text-decoration: none; letter-spacing: -.02em; }
.header-actions { display: flex; align-items: center; gap: 16px; }
.header-actions a { color: var(--muted); text-decoration: none; }
.link-button { appearance: none; border: 0; background: none; color: var(--muted); padding: 0; cursor: pointer; }
.dashboard { display: grid; grid-template-columns: minmax(330px, .9fr) minmax(430px, 1.35fr); gap: 22px; padding-bottom: 50px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 12px 35px rgba(28, 54, 41, .05); overflow: hidden; }
.panel-head { padding: 24px 26px 18px; display: flex; align-items: end; justify-content: space-between; gap: 16px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.7rem, 4vw, 2.35rem); letter-spacing: -.045em; margin-bottom: 6px; }
h2 { font-size: 1.15rem; margin: 0; }
.muted { color: var(--muted); }
.food-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.food-row { display: grid; grid-template-columns: 58px 1fr auto; gap: 12px; padding: 18px 24px; align-items: center; text-decoration: none; border-bottom: 1px solid var(--line); }
.food-row:hover, .food-row.active { background: #f6faf7; }
.time { color: var(--muted); font-size: .88rem; }
.food-name { font-weight: 700; }
.portion { color: var(--muted); font-size: .9rem; margin-top: 3px; }
.calories { font-weight: 750; font-variant-numeric: tabular-nums; }
.empty { padding: 38px 24px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); }
.calendar-wrap { padding: 0 24px 26px; }
.calendar-nav { display: flex; justify-content: space-between; align-items: center; padding: 6px 0 18px; }
.calendar-nav a { text-decoration: none; color: var(--green); font-weight: 700; }
.weekdays, .week { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekdays div { padding: 10px 3px; text-align: center; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .09em; }
.day { min-height: 85px; border: 1px solid var(--line); margin: -1px 0 0 -1px; padding: 10px; text-decoration: none; display: flex; flex-direction: column; justify-content: space-between; background: white; }
.day:hover { background: #f7faf8; }
.day.outside { color: #aeb8b2; background: #fafbfa; }
.day.today { background: var(--green-soft); color: #174b35; box-shadow: inset 0 0 0 2px var(--green); z-index: 1; }
.day.selected { box-shadow: inset 0 0 0 2px var(--ink); z-index: 2; }
.day-number { font-size: 1.4rem; font-weight: 760; }
.day-cals { font-size: .75rem; color: var(--muted); }
.form-card, .detail { padding: 26px; }
.stack { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; }
label { font-size: .82rem; color: var(--muted); font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #ccd7d0; background: white; color: var(--ink); border-radius: 9px; padding: 11px 12px; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--green-soft); border-color: var(--green); }
.button { display: inline-flex; justify-content: center; border: 0; border-radius: 9px; padding: 11px 16px; background: var(--green); color: white; font-weight: 700; cursor: pointer; text-decoration: none; }
.button.secondary { background: #e9efeb; color: var(--ink); }
.button.compact { padding: 8px 12px; color: white; }
.button.danger { background: transparent; color: var(--red); border: 1px solid #e5caca; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.add-form { padding: 20px 24px 24px; background: #fbfcfb; }
.add-grid { display: grid; grid-template-columns: 1fr 88px 96px auto; gap: 9px; align-items: end; }
.food-picker { position: relative; }
.food-search-results { position: absolute; z-index: 20; top: calc(100% + 5px); left: 0; right: 0; max-height: 310px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: 0 16px 35px rgba(28,54,41,.16); }
.food-search-option { border-bottom: 1px solid var(--line); }
.food-search-option:last-child { border-bottom: 0; }
.food-search-result { display: grid; gap: 3px; min-width: 0; width: 100%; padding: 11px 12px; border: 0; background: white; color: var(--ink); text-align: left; cursor: pointer; }
.food-search-result:hover, .food-search-result:focus { outline: 0; background: #f2f8f4; }
.food-search-result span { color: var(--muted); font-size: .78rem; }
.nutrition { margin: 10px 0 22px; border-top: 1px solid var(--line); }
.nutrition-total { display: flex; justify-content: space-between; padding: 14px 0; font-size: 1.05rem; }
.edit-hint { color: var(--muted); font-size: .82rem; margin: 6px 0 14px; }
.nutrient-edit { border-bottom: 1px solid var(--line); }
.nutrient-edit summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; padding: 12px 2px; }
.nutrient-edit summary::-webkit-details-marker { display: none; }
.nutrient-edit summary:hover { color: var(--green); }
.nutrient-edit summary strong { font-variant-numeric: tabular-nums; }
.nutrient-edit small { color: var(--green); font-weight: 700; }
.nutrient-form { display: grid; grid-template-columns: 1fr 90px auto; gap: 9px; align-items: end; padding: 5px 0 14px; }
.reset-nutrient { padding: 0 0 14px; }
.flash, .error { padding: 12px 14px; border-radius: 9px; margin-bottom: 16px; }
.flash { background: var(--green-soft); }
.error { background: #f8e1e1; color: #7d2525; }
.auth { width: min(420px, calc(100% - 32px)); margin: 10vh auto; }
.auth .panel { padding: 34px; }
.food-editor-page { width: min(760px, 100%); margin: 20px auto 50px; }
.portion-editor { display: grid; grid-template-columns: 1fr 180px; gap: 12px; }
.custom-nutrients { margin-top: 12px; border-top: 1px solid var(--line); }
.custom-nutrient { display: grid; grid-template-columns: minmax(150px,1fr) 150px 100px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.custom-nutrient label { color: var(--ink); }
.recipe-page { width: min(980px, 100%); margin: 20px auto 50px; }
.recipe-card { overflow: visible; }
.recipe-library { overflow: hidden; }
.recipe-library-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 26px; border-top: 1px solid var(--line); }
.recipe-library-row h2 { margin-bottom: 5px; }
.recipe-library-row p { margin-bottom: 0; }
.recipe-form { display: grid; gap: 24px; padding: 0 26px 28px; }
.recipe-basics { display: grid; grid-template-columns: 1fr 150px; gap: 12px; }
.recipe-builder { display: grid; gap: 14px; padding-top: 22px; border-top: 1px solid var(--line); }
.recipe-toggle { display: flex; align-items: center; gap: 8px; color: var(--ink); width: max-content; }
.recipe-toggle input { width: auto; }
.recipe-ingredients { display: grid; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.recipe-ingredient { display: grid; grid-template-columns: 24px minmax(140px,1fr) 90px 62px minmax(130px,1fr) auto; gap: 10px; align-items: center; padding: 11px 12px; border-bottom: 1px solid var(--line); background: white; }
.recipe-ingredient:last-child { border-bottom: 0; }
.recipe-ingredient.dragging { opacity: .45; }
.drag-handle { color: var(--muted); cursor: grab; user-select: none; }
.ingredient-unit { color: var(--muted); font-size: .82rem; }
.ingredient-remove { color: var(--red); }
.recipe-empty { border: 0; margin: 0; }
.recipe-profile { display: grid; grid-template-columns: minmax(190px,.55fr) 1fr; gap: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.profile-list { max-height: 360px; overflow-y: auto; border-top: 1px solid var(--line); }
.profile-row { display: flex; justify-content: space-between; gap: 20px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.profile-row strong { font-variant-numeric: tabular-nums; }
@media (max-width: 820px) {
  .dashboard { grid-template-columns: 1fr; }
  .add-grid { grid-template-columns: 1fr 1fr; }
  .day { min-height: 68px; padding: 7px; }
  .day-number { font-size: 1.05rem; }
  .day-cals { display: none; }
  .portion-editor, .custom-nutrient, .recipe-basics, .recipe-profile { grid-template-columns: 1fr; }
  .recipe-ingredient { grid-template-columns: 20px 1fr 80px 54px; }
  .recipe-ingredient input:nth-of-type(2) { grid-column: 2 / 5; }
}
