/* ============================ Themes ============================ */
:root,
[data-theme="dark"] {
  --bg: #0a1425;
  --bg-grad: radial-gradient(140% 90% at 50% -20%, #1b3157 0%, #0d1b33 45%, #081124 78%, #060d1c 100%);
  --card: #14213a;
  /* Glassy card face: cool highlight fading into a translucent navy base. */
  --card-grad: linear-gradient(155deg, rgba(72, 108, 165, .26), rgba(17, 28, 50, .35)), rgba(13, 22, 40, .72);
  --card-grad-modal: linear-gradient(155deg, rgba(72, 108, 165, .24), rgba(17, 28, 50, .5)), #0f1b31;
  --card-line: rgba(138, 176, 255, .15);
  --card2: #1d2c4a;
  --line: #2c3d61;
  --line2: rgba(138, 176, 255, .10);
  --input-bg: rgba(8, 15, 30, .65);
  --text: #eaf1fb;
  --muted: #8d9cb8;
  --accent: #57a8ff;
  --accent-soft: rgba(87, 168, 255, .16);
  --brand-grad: linear-gradient(120deg, #a8d8ff 10%, #57a8ff 90%);
  --btn-bg: rgba(255, 255, 255, .06);
  --btn-line: rgba(148, 183, 255, .22);
  --chip-bg: rgba(255, 255, 255, .04);
  --bar-track: rgba(6, 12, 26, .65);
  --fill-base: #0a1425;
  /* dark end of the macro-bar gradients */
  --glow: 60%;
  /* strength of the neon glow effects */
  --cal: #4da3ff;
  --protein: #34c98e;
  --carbs: #f2b134;
  --fat: #ff7a6e;
  --danger: #ef5350;
  --danger-bg: #3a1214;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(2, 8, 20, .45);
}

[data-theme="light"] {
  --bg: #e9eef7;
  --bg-grad: radial-gradient(140% 90% at 50% -20%, #ffffff 0%, #edf2fa 45%, #e2e9f5 78%, #dbe4f2 100%);
  --card: #ffffff;
  --card-grad: linear-gradient(155deg, #ffffff, #f3f6fc);
  --card-grad-modal: #ffffff;
  --card-line: #d7e0f0;
  --card2: #eef1f7;
  --line: #d5dcea;
  --line2: #e4e9f2;
  --input-bg: #f7f9fc;
  --text: #1a2233;
  --muted: #5d6b84;
  --accent: #2f6fe0;
  --accent-soft: rgba(47, 111, 224, .12);
  --brand-grad: linear-gradient(120deg, #58a0f0 10%, #2f6fe0 90%);
  --btn-bg: #ffffff;
  --btn-line: #cfd9ea;
  --chip-bg: #ffffff;
  --bar-track: #dde4f0;
  --fill-base: #ffffff;
  /* light end of the macro-bar gradients */
  --glow: 30%;
  /* soft coloured shadow rather than neon */
  --cal: #2f6fe0;
  --protein: #17a873;
  --carbs: #d99612;
  --fat: #e05a4e;
  --danger: #d3322e;
  --danger-bg: #fde8e8;
  --shadow: 0 4px 14px rgba(26, 34, 51, .12);
}

/* ============================ Base / native feel ============================ */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

html {
  overscroll-behavior: none;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  background-image: var(--bg-grad);
  /* The gradient's paint area is the body box: keep it at least viewport-tall
     and non-repeating, or it tiles when a filtered list leaves a short page. */
  background-repeat: no-repeat;
  min-height: 100vh;
  min-height: 100svh;
  overscroll-behavior: none;
  transition: color .25s;
  touch-action: manipulation;
}

/* Vertical panning only: stops the browser claiming horizontal swipes for
   back/forward navigation, which made the day-change swipe unreliable. */
#view-diary {
  touch-action: pan-y;
}

/* Installed app only: no pinch-zoom on any view (a zoomed-in native-feel app
   just looks broken; the web version keeps zoom for accessibility). Leaving
   pinch-zoom out of touch-action is what disables the gesture — this is the
   same mechanism that already blocks it on the diary via pan-y. Set on <html>
   as well as <body>, since page zoom is decided on the viewport element. */
html.pwa,
body.pwa {
  touch-action: pan-x pan-y;
}

button,
.navbtn,
.brand,
.meal-head h3,
.bar-head,
.ring-num,
.ring-label,
.nav-ico,
.day-chip {
  user-select: none;
  -webkit-user-select: none;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: .85em;
}

.error {
  color: var(--danger);
  min-height: 1.2em;
}

.note {
  color: var(--carbs);
  font-size: .88em;
}

.row {
  display: flex;
  align-items: end;
  flex-wrap: nowrap;
}

.row.wrap {
  flex-wrap: wrap;
}

.gap {
  gap: 8px;
}

.grow {
  flex: 1;
}

.center {
  text-align: center;
}

h2 {
  font-size: 17px;
  margin: 0 0 12px;
}

code {
  background: var(--card2);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: .9em;
}

/* ============================ Buttons ============================ */
.btn {
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--btn-line);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  transition: transform .12s, border-color .15s, background .15s, box-shadow .15s;
}

.btn:hover {
  border-color: var(--accent);
}

.btn:active {
  transform: scale(.96);
}

.btn.primary {
  background: linear-gradient(160deg, var(--accent), color-mix(in srgb, var(--accent) 75%, #7b5cff));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 40%, transparent);
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.small {
  padding: 5px 12px;
  font-size: 13px;
}

.btn.icon {
  padding: 9px 12px;
}

.btn.close {
  border: none;
  background: none;
  font-size: 22px;
  padding: 0 6px;
  box-shadow: none;
}

.btn.danger {
  color: var(--danger);
}

.btn.tool {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--text);
  font-size: 13px;
  padding: 7px 12px;
}

.btn.tool:hover {
  background: var(--accent);
  color: #fff;
}

/* "New food" chooser (My Foods view) */
.newfood-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.newfood-options .btn {
  font-size: 15px;
  padding: 12px;
}

/* Label scan: a "Camera / Gallery" pair per photo. */
.label-photo-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label-photo-title {
  font-size: 13px;
  color: var(--text);
}

/* Ripple effect (span injected by JS) */
.ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: currentColor;
  opacity: .25;
  transform: scale(0);
  animation: ripple .5s ease-out forwards;
}

@keyframes ripple {
  to {
    transform: scale(3);
    opacity: 0;
  }
}

input,
select,
textarea {
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 16px;
  width: 100%;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* File pickers: restyle the native browser button to match .btn */
input[type=file] {
  padding: 4px;
  font-size: 14px;
  color: var(--muted);
}

input[type=file]::file-selector-button {
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--btn-line);
  border-radius: 999px;
  padding: 6px 14px;
  margin-right: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s;
}

input[type=file]::file-selector-button:hover {
  border-color: var(--accent);
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.check-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}

.check-row input {
  width: auto;
}

/* ============================ Auth ============================ */
#view-auth {
  display: flex;
  justify-content: center;
  padding-top: 10vh;
}

.auth-card {
  background: var(--card-grad);
  border: 1px solid var(--card-line);
  padding: 32px;
  border-radius: var(--radius);
  width: 360px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: pop-in .35s cubic-bezier(.175, .885, .32, 1.2);
}

.auth-logo {
  margin-bottom: 6px;
}

.auth-card h1 {
  margin: 0;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
  text-align: left;
}

/* ============================ Shell ============================ */
#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 1px 0 var(--line2);
}

.brand {
  font-weight: 800;
  font-size: 21px;
  cursor: pointer;
  letter-spacing: .01em;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#topbar .right {
  margin-left: auto;
}

#topbar .icon-btn {
  font-size: 19px;
}

/* Web (default): classic top navigation, like the original layout. */
.topnav-links {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.topnav-links .navbtn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  transition: color .15s, background .15s;
}

.topnav-links .navbtn.active,
.topnav-links .navbtn:hover {
  color: var(--text);
  background: var(--card2);
}

.topnav-links .nav-ico {
  display: none;
}

#topbar-title {
  display: none;
}

#views {
  padding-bottom: 24px;
}

#bottomnav {
  display: none;
}

/* Installed PWA: bottom tab bar instead of the top links. */
body.pwa .topnav-links {
  display: none;
}

body.pwa #topbar-title {
  display: inline;
}

body.pwa #views {
  padding-bottom: 76px;
}

body.pwa #bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  gap: 4px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line2);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .28);
}

#bottomnav .navbtn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 7px 4px 8px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border-radius: 14px;
  transition: color .15s, transform .12s, background .15s, box-shadow .15s;
}

#bottomnav .nav-ico {
  font-size: 20px;
  line-height: 1;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s cubic-bezier(.175, .885, .32, 1.4);
}

#bottomnav .nav-ico svg {
  display: block;
}

#bottomnav .navbtn.active {
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent),
    0 0 14px color-mix(in srgb, var(--accent) 25%, transparent);
}

#bottomnav .navbtn.active .nav-ico {
  transform: translateY(-2px) scale(1.12);
}

#bottomnav .navbtn:active {
  transform: scale(.92);
}

.view {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

.view.slide-in {
  animation: view-in .22s ease-out;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(.94);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.card {
  background: var(--card-grad);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.hint {
  display: none;
  font-size: 12px;
  text-align: center;
  margin-top: 4px;
}

body.pwa .hint {
  display: block;
}

/* ============================ Banner (prominent alerts) ============================ */
/* Rendered as a popover so it stacks above open <dialog> modals. */
#banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  margin: 0;
  width: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  border: none;
  border-bottom: 2px solid var(--danger);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  animation: view-in .2s ease-out;
}

#banner span {
  flex: 1;
}

#banner button {
  background: none;
  border: none;
  color: inherit;
  font-size: 20px;
  cursor: pointer;
}

/* ============================ Pull-to-refresh ============================ */
.ptr {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: height .2s ease-out;
}

.ptr-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  transition: transform .2s, border-top-color .2s;
}

.ptr.ready .ptr-spinner {
  transform: rotate(180deg);
  border-top-color: var(--protein);
}

.ptr.refreshing .ptr-spinner {
  animation: spin .8s linear infinite;
}

/* ============================ Date nav ============================ */
.date-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
  position: relative;
}

.date-nav h2 {
  margin: 0;
}

.date-nav .btn.icon {
  padding: 8px 11px;
  flex-shrink: 0;
}

/* Day-chip strip: selected day raised in the centre, neighbours either side. */
.date-strip {
  flex: 1;
  display: flex;
  gap: 7px;
  min-width: 0;
  align-items: stretch;
  padding: 5px 0;
}

.day-chip {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: var(--chip-bg);
  border: 1px solid var(--card-line);
  border-radius: 12px;
  color: var(--muted);
  padding: 7px 2px;
  cursor: pointer;
  font: inherit;
  transition: transform .12s, border-color .15s, background .15s;
}

.day-chip:hover {
  border-color: var(--accent);
}

.day-chip:active {
  transform: scale(.94);
}

.day-chip.is-today .dc-dow {
  color: var(--accent);
}

.day-chip .dc-dow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
}

.day-chip .dc-date {
  font-size: 11px;
  white-space: nowrap;
}

.day-chip.center {
  flex: 1.7;
  color: var(--text);
  background: linear-gradient(160deg, rgba(104, 143, 202, .32), rgba(20, 32, 56, .85));
  border-color: rgba(148, 183, 255, .32);
  border-radius: 14px;
  z-index: 1;
  box-shadow: 0 10px 22px rgba(2, 8, 20, .5);
  transform: scale(1.1);
}

.day-chip.center:hover {
  border-color: var(--accent);
}

.day-chip.center:active {
  transform: scale(1.04);
}

[data-theme="light"] .day-chip.center {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(26, 34, 51, .18);
}

.day-chip .dc-main {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .05em;
  white-space: nowrap;
}

.day-chip .dc-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.day-chip .dc-sub::after {
  content: " \25BE";
  font-size: 10px;
}

@media (max-width: 430px) {

  .day-chip[data-offset="-2"],
  .day-chip[data-offset="2"] {
    display: none;
  }
}

#date-today:active {
  transform: translateX(-50%) scale(.94);
}

/* In the installed PWA, keep the day/date bar pinned below the topbar while
   scrolling through meals, so it's always clear which day you're editing.
   Only on the single-column layout — the wide grid uses .date-nav as a grid area. */
@media (max-width: 999px) {

  /* No top padding above the date bar: its resting position IS its pinned
     position, so scrolling can never open a gap of page background between
     it and the topbar (it used to travel ~16px, reading as a 2-3mm jump). */
  body.pwa #view-diary {
    padding-top: 0;
  }

  body.pwa #view-diary .date-nav {
    /* Overlap the topbar by 1px so no seam of page background shows between
       them; translucent + blur matches the topbar instead of the old solid
       navy, which stood out against the gradient background. */
    position: sticky;
    top: calc(var(--topbar-h, 56px) - 1px);
    z-index: 4;
    background: color-mix(in srgb, var(--bg) 72%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    margin: 0 -16px 14px;
    padding: 8px 16px;
    box-shadow: 0 6px 6px -6px rgba(0, 0, 0, .25);
  }

  /* Pin the add/search modal near the top of the screen (it centres by
     default). Centred, the on-screen keyboard hides the search box and the
     results underneath it; anchored to the top they stay visible above it. */
  body.pwa #modal-add {
    margin-top: max(8px, env(safe-area-inset-top));
    margin-bottom: auto;
    max-height: 94vh;
  }
}

/* Hidden but focusable date input that backs the picker. */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  border: 0;
  clip-path: inset(50%);
  overflow: hidden;
}

/* ============================ Day summary ============================ */
.summary-flex {
  display: flex;
  gap: 18px;
  align-items: center;
}

/* overflow: visible lets the glow breathe past the SVG box instead of
   clipping into a square at the edges. */
#cal-ring {
  width: 128px;
  height: 128px;
  flex-shrink: 0;
  overflow: visible;
}

.ring-bg {
  fill: none;
  stroke: color-mix(in srgb, var(--muted) 22%, transparent);
  stroke-width: 10;
}

.ring-fg {
  fill: none;
  stroke: var(--cal);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
  transition: stroke-dashoffset .7s cubic-bezier(.25, .8, .35, 1), stroke .3s;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--cal) var(--glow), transparent));
}

.ring-fg.over {
  stroke: var(--danger);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--danger) var(--glow), transparent));
}

.ring-num {
  fill: var(--text);
  font-size: 27px;
  font-weight: 800;
  text-anchor: middle;
}

.ring-label {
  fill: var(--muted);
  font-size: 9.5px;
  text-anchor: middle;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.macro-bars {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  margin-bottom: 4px;
  gap: 6px;
}

.bar-head span:first-child {
  color: var(--text);
}

.bar-head span:last-child {
  white-space: nowrap;
  font-weight: 700;
}

#lbl-calories {
  color: var(--cal);
}

#lbl-protein {
  color: var(--text);
}

#lbl-carbs {
  color: var(--carbs);
}

#lbl-fat {
  color: var(--fat);
}

.bar {
  background: var(--bar-track);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width .6s cubic-bezier(.25, .8, .35, 1);
}

.fill.cal {
  background: linear-gradient(90deg, color-mix(in srgb, var(--cal) 40%, var(--fill-base)), var(--cal));
  box-shadow: 0 0 10px color-mix(in srgb, var(--cal) var(--glow), transparent);
}

.fill.protein {
  background: linear-gradient(90deg, color-mix(in srgb, var(--protein) 40%, var(--fill-base)), var(--protein));
  box-shadow: 0 0 10px color-mix(in srgb, var(--protein) var(--glow), transparent);
}

.fill.carbs {
  background: linear-gradient(90deg, color-mix(in srgb, var(--carbs) 40%, var(--fill-base)), var(--carbs));
  box-shadow: 0 0 10px color-mix(in srgb, var(--carbs) var(--glow), transparent);
}

.fill.fat {
  background: linear-gradient(90deg, color-mix(in srgb, var(--fat) 40%, var(--fill-base)), var(--fat));
  box-shadow: 0 0 10px color-mix(in srgb, var(--fat) var(--glow), transparent);
}

.fill.over {
  background: linear-gradient(90deg, color-mix(in srgb, var(--danger) 45%, var(--fill-base)), var(--danger));
  box-shadow: 0 0 10px color-mix(in srgb, var(--danger) var(--glow), transparent);
}

/* Badge shown when the day's target has been adjusted; tap to edit. */
#target-adjust-note {
  display: block;
  margin: 12px auto 0;
  cursor: pointer;
  border: none;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 14px;
  border-radius: 999px;
  position: relative;
  overflow: hidden;
  transition: background .15s;
}

#target-adjust-note:hover {
  background: var(--accent);
  color: #fff;
}

@media (max-width: 480px) {
  #cal-ring {
    width: 104px;
    height: 104px;
  }

  .bar-head {
    font-size: 11.5px;
  }
}

/* ============================ Meals & entries ============================ */
.meal-block {
  background: var(--card-grad);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, outline-color .15s;
  outline: 2px solid transparent;
}

.meal-block.drop-target {
  outline-color: var(--accent);
}

.meal-head {
  padding: 13px 16px 9px;
  background: transparent;
  border-bottom: 1px solid var(--line2);
}

.meal-head-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meal-head h3 {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-size: 13.5px;
  font-weight: 800;
  flex: 1;
}

.meal-head .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Totals on their own line so kcal · P · C · F always fit. */
.meal-totals {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: nowrap;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 4px;
  white-space: nowrap;
}

.meal-totals b {
  color: var(--text);
  font-size: 14px;
}

.meal-totals .mt-p {
  color: var(--protein);
}

.meal-totals .mt-c {
  color: var(--carbs);
}

.meal-totals .mt-f {
  color: var(--fat);
}

.entry {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas:
    "name cal  del"
    "meta meta del";
  align-items: center;
  column-gap: 10px;
  row-gap: 2px;
  padding: 9px 12px 9px 14px;
  border-top: 1px solid var(--line2);
  transition: background .15s, opacity .2s, transform .2s;
  animation: entry-in .25s ease-out;
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.entry:hover {
  background: var(--accent-soft);
}

@keyframes entry-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.entry.dragging {
  opacity: .45;
  background: var(--accent-soft);
}

.entry .e-name {
  grid-area: name;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry .e-meta {
  grid-area: meta;
  font-size: 12px;
  color: var(--muted);
}

.entry .e-cal {
  grid-area: cal;
  font-size: 15.5px;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.entry .e-cal .unit {
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
}

.entry>.icon-btn {
  grid-area: del;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 8px;
  transition: color .15s, background .15s, transform .12s;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.icon-btn:active {
  transform: scale(.88);
}

.icon-btn.danger:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.meal-empty {
  padding: 14px 16px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Ghost element while dragging an entry */
#drag-ghost {
  position: fixed;
  z-index: 99;
  pointer-events: none;
  background: var(--card2);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: .92;
  max-width: 70vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================ Calendar ============================ */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.cal-dow {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 4px 0;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--card2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  border: 1px solid transparent;
  padding: 2px;
  transition: transform .12s, border-color .15s;
}

.cal-day:hover {
  border-color: var(--accent);
}

.cal-day:active {
  transform: scale(.93);
}

.cal-day.empty {
  background: none;
  cursor: default;
}

.cal-day.today {
  border-color: var(--accent);
}

.cal-day .d {
  font-size: 12px;
  color: var(--muted);
}

.cal-day .k {
  font-size: 11px;
  font-weight: 700;
}

.cal-day.under .k {
  color: var(--protein);
}

.cal-day.near .k {
  color: var(--carbs);
}

.cal-day.over .k {
  color: var(--danger);
}

.cal-legend {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 10px;
  font-size: 12px;
}

.cal-legend .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
}

.dot.under {
  background: var(--protein);
}

.dot.near {
  background: var(--carbs);
}

.dot.over {
  background: var(--danger);
}

/* ============================ Dashboard ============================ */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Grid items refuse to shrink below their content width by default, which let
   long food names push these cards wider than a phone screen. */
.grid-2col>.card {
  min-width: 0;
}

@media (max-width: 560px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
}

#dash-chart svg,
#dash-pie svg,
#dash-macro-pie svg,
#dash-protein svg,
#dash-weekday svg {
  width: 100%;
  height: auto;
  display: block;
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 700px) {
  .stat-tiles {
    grid-template-columns: repeat(6, 1fr);
  }
}

.stat-tile {
  background: var(--card-grad);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 8px;
  text-align: center;
}

.stat-tile .st-val {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
}

.stat-tile .st-val .st-unit {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.stat-tile .st-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.chart-bar {
  transition: height .5s cubic-bezier(.25, .8, .35, 1);
}

.top-food-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line2);
  font-size: 14px;
}

.top-food-row:first-child {
  border-top: none;
}

.top-food-row .tf-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-food-row .tf-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--cal);
  min-width: 3px;
}

.top-food-row .tf-cal {
  font-weight: 600;
  white-space: nowrap;
  font-size: 13px;
}

/* JSON backup & import (dashboard, web only) */
body.pwa .web-only {
  display: none;
}

hr.soft {
  border: none;
  border-top: 1px solid var(--line2);
  margin: 14px 0;
}

.import-result {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--card2);
  border-radius: 10px;
  font-size: 14px;
}

.import-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.import-plan {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.import-plan td {
  padding: 3px 0;
  border-bottom: 1px solid var(--line2);
}

.import-plan td:last-child {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
  padding-left: 12px;
}

.import-plan tr:last-child td {
  border-bottom: none;
}

.import-unmatched {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--muted);
  max-height: 200px;
  overflow-y: auto;
}

.macro-avg-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-top: 1px solid var(--line2);
  font-size: 14px;
}

.macro-avg-row:first-child {
  border-top: none;
}

.pie-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* ============================ My Foods ============================ */
.myfood-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-grad);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.myfood-row .mf-main {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  border-radius: 8px;
  transition: background .15s;
}

.myfood-row .mf-main:hover {
  background: var(--accent-soft);
}

.myfood-row .mf-name {
  font-size: 14.5px;
}

.myfood-row .mf-sub {
  font-size: 12px;
  color: var(--muted);
}

/* "Can be added to" multi-select: two columns of tickable meal chips. */
.mealfor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mealfor-opt {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--btn-line);
  border-radius: 10px;
  background: var(--chip-bg);
  color: var(--text);
  font-size: 13.5px;
  text-transform: capitalize;
  cursor: pointer;
}

.mealfor-opt:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mealfor-opt input {
  width: auto;
  flex: none;
  accent-color: var(--accent);
}

/* Overrides the column direction the base `label` rule sets, so the food name,
   its portion input and the unit stay on one line. */
.mealqty-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--card-line);
}

.mealqty-row:last-child {
  border-bottom: 0;
}

.mealqty-row .mq-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
}

.mealqty-row input {
  width: 88px;
  flex: none;
  text-align: right;
}

.mealqty-row .mq-unit {
  width: 22px;
  font-size: 12px;
  color: var(--muted);
}

.mf-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  padding: 2px 6px;
}

.meal-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  text-transform: capitalize;
  vertical-align: middle;
}

.meal-badge.any {
  background: var(--card2);
  color: var(--muted);
  text-transform: none;
}

.meal-badge.auto {
  background: var(--card2);
  color: var(--muted);
  border: 1px dashed var(--line);
  text-transform: none;
}

/* ============================ Modals ============================ */
dialog {
  background: var(--card-grad-modal);
  color: var(--text);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  padding: 18px;
  width: min(560px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--shadow);
}

dialog[open] {
  animation: modal-in .28s cubic-bezier(.175, .885, .32, 1.15);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(26px) scale(.97);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

dialog::backdrop {
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
  text-transform: capitalize;
}

/* Spread the amount/servings/meal fields across the modal width; keep the
   servings box narrow so the meal dropdown fits on phone screens. */
#modal-edit .row label,
.food-detail .row label {
  flex: 1 1 0;
  min-width: 0;
}

#edit-servings-wrap,
#serving-shortcut-wrap {
  flex: 0 0 auto !important;
}

#edit-servings,
#log-servings {
  width: 72px;
}

#food-results,
#quick-lists {
  margin-top: 12px;
}

/* Two clean columns: name + serving left, calories right (plus optional "+"). */
.food-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas:
    "name cal add"
    "serv cal add";
  column-gap: 8px;
  align-items: center;
  padding: 8px 4px 8px 6px;
  border-radius: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--line2);
  transition: background .15s, transform .1s;
}

.food-row:last-child {
  border-bottom: none;
}

.food-row:hover {
  background: var(--card2);
}

.food-row:active {
  transform: scale(.985);
}

.food-row .f-name {
  grid-area: name;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14.5px;
}

.food-row .f-name .muted {
  font-size: 12px;
}

.food-row .f-serving {
  grid-area: serv;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 1em;
}

.food-row .f-cal {
  grid-area: cal;
  font-size: 13.5px;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
}

.food-row .f-cal .per100 {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--muted);
}

/* One-tap quick add ("+" logs the last-used portion straight away). */
.quick-add-btn {
  grid-area: add;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, color .15s, transform .12s;
}

.quick-add-btn:hover {
  background: var(--accent);
  color: #fff;
}

.quick-add-btn:active {
  transform: scale(.88);
}

.quick-add-btn.done {
  background: var(--protein);
  border-color: var(--protein);
  color: #fff;
}

.quick-add-btn:disabled {
  opacity: .8;
  cursor: default;
}

/* Segmented control (quick-list scope: all foods / this meal). */
#quick-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.seg {
  display: inline-flex;
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  margin-top: 12px;
}

.seg-btn {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  transition: background .15s, color .15s;
}

.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Prominent AI/upload progress overlay (Gemini photos, OpenFoodFacts submits).
   Rendered as a popover so it stacks above any open <dialog>. */
#ai-loading {
  position: fixed;
  inset: 0;
  z-index: 10001;
  width: 100%;
  height: 100%;
  margin: 0;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(3px);
  text-align: center;
  padding: 20px;
  color: var(--text);
}

.ai-loading-text {
  font-size: 16px;
  font-weight: 700;
}

.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.list-title {
  margin: 14px 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.log-preview {
  font-weight: 600;
  color: var(--accent);
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.grid2 .span2 {
  grid-column: span 2;
}

.dates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
  margin: 10px 0;
}

.dates-grid label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}

.dates-grid input {
  width: auto;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: border-color .15s, transform .12s;
}

.chip:hover {
  border-color: var(--accent);
}

.chip:active {
  transform: scale(.94);
}

.chip .muted {
  font-size: 11px;
}

.chip .chip-plus {
  display: inline-block;
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  margin-right: 2px;
}

#scanner-box {
  margin-top: 10px;
}

#scanner {
  max-width: 400px;
  margin-bottom: 4px;
  border-radius: 10px;
  overflow: hidden;
}

#c-scanner {
  max-width: 400px;
  margin-bottom: 6px;
  border-radius: 10px;
  overflow: hidden;
}

/* Recipe builder ingredient rows */
#r-results {
  margin-top: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.r-ing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--line2);
  font-size: 13.5px;
}

.r-ing-row:first-of-type {
  border-top: none;
}

.r-ing-row .ri-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.r-ing-row input {
  width: 80px;
}

.r-ing-row .ri-cal {
  white-space: nowrap;
  min-width: 58px;
  text-align: right;
}

#pairings-box {
  margin-top: 14px;
  border-top: 1px solid var(--line2);
  padding-top: 10px;
}

#pairings-box h4 {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Bulk & photo review rows */
.bulk-row,
.photo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-top: 1px solid var(--line2);
}

.bulk-row .b-line {
  flex: 1 1 100%;
  font-size: 13px;
  color: var(--muted);
}

.bulk-row select {
  flex: 2 1 200px;
}

.bulk-row input.b-qty,
.photo-row input.p-qty {
  width: 82px;
}

.bulk-row .nomatch {
  color: var(--danger);
  font-size: 13px;
}

.photo-row .p-name {
  flex: 1;
  min-width: 140px;
  font-size: 14px;
}

.photo-row .p-macros {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--muted);
}

.photo-row input[type=checkbox] {
  width: auto;
}

.conf {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  text-transform: uppercase;
}

.conf.high {
  background: rgba(52, 201, 142, .18);
  color: var(--protein);
}

.conf.medium {
  background: rgba(242, 177, 52, .18);
  color: var(--carbs);
}

.conf.low {
  background: rgba(229, 83, 75, .18);
  color: var(--danger);
}

/* ============================ Settings extras ============================ */
.logs-box {
  max-height: 250px;
  overflow-y: auto;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-row {
  border-bottom: 1px solid var(--line2);
  padding-bottom: 4px;
}

.log-row .log-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.log-row pre {
  margin: 4px 0 0;
  background: var(--card2);
  padding: 6px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 11px;
  white-space: pre-wrap;
}

.key-reveal {
  margin-top: 10px;
  padding: 10px;
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  border-radius: 10px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  word-break: break-all;
}

.apikey-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--line2);
  font-size: 14px;
}

.apikey-row:first-child {
  border-top: none;
}

.apikey-row .ak-name {
  flex: 1;
}

.apikey-row .ak-meta {
  font-size: 12px;
  color: var(--muted);
}

/* ============================ Toast ============================ */
/* Rendered as a popover so it stacks above open <dialog> modals. */
#toast {
  position: fixed;
  top: auto;
  right: auto;
  margin: 0;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  background: color-mix(in srgb, var(--card2) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius);
  z-index: 9999;
  font-size: 14px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  max-width: 90vw;
  text-align: center;
}

body.pwa #toast {
  bottom: calc(84px + env(safe-area-inset-bottom));
}

#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

#toast.error {
  background: #991b1b;
  border-color: #ef4444;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.45);
  animation: toast-shake 0.4s ease;
}

@keyframes toast-shake {

  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }

  20%,
  60% {
    transform: translateX(-53%) translateY(0);
  }

  40%,
  80% {
    transform: translateX(-47%) translateY(0);
  }
}

/* ============================ Desktop layout ============================ */
/* The mobile layout is the baseline; on wide screens the diary becomes a
   two-column spread with a sticky summary, and everything gets more air. */
@media (min-width: 1000px) {
  .view {
    max-width: 860px;
    padding: 24px;
  }

  #view-diary {
    max-width: 1080px;
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    grid-template-areas:
      "nav    nav"
      "summary meals"
      "summary adjust"
      "summary hint";
    column-gap: 24px;
    align-items: start;
  }

  #view-diary .date-nav {
    grid-area: nav;
    max-width: 520px;
    margin: 0 auto 18px;
    width: 100%;
  }

  .ptr {
    display: none;
  }

  /* pull-to-refresh is touch-only */
  #day-summary {
    grid-area: summary;
    position: sticky;
    top: 76px;
    margin-bottom: 0;
  }

  #view-diary .summary-flex {
    flex-direction: column;
    gap: 14px;
  }

  #view-diary #cal-ring {
    width: 168px;
    height: 168px;
  }

  #view-diary .macro-bars {
    width: 100%;
  }

  #meals {
    grid-area: meals;
  }

  #view-diary>.row {
    grid-area: adjust;
  }

  #view-diary .hint {
    grid-area: hint;
  }

  /* Comfier cards, larger modals, roomier lists. */
  .card {
    padding: 20px;
  }

  dialog {
    width: min(680px, 92vw);
    padding: 24px;
  }

  .entry {
    padding: 11px 14px 11px 16px;
  }

  .food-row {
    padding: 10px 6px 10px 8px;
  }

  #topbar {
    padding: 12px 28px;
  }

  .topnav-links .navbtn {
    padding: 9px 16px;
    font-size: 15px;
  }

  /* Dashboard: wider grid. */
  #view-dashboard {
    max-width: 1000px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
/* ============================ Weight view ============================ */

#wt-chart svg,
#wt-forecast svg {
  width: 100%;
  height: auto;
}

.maint-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.maint-kcal {
  font-size: 28px;
  font-weight: 800;
}

.conf-badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-radius: 999px;
  padding: 3px 9px;
}

.conf-badge.high {
  background: rgba(52, 201, 142, .18);
  color: var(--protein);
}

.conf-badge.medium {
  background: rgba(242, 177, 52, .18);
  color: var(--carbs);
}

.conf-badge.low {
  background: rgba(255, 122, 110, .18);
  color: var(--fat);
}

.maint-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line2);
}

.maint-row:last-child {
  border-bottom: none;
}

.wt-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line2);
  font-size: 13.5px;
}

.wt-row:last-child {
  border-bottom: none;
}

.wt-row-date {
  flex: 1;
  min-width: 0;
}

.wt-row-kg {
  white-space: nowrap;
}

.wt-row-note {
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Wider layout on desktop, like the dashboard. */
@media (min-width: 760px) {
  #view-weight {
    max-width: 1000px;
  }
}
