:root {
  --green: #2f6b4f;
  --green-dark: #245540;
  --green-light: #e7f1ea;
  --leaf: #4f9d6f;
  --cream: #f6f4ee;
  --card: #ffffff;
  --ink: #1f2b25;
  --muted: #6b7a72;
  --line: #e3e0d8;
  --due: #e08a2e;
  --overdue: #d8493f;
  --ok: #3f9d63;
  --shadow: 0 2px 10px rgba(31, 43, 37, .07);
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* beat CSS display rules on .analyze-status etc. */
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Heebo', system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; }
.muted { color: var(--muted); }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: var(--green);
  color: #fff;
  box-shadow: var(--shadow);
}
.brand { font-weight: 800; font-size: 1.15rem; }
.container { max-width: 720px; margin: 0 auto; padding: 18px 16px 60px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 12px; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 1rem;
  padding: 12px 18px; transition: transform .05s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-outline { background: #fff; color: var(--green); border: 2px solid var(--green); }
.btn-danger { background: #fff; color: var(--overdue); border: 1.5px solid var(--overdue); margin-top: 22px; }
.btn-sm { padding: 7px 13px; font-size: .9rem; border-radius: 10px; }
.btn-lg { padding: 15px 20px; font-size: 1.08rem; }
.btn-block { display: flex; width: 100%; margin-top: 12px; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; margin-bottom: 16px; }

/* banner */
.banner { padding: 12px 16px; border-radius: 12px; font-weight: 700; margin-bottom: 16px; }
.banner-due { background: #fbecd7; color: #8a5210; border: 1px solid #f0d3a3; }

/* push notification prompt */
.notif-box { background: var(--green-light); border: 1px solid #cfe3d6; border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.notif-box span { font-weight: 600; font-size: .92rem; flex: 1; min-width: 180px; }
.notif-actions { display: flex; gap: 8px; }

/* grid of plant cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.plant-card { overflow: hidden; display: flex; flex-direction: column; transition: transform .08s, box-shadow .15s; }
.plant-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(31,43,37,.12); }
.thumb { position: relative; aspect-ratio: 1/1; background: var(--green-light); display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder { font-size: 3rem; }
.status-dot { position: absolute; top: 8px; inset-inline-start: 8px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; }
.status-ok .status-dot { background: var(--ok); }
.status-due .status-dot { background: var(--due); }
.status-overdue .status-dot { background: var(--overdue); }
.card-body { padding: 10px 12px 14px; }
.plant-name { font-size: 1.02rem; margin: 0 0 2px; }
.species { color: var(--muted); font-size: .85rem; margin: 0 0 6px; }
.water-line { font-size: .85rem; margin: 0 0 8px; font-weight: 600; }
.card-water-btn { background: var(--green-light); color: var(--green-dark); width: 100%; }
.card-water-btn:hover { background: #d8e8de; }
.card-water-btn:disabled { opacity: .6; }
.dash-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.calendar-link { display: block; text-align: center; margin: 20px auto 0; color: var(--green); font-weight: 700; padding: 12px; }
.dash-links .calendar-link { margin: 0; background: #fff; border-radius: 12px; box-shadow: var(--shadow); flex: 1; min-width: 150px; }

/* per-plant light fit */
.plant-need { margin-bottom: 16px; text-align: center; }
.plant-need .need-label { color: var(--muted); font-weight: 600; }
.plant-need .need-value { font-weight: 800; font-size: 1.15rem; color: var(--green-dark); display: block; margin-top: 2px; }
.plant-need .muted { margin: 8px 0 0; font-size: .9rem; }
.fit-verdict { text-align: center; font-weight: 800; font-size: 1.25rem; padding: 14px; border-radius: 12px; margin-bottom: 6px; }
.fit-good { background: #e3f3e8; color: #1f6b3c; }
.fit-warn { background: #fbecd7; color: #8a5210; }
.fit-bad { background: #fbe4e2; color: #9b2f28; }
.light-check-btn { margin-top: 14px; }

/* light meter */
#cam { width: 100%; max-height: 220px; object-fit: cover; border-radius: 14px; background: #000; }
.light-readout { text-align: center; margin: 16px 0; }
.light-bar { height: 16px; border-radius: 999px; background: #e3e0d8; overflow: hidden; position: relative; }
.light-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg,#6b7a72,#e7c14b,#f4e08a,#fff7d6); transition: width .2s; }
.light-pct { font-size: 2.4rem; font-weight: 800; margin-top: 10px; color: var(--ink); }
.light-cat { font-size: 1.15rem; font-weight: 700; }
.light-tip { color: var(--muted); margin: 6px 0 14px; }
.howto-card summary { font-weight: 700; cursor: pointer; }
.howto-card ul { padding-inline-start: 20px; }
.howto-card li { margin-bottom: 8px; }
.howto { margin-top: 18px; }
.howto h3 { font-size: 1rem; }
.howto ol { padding-inline-start: 20px; margin: 8px 0; }
.howto li { margin-bottom: 8px; }

/* empty state */
.empty { text-align: center; padding: 50px 20px; }
.empty-emoji { font-size: 4rem; }
.empty h2 { margin-top: 10px; }
.empty p { max-width: 360px; margin: 8px auto 22px; }

/* login */
.login-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 34px 28px; text-align: center; width: 100%; max-width: 340px; }
.login-emoji { font-size: 3.4rem; }
.login-card h1 { margin: 6px 0 2px; }
.input-pin { text-align: center; letter-spacing: .3em; font-size: 1.3rem; margin: 18px 0 6px; }

/* forms */
.input { width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 11px; font-family: inherit; font-size: 1rem; background: #fff; color: var(--ink); }
.input:focus { outline: none; border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(79,157,111,.15); }
textarea.input { resize: vertical; }
.input-num { max-width: 120px; }
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 5px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.check { display: flex; align-items: center; gap: 9px; margin: 6px 0 4px; font-size: .95rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--green); }

/* alerts */
.alert { padding: 11px 14px; border-radius: 11px; margin: 12px 0; font-weight: 600; }
.alert-error { background: #fbe4e2; color: #9b2f28; border: 1px solid #f1c4bf; }

/* add page */
.page-title { margin-bottom: 16px; }
.back-link { display: inline-block; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.pick-row { display: flex; gap: 10px; }
.pick-row .btn { flex: 1; }
.pick-count { font-size: .85rem; margin: 10px 0 0; font-weight: 600; }
.pot-field { margin-top: 16px; }
.previews { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.preview { position: relative; }
.preview-fallback { width: 90px; height: 90px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--green-light); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.preview img { width: 90px; height: 90px; object-fit: cover; border-radius: 12px; border: 1.5px solid var(--line); display: block; }
.preview-remove { position: absolute; top: -7px; inset-inline-end: -7px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: var(--overdue); color: #fff; font-size: .8rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); padding: 0; }
.analyze-status { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); font-weight: 600; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--green-light); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-title { color: var(--green); }

/* diagnosis badge */
.diagnosis { background: var(--green-light); border-radius: 12px; padding: 14px; margin: 14px 0; }
.diag-badge { display: inline-block; font-weight: 700; font-size: .9rem; padding: 5px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); }
.diag-notes { margin: 10px 0 0; }
.cond-healthy { background: #e3f3e8; color: #1f6b3c; border-color: #b9e0c6; }
.cond-overwatered { background: #e2eefb; color: #1f4e8a; border-color: #bcd6f3; }
.cond-underwatered, .cond-pest { background: #fbece0; color: #8a4a14; border-color: #f0d0b3; }
.cond-low_light { background: #ece8f5; color: #4a3a7a; border-color: #d3c9ec; }
.cond-other { background: #f0efe9; color: #555; }
.care-details summary { font-weight: 700; cursor: pointer; padding: 6px 0; }

/* detail page */
.detail-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.hero-photo { width: 120px; height: 120px; border-radius: 18px; object-fit: cover; box-shadow: var(--shadow); flex-shrink: 0; }
.hero-photo.placeholder { display: flex; align-items: center; justify-content: center; font-size: 3rem; background: var(--green-light); }
.photo-strip { display: flex; gap: 6px; margin-top: 6px; }
.photo-strip img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.detail-title h1 { margin-bottom: 2px; }
.water-status { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; text-align: center; border-top: 5px solid var(--ok); }
.water-status.status-due { border-top-color: var(--due); }
.water-status.status-overdue { border-top-color: var(--overdue); }
.water-status .big { display: block; font-size: 1.2rem; font-weight: 800; }
.water-status .sub { display: block; color: var(--muted); font-size: .88rem; margin: 6px 0 4px; }
.water-amount { background: var(--green-light); color: var(--green-dark); border-radius: 10px; padding: 9px 12px; margin: 10px 0; font-weight: 600; font-size: .95rem; }
.care-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.care-item:last-child { border-bottom: none; }
.care-ic { font-size: 1.4rem; }
.care-item strong { display: block; }
.care-item p { margin: 2px 0 0; color: #3c4742; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.history li:last-child { border-bottom: none; }
