/* Plantlet — mobile-first stylesheet.
   Phone layout is the default; the desktop shell (sidebar, wider grids,
   two-column detail pages) switches on at 900px. */

@font-face { font-family: "Figtree"; font-weight: 400; font-display: swap; src: url("fonts/figtree-latin-400-normal.7bfd10a3def3.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 500; font-display: swap; src: url("fonts/figtree-latin-500-normal.94e34f97c4c6.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 600; font-display: swap; src: url("fonts/figtree-latin-600-normal.4376f5953b85.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 700; font-display: swap; src: url("fonts/figtree-latin-700-normal.70aaa6879de5.woff2") format("woff2"); }
@font-face { font-family: "Caprasimo"; font-weight: 400; font-display: swap; src: url("fonts/caprasimo-latin-400-normal.c7371a20ecd7.woff2") format("woff2"); }

:root {
  --sage: #728157;
  --sage-600: #5f6d47;
  --leaf: #56633f;
  --olive: #3d472b;
  --terra: #b2622d;
  --rim: #8c491a;
  --cream: #f5ead8;

  --bg: #f5ead8;
  --surface: #fffaf2;
  --surface-2: #f9f1e4;
  --line: #e6d8c1;
  --line-strong: #d6c4a6;
  --ink: #2e2b25;
  --ink-2: #5c564b;
  --muted: #857c6c;
  --primary: #728157;
  --primary-ink: #ffffff;
  --primary-soft: #e6e9d9;
  --danger: #b03a2e;
  --focus: #b2622d;

  --st-plan: #8a8172;  --st-plan-bg: #ece5d8;
  --st-start: #9a6a17; --st-start-bg: #f6e6c4;
  --st-grow: #4f6b2c;  --st-grow-bg: #e2ecd2;
  --st-mature: #a2521d; --st-mature-bg: #f7ddc9;
  --st-done: #5d5a53;  --st-done-bg: #e7e3db;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(61, 50, 30, .06), 0 4px 16px rgba(61, 50, 30, .06);
  --shadow-lg: 0 10px 40px rgba(40, 30, 10, .18);
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Caprasimo", Georgia, serif;
  color-scheme: light;
}

/* Dark palette, applied for explicit dark or system+dark-device. */
:root[data-theme="dark"] {
  --bg: #1c1b17; --surface: #25241f; --surface-2: #2c2a24; --line: #393630; --line-strong: #4a463e;
  --ink: #efe8dc; --ink-2: #cfc6b6; --muted: #9c9383; --primary: #93a474; --primary-ink: #1c1b17;
  --primary-soft: #343b28; --danger: #e0786b; --focus: #e09a62;
  --st-plan: #c3baa9; --st-plan-bg: #35322b; --st-start: #e6b45c; --st-start-bg: #3d321c;
  --st-grow: #a9c47e; --st-grow-bg: #2f3a22; --st-mature: #ec9a63; --st-mature-bg: #432b1b;
  --st-done: #bdb7ab; --st-done-bg: #34322d;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #1c1b17; --surface: #25241f; --surface-2: #2c2a24; --line: #393630; --line-strong: #4a463e;
    --ink: #efe8dc; --ink-2: #cfc6b6; --muted: #9c9383; --primary: #93a474; --primary-ink: #1c1b17;
    --primary-soft: #343b28; --danger: #e0786b; --focus: #e09a62;
    --st-plan: #c3baa9; --st-plan-bg: #35322b; --st-start: #e6b45c; --st-start-bg: #3d321c;
    --st-grow: #a9c47e; --st-grow-bg: #2f3a22; --st-mature: #ec9a63; --st-mature-bg: #432b1b;
    --st-done: #bdb7ab; --st-done-bg: #34322d;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.link { color: var(--primary); font-weight: 600; }
.display { font-family: var(--display); font-weight: 400; font-size: 1.75rem; letter-spacing: -.01em; }
.display.sm { font-size: 1.4rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; font-weight: 600; color: var(--muted); margin: 0 0 2px; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; font-size: .85em; letter-spacing: .04em;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.code.lg { font-size: 1rem; padding: 3px 9px; }
.row-gap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.push { margin-left: auto; }

.icon { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; vertical-align: middle; display: inline-block; }
.icon.xs { width: 16px; height: 16px; }
.on-i { display: none; }
.on > .on-i { display: inline-block; }
.on > .off-i { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; border: 1px solid transparent; font-weight: 600; font-size: .95rem; cursor: pointer;
  background: var(--surface); color: var(--ink); transition: background .15s, transform .05s; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--sage-600); }
.btn-soft { background: var(--primary-soft); color: var(--ink); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .875rem; }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; border: 0;
  background: transparent; cursor: pointer; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm .icon { width: 19px; height: 19px; }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; padding: 3px 9px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip-muted { background: var(--st-done-bg); color: var(--st-done); }
.chip-soft { background: var(--primary-soft); color: var(--ink); }
.chip-founder { background: #f3e2c2; color: #7a4b12; margin-top: 6px; }
:root[data-theme="dark"] .chip-founder { background: #43341c; color: #f0c98a; }
.st-plan { background: var(--st-plan-bg); color: var(--st-plan); }
.st-start { background: var(--st-start-bg); color: var(--st-start); }
.st-grow { background: var(--st-grow-bg); color: var(--st-grow); }
.st-mature { background: var(--st-mature-bg); color: var(--st-mature); }
.st-done { background: var(--st-done-bg); color: var(--st-done); }

/* ---------- shell: phone ---------- */
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 4px; height: 56px; padding: 0 8px;
  padding-top: env(safe-area-inset-top, 0px); height: calc(56px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid transparent;
}
.topbar-title { flex: 1; font-size: 1.05rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.brand-mini { display: grid; place-items: center; width: 44px; height: 44px; }
.brand-mini .logo { width: 28px; height: 28px; }
.topbar-me { display: grid; place-items: center; width: 44px; height: 44px; }

.content { padding: 8px 16px calc(var(--tabbar-h) + var(--safe-b) + 32px); max-width: 1180px; margin: 0 auto; }
.content.narrow { max-width: 640px; }
@media (max-width: 899.98px) { .hide-sm { display: none !important; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .7rem; font-weight: 600; color: var(--muted); }
.tabbar a.on { color: var(--primary); }
.tab-add { align-self: center; justify-self: center; width: 52px; height: 52px; border-radius: 18px; border: 0; cursor: pointer;
  background: var(--terra); color: #fff; box-shadow: 0 6px 16px rgba(178, 98, 45, .35); display: grid; place-items: center; margin-top: -14px; }
.tab-add .icon { width: 30px; height: 30px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 60; left: 12px; right: 12px; top: calc(64px + env(safe-area-inset-top, 0px)); display: grid; gap: 8px; pointer-events: none; }
.toast { margin: 0 auto; max-width: 480px; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px;
  box-shadow: var(--shadow-lg); font-weight: 500; font-size: .95rem; animation: toast 4s ease forwards; }
.toast-error { background: var(--danger); color: #fff; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 6%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-8px); } }

/* ---------- cards / layout ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad, .pad { padding: 16px; }
.grid.cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
.block { margin: 20px 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.two-col, .side-stack { display: grid; gap: 0; }
.side-stack .block { margin-top: 0; margin-bottom: 16px; }

.hello { display: flex; align-items: end; justify-content: space-between; margin: 6px 0 16px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; }
.stat b { font-family: var(--display); font-weight: 400; font-size: 1.6rem; line-height: 1.1; }
.stat span { font-size: .75rem; color: var(--muted); font-weight: 600; }

.hscroll { display: grid; grid-auto-flow: column; grid-auto-columns: 78%; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -16px; padding: 2px 16px 8px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; }

/* batch card: horizontal on phones */
.batch-card { display: grid; grid-template-columns: 104px 1fr; overflow: hidden; min-height: 104px; transition: transform .1s, box-shadow .15s; }
.batch-card:active { transform: scale(.99); }
.bc-media { position: relative; background: var(--surface-2); }
.bc-media img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.bc-ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--line-strong); }
.bc-ph .icon { width: 38px; height: 38px; }
.bc-stage { position: absolute; left: 6px; bottom: 6px; font-size: .68rem; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.bc-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bc-top { display: flex; gap: 6px; align-items: center; }
.bc-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-nick { font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-meta { display: flex; gap: 10px; align-items: center; font-size: .8rem; margin-top: auto; }
.bc-meta span { display: inline-flex; align-items: center; gap: 3px; }
.bc-upd { margin-left: auto; }
.hscroll .batch-card { grid-template-columns: 1fr; grid-template-rows: 150px auto; }

.plant-card { display: grid; grid-template-columns: 76px 1fr; overflow: hidden; min-height: 84px; }
.pc-media { position: relative; background: var(--surface-2); }
.pc-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pc-body { padding: 10px 12px; min-width: 0; }
.pc-title { font-weight: 700; }
.pc-var { font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-meta { display: flex; gap: 8px; align-items: center; font-size: .8rem; margin-top: 4px; flex-wrap: wrap; }

/* ---------- filters ---------- */
.filters { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 14px; align-items: center; }
.search { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 14px; height: 44px; color: var(--muted); }
.search input { border: 0; background: transparent; flex: 1; font: inherit; color: var(--ink); outline: none; min-width: 0; height: 100%; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 6px 14px; border-radius: 999px; font-size: .875rem; font-weight: 600; color: var(--ink-2); }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); }
.seg.wide { display: flex; flex-wrap: wrap; border-radius: 14px; }
.seg.wide label { flex: 1; text-align: center; }
.sort { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); justify-self: end; }
.sort select { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--ink-2); max-width: 150px; }

/* ---------- empty / onboarding ---------- */
.empty { text-align: center; padding: 28px 16px; color: var(--muted); border: 1.5px dashed var(--line-strong); border-radius: var(--radius); }
.empty.big { padding: 40px 20px; color: var(--ink-2); }
.empty h2 { font-family: var(--display); font-weight: 400; font-size: 1.4rem; color: var(--ink); margin: 6px 0 8px; }
.empty .row-gap { justify-content: center; }
.empty-ico { width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty-ico .icon { width: 32px; height: 32px; }
.onboard h3 { font-family: var(--display); font-weight: 400; font-size: 1.3rem; margin-bottom: 12px; }
.onboard { padding: 18px; }
.steps { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 14px; }
.steps li { display: grid; grid-template-columns: 32px 1fr; gap: 12px; }
.steps p { margin: 2px 0 8px; font-size: .9rem; }
.step-n { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--terra); color: #fff; font-weight: 700; }

/* ---------- notes / timeline ---------- */
.feed { display: grid; gap: 10px; }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.feed.compact .note { padding: 10px 12px; border-color: var(--line); box-shadow: none; }
.note-head { display: flex; align-items: center; gap: 8px; min-height: 26px; }
.note-subj { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.note-time { font-size: .8rem; margin-left: auto; white-space: nowrap; }
.note-head > .note-time:first-child { margin-left: 0; margin-right: auto; }
.note-time b { color: var(--ink-2); font-weight: 600; }
.note-del { margin: -6px -8px -6px 0; }
.note-text { margin: 4px 0 0; white-space: normal; overflow-wrap: anywhere; }
.photos { display: grid; gap: 4px; margin-top: 10px; border-radius: 12px; overflow: hidden; }
.photos.n1 { grid-template-columns: 1fr; }
.photos.n2 { grid-template-columns: 1fr 1fr; }
.photos.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.photos.n3 .ph:first-child { grid-row: span 2; }
.photos.n4, .photos.nmany { grid-template-columns: 1fr 1fr; }
.ph { padding: 0; border: 0; background: var(--surface-2); cursor: zoom-in; aspect-ratio: 1; overflow: hidden; }
.photos.n1 .ph { aspect-ratio: 4 / 3; }
.photos.n3 .ph:first-child { aspect-ratio: auto; }
.ph img { width: 100%; height: 100%; object-fit: cover; }

.timeline { display: grid; gap: 10px; margin-top: 14px; }
.day { display: grid; gap: 10px; }
.day-head { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 10px 2px 0; }
#new-notes { display: grid; gap: 10px; }
#new-notes .note { animation: pop .35s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* composer */
.composer { padding: 10px; display: grid; gap: 8px; scroll-margin-top: 72px; }
.composer textarea { width: 100%; border: 0; background: transparent; resize: none; font: inherit; color: var(--ink); padding: 6px 6px 0; min-height: 52px; outline: none; field-sizing: content; max-height: 40vh; }
.composer-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.composer-bar .btn-soft { min-height: 40px; padding: 0 12px; }
.composer-save { margin-left: auto; min-height: 40px; }
@media (max-width: 419.98px) { .composer-bar .btn-soft span { display: none; } .composer-bar .btn-soft { width: 44px; padding: 0; } }
.when { position: relative; }
.when summary { list-style: none; min-height: 40px; padding: 0 10px; color: var(--muted); }
.when summary::-webkit-details-marker { display: none; }
.when[open] input { position: absolute; z-index: 5; top: 44px; left: 0; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-lg); font: inherit; color: var(--ink); }
.uploads { display: flex; gap: 8px; flex-wrap: wrap; }
.uploads:empty { display: none; }
.up { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.up img { width: 100%; height: 100%; object-fit: cover; }
.up .bar { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.6); overflow: hidden; }
.up .bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.up.done .bar { display: none; }
.up.err { outline: 2px solid var(--danger); }
.up button { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }
.up button .icon { width: 16px; height: 16px; }
.form-error { color: var(--danger); font-weight: 600; font-size: .9rem; margin: 4px 0; }

/* ---------- detail pages ---------- */
.detail { display: grid; gap: 14px; }
.info-card { display: grid; gap: 10px; }
.info-top { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.info-card h2 a:hover { text-decoration: underline; text-decoration-thickness: 1px; }
.nick { margin: -4px 0 0; color: var(--ink-2); font-weight: 600; }
.species { font-style: italic; color: var(--muted); margin: -4px 0 0; }
.details { margin: 0; color: var(--ink-2); font-size: .95rem; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0; }
.facts div { background: var(--surface-2); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.facts dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts.counts { grid-template-columns: repeat(4, 1fr); text-align: center; margin-top: 14px; }
.facts.counts dd { font-family: var(--display); font-weight: 400; font-size: 1.3rem; }
.facts.mini { grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 8px 0 12px; }
.facts.mini div { padding: 6px 8px; }
.facts.mini dd { font-size: .85rem; }

.stage-picker { display: grid; gap: 10px; padding: 12px; background: var(--surface-2); border-radius: 14px; }
.stage-track { list-style: none; display: grid; grid-template-columns: repeat(5, 1fr); margin: 0; padding: 0; position: relative; }
.stage-track::before { content: ""; position: absolute; left: 10%; right: 10%; top: 7px; height: 2px; background: var(--line-strong); }
.stage-track li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .68rem; font-weight: 600; color: var(--muted); text-align: center; background: none; }
.stage-track .dot { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); position: relative; z-index: 1; }
.stage-track li.done .dot { background: var(--primary); border-color: var(--primary); }
.stage-track li.now .dot { width: 18px; height: 18px; margin-top: -1px; border: 4px solid currentColor; background: var(--surface); }
.stage-track li.now { background: none; }
.stage-track li.now.st-plan { color: var(--st-plan); }
.stage-track li.now.st-start { color: var(--st-start); }
.stage-track li.now.st-grow { color: var(--st-grow); }
.stage-track li.now.st-mature { color: var(--st-mature); }
.stage-track li.now.st-done { color: var(--st-done); }
.stage-track li.now .lbl { font-weight: 800; }
.select, .stage-form select { width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; padding: 0 12px; }

.lineage { display: grid; gap: 4px; }
.lineage p { margin: 6px 0 0; }
.lin { display: flex; align-items: center; gap: 6px; padding: 6px 0; font-weight: 600; font-size: .95rem; }
.compare-cta { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; background: var(--primary-soft); }
.compare-cta span { flex: 1; display: grid; }
.compare-cta small { color: var(--ink-2); }
.season { margin-bottom: 14px; }
.season .day-head { margin-bottom: 8px; }
.notes-head { margin-top: 24px; }

/* menu */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: 46px; z-index: 40; min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; display: grid; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none; border-radius: 10px; font-weight: 500; text-align: left; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); }
.menu-pop form { margin: 0; }
.danger { color: var(--danger) !important; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form h3 { font-size: 1rem; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-weight: 600; font-size: .9rem; }
.field .opt { font-weight: 500; color: var(--muted); font-size: .8rem; }
.field input:not([type=radio]):not([type=checkbox]), .field select, .field textarea {
  width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 16px; padding: 10px 12px;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 50%, transparent); border-color: var(--primary); }
.field .help { color: var(--muted); }
.field .err { color: var(--danger); font-weight: 600; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.field.radios ul, .field ul { list-style: none; padding: 0; margin: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.check { display: flex; gap: 10px; align-items: center; font-size: .95rem; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.form-actions { display: flex; justify-content: flex-end; }
.form-actions .btn { width: 100%; }
.care { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 12px; }
.care summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.care[open] { gap: 12px; }
.care > :not(summary) { margin-top: 12px; }

/* ---------- pick list (quick note) ---------- */
.pick-list { display: grid; gap: 8px; margin: 8px 0 18px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.pick-thumb { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--line-strong); flex-shrink: 0; }
.pick-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pick-txt { flex: 1; min-width: 0; display: grid; }
.pick-txt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more summary { cursor: pointer; padding: 8px 0; }
.mini-list { list-style: none; padding: 0; margin: 0; display: grid; }
.mini-list a { display: block; padding: 8px 0; border-top: 1px solid var(--line); }
.mini-list li:first-child a { border-top: 0; }

/* ---------- catalog ---------- */
.cat-card { display: flex; flex-direction: column; }
.cat-card form, .cat-card > .chip { margin-top: auto; align-self: flex-start; }
.cat-title { font-weight: 600; font-size: 1.05rem; }

/* ---------- compare ---------- */
.compare-pick { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin: 10px 0 14px; scrollbar-width: none; }
.pill-check { position: relative; flex-shrink: 0; }
.pill-check input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pill-check > span { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-size: .875rem; font-weight: 600; }
.pill-check input:checked + span { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.pill-check input:checked + span .code { background: rgba(255,255,255,.2); border-color: transparent; color: inherit; }
.compare { overflow-x: auto; margin: 0 -16px; padding: 0 16px; scroll-snap-type: x proximity; }
.cmp-row { display: grid; grid-template-columns: 54px repeat(var(--cols), minmax(240px, 1fr)); gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cmp-head { position: sticky; top: 56px; background: var(--bg); z-index: 3; border-bottom: 2px solid var(--line-strong); }
.cmp-col-head { display: grid; gap: 2px; padding: 4px; scroll-snap-align: start; justify-items: start; }
.cmp-wk { position: sticky; left: 0; background: var(--bg); z-index: 2; display: grid; align-content: start; font-size: .85rem; }
.cmp-cell { display: grid; gap: 8px; align-content: start; scroll-snap-align: start; }
.cmp-note { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.cmp-note p { margin: 2px 0 0; font-size: .9rem; }
.cmp-note .photos { margin-top: 6px; max-width: 320px; }
.cmp-note .photos.n1 .ph { aspect-ratio: 3 / 2; }
.cmp-none { color: var(--line-strong); padding: 8px; }

/* ---------- profile ---------- */
.me-card { margin-bottom: 14px; }
.me-top { display: flex; gap: 16px; align-items: center; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--olive); color: var(--cream);
  font-weight: 700; font-size: .95rem; object-fit: cover; flex-shrink: 0; }
.avatar.sm { width: 34px; height: 34px; font-size: .8rem; }
.avatar.lg { width: 76px; height: 76px; font-size: 1.6rem; }
.avatar-edit { position: relative; }
.avatar-btn { position: absolute; right: -4px; bottom: -4px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer; }
.avatar-btn .icon { width: 18px; height: 18px; }
.form.card { margin-bottom: 14px; }
.list-card { display: grid; overflow: hidden; }
.list-card a, .list-card button { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; width: 100%; text-align: left; font-weight: 500; cursor: pointer; }
.list-card > :last-child, .list-card > form:last-child button { border-bottom: 0; }
.list-card span:not(.icon) { flex: 1; }
.list-card form { margin: 0; }

/* ---------- sheet + lightbox ---------- */
dialog { border: 0; padding: 0; color: var(--ink); }
.sheet { width: 100%; max-width: 520px; margin: auto auto 0; border-radius: 22px 22px 0 0; background: var(--surface); padding: 8px 12px calc(12px + var(--safe-b)); }
.sheet[open] { animation: up .22s ease; }
.sheet::backdrop { background: rgba(20, 16, 8, .45); }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 40px; height: 5px; border-radius: 4px; background: var(--line-strong); margin: 4px auto 10px; }
.sheet-item { display: flex; align-items: center; gap: 14px; padding: 12px 8px; border-radius: 14px; }
.sheet-item:hover { background: var(--surface-2); }
.sheet-item span:last-child { display: grid; }
.sheet-item small { color: var(--muted); }
.sheet-ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; }
.c-sage { background: var(--sage); } .c-terra { background: var(--terra); } .c-olive { background: var(--olive); }
.sheet form { margin-top: 6px; }
.lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; background: rgba(10, 9, 6, .94); color: #fff; }
.lightbox[open] { display: grid; place-items: center; }
.lightbox::backdrop { background: rgba(0,0,0,.6); }
.lightbox img { max-width: 100vw; max-height: 86dvh; object-fit: contain; }
.lightbox .icon-btn { position: absolute; color: #fff; background: rgba(255,255,255,.08); }
.lb-close { top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; }
.lb-prev { left: 8px; top: 50%; } .lb-next { right: 8px; top: 50%; }
.lb-caption { position: absolute; bottom: calc(14px + var(--safe-b)); left: 16px; right: 16px; text-align: center; color: #ddd; font-size: .95rem; margin: 0; }

/* ---------- public pages ---------- */
body.public { min-height: 100dvh; }
.public-wrap { max-width: 760px; margin: 0 auto; padding: 16px; display: grid; gap: 18px; }
.public-wrap.auth { min-height: 100dvh; align-content: center; max-width: 440px; }
.public-wrap.auth .public-head { display: none; }
.public-head .brand, .brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 1.4rem; }
.brand .logo { width: 32px; height: 32px; }
.public-foot { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; font-size: .85rem; color: var(--muted); padding: 12px 0 24px; }
.auth-card { text-align: center; display: grid; gap: 14px; padding: 28px 22px; }
.auth-logo .logo { width: 64px; height: 64px; margin: 0 auto; }
.auth-buttons { display: grid; gap: 10px; }
.btn-provider { background: var(--surface); border: 1px solid var(--line-strong); }
.p-apple { background: #000; color: #fff; border-color: #000; }
:root[data-theme="dark"] .p-apple { background: #fff; color: #000; }
.legal a { text-decoration: underline; }
.legal-doc h1 { margin-bottom: 4px; }
.legal-doc h2 { font-size: 1.1rem; margin: 22px 0 8px; }
.legal-doc ul { padding-left: 20px; margin: 0 0 12px; display: grid; gap: 6px; }
.legal-doc a { color: var(--primary); text-decoration: underline; }

/* ---------- tablet+ ---------- */
@media (min-width: 600px) {
  .grid.cards { grid-template-columns: repeat(2, 1fr); }
  .hscroll { grid-auto-columns: 46%; }
  .facts { grid-template-columns: repeat(4, 1fr); }
  .form-actions .btn { width: auto; }
  .filters { grid-template-columns: 1fr auto auto; }
  .search { grid-column: auto; }
}

/* ---------- desktop shell ---------- */
@media (min-width: 900px) {
  .tabbar, .topbar { display: none; }
  .shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
  .sidebar {
    display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; height: 100vh; padding: 22px 16px;
    border-right: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 55%, var(--bg));
  }
  .sidebar .brand { padding: 0 8px; }
  .sidebar-new { justify-content: flex-start; padding-left: 18px; }
  .side-nav { display: grid; gap: 2px; }
  .side-nav a, .side-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; font-weight: 600; color: var(--ink-2); }
  .side-nav a:hover, .side-link:hover, .me-chip:hover { background: var(--surface-2); }
  .side-nav a.on { background: var(--primary-soft); color: var(--ink); }
  .side-nav a.on .icon { color: var(--primary); }
  .side-foot { margin-top: auto; display: grid; gap: 6px; }
  .me-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; }
  .me-chip.on { background: var(--primary-soft); }
  .me-name { display: grid; font-weight: 600; font-size: .9rem; line-height: 1.25; min-width: 0; }
  .me-name small { color: var(--muted); font-weight: 500; font-size: .75rem; }

  .content { padding: 32px 40px 64px; }
  .content.wide { max-width: none; }
  .toasts { top: 18px; left: auto; right: 24px; width: 380px; }
  .display { font-size: 2.1rem; }
  .display.sm { font-size: 1.6rem; }
  .hello { margin-top: 0; }

  .grid.cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
  .grid.cards.plants { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .grid.cards .batch-card { grid-template-columns: 1fr; grid-template-rows: 170px auto; }
  .grid.cards .plant-card { grid-template-columns: 96px 1fr; min-height: 96px; }
  .batch-card:hover, .plant-card:hover { box-shadow: 0 6px 22px rgba(61, 50, 30, .12); transform: translateY(-1px); }
  .hscroll { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); grid-auto-columns: auto; overflow: visible; margin: 0; padding: 0; }
  .hscroll .batch-card { grid-template-rows: 140px auto; }
  .stats { max-width: 620px; gap: 12px; }
  .stat { padding: 14px 16px; }
  .two-col { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 28px; align-items: start; }
  .side-stack { position: sticky; top: 24px; }

  .detail { grid-template-columns: 360px minmax(0, 1fr); gap: 28px; align-items: start; }
  .detail-info { position: sticky; top: 24px; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .facts.counts { grid-template-columns: repeat(4, 1fr); }
  .info-card { padding: 20px; }
  .composer { padding: 12px; }
  .cam-only { display: none; }
  .compare { margin: 0; padding: 0; }
  .cmp-head { top: 0; }
  .lightbox img { max-width: 86vw; }
  .timeline .photos { max-width: 680px; }
  .timeline .photos.n1 { max-width: 560px; }
}

@media (min-width: 1280px) {
  .detail { grid-template-columns: 400px minmax(0, 1fr); }
}

@media (hover: none) { .cam-only { display: inline-flex; } }
@media (hover: hover) and (pointer: fine) { .cam-only { display: none; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- insights (staff) ---------- */
.ins-head { align-items: flex-start; flex-wrap: wrap; }
.ins-head p { margin: 2px 0 0; }
.seg-link { display: block; padding: 6px 14px; border-radius: 999px; font-size: .875rem; font-weight: 600; color: var(--ink-2); }
.seg-link.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.stats.four { grid-template-columns: repeat(2, 1fr); margin-bottom: 14px; }
.stat small { font-size: .72rem; color: var(--muted); }
.ink { color: var(--ink); }
.ins-grid { display: grid; gap: 14px; }
.ins-card h3 { font-size: 1rem; }
.ins-card .block-head { flex-wrap: wrap; }
.ins-legend { display: flex; gap: 12px; font-size: .78rem; color: var(--muted); }
.ins-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--primary); margin-right: 5px; vertical-align: -1px; }
.ins-legend i.ly { background: var(--line-strong); }
.ins-weeks { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(8px, 1fr); gap: 3px; align-items: end; height: 150px;
  border-bottom: 1px solid var(--line); padding-bottom: 1px; overflow-x: auto; }
.ins-wk { display: grid; grid-auto-flow: column; gap: 1px; align-items: end; height: 100%; }
.ins-wk i { display: block; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 1px; }
.ins-wk i.ly { background: var(--line-strong); }
.ins-wk-labels { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(8px, 1fr); gap: 3px; font-size: .68rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.funnel { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 12px; }
.fn-top { display: flex; justify-content: space-between; gap: 8px; font-size: .92rem; }
.fn-n { color: var(--muted); font-variant-numeric: tabular-nums; }
.fn-n b { color: var(--ink); }
.fn-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.fn-track i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.funnel li:last-child .fn-track i { background: var(--terra); }
.prob-list, .fb-list { list-style: none; margin: 0; padding: 0; display: grid; }
.prob, .fb-list li { padding: 10px 0; border-top: 1px solid var(--line); display: grid; gap: 3px; }
.prob:first-child, .fb-list li:first-child { border-top: 0; padding-top: 2px; }
.prob-top { display: flex; align-items: center; gap: 8px; }
.prob-where code, .fb-list code { font-family: ui-monospace, Menlo, monospace; font-size: .82rem; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.fb-list p { margin: 4px 0 0; }
.chip-bad { background: #f6d9d3; color: #8a2a1c; }
.chip-warn { background: var(--st-start-bg); color: var(--st-start); }
:root[data-theme="dark"] .chip-bad { background: #4a2620; color: #f2b2a6; }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] .chip-bad { background: #4a2620; color: #f2b2a6; } }
.ins-ok { display: flex; align-items: center; gap: 8px; color: var(--st-grow); font-weight: 600; font-size: .92rem; }
.table-scroll { overflow-x: auto; margin: 0 -4px; }
.ins-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ins-table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 0 4px 6px; }
.ins-table td { padding: 8px 4px; border-top: 1px solid var(--line); }
.ins-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.miss { display: flex; flex-wrap: wrap; gap: 6px; }
.miss b { margin-left: 2px; }
.ins-foot { margin-top: 20px; }
@media (min-width: 600px) { .stats.four { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) {
  .ins-grid { grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
  .ins-wide { grid-column: 1 / -1; }
  .stats.four { max-width: none; }
}
