/* Plant Doctor — botanical calm design system
   Deep green #2d5a3d, warm cream #faf7f0, terracotta accent #c67d54
   Phone-first (390px), rounded cards, generous whitespace, friendly. */

:root {
  --green-deep: #2d5a3d;
  --green-mid: #3f7a54;
  --green-pale: #e6efe7;
  --cream: #faf7f0;
  --cream-card: #ffffff;
  --terracotta: #c67d54;
  --terracotta-dark: #a8623d;
  --ink: #2a2620;
  --ink-muted: #6b6459;
  --border: #e9e2d4;
  --danger: #b5493a;
  --danger-bg: #fbe9e5;
  --safe: #3f7a54;
  --safe-bg: #e6efe7;
  --warn: #b5842f;
  --warn-bg: #faf0dc;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(45, 90, 61, 0.08);
  --shadow-lift: 0 6px 24px rgba(45, 90, 61, 0.14);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--cream);
  position: relative;
  padding-bottom: 24px;
}

.screen {
  display: none;
  padding: 0 20px 32px;
  animation: fadeIn 0.2s ease;
}
.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 12px;
  position: sticky;
  top: 0;
  background: var(--cream);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-leaf { font-size: 1.4rem; }
.brand-name {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--green-deep);
  letter-spacing: -0.01em;
}

.header-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--green-deep);
}
.header-spacer { width: 40px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--cream-card);
  box-shadow: var(--shadow);
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--green-deep);
}
.icon-btn:active { transform: scale(0.94); }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 1rem;
  padding: 14px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn-large { width: 100%; padding: 16px 20px; font-size: 1.05rem; }
.btn-icon { font-size: 1.1em; }

.btn-primary {
  background: var(--green-deep);
  color: #fff;
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--green-mid); }

.btn-secondary {
  background: var(--cream-card);
  color: var(--green-deep);
  border: 2px solid var(--green-pale);
}

.btn-accent {
  background: var(--terracotta);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  font-weight: 600;
}

/* ---------- Home ---------- */
.btn-hero {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  border: none;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--terracotta), var(--terracotta-dark));
  color: #fff;
  box-shadow: var(--shadow-lift);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s ease;
}
.btn-hero:active { transform: scale(0.98); }
.btn-hero-icon { font-size: 2.1rem; line-height: 1; flex-shrink: 0; }
.btn-hero-text { display: flex; flex-direction: column; gap: 2px; }
.btn-hero-title { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; }
.btn-hero-sub { font-weight: 600; font-size: 0.78rem; opacity: 0.92; }

.home-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 8px 0 24px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--green-deep);
  margin: 8px 0 12px;
}
.section-title.small { font-size: 0.9rem; margin-top: 20px; }

.roster-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.plant-card {
  background: var(--cream-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.plant-card:active { transform: scale(0.97); }

.plant-card-photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--green-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
}

.plant-card-body { padding: 10px 12px 14px; }
.plant-card-name {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--ink);
  margin: 0 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plant-card-room {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin: 0;
}
.plant-card-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 20px;
}
.plant-card-badge.toxic { background: var(--danger-bg); color: var(--danger); }
.plant-card-badge.safe { background: var(--safe-bg); color: var(--safe); }
.plant-card-badge.verify { background: var(--warn-bg); color: var(--warn); }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-muted);
}
.empty-state.small { padding: 24px 12px; font-size: 0.9rem; }
.empty-icon { font-size: 2.6rem; margin-bottom: 10px; }
.empty-state .btn { margin-top: 16px; }

.muted { color: var(--ink-muted); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.85rem; font-weight: 700; color: var(--green-deep); }

input[type="text"], input[type="password"] {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--cream-card);
  color: var(--ink);
}
input[type="text"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: var(--green-mid);
}

.photo-picker { display: flex; justify-content: center; margin-bottom: 4px; }
.photo-picker-label {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border);
  background: var(--cream-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 0.85rem;
  overflow: hidden;
}
.photo-picker-label img { width: 100%; height: 100%; object-fit: cover; }
.photo-picker-icon { font-size: 1.8rem; }

.photo-picker-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.photo-picker-label.small { width: 100%; height: 110px; font-size: 0.78rem; }

/* Photo processing (client-side resize) + friendly HEIC/decode-failure state */
.photo-picker-label.processing { color: var(--ink-muted); font-style: italic; }
.photo-picker-label.processing .photo-picker-icon { animation: pd-pulse 1.1s ease-in-out infinite; }
@keyframes pd-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* The error message is longer than the square photo slot can hold at a readable size, so let the
   slot grow to fit it instead of clipping (the default .photo-picker-label has a fixed height +
   overflow:hidden, sized for a thumbnail image, not for text). */
.photo-picker-label.has-error {
  height: auto;
  min-height: 140px;
  overflow: visible;
  cursor: pointer;
}
.photo-picker-label.small.has-error { min-height: 110px; }

.photo-picker-error {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  font-size: 0.7rem;
  line-height: 1.4;
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: calc(var(--radius-lg) - 2px);
}
.photo-picker-error .photo-picker-error-title { font-weight: 700; font-size: 0.78rem; }

/* ---------- Detail ---------- */
.detail-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 8px 0 16px;
}
.detail-photo {
  width: 84px; height: 84px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--green-pale);
}
.detail-hero-info h1 { font-size: 1.25rem; margin: 0 0 2px; color: var(--ink); }
.detail-hero-info p { margin: 1px 0; font-size: 0.86rem; }

.toxicity-badge {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.toxicity-badge .tb-icon { font-size: 1.3rem; line-height: 1; }
.toxicity-badge.toxic { background: var(--danger-bg); color: var(--danger-dark, #8c3427); }
.toxicity-badge.safe { background: var(--safe-bg); color: #285a3a; }
.toxicity-badge.verify { background: var(--warn-bg); color: #7a5a1f; }

.log-list { display: flex; flex-direction: column; gap: 10px; }
.log-entry {
  background: var(--cream-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
}
.log-entry-main { flex: 1; min-width: 0; }
.log-entry-date { font-size: 0.72rem; color: var(--ink-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.log-entry-issue { font-weight: 700; margin: 4px 0 2px; }
.log-entry-species { font-size: 0.8rem; color: var(--ink-muted); }

/* ---------- Tappable rows (Ward Round summary + Care Log entries) ---------- */
/* Visual affordance for rows that open the full diagnosis: chevron + hover/active state. */
.ward-summary-item.tappable,
.log-entry.tappable {
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.ward-summary-item.tappable:hover,
.log-entry.tappable:hover {
  background: var(--green-pale);
}
.ward-summary-item.tappable:active,
.log-entry.tappable:active {
  transform: scale(0.98);
}
.ward-summary-item.tappable:focus-visible,
.log-entry.tappable:focus-visible {
  outline: 2px solid var(--green-mid);
  outline-offset: 2px;
}
.row-chevron {
  font-size: 1.4rem;
  color: var(--ink-muted);
  line-height: 1;
  flex-shrink: 0;
  padding-left: 2px;
}
.thin-entry-note {
  background: var(--warn-bg);
  color: #7a5a1f;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* ---------- Diagnose flow ---------- */
.diagnose-context {
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.intake-skip-row { text-align: right; margin: -4px 0 14px; }
.skip-link {
  background: none;
  border: none;
  padding: 4px 2px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font-family: inherit;
}
.skip-link:active { color: var(--green-deep); }

.intake-group { margin-bottom: 16px; }
.intake-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--green-deep);
  margin-bottom: 8px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 2px solid var(--border);
  background: var(--cream-card);
  color: var(--ink);
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.chip.selected {
  background: var(--green-deep);
  border-color: var(--green-deep);
  color: #fff;
}

#btn-submit-diagnose { margin-top: 8px; }

/* ---------- Loading / sprout animation ---------- */
.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 6px;
}

.sprout-anim {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 20px;
}
.sprout-pot { font-size: 3rem; position: relative; z-index: 1; }
.sprout-leaf {
  position: absolute;
  bottom: 34px;
  font-size: 1.6rem;
  animation: sprout-grow 1.8s ease-in-out infinite;
  transform-origin: bottom center;
}
@keyframes sprout-grow {
  0% { transform: scale(0.3) translateY(6px) rotate(-6deg); opacity: 0.4; }
  50% { transform: scale(1.15) translateY(-4px) rotate(4deg); opacity: 1; }
  100% { transform: scale(0.3) translateY(6px) rotate(-6deg); opacity: 0.4; }
}

.loading-text { font-weight: 700; font-size: 1.05rem; color: var(--green-deep); margin: 0; }
.loading-sub { font-size: 0.85rem; margin-top: 4px; }

/* ---------- Result ---------- */
.result-content { display: flex; flex-direction: column; gap: 18px; }

.demo-banner {
  background: var(--warn-bg);
  color: #7a5a1f;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.result-species-card {
  background: var(--cream-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}
.result-species-name { font-size: 1.2rem; font-weight: 700; margin: 0 0 2px; }
.result-species-sci { font-style: italic; color: var(--ink-muted); font-size: 0.85rem; margin: 0 0 8px; }
.confidence-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.confidence-pill.high { background: var(--safe-bg); color: var(--safe); }
.confidence-pill.medium { background: var(--warn-bg); color: var(--warn); }
.confidence-pill.low { background: var(--danger-bg); color: var(--danger); }

/* ---------- Demo/sample-data callouts (never let a canned demo response read as a real result) ---------- */
.sample-suffix { color: var(--ink-muted); font-weight: 700; font-size: 0.85em; letter-spacing: 0.02em; }
.species-pill-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.demo-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: transparent;
  color: var(--ink-muted);
  border: 1px dashed var(--ink-muted);
}
.demo-inline-note {
  margin: 10px 0 0;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--ink-muted);
}

.differential-list { display: flex; flex-direction: column; gap: 12px; }
.differential-item {
  background: var(--cream-card);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--terracotta);
}
.differential-item.rank-1 { border-left-color: var(--green-deep); }
.differential-rank { font-size: 0.68rem; font-weight: 800; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.differential-issue { font-weight: 700; margin: 4px 0 6px; font-size: 1rem; }
.differential-evidence { font-size: 0.86rem; color: var(--ink-muted); line-height: 1.45; }

.care-plan-list { display: flex; flex-direction: column; gap: 10px; }
.care-item {
  background: var(--cream-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 10px;
}
.care-priority {
  flex-shrink: 0;
  width: 8px;
  border-radius: 4px;
  margin-top: 2px;
}
.care-priority.urgent { background: var(--danger); }
.care-priority.soon { background: var(--terracotta); }
.care-priority.routine { background: var(--green-mid); }
.care-action { font-weight: 700; font-size: 0.92rem; margin: 0 0 3px; }
.care-why { font-size: 0.82rem; color: var(--ink-muted); line-height: 1.4; }

.result-notes {
  background: var(--green-pale);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.82rem;
  color: #2a4a35;
  line-height: 1.45;
}

.result-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

/* ---------- Ward Round ---------- */
.ward-content { display: flex; flex-direction: column; gap: 16px; }
.ward-plant-name { font-size: 1.3rem; font-weight: 700; text-align: center; margin: 8px 0 0; }
.ward-progress-bar {
  height: 6px;
  background: var(--green-pale);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.ward-progress-fill { height: 100%; background: var(--green-deep); transition: width 0.3s ease; }

.ward-summary-list { display: flex; flex-direction: column; gap: 10px; }
.ward-summary-item {
  background: var(--cream-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
}
.ward-summary-item img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--green-pale); }
.ward-summary-body { flex: 1; min-width: 0; }
.ward-summary-name { font-weight: 700; font-size: 0.92rem; margin: 0; }
.ward-summary-issue { font-size: 0.78rem; color: var(--ink-muted); margin: 2px 0 0; }

/* ---------- Settings ---------- */
.settings-content { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.settings-card {
  background: var(--cream-card);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow);
}
.settings-card h3 { margin: 0 0 8px; font-size: 0.95rem; color: var(--green-deep); }
.settings-card p { margin: 4px 0; font-size: 0.88rem; }
.settings-hint { font-size: 0.78rem !important; color: var(--ink-muted); }
.settings-hint code {
  background: var(--green-pale);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.76rem;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
  max-width: 90%;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
