/* app.css — Plants · Tom's in the Lab
 *
 * Tom's in the Lab family: Roboto (as on tomsinthelab.com), the brick
 * building's palette (outline navy, brick red, window gold) on a warm paper
 * background, and plant green for the one primary action per view.
 * Mobile first (375px, checked at 320px); 44px tap targets; 16px+ inputs;
 * safe areas; dark mode; reduced motion.
 */

/* ------------------------------------------------------------- Tokens -- */
:root {
  color-scheme: light dark;
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #faf7f1;
  --blush: #fdeee9;
  --ink: #12222d;
  --ink-2: #4c5961;
  --ink-3: #7d878d;
  --line: rgba(18, 34, 45, 0.12);
  --line-strong: rgba(18, 34, 45, 0.22);
  --brick: #b5432a;
  --navy: #2a5a7f;
  --gold: #e8b04b;
  --leaf: #2d7a4c;
  --leaf-ink: #ffffff;
  --leaf-soft: #e2efe5;
  --leaf-soft-ink: #1f5636;
  --warn-soft: #fff3d6;
  --warn-ink: #7a5300;
  --danger: #b3261e;
  --danger-soft: #fde7e5;
  --focus: #2a5a7f;
  --shadow: 0 1px 2px rgba(18, 34, 45, 0.06), 0 4px 16px rgba(18, 34, 45, 0.06);
  --font: 'Roboto', system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  --r: 12px;
  --r-sm: 8px;
  --top-h: calc(56px + env(safe-area-inset-top, 0px));
  --tab-h: calc(60px + env(safe-area-inset-bottom, 0px));
  --maxw: 880px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f171c;
    --surface: #17232b;
    --surface-2: #1c2a33;
    --blush: #2a1f1d;
    --ink: #eef1ee;
    --ink-2: #b9c3c6;
    --ink-3: #8a979c;
    --line: rgba(255, 255, 255, 0.1);
    --line-strong: rgba(255, 255, 255, 0.2);
    --leaf: #4fae74;
    --leaf-ink: #06140b;
    --leaf-soft: #1b3325;
    --leaf-soft-ink: #a8dcb9;
    --warn-soft: #33290f;
    --warn-ink: #f0cf82;
    --danger: #ff8a80;
    --danger-soft: #3a1a18;
    --focus: #8cc4ef;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

/* --------------------------------------------------------------- Base -- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
}
img { max-width: 100%; display: block; }
a { color: var(--navy); text-underline-offset: 2px; }
@media (prefers-color-scheme: dark) { a { color: #8cc4ef; } }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
small, .muted { color: var(--ink-2); }
.tiny { font-size: 0.8rem; color: var(--ink-3); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------- Chrome -- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--top-h);
  padding: env(safe-area-inset-top, 0px) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 10px;
  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 var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); min-height: 44px; }
.brand img { width: 34px; height: 34px; }
.brand .name { display: flex; flex-direction: column; line-height: 1.05; }
.brand .name strong { font-size: 1.05rem; font-weight: 900; letter-spacing: 0.01em; }
.brand .name span { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brick); font-weight: 700; }
.topbar .spacer { flex: 1; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; border-radius: 999px;
  border: 0; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--line); }
.icon-btn svg { width: 24px; height: 24px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: var(--tab-h);
  padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left));
  display: flex; justify-content: space-around; align-items: stretch;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; max-width: 140px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 0.72rem; font-weight: 500; color: var(--ink-3); text-decoration: none; min-height: 44px;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current='page'] { color: var(--leaf); }
@media (min-width: 900px) {
  .tabbar { top: 0; bottom: auto; left: auto; right: 64px; height: var(--top-h); background: transparent; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; width: 440px; padding-top: env(safe-area-inset-top, 0px); }
  .tabbar a { flex-direction: row; gap: 6px; font-size: 0.9rem; }
  :root { --tab-h: 0px; }
}

main { max-width: var(--maxw); margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-left)) calc(var(--tab-h) + 32px) max(16px, env(safe-area-inset-right)); }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.page-head h1 { margin: 0; flex: 1 1 auto; }
.site-foot { text-align: center; font-size: 0.85rem; color: var(--ink-3); padding: 24px 0 8px; }
.site-foot a { color: var(--ink-2); display: inline-flex; min-height: 44px; align-items: center; }

/* ------------------------------------------------------------ Buttons -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--r-sm);
  font: inherit; font-weight: 500; font-size: 1rem; line-height: 1;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--leaf); border-color: var(--leaf); color: var(--leaf-ink); }
.btn-primary:hover { filter: brightness(1.05); border-color: var(--leaf); }
.btn-tonal { background: var(--leaf-soft); border-color: transparent; color: var(--leaf-soft-ink); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--navy); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.9rem; position: relative; }
.btn-sm::after { content: ''; position: absolute; inset: -4px 0; }
.btn[disabled], .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ------------------------------------------------------------- Cards -- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-head h2, .card-head h3 { margin: 0; flex: 1; }
.empty { text-align: center; padding: 32px 16px; color: var(--ink-2); }
.empty h2 { color: var(--ink); }
.notice { border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 16px; background: var(--warn-soft); color: var(--warn-ink); font-size: 0.95rem; }
.notice.ok { background: var(--leaf-soft); color: var(--leaf-soft-ink); }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 500; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.tentative { background: var(--warn-soft); color: var(--warn-ink); border-color: transparent; }
.badge.confirmed { background: var(--leaf-soft); color: var(--leaf-soft-ink); border-color: transparent; }
.badge.gifted { background: var(--blush); color: var(--brick); border-color: transparent; }

/* ------------------------------------------------------------- Plants -- */
.plant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.plant-tile { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.plant-tile .ph { aspect-ratio: 1; background: var(--leaf-soft); display: flex; align-items: center; justify-content: center; color: var(--leaf); }
.plant-tile .ph img { width: 100%; height: 100%; object-fit: cover; }
.plant-tile .ph svg { width: 40%; height: 40%; opacity: 0.6; }
.plant-tile .meta { padding: 10px 12px 12px; }
.plant-tile .meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plant-tile .meta span { display: block; font-size: 0.85rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-row input { flex: 1; min-width: 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chip { flex: none; display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 0.9rem; position: relative; }
.chip::after { content: ''; position: absolute; inset: -4px 0; }
.chip[aria-current='true'] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.plant-hero { display: grid; gap: 16px; margin-bottom: 16px; }
.plant-hero .cover { border-radius: var(--r); overflow: hidden; background: var(--leaf-soft); aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; }
.plant-hero .cover img { width: 100%; height: 100%; object-fit: cover; }
.plant-hero .cover svg { width: 30%; opacity: 0.5; color: var(--leaf); }
.plant-hero h1 { margin-bottom: 4px; }
.plant-hero .sub { color: var(--ink-2); margin-bottom: 8px; }
@media (min-width: 700px) { .plant-hero { grid-template-columns: 320px 1fr; align-items: start; } }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: 0.95rem; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button { font: inherit; border: 0; background: none; padding: 0 14px; min-height: 44px; color: var(--ink-2); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--leaf); font-weight: 500; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline > li { position: relative; padding: 0 0 20px 20px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline > li::before { content: ''; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--leaf); border: 2px solid var(--bg); }
.timeline .day { font-weight: 700; font-size: 0.95rem; margin-bottom: 6px; }
.event { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.event:last-child { border-bottom: 0; }
.event .what { flex: 1; min-width: 0; }
.event .what strong { font-weight: 500; }
.event .what p { margin: 2px 0 0; font-size: 0.92rem; color: var(--ink-2); white-space: pre-wrap; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; margin-top: 6px; }
.thumb { position: relative; border: 0; padding: 0; background: var(--leaf-soft); border-radius: var(--r-sm); overflow: hidden; aspect-ratio: 1; cursor: pointer; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .tag { position: absolute; left: 4px; bottom: 4px; font-size: 0.7rem; background: rgba(0, 0, 0, 0.6); color: #fff; padding: 1px 6px; border-radius: 999px; }
.thumb[aria-pressed='true'] { outline: 3px solid var(--leaf); outline-offset: -3px; }
.thumb[aria-pressed='true']::after { content: '✓'; position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--leaf); color: var(--leaf-ink); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.gallery-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.gallery-head h2 { margin: 0; flex: 1; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compare figure { margin: 0; }
.compare img { width: 100%; border-radius: var(--r-sm); background: var(--leaf-soft); }
.compare figcaption { font-size: 0.85rem; color: var(--ink-2); margin-top: 4px; }

/* ------------------------------------------------------------- Forms -- */
label { display: block; font-weight: 500; font-size: 0.92rem; margin: 12px 0 4px; }
label .hint { font-weight: 400; color: var(--ink-3); }
input[type='text'], input[type='search'], input[type='date'], input[type='number'], input[type='email'], input[type='url'], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 88px; resize: vertical; line-height: 1.45; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; min-height: 44px; margin: 4px 0; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--leaf); }
.grid2 { display: grid; gap: 0 12px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
fieldset { border: 0; padding: 0; margin: 0; }
.field-error { color: var(--danger); font-size: 0.9rem; margin-top: 8px; }

/* ------------------------------------------------------------ Sheets -- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 640px; max-height: 92dvh;
  border-radius: 16px 16px 0 0; background: var(--surface); color: var(--ink);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2);
}
dialog.sheet::backdrop { background: rgba(10, 20, 25, 0.45); }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 16px; } }
.sheet-inner { padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; max-height: 92dvh; }
.sheet-head { position: sticky; top: 0; z-index: 1; background: var(--surface); display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.sheet-head h2 { margin: 0; flex: 1; font-size: 1.1rem; }
.lightbox { background: #000; }
.lightbox img { max-height: 70dvh; width: auto; margin: 0 auto; }

/* ------------------------------------------------------------ Uploads -- */
.upload-tray { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.upload-item { position: relative; flex: none; width: 76px; height: 76px; border-radius: var(--r-sm); overflow: hidden; background: var(--leaf-soft); }
.upload-item img { width: 100%; height: 100%; object-fit: cover; }
.upload-item .bar { position: absolute; left: 0; bottom: 0; height: 5px; background: var(--leaf); width: 0; transition: width 0.2s; }
.upload-item .state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 0.7rem; color: #fff; background: rgba(0, 0, 0, 0.45); padding: 2px; }
.upload-item.done .state { display: none; }
.upload-item.failed .state { background: rgba(160, 30, 20, 0.75); }
.upload-item .x { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.upload-item .x::after { content: ''; position: absolute; inset: -8px; }
.upload-item .retry { position: absolute; left: 2px; bottom: 8px; right: 2px; border: 0; border-radius: 6px; background: #fff; color: #000; font-size: 0.75rem; min-height: 26px; cursor: pointer; }
.upload-errors { font-size: 0.9rem; color: var(--danger); }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* --------------------------------------------------------------- Chat -- */
.chat-log { flex: 1; display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
.msg { max-width: 92%; }
.msg.user { align-self: flex-end; }
.msg .bubble { padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--navy); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.error .bubble { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.msg .att { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 6px; }
.msg .att .thumb { width: 96px; }
.msg .att .assign { font-size: 0.8rem; }
.msg-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ccard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.ccard.receipt { display: flex; align-items: center; gap: 8px; background: var(--leaf-soft); border-color: transparent; color: var(--leaf-soft-ink); }
.ccard.receipt .txt { flex: 1; font-size: 0.95rem; }
.ccard.receipt.undone { opacity: 0.6; text-decoration: line-through; }
.ccard.plant { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; }
.ccard.plant img, .ccard.plant .ph { width: 56px; height: 56px; border-radius: var(--r-sm); object-fit: cover; background: var(--leaf-soft); flex: none; }
.ccard .opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ccard table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.ccard td, .ccard th { text-align: left; padding: 4px 6px 4px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
.composer-wrap { position: sticky; bottom: var(--tab-h); background: var(--bg); padding: 8px 0; border-top: 1px solid var(--line); z-index: 5; }
body.keyboard-open .tabbar { display: none; }
body.keyboard-open .composer-wrap { bottom: 0; }
.composer { display: flex; gap: 6px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 160px; flex: 1; padding: 10px 12px; border-radius: 22px; resize: none; }
.composer .icon-btn { background: var(--surface); border: 1px solid var(--line-strong); flex: none; }
.composer .send { background: var(--leaf); color: var(--leaf-ink); border-color: var(--leaf); }
.composer .send[disabled] { opacity: 0.4; }
.ai-status { font-size: 0.85rem; color: var(--ink-2); padding: 0 4px 6px; }
.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.starter { display: flex; flex-wrap: wrap; gap: 6px; }

/* ------------------------------------------------------------- Lists -- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rows > li:last-child { border-bottom: 0; }
.rows .grow { flex: 1; min-width: 0; }
.rows .grow p { margin: 2px 0 0; font-size: 0.92rem; color: var(--ink-2); }
.kv { font-size: 0.9rem; color: var(--ink-2); }
.kv b { color: var(--ink); font-weight: 500; }
table.recipe { width: 100%; border-collapse: collapse; }
table.recipe th, table.recipe td { text-align: left; padding: 8px 6px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 0.95rem; }
table.recipe th { font-weight: 500; color: var(--ink-2); font-size: 0.85rem; }
.comp-row { display: grid; grid-template-columns: 1fr 72px 44px; gap: 6px; align-items: end; margin-bottom: 6px; }
.comp-row .reason { grid-column: 1 / -1; }

/* ---------------------------------------------------------- NFC/share -- */
.status-ladder { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0; padding: 0; list-style: none; }
.status-ladder li { font-size: 0.82rem; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line); }
.status-ladder li.on { background: var(--leaf-soft); color: var(--leaf-soft-ink); border-color: transparent; font-weight: 500; }
.urlbox { display: flex; gap: 6px; }
.urlbox input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
ol.steps { padding-left: 20px; }
ol.steps li { margin-bottom: 6px; }
.label-preview { display: flex; justify-content: center; padding: 16px; background: var(--surface-2); border-radius: var(--r); }

/* --------------------------------------------------- Public care page -- */
body.public { background: var(--bg); }
.public-top { display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; max-width: 680px; margin: 0 auto; }
.public-top img { width: 32px; height: 32px; }
.public-top span { font-weight: 700; font-size: 0.95rem; }
.public-top span em { font-style: normal; color: var(--brick); }
.public main { max-width: 680px; padding-bottom: 40px; }
.public .hero-img { width: 100%; border-radius: var(--r); aspect-ratio: 4 / 3; object-fit: cover; background: var(--leaf-soft); margin-bottom: 16px; }
.public h1 { font-size: 1.9rem; margin-bottom: 4px; }
.public .idline { color: var(--ink-2); margin-bottom: 16px; }
.care-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 12px; }
.care-sec h2 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.care-sec h2 svg { width: 22px; height: 22px; color: var(--leaf); }
.care-sec p { white-space: pre-wrap; margin: 0; }
.care-sec.recorded { background: var(--leaf-soft); border-color: transparent; }
.care-sec.recorded h2 svg { color: var(--leaf-soft-ink); }
.public .gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.public .gallery figure { margin: 0; }
.public .gallery img { border-radius: var(--r-sm); aspect-ratio: 1; object-fit: cover; width: 100%; }
.public .gallery figcaption { font-size: 0.82rem; color: var(--ink-2); }

/* ------------------------------------------------------------ Toasts -- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 16px); z-index: 50; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); max-width: calc(100% - 32px); font-size: 0.95rem; display: flex; gap: 12px; align-items: center; }
.toast button { background: none; border: 0; color: inherit; font: inherit; text-decoration: underline; min-height: 36px; cursor: pointer; }

/* ------------------------------------------------------------- Print -- */
@media print {
  .topbar, .tabbar, .no-print, .site-foot { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
}

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

/* ---------------------------------------------------------- Utilities -- */
.narrow { max-width: 460px; margin: 24px auto; }
.mt { margin-top: 12px; }
.mt-sm { margin-top: 6px; }
.my-sm { margin: 4px 0; }
.mb { margin-bottom: 8px; }
.label-thumb { border-radius: 8px; object-fit: cover; flex: none; }
details.card summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
code { font-size: 0.9em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; overflow-wrap: anywhere; }
.lightbox-img { width: 100%; max-height: 60dvh; object-fit: contain; background: #000; border-radius: var(--r-sm); }
.starter { justify-content: center; }
.starter .chip { white-space: normal; flex: 0 1 auto; max-width: 100%; text-align: left; padding: 8px 14px; line-height: 1.3; }
.card h2 > svg, .card-head h2 > svg { width: 22px; height: 22px; vertical-align: -4px; margin-right: 4px; color: var(--leaf); }

/* ------------------------------------------------------- Chat dock -- */
/* Phone: the chat is the Chat tab, full width, in the page's own scroll
 * (the most reliable layout with the iOS keyboard). Other pages hide it. */
.chat-dock { display: none; }
.m-only { display: inline; }
.d-only { display: none; }
.dock-head { display: none; align-items: center; gap: 8px; padding: 12px 4px 8px; border-bottom: 1px solid var(--line); }
.dock-head h2 { margin: 0; font-size: 1rem; display: flex; align-items: center; gap: 6px; }
.dock-head h2 svg { width: 20px; height: 20px; color: var(--leaf); }
.dock-context { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-size: 0.82rem; background: var(--leaf-soft); color: var(--leaf-soft-ink); border-radius: 999px; padding: 2px 4px 2px 10px; max-width: 60%; }
.dock-context[hidden] { display: none; }
.chip-x { border: 0; background: none; color: inherit; font-size: 18px; line-height: 1; min-width: 32px; min-height: 32px; cursor: pointer; border-radius: 999px; position: relative; }
.chip-x::after { content: ''; position: absolute; inset: -6px; }
body.chat-page main { display: none; }
body.chat-page .chat-dock {
  display: flex; flex-direction: column;
  min-height: calc(100dvh - var(--top-h));
  max-width: var(--maxw); margin: 0 auto;
  padding: 12px max(16px, env(safe-area-inset-right)) var(--tab-h) max(16px, env(safe-area-inset-left));
}
body.chat-page.keyboard-open .chat-dock { padding-bottom: 0; }

/* Desktop: the chat is a sidebar on every page; the page lives on the right. */
@media (min-width: 1024px) {
  body.has-dock { --dock-w: 380px; }
  .m-only { display: none; }
  .d-only { display: inline; }
  body.has-dock .chat-dock,
  body.chat-page .chat-dock {
    display: flex; flex-direction: column;
    position: fixed; top: var(--top-h); bottom: 0; left: 0;
    width: var(--dock-w); max-width: none; min-height: 0; margin: 0;
    padding: 0 12px;
    background: var(--surface-2); border-right: 1px solid var(--line); z-index: 10;
  }
  .dock-head { display: flex; }
  .chat-dock .chat-log { overflow-y: auto; min-height: 0; padding: 12px 4px; overscroll-behavior: contain; }
  .chat-dock .composer-wrap { position: static; background: transparent; padding: 8px 0 12px; }
  .chat-dock .msg { max-width: 100%; }
  .chat-dock .empty { padding: 16px 4px; }
  body.has-dock main, body.chat-page main { display: block; margin: 0 0 0 var(--dock-w); max-width: none; padding: 24px 32px 48px; }
  body.has-dock .toast { left: calc(50% + var(--dock-w) / 2); }
}
@media (min-width: 1400px) { body.has-dock { --dock-w: 440px; } }
.page-wrap { max-width: 920px; margin: 0 auto; }

/* ------------------------------------------------------------ Care tab -- */
.card h2 > svg { width: 22px; height: 22px; vertical-align: -4px; margin-right: 6px; color: var(--leaf); }
.id-caveat { margin: -4px 0 12px; }
.spot-card { background: var(--leaf-soft); border-color: transparent; }
.spot-card .card-head h2 { color: var(--leaf-soft-ink); }
.spot-now { font-weight: 500; margin: 0; }
.spot-advice { margin: 8px 0 0; color: var(--leaf-soft-ink); }
.recorded { background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.care-lines { margin: 8px 0 0; display: grid; gap: 8px; }
.care-line dt { font-weight: 500; font-size: 0.85rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.care-line dd { margin: 2px 0 0; }
.light-meter { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; max-width: 260px; margin: 4px 0; }
.light-meter span { height: 8px; border-radius: 4px; background: var(--line-strong); }
.light-meter span.on { background: var(--gold); }
.light-level { font-weight: 500; margin: 0 0 8px; }
.placements { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.placements li { display: grid; gap: 2px; padding: 8px 10px; border-radius: var(--r-sm); border: 1px solid var(--line); }
.placements li.mine { border-color: var(--leaf); background: var(--leaf-soft); }
.avoid { color: var(--ink-2); }
.care-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .care-grid { grid-template-columns: 1fr 1fr; } }
.care-grid .card { margin: 0; }
.card.mini h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); }
.card.mini p { margin: 0; }
.guide-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 12px; }
.empty-guide { text-align: left; }

.compass { position: relative; width: 220px; height: 220px; margin: 8px auto; }
.compass svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.compass .dial { transition: transform 0.08s linear; }
.compass .ring { fill: var(--surface); stroke: var(--line-strong); stroke-width: 2; }
.compass .tick { stroke: var(--ink-3); stroke-width: 1; }
.compass .tick.major { stroke: var(--ink); stroke-width: 2; }
.compass text { font: 700 18px var(--font); fill: var(--ink-2); text-anchor: middle; }
.compass .card-n { fill: var(--brick); font-size: 22px; }
.compass .pointer path, .compass .pointer circle { fill: var(--leaf); }
.compass-readout { text-align: center; font-weight: 500; min-height: 1.5em; }
.btn-row.center { justify-content: center; }
.dir-grid { display: grid; grid-template-columns: repeat(3, 64px); gap: 6px; justify-content: center; margin: 8px 0; }
.dir-grid .dir { min-height: 48px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); font: 700 0.95rem var(--font); color: var(--ink); cursor: pointer; }
.dir-grid .dir.on, .dir-grid .dir[aria-pressed='true'] { background: var(--leaf); border-color: var(--leaf); color: var(--leaf-ink); }
.dir-center { display: flex; align-items: center; justify-content: center; font-size: 22px; }
.chip[aria-pressed='true'] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.compass { overflow: hidden; isolation: isolate; border-radius: 50%; }
.sheet-head { z-index: 3; }
.spinner { display: inline-block; width: 18px; height: 18px; margin-right: 8px; vertical-align: -3px; border: 3px solid var(--leaf-soft); border-top-color: var(--leaf); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------- Chat controls, add-plants bar -- */
body.chat-page .dock-head { display: flex; }
.dock-head { gap: 4px; }
.dock-head .spacer { flex: 1; }
.dock-head h2 span { white-space: nowrap; }
.dock-sub { padding: 0 4px; }
.dock-sub .dock-context { margin: 6px 0 0; max-width: 100%; }
.meter { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 6px; border: 0; background: none; color: var(--ink-2); font: 500 0.8rem var(--font); cursor: pointer; border-radius: var(--r-sm); }
.meter:hover { background: var(--line); }
.meter-bar { display: inline-block; width: 44px; height: 6px; border-radius: 3px; background: var(--line-strong); overflow: hidden; }
.meter-bar > span { display: block; height: 100%; width: 0; background: var(--leaf); }
.meter-bar.hot > span { background: var(--brick); }
.meter-bar.big { width: 100%; height: 10px; border-radius: 5px; margin: 4px 0 8px; }
.usage-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.usage-row .k { color: var(--ink-2); }
.usage-row .tiny { grid-column: 1 / -1; }
#usage-body h3 { margin: 16px 0 4px; }
.history-item { justify-content: space-between; text-align: left; white-space: normal; height: auto; padding: 10px 12px; gap: 12px; }
.history-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.history-item.current { border-color: var(--leaf); }
.mode-row { display: flex; gap: 6px; margin-bottom: 6px; }
.add-bar { background: var(--leaf-soft); border-radius: var(--r); padding: 10px 12px; margin-bottom: 8px; }
.add-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.add-row label { margin: 0; color: var(--leaf-soft-ink); }
.add-row input { flex: 1; min-width: 0; }
.add-bar .snap { min-height: 52px; font-size: 1.05rem; }
.add-bar .tiny { margin: 6px 0 0; color: var(--leaf-soft-ink); }
#add-mode[aria-pressed='true'] { background: var(--leaf); border-color: var(--leaf); color: var(--leaf-ink); }
@media (max-width: 380px) { #chat-new { padding: 0 10px; } #chat-new svg { display: none; } }
@media (max-width: 360px) { .dock-head h2 span { display: none; } .meter { padding: 0 2px; } .meter-bar { width: 32px; } }
