:root {
  --bg: #0a0a0f;
  --bg-elev: #14141d;
  --bg-row: #101019;
  --border: #2a2a3a;
  --fg: #d0d0e0;
  --fg-dim: #6a6a7e;
  --neon-green: #39ff14;
  --neon-pink: #ff10f0;
  --neon-cyan: #00f0ff;
  --neon-yellow: #f5ff00;
  --danger: #ff3860;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.5;
}

body {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

nav {
  border-bottom: 1px solid var(--neon-green);
  padding: .5rem 0;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 1.25rem;
  align-items: center;
}
nav a {
  color: var(--neon-green);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  text-shadow: 0 0 6px rgba(57, 255, 20, .4);
}
nav a:hover { color: var(--neon-pink); text-shadow: 0 0 8px rgba(255, 16, 240, .5); }
nav .brand {
  color: var(--neon-pink);
  text-shadow: 0 0 8px rgba(255, 16, 240, .5);
}

h1, h2, h3 {
  color: var(--neon-cyan);
  text-transform: uppercase;
  letter-spacing: .1em;
  text-shadow: 0 0 10px rgba(0, 240, 255, .35);
  margin-top: 0;
}
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--neon-yellow); text-shadow: 0 0 6px rgba(245, 255, 0, .3); }

a { color: var(--neon-cyan); }
a:hover { color: var(--neon-pink); }

input, button, select {
  font-family: inherit;
  font-size: 15px;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: .55rem .75rem;
  outline: none;
}

/* hide the spinner arrows on number inputs */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input:focus, select:focus {
  border-color: var(--neon-green);
  box-shadow: 0 0 0 1px var(--neon-green), 0 0 8px rgba(57, 255, 20, .35);
}

input::placeholder { color: var(--fg-dim); }

button {
  cursor: pointer;
  color: var(--neon-green);
  border-color: var(--neon-green);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .3rem .7rem;
  transition: all .08s ease;
}
button:hover {
  color: var(--bg);
  background: var(--neon-green);
  box-shadow: 0 0 10px rgba(57, 255, 20, .6);
}
button.danger, button[hx-delete] {
  color: var(--danger);
  border-color: var(--danger);
}
button.danger:hover, button[hx-delete]:hover {
  color: var(--bg);
  background: var(--danger);
  box-shadow: 0 0 10px rgba(255, 56, 96, .55);
}

/* ---- nutrition search (AI interaction = cyan/blue theme) ---- */
.search-row {
  border: 1px dashed var(--neon-cyan);
  padding: .75rem 1rem;
  margin-bottom: 1.5rem;
  background: rgba(0, 240, 255, .03);
}
#food-search {
  display: flex;
  gap: .75rem;
  align-items: flex-end;
}
#food-search .field-name { flex: 1; }
#food-search .field-name input {
  width: 100%;
  border-color: var(--neon-cyan);
}
#food-search .field-name input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 1px var(--neon-cyan), 0 0 8px rgba(0, 240, 255, .3);
}
#food-search label > span {
  display: block;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--neon-cyan);
  text-shadow: 0 0 4px rgba(0, 240, 255, .3);
  margin-bottom: .25rem;
}
/* button + indicator share padding/border so swapping one for the other
   doesn't shift the row vertically when the request fires. */
#food-search button[type=submit],
#search-indicator {
  padding: .55rem 1.25rem;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .08em;
  border: 1px solid var(--neon-cyan);
  line-height: 1.2;
}
#food-search button[type=submit] {
  color: var(--neon-cyan);
  background: var(--bg-elev);
  text-shadow: 0 0 4px rgba(0, 240, 255, .3);
}
#food-search button[type=submit]:hover {
  color: var(--bg);
  background: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, .55);
}
#search-indicator {
  color: var(--neon-cyan);
  border-style: dashed;
  background: transparent;
  animation: pulse 1s ease-in-out infinite;
}
/* htmx adds .htmx-request to the form while the request is in flight:
   hide the button, show the indicator in its slot. */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }
#food-search:has(#search-indicator.htmx-request) button[type=submit] { display: none; }
@keyframes pulse {
  0%, 100% { opacity: .4; }
  50% { opacity: 1; }
}

#search-results { margin-top: .75rem; }
.search-error {
  padding: .5rem .75rem;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: rgba(255, 56, 96, .06);
}
.search-empty {
  padding: .5rem .75rem;
  color: var(--fg-dim);
  font-style: italic;
}

.candidates {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.candidate {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  background: var(--bg);
}
.candidate:hover { border-color: var(--neon-green); }
.cand-text {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 14rem;
  align-items: baseline;
  gap: .25rem 1rem;
}
.cand-name {
  color: var(--neon-green);
  text-shadow: 0 0 4px rgba(57, 255, 20, .3);
}
.cand-desc {
  color: var(--fg-dim);
  font-size: .85em;
  grid-column: 1 / 2;
}
.cand-macros {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
  color: var(--neon-cyan);
  font-size: .85em;
  font-variant-numeric: tabular-nums;
  text-align: right;
  align-self: center;
}
.cand-add { margin: 0; }
.cand-add button { padding: .35rem .75rem; }

/* ---- new-food form ---- */
#new-food {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
#new-food label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
#new-food label > span {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--neon-cyan);
  text-shadow: 0 0 4px rgba(0, 240, 255, .3);
}
#new-food .field-name { flex: 1; min-width: 16rem; }
#new-food .field-name input { width: 100%; }
#new-food input[type=number] { width: 7rem; }
#new-food button[type=submit] { align-self: flex-end; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--neon-green);
  background: var(--bg-elev);
}
th, td {
  text-align: left;
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--border);
}
thead th {
  color: var(--neon-pink);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .85em;
  background: var(--bg);
  border-bottom: 1px solid var(--neon-pink);
  text-shadow: 0 0 6px rgba(255, 16, 240, .35);
}
tbody tr:hover { background: var(--bg-row); }
tbody tr:last-child td { border-bottom: none; }
tr.editing { background: var(--bg-row); }
tr.editing input { width: 100%; }
tr.editing input[type=number] { width: 5rem; }

td.actions { text-align: right; white-space: nowrap; }
td.actions button { margin-left: .35rem; }
td.cals {
  color: var(--neon-yellow);
  text-shadow: 0 0 5px rgba(245, 255, 0, .35);
  font-variant-numeric: tabular-nums;
}
td.serving { color: var(--fg-dim); font-size: .9em; white-space: nowrap; }
td.serving-edit { white-space: nowrap; }
td.serving-edit .unit-input { width: 6rem; margin-right: .25rem; }
td.serving-edit .grams-input { width: 5rem; }

::selection {
  background: var(--neon-pink);
  color: var(--bg);
}

/* glow scanline header bar (subtle) */
nav::before {
  content: "▶";
  color: var(--neon-pink);
  text-shadow: 0 0 6px var(--neon-pink);
}

/* ---- day view ---- */
.day-header {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 1rem;
}
.day-nav {
  display: flex;
  gap: 1.5rem;
  font-size: .85em;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.day-nav a {
  color: var(--fg-dim);
  text-decoration: none;
}
.day-nav a:hover { color: var(--neon-pink); text-shadow: 0 0 6px rgba(255,16,240,.4); }
.day-date {
  color: var(--fg-dim);
  font-size: .85em;
}

.totals {
  display: block;
  padding: .75rem 1rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--neon-yellow);
  background: var(--bg-elev);
  box-shadow: 0 0 12px rgba(245, 255, 0, .12) inset;
}
.totals-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: .5rem;
}
.totals-label {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .75rem;
  color: var(--fg-dim);
}
.totals-edit {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--fg-dim);
  text-decoration: none;
}
.totals-edit:hover { color: var(--neon-pink); }
.totals-bars {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  font-variant-numeric: tabular-nums;
}
.t-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr 7rem;
  align-items: center;
  gap: .75rem;
  font-size: .9rem;
}
.t-key {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .7rem;
  color: var(--fg-dim);
}
.t-bar {
  height: .55rem;
  border: 1px solid var(--border);
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.t-fill {
  height: 100%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  transition: width .2s ease;
}
.t-bar.over { border-color: var(--danger); }
.t-bar.over .t-fill { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.t-vals {
  text-align: right;
  font-size: .9rem;
}
.t-of { color: var(--fg-dim); font-size: .85em; }

/* per-macro color */
.t-cals    { color: var(--neon-yellow); }
.t-carbs   { color: var(--neon-cyan); }
.t-protein { color: var(--neon-green); }
.t-fat     { color: var(--neon-pink); }
.t-alc     { color: #c89bff; } /* ethanol-purple, no neon partner needed */
.t-cals    .t-vals { text-shadow: 0 0 6px rgba(245, 255, 0, .35); }
.t-carbs   .t-vals { text-shadow: 0 0 5px rgba(0, 240, 255, .3); }
.t-protein .t-vals { text-shadow: 0 0 5px rgba(57, 255, 20, .3); }
.t-fat     .t-vals { text-shadow: 0 0 5px rgba(255, 16, 240, .3); }
.t-alc     .t-vals { text-shadow: 0 0 5px rgba(200, 155, 255, .3); }

/* untracked rows (alcohol): no bar fill, just a hairline */
.t-bar-untracked {
  height: .55rem;
  border: none;
  border-top: 1px dashed var(--border);
  background: transparent;
  align-self: center;
}

.meal-block {
  border: 1px solid var(--neon-pink);
  background: var(--bg-elev);
  margin-bottom: 1.25rem;
  padding: 0;
}
.meal-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: .5rem .75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--neon-pink);
}
.meal-header h3 {
  margin: 0;
  color: var(--neon-yellow);
  font-size: .9rem;
  letter-spacing: .15em;
  text-shadow: 0 0 6px rgba(245, 255, 0, .3);
}
.meal-totals {
  color: var(--fg-dim);
  font-size: .85em;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.entries {
  list-style: none;
  margin: 0;
  padding: 0;
}
.entries .empty {
  padding: .5rem .75rem;
  color: var(--fg-dim);
  font-style: italic;
}
.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content max-content max-content;
  align-items: center;
  gap: 1.75rem;
  padding: .5rem .9rem;
  border-bottom: 1px solid var(--border);
}
.entry:last-child { border-bottom: none; }
.entry-name {
  color: var(--neon-green);
  text-shadow: 0 0 4px rgba(57,255,20,.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-qty {
  color: var(--neon-cyan);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* whole-row click target — hover hints editability */
.entry { cursor: pointer; transition: background .08s ease; }
.entry:hover { background: var(--bg-row); }
.entry:hover .entry-qty { text-shadow: 0 0 6px rgba(0, 240, 255, .5); }
.entry .danger { cursor: pointer; }

/* edit row: drop the 4-col grid and use a flex form so the input,
   unit label, and the two buttons line up without leaving big gaps. */
.entry.editing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
  background: var(--bg-row);
  cursor: default;
}
.entry.editing input, .entry.editing button { cursor: auto; }
.entry.editing .entry-name { flex: 1 1 12rem; min-width: 0; }
.entry-edit-form {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.entry-qty-input {
  width: 4.5rem;
  padding: .25rem .4rem;
  color: var(--neon-cyan);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.entry-unit {
  color: var(--fg-dim);
  font-size: .9em;
  white-space: nowrap;
}
button.entry-save {
  color: var(--neon-green);
  border-color: var(--neon-green);
  padding: .2rem .55rem;
  font-size: .8em;
}
button.entry-save:hover {
  color: var(--bg);
  background: var(--neon-green);
  box-shadow: 0 0 8px rgba(57, 255, 20, .5);
}
button.entry-cancel {
  color: var(--fg-dim);
  border-color: var(--border);
  padding: .2rem .55rem;
  font-size: .8em;
}
button.entry-cancel:hover {
  color: var(--bg);
  background: var(--fg-dim);
  box-shadow: none;
}
.entry-macros {
  color: var(--fg-dim);
  font-size: .85em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.entry button { padding: .15rem .55rem; line-height: 1; }

.add-entry {
  display: flex;
  gap: .5rem;
  padding: .5rem .75rem;
  border-top: 1px dashed var(--border);
  background: var(--bg);
}
.add-entry select { flex: 1; min-width: 0; }
.add-entry input[type=number] { width: 5rem; }

/* ---- quick-log button: lives between header and totals, right-aligned
   so it sits directly above the "edit goals" link inside the totals bar. */
.day-actions {
  text-align: right;
  margin-bottom: .35rem;
}
/* big & green — color/border/hover inherited from the base button rule */
.quick-log-btn {
  padding: .55rem 1.25rem;
  font-size: 1rem;
}

/* ---- quick log region (day-level AI parser) ---- */
.quick-log-region {
  margin-bottom: 1.5rem;
}
.quick-log-region:empty { margin-bottom: 0; }
.quick-log-open {
  border: 1px dashed var(--neon-cyan);
  background: rgba(0, 240, 255, .03);
  padding: .75rem 1rem;
}
.qlog-head, .parse-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: .5rem;
}
.qlog-title, .parse-title {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--neon-cyan);
  text-shadow: 0 0 4px rgba(0, 240, 255, .3);
}
.parse-title-err { color: var(--danger); text-shadow: 0 0 4px rgba(255,56,96,.4); }
.qlog-close {
  padding: .05rem .45rem;
  font-size: .9rem;
  line-height: 1;
  color: var(--fg-dim);
  border-color: var(--border);
}
.qlog-close:hover {
  color: var(--bg);
  background: var(--fg-dim);
  box-shadow: none;
}

.quick-log { display: flex; flex-direction: column; gap: .5rem; }
.quick-log textarea {
  font-family: inherit;
  font-size: 14px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: .5rem .65rem;
  resize: vertical;
  width: 100%;
  min-height: 4.5rem;
  outline: none;
  line-height: 1.4;
}
.quick-log textarea:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 1px var(--neon-cyan), 0 0 8px rgba(0, 240, 255, .3);
}
.qlog-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .75rem;
}
.qlog-actions button {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
}
.qlog-actions button:hover {
  color: var(--bg);
  background: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, .55);
}
.qlog-indicator {
  color: var(--neon-yellow);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  animation: pulse 1s ease-in-out infinite;
}

/* ---- parse preview ---- */
.parse-preview { display: flex; flex-direction: column; gap: .5rem; }
.parse-empty {
  color: var(--fg-dim);
  font-style: italic;
  font-size: .85em;
}
.parse-items, .parse-unmatched {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.parse-item {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1.4fr) 4.5rem auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .35rem .7rem;
  padding: .35rem .6rem;
  border: 1px solid var(--border);
  background: var(--bg);
}
.parse-item:hover { border-color: var(--neon-cyan); }
.parse-slot {
  padding: .2rem .35rem;
  font-size: .8rem;
  text-transform: lowercase;
  color: var(--neon-yellow);
  border-color: var(--border);
  background: var(--bg-elev);
}
.parse-slot:focus { border-color: var(--neon-yellow); box-shadow: 0 0 0 1px var(--neon-yellow); }
.parse-name {
  color: var(--neon-green);
  text-shadow: 0 0 4px rgba(57, 255, 20, .3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.parse-qty {
  width: 100%;
  font-variant-numeric: tabular-nums;
  color: var(--neon-cyan);
  text-align: right;
  padding: .25rem .4rem;
}
.parse-unit {
  color: var(--fg-dim);
  font-size: .85em;
  white-space: nowrap;
}
.parse-macros {
  color: var(--fg-dim);
  font-size: .8em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}
.parse-source {
  grid-column: 1 / -1;
  color: var(--fg-dim);
  font-size: .75em;
  font-style: italic;
  margin-top: -.1rem;
}
.parse-drop {
  padding: .1rem .45rem;
  color: var(--danger);
  border-color: var(--danger);
  line-height: 1;
  font-size: .85em;
}
.parse-drop:hover {
  color: var(--bg);
  background: var(--danger);
  box-shadow: 0 0 8px rgba(255, 56, 96, .5);
}
.parse-unmatched li {
  padding: .3rem .6rem;
  border: 1px dashed var(--danger);
  background: rgba(255, 56, 96, .04);
  color: var(--danger);
  font-size: .8em;
  display: flex;
  gap: .75rem;
  align-items: baseline;
  flex-wrap: wrap;
}
.unmatch-note { color: var(--fg-dim); font-style: italic; }
.parse-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
}
.parse-actions button {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
}
.parse-actions button:hover {
  color: var(--bg);
  background: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, .55);
}
.parse-err {
  padding: .4rem .6rem;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: rgba(255, 56, 96, .06);
  font-size: .85em;
}
.parse-echo {
  color: var(--fg-dim);
  font-style: italic;
  font-size: .8em;
}

/* ---- weight page ---- */
#weight-log {
  display: flex;
  gap: .75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--border);
}
#weight-log label { display: flex; flex-direction: column; gap: .25rem; }
#weight-log label > span {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--neon-cyan);
  text-shadow: 0 0 4px rgba(0, 240, 255, .3);
}
#weight-log input[name="weight_lbs"] {
  width: 8rem;
  font-variant-numeric: tabular-nums;
  color: var(--neon-cyan);
  text-shadow: 0 0 4px rgba(0, 240, 255, .3);
}
#weight-log input[name="date"] { width: 11rem; }

.weight-history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.weight-empty {
  padding: .5rem .75rem;
  color: var(--fg-dim);
  font-style: italic;
}
.weight-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-variant-numeric: tabular-nums;
}
.weight-row:hover { border-color: var(--neon-cyan); }
.weight-date {
  color: var(--fg-dim);
  font-size: .9em;
  letter-spacing: .04em;
}
.weight-value {
  color: var(--neon-cyan);
  text-shadow: 0 0 5px rgba(0, 240, 255, .35);
  font-size: 1.1rem;
}
.weight-value small {
  color: var(--fg-dim);
  font-size: .65em;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-left: .25rem;
  text-shadow: none;
}
.weight-row button {
  padding: .15rem .5rem;
}

/* ---- settings page ---- */
.settings-blurb { color: var(--fg-dim); margin-top: -.25rem; }
#settings-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  max-width: 24rem;
}
#settings-form label > span {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--neon-cyan);
  display: block;
  margin-bottom: .25rem;
}
#settings-form input { width: 100%; }
#settings-form button { align-self: flex-start; margin-top: .5rem; }

/* ---- error toast (htmx 4xx/5xx + network errors) ---- */
.toast {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  max-width: 32rem;
  margin: 0 auto;
  padding: .75rem 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--danger);
  color: var(--danger);
  text-shadow: 0 0 5px rgba(255, 56, 96, .4);
  box-shadow: 0 0 14px rgba(255, 56, 96, .35);
  font-variant-numeric: tabular-nums;
  font-size: .9em;
  cursor: pointer;
  z-index: 1000;
  word-break: break-word;
}
.toast::before {
  content: "▲ ";
  color: var(--danger);
  font-weight: 700;
  margin-right: .25rem;
}
.toast[hidden] { display: none; }

/* ===== mobile / single-column ===== */
@media (max-width: 640px) {
  html, body { font-size: 15px; }
  body { padding: .6rem .75rem; max-width: 100%; }

  nav { gap: .9rem; padding: .4rem 0; margin-bottom: 1rem; }
  nav .brand { display: none; } /* save horizontal space */
  nav a { font-size: .9em; }

  h1 { font-size: 1.2rem; }
  h2 { font-size: 1rem; }
  h3 { font-size: .9rem; }

  /* ---- inputs/buttons: bigger tap targets ---- */
  input, button, select {
    font-size: 16px;            /* prevents iOS auto-zoom on focus */
    padding: .5rem .65rem;
  }
  button { min-height: 2.25rem; }

  /* ---- search form ---- */
  .search-row { padding: .6rem .75rem; }
  #food-search { flex-wrap: wrap; gap: .5rem; }
  #food-search .field-name { flex: 1 1 100%; }
  #food-search button { flex: 1; }
  #search-indicator { display: none; }
  .htmx-request #search-indicator { display: inline-block; flex: 0 0 100%; text-align: center; }

  /* ---- new-food form: stack each field full width ---- */
  #new-food { gap: .55rem; }
  #new-food label { flex: 1 1 100%; }
  #new-food label > span { font-size: .65rem; }
  #new-food input,
  #new-food input[type=number] { width: 100% !important; }
  #new-food button[type=submit] { width: 100%; align-self: stretch; margin-top: .25rem; }

  /* ---- foods table → cards ---- */
  table#foods { display: block; border: none; background: transparent; }
  table#foods thead { display: none; }
  table#foods tbody, table#foods tbody tr { display: block; }
  table#foods tbody tr {
    position: relative;
    border: 1px solid var(--neon-green);
    background: var(--bg-elev);
    padding: .5rem .75rem;
    margin-bottom: .4rem;
  }
  table#foods tbody tr:hover { background: var(--bg-elev); } /* no hover lift on touch */
  table#foods td { display: inline; padding: 0; border: none; }

  /* name as block heading inside the card */
  table#foods td:nth-child(1) {
    display: block;
    color: var(--neon-green);
    font-weight: 600;
    margin-bottom: .2rem;
    padding-right: 6.5rem; /* leave room for action buttons */
    text-shadow: 0 0 4px rgba(57, 255, 20, .3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* inline stat strip; relabel cells via pseudo-element after each */
  table#foods td.serving { color: var(--fg-dim); font-size: .85em; }
  table#foods td.cals    { color: var(--neon-yellow); font-size: .85em; }
  table#foods td:nth-child(4),
  table#foods td:nth-child(5),
  table#foods td:nth-child(6),
  table#foods td:nth-child(7) { color: var(--fg-dim); font-size: .85em; }
  table#foods td.serving::after { content: " · "; color: var(--border); }
  table#foods td.cals::after    { content: " cal · "; color: var(--border); }
  table#foods td:nth-child(4)::after { content: "c · "; color: var(--border); }
  table#foods td:nth-child(5)::after { content: "p · "; color: var(--border); }
  table#foods td:nth-child(6)::after { content: "f · "; color: var(--border); }
  table#foods td:nth-child(7)::after { content: "a"; color: var(--border); }

  /* actions: top-right corner of the card */
  table#foods td.actions {
    display: block;
    position: absolute;
    top: .35rem;
    right: .5rem;
    text-align: right;
  }
  table#foods td.actions button {
    padding: .25rem .55rem;
    font-size: .75em;
    min-height: 0;
  }

  /* edit row keeps the same card shape, vertical stack */
  table#foods tbody tr.editing { padding: .65rem .75rem; }
  table#foods tr.editing td { display: block; margin-bottom: .35rem; }
  table#foods tr.editing td::after { content: none; }
  table#foods tr.editing td input { width: 100%; }
  table#foods tr.editing td.actions {
    position: static;
    display: flex;
    gap: .4rem;
    margin-top: .25rem;
  }
  table#foods tr.editing td.actions button { flex: 1; font-size: 1em; }

  /* search candidates */
  .candidate {
    flex-wrap: wrap;
    gap: .5rem;
  }
  .cand-text { flex: 1 1 100%; grid-template-columns: 1fr; }
  .cand-macros { grid-column: 1; grid-row: auto; text-align: left; }
  .cand-add { flex: 1 1 100%; }
  .cand-add button { width: 100%; }

  /* ---- day view ---- */
  .day-header { gap: .25rem; margin-bottom: 1rem; padding-bottom: .6rem; }
  .day-nav { gap: 1rem; }

  /* totals bar: compact on mobile */
  .totals { padding: .55rem .75rem; }
  .t-row {
    grid-template-columns: 2rem 1fr 6rem;
    gap: .5rem;
  }
  .t-row .t-vals { font-size: .85rem; }

  /* meal header: stack slot + totals on narrow */
  .meal-header { flex-wrap: wrap; gap: .25rem .75rem; }
  .meal-totals { font-size: .8em; }

  /* entry row: two-line layout */
  .entry {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name actions"
      "stats actions";
    gap: .15rem .5rem;
    padding: .5rem .75rem;
  }
  .entry-name   { grid-area: name; }
  .entry button { grid-area: actions; align-self: start; padding: .15rem .5rem; }
  .entry-qty, .entry-macros {
    grid-area: stats;
    display: inline;
    font-size: .85em;
  }
  /* render qty + macros on the same visual line, separated by · */
  .entry-qty::after { content: " · "; color: var(--border); }

  /* edit row: drop the grid override, stack name above form */
  .entry.editing { padding: .55rem .75rem; }
  .entry.editing .entry-name { flex: 1 1 100%; }
  .entry-edit-form { flex: 1 1 100%; }
  .entry-qty-input { flex: 1; min-width: 5rem; }
  .entry-save, .entry-cancel { flex: 1; min-height: 2.1rem; }

  /* add-entry form: stack the food select on its own row */
  .add-entry { flex-wrap: wrap; gap: .45rem; }
  .add-entry select { flex: 1 1 100%; }
  .add-entry input[type=number] { flex: 1; width: auto; }
  .add-entry button { flex: 1; }

  .quick-log-btn { font-size: .95rem; padding: .5rem 1rem; }

  /* quick-log region: tighten padding */
  .quick-log-open { padding: .6rem .75rem; }
  .quick-log textarea { min-height: 5rem; }
  .qlog-actions button { flex: 1; }

  /* parse preview rows: stacked grid */
  .parse-item {
    grid-template-columns: 6rem minmax(0, 1fr) 4rem auto auto;
    grid-template-areas:
      "slot name name name drop"
      "slot qty unit macros drop";
    gap: .15rem .45rem;
    padding: .4rem .55rem;
  }
  .parse-slot   { grid-area: slot; }
  .parse-name   { grid-area: name; }
  .parse-qty    { grid-area: qty; }
  .parse-unit   { grid-area: unit; }
  .parse-macros { grid-area: macros; text-align: left; font-size: .75em; }
  .parse-drop   { grid-area: drop; }
  .parse-source { grid-column: 1 / -1; }
}
