/* ============================================================
   绿意 · 花卉浇水管家
   ============================================================ */

*,
*::before,
*::after { box-sizing: border-box; }

:root {
  --bg: #f7f8f2;
  --surface: #ffffff;
  --surface-2: #f2f5ec;
  --ink: #1d2a21;
  --muted: #6c7c70;
  --line: #e5eade;

  --green: #3f8f5f;
  --green-deep: #2e6f49;
  --green-soft: #e8f3e9;

  --orange: #cf7a1f;
  --orange-soft: #fdf1df;

  --red: #bf5049;
  --red-soft: #fbeceb;

  --lime: #6d8c26;
  --lime-soft: #f2f7e2;

  --radius: 18px;
  --shadow: 0 1px 2px rgba(28, 45, 33, .05), 0 14px 34px -22px rgba(28, 45, 33, .45);
  --shadow-lift: 0 22px 44px -26px rgba(28, 45, 33, .55);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", "Noto Serif SC", Georgia, serif;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f1411;
  --surface: #18201b;
  --surface-2: #1f2a23;
  --ink: #e9f0e9;
  --muted: #94a598;
  --line: #2a352d;

  --green: #6fbd8d;
  --green-deep: #93d7ac;
  --green-soft: #1d3126;

  --orange: #e6a763;
  --orange-soft: #302619;

  --red: #e18b82;
  --red-soft: #33201f;

  --lime: #b8cb70;
  --lime-soft: #262d1a;

  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 18px 44px -26px rgba(0, 0, 0, .85);
  --shadow-lift: 0 24px 50px -26px rgba(0, 0, 0, .9);

  color-scheme: dark;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(920px 520px at 6% -14%, rgba(63, 143, 95, .12), transparent 62%),
    radial-gradient(760px 430px at 102% -8%, rgba(207, 122, 31, .10), transparent 58%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 24px 54px;
}

/* ---------------- topbar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  font-size: 26px;
  border-radius: 17px;
  background: linear-gradient(155deg, #eaf5e7, #d5e8d8);
  box-shadow: inset 0 0 0 1px rgba(63, 143, 95, .16), 0 10px 22px -16px rgba(46, 111, 73, .9);
}

[data-theme="dark"] .brand-mark {
  background: linear-gradient(155deg, #25352b, #1b2820);
  box-shadow: inset 0 0 0 1px rgba(111, 189, 141, .18);
}

.brand-text h1 {
  font-family: var(--font-serif);
  font-size: 27px;
  letter-spacing: .14em;
  line-height: 1.1;
}

.brand-text p {
  font-size: 11px;
  letter-spacing: .28em;
  color: var(--muted);
  margin-top: 3px;
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.date-label {
  font-size: 13px;
  color: var(--muted);
  margin-right: 4px;
  font-variant-numeric: tabular-nums;
}

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: transform .15s ease, background .2s, color .2s, border-color .2s, box-shadow .2s;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 12px 24px -14px rgba(46, 111, 73, .95);
}

.btn-primary:hover { background: var(--green-deep); }
[data-theme="dark"] .btn-primary { color: #0e1a12; }
[data-theme="dark"] .btn-primary:hover { background: #a5e2bc; }

.btn.ghost {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.ghost:hover { border-color: var(--green); color: var(--green-deep); }

.icon-btn {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: transform .15s, color .2s, background .2s, border-color .2s;
}

.icon-btn:hover { color: var(--ink); background: var(--surface-2); transform: translateY(-1px); }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }
.icon-btn.subtle { background: transparent; border-color: transparent; }
.icon-btn.subtle:hover { background: var(--surface-2); }

.link-btn {
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px dashed var(--line);
  padding: 0 0 2px;
  transition: color .2s, border-color .2s;
}

.link-btn:hover { color: var(--green-deep); border-color: var(--green); }

/* ---------------- stats ---------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 18px 15px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  inset: auto -30px -46px auto;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--tone-soft, var(--green-soft));
  opacity: .7;
}

.stat-top {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  position: relative;
}

.stat-value {
  position: relative;
  font-family: var(--font-serif);
  font-size: 30px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: .01em;
  margin-top: 2px;
  color: var(--tone, var(--ink));
  font-variant-numeric: tabular-nums;
}

.stat-value small {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 5px;
}

.stat[data-tone="red"] { --tone: var(--red); --tone-soft: var(--red-soft); }
.stat[data-tone="orange"] { --tone: var(--orange); --tone-soft: var(--orange-soft); }
.stat[data-tone="green"] { --tone: var(--green); --tone-soft: var(--green-soft); }
.stat[data-tone="ink"] { --tone: var(--ink); --tone-soft: var(--surface-2); }

/* ---------------- layout ---------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
}

/* ---------------- toolbar ---------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search { position: relative; flex: 1 1 200px; min-width: 170px; }

.search span {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: .55;
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 11px 14px 11px 37px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.search input::-webkit-search-cancel-button { cursor: pointer; }
.search input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(63, 143, 95, .14); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: all .18s;
}

.chip:hover { color: var(--ink); border-color: rgba(63, 143, 95, .4); }
.chip.is-active { background: var(--green); border-color: var(--green); color: #fff; }
[data-theme="dark"] .chip.is-active { color: #0e1a12; }

.select {
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.select:focus { border-color: var(--green); }

/* ---------------- plant grid ---------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(276px, 1fr));
  gap: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 17px 17px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  animation: rise .38s cubic-bezier(.22, .8, .3, 1) both;
  transition: transform .18s ease, box-shadow .22s, border-color .2s;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: rgba(63, 143, 95, .32);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.card[data-status="overdue"] { box-shadow: var(--shadow), inset 3px 0 0 var(--red); }
.card[data-status="today"] { box-shadow: var(--shadow), inset 3px 0 0 var(--orange); }
.card[data-status="soon"] { box-shadow: var(--shadow), inset 3px 0 0 var(--lime); }
.card[data-status="ok"] { box-shadow: var(--shadow), inset 3px 0 0 var(--green); }

.card-head { display: flex; align-items: flex-start; gap: 11px; }

.card-emoji {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 22px;
  border-radius: 13px;
  background: var(--surface-2);
}

.card-title { min-width: 0; }
.card-title h3 { font-size: 16px; line-height: 1.35; }

.card-title p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  flex: none;
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}

.pill.overdue { background: var(--red-soft); color: var(--red); }
.pill.today { background: var(--orange-soft); color: var(--orange); }
.pill.soon { background: var(--lime-soft); color: var(--lime); }
.pill.ok { background: var(--green-soft); color: var(--green-deep); }

.card-body { display: flex; align-items: center; gap: 15px; }

.ring-wrap { position: relative; width: 74px; height: 74px; flex: none; }

.ring { width: 74px; height: 74px; transform: rotate(-90deg); display: block; }
.ring circle { fill: none; stroke-width: 5.5; stroke-linecap: round; }
.ring-track { stroke: var(--line); }
.ring-fill { transition: stroke-dasharray .55s ease; stroke: var(--green); }
.ring-fill.overdue { stroke: var(--red); }
.ring-fill.today { stroke: var(--orange); }
.ring-fill.soon { stroke: var(--lime); }

.ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  line-height: 1;
  pointer-events: none;
}

.ring-label b {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ring-label span { font-size: 9.5px; color: var(--muted); margin-top: 3px; letter-spacing: .04em; }

.facts { flex: 1; min-width: 0; display: grid; gap: 5px; font-size: 12.5px; }
.facts div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.facts dt { color: var(--muted); white-space: nowrap; }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }

.card-foot { display: flex; gap: 7px; align-items: center; }

.btn.water {
  flex: 1;
  padding: 9px 12px;
  font-size: 13px;
  background: var(--green-soft);
  color: var(--green-deep);
  border: 1px solid transparent;
}

.btn.water:hover { background: var(--green); color: #fff; }
[data-theme="dark"] .btn.water:hover { color: #0e1a12; }

.btn.water.done {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--line);
}

.btn.water.done:hover { background: var(--surface-2); color: var(--muted); }

.grid.no-anim .card { animation: none; }

.card.splash { animation: splash .5s ease; }

@keyframes splash {
  0% { transform: none; }
  30% { transform: scale(.985) rotate(-.4deg); }
  60% { transform: scale(1.008) rotate(.3deg); }
  100% { transform: none; }
}

/* ---------------- sidebar ---------------- */

.sidebar {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 22px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 17px;
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  letter-spacing: .02em;
  margin-bottom: 10px;
}

.badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-deep);
  font-variant-numeric: tabular-nums;
}

.task-list { display: grid; gap: 2px; }

.task {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 11px;
  cursor: pointer;
  transition: background .15s;
}

.task:hover { background: var(--surface-2); }
.task-emoji { font-size: 17px; line-height: 1; }
.task-body { flex: 1; min-width: 0; }

.task-body b {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-body small { font-size: 11.5px; color: var(--muted); }
.task-body small.hot { color: var(--red); }

.task .icon-btn.water-mini {
  width: 28px;
  height: 28px;
  font-size: 13px;
  border-radius: 9px;
  background: transparent;
  border-color: transparent;
}

.task .icon-btn.water-mini:hover { background: var(--green-soft); color: var(--green-deep); }

.panel-empty {
  font-size: 12.5px;
  color: var(--muted);
  padding: 4px 8px 6px;
}

.panel.tip {
  background: linear-gradient(160deg, var(--green-soft), var(--surface) 78%);
  border-color: rgba(63, 143, 95, .22);
}

.panel.tip p { font-size: 12.5px; color: var(--ink); opacity: .82; line-height: 1.7; }

/* ---------------- empty ---------------- */

.empty {
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
  padding: 56px 20px 60px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .35);
}

[data-theme="dark"] .empty { background: rgba(255, 255, 255, .02); }

.empty-mark { font-size: 42px; filter: saturate(.9); }
.empty h2 { font-size: 17px; }
.empty p { font-size: 13px; color: var(--muted); max-width: 320px; }
.empty .btn { margin-top: 8px; }

/* ---------------- footer ---------------- */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------------- dialog form ---------------- */

.dialog {
  width: min(560px, 93vw);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .55);
  overflow: hidden;
}

.dialog::backdrop {
  background: rgba(16, 26, 19, .42);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 22px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 { font-size: 16px; letter-spacing: .03em; }

.dialog-body {
  display: grid;
  gap: 13px;
  padding: 18px 22px;
  max-height: min(64vh, 560px);
  overflow-y: auto;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 22px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}

.field { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}

.field textarea { resize: vertical; min-height: 74px; line-height: 1.6; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(63, 143, 95, .14);
}

.field input:invalid:not(:placeholder-shown) { border-color: var(--red); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 5px; }

.emoji-picker button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 18px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 2px solid transparent;
  transition: transform .15s, border-color .15s, background .15s;
}

.emoji-picker button:hover { transform: translateY(-2px); }
.emoji-picker button.is-selected { border-color: var(--green); background: var(--green-soft); }

/* ---------------- drawer ---------------- */

.drawer { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.drawer[aria-hidden="false"] { pointer-events: auto; }

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 26, 19, .38);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity .26s;
}

.drawer[aria-hidden="false"] .drawer-backdrop { opacity: 1; }

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(430px, 94vw);
  padding: 22px 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  border-radius: 22px 0 0 22px;
  box-shadow: -24px 0 70px -34px rgba(0, 0, 0, .5);
  transform: translateX(102%);
  transition: transform .32s cubic-bezier(.22, .8, .3, 1);
}

.drawer[aria-hidden="false"] .drawer-panel { transform: none; }

body.is-locked { overflow: hidden; }

.drawer-head { display: flex; align-items: flex-start; gap: 12px; }

.drawer-emoji {
  width: 58px;
  height: 58px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 30px;
  border-radius: 17px;
  background: var(--surface-2);
}

.drawer-head h2 { font-size: 19px; line-height: 1.3; }
.drawer-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.drawer-head .icon-btn { margin-left: auto; }

.drawer-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.metric {
  padding: 11px 13px;
  border-radius: 13px;
  background: var(--surface-2);
  display: grid;
  gap: 2px;
}

.metric span { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.metric b { font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric small { font-size: 11px; color: var(--muted); }
.metric.accent { background: var(--green-soft); }
.metric.accent b { color: var(--green-deep); }

.drawer-section h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: .05em;
  margin-bottom: 9px;
}

.drawer-section h3 em {
  font-style: normal;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
}

.history { display: grid; gap: 1px; }

.history li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 2px;
  font-size: 13px;
  border-bottom: 1px dashed var(--line);
}

.history li:last-child { border-bottom: none; }

.history .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
  opacity: .7;
}

.history .h-week { color: var(--muted); font-size: 12px; }
.history .h-ago { margin-left: auto; font-size: 11.5px; color: var(--muted); }

.notes-box {
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink);
  opacity: .85;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--surface-2);
  border-left: 3px solid var(--green);
  white-space: pre-wrap;
}

.drawer-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}

.drawer-actions .btn.water { flex: 1; }
.drawer-actions .icon-btn { width: 42px; height: 42px; }

/* ---------------- toast ---------------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 120;
  padding: 11px 20px;
  max-width: 90vw;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13.5px;
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, .7);
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- responsive ---------------- */

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; grid-template-columns: 1fr 1fr; }
  .panel.tip { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .app { padding: 22px 16px 46px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .brand-text h1 { font-size: 24px; }
  .date-label { order: 3; width: 100%; margin: 0; font-size: 12px; }
  .grid { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: 1fr; }
  .dialog { border-radius: 18px; }
  .dialog-body { max-height: 62vh; }
  .grid-2 { grid-template-columns: 1fr; }
  .footer { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 420px) {
  .chips { width: 100%; }
  .select { flex: 1; }
  .card-foot .icon-btn { width: 34px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
