/* Planterra — mobile-first, dark theme on brand
   Brand: #10b981 emerald, #0f172a navy, white
   Fonts: Plus Jakarta Sans (UI), Montserrat (wordmark accents)
   Baseline width: 375px (iPhone SE)
*/

:root {
  --emerald: #10b981;
  --emerald-dim: #059669;
  --emerald-glow: rgba(16, 185, 129, 0.15);
  --navy: #0f172a;
  --navy-lift: #1e293b;
  --navy-soft: #334155;
  --ink: #f8fafc;
  --ink-dim: #cbd5e1;
  --ink-mute: #94a3b8;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --danger: #f87171;
  --warn: #fbbf24;

  --nav-h: 72px;
  --tara-strip-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--navy);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  display: flex;
  flex-direction: column;
  /* Reserve space for bottom nav + iPhone home indicator */
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

a { color: var(--emerald); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ===== Top bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--navy) 65%, rgba(15, 23, 42, 0));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar .brand { display: flex; align-items: center; gap: 8px; height: 44px; }
.topbar .brand img { height: 44px; width: auto; }
.topbar .meta { display: flex; align-items: center; gap: 10px; color: var(--ink-dim); font-size: 14px; }
.topbar .meta .temp { font-weight: 600; color: var(--ink); }

/* ===== App view container ===== */
.view {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 768px) {
  .view { max-width: 720px; }
}
@media (min-width: 1100px) {
  .view { max-width: 960px; }
}

/* ===== Cards & sections ===== */
.card {
  background: var(--navy-lift);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card-hero {
  background: linear-gradient(155deg, rgba(16,185,129,0.18) 0%, var(--navy-lift) 65%);
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 4px 4px 0;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--emerald);
}
.kicker .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

h1, h2, h3 { margin: 0; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 15px; font-weight: 600; }

.muted  { color: var(--ink-mute); }
.subtle { color: var(--ink-dim); font-size: 14px; }

/* ===== Tara briefing card (home) ===== */
.tara-briefing { display: flex; flex-direction: column; gap: 10px; }
.tara-briefing .who {
  display: flex; align-items: center; gap: 10px;
}
.tara-briefing .who .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--emerald);
  color: var(--navy);
  display: grid; place-items: center;
  font-weight: 800;
  box-shadow: 0 0 0 4px rgba(16,185,129,0.15);
}
.tara-briefing .who .name { font-weight: 700; }
.tara-briefing .who .role { font-size: 12px; color: var(--ink-mute); }
.tara-briefing p { margin: 0; color: var(--ink); }

/* Quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.quick-action {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px;
  background: var(--navy-lift);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink-dim);
  font-size: 12px;
  font-weight: 600;
}
.quick-action .ico { font-size: 20px; line-height: 1; color: var(--emerald); }

/* In-bloom grid — static on mobile (no scroll), expands on desktop */
.bloom-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.bloom-card {
  background: var(--navy-lift);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
@media (min-width: 768px) {
  .bloom-row { grid-template-columns: repeat(6, 1fr); }
}
.bloom-card .photo {
  aspect-ratio: 1 / 1;
  background: var(--navy-soft);
  background-size: cover; background-position: center;
}
.bloom-card .label { padding: 8px 10px; font-size: 12px; font-weight: 600; }
.bloom-card .label .sub { color: var(--ink-mute); font-size: 11px; font-weight: 400; display: block; margin-top: 2px; }

/* ===== My Garden grid ===== */
.filter-row {
  display: flex; gap: 8px; overflow-x: auto;
  margin: 0 -16px; padding: 4px 16px 8px;
  -ms-overflow-style: none; scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
@media (min-width: 768px) {
  .filter-row {
    overflow-x: visible;
    flex-wrap: wrap;
    margin: 0;
    padding: 4px 0 8px;
  }
}

/* ===== Garden filter bar ===== */
.garden-header { }
.garden-search-row {
  display: flex; gap: 8px; align-items: center;
}
.garden-search {
  flex: 1;
  background: var(--navy-lift);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}
.garden-search:focus { border-color: var(--emerald); }
.clear-filters {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink-mute);
  cursor: pointer;
  white-space: nowrap;
}
.filter-btns {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.filter-btn {
  background: var(--navy-lift);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
  cursor: pointer;
  white-space: nowrap;
  display: flex; align-items: center; gap: 4px;
}
.filter-btn--active {
  background: var(--emerald);
  color: var(--navy);
  border-color: var(--emerald);
}
.filter-btn--open {
  border-color: var(--emerald);
  color: var(--emerald);
}
.filter-caret { font-size: 10px; opacity: 0.7; }
.filter-panel {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 14px;
  background: var(--navy-lift);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chip {
  flex: 0 0 auto;
  padding: 8px 14px;
  background: var(--navy-lift);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
  white-space: nowrap;
}
.chip.active {
  background: var(--emerald);
  color: var(--navy);
  border-color: var(--emerald);
}

.plant-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.plant-card {
  background: var(--navy-lift);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.plant-card .photo {
  aspect-ratio: 1 / 1;
  background: var(--navy-soft);
  background-size: cover;
  background-position: center;
  position: relative;
}
.plant-card .badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(15, 23, 42, 0.7);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.plant-card .body { padding: 10px 12px 12px; }
.plant-card .name {
  font-size: 14px; font-weight: 700; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.plant-card .botanical {
  font-size: 11px; color: var(--ink-mute); font-style: italic;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Plant detail */
.plant-detail .hero {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--navy-lift);
  background-size: cover;
  background-position: center 20%; /* show upper portion — flowers/foliage, not soil */
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.plant-detail h1 { margin-top: 12px; }
.plant-detail .botanical { font-style: italic; color: var(--ink-mute); margin-top: 2px; }
.facts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 6px;
}
.facts .fact {
  background: var(--navy-lift); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.facts .fact .k { font-size: 11px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: 0.05em; }
.facts .fact .v { font-size: 14px; color: var(--ink); margin-top: 2px; }

/* ===== Tara screen ===== */
.tara-screen {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 60px - 68px); /* full height minus topbar and bottom nav */
  padding: 0;
  overflow: hidden;
}
.tara-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.tara-intro {
  text-align: center;
  padding-bottom: 8px;
}
.tara-intro .avatar-lg {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: var(--emerald);
  color: var(--navy);
  display: grid; place-items: center;
  font-weight: 800; font-size: 32px;
  margin: 16px auto 8px;
  box-shadow: 0 0 0 8px rgba(16,185,129,0.12), 0 0 32px rgba(16,185,129,0.25);
}
.tara-prompts {
  display: flex; flex-direction: column; gap: 8px; margin-top: 12px;
}
.tara-screen .prompt {
  text-align: left;
  background: var(--navy-lift);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.tara-screen .prompt .ico { color: var(--emerald); margin-right: 8px; }

/* Chat messages */
.tara-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.tara-msg--user {
  flex-direction: row-reverse;
}
.tara-msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--emerald);
  color: var(--navy);
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
  flex-shrink: 0;
}
.tara-msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.tara-msg--assistant .tara-msg-bubble {
  background: var(--navy-lift);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.tara-msg--user .tara-msg-bubble {
  background: var(--emerald);
  color: var(--navy);
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.tara-typing {
  display: flex; gap: 4px; align-items: center; padding: 12px 16px;
}
.tara-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--emerald);
  animation: dot-pulse 1.2s infinite;
}
.tara-typing span:nth-child(2) { animation-delay: 0.2s; }
.tara-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Intro mode: don't stretch messages — input sits right below prompts */
.tara-screen--intro {
  height: auto;
  min-height: unset;
  overflow: visible;
}
.tara-screen--intro .tara-messages {
  flex: 0 0 auto;
  overflow: visible;
}
.tara-screen--intro .tara-input-row {
  border-top: none;
  padding-top: 16px;
}

/* Input row */
.tara-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--navy);
}
.tara-input {
  flex: 1;
  background: var(--navy-lift);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 10px 16px;
  color: var(--ink);
  font-size: 14px;
  outline: none;
}
.tara-input::placeholder { color: var(--ink-mute); }
.tara-input:focus { border-color: var(--emerald); }
.tara-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--emerald);
  color: var(--navy);
  border: none;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.tara-send:disabled { opacity: 0.4; }

/* ===== Identify screen ===== */
.identify-screen .camera-card {
  width: 100%;
  background: linear-gradient(160deg, var(--emerald) 0%, var(--emerald-dim) 100%);
  color: var(--navy);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  font-weight: 700;
  cursor: pointer;
  border: none;
}
.identify-screen .camera-card--secondary {
  background: var(--navy-lift);
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 18px 20px;
}
.identify-screen .camera-card .ico { font-size: 40px; }
.identify-screen .camera-card--secondary .ico { font-size: 28px; }
.identify-screen .camera-card .cta { font-size: 18px; margin-top: 6px; }
.identify-screen .camera-card--secondary .cta { font-size: 16px; margin-top: 4px; }

/* Desktop: show library button, hide mobile trio */
.identify-mobile { display: flex; flex-direction: column; gap: 10px; }
.identify-desktop { display: none; }
@media (min-width: 768px) {
  .identify-desktop { display: block; }
  .identify-mobile { display: none; }
}


/* ===== Bottom nav (Tara CENTER, elevated) ===== */
.bottom-nav {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--navy);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 40;
}
.bottom-nav .nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  color: var(--ink-mute);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  padding: 8px 0;
  min-height: 48px; /* touch target */
}
.bottom-nav .nav-item .ico { font-size: 22px; line-height: 1; }
.bottom-nav .nav-item.active { color: var(--emerald); }
.bottom-nav .nav-item.center {
  position: relative;
}
.bottom-nav .nav-item.center .ico {
  position: absolute;
  top: -24px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--emerald);
  color: var(--navy);
  display: grid; place-items: center;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.35), 0 0 0 6px var(--navy);
}
.bottom-nav .nav-item.center .label { margin-top: 32px; color: var(--emerald); }

/* ===== Loading / empty ===== */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 32px 0;
  color: var(--ink-mute);
  font-size: 14px;
}
.empty {
  text-align: center; padding: 32px 16px;
  color: var(--ink-mute);
}

/* iPad / wider: cap width, still mobile look */
@media (min-width: 600px) {
  .plant-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--navy-lift);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 1000;
  white-space: nowrap;
}
.toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Edit Button (on detail view) ===== */
.btn-edit {
  width: 100%;
  padding: 16px;
  background: var(--emerald);
  color: var(--navy);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.01em;
}

/* ===== Plant Edit Screen ===== */
.plant-edit { padding-bottom: 32px; }

.edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.edit-header h1 { margin: 0; color: var(--emerald); }
.edit-close {
  background: none; border: none;
  color: var(--ink-mute); font-size: 24px;
  cursor: pointer; padding: 4px 8px;
}

/* Photo block */
.edit-photo-block { margin-bottom: 16px; }
.edit-photo-preview {
  width: 100%; height: 180px;
  border-radius: var(--radius);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: var(--navy-lift);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.edit-photo-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-mute); font-size: 14px;
}
.edit-photo-btns { display: flex; gap: 8px; }
.btn-photo-upload {
  flex: 1;
  display: block;
  padding: 10px 16px;
  background: rgba(16,185,129,0.1);
  border: 1px solid var(--emerald);
  border-radius: var(--radius);
  color: var(--emerald);
  font-size: 14px; font-weight: 600;
  text-align: center; cursor: pointer;
}
.btn-photo-remove {
  padding: 10px 14px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: var(--radius);
  color: #f87171;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}

/* Form fields */
.edit-form { display: flex; flex-direction: column; gap: 14px; }
.edit-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.edit-field { display: flex; flex-direction: column; gap: 4px; }
.edit-label {
  font-size: 11px; font-weight: 600;
  color: var(--ink-mute);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.edit-input {
  background: var(--navy-lift);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--ink);
  font-size: 14px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.edit-input:focus { border-color: var(--emerald); }
.edit-textarea { resize: vertical; min-height: 80px; font-family: inherit; }
select.edit-input { appearance: auto; }

.btn-save {
  width: 100%;
  padding: 16px;
  background: var(--emerald);
  color: var(--navy);
  border: none;
  border-radius: var(--radius);
  font-size: 16px; font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}
.btn-save:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-cancel {
  width: 100%;
  padding: 14px;
  background: none;
  border: none;
  color: var(--ink-mute);
  font-size: 15px;
  cursor: pointer;
}
