/* My Garden — warm botanical UI, mobile-first */
:root {
  --canvas: #FAF9F6;
  --card: #FFFFFF;
  --sage: #2E5A44;
  --sage-dark: #23473A;
  --sage-soft: #E6EEE9;
  --terracotta: #C86D51;
  --terracotta-soft: #F8E9E3;
  --amber: #D97706;
  --amber-soft: #FDF1DC;
  --amber-text: #92500A;
  --blue-soft: #E4EEF4;
  --blue-text: #2F5A73;
  --ink: #26302B;
  --muted: #6A746E;
  --line: #E7E3DA;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(38, 48, 43, .05), 0 6px 18px rgba(38, 48, 43, .06);
  --tabbar-h: 62px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.sheet-open { overflow: hidden; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(46, 90, 68, .45); outline-offset: 2px; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: rgba(250, 249, 246, .92);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font: 600 1.35rem/1.2 var(--serif); letter-spacing: -.01em; }
.icon-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.icon-btn:active { background: var(--sage-soft); color: var(--sage); }

/* ---------- Layout ---------- */
main {
  max-width: 640px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
  display: flex; flex-direction: column; gap: 14px;
  outline: none;
}
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid rgba(231, 227, 218, .7); padding: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card h2, .section-title { font: 600 1.08rem/1.25 var(--serif); }
.section-title { margin: 6px 2px -4px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }

/* ---------- Buttons ---------- */
.btn {
  min-height: 46px; padding: 0 18px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; background: var(--sage); color: #fff; text-align: center;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.98); background: var(--sage-dark); }
.btn.block { width: 100%; }
.btn.secondary { background: var(--sage-soft); color: var(--sage); }
.btn.ghost { background: transparent; color: var(--sage); border: 1.5px solid var(--sage-soft); }
.btn.accent { background: var(--terracotta); }
.btn.danger { background: transparent; color: #A63A2B; border: 1.5px solid #F0D5CF; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: .9rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.link { color: var(--sage); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }

/* ---------- Forms ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: #fff; color: var(--ink); font-weight: 400; font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
select.input {
  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 d='M1 1.500l5 5 5-5' fill='none' stroke='%236A746E' stroke-width='1.800' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
.input:focus { border-color: var(--sage); outline: none; box-shadow: 0 0 0 3px rgba(46, 90, 68, .14); }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; min-width: 0; }

.switch {
  flex: none; position: relative; width: 52px; height: 32px; border-radius: 999px;
  background: #D9D5CB; transition: background .18s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .18s ease;
}
.switch[aria-checked="true"] { background: var(--sage); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 48px; }
.toggle-row + .toggle-row { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.toggle-row strong { display: block; font-weight: 600; }

.segmented { display: flex; background: #F1EEE7; border-radius: 999px; padding: 4px; gap: 4px; }
.segmented button {
  flex: 1; min-height: 40px; border-radius: 999px; font-weight: 600; font-size: .9rem; color: var(--muted); padding: 0 10px;
}
.segmented button[aria-pressed="true"] { background: #fff; color: var(--sage); box-shadow: 0 1px 3px rgba(38, 48, 43, .14); }

.stepper { display: inline-flex; align-items: center; gap: 4px; background: #F1EEE7; border-radius: 999px; padding: 3px; }
.stepper button { width: 40px; height: 40px; border-radius: 50%; background: #fff; font-size: 1.25rem; font-weight: 600; color: var(--sage); }
.stepper output { min-width: 34px; text-align: center; font-weight: 700; }

/* ---------- Chips & pills ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 4px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 44px; padding: 0 16px; border-radius: 999px; font-weight: 600; font-size: .92rem;
  background: #fff; border: 1.5px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--sage); border-color: var(--sage); color: #fff; }
.chip.accent[aria-pressed="true"] { background: var(--terracotta); border-color: var(--terracotta); }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  font-size: .76rem; font-weight: 700; letter-spacing: .01em; background: #F1EEE7; color: var(--muted); white-space: nowrap;
}
.pill.sage { background: var(--sage-soft); color: var(--sage); }
.pill.terracotta { background: var(--terracotta-soft); color: #9C4A31; }
.pill.amber { background: var(--amber-soft); color: var(--amber-text); }
.pill.blue { background: var(--blue-soft); color: var(--blue-text); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Banners ---------- */
.banner { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid transparent; }
.banner-icon { font-size: 1.4rem; line-height: 1.2; }
.banner h3 { font-size: .98rem; font-weight: 700; margin-bottom: 2px; }
.banner p { font-size: .9rem; }
.banner p + p { margin-top: 4px; }
.banner.frost, .banner.wait, .banner.warn { background: var(--amber-soft); border-color: #F3D9A8; color: #6B3D08; }
.banner.frost h3, .banner.wait h3, .banner.warn h3 { color: var(--amber-text); }
.banner.water { background: var(--blue-soft); border-color: #C9DDE8; color: #24495E; }
.banner.ready, .banner.good { background: var(--sage-soft); border-color: #CADBD1; color: var(--sage-dark); }
.banner.info { background: #F1EEE7; border-color: var(--line); color: var(--muted); }
.banner.tip { background: var(--terracotta-soft); border-color: #EFD2C6; color: #7C3A25; }
.banner .btn { margin-top: 10px; }

/* ---------- Today ---------- */
.hero { display: flex; flex-direction: column; gap: 8px; }
.hero-loc { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hero-loc strong { font: 600 1.15rem/1.2 var(--serif); }
.now { display: flex; align-items: center; gap: 14px; }
.now-icon { font-size: 2.6rem; line-height: 1; }
.now-temp { font: 600 2.9rem/1 var(--serif); letter-spacing: -.02em; }
.now-temp sup { font-size: 1.2rem; vertical-align: top; position: relative; top: .3em; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--canvas); border-radius: var(--radius-sm); padding: 12px; border: 1px solid var(--line); }
.stat .k { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat .v { font: 600 1.6rem/1.15 var(--serif); margin-top: 2px; }
.stat .n { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.stat.bed { background: #F1F6F3; border-color: #D8E6DE; }
.stat.pot { background: #FCF3EF; border-color: #F1DCD3; }
.forecast { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scrollbar-width: none; }
.forecast::-webkit-scrollbar { display: none; }
.fday {
  flex: none; width: 62px; padding: 10px 4px; border-radius: 14px; background: var(--canvas); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .82rem;
}
.fday .d { font-weight: 700; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
.fday .i { font-size: 1.35rem; line-height: 1.2; }
.fday .hi { font-weight: 700; }
.fday .lo { color: var(--muted); }
.fday.frosty { background: var(--amber-soft); border-color: #F3D9A8; }
.fday.frosty .lo { color: var(--amber-text); font-weight: 700; }
.fday .pop { font-size: .7rem; color: var(--blue-text); min-height: 1em; }

/* ---------- Tasks ---------- */
.tasks { display: flex; flex-direction: column; }
.task { display: flex; align-items: flex-start; gap: 6px; padding: 8px 0; }
.task + .task { border-top: 1px solid var(--line); }
.check { flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.check::before {
  content: ""; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #C9C4B8; background: #fff;
  transition: background .15s ease, border-color .15s ease;
}
.check[aria-checked="true"]::before {
  border-color: var(--sage);
  background: var(--sage) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.500l4 4 8-9' fill='none' stroke='%23fff' stroke-width='2.800' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/18px no-repeat;
}
.task-body { flex: 1; min-width: 0; padding: 9px 0 6px; }
.task-body[data-action] { cursor: pointer; }
.task-title { font-weight: 600; line-height: 1.3; }
.task-meta { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.task-notes { font-size: .86rem; color: var(--muted); margin-top: 4px; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.task.done .task-notes { display: none; }
.overdue { color: #A63A2B; font-weight: 700; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.empty { text-align: center; padding: 22px 12px; color: var(--muted); }
.empty .big { font-size: 2.2rem; display: block; margin-bottom: 6px; }

/* ---------- Garden spaces ---------- */
.space-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.space-head h2 { font-size: 1.15rem; }
.crop-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 0; text-align: left;
  border-top: 1px solid var(--line);
}
.crop-emoji {
  flex: none; width: 44px; height: 44px; border-radius: 14px; background: var(--canvas); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
}
.crop-row .name { font-weight: 600; line-height: 1.25; }
.crop-row .sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.chev { flex: none; color: #B9B4A8; font-size: 1.3rem; }
.flag { flex: none; font-size: 1.05rem; }

/* ---------- Library ---------- */
.search { position: relative; }
.search .input { padding-left: 42px; border-radius: 999px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.plant-list { display: flex; flex-direction: column; gap: 10px; }
.plant-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid rgba(231, 227, 218, .7);
}
.plant-card .name { font-weight: 600; }
.plant-card .pills { margin-top: 5px; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head h2 { font-size: 1.2rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-wd { text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-cell {
  min-height: 48px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.cal-num { font-size: .95rem; font-weight: 500; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.cal-cell.today .cal-num { color: var(--terracotta); font-weight: 800; }
.cal-cell.selected { background: var(--sage-soft); }
.cal-cell.selected .cal-num { background: var(--sage); color: #fff; font-weight: 700; }
.cal-dots { display: flex; gap: 3px; height: 6px; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--muted); margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.legend li { display: flex; align-items: center; }

/* ---------- Timeline ---------- */
.timeline { position: relative; }
.tl-item { position: relative; display: flex; gap: 4px; padding: 0 0 14px 0; }
.tl-item::before { content: ""; position: absolute; left: 21px; top: 36px; bottom: -8px; width: 2px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-item .check { position: relative; z-index: 1; }
.tl-body { flex: 1; min-width: 0; padding-top: 9px; }
.tl-date { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.tl-title { font-weight: 600; margin-top: 1px; }
.tl-notes { font-size: .86rem; color: var(--muted); margin-top: 3px; }
.tl-item.done .tl-title { text-decoration: line-through; color: var(--muted); }

/* ---------- Detail blocks ---------- */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fact { background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.fact .k { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fact .v { font-weight: 600; margin-top: 2px; }
.rel { display: flex; gap: 10px; padding: 10px 0; }
.rel + .rel { border-top: 1px solid var(--line); }
.rel .name { font-weight: 600; }
.rel .why { font-size: .86rem; color: var(--muted); }
details.fold { border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
details.fold + details.fold { margin-top: 8px; }
details.fold summary {
  min-height: 48px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; font-weight: 600; cursor: pointer; list-style: none;
}
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::after { content: "＋"; color: var(--muted); }
details.fold[open] summary::after { content: "－"; }
details.fold .fold-body { padding: 0 14px 12px; }
.feed { padding: 10px 0; }
.feed + .feed { border-top: 1px solid var(--line); }
.feed .when { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--terracotta); }
.feed .what { font-weight: 600; margin-top: 2px; }
.feed .how { font-size: .86rem; color: var(--muted); margin-top: 2px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 4px 6px calc(env(safe-area-inset-bottom) + 4px);
  background: rgba(255, 255, 255, .96);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: #8A938D; font-size: .7rem; font-weight: 600; border-radius: 14px;
}
.tab svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--sage); }
.tab[aria-current="page"] svg { stroke-width: 2.1; }

/* ---------- Bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(30, 38, 34, .45); animation: fade .2s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; margin: 0 auto; max-width: 640px;
  max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--canvas); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
  animation: rise .26s cubic-bezier(.2, .8, .2, 1);
}
.sheet-head {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 8px 8px 20px; border-bottom: 1px solid var(--line);
}
.sheet-head h2 { font: 600 1.2rem/1.25 var(--serif); }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 16px calc(env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 14px; }
.sheet-foot { flex: none; padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px); border-top: 1px solid var(--line); background: var(--canvas); display: flex; gap: 10px; }
.sheet-foot .btn { flex: 1; }
.plant-hero { display: flex; align-items: center; gap: 14px; }
.plant-hero .crop-emoji { width: 60px; height: 60px; font-size: 2.1rem; border-radius: 18px; background: #fff; }
.label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px); transform: translateX(-50%);
  z-index: 60; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: .92rem; font-weight: 500; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  animation: rise .2s ease;
}
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.500px solid var(--sage-soft); border-top-color: var(--sage); animation: spin .8s linear infinite; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.toast { animation-name: toast-in; }
@keyframes toast-in { from { transform: translate(-50%, 12px); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (min-width: 700px) {
  .sheet { bottom: 24px; border-radius: 24px; max-height: 86vh; }
}
