:root {
  --ink: #20352f;
  --muted: #66756f;
  --paper: #f7f5ee;
  --card: #fffefa;
  --line: #dedfd7;
  --green: #1e6c55;
  --green-dark: #15503f;
  --mint: #dfeee7;
  --terracotta: #a84635;
  --red-soft: #faebe7;
  --shadow: 0 24px 70px rgba(31, 57, 49, .09);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { min-height: 100vh; margin: 0; display: flex; flex-direction: column; background: radial-gradient(circle at 8% 8%, #e7efe7 0, transparent 29rem), var(--paper); }
a { color: var(--green); font-weight: 650; text-underline-offset: 3px; }
a:hover { color: var(--green-dark); }
button, input, select { font: inherit; }

.site-header { height: 76px; display: flex; align-items: center; justify-content: space-between; width: min(1160px, calc(100% - 40px)); margin: auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: Georgia, serif; font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: white; background: var(--green); border-radius: 11px 11px 11px 3px; font-style: italic; }
.site-nav { display: flex; align-items: center; gap: 24px; }
.site-nav form { margin: 0; }
.site-nav a, .site-nav .link-button { color: var(--ink); font-size: .92rem; text-decoration: none; }
main { width: 100%; flex: 1; }
footer { padding: 30px 20px 34px; text-align: center; color: #86918d; font-size: .78rem; letter-spacing: .03em; }

h1, h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; letter-spacing: -.035em; color: var(--ink); }
h1 { font-size: clamp(2.15rem, 5vw, 4.5rem); line-height: .98; }
h2 { font-size: 1.5rem; }
p { line-height: 1.6; }
.eyebrow { margin: 0 0 12px; color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); }
.lede { max-width: 31rem; color: #52645d; font-family: Georgia, serif; font-size: 1.25rem; line-height: 1.55; }

.auth-layout { min-height: calc(100vh - 156px); width: min(1080px, calc(100% - 40px)); margin: auto; display: grid; grid-template-columns: 1.12fr .88fr; gap: clamp(40px, 8vw, 110px); align-items: center; padding: 50px 0 80px; }
.intro-panel h1 { max-width: 600px; }
.intro-panel { position: relative; }
.intro-panel::after { content: ""; position: absolute; z-index: -1; width: 280px; height: 280px; right: 5%; top: -40px; border: 1px solid rgba(30, 108, 85, .12); border-radius: 50% 48% 45% 53%; transform: rotate(12deg); }
.privacy-note { display: inline-flex; align-items: center; gap: 10px; margin-top: 28px; padding: 12px 16px; border: 1px solid #cedbd3; border-radius: 99px; color: var(--green-dark); background: rgba(255, 255, 255, .45); font-size: .83rem; }
.privacy-note span { font-size: .55rem; }

.card { border: 1px solid rgba(205, 210, 201, .85); background: rgba(255, 254, 250, .93); box-shadow: var(--shadow); border-radius: 24px; }
.auth-card { padding: clamp(28px, 5vw, 46px); }
.auth-card h2 { font-size: 2.35rem; }
.auth-card > .muted { margin: 10px 0 26px; }
.form-card { width: min(520px, 100%); padding: clamp(28px, 5vw, 48px); }
.form-card h1 { font-size: clamp(2.1rem, 8vw, 3.2rem); }
.form-card > .muted { margin: 13px 0 28px; }

form { margin-top: 22px; }
label { display: block; margin: 16px 0; color: #43534e; font-size: .82rem; font-weight: 750; letter-spacing: .015em; }
input, select { display: block; width: 100%; margin-top: 8px; padding: 13px 14px; color: var(--ink); background: #fff; border: 1px solid #cfd5d0; border-radius: 10px; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(30, 108, 85, .12); }
.code-input { text-align: center; font: 700 1.65rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .35em; padding-left: calc(14px + .35em); }
.button { display: inline-flex; min-height: 43px; align-items: center; justify-content: center; padding: 10px 17px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; font-weight: 750; font-size: .88rem; transition: transform .12s, background .12s; }
.button:hover { transform: translateY(-1px); }
.primary { color: white; background: var(--green); box-shadow: 0 8px 20px rgba(30, 108, 85, .18); }
.primary:hover { color: white; background: var(--green-dark); }
.secondary { color: var(--green-dark); background: #edf5f0; border-color: #c5d8ce; }
.danger { color: white; background: var(--terracotta); }
.danger-outline { color: var(--terracotta); border-color: #d9aaa0; background: transparent; }
.full { width: 100%; margin-top: 8px; }
.link-button { padding: 0; color: var(--green); background: none; border: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-weight: 650; }
.form-row { display: flex; justify-content: flex-end; margin: -4px 0 16px; font-size: .82rem; }
.card-foot { margin: 24px 0 0; padding-top: 21px; border-top: 1px solid #e3e4dd; color: var(--muted); text-align: center; font-size: .85rem; }
.resend-form { margin: 18px 0 0; text-align: center; }

.single-column { min-height: calc(100vh - 156px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; width: min(600px, calc(100% - 40px)); margin: auto; padding: 35px 0 65px; }
.stepper { width: min(360px, 75vw); display: flex; align-items: center; justify-content: center; }
.stepper span { display: grid; place-items: center; flex: 0 0 30px; height: 30px; border: 1px solid #c4cbc5; border-radius: 50%; color: #89938e; background: var(--paper); font-size: .74rem; font-weight: 800; }
.stepper span.active { color: white; border-color: var(--green); background: var(--green); box-shadow: 0 0 0 5px rgba(30, 108, 85, .1); }
.stepper span.done { color: var(--green); border-color: #a9c3b5; background: var(--mint); }
.stepper i { height: 1px; flex: 1; background: #cbd0cb; }
.stepper i.done { background: #88b19e; }
.message { margin: 20px 0; padding: 12px 14px; border-radius: 10px; font-size: .86rem; line-height: 1.45; }
.message.error { color: #7c3025; background: var(--red-soft); border: 1px solid #efd0c8; }
.message.success { color: #205b47; background: #e7f3ec; border: 1px solid #c6dfd2; }
.dev-code { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center; margin: 22px 0; padding: 15px 17px; border: 1px dashed #b5cbbf; border-radius: 12px; background: #f0f7f3; }
.dev-code span { color: var(--green); font-size: .69rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.dev-code strong { grid-row: span 2; font: 750 1.55rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.dev-code small { color: var(--muted); font-size: .72rem; }

.profile-shell { width: min(1030px, calc(100% - 40px)); margin: auto; padding: 55px 0 75px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 34px; }
.page-heading h1 { font-size: clamp(2.6rem, 6vw, 4rem); }
.page-heading .muted { margin: 10px 0 0; }
.avatar { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 21px 21px 21px 7px; color: white; background: var(--green); font-family: Georgia, serif; font-size: 2rem; text-transform: uppercase; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.setting-card { padding: 28px; box-shadow: 0 12px 40px rgba(31, 57, 49, .055); }
.setting-card.wide { grid-column: 1 / -1; }
.setting-heading { display: flex; gap: 14px; align-items: flex-start; padding-bottom: 17px; border-bottom: 1px solid #e4e5df; }
.setting-heading .icon { display: grid; place-items: center; flex: 0 0 37px; height: 37px; border-radius: 10px; color: var(--green); background: var(--mint); font-weight: 800; }
.setting-heading h2 { font-size: 1.25rem; }
.setting-heading p { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }
.current-value { margin: 19px 0 4px; font-weight: 750; overflow-wrap: anywhere; }
.setting-card form { margin-top: 10px; }
.password-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: end; }
.password-grid label { margin: 8px 0 0; }
.password-grid .button { grid-column: 1 / -1; justify-self: start; }
.danger-row { display: flex; justify-content: space-between; align-items: center; margin-top: 26px; padding: 26px 28px; border-top: 1px solid #ddc7c1; border-bottom: 1px solid #ddc7c1; }
.danger-row h2 { font-size: 1.2rem; color: #71372e; }
.danger-row p { margin: 4px 0 0; color: var(--muted); font-size: .82rem; }
.danger-card { border-color: #e5c7bf; }
.danger-symbol { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 21px; border-radius: 50%; color: var(--terracotta); background: var(--red-soft); font: 800 1.25rem Georgia, serif; }
.danger-text { color: var(--terracotta); }
.search-form { max-width: 630px; margin: 0 0 24px; }
.search-form > label { margin-bottom: 8px; }
.search-form > div { display: flex; gap: 10px; }
.search-form input { margin: 0; }
.table-card { overflow: hidden; box-shadow: 0 12px 40px rgba(31, 57, 49, .055); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 17px 20px; border-bottom: 1px solid #e7e7e0; text-align: left; font-size: .85rem; }
th { color: var(--muted); background: #f4f5ef; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.status { display: inline-block; padding: 5px 9px; border-radius: 99px; font-size: .7rem; font-weight: 800; text-transform: capitalize; }
.status.active { color: #1d634b; background: #e1f0e8; }
.status.disabled { color: #8b3e31; background: #f6e7e3; }
.empty-state { padding: 50px 20px; color: var(--muted); text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.narrow-shell { max-width: 760px; }
.back-link { margin: 0 0 28px; font-size: .82rem; }
.account-summary { padding: 10px 28px; box-shadow: 0 12px 40px rgba(31, 57, 49, .055); }
.account-summary dl { display: grid; grid-template-columns: 1fr 1fr; margin: 0; }
.account-summary dl div { padding: 20px 0; border-bottom: 1px solid #e7e7e0; }
.account-summary dl div:nth-last-child(-n+2) { border-bottom: 0; }
.account-summary dt { margin-bottom: 5px; color: var(--muted); font-size: .7rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.account-summary dd { margin: 0; font-size: .9rem; font-weight: 650; }
.admin-action { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-top: 20px; padding: 25px 28px; box-shadow: none; }
.admin-action h2 { font-size: 1.2rem; }
.admin-action p { margin: 5px 0 0; color: var(--muted); font-size: .8rem; }
.admin-action form { flex: 0 0 auto; margin: 0; }
.admin-action.destructive { align-items: flex-start; border-color: #e5c7bf; }
.admin-action.destructive form { width: 250px; }
.admin-action.destructive label { margin-top: 0; }

/* Food diary: daily progress and meals share a compact reading rhythm. */
.diary-shell { width: min(1120px, calc(100% - 48px)); margin: auto; padding: 38px 0 64px; }
.diary-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.diary-header h1 { font-size: clamp(2.4rem, 5vw, 3.25rem); }
.diary-header .eyebrow { margin-bottom: 10px; }
.diary-actions { display: flex; gap: 10px; }
.compact { min-height: 40px; padding: 8px 13px; font-size: .82rem; }
.date-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.date-current { display: flex; align-items: center; gap: 18px; flex: 1; }
.date-current > strong { font-size: 1rem; }
.date-arrow { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; background: var(--card); }
.date-arrow:last-child { order: 0; }
.date-current { order: 1; }
.date-picker { position: relative; margin-left: auto; font-size: .82rem; }
.date-picker summary { padding: 10px 0; cursor: pointer; color: var(--green); font-weight: 650; }
.date-picker form { position: absolute; z-index: 3; right: 0; top: 100%; width: 270px; margin: 6px 0 0; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.date-picker label { margin: 0; }
.date-picker button { width: 100%; margin-top: 12px; }
.today-link { display: inline-block; margin: -7px 0 20px; font-size: .82rem; }
.nutrition-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); overflow: hidden; }
.summary-card { padding: 22px; border-right: 1px solid var(--line); --nutrient-color: var(--green); }
.summary-card:last-child { border-right: 0; }
.summary-card.nutrient-calories { background: #edf4ee; }
.nutrient-fat { --nutrient-color: #ae7838; }
.nutrient-carbohydrate { --nutrient-color: #568caa; }
.nutrient-protein { --nutrient-color: #8a729b; }
.summary-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; font-weight: 650; }
.summary-label::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--nutrient-color); }
.summary-value { margin: 12px 0; font-size: 2rem; font-weight: 650; line-height: 1; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.summary-value small { font-size: .8rem; letter-spacing: 0; font-weight: 500; color: var(--muted); }
.summary-meta { margin: 9px 0 0; color: var(--muted); font-size: .73rem; line-height: 1.6; }
.summary-meta strong { color: var(--ink); font-weight: 650; }
.summary-meta a { font-weight: 500; }
.over-target .summary-meta strong { color: var(--terracotta); }
.progress-meter { display: block; width: 100%; height: 6px; border: 0; border-radius: 4px; background: #e5e8e1; }
.progress-meter::-webkit-meter-bar { height: 6px; border: 0; border-radius: 4px; background: #e5e8e1; }
.progress-meter::-webkit-meter-optimum-value { background: var(--nutrient-color, var(--green)); border-radius: 4px; }
.progress-meter::-moz-meter-bar { background: var(--nutrient-color, var(--green)); border-radius: 4px; }
.incomplete { display: inline-block; padding: 2px 5px; border-radius: 4px; color: #78551d; background: #f5ead4; font-size: .65rem; font-weight: 600; vertical-align: middle; }
.daily-caveat { margin: -14px 0 25px; color: #78551d; font-size: .8rem; }
.diary-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.meal-stack { display: grid; gap: 14px; }
.meals-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1px; }
.meals-title h2 { font-size: 1.3rem; }
.meals-title > span { color: var(--muted); font-size: .78rem; }
.meal-card { border-radius: 14px; box-shadow: none; overflow: hidden; }
.meal-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; }
.meal-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.meal-heading h2 { font-family: inherit; font-size: .96rem; letter-spacing: 0; }
.meal-total { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.meal-heading .button { background: transparent; box-shadow: none; border-color: #cfddd3; }
.meal-empty { padding: 0 20px 16px; color: var(--muted); font-size: .8rem; }
.meal-empty p { margin: 0; }
.entry-list { padding: 0 20px; }
.diary-entry { position: relative; padding: 16px 0 14px; border-top: 1px solid #e8e9e2; }
.entry-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; }
.entry-main h3 { margin: 0; font-size: .9rem; font-weight: 650; line-height: 1.4; }
.entry-main p { margin: 4px 0 0; color: var(--muted); font-size: .75rem; }
.entry-main p.entry-portion { color: var(--ink); }
.entry-main p.entry-macros { margin-top: 7px; font-size: .7rem; }
.entry-calories { text-align: right; font-variant-numeric: tabular-nums; }
.entry-calories strong { font-size: 1rem; font-weight: 650; }
.entry-calories span { display: block; color: var(--muted); font-size: .67rem; margin-top: 3px; }
.entry-edit { margin-top: 4px; }
.entry-edit > summary { position: absolute; top: 58px; right: -8px; padding: 8px; color: var(--green); font-size: .75rem; cursor: pointer; list-style: none; }
.entry-edit > summary::-webkit-details-marker { display: none; }
.entry-edit[open] > summary { text-decoration: underline; }
.entry-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 16px; margin: 14px 0 0; padding: 16px; background: #f3f5ef; border-radius: 10px; font-size: .8rem; }
.entry-controls form { display: flex; gap: 8px; align-items: end; margin: 0; }
.entry-controls label { margin: 0; font-size: .72rem; }
.entry-controls label > span { display: block; max-width: 160px; }
.entry-controls input, .entry-controls select { width: auto; padding: 9px; height: 40px; margin-top: 7px; font-size: .8rem; }
.entry-controls .amount-input { width: 90px; }
.entry-controls .measure-name { padding-bottom: 12px; font-size: .75rem; }
.entry-controls > a, .entry-controls .danger-link { padding: 12px 0; }
.danger-link { color: var(--terracotta); }
.copy-meal { padding: 0 20px 6px; border-top: 1px solid #ecece5; color: var(--muted); font-size: .75rem; }
.copy-meal > summary { cursor: pointer; width: fit-content; padding: 10px 0 5px; }
.copy-meal form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; align-items: end; }
.copy-meal form button { grid-column: 1 / -1; justify-self: start; }
.copy-meal label { margin: 0; font-size: .75rem; }
.copy-meal input, .copy-meal select { padding: 10px; min-width: 0; font-size: .8rem; }
.nutrition-detail { display: grid; gap: 16px; margin-top: 39px; }
.detail-card { padding: 22px; border-radius: 14px; box-shadow: none; }
.detail-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.detail-heading h2, .macro-card h2 { font-size: 1.2rem; }
.detail-heading a { font-size: .72rem; }
.nutrient-list { margin: 18px 0 0; }
.nutrient-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #ecece5; font-size: .76rem; }
.nutrient-list > div:last-child { border: 0; }
.nutrient-list dt { color: var(--muted); }
.nutrient-list dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.unknown-note { color: var(--muted); font-size: .7rem; margin: 18px 0 0; }
.macro-card > p { font-size: .8rem; }
.macro-shares { display: grid; gap: 14px; margin-top: 20px; }
.macro-shares > div { display: grid; grid-template-columns: 100px 1fr 35px; align-items: center; gap: 12px; font-size: .75rem; }
.macro-shares > div:nth-child(1) { --nutrient-color: #ae7838; }
.macro-shares > div:nth-child(2) { --nutrient-color: #568caa; }
.macro-shares > div:nth-child(3) { --nutrient-color: #8a729b; }
.macro-shares strong { text-align: right; font-weight: 600; }
/* Logging keeps selection and portion entry together. */
.add-food-shell { max-width: 820px; }
.add-food-shell .back-link { display: flex; justify-content: space-between; gap: 16px; font-size: .8rem; margin: 0 0 28px; }
.back-link > span { color: var(--muted); }
.add-heading { margin-bottom: 24px; align-items: center; }
.add-heading h1 { font-size: 2.6rem; }
.add-heading .eyebrow { margin-bottom: 9px; }
.create-actions { display: flex; gap: 20px; font-size: .8rem; }
.meal-tabs { display: flex; gap: 4px; padding: 5px; background: #eaece4; border-radius: 12px; overflow-x: auto; margin-bottom: 26px; }
.meal-tabs a { flex: 1 0 auto; text-align: center; padding: 10px 14px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .83rem; font-weight: 600; }
.meal-tabs a[aria-current] { background: var(--card); color: var(--green-dark); box-shadow: 0 2px 5px #20352f0c; }
.food-search { padding: 0; margin: 0 0 18px; }
.food-search label { font-size: .8rem; margin: 0 0 9px; }
.food-search > div { display: flex; gap: 8px; }
.food-search input { margin: 0; min-width: 0; padding: 15px; }
.clear-search { display: inline-block; margin-top: 10px; font-size: .8rem; }
.quick-entry { margin: 0 0 28px; border-bottom: 1px solid var(--line); font-size: .82rem; }
.quick-entry > summary { display: flex; justify-content: space-between; gap: 15px; padding: 8px 0 18px; color: var(--muted); cursor: pointer; list-style: none; }
.quick-entry > summary::-webkit-details-marker { display: none; }
.quick-entry > summary strong { color: var(--green); font-weight: 650; }
.quick-entry-body { padding: 0 0 22px; }
.quick-entry-body p { margin: 0; font-size: .8rem; }
.quick-entry-body form { margin: 0; }
.quick-main { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.optional-macros { margin-bottom: 18px; }
.optional-macros > summary { padding: 8px 0; cursor: pointer; color: var(--green); }
.manual-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.food-section { margin-top: 26px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 16px; }
.section-heading h2 { font-size: 1.4rem; }
.section-heading p { font-size: .8rem; margin: 6px 0 0; }
.food-result-list, .food-library-list { display: grid; gap: 10px; }
.food-result { border: 1px solid var(--line); border-radius: 12px; background: var(--card); overflow: hidden; }
.food-result > summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; cursor: pointer; padding: 18px 20px; list-style: none; }
.food-result > summary::-webkit-details-marker { display: none; }
.food-result > summary:hover { background: #f2f6ef; }
.food-result[open] { border-color: #9bb8a7; }
.food-result[open] > summary { background: #eff5ed; }
.food-result h3 { margin: 0; font-size: .92rem; line-height: 1.45; font-weight: 650; }
.food-result-copy { min-width: 0; overflow-wrap: anywhere; }
.food-result-copy p, .library-food p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; }
.food-result-copy .food-reference { margin-top: 9px; color: var(--ink); font-size: .75rem; }
.food-reference span { color: var(--muted); }
.select-food { flex-shrink: 0; color: var(--green); font-size: .8rem; font-weight: 650; }
.select-food .close-label { display: none; }
.food-result[open] .choose-label { display: none; }
.food-result[open] .close-label { display: inline; }
.food-selection { padding: 20px; }
.portion-form { margin: 0; }
.portion-fields { display: grid; grid-template-columns: 110px minmax(120px, 1fr) 160px; align-items: end; gap: 12px; }
.portion-fields label { margin: 0; }
.portion-fields input, .portion-fields select { min-width: 0; }
.portion-preview { padding-bottom: 6px; text-align: right; }
.portion-preview output { display: block; font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.portion-preview > span { font-size: .72rem; color: var(--muted); }
.portion-actions { display: flex; gap: 10px; margin-top: 20px; }
.food-selection-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); margin-top: 20px; padding-top: 14px; font-size: .72rem; color: var(--muted); overflow-wrap: anywhere; }
.food-tags { display: flex; gap: 6px; margin-bottom: 6px; }
.food-tags span { padding: 3px 7px; border-radius: 99px; color: var(--green-dark); background: var(--mint); font-size: .65rem; }
.search-welcome { text-align: center; padding: 35px 0 65px; }
.search-symbol { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 20px; border-radius: 50%; background: #e6ece1; color: var(--green); font-size: 2.5rem; }
.search-welcome h2 { font-size: 1.6rem; }
.search-welcome p { font-size: .85rem; color: var(--muted); }
.target-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.target-grid label span, .nutrition-form-grid label span { float: right; color: var(--muted); font-size: .65rem; font-weight: 500; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid #659e86; outline-offset: 4px; border-radius: 5px; }
.site-nav a[aria-current] { color: var(--green); text-decoration: underline; text-underline-offset: 8px; }
.settings-shell { max-width: 920px; }
.target-grid { margin-bottom: 18px; }
.meal-settings { display: grid; gap: 7px; margin: 19px 0; }
.meal-setting { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: center; padding: 9px 12px; border: 1px solid #e4e6df; border-radius: 10px; }
.meal-setting label { margin: 0; }
.meal-setting input { margin: 0; }
.check-label { display: flex; align-items: center; gap: 8px; }
.check-label input { width: 17px; height: 17px; }
.check-label span { font-size: .72rem; }
.library-food { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 22px; box-shadow: 0 7px 24px rgba(31,57,49,.04); }
.library-food h2 { font-size: 1.08rem; }
.library-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.library-actions form { margin: 0; }
.food-form-shell { max-width: 900px; }
.food-definition-form { padding: 30px; }
.food-definition-form > section { padding: 5px 0 28px; margin-bottom: 26px; border-bottom: 1px solid #e4e5df; }
.food-definition-form h2 { font-size: 1.25rem; }
.food-definition-form .eyebrow { margin-bottom: 5px; }
.form-grid, .nutrition-form-grid { display: grid; gap: 0 14px; margin-top: 14px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: .6fr 1fr 1fr; }
.nutrition-form-grid { grid-template-columns: repeat(4, 1fr); }
.alternative-measures { margin-top: 17px; padding: 14px 16px; border: 1px solid #e3e6df; border-radius: 12px; background: #fafaf6; }
.alternative-measures summary { cursor: pointer; font-size: .78rem; font-weight: 750; }
.alternative-measures > p { margin: 6px 0 2px; font-size: .7rem; }
.form-grid.alternative-row { grid-template-columns: 1fr .8fr .65fr; margin-top: 5px; }
.form-submit { display: flex; align-items: center; gap: 18px; }
.recipe-heading-grid { grid-template-columns: 1.5fr .55fr 1fr .8fr; }
.recipe-help { margin: 5px 0 14px; font-size: .76rem; }
.recipe-ingredients { display: grid; gap: 8px; }
.recipe-row { display: grid; grid-template-columns: 1fr 140px; gap: 9px; }
.recipe-row label { margin: 0; }
.recipe-row select, .recipe-row input { margin: 0; }

@media (max-width: 760px) {
  .site-header { height: 66px; width: min(100% - 28px, 1160px); }
  .auth-layout { display: block; width: min(100% - 28px, 520px); padding: 35px 0 60px; }
  .intro-panel { margin-bottom: 35px; }
  .intro-panel h1 { font-size: 3.2rem; }
  .intro-panel .lede, .intro-panel::after { display: none; }
  .privacy-note { margin-top: 16px; }
  .single-column, .profile-shell { width: min(100% - 28px, 600px); }
  .settings-grid { grid-template-columns: 1fr; }
  .setting-card.wide { grid-column: auto; }
  .password-grid { grid-template-columns: 1fr; }
  .password-grid .button { grid-column: auto; width: 100%; }
  .page-heading { align-items: flex-end; }
  .avatar { width: 51px; height: 51px; border-radius: 16px 16px 16px 5px; }
  .danger-row { align-items: flex-start; gap: 18px; flex-direction: column; }
  .table-card { overflow-x: auto; }
  table { min-width: 650px; }
  .account-summary dl { grid-template-columns: 1fr; }
  .account-summary dl div:nth-last-child(-n+2) { border-bottom: 1px solid #e7e7e0; }
  .account-summary dl div:last-child { border-bottom: 0; }
  .admin-action { align-items: stretch; flex-direction: column; }
  .admin-action.destructive form { width: 100%; }
  .site-nav { gap: 13px; }
  .site-nav a, .site-nav .link-button { font-size: .77rem; }
  .site-nav a[href="/profile"] { display: none; }
  .diary-shell { width: min(100% - 24px, 600px); padding-top: 25px; }
  .target-grid, .nutrition-form-grid { grid-template-columns: 1fr 1fr; }
  .meal-setting { grid-template-columns: 95px 1fr; }
  .library-food { align-items: flex-start; flex-direction: column; }
  .library-actions { flex-wrap: wrap; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .form-grid.alternative-row { grid-template-columns: 1fr; }
  .recipe-heading-grid { grid-template-columns: 1fr; }
  .recipe-row { grid-template-columns: 1fr 105px; }
  .food-definition-form { padding: 22px; }
}

@media (max-width: 430px) {
  .brand span:last-child { display: none; }
  .meal-setting { grid-template-columns: 1fr; }
}

.search-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin: 1rem 0; }

@media (max-width: 900px) {
  .diary-grid { grid-template-columns: minmax(0, 1fr); }
  .nutrition-detail { grid-template-columns: 1fr 1fr; margin-top: 4px; align-items: start; }
  .summary-card { padding: 18px; }
}
@media (max-width: 600px) {
  .diary-shell { width: calc(100% - 32px); padding-top: 24px; }
  .diary-header { gap: 10px; margin-bottom: 24px; }
  .diary-header h1 { font-size: 2.3rem; }
  .diary-header .eyebrow { font-size: .62rem; }
  .diary-actions .button { padding: 9px 10px; font-size: .72rem; }
  .date-nav { gap: 8px; align-items: start; }
  .date-current { flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
  .date-current > strong { font-size: .82rem; padding-top: 2px; }
  .date-picker { margin-left: 0; }
  .date-picker summary { padding: 5px 0; font-size: .75rem; }
  .date-picker form { right: auto; left: -95px; }
  .nutrition-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 24px; }
  .summary-card { padding: 16px; }
  .summary-card:nth-child(2) { border-right: 0; }
  .summary-card:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .summary-label { font-size: .73rem; gap: 6px; }
  .summary-value { font-size: 1.75rem; margin: 10px 0; }
  .summary-meta { font-size: .68rem; }
  .nutrition-detail { grid-template-columns: 1fr; }
  .meal-heading { padding: 14px 16px; }
  .meal-title { flex-direction: column; gap: 4px; }
  .entry-list { padding: 0 16px; }
  .entry-main { gap: 12px; }
  .entry-main h3 { font-size: .85rem; }
  .entry-main p.entry-macros { max-width: calc(100% - 20px); font-size: .65rem; }
  .entry-controls { padding: 12px; flex-direction: column; align-items: stretch; }
  .entry-controls form { flex-wrap: wrap; }
  .entry-controls select { max-width: 170px; }
  .entry-controls .measure-name { max-width: 80px; overflow-wrap: anywhere; }
  .copy-meal { padding-left: 16px; padding-right: 16px; }
  .add-food-shell .back-link { flex-direction: column; gap: 8px; margin-bottom: 22px; }
  .add-heading { flex-direction: column; align-items: flex-start; gap: 18px; }
  .add-heading h1 { font-size: 2.4rem; }
  .create-actions { gap: 22px; }
  .meal-tabs { margin-bottom: 22px; }
  .meal-tabs a { padding: 10px 12px; font-size: .78rem; }
  .food-search input { padding: 13px 10px; font-size: .85rem; }
  .food-search .button { padding: 10px 13px; }
  .quick-entry > summary { font-size: .76rem; }
  .food-result > summary { padding: 16px; gap: 12px; }
  .food-result h3 { font-size: .85rem; }
  .food-source { display: none; }
  .select-food { font-size: .72rem; }
  .food-selection { padding: 16px; }
  .portion-fields { grid-template-columns: 90px minmax(0, 1fr); }
  .portion-preview { grid-column: 1 / -1; text-align: left; display: flex; align-items: baseline; gap: 8px; padding: 4px 0 0; }
  .portion-actions { flex-direction: column; margin-top: 14px; }
  .food-selection-meta { flex-direction: column; gap: 10px; }
  .manual-grid { gap: 8px; }
  .manual-grid input { padding: 12px 8px; }
  .daily-caveat { font-size: .74rem; }
}
.usual-portion { margin: 0 0 16px; color: var(--muted); font-size: .75rem; }

.add-food-shell .search-pagination { margin: 10px 0 16px; font-size: .78rem; }
.add-food-shell .search-pagination p { margin: 0; }
@media (max-width: 600px) {
  .add-food-shell .search-pagination { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .add-food-shell .search-pagination p { grid-column: 1 / -1; order: -1; }
  .add-food-shell .search-pagination a:last-child { grid-column: 2; }
}
