:root {
  --bg: #f7f1e3;
  --paper: #fbf6ea;
  --ink: #2b2620;
  --muted: #6b5e44;
  --leaf: #4a6a3a;
  --leaf-dark: #2f4a25;
  --accent: #b34a3a;
  --border: #d6c9a8;
  --shadow: 0 2px 10px rgba(60, 48, 20, 0.10);
  --tap: rgba(74, 106, 58, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 60px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: var(--tap); }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  overflow-x: hidden;
}
a { color: var(--leaf-dark); text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3 { font-family: Georgia, 'Iowan Old Style', serif; }

/* ---------- App bar (sticky top) ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
  box-shadow: var(--shadow);
}
.appbar-inner {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.7rem 1rem 0.4rem;
}
.brand {
  font-family: 'Brush Script MT', 'Snell Roundhand', cursive;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--leaf-dark);
  line-height: 1;
}
.brand-sub { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- Category chips (horizontal scroll) ---------- */
.chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0 1rem 0.7rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.95rem;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  scroll-snap-align: start;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.chip.is-active {
  background: var(--leaf-dark);
  color: #fff;
  border-color: var(--leaf-dark);
}

/* ---------- Main ---------- */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.9rem 1rem calc(var(--tabbar-h) + var(--safe-bottom) + 1.5rem);
}

.hero-card {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.hero-card img {
  display: block;
  width: 100%;
  height: 200px;
  object-fit: cover;
  object-position: 50% 8%;
}
.hero-card p {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  margin: 0;
  padding: 1.6rem 0.9rem 0.6rem;
  color: #fff;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  background: linear-gradient(transparent, rgba(20, 24, 14, 0.7));
}

/* ---------- Card grid: 2-up phone → more on wider ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 90ms ease;
}
.card:active { transform: scale(0.975); }
.card-img { aspect-ratio: 1 / 1; background: var(--bg); }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { padding: 0.6rem 0.75rem 0.8rem; }
.card-body h3 {
  margin: 0 0 0.15rem;
  font-size: 0.98rem;
  line-height: 1.2;
  color: var(--leaf-dark);
}
.card-meta { margin: 0; font-size: 0.76rem; color: var(--muted); }
.card-days { margin: 0.3rem 0 0; font-size: 0.78rem; color: var(--leaf); }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* ---------- List view ---------- */
.list { display: flex; flex-direction: column; gap: 0.5rem; }
.list-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem 0.7rem;
  color: inherit;
  box-shadow: var(--shadow);
  min-height: 60px;
}
.list-row:active { background: #f1e8ce; }
.list-row img { width: 52px; height: 52px; border-radius: 9px; object-fit: cover; flex: 0 0 auto; }
.list-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.list-name { font-weight: 600; color: var(--leaf-dark); }
.list-sci { font-size: 0.78rem; color: var(--muted); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-days { font-size: 0.78rem; color: var(--leaf); flex: 0 0 auto; text-align: right; }
.list-chevron { color: var(--border); font-size: 1.4rem; flex: 0 0 auto; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--paper);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 10px rgba(60, 48, 20, 0.08);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--tabbar-h);
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  cursor: pointer;
}
.tab svg { width: 24px; height: 24px; fill: currentColor; }
.tab.is-active { color: var(--leaf-dark); }

/* ---------- Detail page ---------- */
.appbar-detail .appbar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.6rem;
  min-height: 48px;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--leaf-dark);
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
}
.back-btn svg { width: 22px; height: 22px; }
.back-btn:active { background: var(--tap); }
.appbar-title {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail { padding-top: 0.4rem; }
.hero-img-wrap {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--paper);
}
.plant-hero { display: block; width: 100%; height: auto; }
.detail-head { padding: 1rem 0.2rem 0.2rem; }
.cat-tag {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #fff;
  background: var(--leaf);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.detail-head h1 {
  margin: 0.5rem 0 0.2rem;
  font-size: 1.7rem;
  color: var(--leaf-dark);
  line-height: 1.15;
}
.subtitle { margin: 0; color: var(--muted); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin: 1rem 0 0.5rem;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
}
.stat-ico { font-size: 1.1rem; }
.stat-k { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat-v { font-size: 0.88rem; color: var(--ink); font-weight: 500; }

.prose { margin: 1.4rem 0.2rem; }
.prose h2 {
  font-size: 1.1rem;
  color: var(--leaf-dark);
  margin: 0 0 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px dashed var(--border);
}
.prose p { margin: 0; }

.rel-row { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 0.2rem; }
.rel-chip {
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--leaf-dark);
}
.rel-chip:active { background: #f1e8ce; }

.prevnext {
  display: flex;
  gap: 0.6rem;
  margin: 1.8rem 0.2rem 0;
}
.pn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 0.7rem;
  min-height: 56px;
  color: inherit;
}
.pn-empty { background: none; border: none; box-shadow: none; }
.pn-next { justify-content: flex-end; text-align: right; }
.pn-arrow { font-size: 1.5rem; color: var(--leaf); line-height: 1; }
.pn-text { display: flex; flex-direction: column; min-width: 0; }
.pn-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.pn-name { font-weight: 600; color: var(--leaf-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (hover: hover) {
  .card { transition: transform 120ms ease, box-shadow 120ms ease; }
  .card:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(60,48,20,0.14); }
  .chip:hover { border-color: var(--leaf); }
}

/* ---------- Wider screens: roomier grid, centered detail ---------- */
@media (min-width: 560px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .hero-card img { height: 260px; }
}
@media (min-width: 860px) {
  .card-grid { grid-template-columns: repeat(4, 1fr); }
  .detail { max-width: 720px; margin-left: auto; margin-right: auto; }
  .stat-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 1100px) {
  .card-grid { grid-template-columns: repeat(5, 1fr); }
}

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