/* ================================================================
   Dashboard — Bento / Whimsical Theme
   Matches health-goals.html candy palette
   ================================================================ */

/* Home Dot Button */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@600&display=swap');
.home-dot {
  position: fixed;
  top: calc(2rem + env(safe-area-inset-top, 0px));
  right: calc(2rem + env(safe-area-inset-right, 0px));
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  box-shadow: 0 4px 15px rgb(230, 0, 255);
  transition: all 0.3s ease;
  cursor: pointer;
  text-decoration: none;
}
.home-dot:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(240, 147, 251, 0.6);
}
.dot-pulse {
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  position: relative;
}
.dot-pulse::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: white;
  border-radius: 50%;
  animation: dotpulse 2s ease-out infinite;
}
@keyframes dotpulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}

:root {
  --dash-bg: #fef9f0;
  --dash-font: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --dash-hero-font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --dash-purple: #a855f7;
  --dash-pink: #f472b6;
  --dash-yellow: #fbbf24;
  --dash-blue: #60a5fa;
  --dash-green: #34d399;
  --dash-dark: #1e1b4b;
  --dash-muted: #6b7280;
  --dash-card: rgba(255,255,255,0.78);
  --dash-border: rgba(168,85,247,0.12);
  --dash-radius: 22px;
  --dash-radius-sm: 14px;
  --dash-shadow: 0 4px 24px rgba(168,85,247,0.08);
}

/* ── Page background ─────────────────────────── */
body {
  margin: 0;
  font-family: var(--dash-font);
  background: linear-gradient(160deg, #b1cbae 0%, #12d600 30%, #00771c 65%, #4ab24e 100%);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Hero greeting only — keep dashboard title typography */
.dash-hero-left,
.dash-hero-left * {
  font-family: var(--dash-hero-font) !important;
}

/* Blobs */
.dash-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  animation: blobFloat 14s ease-in-out infinite alternate;
}
.dash-blob-1 { width: 380px; height: 380px; top: -80px; right: -60px; background: radial-gradient(circle, var(--dash-pink), transparent 70%); }
.dash-blob-2 { width: 300px; height: 300px; bottom: 15%; left: -80px; background: radial-gradient(circle, var(--dash-blue), transparent 70%); animation-delay: -5s; }
.dash-blob-3 { width: 260px; height: 260px; top: 55%; right: 10%; background: radial-gradient(circle, var(--dash-yellow), transparent 70%); animation-delay: -9s; }

@keyframes blobFloat {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(20px, -20px) scale(1.08); }
  100% { transform: translate(-10px, 15px) scale(0.95); }
}

/* ── Container ───────────────────────────────── */
.dashboard-container {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: calc(2rem + env(safe-area-inset-top, 0px)) 1.5rem 1rem;
}

/* ── Hero ─────────────────────────────────────── */
.dash-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.dash-eyebrow {
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dash-purple);
  margin: 0 0 0.25rem;
}

.dash-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--dash-dark);
  margin: 0 0 0.35rem;
  line-height: 1.15;
}

.gradient-text {
background: linear-gradient(135deg, #9500a5 0%, #0008ff 100%);
 -webkit-background-clip: text;
  background-clip: text;
}

.dash-subtitle {
  font-size: 1rem;
  font-weight:500;
  color: white;
  margin: 0;
}

/* Quick stats row */
.dash-hero-right {
  display: flex;
  gap: 1rem;
}

.dash-quick-stat {
  background: var(--dash-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--dash-border);
  border-radius: var(--dash-radius-sm);
  padding: 0.75rem 1.1rem;
  text-align: center;
  min-width: 75px;
  box-shadow: var(--dash-shadow);
}

.dash-qs-num {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--dash-purple);
  line-height: 1.1;
}

.dash-qs-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dash-muted);
  margin-top: 2px;
}

/* ── Bento Grid ──────────────────────────────── */
.bento {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.bento-card {
  background: var(--dash-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--dash-border);
  border-radius: var(--dash-radius);
  box-shadow: var(--dash-shadow);
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.25s ease;
  animation: bentoIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}

.bento-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(168,85,247,0.14);
}

@keyframes bentoIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bento-card:nth-child(1) { animation-delay: 0s; }
.bento-card:nth-child(2) { animation-delay: 0.06s; }
.bento-card:nth-child(3) { animation-delay: 0.12s; }
.bento-card:nth-child(4) { animation-delay: 0.18s; }
.bento-card:nth-child(5) { animation-delay: 0.24s; }

.bento-card.hidden { display: none; }

/* Span rules */
.bento-sub         { grid-column: 1 / -1; }
.bento-master      { grid-column: 1 / -1; }
.bento-achievements { grid-column: 1 / -1; }
.bento-cta          { grid-column: 1 / -1; }

/* ── Card header ─────────────────────────────── */
.bento-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(168,85,247,0.06);
}

.bento-card-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--dash-dark);
}

.bento-card-body {
  padding: 1.25rem;
}

.bento-body-text {
  font-size: 1.2rem;
  color: white;
  line-height: 1.5;
  margin: 0 0 1rem;
}

/* ── Pills (badges) ──────────────────────────── */
.pill {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  animation: pillPop 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes pillPop { from { transform: scale(0.7); opacity: 0; } }

.pill-active  { background: linear-gradient(135deg, var(--dash-green), #059669); color: #fff; }
.pill-trial   { background: linear-gradient(135deg, var(--dash-yellow), #d97706); color: #fff; }
.pill-inactive{ background: #e5e7eb; color: var(--dash-muted); }
.pill-master  { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #78350f; }
.pill-gold    { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #78350f; }

/* ── Subscription status rows ────────────────── */
.status-rows {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.status-rows.status-empty {
  align-items: center;
  text-align: center;
  padding: 2rem 1.25rem;
}

.status-empty .empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.status-empty p { margin: 0; color: var(--dash-muted); font-size: 0.95rem; }
.status-empty .empty-hint { font-size: 0.82rem; color: #9ca3af; }

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(168,85,247,0.06);
}

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

.s-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--dash-dark);
}

.s-value {
  font-size: 0.88rem;
  color: var(--dash-muted);
}

.s-highlight { color: var(--dash-purple); font-weight: 700; }
.s-success   { color: var(--dash-green); font-weight: 700; }

/* ── Master card ─────────────────────────────── */
.bento-master {
  background: linear-gradient(135deg, rgba(251,191,36,0.15), rgba(245,158,11,0.1));
  border-color: rgba(251,191,36,0.3);
}

.check-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.check-list li {
  padding: 0.45rem 0;
  font-size: 0.88rem;
  color: var(--dash-dark);
  border-bottom: 1px dashed rgba(168,85,247,0.08);
}

.check-list li::before {
  content: '✓ ';
  color: var(--dash-green);
  font-weight: 700;
}

/* ── Feature tiles ───────────────────────────── */
.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 1rem 1.1rem;
}

.feature-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0.9rem 0.5rem;
  border-radius: var(--dash-radius-sm);
  background: rgba(168,85,247,0.04);
  border: 1px solid rgba(168,85,247,0.06);
  transition: background 0.2s ease, transform 0.2s ease;
}

.feature-tile:hover {
  background: rgba(168,85,247,0.1);
  transform: translateY(-2px);
}

.feature-emoji { font-size: 1.6rem; }

.feature-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--dash-dark);
  text-align: center;
  line-height: 1.2;
}

.feature-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fb-unlocked { background: #d1fae5; color: #059669; }
.fb-locked   { background: #fee2e2; color: #ef4444; }

/* ── Action buttons stack ────────────────────── */
.action-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 1rem 1.1rem;
}

.action-btn {
  display: block;
  text-align: center;
  padding: 0.7rem 1rem;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.action-btn:hover { transform: translateY(-2px); }
.action-btn:active { transform: scale(0.97); }

.action-primary {
  background: linear-gradient(135deg, var(--dash-purple), var(--dash-pink));
  color: #fff;
  box-shadow: 0 4px 14px rgba(168,85,247,0.3);
}

.action-secondary {
  background: rgba(168,85,247,0.08);
  color: var(--dash-purple);
}

.action-danger {
  background: rgba(239,68,68,0.08);
  color: #ef4444;
}

.action-btn.hidden { display: none; }

/* ── CTA card ────────────────────────────────── */
.bento-cta {
  background: linear-gradient(135deg, rgba(239,68,68,0.06), rgba(236,72,153,0.08));
  border-color: rgba(239,68,68,0.15);
}

.cta-inner {
  padding: 2rem 1.5rem;
  text-align: center;
}

.cta-icon { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; }

.cta-inner h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--dash-dark);
}

.cta-inner p {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--dash-muted);
}

/* ── Footer ──────────────────────────────────── */
.dash-footer {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  margin-top: auto;
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.78rem;
  color: #9ca3af;
}

.dash-footer p { margin: 0; }

/* ── Loading ─────────────────────────────────── */
.loading-spinner {
  text-align: center;
  padding: 2rem;
  color: var(--dash-muted);
  font-size: 0.9rem;
}

.loading-spinner::after {
  content: '';
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid #e5e7eb;
  border-radius: 50%;
  border-top-color: var(--dash-purple);
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

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

/* ── Achievements (reused from renderBadges) ── */
.ach-stats {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(168,85,247,0.08);
}

.ach-stat { display: flex; flex-direction: column; align-items: center; }
.ach-stat-num { font-size: 1.6rem; font-weight: 700; color: var(--dash-purple); }
.ach-stat-label { font-size: 0.7rem; color: var(--dash-muted); text-transform: uppercase; letter-spacing: 0.04em; }

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

.ach-card {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-radius: var(--dash-radius-sm);
  background: rgba(168,85,247,0.03);
  border: 1.5px solid transparent;
  transition: all 0.25s ease;
}

.ach-card.ach-unlocked {
  background: rgba(251,191,36,0.1);
  border-color: rgba(251,191,36,0.35);
}

.ach-card.ach-maxed {
  background: linear-gradient(135deg, rgba(254,243,199,0.7), rgba(253,230,138,0.5));
  border-color: #f59e0b;
  box-shadow: 0 2px 10px rgba(245,158,11,0.15);
}

.ach-icon { font-size: 1.8rem; flex-shrink: 0; line-height: 1; margin-top: 2px; }

.ach-icon.ach-icon-lottie {
  width: 52px; height: 52px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(168,85,247,0.06);
}

.ach-info { flex: 1; min-width: 0; }
.ach-title { font-weight: 700; font-size: 0.82rem; color: var(--dash-dark); margin-bottom: 1px; }
.ach-tier { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 3px; }
.ach-desc { font-size: 0.68rem; color: var(--dash-muted); line-height: 1.35; margin-bottom: 5px; }

.ach-bar-track { width: 100%; height: 4px; border-radius: 2px; background: #e5e7eb; overflow: hidden; }
.ach-bar-fill  { height: 100%; border-radius: 2px; transition: width 0.6s ease; }
.ach-progress  { font-size: 0.6rem; color: #9ca3af; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 640px) {
  .dashboard-container { padding: calc(1.25rem + env(safe-area-inset-top, 0px)) 1rem 1rem; }

  .home-dot {
    width: 40px;
    height: 40px;
    top: calc(1rem + env(safe-area-inset-top, 0px));
    right: calc(1rem + env(safe-area-inset-right, 0px));
  }
  .dot-pulse {
    width: 16px;
    height: 16px;
  }

  .dash-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .dash-title { font-size: 1.65rem; }

  .dash-hero-right { width: 100%; justify-content: space-between; }

  .bento {
    grid-template-columns: 1fr;
  }

  .feature-grid {
    grid-template-columns: 1fr 1fr;
  }

  .ach-grid {
    grid-template-columns: 1fr;
  }

  .ach-icon.ach-icon-lottie { width: 46px; height: 46px; }
}

/* ================================================================
   Nutrition Journal
   ================================================================ */
.bento-journal { grid-column: 1 / -1; }

.bento-journal-header {
  flex-wrap: wrap;
  gap: 10px;
}

.bento-journal-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.journey-coach-slot {
  display: inline-flex;
  align-items: center;
}

/* Daily Chew streak — themed in daily-quiz.css */

.journal-container { padding: 1rem 1.1rem; }

.journal-empty {
  text-align: center;
  padding: 2rem 1rem;
}
.journal-empty-icon { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; }
.journal-empty-text { margin: 0; font-size: 0.95rem; color: var(--dash-muted); }
.journal-empty-hint { margin: 4px 0 0; font-size: 0.82rem; color: #9ca3af; }

/* Scrollable horizontal grid */
.journal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

/* Individual bento card */
.journal-card {
  all: unset;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border-radius: var(--dash-radius-sm);
  background: rgb(246, 236, 255);
  border: 1.5px solid rgba(255, 223, 128, 0.285);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.journal-free-note {
  margin: 0 1.1rem 0.5rem;
  font-size: 0.78rem;
  color: var(--dash-muted);
  line-height: 1.4;
}

.journal-view-tabs {
  display: flex;
  gap: 8px;
  padding: 0 1.1rem 0.65rem;
}

.journal-tab {
  border: 1px solid rgba(168,85,247,0.15);
  background: rgba(255,255,255,0.6);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--dash-muted);
}

.journal-tab.is-active {
  background: rgba(168,85,247,0.12);
  border-color: rgba(168,85,247,0.35);
  color: var(--dash-purple);
}

.journal-totals-bar {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  margin: 0 1.1rem 0.75rem;
  padding: 0.65rem 0.5rem;
  border-radius: 12px;
  background: rgba(0,168,204,0.06);
  border: 1px solid rgba(0,168,204,0.12);
}

.jt-item { text-align: center; }
.jt-val { display: block; font-weight: 800; font-size: 0.95rem; color: var(--dash-dark); }
.jt-lbl { display: block; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dash-muted); }

.journal-period-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 1.1rem 0.65rem;
  scrollbar-width: none;
}

.journal-period-chip {
  flex: 0 0 auto;
  border: 1px solid rgba(168,85,247,0.12);
  background: #fff;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--dash-muted);
}

.journal-period-chip.is-active {
  background: rgba(168,85,247,0.1);
  color: var(--dash-purple);
  border-color: rgba(168,85,247,0.3);
}

.jc-date-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.jc-ftm-badge {
  font-size: 0.85rem;
  line-height: 1;
}

.jc-stats--manual .jc-manual-tag {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #00a8cc;
  background: rgba(0,168,204,0.1);
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
}

.jd-netcarbs-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 12px;
  background: var(--jd-surface, rgba(255, 255, 255, 0.24));
  border: 1px solid var(--jd-surface-border, rgba(255, 255, 255, 0.34));
}

.jd-netcarbs-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.78rem;
}

.jd-netcarbs-copy strong { font-size: 0.82rem; color: var(--dash-dark); }
.jd-netcarbs-copy span { color: var(--jd-muted-text, var(--dash-muted)); font-size: 0.68rem; }

.jd-netcarbs-val {
  font-weight: 800;
  font-size: 1rem;
  color: var(--dash-dark);
}

.jd-netcarbs-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}

.jd-netcarbs-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.jd-netcarbs-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  transition: background 0.2s;
}

.jd-netcarbs-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.jd-netcarbs-toggle input:checked + .jd-netcarbs-slider {
  background: var(--dash-dark);
}

.jd-netcarbs-toggle input:checked + .jd-netcarbs-slider::before {
  transform: translateX(18px);
}

.jd-ftm-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 0.75rem;
}

.jd-header-emoji { position: relative; }

.jd-manual-note {
  font-size: 0.82rem;
  color: var(--jd-muted-text, var(--dash-muted));
  padding: 0.5rem 0;
}

.journal-card:hover,
.journal-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(168,85,247,0.12);
  border-color: rgba(168,85,247,0.25);
}

.journal-card:active { transform: scale(0.97); }

.jc-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.jc-emoji { font-size: 1.5rem; }

.jc-date {
  font-size: 0.6rem;
  font-weight: 600;
  color: #9ca3af;
  text-align: right;
  line-height: 1.35;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.jc-name {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--dash-dark);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.jc-stats {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 2px;
}

.jc-peak {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--dash-purple);
  line-height: 1;
}

.jc-peak small {
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--dash-muted);
}

/* Severity pill */
.jc-sev {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 100px;
}

.sev-green  { background: #d1fae5; color: #059669; }
.sev-yellow { background: #fef3c7; color: #d97706; }
.sev-orange { background: #ffedd5; color: #ea580c; }
.sev-red    { background: #fee2e2; color: #dc2626; }

.jc-macros {
  display: flex;
  gap: 6px;
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--dash-muted);
  margin-top: auto;
}

/* ── Journal Detail Modal ────────────────────── */
.jd-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.jd-overlay.jd-visible { opacity: 1; }

.jd-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: #009211;
  --jd-muted-text: #0f3322;
  --jd-surface: rgb(255, 255, 255);
  --jd-surface-border: rgba(255, 255, 255, 0.34);
  --jd-divider: rgb(255, 255, 255);
  border-radius: 24px 24px 0 0;
  padding: 1.5rem 1.5rem 2rem;
  box-shadow: 0 -12px 44px rgba(0, 48, 12, 0.38);
  transform: translateY(30px);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.jd-visible .jd-sheet { transform: translateY(0); }

.jd-close {
  position: absolute;
  top: 12px; right: 16px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.35rem;
  color: var(--dash-dark);
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.jd-close:hover {
  background: rgba(255, 255, 255, 0.32);
}

.jd-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.25rem;
}

.jd-header-emoji { font-size: 2.2rem; }

.jd-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--dash-dark);
  line-height: 1.25;
}

.jd-date {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--jd-muted-text, var(--dash-muted));
}

.jd-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 1rem;
}

.jd-stat {
  text-align: center;
  padding: 10px 6px;
  border-radius: var(--dash-radius-sm);
  background: var(--jd-surface, rgba(255, 255, 255, 0.24));
  border: 1px solid var(--jd-surface-border, rgba(255, 255, 255, 0.34));
}

.jd-stat-num {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--dash-dark);
  line-height: 1.1;
}

.jd-stat-label {
  display: block;
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--jd-muted-text, var(--dash-muted));
  margin-top: 2px;
}

.jd-sev-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--jd-divider, rgba(0, 0, 0, 0.14));
  border-bottom: 1px solid var(--jd-divider, rgba(0, 0, 0, 0.14));
}

.jd-sev-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--dash-dark);
}

.jd-macros-bar {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 1rem;
}

.jd-macro {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--jd-surface, rgba(255, 255, 255, 0.24));
  border: 1px solid var(--jd-surface-border, rgba(255, 255, 255, 0.34));
}

.jd-macro-val {
  font-size: 1rem;
  font-weight: 800;
  color: var(--dash-dark);
}

.jd-macro-label {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--jd-muted-text, var(--dash-muted));
  margin-top: 1px;
}

/* Meal components list */
.jd-components {
  margin-bottom: 1rem;
}

.jd-components h4 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--dash-dark);
}

.jd-comp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed var(--jd-divider, rgba(0, 0, 0, 0.14));
  font-size: 0.78rem;
}

.jd-comp-name { color: var(--dash-dark); font-weight: 600; }
.jd-comp-macro { color: var(--jd-muted-text, var(--dash-muted)); font-size: 0.68rem; font-weight: 600; }

.jd-mode-tag {
  text-align: center;
  font-size: 0.68rem;
  color: var(--jd-muted-text, #6b7280);
  margin: 0;
}

/* Severity pills inside green detail sheet — keep pill colors, add subtle edge */
.jd-sheet .jc-sev {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

/* ── Journal responsive ──────────────────────── */
@media (max-width: 640px) {
  .journal-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .jd-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .jd-macros-bar {
    flex-wrap: wrap;
  }
}

/* ================================================================
   Night Mode — Dashboard
   Applied when body.night-mode is set by theme-toggle.js
   ================================================================ */
body.night-mode {
  --dash-bg: #0d0d1a;
  --dash-card: rgba(22, 20, 48, 0.85);
  --dash-border: rgba(139, 92, 246, 0.18);
  --dash-dark: #e9e4ff;
  --dash-muted: #9a93c4;
  --dash-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

body.night-mode {
  background: linear-gradient(160deg, #0d0d1a 0%, #130d24 35%, #0f0f2a 65%, #0a101e 100%);
}

/* Blobs — dimmer in night mode */
body.night-mode .dash-blob { opacity: 0.18; }

/* Bento cards */
body.night-mode .bento-card {
  background: var(--dash-card);
  border-color: var(--dash-border);
}
body.night-mode .bento-card:hover {
  box-shadow: 0 8px 32px rgba(139, 92, 246, 0.22);
}

/* Card header separator */
body.night-mode .bento-card-header {
  border-bottom-color: rgba(139, 92, 246, 0.1);
}

/* Quick stat boxes */
body.night-mode .dash-quick-stat {
  background: rgba(22, 20, 48, 0.9);
  border-color: rgba(139, 92, 246, 0.2);
}

/* Achievement cards */
body.night-mode .ach-card {
  background: rgba(139, 92, 246, 0.06);
  border-color: rgba(139, 92, 246, 0.12);
}
body.night-mode .ach-card.ach-unlocked {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.25);
}
body.night-mode .ach-card.ach-maxed {
  background: linear-gradient(135deg, rgba(120, 80, 0, 0.35), rgba(100, 65, 0, 0.25));
  border-color: #92710a;
}
body.night-mode .ach-bar-track { background: rgba(255,255,255,0.08); }
body.night-mode .ach-progress { color: #6b63a0; }

/* Journal cards */
body.night-mode .journal-card {
  background: rgba(139, 92, 246, 0.06);
  border-color: rgba(139, 92, 246, 0.12);
}
body.night-mode .journal-card:hover,
body.night-mode .journal-card:focus-visible {
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.18);
}

/* Severity pills — night friendly */
body.night-mode .sev-green  { background: rgba(16, 185, 129, 0.15); color: #34d399; }
body.night-mode .sev-yellow { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
body.night-mode .sev-orange { background: rgba(234, 88, 12, 0.15);  color: #fb923c; }
body.night-mode .sev-red    { background: rgba(239, 68, 68, 0.15);  color: #f87171; }

/* CTA card */
body.night-mode .bento-cta {
  background: linear-gradient(135deg, rgba(239,68,68,0.08), rgba(236,72,153,0.1));
  border-color: rgba(239,68,68,0.2);
}
body.night-mode .cta-inner h2 { color: var(--dash-dark); }

/* Action buttons */
body.night-mode .action-secondary {
  background: rgba(139, 92, 246, 0.12);
  color: #c4b5fd;
}
body.night-mode .action-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

/* Journal detail sheet */
body.night-mode .jd-sheet {
  background: linear-gradient(165deg, #065f46 0%, #047857 48%, #064e3b 100%);
  --jd-muted-text: rgba(236, 253, 245, 0.78);
  --jd-surface: rgba(255, 255, 255, 0.1);
  --jd-surface-border: rgba(255, 255, 255, 0.16);
  --jd-divider: rgba(255, 255, 255, 0.14);
  box-shadow: 0 -12px 44px rgba(0, 0, 0, 0.45);
}
body.night-mode .jd-close {
  color: var(--dash-dark);
  background: rgba(255, 255, 255, 0.12);
}
body.night-mode .jd-close:hover {
  background: rgba(255, 255, 255, 0.2);
}
body.night-mode .jd-stat-num,
body.night-mode .jd-netcarbs-val {
  color: var(--dash-dark);
}
body.night-mode .jd-stat { background: var(--jd-surface); border-color: var(--jd-surface-border); }
body.night-mode .jd-macro { background: var(--jd-surface); border-color: var(--jd-surface-border); }
body.night-mode .jd-netcarbs-bar {
  background: var(--jd-surface);
  border-color: var(--jd-surface-border);
}
body.night-mode .jd-netcarbs-toggle input:checked + .jd-netcarbs-slider {
  background: rgba(236, 253, 245, 0.85);
}
body.night-mode .jd-netcarbs-toggle input:checked + .jd-netcarbs-slider::before {
  background: #064e3b;
}
body.night-mode .jd-sev-row {
  border-color: var(--jd-divider);
}
body.night-mode .jd-comp-row {
  border-bottom-color: var(--jd-divider);
}
body.night-mode .jd-mode-tag,
body.night-mode .jd-date,
body.night-mode .jd-stat-label,
body.night-mode .jd-macro-label,
body.night-mode .jd-manual-note,
body.night-mode .jd-comp-macro,
body.night-mode .jd-netcarbs-copy span {
  color: var(--jd-muted-text);
}

/* Home dot — glow adjusts */
body.night-mode .home-dot {
  box-shadow: 0 4px 18px rgba(200, 80, 255, 0.45);
}

/* Inline status rows */
body.night-mode .status-empty p { color: var(--dash-muted); }

/* Footer */
body.night-mode .dash-footer { color: #4a4470; }

/* Pill inactive */
body.night-mode .pill-inactive { background: rgba(255,255,255,0.08); color: var(--dash-muted); }
