/* Plant Care — single stylesheet, mobile-first, no external assets. */

:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #eef2ec;
  --ink: #1c2b23;
  --ink-soft: #59685f;
  --line: #dbe3da;
  --green: #2e6b4c;
  --green-deep: #244c3a;
  --green-soft: #dceadf;
  --danger: #b3372f;
  --warning: #b7791f;
  --radius: 14px;
  --tabbar-h: 60px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.3, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100dvh; }

#app {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 2px 10px; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0; color: var(--green-deep); }
.page-head .sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.btn {
  appearance: none; border: none; border-radius: 12px;
  font: inherit; font-weight: 600;
  padding: 11px 16px; cursor: pointer;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px;
  transition: transform 0.08s var(--ease), background 0.15s ease;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }
.btn-soft { background: var(--green-soft); border-color: transparent; color: var(--green-deep); }
.btn-danger { color: var(--danger); border-color: #e5c9c5; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; min-height: 36px; font-size: 14px; border-radius: 10px; }

.plants-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding-top: 4px; }

.plant-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; cursor: pointer;
  box-shadow: 0 1px 2px rgba(28, 43, 35, 0.05);
  transition: transform 0.08s var(--ease);
}
.plant-card:active { transform: scale(0.98); }

.plant-thumb { aspect-ratio: 4 / 3; background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.plant-thumb img { width: 100%; height: 100%; object-fit: cover; }
.plant-thumb .ph { font-size: 40px; }

.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge-due   { background: #fbe9e7; color: var(--danger); }
.badge-soon  { background: #fdf1de; color: var(--warning); }
.badge-ok    { background: var(--green-soft); color: var(--green); }
.badge-muted { background: var(--surface-2); color: var(--ink-soft); }

.today-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; cursor: pointer;
}
.today-item .t-thumb { width: 46px; height: 46px; border-radius: 10px; background: var(--surface-2); overflow: hidden; flex: none; display: flex; align-items: center; justify-content: center; }
.today-item .t-thumb img { width: 100%; height: 100%; object-fit: cover; }
.today-item .t-info { flex: 1; min-width: 0; }
.today-item .t-name { font-weight: 650; }
.today-item .t-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

/* ---------- detail page ---------- */

.hero-photo { height: 240px; background: var(--surface-2); border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; margin: 4px 0 12px; }
.hero-photo img { width: 100%; height: 100%; object-fit: cover; }
.hero-photo .ph { font-size: 72px; }

.detail-name { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; margin: 0 0 2px; color: var(--green-deep); }
.detail-species { color: var(--ink-soft); font-style: italic; margin: 0 0 8px; }

.fact-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 12px 0; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.fact .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }
.fact .v { font-weight: 650; margin-top: 3px; font-size: 14.5px; }

.actions-row { display: flex; gap: 8px; margin: 4px 0 0; flex-wrap: wrap; }
.actions-row .btn { flex: 1; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 12px 0; }
.card h3 { margin: 0 0 8px; font-size: 15px; color: var(--green-deep); }
.plant-notes { white-space: pre-wrap; font-size: 14px; line-height: 1.5; color: var(--ink); margin: 0; }

.photo-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.photo-tile { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: pointer; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- timeline ---------- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 30px; }
.timeline li::before { content: ""; position: absolute; left: 8px; top: 22px; bottom: -2px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.tl-marker { position: absolute; left: 0; top: 0; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 10px; }
.tl-body { display: flex; gap: 8px; align-items: flex-start; }
.tl-main { flex: 1; min-width: 0; }
.tl-time { font-size: 12px; color: var(--ink-soft); }
.tl-text { font-size: 14px; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.tl-photo { width: 56px; height: 56px; border-radius: 10px; background: var(--surface-2); overflow: hidden; cursor: pointer; flex: none; }
.tl-photo img { width: 100%; height: 100%; object-fit: cover; }
.tl-del { border: none; background: transparent; color: var(--ink-soft); font-size: 13px; padding: 4px; cursor: pointer; flex: none; }
.tl-del:hover { color: var(--danger); }

/* ---------- forms ---------- */

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="date"],
.form-row input[type="password"],
.form-row select,
.form-row textarea {
  width: 100%;
  font: inherit;
  font-size: 15.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  min-height: 46px;
}
.form-row textarea { resize: vertical; min-height: 88px; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  outline: 2px solid var(--green);
  outline-offset: 1px;
  border-color: var(--green);
}
.frm-err { color: var(--danger); font-size: 13.5px; margin: 8px 0 0; }

/* ---------- empty / status states ---------- */

.empty {
  text-align: center;
  padding: 40px 18px;
  color: var(--ink-soft);
}
.empty .empty-ic { font-size: 44px; margin-bottom: 8px; }
.empty .empty-h { font-weight: 700; font-size: 16px; color: var(--ink); margin: 0 0 4px; }
.empty .empty-t { font-size: 14px; margin: 0 0 14px; }

.loading { text-align: center; padding: 48px 0; color: var(--ink-soft); font-size: 14px; }
.spin {
  width: 26px; height: 26px;
  border: 3px solid var(--green-soft);
  border-top-color: var(--green);
  border-radius: 50%;
  margin: 0 auto 10px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tab bar ---------- */

#tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 40;
}
.tab {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 4px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tab .tab-ic { font-size: 21px; line-height: 1; }
.tab.is-active { color: var(--green-deep); }
.tab-add .tab-ic {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--green-deep); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 400;
  margin-top: -12px; line-height: 1;
}

/* ---------- modal ---------- */

.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(15, 23, 18, 0.55);
  z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 620px;
  max-height: 88dvh;
  overflow: auto;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  animation: slide-up 0.18s var(--ease);
}
@keyframes slide-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 10px; font-size: 18px; color: var(--green-deep); }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }
.modal .modal-img {
  width: 100%; border-radius: 12px;
  background: var(--surface-2);
  margin-bottom: 10px;
  max-height: 46dvh; object-fit: contain;
}

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

#toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  width: min(92vw, 460px);
}
.toast {
  background: rgba(28, 43, 35, 0.95);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 999px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  animation: toast-in 0.18s var(--ease);
}
.toast.toast-err { background: rgba(150, 49, 41, 0.97); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- login ---------- */

.login-wrap { max-width: 340px; margin: 0 auto; padding: 60px 0 20px; text-align: center; }
.login-wrap .lock { font-size: 40px; }
.login-wrap p { font-size: 14px; color: var(--ink-soft); line-height: 1.5; }
.login-wrap form { text-align: left; margin-top: 14px; }
.login-wrap input { width: 100%; font: inherit; font-size: 15.5px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }

/* ---------- settings ---------- */

.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: none; }
.set-row .k { font-weight: 600; font-size: 14.5px; }
.set-row .v { font-size: 13px; color: var(--ink-soft); }
.note { font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; }

@media (min-width: 640px) {
  .modal-scrim { align-items: center; }
  .modal { border-radius: 18px; }
  #tabbar { left: 50%; transform: translateX(-50%); width: min(100%, 620px); border-radius: 0; }
}