:root {
  --bg: #f3f7ef;
  --card: #ffffff;
  --ink: #1d2a20;
  --muted: #66756a;
  --line: #dfe8d9;
  --green: #2f7d4f;
  --green-soft: #e2f1e6;
  --blue: #2c6fb7;
  --blue-soft: #e3eefa;
  --amber: #b06d00;
  --amber-soft: #fdf0d9;
  --red: #b23b3b;
  --red-soft: #fbe5e5;
  --shadow: 0 1px 2px rgba(30, 50, 35, .06), 0 4px 14px rgba(30, 50, 35, .06);
  --radius: 18px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a14;
    --card: #1b261e;
    --ink: #e8f0e9;
    --muted: #93a597;
    --line: #2a3a2e;
    --green: #6cc48f;
    --green-soft: #1f3a29;
    --blue: #7fb2ec;
    --blue-soft: #1c2c40;
    --amber: #f0b552;
    --amber-soft: #3a2e17;
    --red: #ef8a8a;
    --red-soft: #3d2222;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 96px);
}

h1 { font-size: 28px; line-height: 1.15; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 28px 0 10px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* Tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center; gap: 2px;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabs button {
  flex: 1; max-width: 130px; border: 0; background: none; padding: 6px 0;
  font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px;
  border-radius: 12px;
}
.tabs button span { font-size: 22px; line-height: 1; filter: grayscale(.6); }
.tabs button.active { color: var(--green); font-weight: 600; }
.tabs button.active span { filter: none; }

/* Header */
.hello { margin-bottom: 18px; }
.hello .date { color: var(--muted); font-size: 15px; text-transform: lowercase; }
.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.icon-btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 50%;
  width: 40px; height: 40px; font-size: 18px; flex: none;
}

/* Progress */
.progress { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.progress .bar { height: 10px; background: var(--green-soft); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress .bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width .4s ease; }

/* Task card */
.task {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
}
.task-top { display: flex; gap: 12px; align-items: center; }
.ava {
  width: 56px; height: 56px; border-radius: 16px; flex: none;
  display: grid; place-items: center; font-size: 30px; background: var(--green-soft);
  overflow: hidden; border: 0; padding: 0;
}
.ava img { width: 100%; height: 100%; object-fit: cover; }
.task-name { font-weight: 700; font-size: 17px; }
.task-sub { color: var(--muted); font-size: 14px; }
.quip { font-size: 15px; margin: 10px 0 0; padding: 10px 12px; background: var(--bg); border-radius: 12px; }
.quip::before { content: "💬 "; }
.question { font-weight: 600; margin: 12px 0 8px; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  border: 0; border-radius: 14px; padding: 13px 10px; font-weight: 600; font-size: 15px;
  background: var(--bg); color: var(--ink); min-height: 48px;
}
.btn.water { background: var(--blue-soft); color: var(--blue); }
.btn.ok { background: var(--green-soft); color: var(--green); }
.btn.primary { background: var(--green); color: #fff; }
.btn.ghost { background: none; color: var(--muted); font-weight: 500; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.wide { width: 100%; }
.later { display: block; margin: 6px auto 0; border: 0; background: none; color: var(--muted); font-size: 14px; padding: 6px 10px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 8px; }

.task.bonus { border: 1px dashed var(--line); box-shadow: none; background: transparent; }
.task.done-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; box-shadow: none; background: transparent; border: 1px solid var(--line); margin-bottom: 8px; }
.done-row .ava { width: 36px; height: 36px; font-size: 20px; border-radius: 10px; }

.more {
  width: 100%; border: 1px dashed var(--line); background: none; border-radius: var(--radius);
  padding: 14px; color: var(--muted); margin-bottom: 12px;
}

.celebrate {
  text-align: center; padding: 28px 16px; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.celebrate .big { font-size: 56px; line-height: 1; margin-bottom: 8px; }

/* Plants grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pcard {
  background: var(--card); border: 0; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px; text-align: left; display: flex; flex-direction: column; gap: 6px;
}
.pcard .pic {
  aspect-ratio: 1; border-radius: 12px; background: var(--green-soft);
  display: grid; place-items: center; font-size: 48px; overflow: hidden; position: relative;
}
.pcard .pic img { width: 100%; height: 100%; object-fit: cover; }
.pcard .mood { position: absolute; right: 6px; bottom: 6px; font-size: 22px; background: var(--card); border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; }
.pcard b { font-size: 15px; line-height: 1.2; }
.pcard small { color: var(--muted); font-size: 12px; line-height: 1.25; }
.group-title { font-size: 14px; color: var(--muted); font-weight: 600; margin: 20px 0 8px; text-transform: uppercase; letter-spacing: .04em; }

/* Sheet */
dialog {
  border: 0; padding: 0; width: 100%; max-width: 560px; max-height: 92dvh;
  margin: auto auto 0; border-radius: 22px 22px 0 0; background: var(--bg); color: var(--ink);
}
dialog::backdrop { background: rgba(10, 20, 12, .45); }
#sheet-body { padding: 18px 16px calc(env(safe-area-inset-bottom) + 24px); }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet-head .ava { width: 72px; height: 72px; font-size: 40px; border-radius: 20px; }
.close { margin-left: auto; align-self: flex-start; }
.info { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.info b { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--card);
  font-size: 16px;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 8px 12px; font-size: 14px;
}
.chip.on { background: var(--green); color: #fff; border-color: var(--green); }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 20px; }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--green); }
.history { font-size: 14px; color: var(--muted); }

/* Light */
.lux-row {
  background: var(--card); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px;
  display: grid; grid-template-columns: 1fr 96px; gap: 4px 10px; align-items: center;
}
.lux-row .nm { font-weight: 600; font-size: 15px; }
.lux-row .need { font-size: 13px; color: var(--muted); }
.lux-row input { grid-row: span 2; text-align: right; padding: 10px; }
.lux-bar { grid-column: 1 / -1; position: relative; height: 8px; background: var(--bg); border-radius: 99px; margin-top: 4px; }
.lux-bar .range { position: absolute; top: 0; bottom: 0; background: var(--green-soft); border-radius: 99px; }
.lux-bar .dot { position: absolute; top: -3px; width: 14px; height: 14px; border-radius: 50%; margin-left: -7px; background: var(--green); border: 2px solid var(--card); }
.lux-bar .dot.low { background: var(--amber); }
.lux-bar .dot.high { background: var(--red); }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.tag.low { background: var(--amber-soft); color: var(--amber); }
.tag.high { background: var(--red-soft); color: var(--red); }
.tag.ok { background: var(--green-soft); color: var(--green); }
.idea { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; border-left: 4px solid var(--amber); }

/* Room */
.room-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.metric .val { font-size: 34px; font-weight: 700; line-height: 1.1; }
.metric .lbl { font-size: 13px; color: var(--muted); }
.metric input { margin-top: 8px; }
.status { border-radius: 14px; padding: 12px 14px; margin-top: 10px; }
.status.ok { background: var(--green-soft); }
.status.warn { background: var(--amber-soft); }
.scenario { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; display: flex; gap: 10px; align-items: flex-start; }
.scenario div { flex: 1; font-size: 15px; }
.scenario button { flex: none; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 6px 10px; font-size: 13px; }

/* Toast + confetti */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 86px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 15px;
  z-index: 20; max-width: calc(100vw - 32px); text-align: center; animation: pop .25s ease;
}
.toast .undo { border: 0; background: none; color: var(--green-soft); font-weight: 700; margin-left: 6px; padding: 0; text-decoration: underline; }
@keyframes pop { from { transform: translate(-50%, 10px); opacity: 0; } }
.confetti { position: fixed; top: -40px; z-index: 30; font-size: 26px; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
  .progress .bar i { transition: none; }
}
