/* =========================================================
   COASTAL DAILY FOOD LOG - DYNAMIC ATMOSPHERIC STYLES
   ========================================================= */

:root {
  /* Dynamic Palette Variables (Defaults to Morning/Dawn) */
  --sky-bg: linear-gradient(180deg, #2c4c74 0%, #618bb5 35%, #d98867 75%, #fcd19c 100%);
  --sun-display: block;
  --moon-display: none;
  --sun-core: #fff3cc;
  --sun-corona: rgba(255, 178, 64, 0.45);
  --sun-glow: rgba(255, 140, 40, 0.25);
  --sun-scale: 1;
  --celestial-x: 22%;
  --celestial-y: 52%;

  --water-back: #315878;
  --water-mid: #254d6f;
  --water-front: #1c3e5a;
  --water-reflection-color: rgba(254, 212, 142, 0.35);
  --water-reflection-x: 22%;

  --mountain-back-color: #243f5b;
  --mountain-front-color: #1a324b;
  --sand-color: #d1b48c;
  --silhouette-color: #162433;

  --card-bg: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.24);
  --card-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  --card-backdrop: blur(5px);

  --text-main: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.85);
  --text-dim: rgba(255, 255, 255, 0.7);

  --input-bg: rgba(255, 255, 255, 0.07);
  --input-border: rgba(255, 255, 255, 0.2);
  --input-focus-border: #fbd19c;
  --input-text: #ffffff;

  --pill-bg: rgba(255, 255, 255, 0.18);
  --pill-border: rgba(255, 255, 255, 0.35);
  --active-btn-bg: #ffffff;
  --active-btn-text: #1a2a3a;
  
  --stars-opacity: 0;
  --clouds-opacity: 0.85;
}

/* =========================================================
   THEMES: MORNING, AFTERNOON, EVENING, NIGHT
   ========================================================= */

/* 1. MORNING (Sunrise / Dawn) */
body.phase-morning {
  --sky-bg: linear-gradient(180deg, #2b4b73 0%, #5681aa 30%, #e28f68 68%, #fedbb4 100%);
  --sun-display: block;
  --moon-display: none;
  --sun-core: #fff5d7;
  --sun-corona: rgba(255, 185, 87, 0.55);
  --sun-glow: rgba(255, 134, 52, 0.3);
  --sun-scale: 1.05;
  --celestial-x: 22%;
  --celestial-y: 48%;

  --water-back: #355f84;
  --water-mid: #2b5072;
  --water-front: #20415f;
  --water-reflection-color: rgba(254, 219, 168, 0.42);
  --water-reflection-x: 22%;

  --mountain-back-color: #27425f;
  --mountain-front-color: #1b3149;
  --sand-color: #d8b88d;
  --silhouette-color: #152536;

  --card-bg: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.28);
  --input-focus-border: #fedbb4;
  --stars-opacity: 0;
  --clouds-opacity: 0.85;
}

/* 2. AFTERNOON (Bright Midday Sun) */
body.phase-afternoon {
  --sky-bg: linear-gradient(180deg, #1b73cb 0%, #419ff2 35%, #7ed0fc 70%, #c4edff 100%);
  --sun-display: block;
  --moon-display: none;
  --sun-core: #ffffff;
  --sun-corona: rgba(255, 235, 150, 0.7);
  --sun-glow: rgba(255, 215, 80, 0.45);
  --sun-scale: 1.25;
  --celestial-x: 50%;
  --celestial-y: 18%;

  --water-back: #2087d3;
  --water-mid: #186cb2;
  --water-front: #10528e;
  --water-reflection-color: rgba(255, 255, 255, 0.5);
  --water-reflection-x: 50%;

  --mountain-back-color: #3b7da3;
  --mountain-front-color: #296081;
  --sand-color: #ecc995;
  --silhouette-color: #1c4357;

  --card-bg: rgba(255, 255, 255, 0.12);
  --card-border: rgba(255, 255, 255, 0.35);
  --card-shadow: 0 16px 40px rgba(7, 44, 76, 0.16);
  --input-bg: rgba(255, 255, 255, 0.14);
  --input-border: rgba(255, 255, 255, 0.3);
  --input-text: #0e2a44;
  --text-main: #0c263e;
  --text-muted: #1d3e5e;
  --text-dim: #2e5377;
  --input-focus-border: #1b73cb;
  --pill-bg: rgba(255, 255, 255, 0.25);
  --pill-border: rgba(255, 255, 255, 0.45);
  --active-btn-bg: #0c263e;
  --active-btn-text: #ffffff;
  --stars-opacity: 0;
  --clouds-opacity: 0.95;
}

/* 3. EVENING (Golden Sunset) */
body.phase-evening {
  --sky-bg: linear-gradient(180deg, #2a1147 0%, #681f57 32%, #b53e53 60%, #e66847 82%, #fdb664 100%);
  --sun-display: block;
  --moon-display: none;
  --sun-core: #ffe285;
  --sun-corona: rgba(255, 110, 50, 0.65);
  --sun-glow: rgba(230, 60, 40, 0.4);
  --sun-scale: 1.15;
  --celestial-x: 78%;
  --celestial-y: 54%;

  --water-back: #59254c;
  --water-mid: #461d3f;
  --water-front: #31142e;
  --water-reflection-color: rgba(255, 160, 70, 0.55);
  --water-reflection-x: 78%;

  --mountain-back-color: #3b1638;
  --mountain-front-color: #270d26;
  --sand-color: #9f5b5b;
  --silhouette-color: #1a081c;

  --card-bg: rgba(30, 10, 30, 0.16);
  --card-border: rgba(255, 175, 130, 0.28);
  --input-bg: rgba(255, 255, 255, 0.08);
  --input-focus-border: #fdb664;
  --text-main: #ffffff;
  --text-muted: #ffdfcf;
  --text-dim: #e1b4a3;
  --stars-opacity: 0.15;
  --clouds-opacity: 0.6;
}

/* 4. NIGHT (Moonlit Ocean & Stars) */
body.phase-night {
  --sky-bg: linear-gradient(180deg, #050a17 0%, #0c152b 38%, #142240 70%, #172c54 100%);
  --sun-display: none;
  --moon-display: block;
  --sun-scale: 0.95;
  --celestial-x: 75%;
  --celestial-y: 24%;

  --water-back: #0f1c34;
  --water-mid: #0a1324;
  --water-front: #060b16;
  --water-reflection-color: rgba(195, 222, 255, 0.32);
  --water-reflection-x: 75%;

  --mountain-back-color: #0b1424;
  --mountain-front-color: #070c17;
  --sand-color: #1e2c45;
  --silhouette-color: #04070e;

  --card-bg: rgba(6, 12, 24, 0.18);
  --card-border: rgba(135, 175, 230, 0.22);
  --input-bg: rgba(255, 255, 255, 0.05);
  --input-border: rgba(150, 190, 245, 0.18);
  --input-focus-border: #8ec5fc;
  --text-main: #f0f6ff;
  --text-muted: #c2d6f4;
  --text-dim: #8baad4;
  --pill-bg: rgba(20, 36, 68, 0.4);
  --pill-border: rgba(140, 180, 240, 0.3);
  --active-btn-bg: #8ec5fc;
  --active-btn-text: #050a17;
  --stars-opacity: 0.95;
  --clouds-opacity: 0.25;
}

/* =========================================================
   GLOBAL RESET & BASE
   ========================================================= */

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

html, body {
  min-height: 100vh;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  overflow-x: hidden;
  position: relative;
  transition: color 0.8s ease;
}

/* =========================================================
   SCENERY BACKGROUND & ANIMATIONS
   ========================================================= */

.scenery-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.sky-gradient {
  position: absolute;
  inset: 0;
  background: var(--sky-bg);
  transition: background 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: background;
}

/* Twinkling Stars Canvas */
.stars-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 70%;
  opacity: var(--stars-opacity);
  transition: opacity 1.5s ease;
}

/* Celestial Body (Sun / Moon) */
.celestial-wrapper {
  position: absolute;
  top: var(--celestial-y);
  left: var(--celestial-x);
  transform: translate(-50%, -50%);
  transition: top 1.8s cubic-bezier(0.34, 1.3, 0.64, 1),
              left 1.8s cubic-bezier(0.34, 1.3, 0.64, 1);
  z-index: 1;
}

.celestial-body {
  position: relative;
  width: 110px;
  height: 110px;
  transform: scale(var(--sun-scale));
  transition: transform 1.2s ease;
}

/* Sun Rendering */
.sun-glow {
  display: var(--sun-display);
  position: absolute;
  inset: -50px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--sun-corona) 0%, var(--sun-glow) 50%, transparent 75%);
  animation: pulseSun 4s infinite alternate ease-in-out;
}

.sun-core {
  display: var(--sun-display);
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--sun-core) 25%, #ffb648 85%);
  box-shadow: 0 0 45px var(--sun-corona), 0 0 90px var(--sun-glow);
}

@keyframes pulseSun {
  0% { transform: scale(0.95); opacity: 0.85; }
  100% { transform: scale(1.08); opacity: 1; }
}

/* Moon Rendering */
.moon-body {
  display: var(--moon-display);
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff 0%, #d8e5f7 60%, #a4bfe3 100%);
  box-shadow: 0 0 30px rgba(185, 215, 255, 0.7), 0 0 70px rgba(135, 175, 245, 0.4);
}

.moon-crater {
  position: absolute;
  background: rgba(140, 165, 205, 0.35);
  border-radius: 50%;
}
.moon-crater.c1 { width: 22px; height: 22px; top: 24px; left: 28px; }
.moon-crater.c2 { width: 14px; height: 14px; top: 58px; left: 45px; }
.moon-crater.c3 { width: 10px; height: 10px; top: 38px; left: 65px; }

/* Clouds */
.clouds-layer {
  position: absolute;
  top: 5%;
  left: 0;
  width: 100%;
  height: 45%;
  opacity: var(--clouds-opacity);
  transition: opacity 1.5s ease;
  pointer-events: none;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(4px);
  border-radius: 100px;
}

.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud-1 {
  width: 220px;
  height: 60px;
  top: 15%;
  left: -240px;
  animation: floatCloud 45s linear infinite;
}
.cloud-1::before { width: 90px; height: 90px; top: -45px; left: 35px; }
.cloud-1::after { width: 70px; height: 70px; top: -30px; left: 105px; }

.cloud-2 {
  width: 310px;
  height: 75px;
  top: 32%;
  left: -350px;
  animation: floatCloud 62s linear infinite 14s;
  opacity: 0.7;
}
.cloud-2::before { width: 120px; height: 120px; top: -60px; left: 55px; }
.cloud-2::after { width: 95px; height: 95px; top: -45px; left: 150px; }

.cloud-3 {
  width: 180px;
  height: 50px;
  top: 8%;
  left: -200px;
  animation: floatCloud 52s linear infinite 28s;
  opacity: 0.5;
}
.cloud-3::before { width: 75px; height: 75px; top: -38px; left: 28px; }
.cloud-3::after { width: 60px; height: 60px; top: -25px; left: 85px; }

.cloud-4 {
  width: 260px;
  height: 65px;
  top: 48%;
  left: -280px;
  animation: floatCloud 75s linear infinite 5s;
  opacity: 0.6;
}
.cloud-4::before { width: 100px; height: 100px; top: -50px; left: 45px; }
.cloud-4::after { width: 80px; height: 80px; top: -35px; left: 125px; }

@keyframes floatCloud {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 400px)); }
}

/* Distant Mountains / Horizon */
.distant-landscape {
  position: absolute;
  bottom: 160px;
  left: 0;
  width: 100%;
  height: 180px;
}

.distant-landscape svg {
  width: 100%;
  height: 100%;
}

.mountain-back {
  fill: var(--mountain-back-color);
  transition: fill 1.5s ease;
  opacity: 0.7;
}

.mountain-front {
  fill: var(--mountain-front-color);
  transition: fill 1.5s ease;
  opacity: 0.9;
}

/* Water Sun/Moon Reflection */
.water-reflection {
  position: absolute;
  bottom: 0;
  left: var(--water-reflection-x);
  transform: translateX(-50%);
  width: 160px;
  height: 180px;
  background: radial-gradient(ellipse at 50% 20%, var(--water-reflection-color) 0%, transparent 70%);
  filter: blur(8px);
  opacity: 0.85;
  transition: left 1.8s ease, background 1.5s ease;
  z-index: 2;
  animation: shimmerWater 3s infinite ease-in-out alternate;
}

@keyframes shimmerWater {
  0% { transform: translateX(-50%) scaleX(0.85); opacity: 0.6; }
  100% { transform: translateX(-50%) scaleX(1.2); opacity: 0.95; }
}

/* Ocean & Beach Shoreline */
.ocean-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 220px;
  z-index: 3;
}

.wave {
  position: absolute;
  left: 0;
  width: 200%;
  height: 120px;
}

.wave-1 {
  bottom: 60px;
  fill: var(--water-back);
  transition: fill 1.5s ease;
  opacity: 0.85;
  animation: waveMotion 11s linear infinite;
}

.wave-2 {
  bottom: 30px;
  fill: var(--water-mid);
  transition: fill 1.5s ease;
  opacity: 0.9;
  animation: waveMotion 8s linear infinite reverse;
}

.wave-3 {
  bottom: 0px;
  fill: var(--water-front);
  transition: fill 1.5s ease;
  animation: waveMotion 6s linear infinite;
}

@keyframes waveMotion {
  0% { transform: translateX(0); }
  50% { transform: translateX(-25%) translateY(-5px); }
  100% { transform: translateX(-50%); }
}

.sand-beach {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 38px;
  background: var(--sand-color);
  transition: background 1.5s ease;
  border-top-left-radius: 40% 18px;
  border-top-right-radius: 30% 12px;
  box-shadow: 0 -4px 15px rgba(0,0,0,0.15);
}

.palm-trees {
  position: absolute;
  bottom: 15px;
  left: 20px;
  width: 150px;
  height: 200px;
  pointer-events: none;
}

.palm-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.25));
}

/* =========================================================
   FALLING & STACKING FOOD ANIMATION
   ========================================================= */

.falling-food-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

.falling-food-item {
  position: absolute;
  top: 0;
  left: 0;
  font-size: 30px;
  line-height: 1;
  user-select: none;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.28));
  will-change: transform, opacity;
  transition: opacity 0.5s ease;
}

.falling-food-item.landed {
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.22));
}

@media (max-width: 600px) {
  .falling-food-item {
    font-size: 24px;
  }
}

/* =========================================================
   TOP STATUS & NAVIGATION BAR
   ========================================================= */

.top-nav {
  position: relative;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 32px;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
  transition: all 0.8s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 1.6rem;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.time-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.live-clock-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  border-radius: 40px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.tz-badge {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.24);
  color: inherit;
  padding: 2px 7px;
  border-radius: 6px;
}

.phase-badge {
  font-size: 0.75rem;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.25);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
}

.audio-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 30px;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg);
  color: inherit;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.audio-toggle-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.25);
}

.audio-toggle-btn.playing {
  background: #10b981;
  color: #ffffff;
  border-color: #10b981;
}

/* =========================================================
   MAIN FOOD DIARY CONTAINER & CARDS
   ========================================================= */

.diary-wrapper {
  position: relative;
  z-index: 10;
  max-width: 960px;
  margin: 32px auto 140px;
  padding: 0 20px;
}

.glass-card {
  background: var(--card-bg);
  backdrop-filter: var(--card-backdrop);
  -webkit-backdrop-filter: var(--card-backdrop);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: 28px;
  padding: 36px 40px;
  transition: background 0.8s ease, border-color 0.8s ease, box-shadow 0.8s ease;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.today-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
  backdrop-filter: blur(10px);
}

.today-date-badge .date-icon {
  font-size: 1.05rem;
}

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.85rem;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 6px;
}

.card-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Form Grid */
.food-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
}

.meal-block {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 18px;
  padding: 18px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.meal-block:focus-within {
  border-color: var(--input-focus-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.meal-block.full-width {
  grid-column: 1 / -1;
}

/* Meal Block Locked / Disabled State */
.meal-block.is-locked {
  background: rgba(8, 12, 18, 0.42) !important;
  border: 1px solid rgba(80, 95, 115, 0.35) !important;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.25) !important;
  cursor: not-allowed;
  position: relative;
  transition: all 0.4s ease;
}

.meal-block.is-locked:hover,
.meal-block.is-locked:focus-within {
  transform: none !important;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4) !important;
  border-color: rgba(80, 95, 115, 0.45) !important;
}

.meal-block.is-locked .meal-title {
  color: #e2e8f0 !important;
  cursor: not-allowed;
}

.meal-block.is-locked .meal-icon {
  filter: grayscale(0.8) opacity(0.7);
}

.meal-block.is-locked .meal-textarea {
  cursor: not-allowed !important;
  color: #cbd5e1 !important;
  user-select: text;
}

.meal-block.is-locked .meal-textarea::placeholder {
  color: #64748b !important;
}

.meal-block.is-locked .lock-badge.locked {
  background: rgba(30, 41, 59, 0.95);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.meal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.meal-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.meal-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.meal-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
}

/* Lock Badges */
.lock-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.lock-badge.open {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.lock-badge.locked {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.lock-badge.always-open {
  background: rgba(147, 197, 253, 0.18);
  color: #bfdbfe;
  border: 1px solid rgba(147, 197, 253, 0.35);
}

.meal-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.input-wrapper {
  flex: 1;
}

.meal-textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--input-text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 72px;
  outline: none;
  transition: color 0.3s ease;
}

.meal-textarea::placeholder {
  color: var(--text-dim);
  opacity: 0.75;
}

/* Form Footer & Action Buttons */
.form-footer {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.save-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.save-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  transition: background 0.3s ease;
}

.save-dot.saving {
  background: #f59e0b;
  box-shadow: 0 0 10px #f59e0b;
  animation: pulseDot 1s infinite alternate;
}

@keyframes pulseDot {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(1.3); opacity: 1; }
}

.button-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 11px 26px;
  min-width: 190px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center;
}

.action-btn.secondary {
  background: rgba(255, 255, 255, 0.14);
  color: inherit;
  border: 1px solid var(--input-border);
}

.action-btn.secondary:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
}

.action-btn.primary {
  background: #ffffff;
  color: #1a2a3a;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.action-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.action-btn.download {
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
  border: 1px solid var(--input-border);
}

.action-btn.download:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-2px);
}

.action-btn:disabled,
.action-btn.disabled {
  opacity: 0.38 !important;
  cursor: not-allowed !important;
  filter: grayscale(0.8) !important;
  transform: none !important;
  box-shadow: none !important;
}

.auto-email-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 14px;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.32);
  color: #7dd3fc;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  user-select: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.auto-email-badge .badge-icon {
  font-size: 1.1rem;
}

/* =========================================================
   1. BENTO PROGRESS TRACKER (HEADER)
   ========================================================= */

.bento-progress-card {
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 12px 18px;
  min-width: 250px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.progress-meta .meta-label {
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.progress-meta .meta-val {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.18);
  padding: 2px 8px;
  border-radius: 12px;
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10b981 0%, #34d399 50%, #6ee7b7 100%);
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.progress-pills {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.pill-step {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.3s ease;
}

.pill-step.completed {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.45);
}

.pill-step.locked-step {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.45);
}


/* =========================================================
   5. AESTHETIC BENTO RECEIPT MODAL
   ========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 9, 20, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.receipt-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: rgba(18, 24, 36, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 28px;
  padding: 32px 28px 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(30px) scale(0.95);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  color: #ffffff;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.active .receipt-card {
  transform: translateY(0) scale(1);
}

.close-receipt-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.close-receipt-btn:hover {
  background: rgba(239, 68, 68, 0.35);
  transform: rotate(90deg);
}

.receipt-header {
  text-align: center;
  margin-bottom: 16px;
}

.receipt-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}

.receipt-logo {
  font-size: 1.6rem;
}

.receipt-brand h2 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.receipt-tagline {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 8px;
}

.receipt-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #93c5fd;
}

.receipt-divider {
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
  margin: 14px 0;
}

.receipt-divider.dashed {
  background: transparent;
  border-top: 1px dashed rgba(255, 255, 255, 0.25);
}

.receipt-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.receipt-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 9px 12px;
  border-radius: 12px;
}

.item-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 3px;
}

.item-content {
  font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.receipt-summary-footer {
  text-align: center;
  margin-bottom: 16px;
}

.summary-score {
  font-size: 0.95rem;
  font-weight: 700;
  color: #34d399;
  margin-bottom: 8px;
}

.barcode-graphic {
  font-family: monospace;
  letter-spacing: 2px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.3);
}

.receipt-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.receipt-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 14px;
  border: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.receipt-btn.whatsapp {
  background: #25d366;
  color: #ffffff;
  flex: 1 1 100%;
}

.receipt-btn.whatsapp:hover {
  background: #20bd5a;
  transform: translateY(-1px);
}

.receipt-btn.copy {
  background: #ffffff;
  color: #0f172a;
}

.receipt-btn.copy:hover {
  background: #f1f5f9;
  transform: translateY(-1px);
}

.receipt-btn.download {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.receipt-btn.download:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

/* =========================================================
   CALENDAR NAVIGATION & PAST LOG NOTICE
   ========================================================= */

.date-header-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.calendar-btn-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.calendar-trigger-btn {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.calendar-trigger-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.hidden-date-picker {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.today-jump-btn {
  background: rgba(14, 165, 233, 0.35);
  border: 1px solid rgba(56, 189, 248, 0.6);
  color: #e0f2fe;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.today-jump-btn:hover {
  background: rgba(14, 165, 233, 0.55);
  transform: translateY(-1px);
}

.past-date-notice {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 12px;
  padding: 8px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fef3c7;
  font-size: 0.82rem;
  animation: fadeIn 0.3s ease;
}

.past-date-notice .notice-icon {
  font-size: 1.15rem;
}

.past-date-notice .notice-text strong {
  color: #fbbf24;
}

.past-date-notice .notice-text p {
  margin: 2px 0 0;
  color: #e2e8f0;
  font-size: 0.76rem;
}

/* =========================================================
   REPORT DURATION TABS & RESEND EMAIL
   ========================================================= */

.report-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin: 10px 0 14px 0;
}

.report-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 7px 8px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.report-tab:hover {
  color: #ffffff;
}

.report-tab.active {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.resend-email-box {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.resend-label {
  display: block;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
  margin-bottom: 6px;
}

.resend-input-row {
  display: flex;
  gap: 8px;
}

.resend-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 8px 12px;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.resend-input:focus {
  border-color: #38bdf8;
  background: rgba(15, 23, 42, 0.85);
}

.resend-btn {
  background: linear-gradient(135deg, #0ea5e9, #0284c7) !important;
  color: #ffffff !important;
  border: none !important;
  padding: 8px 14px !important;
  white-space: nowrap;
}

.resend-btn:hover {
  background: linear-gradient(135deg, #38bdf8, #0ea5e9) !important;
  transform: translateY(-1px);
}

.email-status-message {
  margin-top: 8px;
  font-size: 0.74rem;
  padding: 6px 10px;
  border-radius: 6px;
  line-height: 1.4;
}

.email-status-message.success {
  background: rgba(16, 185, 129, 0.25);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #a7f3d0;
}

.email-status-message.error {
  background: rgba(239, 68, 68, 0.25);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

/* =========================================================
   STATISTICS & PERIOD LIST FOR REPORTS
   ========================================================= */

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

.stat-grid.category-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}

.stat-card.mini {
  padding: 6px 8px;
}

.stat-number {
  font-size: 1.25rem;
  font-weight: 800;
  color: #38bdf8;
  display: block;
  line-height: 1.2;
}

.stat-card.mini .stat-number {
  font-size: 0.95rem;
  color: #e2e8f0;
}

.stat-label {
  font-size: 0.68rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.period-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}

.day-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.day-row-date {
  font-weight: 600;
  color: #e2e8f0;
}

.day-row-badges {
  display: flex;
  gap: 4px;
  align-items: center;
}

.day-mini-pill {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

.day-mini-pill.done {
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
  font-weight: 600;
}


/* =========================================================
   NOTIFICATION TOAST
   ========================================================= */

.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: rgba(15, 23, 42, 0.9);
  color: #ffffff;
  padding: 12px 22px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transform: translateY(100px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* =========================================================
   RESPONSIVE DESIGN (ALL DEVICE COMPATIBILITY)
   ========================================================= */

/* Tablets & Medium Screens (<= 920px) */
@media (max-width: 920px) {
  .food-form {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .diary-wrapper {
    margin-top: 24px;
    margin-bottom: 120px;
    padding: 0 16px;
  }
}

/* Tablets in Portrait & Mobile (<= 768px) */
@media (max-width: 768px) {
  .top-nav {
    padding: 12px 18px;
    justify-content: center;
    gap: 12px;
  }
  
  .brand {
    width: 100%;
    justify-content: center;
  }

  .time-controls {
    justify-content: center;
    width: 100%;
    gap: 10px;
  }

  .glass-card {
    padding: 24px 20px;
    border-radius: 22px;
  }

  .card-header {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 22px;
    padding-bottom: 18px;
  }

  .form-footer {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 14px;
  }

  .button-actions {
    width: 100%;
    justify-content: stretch;
  }

  .button-actions .action-btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }
}

/* Mobile Phones (<= 560px) */
@media (max-width: 560px) {
  .top-nav {
    padding: 10px 14px;
  }

  .brand-icon {
    font-size: 1.35rem;
  }

  .brand-title {
    font-size: 1.05rem;
  }

  .live-clock-pill {
    padding: 5px 10px;
    font-size: 0.82rem;
    gap: 6px;
  }

  .audio-toggle-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  .diary-wrapper {
    margin-top: 14px;
    margin-bottom: 90px;
    padding: 0 10px;
  }

  .glass-card {
    padding: 20px 14px;
    border-radius: 18px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  .card-title {
    font-size: 1.45rem;
  }

  .card-subtitle {
    font-size: 0.85rem;
  }

  .today-date-badge {
    font-size: 0.82rem;
    padding: 4px 10px;
  }

  .meal-block {
    padding: 14px 12px;
    border-radius: 16px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  .meal-header {
    gap: 6px;
  }

  .meal-title {
    font-size: 0.98rem;
  }

  .lock-badge {
    font-size: 0.68rem;
    padding: 3px 8px;
  }

  .meal-textarea {
    font-size: 16px; /* Prevents auto-zoom on iOS Safari */
    min-height: 60px;
  }

  .button-actions {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .button-actions .action-btn {
    width: 100%;
    min-width: 0;
    padding: 12px 18px;
    font-size: 0.92rem;
  }

  .save-status {
    justify-content: center;
    font-size: 0.8rem;
  }
}
