:root {
  --bg: #f4f6f2;
  --card: #ffffff;
  --ink: #16241c;
  --muted: #667a6f;
  --line: #e2e8e0;
  --green: #2f6f4e;
  --green-dark: #245a3f;
  --green-soft: #e6f1ea;
  --amber: #b5761f;
  --amber-soft: #fdf3e2;
  --blue: #2f5d8a;
  --blue-soft: #e7eff7;
  --red: #b03d33;
  --pink-soft: #fbeaf0;
  --r: 14px;
  --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 4px 14px rgba(20, 40, 30, .05);
}

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

body {
  margin: 0;
  background: #e8ebe6;
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* On a phone this fills the screen; on a desktop it sits in a phone-sized
   column so the layout you test is the layout you ship. */
#phone {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 40px rgba(0, 0, 0, .08);
  display: flex;
  flex-direction: column;
}
#screen { flex: 1; padding-bottom: 78px; }

/* ---------- top bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--green); color: #fff;
  padding: 14px 16px 12px;
  border-radius: 0 0 18px 18px;
}
.appbar h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.appbar .loc {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .16); border: 0; color: #fff;
  padding: 5px 11px; border-radius: 20px; font: inherit; font-size: 13px;
  margin-top: 7px; cursor: pointer;
}
.appbar .loc:active { background: rgba(255, 255, 255, .28); }

.searchwrap { padding: 12px 16px 4px; }
.searchwrap input {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); font: inherit;
}
.searchwrap input:focus { outline: 2px solid var(--green-soft); border-color: var(--green); }

/* ---------- generic ---------- */
.pad { padding: 14px 16px; }
.card {
  background: var(--card); border-radius: var(--r); padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700; margin: 18px 16px 8px;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

button.btn {
  background: var(--green); color: #fff; border: 0; padding: 13px 18px;
  border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer; width: 100%;
}
button.btn:active { background: var(--green-dark); }
button.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
button.btn.small { padding: 9px 14px; font-size: 14px; width: auto; }
button.btn:disabled { opacity: .55; }

select, input {
  width: 100%; padding: 12px 13px; border: 1px solid var(--line);
  border-radius: 12px; font: inherit; background: var(--card); color: var(--ink);
}
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }

.chip {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; background: var(--green-soft); color: var(--green); font-weight: 600;
}
.chip.grey { background: #eef1ee; color: var(--muted); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.pink { background: var(--pink-soft); color: #a23f66; }

/* ---------- task list (This week) ---------- */
.task {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border-radius: var(--r); padding: 12px 14px;
  margin-bottom: 9px; box-shadow: var(--shadow); cursor: pointer;
}
.task .ic {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; font-size: 18px; background: var(--green-soft);
}
.task .ic.harvest { background: var(--amber-soft); }
.task .ic.bloom { background: var(--pink-soft); }
.task .ic.care { background: var(--blue-soft); }
.task b { display: block; font-weight: 600; }
.task .sub { font-size: 12.5px; color: var(--muted); }

/* ---------- category grid ---------- */
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; padding: 0 16px; }
.cat {
  background: var(--card); border: 0; border-radius: var(--r); padding: 16px 14px;
  text-align: left; font: inherit; cursor: pointer; box-shadow: var(--shadow);
}
.cat .e { font-size: 26px; display: block; margin-bottom: 6px; }
.cat b { display: block; font-weight: 600; }
.cat .n { font-size: 12.5px; color: var(--muted); }
.cat:active { transform: scale(.98); }
.cat.feature { background: linear-gradient(160deg, #2f6f4e, #3d8560); color: #fff; }
.cat.feature .n { color: rgba(255,255,255,.82); }

/* ---------- plant rows ---------- */
.plant {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border-radius: var(--r); padding: 12px 14px;
  margin-bottom: 9px; box-shadow: var(--shadow); cursor: pointer;
}
.plant .thumb {
  width: 44px; height: 44px; border-radius: 11px; flex: none;
  background: var(--green-soft); display: grid; place-items: center; font-size: 21px;
  background-size: cover; background-position: center;
}
.plant b { display: block; font-weight: 600; }
.plant em { font-style: italic; color: var(--muted); font-size: 12.5px; }
.plant .go { color: var(--muted); font-size: 19px; }

/* ---------- detail ---------- */
.detail-head {
  background: var(--green); color: #fff; padding: 14px 16px 20px;
  border-radius: 0 0 18px 18px;
}
.detail-head .back {
  background: rgba(255,255,255,.16); border: 0; color: #fff; font: inherit;
  padding: 6px 12px; border-radius: 20px; cursor: pointer; margin-bottom: 10px;
}
.detail-head h1 { margin: 0; font-size: 23px; letter-spacing: -.015em; }
.detail-head .bot { opacity: .82; font-style: italic; font-size: 14px; }

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv .item { background: var(--card); border-radius: 12px; padding: 11px 12px; box-shadow: var(--shadow); }
.kv .item .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kv .item .v { font-weight: 600; margin-top: 2px; }

.timeline { margin-top: 4px; }
.tl-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.tl-row:last-child { border-bottom: 0; }
.tl-row .lab { flex: none; width: 106px; font-size: 13px; color: var(--muted); }
.tl-row .val { font-weight: 600; font-size: 14px; }
.tl-row.active .val { color: var(--green); }
.tl-row .now-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); margin-left: 6px; vertical-align: 1px;
}

.bar { height: 9px; border-radius: 5px; background: #eef1ee; position: relative; overflow: hidden; margin-top: 3px; }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.months { display: flex; font-size: 9px; color: var(--muted); margin-top: 3px; }
.months span { flex: 1; text-align: center; }

.note { background: var(--amber-soft); border-left: 3px solid var(--amber); padding: 9px 12px; border-radius: 0 8px 8px 0; font-size: 13px; margin: 8px 0; }
.warn { background: var(--pink-soft); border-left-color: var(--red); }

/* ---------- tab bar ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  max-width: 460px; margin: 0 auto;
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar.hidden { display: none; }
#tabbar button {
  background: none; border: 0; padding: 8px 4px 10px; font: inherit;
  color: var(--muted); cursor: pointer; display: grid; gap: 2px; justify-items: center;
}
#tabbar button i { font-style: normal; font-size: 20px; line-height: 1; }
#tabbar button span { font-size: 10.5px; font-weight: 600; }
#tabbar button.active { color: var(--green); }

/* ---------- misc ---------- */
/* ---------- segmented control ---------- */
.segwrap { padding: 12px 16px 0; }
.seg { display: flex; background: #e7ebe6; border-radius: 11px; padding: 3px; }
.seg button {
  flex: 1; border: 0; background: none; font: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--muted); padding: 8px 6px; border-radius: 9px; cursor: pointer;
}
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ---------- schedule chart ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 11px; height: 8px; border-radius: 3px; display: inline-block; }

.chartcard {
  background: var(--card); border-radius: var(--r); margin: 0 16px 4px;
  padding: 10px 12px 12px; box-shadow: var(--shadow); overflow: hidden;
}
.chartmonths, .chartrow { display: flex; align-items: center; }
.chartmonths { font-size: 9.5px; color: var(--muted); padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.chartmonths > span:not(.chartname) { flex: 1; text-align: center; }
.chartname {
  flex: none; width: 108px; font-size: 12px; font-weight: 600; line-height: 1.25;
  padding-right: 8px; overflow-wrap: break-word;
}
.chartrow { padding: 6px 0; cursor: pointer; border-bottom: 1px solid #f2f5f1; }
.chartrow:last-child { border-bottom: 0; }
.chartrow:active { background: var(--bg); }
.chartlane {
  position: relative; flex: 1; height: 13px; background: #f1f4f0; border-radius: 4px; overflow: hidden;
}
.chartlane i { position: absolute; top: 2px; height: 9px; border-radius: 3px; }
.chartlane i.today { top: 0; height: 13px; width: 2px !important; background: var(--ink); border-radius: 0; opacity: .55; }

.empty { text-align: center; color: var(--muted); padding: 40px 24px; }
.empty .e { font-size: 34px; display: block; margin-bottom: 10px; }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--green);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%) translateY(90px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px;
  transition: transform .25s; z-index: 100; max-width: 90vw; font-size: 14px;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

.adminlink {
  display: block; text-align: center; padding: 14px; color: var(--muted);
  font-size: 12.5px; text-decoration: none;
}
.adminlink:hover { color: var(--green); }

.onboard { padding: 36px 22px 24px; }
.onboard .hero { text-align: center; margin-bottom: 26px; }
.onboard .hero .e { font-size: 46px; }
.onboard .hero h1 { margin: 10px 0 4px; font-size: 25px; letter-spacing: -.02em; }
.onboard .or { text-align: center; color: var(--muted); font-size: 12.5px; margin: 16px 0; }

/* ---------- expanded / printable chart ---------- */
.chart-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.chart-head .openhint { font-size: 10px; opacity: .6; font-weight: 600; }
.chart-head:active { color: var(--green); }

.chart-overlay {
  position: fixed; inset: 0; z-index: 200; background: var(--bg); overflow-y: auto;
}
.chart-sheet { max-width: 1000px; margin: 0 auto; padding-bottom: 40px; }
.chart-toolbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 14px;
}
.chart-controls { padding: 12px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
.chart-controls .chip { cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: 6px; }
.chart-controls .chip i { width: 10px; height: 8px; border-radius: 2px; display: inline-block; }
.chart-controls .chip input { width: auto; margin: 0; accent-color: var(--green); }
.chart-controls .chip:not(.on) { background: #eef1ee; color: var(--muted); }

.printable { padding: 16px 14px; background: #fff; }
.sheet-head h2 { margin: 0 0 2px; font-size: 20px; }
.sheet-sub { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.sheet-legend { margin-bottom: 14px; }
.sheet-group { margin-bottom: 18px; break-inside: avoid; }
.sheet-group h3 { font-size: 13px; margin: 0 0 6px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sheet-card { margin: 0; box-shadow: none; border: 1px solid var(--line); }
.sheet-card .chartname { width: 150px; }
.sheet-card .chartmonths > span:not(.chartname) { font-size: 10px; }
.rowslot { display: block; font-size: 10px; font-weight: 500; color: var(--muted); }
.sheet-foot { font-size: 11px; color: var(--muted); margin-top: 10px; }

body.chart-open #phone { display: none; }

@media print {
  @page { margin: 12mm; }
  body { background: #fff; }
  .no-print, #tabbar, #toast { display: none !important; }
  .chart-overlay { position: static; overflow: visible; }
  .printable { padding: 0; }
  .chartlane { background: #f1f4f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .chartlane i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .legend i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Toast: dismissible, and never parked on top of a button. */
.toast { display: flex; align-items: center; gap: 12px; cursor: pointer; line-height: 1.4; text-align: left; }
.toast.low { bottom: 18px; }
.toast .x { font-style: normal; opacity: .65; flex: none; font-size: 12px; }

/* ---------- per-activity calendar lanes (plant detail) ---------- */
.lane-months {
  display: flex; justify-content: space-between; font-size: 9.5px; color: var(--muted);
  padding: 0 0 4px; border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.lane { margin-bottom: 11px; }
.lane:last-of-type { margin-bottom: 2px; }
.lane-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.lane-name { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.lane-name i { width: 10px; height: 8px; border-radius: 2px; display: inline-block; flex: none; }
.lane-date { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.lane.active .lane-date { color: var(--green); font-weight: 600; }
.now-tag {
  background: var(--green); color: #fff; border-radius: 4px;
  font-size: 9.5px; padding: 1px 5px; font-weight: 700; text-transform: uppercase;
}
.lane-bar { position: relative; height: 10px; background: #eef1ee; border-radius: 5px; overflow: hidden; }
.lane-bar i { position: absolute; top: 1px; height: 8px; border-radius: 4px; }
.lane-bar i.lane-today { top: 0; height: 10px; width: 2px !important; background: var(--ink); opacity: .5; border-radius: 0; }
.plant.dim { opacity: .62; }
