:root{
  --bg:#f7f4ee; --card:#fffdf8; --ink:#1f2933; --muted:#667085; --line:#e8dfd1;
  --accent:#b86b2b; --accent2:#2f6f5e; --danger:#9b1c1c; --good:#237a4b; --warn:#9a6700;
  --shadow:0 12px 30px rgba(31,41,51,.08); --radius:20px;
}
*{box-sizing:border-box} body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;background:var(--bg);color:var(--ink);line-height:1.45}
a{color:var(--accent2);text-decoration:none} a:hover{text-decoration:underline}
.site-header{position:sticky;top:0;z-index:2;display:flex;align-items:center;justify-content:space-between;gap:18px;padding:16px 26px;background:rgba(255,253,248,.92);backdrop-filter:blur(10px);border-bottom:1px solid var(--line)}
.brand{display:flex;align-items:center;gap:10px;font-weight:800;font-size:1.18rem;color:var(--ink)}.brand:hover{text-decoration:none}.brand-mark{display:grid;place-items:center;width:38px;height:38px;border-radius:14px;background:var(--accent);color:white;box-shadow:var(--shadow)}
.nav{display:flex;align-items:center;gap:14px;flex-wrap:wrap}.nav a{font-weight:650;color:var(--ink)}
.container{max-width:1180px;margin:0 auto;padding:28px}.site-footer{text-align:center;color:var(--muted);padding:28px;border-top:1px solid var(--line)}
.hero{display:grid;grid-template-columns:1.2fr .8fr;gap:24px;align-items:center}.hero h1{font-size:clamp(2.2rem,4vw,4rem);line-height:1.02;margin:0 0 14px}.hero p{font-size:1.12rem;color:var(--muted);max-width:720px}.tag{display:inline-flex;gap:8px;align-items:center;padding:8px 12px;border:1px solid var(--line);border-radius:999px;background:var(--card);font-weight:700;color:var(--accent2);margin-bottom:16px}
.grid{display:grid;gap:18px}.grid.two{grid-template-columns:repeat(2,minmax(0,1fr))}.grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}.grid.four{grid-template-columns:repeat(4,minmax(0,1fr))}
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:22px;box-shadow:var(--shadow)}.card h2,.card h3{margin-top:0}.muted{color:var(--muted)}.big-number{font-size:2.25rem;font-weight:850;letter-spacing:-.04em}.unit{color:var(--muted);font-weight:700}.pill{display:inline-block;padding:6px 10px;border-radius:999px;background:#f0eadf;border:1px solid var(--line);font-weight:700;color:var(--muted)}
.btn,button{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;border-radius:14px;padding:11px 16px;background:var(--accent2);color:#fff;font-weight:800;cursor:pointer;box-shadow:var(--shadow)}.btn:hover,button:hover{text-decoration:none;filter:brightness(.96)}.btn.secondary,button.secondary{background:#ebe3d7;color:var(--ink)}.btn.danger,button.danger{background:var(--danger)}.btn.small{padding:8px 11px;border-radius:12px;font-size:.92rem}
form{display:grid;gap:14px}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}label{display:grid;gap:6px;font-weight:750}input,select,textarea{width:100%;padding:11px 12px;border:1px solid var(--line);border-radius:12px;background:#fff;color:var(--ink);font:inherit}textarea{min-height:100px}.help{font-size:.9rem;color:var(--muted);font-weight:500}.actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.right{text-align:right}
.table-wrap{overflow:auto;border:1px solid var(--line);border-radius:16px;background:var(--card)}table{width:100%;border-collapse:collapse}th,td{padding:12px;border-bottom:1px solid var(--line);text-align:left;vertical-align:top}th{background:#f4eddf;font-size:.88rem;text-transform:uppercase;letter-spacing:.04em;color:var(--muted)}tr:last-child td{border-bottom:0}
.flash{padding:12px 14px;margin-bottom:18px;border-radius:14px;border:1px solid var(--line);background:var(--card);font-weight:700}.flash.success{border-color:#b9e5ca;background:#ecfff4;color:var(--good)}.flash.error{border-color:#f2b8b5;background:#fff1f0;color:var(--danger)}.flash.info{border-color:#bfd7ff;background:#eff6ff;color:#204a87}.flash.warning{border-color:#ffd666;background:#fffbe6;color:var(--warn)}
.progress{height:16px;border-radius:999px;background:#ece3d8;overflow:hidden}.bar{height:100%;background:var(--accent2);width:0%}.bar.warn{background:var(--warn)}.bar.danger{background:var(--danger)}
.kv{display:grid;grid-template-columns:1fr auto;gap:8px}.kv div{padding:8px 0;border-bottom:1px dashed var(--line)}.kv div:nth-child(even){font-weight:800;text-align:right}.center{text-align:center}.section{margin-top:24px}.nowrap{white-space:nowrap}
@media(max-width:850px){.hero,.grid.two,.grid.three,.grid.four,.form-grid{grid-template-columns:1fr}.site-header{align-items:flex-start;flex-direction:column}.container{padding:18px}.nav{gap:10px}.card{padding:18px}}

/* Friendly profile calculation panel */
.friendly-kv div:nth-child(odd) {
  color: var(--muted);
}

.advanced-panel {
  margin-top: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.advanced-panel summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.1rem;
  font-weight: 800;
  color: var(--ink);
  background: #f7faf7;
  border-bottom: 1px solid transparent;
}

.advanced-panel summary::-webkit-details-marker {
  display: none;
}

.advanced-panel summary::after {
  content: "+";
  float: right;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--muted);
}

.advanced-panel[open] summary {
  border-bottom-color: var(--border);
}

.advanced-panel[open] summary::after {
  content: "−";
}

.advanced-panel > p,
.advanced-panel > .kv {
  margin-left: 1.1rem;
  margin-right: 1.1rem;
}

.advanced-panel > .kv {
  margin-bottom: 1.1rem;
}

/* Calorie Ledger branding */
.site-logo {
  display: block;
  height: 54px;
  width: auto;
  max-width: 260px;
  object-fit: contain;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-text {
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

@media (max-width: 640px) {
  .site-logo {
    height: 42px;
    max-width: 220px;
  }
}

/* Food library remove/delete controls */
.table-actions {
  white-space: nowrap;
}

.inline-delete {
  display: inline-block;
  margin: 0 0 0 0.35rem;
}

.delete-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-weight: 800;
  cursor: pointer;
  background: #9f2a2a;
  color: #fff;
  text-decoration: none;
}

.danger-button:hover {
  filter: brightness(0.95);
}

.danger-button.small {
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-size: 0.9rem;
}

.private-pill {
  background: #eef6f1;
}

/* Cleaner food action buttons */
.table-actions {
  white-space: nowrap;
  min-width: 170px;
}

.table-actions .btn,
.table-actions .danger-button {
  vertical-align: middle;
}

.table-actions .btn.small,
.table-actions .danger-button.small {
  display: inline-flex;
  width: auto;
  min-width: 68px;
  height: 38px;
  padding: 0 0.75rem;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  line-height: 1;
}

.inline-delete {
  display: inline-flex;
  margin: 0 0 0 0.4rem;
  vertical-align: middle;
}

.inline-delete .danger-button.small {
  background: #8f2f2f;
  color: #fff;
}

/* Edit food page remove button */
.delete-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.delete-form .danger-button {
  width: auto;
  min-width: 150px;
  max-width: 220px;
  padding: 0.8rem 1.1rem;
  background: #8f2f2f;
  color: #fff;
}

/* Keep Save / Cancel / Remove from visually blending together */
.actions + .delete-form {
  margin-top: 1.25rem;
}

@media (max-width: 760px) {
  .table-actions {
    min-width: 120px;
  }

  .inline-delete {
    display: block;
    margin: 0.4rem 0 0 0;
  }

  .table-actions .btn.small,
  .table-actions .danger-button.small {
    width: 100%;
  }
}

/* Edit Food page action layout refinement */
.share-row {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.share-row input[type="checkbox"] {
  width: auto;
  min-width: 0;
  margin: 0;
}

.food-edit-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.food-edit-actions button,
.food-edit-actions .btn {
  width: auto;
  min-width: 104px;
  height: 44px;
  padding: 0 1rem;
}

.food-remove-form {
  display: block;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.food-remove-form .danger-button {
  display: inline-flex;
  width: auto;
  min-width: 220px;
  max-width: 260px;
  height: 44px;
  padding: 0 1.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: #9f2f35;
  color: #fff;
}

/* Override earlier generic rules that made delete buttons stretch oddly */
.delete-form .danger-button {
  width: auto;
}

@media (max-width: 640px) {
  .food-edit-actions {
    align-items: stretch;
  }

  .food-edit-actions button,
  .food-edit-actions .btn,
  .food-remove-form .danger-button {
    width: 100%;
    max-width: none;
  }
}

/* Cloudflare Turnstile */
.turnstile-wrap {
  margin: 1rem 0;
  min-height: 65px;
  display: flex;
  align-items: center;
}

/* Daily Log unified food search */
.food-result-list {
  display: grid;
  gap: 0.7rem;
  margin: 0.75rem 0 1.25rem;
}

.food-result-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 140px 100px auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.food-result-card.usda-result {
  background: #fbfdfb;
}

.food-result-card select,
.food-result-card input[type="number"] {
  margin: 0;
  width: 100%;
}

.food-result-card button.small {
  white-space: nowrap;
}

@media (max-width: 760px) {
  .food-result-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .food-result-card button.small {
    width: 100%;
  }
}

/* Daily Log scroll cleanup */
.food-result-list {
  gap: 0.45rem;
}

.food-result-card {
  grid-template-columns: minmax(240px, 1fr) 120px 80px auto;
  gap: 0.5rem;
  padding: 0.6rem 0.7rem;
  border-radius: 12px;
}

.food-result-card strong {
  line-height: 1.2;
}

.food-result-card .muted {
  font-size: 0.88rem;
  line-height: 1.25;
}

.food-result-card select,
.food-result-card input[type="number"] {
  min-height: 38px;
  padding: 0.45rem 0.55rem;
}

.food-result-card button.small {
  min-height: 38px;
  padding: 0 0.8rem;
}

.card h3 {
  margin-top: 1rem;
  margin-bottom: 0.45rem;
}

@media (max-width: 760px) {
  .food-result-card {
    grid-template-columns: 1fr;
    padding: 0.7rem;
  }
}

/* USDA pagination on Daily Log */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: 1rem 0 0.4rem;
}

.pager a,
.pager span {
  min-width: 36px;
  min-height: 36px;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 800;
  border: 1px solid var(--border);
}

.pager a {
  background: #fff;
  color: var(--ink);
}

.pager a:hover {
  background: #f4f7f4;
}

.pager .current {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.pager .disabled {
  opacity: 0.45;
  background: #f2eee7;
}

.pager .ellipsis {
  border-color: transparent;
  background: transparent;
  min-width: auto;
}

.pager-note {
  margin-top: 0.25rem;
}

/* Profile Restart & Data Management */
.restart-section {
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
}

.restart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.restart-option {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  background: #fff;
}

.restart-option h3 {
  margin-top: 0;
}

.restart-option p {
  color: var(--muted);
  min-height: 4.2rem;
}

.restart-option.danger {
  border-color: #ddb8b8;
  background: #fffafa;
}

.restart-button {
  width: 100%;
  border: 0;
  border-radius: 13px;
  padding: 0.85rem 1rem;
  font-weight: 900;
  cursor: pointer;
}

.restart-button.primary {
  background: var(--green);
  color: #fff;
}

.restart-button.warning {
  background: #eadfcf;
  color: var(--ink);
}

.restart-button.danger {
  background: #9f2f35;
  color: #fff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 20, 32, 0.56);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  width: min(560px, 100%);
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.28);
  padding: 1.5rem;
}

.modal-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  border: 0;
  background: #f0ebe2;
  color: var(--ink);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.modal-actions button {
  width: auto;
}

@media (max-width: 860px) {
  .restart-grid {
    grid-template-columns: 1fr;
  }

  .restart-option p {
    min-height: auto;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions button {
    width: 100%;
  }
}

/* FatSecret Daily Log result source */
.food-result-card.fatsecret-result {
  background: #fbfdfb;
}

/* Daily Log food search copy/quantity cleanup */
.attribution-line {
  font-size: 0.82rem;
  margin-top: -0.35rem;
}

.mini-quantity {
  display: grid;
  gap: 0.25rem;
  margin: 0;
}

.mini-quantity span {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--muted);
  line-height: 1;
}

.food-result-card .mini-quantity input[type="number"] {
  margin: 0;
  width: 100%;
}

@media (max-width: 760px) {
  .mini-quantity span {
    font-size: 0.82rem;
  }
}

/* Food Lookup page */
.accordion-summary {
  cursor: pointer;
  font-weight: 900;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: #f7f5ef;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.accordion-summary span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.accordion-body {
  padding-top: 1rem;
}

.food-result-card.fatsecret-result {
  background: #fbfdfb;
}

.attribution-line {
  font-size: 0.82rem;
  margin-top: 0.35rem;
}

/* Foods hub lookup/library cleanup */
.food-library-controls {
  margin-bottom: 0.75rem;
}

.food-library-controls select {
  min-width: 150px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.5rem 0 1rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-weight: 800;
  text-decoration: none;
}

.chip.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.lookup-details {
  margin-top: 1rem;
}

.food-library-table {
  max-height: 760px;
  overflow: auto;
}

.food-library-table thead th {
  position: sticky;
  top: 0;
  background: #f0eadf;
  z-index: 2;
}

@media (max-width: 760px) {
  .food-library-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .food-library-controls select,
  .food-library-controls button,
  .food-library-controls .btn {
    width: 100%;
  }

  .food-library-table {
    max-height: none;
  }
}

/* Food Library filter chip visibility fix */
.filter-chips .chip,
.filter-chips .chip:link,
.filter-chips .chip:visited {
  color: var(--ink, #182331) !important;
  background: #ffffff !important;
  border: 1px solid var(--border, #ddd4c8) !important;
  text-decoration: none !important;
}

.filter-chips .chip:hover {
  background: #f7f5ef !important;
  color: var(--ink, #182331) !important;
}

.filter-chips .chip.active,
.filter-chips .chip.active:link,
.filter-chips .chip.active:visited,
.filter-chips .chip.active:hover {
  background: var(--green, #2f6f5e) !important;
  border-color: var(--green, #2f6f5e) !important;
  color: #ffffff !important;
}

/* Daily Log dual food database actions */
.result-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.food-result-card .result-actions button.small,
.food-result-card .result-actions .btn.small {
  min-height: 38px;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .result-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .food-result-card .result-actions button.small,
  .food-result-card .result-actions .btn.small {
    width: 100%;
  }
}

/* Food Lookup USDA accordion indicator */
.lookup-details .accordion-summary {
  position: relative;
  padding-right: 3rem;
  list-style: none;
}

.lookup-details .accordion-summary::-webkit-details-marker {
  display: none;
}

.lookup-details .accordion-summary::after {
  content: "⌄";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--muted);
  transition: transform 0.18s ease;
}

.lookup-details[open] .accordion-summary::after {
  transform: translateY(-50%) rotate(180deg);
}

/* Dashboard food log mobile-friendly cards */
.dashboard-food-list {
  display: grid;
  gap: 0.75rem;
}

.dashboard-food-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 1.2fr) auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.dashboard-food-main strong {
  display: block;
  line-height: 1.25;
}

.meal-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  background: #f0eadf;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  padding: 0.25rem 0.55rem;
  margin-bottom: 0.4rem;
}

.dashboard-food-edit {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(110px, 0.8fr) auto;
  gap: 0.55rem;
  align-items: end;
  margin: 0;
}

.dashboard-food-edit label {
  margin: 0;
}

.dashboard-food-edit label span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  margin-bottom: 0.25rem;
}

.dashboard-food-edit select,
.dashboard-food-edit input {
  margin: 0;
}

.dashboard-food-actions,
.dashboard-food-delete {
  margin: 0;
}

.dashboard-food-delete {
  align-self: end;
}

@media (max-width: 860px) {
  .dashboard-food-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .dashboard-food-edit {
    grid-template-columns: 1fr;
  }

  .dashboard-food-actions button,
  .dashboard-food-delete button {
    width: 100%;
  }

  .dashboard-food-delete {
    margin-top: -0.25rem;
  }
}

/* Dashboard food entry compact layout override */
.dashboard-food-head {
  align-items: center;
  gap: 1rem;
}

.dashboard-food-list {
  display: grid;
  gap: 0.65rem;
}

.dashboard-food-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(420px, 1.25fr);
  gap: 0.9rem;
  align-items: end;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.dashboard-food-main strong {
  display: block;
  line-height: 1.25;
  font-size: 1rem;
}

.dashboard-food-main .muted {
  margin-top: 0.15rem;
}

.meal-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  background: #f0eadf;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  padding: 0.22rem 0.52rem;
  margin-bottom: 0.35rem;
}

.dashboard-food-edit {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(105px, 0.65fr) auto;
  gap: 0.55rem;
  align-items: end;
  margin: 0;
}

.dashboard-food-edit label {
  margin: 0;
}

.dashboard-food-edit label span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  margin-bottom: 0.2rem;
}

.dashboard-food-edit select,
.dashboard-food-edit input {
  margin: 0;
  min-height: 40px;
}

.dashboard-food-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  justify-content: flex-end;
  margin: 0;
}

.dashboard-food-actions button.small {
  min-height: 40px;
  padding: 0.55rem 0.85rem;
  width: auto;
  min-width: 76px;
}

.dashboard-food-actions .danger-button.small {
  background: #9f2f35;
}

@media (max-width: 920px) {
  .dashboard-food-card {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .dashboard-food-edit {
    grid-template-columns: 1fr 0.8fr;
  }

  .dashboard-food-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-food-actions button.small {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .dashboard-food-head {
    align-items: stretch;
  }

  .dashboard-food-head .btn {
    width: 100%;
  }

  .dashboard-food-card {
    padding: 0.8rem;
  }

  .dashboard-food-edit {
    grid-template-columns: 1fr;
  }

  .dashboard-food-actions {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-food-actions button.small {
    min-height: 42px;
  }
}

/* Dashboard food cards: mobile spacing cleanup */
@media (max-width: 520px) {
  .dashboard-food-list {
    gap: 1.15rem;
  }

  .dashboard-food-card {
    padding: 0.95rem;
    border-radius: 18px;
    box-shadow: 0 10px 26px rgba(24, 35, 49, 0.05);
  }

  .dashboard-food-actions {
    margin-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  .dashboard-food-card + .dashboard-food-card {
    margin-top: 0.15rem;
  }

  .dashboard-food-main {
    padding-bottom: 0.15rem;
  }

  .dashboard-food-main strong {
    margin-bottom: 0.2rem;
  }
}

/* Dashboard food cards: stronger mobile separation override */
@media (max-width: 520px) {
  #dashboard-food-log .dashboard-food-list {
    gap: 1.35rem !important;
  }

  #dashboard-food-log .dashboard-food-card {
    padding: 1rem !important;
    margin-bottom: 0 !important;
    border: 1px solid var(--border, #ddd4c8) !important;
    border-radius: 18px !important;
    background: #fff !important;
    box-shadow: 0 10px 28px rgba(24, 35, 49, 0.08) !important;
  }

  #dashboard-food-log .dashboard-food-card + .dashboard-food-card {
    margin-top: 0.35rem !important;
  }

  #dashboard-food-log .dashboard-food-actions {
    margin-top: 0.55rem !important;
    padding-bottom: 0.65rem !important;
    border-bottom: 1px solid rgba(221, 212, 200, 0.65) !important;
  }

  #dashboard-food-log .dashboard-food-card:last-child .dashboard-food-actions {
    border-bottom: 0 !important;
    padding-bottom: 0 !important;
  }

  #dashboard-food-log .dashboard-food-main {
    padding-top: 0.25rem !important;
  }

  #dashboard-food-log .dashboard-food-main .meal-pill {
    margin-bottom: 0.45rem !important;
  }
}

/* Dashboard food cards: visible mobile/tablet separation */
@media (max-width: 900px) {
  #dashboard-food-log .dashboard-food-list {
    display: grid !important;
    gap: 1.35rem !important;
  }

  #dashboard-food-log .dashboard-food-card {
    display: block !important;
    padding: 1rem 0 1.25rem !important;
    margin: 0 !important;
    border: 0 !important;
    border-bottom: 2px solid #e3d9ca !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  #dashboard-food-log .dashboard-food-card:last-child {
    border-bottom: 0 !important;
    padding-bottom: 0 !important;
  }

  #dashboard-food-log .dashboard-food-main {
    margin-bottom: 0.65rem !important;
  }

  #dashboard-food-log .dashboard-food-edit {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0.7rem !important;
    margin: 0 !important;
  }

  #dashboard-food-log .dashboard-food-actions {
    display: flex !important;
    gap: 0.6rem !important;
    justify-content: flex-start !important;
    align-items: center !important;
    margin-top: 0.35rem !important;
    padding-bottom: 0 !important;
    border-bottom: 0 !important;
  }

  #dashboard-food-log .dashboard-food-actions button.small {
    width: auto !important;
    min-width: 86px !important;
    min-height: 42px !important;
    padding: 0.6rem 0.95rem !important;
  }

  #dashboard-food-log .dashboard-food-actions .danger-button.small {
    min-width: 92px !important;
  }
}

/* Dashboard food cards: hard separation override */
#dashboard-food-log .dashboard-food-list {
  display: grid !important;
  gap: 1.25rem !important;
}

#dashboard-food-log .dashboard-food-card {
  display: grid !important;
  gap: 0.85rem !important;
  padding: 1rem !important;
  margin: 0 0 1.15rem 0 !important;
  border: 1px solid #ddd4c8 !important;
  border-radius: 18px !important;
  background: #ffffff !important;
  box-shadow: 0 10px 24px rgba(24, 35, 49, 0.07) !important;
}

#dashboard-food-log .dashboard-food-card + .dashboard-food-card {
  margin-top: 0.35rem !important;
}

#dashboard-food-log .dashboard-food-main {
  padding-bottom: 0.15rem !important;
}

#dashboard-food-log .dashboard-food-edit {
  display: grid !important;
  gap: 0.65rem !important;
}

#dashboard-food-log .dashboard-food-actions {
  display: flex !important;
  gap: 0.65rem !important;
  justify-content: flex-start !important;
  align-items: center !important;
  margin-top: 0.45rem !important;
  padding-top: 0.2rem !important;
}

#dashboard-food-log .dashboard-food-actions button.small {
  width: auto !important;
  min-width: 90px !important;
  min-height: 42px !important;
  padding: 0.6rem 1rem !important;
}

#dashboard-food-log .dashboard-food-actions .danger-button.small {
  min-width: 96px !important;
}

@media (min-width: 921px) {
  #dashboard-food-log .dashboard-food-card {
    grid-template-columns: minmax(240px, 1fr) minmax(460px, 1.25fr) !important;
    align-items: end !important;
  }

  #dashboard-food-log .dashboard-food-edit {
    grid-template-columns: minmax(140px, 1fr) minmax(110px, 0.65fr) auto !important;
    align-items: end !important;
  }
}

@media (max-width: 920px) {
  #dashboard-food-log .dashboard-food-card {
    grid-template-columns: 1fr !important;
  }

  #dashboard-food-log .dashboard-food-edit {
    grid-template-columns: 1fr !important;
  }

  #dashboard-food-log .dashboard-food-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
  }

  #dashboard-food-log .dashboard-food-actions button.small {
    width: 100% !important;
  }
}

/* Dashboard food cards: final balanced mobile spacing */
#dashboard-food-log .dashboard-food-head {
  margin-bottom: 0.85rem !important;
}

#dashboard-food-log .dashboard-food-head .btn {
  margin-top: 0.35rem !important;
}

@media (max-width: 920px) {
  #dashboard-food-log .dashboard-food-list {
    gap: 0.85rem !important;
  }

  #dashboard-food-log .dashboard-food-card {
    padding: 0.85rem !important;
    margin: 0 0 0.85rem 0 !important;
    border: 1px solid #ddd4c8 !important;
    border-radius: 16px !important;
    background: #ffffff !important;
    box-shadow: 0 6px 16px rgba(24, 35, 49, 0.045) !important;
  }

  #dashboard-food-log .dashboard-food-main {
    margin-bottom: 0.45rem !important;
    padding: 0 !important;
  }

  #dashboard-food-log .dashboard-food-main strong {
    font-size: 1rem !important;
    line-height: 1.25 !important;
    margin-bottom: 0.1rem !important;
  }

  #dashboard-food-log .dashboard-food-main .muted {
    font-size: 0.95rem !important;
    margin-top: 0.1rem !important;
  }

  #dashboard-food-log .meal-pill {
    font-size: 0.72rem !important;
    padding: 0.2rem 0.5rem !important;
    margin-bottom: 0.35rem !important;
  }

  #dashboard-food-log .dashboard-food-edit {
    gap: 0.45rem !important;
  }

  #dashboard-food-log .dashboard-food-edit label span {
    font-size: 0.78rem !important;
    margin-bottom: 0.2rem !important;
  }

  #dashboard-food-log .dashboard-food-edit select,
  #dashboard-food-log .dashboard-food-edit input {
    min-height: 42px !important;
    padding: 0.55rem 0.7rem !important;
  }

  #dashboard-food-log .dashboard-food-actions {
    margin-top: 0.45rem !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.55rem !important;
  }

  #dashboard-food-log .dashboard-food-actions button.small {
    min-height: 40px !important;
    padding: 0.52rem 0.75rem !important;
    width: 100% !important;
  }

  #dashboard-food-log .dashboard-food-card + .dashboard-food-card {
    margin-top: 0 !important;
  }
}

@media (min-width: 921px) {
  #dashboard-food-log .dashboard-food-list {
    gap: 1rem !important;
  }

  #dashboard-food-log .dashboard-food-card {
    margin-bottom: 1rem !important;
  }
}

/* Daily Log entry cards */
.daily-entry-list {
  display: grid;
  gap: 0.85rem;
}

.daily-entry-card {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(330px, 1.35fr);
  gap: 0.75rem;
  align-items: end;
  padding: 0.8rem;
  border: 1px solid #ddd4c8;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(24, 35, 49, 0.04);
}

.daily-entry-main strong {
  display: block;
  line-height: 1.25;
}

.daily-entry-main .muted {
  margin-top: 0.15rem;
}

.daily-entry-edit {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(100px, 0.65fr) auto;
  gap: 0.5rem;
  align-items: end;
  margin: 0;
}

.daily-entry-edit label {
  margin: 0;
}

.daily-entry-edit label span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  margin-bottom: 0.2rem;
}

.daily-entry-edit select,
.daily-entry-edit input {
  margin: 0;
  min-height: 40px;
}

.daily-entry-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  justify-content: flex-end;
  margin: 0;
}

.daily-entry-actions button.small {
  min-height: 40px;
  min-width: 74px;
  padding: 0.55rem 0.8rem;
  width: auto;
}

.exercise-entry-card {
  grid-template-columns: 1fr auto;
}

.exercise-entry-actions {
  align-self: end;
}

@media (max-width: 920px) {
  .daily-entry-list {
    gap: 0.85rem;
  }

  .daily-entry-card,
  .exercise-entry-card {
    grid-template-columns: 1fr;
    gap: 0.6rem;
    padding: 0.85rem;
  }

  .daily-entry-edit {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .daily-entry-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-content: stretch;
  }

  .exercise-entry-actions {
    grid-template-columns: 1fr;
  }

  .daily-entry-actions button.small {
    width: 100%;
    min-height: 40px;
  }
}

/* Daily Log: desktop-safe entry card layout */
.daily-entry-grid.grid.two {
  grid-template-columns: 1fr !important;
}

#daily-entries > .card {
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden;
}

#daily-entries .daily-entry-card {
  max-width: 100% !important;
}

@media (min-width: 921px) {
  #daily-entries .daily-entry-card {
    grid-template-columns: minmax(260px, 1fr) minmax(520px, 1.35fr) !important;
    align-items: end !important;
  }

  #daily-entries .daily-entry-edit {
    grid-template-columns: minmax(160px, 1fr) minmax(120px, 0.65fr) auto !important;
    align-items: end !important;
  }

  #daily-entries .daily-entry-actions {
    justify-content: flex-end !important;
  }

  #daily-entries .daily-entry-actions button.small {
    width: auto !important;
    min-width: 84px !important;
  }

  #daily-entries .exercise-entry-card {
    grid-template-columns: minmax(260px, 1fr) auto !important;
  }
}

/* Foods page: mobile food library cards */
@media (max-width: 760px) {
  #library .food-library-table {
    max-height: none !important;
    overflow: visible !important;
  }

  #library .food-library-table table,
  #library .food-library-table thead,
  #library .food-library-table tbody,
  #library .food-library-table th,
  #library .food-library-table td,
  #library .food-library-table tr {
    display: block;
  }

  #library .food-library-table thead {
    display: none;
  }

  #library .food-library-table tbody {
    display: grid;
    gap: 0.8rem;
  }

  #library .food-library-table tr.food-library-row {
    border: 1px solid var(--border, #ddd4c8);
    border-radius: 16px;
    background: #fff;
    padding: 0.85rem;
    box-shadow: 0 6px 16px rgba(24, 35, 49, 0.045);
  }

  #library .food-library-table td {
    border: 0 !important;
    padding: 0.35rem 0 !important;
    text-align: left !important;
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
  }

  #library .food-library-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 900;
    font-size: 0.78rem;
    flex: 0 0 auto;
  }

  #library .food-library-table td.food-library-name {
    display: block;
    padding-bottom: 0.55rem !important;
  }

  #library .food-library-table td.food-library-name::before {
    display: none;
  }

  #library .food-library-table td.food-library-name strong {
    display: block;
    font-size: 1rem;
    line-height: 1.25;
  }

  #library .food-library-table td[data-label="Source"] {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  #library .food-library-table td[data-label="Source"]::before {
    margin-right: auto;
  }

  #library .food-library-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    align-items: stretch;
    padding-top: 0.7rem !important;
  }

  #library .food-library-actions::before {
    display: none;
  }

  #library .food-library-actions .btn,
  #library .food-library-actions button,
  #library .food-library-actions form {
    width: 100%;
  }

  #library .food-library-actions .btn,
  #library .food-library-actions button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #library .pager {
    margin-top: 1rem;
  }
}

/* Profile restart/data-management button visibility fix */
.restart-grid {
  align-items: stretch;
}

.restart-option {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.restart-option p {
  flex: 1;
}

.restart-button,
.restart-option .restart-button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  min-height: 46px !important;
  padding: 0.75rem 1rem !important;
  border: 0 !important;
  border-radius: 12px !important;
  font-weight: 900 !important;
  cursor: pointer !important;
  opacity: 1 !important;
  visibility: visible !important;
  text-indent: 0 !important;
  color: #fff !important;
  box-shadow: 0 10px 24px rgba(24, 35, 49, 0.08) !important;
}

.restart-button.journey-button {
  background: var(--green, #2f6f5e) !important;
  color: #fff !important;
}

.restart-button.warning {
  background: #e8decd !important;
  color: var(--ink, #182331) !important;
}

.restart-button.danger,
.restart-option.danger .restart-button {
  background: #a52a32 !important;
  color: #fff !important;
}

.restart-button:hover {
  filter: brightness(0.98);
}

@media (max-width: 760px) {
  .restart-option {
    gap: 0.65rem;
  }

  .restart-button,
  .restart-option .restart-button {
    min-height: 44px !important;
    font-size: 0.95rem !important;
  }
}

/* calorie_ledger_footer_background_blend */
.site-footer {
  background: transparent !important;
  background-color: transparent !important;
  border-top: 1px solid rgba(221, 212, 200, 0.72) !important;
  box-shadow: none !important;
  margin-top: 36px;
  padding: 30px 18px 26px;
}

.site-footer,
.site-footer p,
.site-footer .muted {
  color: #64748b;
}

.site-footer a {
  color: #236b55;
  font-weight: 850;
}

.site-footer .card,
.site-footer-card,
.footer-card,
.footer-legal-card {
  background: transparent !important;
  background-color: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

@media (max-width: 640px) {
  .site-footer {
    margin-top: 30px;
    padding: 28px 18px 24px;
  }
}
