:root {
  --bg: #f6f8f4;
  --surface: #ffffff;
  --surface-2: #eef1ea;
  --border: #dde3d5;
  --text: #1a2016;
  --text-dim: #5b6552;
  --accent: #2f7d3e;
  --accent-strong: #22662f;
  --water: #2563eb;
  --skip: #6b7280;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12160f;
    --surface: #1a1f16;
    --surface-2: #232a1e;
    --border: #2c3426;
    --text: #e8ecdf;
    --text-dim: #98a08a;
    --accent: #5cb26a;
    --accent-strong: #7dc98a;
    --water: #60a5fa;
    --skip: #9ca3af;
    --warn: #fbbf24;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 96px;
}

header.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
header.topbar h1 {
  font-size: 18px; margin: 0; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
header.topbar .who {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-dim);
}
header.topbar .who img { width: 28px; height: 28px; border-radius: 50%; }

main { max-width: 720px; margin: 0 auto; padding: 16px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin: 24px 0 8px; }
h2:first-child { margin-top: 8px; }

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card.tap {
  cursor: pointer; display: block; color: inherit;
}
.card.tap:hover { border-color: var(--accent); text-decoration: none; }

.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
  font-size: 12px; font-weight: 500;
}
.pill.water { background: var(--water); color: white; }
.pill.skip { background: var(--surface-2); color: var(--text-dim); }
.pill.overdue { background: var(--warn); color: #1a1a1a; }
.pill.healthy { background: var(--accent); color: white; }
.pill.concerning { background: var(--warn); color: #1a1a1a; }
.pill.sick { background: var(--danger); color: white; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px;
  border: none; border-radius: var(--radius);
  background: var(--accent); color: white;
  font-size: 16px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background 0.1s;
}
button:hover, .btn:hover { background: var(--accent-strong); text-decoration: none; }
button:disabled, .btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary, .btn.secondary {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
}
button.secondary:hover, .btn.secondary:hover { background: var(--surface-2); }
button.danger, .btn.danger { background: var(--danger); color: white; }
button.full, .btn.full { width: 100%; }

input, select, textarea {
  width: 100%; padding: 12px 14px; min-height: 48px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 16px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.plant-photo {
  width: 56px; height: 56px; border-radius: 12px; object-fit: cover;
  background: var(--surface-2); flex-shrink: 0;
}
.plant-photo.big {
  width: 100%; height: 240px; border-radius: var(--radius); margin-bottom: 16px;
}

.action-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: center;
  z-index: 20;
}
.action-bar > * { flex: 1; max-width: 240px; }

.verdict {
  padding: 20px; border-radius: var(--radius); text-align: center;
  font-size: 20px; font-weight: 700;
}
.verdict.water { background: var(--water); color: white; }
.verdict.skip { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.verdict.unknown { background: var(--warn); color: #1a1a1a; }
.verdict .reasoning { font-size: 14px; font-weight: 400; margin-top: 8px; opacity: 0.9; }

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 16px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 36px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  font-family: inherit;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.chip .count {
  background: rgba(0,0,0,0.12);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.chip[aria-pressed="true"] .count { background: rgba(255,255,255,0.25); }

.suggest-wrap { position: relative; }
.suggest-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow-y: auto;
  z-index: 30;
  display: none;
}
.suggest-list[data-open="1"] { display: block; }
.suggest-item {
  padding: 12px 14px;
  cursor: pointer;
  font-size: 16px;
  border-bottom: 1px solid var(--border);
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item[aria-selected="true"], .suggest-item:hover { background: var(--surface-2); }

details.location-group { margin-bottom: 8px; }
details.location-group > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 4px;
  margin: 16px 0 4px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
details.location-group > summary::-webkit-details-marker { display: none; }
details.location-group > summary::before {
  content: '▸';
  display: inline-block;
  transition: transform 0.15s;
  font-size: 12px;
  color: var(--text-dim);
}
details.location-group[open] > summary::before { transform: rotate(90deg); }
details.location-group > summary .count {
  margin-left: auto;
  background: var(--surface-2);
  color: var(--text-dim);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}

.empty {
  text-align: center; padding: 48px 16px; color: var(--text-dim);
}
.empty p { margin: 8px 0; }
.empty .leaf { font-size: 40px; margin-bottom: 12px; }

.error { color: var(--danger); font-size: 14px; margin-top: 8px; }
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
