/* ============================================================
   ReliaGrow — earthy botanical UI
   ============================================================ */
:root {
  --paper: #efe9da;
  --ink: #1c2b21;
  --inkS: #44544a;
  --forest: #1f4d35;
  --forest2: #2c6648;
  --moss: #6f8a63;
  --leaf: #3f8a52;
  --amber: #c2882a;
  --clay: #b9472a;
  --card: #f7f3e9;
  --card2: #fbf8f0;
  --line: #d9d1bd;
  --shadow: 0 6px 20px rgba(40, 50, 30, 0.10);
  --shadow-sm: 0 2px 8px rgba(40, 50, 30, 0.08);
  --r: 20px;
  --r-sm: 12px;
}

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

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

body {
  font-family: 'Spline Sans', system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(111,138,99,0.08), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(194,136,42,0.06), transparent 45%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 460px;
  margin: 0 auto;
  padding: 18px 16px calc(96px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 16px; }
img { display: block; }

.mono { font-family: 'DM Mono', monospace; }
.serif { font-family: 'Fraunces', serif; }

/* ---------- App header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.app-header h1 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 30px;
  letter-spacing: -0.5px;
}
.pulse { color: var(--forest2); font-style: italic; }
.icon-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  color: var(--forest);
  font-size: 20px;
  transition: transform .12s ease, background .12s ease;
}
.icon-btn:active { transform: scale(.92); }
.header-actions { display: flex; gap: 8px; }

.boot { text-align: center; padding-top: 30vh; color: var(--inkS); }
.boot h1 { font-family: 'Fraunces', serif; font-size: 34px; }
.boot .pulse { font-style: italic; }

/* ---------- Subhead / counts ---------- */
.subhead {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--moss);
  margin-bottom: 14px;
}

/* ---------- Plant grid ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.plant-card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-align: left;
  display: flex;
  flex-direction: column;
  transition: transform .12s ease;
}
.plant-card:active { transform: scale(.97); }
.thumb {
  aspect-ratio: 1 / 1;
  width: 100%;
  object-fit: cover;
  background: linear-gradient(150deg, #e7e1cf, #d8e0cc);
}
.thumb.placeholder {
  display: grid; place-items: center;
  font-size: 44px; color: var(--moss);
}
.plant-card .meta { padding: 10px 12px 14px; }
.plant-card .name {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.2;
}
.plant-card .sci {
  font-size: 12px; font-style: italic; color: var(--inkS);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Status badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'DM Mono', monospace;
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 4px 9px; border-radius: 999px;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; }
.badge.green { background: rgba(63,138,82,.14); color: #2c6b40; }
.badge.green .dot { background: var(--leaf); }
.badge.amber { background: rgba(194,136,42,.16); color: #946017; }
.badge.amber .dot { background: var(--amber); }
.badge.red { background: rgba(185,71,42,.14); color: #9a3b22; }
.badge.red .dot { background: var(--clay); }
.badge.unknown { background: rgba(111,138,99,.14); color: var(--inkS); }
.badge.unknown .dot { background: var(--moss); }
.card-badge { position: absolute; top: 10px; left: 10px; box-shadow: var(--shadow-sm); }
.thumb-wrap { position: relative; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--inkS);
}
.empty .leaf { font-size: 56px; }
.empty h2 { font-family: 'Fraunces', serif; margin: 12px 0 6px; color: var(--ink); }

/* ---------- Floating add button ---------- */
.fab {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 30;
  background: var(--forest);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 22px;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(31,77,53,.35);
  display: flex; align-items: center; gap: 8px;
}
.fab:active { transform: translateX(-50%) scale(.96); }

/* ---------- Detail view ---------- */
.detail-top {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.back-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow-sm);
  display: grid; place-items: center; font-size: 20px; color: var(--forest);
}
.detail-title { flex: 1; min-width: 0; }
.detail-title .name {
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 22px; line-height: 1.15;
}
.detail-title .sci { font-size: 13px; font-style: italic; color: var(--inkS); }

.hero {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--r);
  box-shadow: var(--shadow);
  background: linear-gradient(150deg, #e7e1cf, #d8e0cc);
}
.hero.placeholder { display: grid; place-items: center; font-size: 60px; color: var(--moss); }
.hero-wrap { position: relative; margin-bottom: 12px; }
.hero-badge { position: absolute; top: 12px; right: 12px; box-shadow: var(--shadow-sm); }

/* ---------- Filmstrip ---------- */
.filmstrip {
  display: flex; gap: 10px;
  overflow-x: auto; padding: 4px 2px 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filmstrip::-webkit-scrollbar { display: none; }
.film {
  flex: 0 0 auto; width: 62px; text-align: center;
}
.film img {
  width: 62px; height: 62px; object-fit: cover;
  border-radius: var(--r-sm);
  border: 2px solid transparent;
  box-shadow: var(--shadow-sm);
}
.film.active img { border-color: var(--forest2); }
.film .when {
  font-family: 'DM Mono', monospace;
  font-size: 9.5px; color: var(--inkS); margin-top: 4px;
  white-space: nowrap;
}
.film .stat-dot {
  width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 3px;
}

/* ---------- Action row ---------- */
.action-row { display: flex; gap: 8px; margin: 4px 0 16px; }
.action-row button {
  flex: 1;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  border-radius: var(--r-sm);
  padding: 12px 6px;
  font-size: 12.5px; font-weight: 600;
  color: var(--forest);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.action-row button .ic { font-size: 18px; }
.action-row button.primary { background: var(--forest); color: #fff; }
.action-row button:active { transform: scale(.96); }
.action-row button:disabled { opacity: .5; }

/* ---------- Cards (diagnosis / advice / info) ---------- */
.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-label {
  font-family: 'DM Mono', monospace;
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--moss); margin-bottom: 8px;
}
.card h3 {
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 18px; margin-bottom: 6px;
}
.card p { font-size: 14.5px; line-height: 1.5; color: var(--inkS); margin-bottom: 8px; }
.card p strong { color: var(--ink); }
.remedies { list-style: none; margin-top: 6px; }
.remedies li {
  position: relative; padding-left: 22px; font-size: 14px; line-height: 1.45;
  margin-bottom: 6px; color: var(--ink);
}
.remedies li::before {
  content: '🌱'; position: absolute; left: 0; top: 0; font-size: 13px;
}

/* status-tinted diagnosis card */
.diag.green { border-left: 5px solid var(--leaf); }
.diag.amber { border-left: 5px solid var(--amber); }
.diag.red { border-left: 5px solid var(--clay); }
.diag .status-line { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

/* proactive advice card */
.advice {
  background: linear-gradient(160deg, #eaf2e4, #dcebd1 0%);
  background: linear-gradient(160deg, #e8f1e1, #dce9d2);
  border: 1px solid #c7dcb6;
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.advice .card-label { color: var(--forest2); }
.advice .from {
  font-size: 13px; color: var(--forest); font-weight: 600; margin-bottom: 8px;
}
.advice ul { list-style: none; }
.advice ul li {
  position: relative; padding-left: 22px; font-size: 14px; line-height: 1.5;
  margin-bottom: 7px; color: var(--ink);
}
.advice ul li::before { content: '✓'; position: absolute; left: 2px; color: var(--leaf); font-weight: 700; }
.advice .warn {
  margin-top: 10px; padding: 10px 12px;
  background: rgba(194,136,42,.14);
  border-radius: var(--r-sm);
  font-size: 13.5px; line-height: 1.45; color: #845112;
  display: flex; gap: 8px;
}
.advice .warn::before { content: '⚠️'; }
.advice .src-tag {
  display: inline-block; margin-top: 10px;
  font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: .5px;
  text-transform: uppercase; color: var(--moss);
}

/* ---------- Care log ---------- */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 18px 2px 10px;
}
.section-head h2 { font-family: 'Fraunces', serif; font-weight: 600; font-size: 19px; }
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-entry {
  background: var(--card);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  cursor: pointer;
}
.log-entry .row { display: flex; align-items: center; gap: 10px; }
.log-entry .ic {
  width: 30px; height: 30px; border-radius: 9px;
  background: rgba(111,138,99,.16);
  display: grid; place-items: center; font-size: 15px; flex: 0 0 auto;
}
.log-entry .label { font-weight: 600; font-size: 14.5px; flex: 1; }
.log-entry .date { font-family: 'DM Mono', monospace; font-size: 11.5px; color: var(--inkS); }
.log-entry .expand {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line);
  font-size: 13.5px; color: var(--inkS); line-height: 1.5;
}
.log-entry .expand .full-ts {
  font-family: 'DM Mono', monospace; font-size: 11.5px; color: var(--moss);
  display: block; margin-bottom: 4px;
}
.show-more {
  width: 100%; margin-top: 4px;
  background: transparent; color: var(--forest2);
  font-weight: 600; font-size: 13.5px; padding: 10px;
}
.log-empty { color: var(--inkS); font-size: 14px; padding: 8px 2px; }

/* ---------- Bottom sheet ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(28,43,33,.42);
  backdrop-filter: blur(2px);
  animation: fade .18s ease;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: 460px; margin: 0 auto;
  background: var(--card2);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -10px 30px rgba(30,40,25,.22);
  padding: 8px 18px calc(24px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: slideup .24s cubic-bezier(.2,.8,.25,1);
}
.sheet .grabber {
  width: 42px; height: 5px; border-radius: 3px; background: var(--line);
  margin: 8px auto 14px;
}
.sheet h2 {
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 21px; margin-bottom: 4px;
}
.sheet .sub { font-size: 13px; color: var(--inkS); margin-bottom: 16px; }
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* segmented control */
.segmented {
  display: flex; background: var(--paper); border-radius: 12px; padding: 4px; margin-bottom: 16px;
}
.segmented button {
  flex: 1; padding: 9px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--inkS);
}
.segmented button.on { background: var(--card2); color: var(--forest); box-shadow: var(--shadow-sm); }

/* action chips */
.chips { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 16px; }
.chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--paper);
  border: 1.5px solid transparent;
  border-radius: 999px;
  padding: 9px 14px; font-size: 14px; font-weight: 500;
}
.chip .ic { font-size: 16px; }
.chip.on { background: rgba(63,138,82,.14); border-color: var(--leaf); color: var(--forest); font-weight: 600; }

/* forms */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-family: 'DM Mono', monospace; font-size: 11px;
  text-transform: uppercase; letter-spacing: 1px; color: var(--moss); margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 12px;
  color: var(--ink); outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--moss); }
.field textarea { resize: vertical; min-height: 70px; }

.btn {
  width: 100%; padding: 15px; border-radius: 14px;
  background: var(--forest); color: #fff; font-weight: 600; font-size: 15.5px;
  box-shadow: var(--shadow-sm); margin-top: 6px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; }
.btn.ghost { background: var(--paper); color: var(--forest); }
.btn.clay { background: var(--clay); }

.photo-drop {
  border: 2px dashed var(--line); border-radius: 16px;
  padding: 28px 16px; text-align: center; color: var(--inkS);
  background: var(--paper); margin-bottom: 14px;
}
.photo-drop .big { font-size: 40px; }
.photo-drop .hint { font-size: 13px; margin-top: 6px; }
.preview-img { width: 100%; border-radius: 14px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }

.inline-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px;
}
.inline-spinner.dark { border-color: rgba(31,77,53,.3); border-top-color: var(--forest); }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-block { text-align: center; padding: 30px; color: var(--inkS); }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; left: 0; right: 0; z-index: 80;
  bottom: calc(86px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 16px;
}
.toast {
  max-width: 420px; width: 100%;
  background: var(--ink); color: #f4efe2;
  padding: 12px 16px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow);
  animation: toastin .22s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast.good { background: var(--forest); }
.toast.bad { background: var(--clay); }
.toast.warn { background: var(--amber); color: #20170a; }
@keyframes toastin { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

[hidden] { display: none !important; }
