:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --border: #e2dccf;
  --border-strong: #c8c0ad;
  --ink: #2a2520;
  --ink-soft: #6b6457;
  --ink-mute: #a39a87;
  --moss: #1f3a2e;
  --moss-soft: #4a6b5a;
  --moss-bg: #e8efe9;
  --clay: #b04f2e;
  --clay-bg: #f5e8df;
  --amber: #b07a1f;
  --amber-bg: #f5ecd8;
  --ripe: #a02828;
  --ripe-bg: #f5dfdf;
  --stone-bg: #efece4;
  --shadow: 0 1px 0 rgba(0,0,0,0.03), 0 1px 3px rgba(0,0,0,0.05);
  --serif: ui-serif, Georgia, 'Times New Roman', serif;
  --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tap: 44px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.boot {
  padding: 4rem 1rem;
  text-align: center;
  color: var(--ink-mute);
}

/* Header */
.header {
  padding: 1.75rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.header-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: none;
  padding: 0.5rem 0 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--moss);
  font-size: 0.875rem;
  font-family: var(--sans);
  cursor: pointer;
  min-height: var(--tap);
}
.eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--moss);
  font-weight: 500;
  margin-bottom: 0.4rem;
}
h1.title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2rem;
  letter-spacing: -0.015em;
  margin: 0;
  line-height: 1.1;
}
h2.section {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.25rem;
  margin: 0 0 0.75rem;
}
.subtitle {
  color: var(--ink-soft);
  font-size: 0.875rem;
  margin-top: 0.4rem;
}
.stats {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
  font-size: 0.875rem;
  color: var(--ink-soft);
}
.stat-num { color: var(--ink); font-weight: 600; }
.stat-alert { color: var(--clay); }

/* Body container */
.main {
  padding: 1.25rem;
}
.main > * + * { margin-top: 0.75rem; }

/* Section eyebrow inside main */
.section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-mute);
  font-weight: 500;
  margin: 1.25rem 0 0.5rem;
}
.section-label:first-child { margin-top: 0; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  display: block;
  transition: border-color 0.15s, transform 0.05s;
}
.card:hover { border-color: var(--moss); }
.card:active { transform: scale(0.995); }

.card-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.card-grow { flex: 1; min-width: 0; }
.card-title {
  font-family: var(--serif);
  font-size: 1.125rem;
  font-weight: 500;
  margin: 0;
}
.card-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.card-meta-row {
  display: flex;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
}
.card-num {
  text-align: right;
  font-size: 0.75rem;
  color: var(--ink-mute);
  flex-shrink: 0;
}
.card-num .big {
  display: block;
  font-family: var(--serif);
  font-size: 1.6rem;
  color: var(--ink);
  line-height: 1;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 2.5rem 1.25rem;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  color: var(--ink-soft);
}
.empty .ic {
  width: 36px;
  height: 36px;
  margin: 0 auto 0.5rem;
  color: var(--moss);
}
.empty p { margin: 0.25rem 0; }
.empty .hint { font-size: 0.875rem; color: var(--ink-mute); }

/* Add button (dashed full-width) */
.btn-add {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 1rem;
  border: 2px dashed var(--border-strong);
  background: transparent;
  border-radius: 10px;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: var(--tap);
}
.btn-add:hover { border-color: var(--moss); color: var(--moss); }

/* Primary / Secondary / Danger buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: var(--tap);
  text-decoration: none;
}
.btn-primary {
  background: var(--moss);
  color: white;
  border-color: var(--moss);
}
.btn-primary:disabled {
  background: var(--ink-mute);
  border-color: var(--ink-mute);
  cursor: not-allowed;
}
.btn-danger {
  color: var(--ripe);
  border-color: var(--ripe-bg);
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--moss);
}
.btn-row {
  display: flex;
  gap: 0.5rem;
}
.btn-row .btn { flex: 1; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; min-height: 36px; }

/* Form */
.form {
  background: var(--surface);
  border: 1px solid var(--moss);
  border-radius: 10px;
  padding: 1rem;
}
.form > * + * { margin-top: 0.75rem; }
.field-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  font-weight: 500;
  margin-bottom: 0.35rem;
}
.input, .textarea, .select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.7rem 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
  min-height: var(--tap);
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--moss);
  background: var(--surface);
}
.textarea { min-height: 5rem; resize: vertical; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b6457' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
  min-height: 36px;
}
.chip.active {
  background: var(--moss);
  color: white;
  border-color: var(--moss);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* Autocomplete suggestions */
.suggest-wrap { position: relative; }
.suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  max-height: 16rem;
  overflow-y: auto;
  z-index: 10;
  box-shadow: var(--shadow);
}
.suggest-item {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 0.65rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--ink);
}
.suggest-item:hover { background: var(--moss-bg); }
.suggest-item .days { color: var(--ink-mute); font-size: 0.8rem; }

/* Plant progress ring + status */
.plant-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.ring { flex-shrink: 0; transform: rotate(-90deg); }
.ring-bg { stroke: var(--border); fill: none; stroke-width: 4; }
.ring-fg { fill: none; stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset 0.5s; }
.ring-fg.tone-stone { stroke: var(--ink-mute); }
.ring-fg.tone-moss { stroke: var(--moss); }
.ring-fg.tone-amber { stroke: var(--amber); }
.ring-fg.tone-clay { stroke: var(--clay); }
.ring-fg.tone-ripe { stroke: var(--ripe); }

.stage { font-weight: 500; font-size: 0.95rem; }
.stage.tone-stone { color: var(--ink-soft); }
.stage.tone-moss { color: var(--moss); }
.stage.tone-amber { color: var(--amber); }
.stage.tone-clay { color: var(--clay); }
.stage.tone-ripe { color: var(--ripe); }

/* Harvest forecast panel */
.harvest-panel {
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid var(--border);
}
.harvest-panel.tone-stone { background: var(--stone-bg); }
.harvest-panel.tone-moss { background: var(--moss-bg); }
.harvest-panel.tone-amber { background: var(--amber-bg); }
.harvest-panel.tone-clay { background: var(--clay-bg); }
.harvest-panel.tone-ripe { background: var(--ripe-bg); }

.harvest-stage {
  font-family: var(--serif);
  font-size: 1.75rem;
  margin: 0.2rem 0 0.75rem;
  line-height: 1.1;
}
.harvest-stage.tone-stone { color: var(--ink-soft); }
.harvest-stage.tone-moss { color: var(--moss); }
.harvest-stage.tone-amber { color: var(--amber); }
.harvest-stage.tone-clay { color: var(--clay); }
.harvest-stage.tone-ripe { color: var(--ripe); }

.harvest-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--ink-soft);
  padding: 0.15rem 0;
}
.harvest-row span:last-child { color: var(--ink); }
.harvest-tip {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-strong);
  font-size: 0.875rem;
}

/* Weather card */
.weather-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}
.weather-strip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}
.weather-strip::-webkit-scrollbar { display: none; }
.weather-day {
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem;
  text-align: center;
  min-width: 76px;
}
.weather-day-name { font-size: 0.7rem; color: var(--ink-mute); text-transform: uppercase; letter-spacing: 0.08em; }
.weather-day-icon { font-size: 1.4rem; line-height: 1.5; }
.weather-day-temp { font-size: 0.85rem; color: var(--ink); }
.weather-day-rain { font-size: 0.7rem; color: var(--moss-soft); margin-top: 0.15rem; }
.weather-banner {
  margin-top: 0.85rem;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  background: var(--moss-bg);
  color: var(--moss);
  border-left: 3px solid var(--moss);
}
.weather-banner.frost { background: #e8eef5; color: #2b4a6b; border-left-color: #2b4a6b; }
.weather-banner.heat { background: var(--clay-bg); color: var(--clay); border-left-color: var(--clay); }
.weather-banner.dry { background: var(--amber-bg); color: var(--amber); border-left-color: var(--amber); }

/* Photo grid */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.photo-tile {
  aspect-ratio: 1;
  background: var(--stone-bg);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  border: none;
  padding: 0;
  cursor: pointer;
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.65), transparent);
  color: white;
  font-size: 0.65rem;
  padding: 0.4rem 0.45rem 0.3rem;
  text-align: left;
}

/* Photo viewer */
.viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.viewer img { max-width: 100%; max-height: 75vh; border-radius: 6px; }
.viewer-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
}
.viewer-info {
  position: absolute;
  bottom: 2rem;
  left: 0; right: 0;
  text-align: center;
  color: white;
}

/* Tag/pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}
.pill-sun { background: var(--amber-bg); color: var(--amber); }
.pill-warn { background: var(--clay-bg); color: var(--clay); }
.pill-info { background: var(--moss-bg); color: var(--moss); }

/* Bottom tab bar */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  width: 100%;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  padding: 0.6rem 0.25rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  color: var(--ink-mute);
  font-family: inherit;
  font-size: 0.7rem;
  cursor: pointer;
  min-height: 56px;
}
.tab.active { color: var(--moss); }
.tab svg { width: 22px; height: 22px; }

/* Task / harvest entry */
.entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  display: flex;
  gap: 0.85rem;
  align-items: center;
}
.entry-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  background: var(--moss-bg);
  color: var(--moss);
}
.entry-mark.water { background: #e3edf5; color: #2b5780; }
.entry-mark.prune { background: var(--moss-bg); color: var(--moss); }
.entry-mark.fert { background: var(--amber-bg); color: var(--amber); }
.entry-mark.treat { background: var(--clay-bg); color: var(--clay); }
.entry-mark.harvest { background: var(--ripe-bg); color: var(--ripe); }
.entry-body { flex: 1; min-width: 0; }
.entry-title { font-weight: 500; color: var(--ink); }
.entry-meta { font-size: 0.8rem; color: var(--ink-soft); }
.entry-del {
  background: none;
  border: none;
  color: var(--ink-mute);
  padding: 0.5rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* Companion check banner */
.companion-warn {
  background: var(--clay-bg);
  border: 1px solid var(--clay);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  color: var(--clay);
}
.companion-good {
  background: var(--moss-bg);
  border: 1px solid var(--moss);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  color: var(--moss);
}
.companion-warn ul, .companion-good ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

/* Season switcher in header */
.season-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--moss-bg);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  color: var(--moss);
  font-size: 0.8rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  margin-top: 0.85rem;
}

/* Inline icons */
.ic-inline {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
}

/* Notes display */
.notes-text {
  white-space: pre-wrap;
  color: var(--ink);
  min-height: 1.5rem;
}
.notes-text.empty { color: var(--ink-mute); font-style: italic; }

/* Modal */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal {
  background: var(--surface);
  width: 100%;
  max-width: 640px;
  border-radius: 14px 14px 0 0;
  padding: 1.25rem;
  max-height: 80vh;
  overflow-y: auto;
}
.modal h3 {
  font-family: var(--serif);
  margin: 0 0 0.85rem;
  font-weight: 500;
  font-size: 1.25rem;
}

/* Inline edit field */
.title-edit {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 500;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-strong);
  padding: 0 0 0.2rem;
  width: 100%;
  color: var(--ink);
}
.title-edit:focus { outline: none; border-bottom-color: var(--moss); }

/* Yield big number */
.yield-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
}
.yield-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
}
.yield-tile .name { font-size: 0.8rem; color: var(--ink-soft); }
.yield-tile .amount {
  font-family: var(--serif);
  font-size: 1.4rem;
  color: var(--ink);
  margin-top: 0.15rem;
}
.yield-tile .unit { font-size: 0.75rem; color: var(--ink-mute); }
