/* Greenhouse — soft botanical design system */

:root {
  --cream: #faf7ef;
  --paper: #fffdf6;
  --moss-50: #eef4ea;
  --moss-100: #dfead6;
  --moss-200: #c2d8b4;
  --moss-300: #9dc08b;
  --moss-400: #7aa569;
  --moss-500: #5d8a4e;
  --moss-600: #476e3c;
  --moss-700: #37552f;
  --moss-800: #2e4b34;
  --ink: #2b3626;
  --ink-soft: #5c6a54;
  --amber: #e8a13c;
  --amber-soft: #fdf0da;
  --amber-ink: #8a5a14;
  --terra: #c96f4a;
  --sky: #b8d4e3;
  --danger: #b3543f;
  --shadow-soft: 0 2px 10px rgba(46, 75, 52, 0.08), 0 8px 28px rgba(46, 75, 52, 0.07);
  --shadow-lift: 0 6px 18px rgba(46, 75, 52, 0.14), 0 14px 40px rgba(46, 75, 52, 0.12);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--moss-100), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #f3ead9, transparent 55%),
    var(--cream);
  min-height: 100vh;
  line-height: 1.5;
}

/* Ambient drifting leaves */
.ambient { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.leaf { position: absolute; font-size: 26px; opacity: 0.16; filter: saturate(0.8); }
.leaf-1 { top: 12%; left: 6%; animation: drift 17s ease-in-out infinite; }
.leaf-2 { top: 64%; right: 8%; animation: drift 22s ease-in-out infinite reverse; font-size: 34px; }
.leaf-3 { top: 38%; left: 78%; animation: drift 26s ease-in-out infinite 4s; font-size: 20px; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0) rotate(-6deg); }
  50% { transform: translate(14px, -22px) rotate(9deg); }
}

/* Header */
.app-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(16px, 4vw, 44px) 10px;
  max-width: 1080px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-size: 34px;
  background: var(--paper);
  border-radius: 16px;
  padding: 8px 10px;
  box-shadow: var(--shadow-soft);
}
.app-header h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 28px);
  letter-spacing: 0.01em;
  color: var(--moss-800);
}
.tagline { margin: 0; font-size: 13px; color: var(--ink-soft); }
.header-actions { display: flex; gap: 8px; }

/* Buttons */
.ghost-btn, .primary-btn {
  font: inherit;
  font-size: 14px;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  min-height: 40px;
}
.ghost-btn {
  background: transparent;
  border-color: var(--moss-200);
  color: var(--moss-700);
}
.ghost-btn:hover { background: var(--moss-50); }
.ghost-btn.danger { color: var(--danger); border-color: #e5c9bf; }
.ghost-btn.danger:hover { background: #f9ece7; }
.primary-btn {
  background: var(--moss-600);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
}
.primary-btn:hover { background: var(--moss-700); transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.primary-btn:active { transform: translateY(0); }
.primary-btn.danger-solid { background: var(--danger); }
.primary-btn.danger-solid:hover { background: #9c4634; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

/* Layout */
.app {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px clamp(16px, 4vw, 44px) 90px;
  display: grid;
  gap: 22px;
}

/* Week planner */
.week-card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(16px, 3vw, 26px);
}
.week-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.week-head h2 { margin: 0; font-size: 19px; color: var(--moss-800); }
.week-range { font-size: 13px; color: var(--ink-soft); }
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.day-col {
  background: var(--moss-50);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1.5px solid transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.day-col.is-today {
  background: #e9f3e1;
  border-color: var(--moss-300);
}
.day-col.is-past { opacity: 0.72; }
.day-label { text-align: center; }
.day-label .dow {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.day-label .dnum {
  display: inline-grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  margin-top: 2px;
}
.is-today .dnum { background: var(--moss-600); color: #fff; }
.day-empty {
  font-size: 11px;
  color: var(--ink-soft);
  text-align: center;
  margin-top: auto;
  margin-bottom: auto;
  opacity: 0.7;
}

/* Plant chips inside the week */
.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  font: inherit;
  font-size: 12.5px;
  background: var(--paper);
  border: 1.5px solid var(--moss-200);
  border-radius: 999px;
  padding: 5px 9px 5px 6px;
  cursor: pointer;
  color: var(--ink);
  text-align: left;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
  min-height: 34px;
}
.chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.chip .chip-avatar { font-size: 15px; }
.chip .chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-weight: 550;
}
.chip .chip-check {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--moss-300);
  color: transparent;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  font-size: 11px;
}
.chip:hover .chip-check { border-color: var(--moss-500); }
.chip.watered {
  background: var(--moss-100);
  border-color: var(--moss-300);
}
.chip.watered .chip-check { background: var(--moss-500); border-color: var(--moss-500); color: #fff; }
.chip.watered .chip-name { text-decoration: line-through; color: var(--ink-soft); }

/* Sections */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 2px 0;
}
.section-head h2 { margin: 0; font-size: 17px; color: var(--moss-800); }
.section-head .hint { font-size: 12.5px; color: var(--ink-soft); }

/* Overdue — warm nudge, never alarming */
.overdue-card {
  background: linear-gradient(160deg, var(--amber-soft), #fdf6e8);
  border: 1.5px solid #f0dcb8;
  border-radius: var(--radius-lg);
  padding: clamp(16px, 3vw, 22px);
}
.overdue-card h2 { margin: 0 0 4px; font-size: 17px; color: var(--amber-ink); }
.overdue-card .sub { margin: 0 0 14px; font-size: 13px; color: #a0742c; }
.overdue-list { display: grid; gap: 10px; }

/* Plant cards */
.plant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
  gap: 14px;
}
.plant-grid > * { min-width: 0; }
.plant-card > * { min-width: 0; }
.plant-top > div { min-width: 0; }
.plant-card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 16px;
  display: grid;
  gap: 10px;
  border: 1.5px solid transparent;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  animation: card-in 0.35s ease backwards;
}
.plant-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.plant-card.is-overdue { border-color: #f0dcb8; background: linear-gradient(170deg, #fffdf6, var(--amber-soft)); }
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.plant-top { display: flex; align-items: center; gap: 12px; }
.plant-avatar {
  font-size: 26px;
  background: var(--moss-50);
  border-radius: 14px;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.plant-name {
  margin: 0;
  font-size: 16.5px;
  color: var(--moss-800);
  overflow-wrap: anywhere;
}
.plant-note {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plant-status { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status-pill {
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
}
.status-pill.today { background: var(--moss-100); color: var(--moss-700); }
.status-pill.future { background: #eef2f6; color: #4a5f74; }
.status-pill.overdue { background: #f7e3c2; color: var(--amber-ink); }
.plant-meta { font-size: 12px; color: var(--ink-soft); }
.plant-badges { display: flex; gap: 5px; flex-wrap: wrap; min-height: 22px; }
.badge-chip {
  font-size: 13px;
  background: var(--moss-50);
  border: 1px solid var(--moss-200);
  border-radius: 999px;
  padding: 2px 8px;
  cursor: default;
}
.plant-actions { display: flex; gap: 8px; }
.water-btn {
  flex: 1;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  background: var(--moss-500);
  border: none;
  border-radius: 12px;
  padding: 11px 14px;
  min-height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.water-btn:hover { background: var(--moss-600); transform: translateY(-1px); }
.water-btn:disabled {
  background: var(--moss-100);
  color: var(--moss-600);
  cursor: default;
  transform: none;
}
.icon-btn {
  font: inherit;
  background: transparent;
  border: 1.5px solid var(--moss-200);
  border-radius: 12px;
  width: 44px;
  min-height: 44px;
  cursor: pointer;
  color: var(--moss-700);
  font-size: 15px;
  transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--moss-50); }

/* Achievements */
.achievements-card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(16px, 3vw, 22px);
}
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.achievement {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--moss-50);
  border: 1.5px solid var(--moss-200);
  transition: transform 0.2s ease;
}
.achievement .a-icon { font-size: 22px; }
.achievement .a-name { font-size: 13px; font-weight: 600; color: var(--moss-800); }
.achievement .a-desc { font-size: 11px; color: var(--ink-soft); }
.achievement.locked { opacity: 0.45; filter: grayscale(0.7); border-style: dashed; }
.achievement.unlocked { animation: pop-in 0.4s ease; }
@keyframes pop-in {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* Empty state */
.empty-state {
  text-align: center;
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(36px, 7vw, 64px) clamp(20px, 5vw, 48px);
  display: grid;
  justify-items: center;
  gap: 12px;
}
.empty-state .big-plant { font-size: 56px; animation: sway 4s ease-in-out infinite; }
@keyframes sway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(5deg); }
}
.empty-state h2 { margin: 0; font-size: 22px; color: var(--moss-800); }
.empty-state p { margin: 0; max-width: 42ch; color: var(--ink-soft); font-size: 14.5px; }
.empty-state .primary-btn { margin-top: 8px; font-size: 15px; padding: 12px 22px; }

/* Celebration banner */
.celebration {
  background: linear-gradient(140deg, var(--moss-600), var(--moss-500));
  color: #f2f8ec;
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-soft);
}
.celebration .c-icon { font-size: 28px; }
.celebration p { margin: 0; font-size: 14.5px; }
.celebration strong { font-weight: 650; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 54, 38, 0.38);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 40;
  animation: fade-in 0.18s ease;
}
.modal-backdrop[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  padding: 24px;
  width: min(480px, 100%);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  animation: rise-in 0.22s ease;
}
.modal.small { width: min(380px, 100%); }
.modal.drawer { width: min(520px, 100%); }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal h2 { margin: 0 0 14px; font-size: 19px; color: var(--moss-800); }
.modal p { color: var(--ink-soft); font-size: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; border: none; padding: 0; }
.field > span, .field legend { font-size: 13px; font-weight: 600; color: var(--moss-700); padding: 0; }
.field em { font-weight: 400; color: var(--ink-soft); }
.field input[type="text"], .field input[type="number"] {
  font: inherit;
  font-size: 15px;
  padding: 11px 13px;
  border: 1.5px solid var(--moss-200);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.field input:focus { border-color: var(--moss-400); outline: none; box-shadow: 0 0 0 3px var(--moss-100); }
.inline-field { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.inline-field input { width: 76px; text-align: center; }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.preset-btn {
  font: inherit;
  font-size: 12.5px;
  border: 1.5px solid var(--moss-200);
  background: #fff;
  color: var(--moss-700);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  min-height: 34px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.preset-btn[aria-checked="true"] { background: var(--moss-600); border-color: var(--moss-600); color: #fff; }
.avatar-row { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-btn {
  font-size: 20px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1.5px solid var(--moss-200);
  background: #fff;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.avatar-btn:hover { transform: scale(1.08); }
.avatar-btn[aria-checked="true"] { border-color: var(--moss-600); background: var(--moss-50); box-shadow: 0 0 0 2px var(--moss-200); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Drawer (plant detail) */
.drawer-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.drawer-head .plant-avatar { width: 60px; height: 60px; font-size: 30px; }
.drawer-head h2 { margin: 0; }
.drawer-sub { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); }
.stat-row { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.stat {
  flex: 1;
  min-width: 96px;
  background: var(--moss-50);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  text-align: center;
}
.stat .s-num { font-size: 20px; font-weight: 700; color: var(--moss-700); }
.stat .s-label { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }
.history-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; max-height: 240px; overflow-y: auto; }
.history-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  background: #fff;
  border: 1px solid var(--moss-100);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.history-list .h-date { font-weight: 600; color: var(--moss-800); }
.history-list .h-rel { color: var(--ink-soft); font-size: 12.5px; }
.history-list .h-late { color: var(--amber-ink); font-size: 12px; }
.history-list .h-ontime { color: var(--moss-600); font-size: 12px; }
.history-empty { font-size: 13px; color: var(--ink-soft); text-align: center; padding: 14px 0; }
.drawer-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* Toasts */
.toast-region {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 60;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--moss-800);
  color: #eef4ea;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: var(--shadow-lift);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s ease;
}
.toast.badge-toast { background: linear-gradient(140deg, var(--moss-700), var(--moss-500)); }
.toast .t-icon { font-size: 20px; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast.leaving { animation: toast-out 0.25s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* Confetti leaves */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 55; overflow: hidden; }
.confetti-leaf {
  position: absolute;
  font-size: 16px;
  animation: leaf-fall 1.1s ease-in forwards;
}
@keyframes leaf-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translateY(90px) rotate(160deg) scale(0.6); }
}

/* Watered ripple on cards */
@keyframes watered-pulse {
  0% { box-shadow: 0 0 0 0 rgba(93, 138, 78, 0.45); }
  100% { box-shadow: 0 0 0 18px rgba(93, 138, 78, 0); }
}
.plant-card.just-watered { animation: watered-pulse 0.7s ease; }

/* Responsive: phone-first reflow */
@media (max-width: 760px) {
  .app-header { flex-wrap: wrap; }
  .week-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
  .day-col { min-height: 108px; padding: 8px 4px; }
  .chip { font-size: 0; gap: 0; justify-content: center; padding: 6px; }
  .chip .chip-avatar { font-size: 15px; }
  .chip .chip-check { display: none; }
  .day-label .dnum { width: 24px; height: 24px; font-size: 13px; }
  .plant-grid { grid-template-columns: 1fr; }
  .header-actions { margin-left: auto; }
}

@media (max-width: 420px) {
  .week-grid { gap: 4px; }
  .day-col { border-radius: 10px; }
  .brand-mark { font-size: 28px; padding: 6px 8px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .leaf { animation: none; }
}
