/* ── DESIGN TOKENS (ported from snehal.ai style.scss) ──────────────── */

:root,
[data-theme="light"] {
  --bg:              #fafaf9;
  --bg-alt:          #f8fafc;
  --bg-header:       rgba(250, 250, 249, 0.92);
  --text:            #1e293b;
  --text-muted:      #64748b;
  --heading:         #0f172a;
  --border:          #e2e8f0;
  --accent:          #1d4ed8;
  --accent-2:        #2563eb;
  --accent-bg:       rgba(29, 78, 216, 0.07);
  --accent-border:   rgba(29, 78, 216, 0.2);
  --card-bg:         #f3f3f0;
  --card-border:     rgba(0, 0, 0, 0.08);
  --toggle-bg:       #f1f5f9;
  --toggle-border:   #cbd5e1;
  --header-shadow:   0 1px 8px rgba(0, 0, 0, 0.07);
  --selection-bg:    rgba(29, 78, 216, 0.18);
  --selection-text:  #0f172a;
  --color-success:   #4e7f2f;
}

[data-theme="dark"] {
  --bg:              #1f1f1e;
  --bg-alt:          #272726;
  --bg-header:       rgba(31, 31, 30, 0.92);
  --text:            #e6edf3;
  --text-muted:      #8b949e;
  --heading:         #f0f6fc;
  --border:          #3d3d3c;
  --accent:          #60a5fa;
  --accent-2:        #93c5fd;
  --accent-bg:       rgba(96, 165, 250, 0.10);
  --accent-border:   rgba(96, 165, 250, 0.28);
  --card-bg:         #31312e;
  --card-border:     rgba(255, 255, 255, 0.08);
  --toggle-bg:       #2f2f2e;
  --toggle-border:   #3d3d3c;
  --header-shadow:   0 1px 8px rgba(0, 0, 0, 0.4);
  --selection-bg:    rgba(147, 197, 253, 0.22);
  --selection-text:  #f0f6fc;
  --color-success:   #7db84e;
}

/* ── BASE ───────────────────────────────────────────────────────────── */

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

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s ease, color 0.2s ease;
}

::-moz-selection { background: var(--selection-bg); color: var(--selection-text); }
::selection      { background: var(--selection-bg); color: var(--selection-text); }

/* ── HEADER ─────────────────────────────────────────────────────────── */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-header);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--header-shadow);
  z-index: 10;
}

.logo {
  font-family: 'Bitter', Georgia, serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 7px;
}

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

.last-update {
  color: var(--text-muted);
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.refresh-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-success);
  opacity: 0.45;
  transition: opacity 0.3s;
  flex-shrink: 0;
}
.refresh-dot.active { opacity: 1; }

/* ── THEME TOGGLE ───────────────────────────────────────────────────── */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--toggle-border);
  border-radius: 8px;
  background: var(--toggle-bg);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.theme-toggle:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-bg);
}

/* In light mode show moon (click to go dark), in dark mode show sun (click to go light) */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ── STATS STRIP ────────────────────────────────────────────────────── */

.stats-strip {
  display: flex;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
}
.stats-strip::-webkit-scrollbar { display: none; }

/* grouped layout */
.stat-group {
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--border);
  /* flex value set inline (= sensor count) so every stat gets equal width */
}
.stat-group:last-child { border-right: none; }

.stat-group-name {
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 8px 20px 0;
  opacity: 0.55;
  white-space: nowrap;
}

.stat-group-body {
  display: flex;
  flex: 1;
}

.stat {
  flex: 1;
  min-width: 110px;
  padding: 5px 20px 16px;
  border-right: 1px solid var(--border);
  transition: background 0.12s;
}
.stat:last-child { border-right: none; }
.stat:hover { background: var(--bg-alt); }

/* ungrouped fallback: direct .stat children of .stats-strip */
.stats-strip > .stat {
  padding: 16px 20px;
  min-width: 120px;
}

.stat-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-family: 'Bitter', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-unit {
  font-family: 'Nunito Sans', -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 2px;
  letter-spacing: 0;
}

/* ── CHARTS GRID ────────────────────────────────────────────────────── */

.charts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 24px;
  flex: 1;
}

@media (max-width: 720px) {
  .charts { grid-template-columns: 1fr; padding: 16px; gap: 12px; }
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 18px 18px 14px;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
  min-width: 0; /* prevent grid cell blowout on mobile */
}
.chart-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.10);
  transform: translateY(-1px);
}
[data-theme="dark"] .chart-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.chart-title {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.chart-wrap {
  position: relative;
  height: 140px;
}

/* ── EMPTY STATE ────────────────────────────────────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 80px 24px;
  gap: 8px;
  text-align: center;
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 4px;
  opacity: 0.4;
}

.empty-label {
  font-family: 'Bitter', Georgia, serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--heading);
}

.empty-hint {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── FOOTER ─────────────────────────────────────────────────────────── */

footer {
  color: var(--text-muted);
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 13px 24px;
  border-top: 1px solid var(--border);
  letter-spacing: 0.01em;
}

/* ── MOBILE ─────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  /* Groups stack vertically; their stat rows scroll horizontally inside */
  .stats-strip {
    flex-direction: column;
    overflow-x: visible;
  }

  .stat-group {
    border-right: none;
    border-bottom: 2px solid var(--border);
  }
  .stat-group:last-child { border-bottom: none; }

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

  .stat-group-body .stat {
    min-width: 0;
    border-bottom: 1px solid var(--border);
  }
  /* remove bottom border on last row (last 2 items) */
  .stat-group-body .stat:nth-last-child(-n+2) { border-bottom: none; }
  /* remove right border on even items (right column) */
  .stat-group-body .stat:nth-child(2n) { border-right: none; }
}

@media (max-width: 480px) {
  header        { padding: 9px 16px; }
  .theme-toggle { width: 32px; height: 32px; border-radius: 7px; }
  .stat         { padding: 4px 14px 13px; }
  .stat-value   { font-size: 19px; }
  .last-update  { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════
   GARDEN HERO — self-contained palette, cozy Stardew-adjacent style
   ═══════════════════════════════════════════════════════════════════ */

.garden {
  width: 100%;
  overflow: hidden;
  border-bottom: 2px solid rgba(0,0,0,0.08);
  /* Garden palette -- ported from reference_bed.html :root */
  --g-wood-light:       #b07a44;
  --g-wood:             #8a5a30;
  --g-wood-dark:        #5e3a1c;
  --g-wood-shadow:      #412713;
  --g-soil-dry:         #9c7350;
  --g-soil-mid:         #6b4a2e;
  --g-soil-wet:         #3f2a18;
  --g-soil-damp-patch:  rgba(40,24,12,0.55);
  --g-leaf:             #5a8a3c;
  --g-leaf-dark:        #3f6b29;
  --g-leaf-wilt:        #8a9a5c;
  --g-chip-bg:          #f3e9d2;
  --g-chip-ink:         #4a3623;
  --g-chip-shadow:      rgba(40,24,12,0.35);
  --g-label-wood:       #6b4527;
  --g-grass:            #6fa64c;
  --g-grass-dark:       #588a3a;
}
[data-theme="dark"] .garden {
  --g-chip-bg:          rgba(42, 30, 15, 0.96);
  --g-chip-ink:         #e8d4b8;
  --g-chip-shadow:      rgba(0,0,0,0.35);
  --g-wood-light:       #7a5228;
  --g-wood:             #5e3c1a;
  --g-wood-dark:        #321806;
  --g-wood-shadow:      #1e0e04;
  --g-soil-dry:         #7a5535;
  --g-soil-mid:         #4e3620;
  --g-soil-wet:         #2d1c0d;
}

/* ── Sky strip ── */
.garden-sky {
  position: relative;
  width: 100%;
  height: 86px;
  background: linear-gradient(180deg, #5ba8d8 0%, #c8e8ff 100%);
  overflow: hidden;
  transition: background 3s ease, filter 3s ease;
}

.sky-sun {
  position: absolute;
  top: 14px;
  right: 72px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffd94a;
  box-shadow: 0 0 22px 7px rgba(255,220,50,0.55);
  z-index: 2;
  transition: opacity 2s ease, background 2s ease, box-shadow 2s ease;
}

.sky-moon {
  position: absolute;
  top: 14px;
  right: 72px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 38%, #e8e4c8 60%, #b8b498 100%);
  box-shadow: 0 0 14px 4px rgba(220,215,180,0.35);
  opacity: 0;
  z-index: 2;
  transition: opacity 2s ease;
}

.sky-cloud {
  position: absolute;
  height: 22px;
  border-radius: 50px;
  background: rgba(255,255,255,0.85);
  filter: blur(1.5px);
  z-index: 1;
  transition: opacity 3s ease, background 3s ease;
}
.sky-cloud::before,
.sky-cloud::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: 50%;
}
.sky-cloud::before { width: 55%; height: 160%; top: -50%; left: 18%; }
.sky-cloud::after  { width: 40%; height: 130%; top: -35%; right: 18%; }

.sky-chips {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 4;
  pointer-events: none;
}

.sky-chip {
  background: var(--g-chip-bg);
  color: var(--g-chip-ink);
  border-radius: 12px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Nunito Sans', sans-serif;
  box-shadow: 0 2px 8px var(--g-chip-shadow);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  letter-spacing: 0.01em;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sky-chip-label { font-weight: 600; opacity: 0.6; font-size: 10px; margin-right: 1px; }

/* ── Grass horizon strip -- stitches the sky-to-ground color seam ── */
.garden-horizon {
  height: 14px;
  background: linear-gradient(to bottom, var(--g-grass) 0%, var(--g-grass-dark) 100%);
  box-shadow: 0 3px 8px rgba(0,0,0,0.20);
  position: relative;
  z-index: 1;
}
/* subtle vertical streaks suggest individual grass blades */
.garden-horizon::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(90deg,
      transparent 0px, transparent 5px,
      rgba(255,255,255,0.10) 5px, rgba(255,255,255,0.10) 6px,
      transparent 6px, transparent 10px,
      rgba(0,0,0,0.07) 10px, rgba(0,0,0,0.07) 11px);
  pointer-events: none;
}
[data-theme="dark"] .garden-horizon {
  --g-grass:      #5a8c3a;
  --g-grass-dark: #486e2c;
}

/* ── Ground strip ── */
.garden-ground {
  /* richer earth tone; beds stand out more against darker ground */
  background: linear-gradient(180deg, #7a6040 0%, #604828 100%);
  padding: 14px 24px 22px;
  display: flex;
  gap: 22px;
  justify-content: center;
  align-items: flex-start;
  overflow-x: auto;
  scrollbar-width: none;
  position: relative;  /* needed for pebble SVG overlay */
}
.garden-ground::-webkit-scrollbar { display: none; }
[data-theme="dark"] .garden-ground {
  background: linear-gradient(180deg, #2a1c0e 0%, #1a100a 100%);
}

/* ── Bed card ── */
.g-bed {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.g-bed-name {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--g-chip-ink);
  opacity: 0.7;
  margin-bottom: 5px;
}

/* Wooden raised-bed frame */
.g-bed-frame {
  position: relative;
  width: 210px;
  height: 158px;
  border-radius: 6px;
  /* Multi-layer wooden plank border illusion */
  background:
    linear-gradient(to right,  var(--g-wood-shadow) 0, var(--g-wood) 5px, var(--g-wood-light) 7px, var(--g-wood) 13px, transparent 13px),
    linear-gradient(to left,   var(--g-wood-shadow) 0, var(--g-wood) 5px, var(--g-wood-light) 7px, var(--g-wood) 13px, transparent 13px),
    linear-gradient(to bottom, var(--g-wood-shadow) 0, var(--g-wood) 5px, var(--g-wood-light) 7px, var(--g-wood) 13px, transparent 13px),
    linear-gradient(to top,    var(--g-wood-shadow) 0, var(--g-wood) 4px, var(--g-wood-light) 6px, var(--g-wood) 11px, transparent 11px);
  box-shadow: 3px 5px 12px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.12);
  overflow: hidden;
}

/* Plank grain lines */
.g-bed-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(90deg,
      transparent 0, transparent 34px,
      rgba(0,0,0,0.07) 34px, rgba(0,0,0,0.07) 35px);
  pointer-events: none;
  z-index: 6;
}

/* Soil area -- gradient driven by moisture via JS inline props */
.g-soil {
  position: absolute;
  inset: 13px 13px 16px;
  border-radius: 2px;
  /* default gradient for healthy/damp soil; JS overrides with computed colors */
  background: linear-gradient(to bottom, var(--g-soil-mid), var(--g-soil-wet));
  overflow: hidden;
}

/* Front rail -- overlaps soil bottom so plants sit inside the bed */
.g-front-rail {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: linear-gradient(to bottom, var(--g-wood) 0%, var(--g-wood-dark) 100%);
  border-top: 4px solid var(--g-wood-light);
  border-radius: 0 0 4px 4px;
  z-index: 8;
  overflow: hidden;
}
/* plank seam lines on the front rail */
.g-front-rail::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(90deg,
    transparent 0, transparent 66px,
    var(--g-wood-shadow) 66px, var(--g-wood-shadow) 68px);
  opacity: 0.55;
}

/* Damp soil patch under each plant root (child of .g-plant) */
.g-damp-patch {
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--g-soil-damp-patch);
  transition: width 1.8s ease, height 1.8s ease, opacity 1.8s ease;
  pointer-events: none;
}

/* Rooted base mound at plant foot (child of .g-plant, behind sprite) */
.g-plant-base {
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--g-leaf-dark);
  pointer-events: none;
}

/* Asleep / sleeping state */
.g-bed.g-asleep .g-bed-frame { filter: grayscale(.85) brightness(.6); }

/* Sleep overlay: hidden by default, shown when bed gains g-asleep */
.g-sleep-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
  z-index: 11;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.g-bed.g-asleep .g-sleep-overlay { opacity: 1; }
.g-zzz {
  font-size: 17px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: rgba(210, 196, 174, 0.88);
  letter-spacing: 5px;
}
.g-nosig {
  font-size: 9px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: rgba(210, 196, 174, 0.55);
  letter-spacing: 0.05em;
}
@media (prefers-reduced-motion: no-preference) {
  .g-zzz {
    animation: g-zzz-float 3.2s ease-in-out infinite;
  }
  @keyframes g-zzz-float {
    0%, 100% { transform: translateY(0)   scale(1);    opacity: 0.88; }
    50%       { transform: translateY(-5px) scale(1.06); opacity: 1;    }
  }
}

/* Plant container */
.g-plants {
  position: absolute;
  inset: 2px 4px 22px;
}

/* Outer wrapper — driven by wilt (transitions smoothly) */
.g-plant {
  position: absolute;
  bottom: 0;
  width: 44px;
  height: 56px;
  transform-origin: center bottom;
  transform: rotate(var(--g-wilt-rot, 0deg));
  filter: saturate(var(--g-sat, 1)) brightness(var(--g-bright, 1));
  transition: transform 1.8s ease, filter 1.8s ease;
}

/* Inner wrapper — driven by ambient sway animation */
.g-plant-inner {
  width: 100%;
  height: 100%;
  transform-origin: center bottom;
  transform: rotate(var(--g-rot, 0deg));
}
.g-plant-inner svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Wood label nailed to the front rail */
.g-label {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 62%;
  height: 22px;
  background: var(--g-label-wood);
  border: 2px solid var(--g-wood-shadow);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 9;
  box-sizing: border-box;
}
.g-label::before,
.g-label::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #2a160a;
  box-shadow: 0 12px 0 #2a160a;
  pointer-events: none;
}
.g-label::before { top: 2px; left: 5px; }
.g-label::after  { top: 2px; right: 5px; }
.g-label-moist {
  font-size: 10px;
  font-weight: 700;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: #f3e9d2;
  white-space: nowrap;
}
.g-label-batt {
  font-size: 10px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: #cdeccd;
  white-space: nowrap;
}

/* Low-battery soft pulse */
.g-label-batt.g-batt-low {
  color: #ff9977;
  animation: g-batt-pulse 2.4s ease-in-out infinite;
}
@keyframes g-batt-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* Droplet alert ping */
.g-droplet-ping {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 18px;
  z-index: 12;
  opacity: 0;
  pointer-events: none;
  animation: g-ping 1.8s ease-out forwards;
}
@keyframes g-ping {
  0%   { opacity: 0;   transform: translateY(0)    scale(0.5); }
  18%  { opacity: 1;   transform: translateY(-6px) scale(1.15); }
  80%  { opacity: 0.6; transform: translateY(-12px) scale(1); }
  100% { opacity: 0;   transform: translateY(-18px) scale(0.85); }
}

/* ── Garden Robot ───────────────────────────────────────────────────── */
#garden-robot {
  position: absolute;
  width: 40px;
  /* bottom:22px aligns with the bed front-rail ground line
     (matches .garden-ground bottom padding); vertical animation is
     translateY % of the element's own height (52px svg) */
  bottom: 22px;
  z-index: 13;
  pointer-events: none;
  overflow: visible;
  transform: translateY(110%);
  opacity: 0;
  transition: opacity 0.12s;
}
#garden-robot.g-robot-visible {
  opacity: 1;
}

.g-robot-body {
  display: block;
  line-height: 0;
}

.g-robot-bubble {
  position: absolute;
  bottom: 58px;   /* floats above the 52px robot body */
  left: 50%;
  transform: translateX(-50%) translateY(5px) scale(0.88);
  background: var(--g-chip-bg);
  color: var(--g-chip-ink);
  font-family: 'Nunito Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  padding: 5px 10px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 2px 8px var(--g-chip-shadow);
  opacity: 0;
  transition: opacity 0.28s, transform 0.28s;
  pointer-events: none;
}
/* Downward triangle tail pointing at robot */
.g-robot-bubble::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--g-chip-bg);
}
#garden-robot.g-robot-speak .g-robot-bubble {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

/* Responsive */
@media (max-width: 720px) {
  .garden-ground {
    flex-direction: column;
    align-items: center;
    padding: 12px 16px 18px;
  }
  .garden-sky { height: 72px; }
  .sky-chips  { gap: 5px; }
  .sky-chip   { font-size: 11px; padding: 4px 9px; }
}

/* ── Ambient animation (no-preference only) ─────────────────────────── */
@media (prefers-reduced-motion: no-preference) {

  /* Gentle plant sway — inner wrapper only, so wilt transition is unaffected */
  .g-plant-inner {
    animation: g-sway 4.2s ease-in-out infinite;
    animation-delay: var(--g-delay, 0s);
  }
  @keyframes g-sway {
    0%, 100% { transform: rotate(var(--g-rot, 0deg)); }
    35%       { transform: rotate(calc(var(--g-rot, 0deg) + 2.8deg)); }
    68%       { transform: rotate(calc(var(--g-rot, 0deg) - 1.8deg)); }
  }

  /* Cloud drift */
  .sky-cloud {
    animation: g-cloud-drift var(--g-cdur, 22s) linear infinite;
    animation-delay: var(--g-cdelay, 0s);
  }
  @keyframes g-cloud-drift {
    0%   { transform: translateX(-250px); }
    100% { transform: translateX(calc(100vw + 250px)); }
  }

  /* Sun shimmer */
  .sky-sun {
    animation: g-sun-shimmer 3.8s ease-in-out infinite;
  }
  @keyframes g-sun-shimmer {
    0%, 100% { box-shadow: 0 0 22px 7px rgba(255,220,50,0.55); }
    50%       { box-shadow: 0 0 34px 12px rgba(255,220,50,0.75); }
  }

  /* Fireflies */
  .g-firefly {
    animation: g-firefly-blink var(--g-fdur, 2.2s) ease-in-out infinite;
    animation-delay: var(--g-fdelay, 0s);
  }
  @keyframes g-firefly-blink {
    0%, 100% { opacity: 0; transform: translate(0, 0) scale(0.7); }
    50%       { opacity: 0.85; transform: translate(var(--g-fx, 4px), var(--g-fy, -5px)) scale(1.1); }
  }

  /* Garden robot pop-up
     translateY % is relative to element's own height (52px).
     -200% = 104px up from bottom:22px baseline → clears the 158px bed frame top. */
  #garden-robot.g-robot-rising {
    animation: g-robot-rise 0.68s cubic-bezier(0.22, 1.3, 0.58, 1) forwards;
  }
  #garden-robot.g-robot-sinking {
    animation: g-robot-sink 0.42s ease-in forwards;
  }
  @keyframes g-robot-rise {
    0%   { transform: translateY(110%); }
    68%  { transform: translateY(-215%); }  /* bouncy overshoot */
    84%  { transform: translateY(-192%); }  /* settle back */
    100% { transform: translateY(-200%); }
  }
  @keyframes g-robot-sink {
    0%   { transform: translateY(-200%); }
    100% { transform: translateY(110%); }
  }
  /* Gentle bob while the speech bubble is showing */
  #garden-robot.g-robot-speak .g-robot-body {
    animation: g-robot-bob 2.4s ease-in-out infinite;
  }
  @keyframes g-robot-bob {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-4px); }
  }
}
