:root {
  --background: #111418;
  --card: #1b2027;
  --border: #2c333d;
  --text: #e6e6e6;
  --muted: #8a8f98;
  /* Green, yellow and red mean a meal verdict and nothing else; the app's own accent is a
     calm blue that is not on that scale. */
  --accent: #8ab4f8;
  --green: #5cc98a;
  --yellow: #e3cf7a;
  --red: #e26d6d;
}

* { box-sizing: border-box; }

/* A quick double tap must not zoom the page, also on empty areas, so it is set on every
   element (pinch zoom still works). Meal cards keep their own pan-y for swipe-to-delete. */
*, *::before, *::after { touch-action: manipulation; }
input, textarea { touch-action: auto; }
[hidden] { display: none !important; }

body {
  margin: 0;
  /* Start clear of the status bar: iOS fades what sits right under it (2026-12-05). */
  padding: calc(env(safe-area-inset-top) + 8px) 16px max(24px, env(safe-area-inset-bottom));
  background: var(--background);
  color: var(--text);
  font: 16px/1.45 -apple-system, system-ui, sans-serif;
}

h1 { margin: 8px 0 20px; font-size: 24px; }

form { display: grid; gap: 6px; margin-top: 16px; }
form button.primary { margin-top: 12px; }

.password-row { display: flex; gap: 8px; }
.password-row input { flex: 1; }
.show-password { flex: none; width: 64px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--muted); font-size: 14px; }
label { color: var(--muted); font-size: 14px; margin-top: 8px; }
input[readonly] { color: var(--muted); }
input { width: 100%; min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); font-size: 16px; }

button { font: inherit; cursor: pointer; }
.primary { width: 100%; padding: 14px; border: 0; border-radius: 12px; background: #eef0f3; color: #14181d; font-weight: 600; }
.quiet { white-space: nowrap; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--muted); font-size: 14px; }

.message { min-height: 1.4em; color: var(--muted); font-size: 14px; }
.message.error { color: var(--red); }

.day-header { display: grid; grid-template-columns: 52px 1fr 52px; align-items: start; gap: 8px; margin: 4px 0 16px; }
.day-name { display: flex; flex-direction: column; align-items: center; min-width: 0; padding: 0; border: 0; background: none; color: var(--text); }
.day-name:disabled { opacity: 1; cursor: default; }
.day-title { font-size: 24px; font-weight: 700; line-height: 1.2; }
.day-subtitle { margin-top: 2px; color: var(--muted); font-size: 14px; }
.day-name.is-earlier-day .day-title { color: var(--accent); }
.day-arrow { width: 52px; height: 52px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); color: var(--text); font-size: 26px; line-height: 1; }
.day-arrow:disabled { opacity: 0.25; }

#invite-screen p { color: var(--muted); }
#invite-screen .quiet { width: 100%; margin-top: 10px; padding: 12px; }

.meals { list-style: none; margin: 16px 0 24px; padding: 0; display: grid; gap: 10px; }
.meal-row { position: relative; border-radius: 12px; }
.meal-row.deleting { opacity: 0.5; pointer-events: none; }

/* A card is two pages side by side: the picture and the details (swipe or click to flip,
   2026-12-04). The picture page alone sets the card's height (3:4, reserved before the
   picture loads so nothing jumps); the details scroll inside that same height. */
.meal { position: relative; overflow: hidden; border: 1px solid var(--border); border-left: 6px solid var(--border); border-radius: 12px; background: var(--card); touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: pointer; }
.meal.verdict-green { border-left-color: var(--green); }
.meal.verdict-yellow { border-left-color: var(--yellow); }
.meal.verdict-red { border-left-color: var(--red); }
/* A cleaning is not food: a grey edge instead of a verdict colour. */
.meal.kind-cleaning { border-left-color: #8a94a3; }
/* A belly photo (private) is not food either: a soft violet edge, no verdict colour. */
.meal.kind-belly { border-left-color: #a78bfa; }
.meal-pages { display: flex; }
.meal-page { flex: 0 0 100%; min-width: 0; position: relative; }
.meal-photo-frame { aspect-ratio: 3 / 4; overflow: hidden; background: #262c35; }
.meal-photo { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; opacity: 0; transition: opacity 0.25s ease; }
.meal-photo.loaded { opacity: 1; }
/* Likes (double-tap the picture): a small heart sits on the picture's bottom-left corner,
   so it takes no extra space; the time label is on the right. */
.meal-heart { position: absolute; left: 4px; bottom: 2px; display: none; padding: 6px; border: 0; background: none; color: #ffffffcc; font-size: 22px; line-height: 1; text-shadow: 0 1px 4px #000a; cursor: pointer; }
.meal.liked .meal-heart { display: block; }
.meal.liked-by-me .meal-heart { color: #ff4d6d; }
.meal-heart-pop { position: absolute; left: 50%; top: 50%; color: #fff; font-size: 96px; line-height: 1; text-shadow: 0 2px 12px #0008; opacity: 0; transform: translate(-50%, -50%) scale(0); pointer-events: none; }
.meal-heart-pop.popping { animation: heart-pop 0.8s ease forwards; }
@keyframes heart-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
  20% { opacity: 0.95; transform: translate(-50%, -50%) scale(1.15); }
  40% { transform: translate(-50%, -50%) scale(0.95); }
  70% { opacity: 0.95; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}
.meal-time-chip { position: absolute; right: 10px; bottom: 10px; padding: 3px 8px; border-radius: 999px; background: #000a; color: #fff; font-size: 12px; }
.meal-details-scroll { position: absolute; inset: 0; overflow-y: auto; padding: 12px 14px; }
/* Details are a column: the readings, then the picture model and the red Delete at the bottom. */
.meal-details-scroll { display: flex; flex-direction: column; }
.private-note { margin-top: 12px; color: #c4b5fd; font-size: 13px; }
.picture-model { margin-top: 12px; color: var(--muted); font-size: 12px; }
.meal-delete { display: block; width: 100%; margin-top: auto; padding: 11px; border: 1px solid var(--red); border-radius: 10px; background: transparent; color: var(--red); font-weight: 600; }
.meal-delete.armed { background: var(--red); color: #fff; }
.meal-hide { display: block; width: 100%; margin-bottom: 8px; padding: 11px; border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--text); font-weight: 600; }
/* Elie's buttons sit together at the bottom, under a spacer that takes the free space. */
.details-spacer { flex: 1 0 16px; }
.meal-details-scroll > .meal-delete { margin-top: 0; }
/* First-time hint on the first card's picture (top-left, over the picture, no extra space). */
.meal-hint { position: absolute; left: 10px; top: 10px; right: 10px; width: fit-content; max-width: calc(100% - 20px); padding: 5px 10px; border-radius: 999px; background: #000b; color: #fff; font-size: 12px; pointer-events: none; }
.meal-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.meal-items { margin-top: 4px; font-weight: 600; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meal-items.is-cut { cursor: pointer; }
.meal-items.is-open { -webkit-line-clamp: unset; }
.meal-verdicts { display: grid; gap: 10px; margin-top: 8px; }
.verdict-line { padding-top: 8px; border-top: 1px solid var(--border); }
.verdict-head { display: flex; align-items: center; gap: 8px; }
.verdict-head::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.verdict-line.verdict-green .verdict-head::before { background: var(--green); }
.verdict-line.verdict-yellow .verdict-head::before { background: var(--yellow); }
.verdict-line.verdict-red .verdict-head::before { background: var(--red); }
.verdict-judge { color: var(--text); font-weight: 600; font-size: 14px; }
.verdict-kcal { margin-left: auto; color: var(--text); font-size: 14px; white-space: nowrap; }
.verdict-reason { margin-top: 3px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.verdict-numbers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.number-tag { padding: 2px 8px; border-radius: 999px; background: #262c35; color: var(--text); font-size: 12px; white-space: nowrap; }
.empty { color: var(--muted); }

.crash-note { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--red); border-radius: 12px; background: var(--card); }
.crash-note p { margin: 0 0 10px; }
.crash-detail { color: var(--muted); font-size: 12px; word-break: break-word; }

/* Settings sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; background: rgba(0, 0, 0, 0.55); }
.sheet-backdrop[hidden] { display: none; }
.sheet { width: 100%; padding: 18px 16px max(18px, env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; background: var(--card); display: grid; gap: 8px; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sheet h2 { margin: 0; font-size: 18px; }
.sheet .message:empty { display: none; }
.sheet-row { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--background); color: var(--text); font-size: 16px; text-align: left; }
.sheet-row[hidden] { display: none; }
.sheet-row.danger { color: var(--red); }
.sheet-close { padding: 6px 2px 6px 12px; border: 0; background: none; color: var(--accent); font-size: 16px; font-weight: 600; }

/* Day status ("Sending…", "Reading your meal…", errors) floats at the bottom instead of
   reserving a line between the Snap button and the meals. */
#day-message {
  position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 15;
  margin: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--card); color: var(--text); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
#day-message:empty { display: none; }
#day-message.error { border-color: var(--red); color: var(--red); }

/* Big screens (Mac, iPad): controls in a centred phone-width column, meal cards in a grid
   below (2-3 per row). Phones are unchanged. */
@media (min-width: 700px) {
  body { padding-left: 32px; padding-right: 32px; }
  #sign-in-screen, #invite-screen { max-width: 420px; margin: 8vh auto 0; }
  #day-screen { max-width: 1120px; margin: 0 auto; }
  .day-header { max-width: 620px; margin-left: auto; margin-right: auto; }
  .meals { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-top: 24px; }
  /* Cards in a row are as tall as the tallest one; the card fills its row so the Delete strip stays hidden. */
  .meals .meal-row { display: flex; }
  .meals .meal-row .meal { flex: 1; }
  .meals .empty { grid-column: 1 / -1; text-align: center; }
  #day-message { left: 50%; right: auto; width: min(560px, calc(100% - 64px)); transform: translateX(-50%); }
  .sheet-backdrop { align-items: center; justify-content: center; }
  .sheet { max-width: 420px; border-radius: 20px; }
}

/* Dashboard view (?view=dashboard): no Snap row; Settings is a ⚙ in the header and "Snap a
   meal" lives in Settings. Normal phone/Mac views never show these two. */
.snap-from-settings { display: none; }

.dashboard-view .snap-from-settings:not([hidden]) { display: block; }


/* Header: back, the day, forward, Settings (since 2026-12-04 there is no Snap row). */
.day-header { grid-template-columns: 52px 1fr 52px 52px; }
.header-settings { display: inline-flex; align-items: center; justify-content: center; font-size: 22px; }

/* The "+" after the last meal opens the camera. */
/* Same navy glow the old Snap button had (inspired by the dashboard's "Breathe" banner). */
.add-meal-button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 100%; min-height: 110px; height: 100%; border: 1px solid #2b3a52; border-radius: 12px;
  background: radial-gradient(ellipse at 50% 140%, #2a4a7a 0%, #16233a 55%, #0f141c 100%);
  color: #9cc3ff; cursor: pointer; transition: transform 0.12s ease, border-color 0.12s ease;
}
.add-meal-button:active { transform: scale(0.98); }
.add-meal-plus { font-size: 40px; line-height: 1; font-weight: 300; }
.add-meal-hint { font-size: 12px; }
.add-meal-hint { color: #9cc3ffaa; }
.dashboard-view .add-meal { display: none; }

/* Settings: which version is running (and whether belly photos are private). */
.version-line { margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
