:root {
  --primary:      #22c55e;
  --primary-dark: #16a34a;
  --danger:       #ef4444;
  --warn:         #f59e0b;
  --bg:           #0f172a;
  --surface:      #1e293b;
  --text:         #f1f5f9;
  --muted:        #94a3b8;
  --border:       #334155;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ─────────────────────────────────────── */
header {
  position: relative;
  padding: 1.25rem 1rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
header h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.5px; }
header h1 .ai { color: var(--primary); }
#daily-total { margin-top: 0.35rem; font-size: 0.95rem; color: var(--muted); }
#daily-total strong { color: var(--primary); font-size: 1.15rem; }

#macro-totals {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}
#macro-totals strong { color: var(--text); }

/* ── AUTH ────────────────────────────────────────── */
#auth-section {
  position: absolute;
  top: 0.85rem;
  left: 1rem;
}
.auth-btn {
  font-size: 0.78rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.auth-btn:hover { border-color: var(--primary); color: var(--primary); }
.auth-signed-in { display: flex; align-items: center; gap: 0.5rem; }
.auth-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }

.auth-widget {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.auth-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
  max-width: 220px;
  white-space: normal;
  line-height: 1.4;
}
.auth-widget:hover .auth-tooltip { opacity: 1; }

/* ── RECORD SECTION ─────────────────────────────── */
.record-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem 1.5rem;
  gap: 1.25rem;
}

#record-btn {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 3.2rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.4);
  line-height: 1;
}
#record-btn:hover:not(:disabled) { transform: scale(1.06); }
#record-btn:disabled { cursor: not-allowed; }

#record-btn.recording {
  background: var(--danger);
  animation: pulse 1.3s ease-in-out infinite;
}
#record-btn.processing { background: var(--warn); }

.record-btns {
  position: relative;
  width: 130px;
  height: 130px;
}

#photo-btn {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  background: var(--surface);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
#photo-btn:hover:not(:disabled) { transform: scale(1.1); background: var(--border); }
#photo-btn:disabled { cursor: not-allowed; opacity: 0.5; }
#photo-btn.processing { background: var(--warn); border-color: var(--warn); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0  0   rgba(239,68,68,0.55); }
  70%  { box-shadow: 0 0 0 22px rgba(239,68,68,0);    }
  100% { box-shadow: 0 0 0  0   rgba(239,68,68,0);    }
}

#waveform {
  width: 220px;
  height: 44px;
  border-radius: 8px;
}

#status {
  font-size: 1rem;
  color: var(--muted);
  min-height: 1.4em;
  text-align: center;
  max-width: 320px;
}
#status.error   { color: var(--danger); }
#status.success { color: var(--primary); }

#transcript {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  max-width: 320px;
  font-style: italic;
  min-height: 1.2em;
  margin-top: 0.25rem;
}

#text-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  background: var(--surface);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
#text-btn:hover:not(:disabled) { transform: scale(1.1); background: var(--border); }
#text-btn:disabled { cursor: not-allowed; opacity: 0.5; }

#text-track-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 1.25rem;
  width: min(340px, 90vw);
  margin: auto;
}
#text-track-dialog::backdrop { background: rgba(0,0,0,0.55); }
.text-track-label {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}
#text-track-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#text-track-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}
#text-track-input::placeholder { color: var(--muted); }
#text-track-input:focus { border-color: var(--primary); }
.text-track-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.text-track-cancel {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.text-track-cancel:hover { color: var(--text); border-color: var(--text); }
#text-track-btn {
  background: var(--primary);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: opacity 0.15s;
}
#text-track-btn:disabled { opacity: 0.4; cursor: default; }

/* ── LOG LIST ───────────────────────────────────── */
/* Tell the browser to handle only vertical scroll natively so horizontal
   swipe events reach our JS handler on real touch devices. */
html, body { touch-action: pan-y; }

/* ── SWIPE / DAY-NAVIGATION ANIMATIONS ─────────────── */
@keyframes slideInFromLeft {
  from { transform: translateX(-40px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
@keyframes slideInFromRight {
  from { transform: translateX(40px);  opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
.slide-from-left  { animation: slideInFromLeft  0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94); }
.slide-from-right { animation: slideInFromRight 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94); }

.logs-section {
  flex: 1;
  padding: 0 1rem 2rem;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.logs-header h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

#export-btn, #add-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
#export-btn:hover, #add-btn:hover { border-color: var(--primary); color: var(--primary); }
#add-btn { font-size: 1.1rem; padding: 0.15rem 0.65rem; }

/* ── DAY NAVIGATION ─────────────────────────────── */
.day-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#day-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  min-width: 6rem;
  text-align: center;
}

.day-nav-btn, #prev-day, #next-day {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
#prev-day:hover, #next-day:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
#next-day:disabled { opacity: 0.3; cursor: default; }

#log-list { display: flex; flex-direction: column; gap: 0.6rem; }
#log-list.collapsed { display: none; }

#entries-toggle {
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0.35rem 0.25rem;
  cursor: pointer;
  text-align: left;
  width: 100%;
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}
#entries-toggle:hover { color: var(--text); }

/* ── MEAL GROUPS ─────────────────────────────────────────────────────────── */

.meal-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 0.6rem;
}

.meal-group-header {
  background: var(--surface);
  border: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: filter 0.15s;
}
.meal-group-header:hover { filter: brightness(1.12); }

.meal-group--open .meal-group-header {
  border-bottom: 1px solid var(--border);
}

.meal-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  min-width: 5rem;
}

.meal-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.meal-macros {
  display: flex;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.meal-kcal {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 3.75rem;
  text-align: right;
}

.meal-chevron {
  font-size: 0.55rem;
  color: var(--muted);
  display: inline-block;
  transition: transform 0.2s ease;
  transform: rotate(0deg);
}
.meal-group--open .meal-chevron { transform: rotate(90deg); }

.meal-entries {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.4rem;
  background: var(--bg);
}

.meal-entries .log-entry { border-radius: 7px; }


.edit-meal-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}
.edit-meal-label select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.78rem;
  padding: 0.15rem 0.3rem;
  cursor: pointer;
}

.log-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  animation: slideIn 0.25s ease;
}

.log-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  align-self: center;
  background: var(--border);
}
.log-thumb--loading {
  opacity: 0;
  transition: opacity 0.3s ease;
}
.log-thumb:not(.log-thumb--loading) {
  opacity: 1;
}

.log-left { display: flex; flex-direction: column; flex: 1; min-width: 0; }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0);    }
}

.log-food { font-size: 0.95rem; font-weight: 500; }
.log-time { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

.log-macros {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
}

/* Macro colour labels */
.macro-p  { color: #60a5fa; font-weight: 600; } /* blue  - protein */
.macro-c  { color: #fbbf24; font-weight: 600; } /* amber - carbs   */
.macro-f  { color: #f87171; font-weight: 600; } /* red   - fat     */
.macro-fi { color: #a78bfa; font-weight: 600; } /* violet- fibre   */

.log-right { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }

.log-calories { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.log-calories span { font-size: 0.72rem; font-weight: 400; color: var(--muted); }

.delete-btn {
  background: none;
  border: none;
  color: var(--border);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0 0.2rem;
  transition: color 0.15s;
  line-height: 1;
}
.delete-btn:hover { color: var(--danger); }

.edit-btn {
  background: none;
  border: none;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0 0.2rem;
  opacity: 0.5;
  transition: opacity 0.15s;
  line-height: 1;
}
.edit-btn:hover { opacity: 1; }

.edit-fields {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.edit-macros {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.edit-macros label {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}
.edit-macros input {
  width: 3.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.78rem;
  padding: 0.2rem 0.3rem;
  text-align: right;
}

.edit-time-label { margin-left: auto; }
.edit-time {
  min-width: 5.5rem;
  width: auto;
  text-align: left;
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 0.2rem 0.3rem;
  color-scheme: dark;
}
.edit-food {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--primary);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.3rem 0.5rem;
}
.edit-calories {
  width: 5rem;
  background: var(--bg);
  border: 1px solid var(--primary);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.3rem 0.5rem;
  text-align: right;
}
.edit-unit { font-size: 0.75rem; color: var(--muted); }

.save-btn {
  background: var(--primary);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}
.save-btn:hover { background: var(--primary-dark); }

.cancel-btn {
  background: none;
  border: none;
  color: var(--border);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0 0.2rem;
  transition: color 0.15s;
}
.cancel-btn:hover { color: var(--danger); }

#empty-state {
  text-align: center;
  padding: 2.5rem 0;
  color: var(--muted);
  font-size: 0.95rem;
}

#cal-chart, #chart-protein, #chart-carbs, #chart-fat, #chart-fibre {
  display: none;
  width: 100%;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}

/* ── CHART SECTIONS ─────────────────────────────── */
.chart-section {
  margin-top: 1.25rem;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

#targets-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 2.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.15s;
}
#targets-btn:hover { color: var(--primary); }

.macro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.macro-subplot {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.macro-subplot-header {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── CONFIRM DIALOG ──────────────────────────────── */
#confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
#confirm-overlay.active { display: flex; }

#confirm-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  min-width: 260px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#confirm-message {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}
#confirm-message small { font-size: 0.8rem; }

.confirm-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ── TARGETS DIALOG ─────────────────────────────── */
#targets-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
}
#targets-overlay.open { display: block; }

#targets-dialog {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 101;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  min-width: 260px;
  gap: 0.8rem;
  flex-direction: column;
}
#targets-dialog.open { display: flex; }

#targets-dialog h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

#targets-dialog label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}
#targets-dialog label span { min-width: 4.5rem; font-weight: 600; }
#targets-dialog input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.3rem 0.5rem;
  text-align: right;
  max-width: 5rem;
}

.targets-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
}
.targets-actions button {
  background: var(--primary);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.85rem;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
}
.targets-actions button:hover { background: var(--primary-dark); }

.macro-cal { color: #22c55e; font-weight: 600; }

/* ── FOOTER ─────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.25rem 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}
footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}
footer a:hover { color: var(--primary); }

/* ── IOS INSTALL BANNER ─────────────────────────── */
#ios-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 2px solid var(--primary);
  padding: 0.9rem 1rem 1.2rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  z-index: 999;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
#ios-install-banner .banner-icon { font-size: 1.6rem; flex-shrink: 0; }
#ios-install-banner .banner-text { flex: 1; font-size: 0.82rem; line-height: 1.5; }
#ios-install-banner .banner-text strong { color: var(--text); display: block; margin-bottom: 0.2rem; }
#ios-install-banner .banner-text span { color: var(--muted); }
#ios-install-banner .banner-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
}
#ios-install-banner .banner-close:hover { color: var(--danger); }

/* ── TRENDS BUTTON ──────────────────────────────── */
#trends-btn {
  position: absolute;
  top: 1.1rem;
  right: 4.2rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.15s;
}
#trends-btn:hover { color: var(--primary); }

/* ── TRENDS SLIDE-UP PANEL ──────────────────────── */
#trends-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 150;
}
#trends-overlay.open { display: block; }

#trends-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 1rem 1rem 2rem;
  z-index: 151;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
#trends-panel.open { transform: translateY(0); }

.trends-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 700;
}
.trends-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  transition: color 0.15s;
}
.trends-close-btn:hover { color: var(--danger); }

/* Period pill toggle */
.trends-period {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.trends-period-btn {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.trends-period-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Stats row */
#trends-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.trends-stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.5rem;
  text-align: center;
}
.trends-stat-label {
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}
.trends-stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.trends-stat-value.positive { color: var(--primary); }
.trends-stat-value.negative { color: var(--danger); }
.trends-stat-unit { font-size: 0.65rem; color: var(--muted); font-weight: 400; }

/* Metric toggle */
.trends-metric {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.trends-metric-btn {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.25rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.trends-metric-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Hint icon & description */
.hint-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0 0.15rem;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
}
.hint-btn:hover { color: var(--primary); }

.trends-chart-hint {
  font-size: 0.76rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.45;
  margin: 0.2rem 0 0.6rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border-left: 2px solid var(--border);
  border-radius: 0 6px 6px 0;
}

/* See-trends button at bottom of daily view */
.see-trends-btn {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.65rem 1rem;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, color 0.15s;
}
.see-trends-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Trends chart sections */
.trends-chart-section {
  margin-top: 1.25rem;
}

#trends-bar-chart,
#trends-deficit-chart,
#trends-heatmap,
#trends-rhythm-chart {
  display: block;
  width: 100%;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}

/* Heatmap legend */
.heatmap-legend {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.68rem;
  color: var(--muted);
  align-items: center;
  flex-wrap: wrap;
}
.heatmap-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  margin-right: 3px;
  vertical-align: middle;
}

/* ── STREAK BADGE ───────────────────────────────── */
#streak-display {
  text-align: center;
  padding: 0.25rem 0 0;
}
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(251,191,36,0.1);
  border: 1px solid rgba(251,191,36,0.3);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  color: #fbbf24;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}


