:root {
  --bg: #f7f3df;
  --bg-2: #eef0d8;
  --panel: #fffdf5;
  --panel-2: #fbf7e9;
  --ink: #172419;
  --muted: #637265;
  --leaf: #2f6f4e;
  --leaf-2: #4e8a62;
  --moss: #7d8f4c;
  --clay: #b76e56;
  --sun: #e6b85c;
  --line: #ddd9c4;
  --warn: #fff0c6;
  --danger: #9f322e;
  --shadow: 0 20px 55px rgba(31, 63, 38, 0.18);
  --soft-shadow: 0 10px 28px rgba(31, 63, 38, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: radial-gradient(circle at top left, #fff9de 0, var(--bg) 34%, #eff2df 100%); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

#appShell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  min-height: 74px;
  padding: 10px 14px calc(10px + env(safe-area-inset-top, 0px));
  background: rgba(255, 253, 245, 0.9);
  border-bottom: 1px solid rgba(221, 217, 196, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
}
.brand-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo-mark { width: 48px; height: 48px; flex: 0 0 auto; filter: drop-shadow(0 8px 14px rgba(47, 111, 78, 0.22)); }
.logo-mark svg rect { fill: var(--leaf); }
.logo-mark svg path[stroke] { stroke: #fff8df; }
.logo-mark .leaf-a { fill: #a8ce78; }
.logo-mark .leaf-b { fill: #c6df8d; }
.logo-mark .leaf-c { fill: #7caf67; }
.brand { font-weight: 950; font-size: 25px; letter-spacing: -0.055em; line-height: 1; color: var(--leaf); }
.status-line { font-size: 12px; color: var(--muted); margin-top: 4px; max-width: 54vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.primary-btn {
  background: linear-gradient(135deg, var(--leaf), var(--leaf-2));
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(47, 111, 78, 0.28);
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(47, 111, 78, 0.33); }
.primary-btn:disabled { opacity: 0.58; cursor: progress; transform: none; }
.wide { width: 100%; justify-content: center; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: #fffdf5; font-size: 28px; line-height: 1; color: var(--muted);
}
.pill-btn, .secondary-btn {
  border: 1px solid var(--line);
  background: rgba(255, 253, 245, 0.96);
  color: var(--leaf);
  font-weight: 900;
  border-radius: 999px;
  padding: 10px 13px;
  box-shadow: var(--soft-shadow);
}
.secondary-btn.subtle { color: var(--muted); background: #fbf7e9; box-shadow: none; }
.secondary-btn.light { background: white; box-shadow: none; }
.edit-btn { background: #f4ead2; color: #754735; border-color: #ead5ba; }

.setup-warning { margin: 10px 12px 0; padding: 10px 12px; border: 1px solid #f0d889; background: var(--warn); border-radius: 16px; }
.hidden { display: none !important; }
.main-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 14px; padding: 14px; }
.map-panel, .list-panel { background: var(--panel); border: 1px solid rgba(221, 217, 196, 0.9); border-radius: 26px; box-shadow: var(--shadow); overflow: hidden; }
.map-panel { position: relative; min-height: 610px; }
#map { position: absolute; inset: 0; }
.map-actions { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 8px; z-index: 5; }
.map-pick-bar {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 28px));
  z-index: 7;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: rgba(255, 253, 245, 0.96);
  border: 1px solid #d4d0b9;
  box-shadow: var(--shadow);
  border-radius: 22px;
  padding: 12px;
}
.map-pick-bar strong { display: block; color: var(--leaf); }
.map-pick-bar span { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }

.list-panel { padding: 13px; overflow: auto; }
.intro-card {
  background: linear-gradient(145deg, #2f6f4e, #6f8f4a);
  color: white;
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 18px 38px rgba(47, 111, 78, 0.22);
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}
.intro-card::after {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  right: -54px;
  top: -44px;
  background: radial-gradient(circle, rgba(255,255,255,0.24), rgba(255,255,255,0));
  border-radius: 999px;
}
.intro-eyebrow { font-size: 12px; font-weight: 950; opacity: .78; text-transform: uppercase; letter-spacing: .08em; }
.intro-card h1 { margin: 5px 0 7px; font-size: 24px; line-height: 1; letter-spacing: -0.055em; }
.intro-card p { margin: 0; font-size: 13px; line-height: 1.38; opacity: .9; }

.filter-card, .legend-card { background: rgba(255, 253, 245, 0.84); border: 1px solid var(--line); border-radius: 20px; padding: 12px; display: grid; gap: 8px; }
.filter-card label { font-size: 12px; font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.legend-card { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.legend-card span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 850; color: var(--muted); background: #f6f2df; border: 1px solid #e7e0c5; border-radius: 999px; padding: 6px 8px; }
.legend-card b { font-size: 16px; }
select, input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px;
  background: white;
  color: var(--ink);
  outline-color: var(--leaf-2);
}
textarea { resize: vertical; }
.tiny-note { color: var(--muted); font-size: 12px; line-height: 1.35; }
.section-title { font-weight: 950; margin: 15px 4px 10px; color: var(--muted); letter-spacing: -0.02em; }
.spot-list { display: grid; gap: 10px; padding-bottom: 14px; }
.spot-card { width: 100%; border: 1px solid var(--line); background: rgba(255, 253, 245, 0.94); border-radius: 20px; padding: 10px; display: grid; grid-template-columns: 68px 1fr; gap: 10px; text-align: left; box-shadow: 0 5px 15px rgba(31, 63, 38, 0.06); }
.spot-card:hover { border-color: #aac8a9; transform: translateY(-1px); }
.spot-thumb { height: 68px; border-radius: 17px; background: linear-gradient(135deg, #e2ebd0, #bad5a8); display: grid; place-items: center; color: var(--leaf); font-size: 30px; overflow: hidden; background-size: cover; background-position: center; }
.spot-name { font-weight: 950; color: var(--ink); line-height: 1.16; letter-spacing: -0.025em; }
.spot-place { color: var(--muted); font-size: 13px; margin-top: 4px; line-height: 1.25; }
.spot-meta { color: var(--leaf); font-size: 12px; font-weight: 900; margin-top: 8px; line-height: 1.25; }
.empty-state { padding: 18px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 18px; background: #fffaf0; }

.sheet {
  position: fixed; inset: 0; z-index: 50; background: rgba(13, 24, 16, 0.36);
  display: grid; place-items: end center; padding: 16px; backdrop-filter: blur(4px);
}
.sheet-card {
  width: min(760px, 100%);
  max-height: min(90dvh, 880px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 30px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.sheet-header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding-bottom: 12px; }
.sheet-header h2 { margin: 0; font-size: 25px; letter-spacing: -0.045em; color: var(--leaf); }
.sheet-header p { margin: 5px 0 0; color: var(--muted); font-size: 14px; line-height: 1.35; }
.plant-form { display: grid; gap: 12px; }
.form-section { background: #fbf8ec; border: 1px solid #e8e1c7; border-radius: 22px; padding: 12px; display: grid; gap: 12px; }
.section-kicker { color: var(--clay); font-weight: 950; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
.plant-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 900; color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.location-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.selected-place { border: 1px solid #bad2b4; background: #f2f7e8; color: var(--ink); padding: 12px; border-radius: 18px; line-height: 1.35; }
.selected-place-top { display: flex; justify-content: space-between; margin-bottom: 4px; }
.selected-source { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--leaf); font-weight: 950; text-transform: uppercase; letter-spacing: .04em; }
.selected-place strong { display: block; margin-bottom: 2px; }
.ethics-box { padding: 12px; border-radius: 18px; background: #f6ecd0; color: #67491d; border: 1px solid #e7d09c; font-size: 14px; line-height: 1.35; }
.detail-card img { width: 100%; max-height: 320px; object-fit: cover; border-radius: 20px; border: 1px solid var(--line); background: #f3f3f3; }
.detail-hero-icon { height: 148px; display: grid; place-items: center; border-radius: 22px; font-size: 58px; background: radial-gradient(circle at top left, #fff8df, #dce9c6); border: 1px solid var(--line); }
.detail-grid { display: grid; gap: 10px; }
.detail-line { color: var(--muted); line-height: 1.45; }
.detail-line strong { color: var(--ink); }
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { background: #eff6e9; color: var(--leaf); border: 1px solid #d4e6c8; border-radius: 999px; padding: 7px 10px; font-size: 12px; font-weight: 950; }
.danger-text { color: var(--danger); font-weight: 900; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

@media (max-width: 900px) {
  .topbar { min-height: 67px; }
  .logo-mark { width: 42px; height: 42px; }
  .brand { font-size: 22px; }
  .primary-btn { padding: 10px 12px; }
  .main-grid { grid-template-columns: 1fr; grid-template-rows: minmax(58dvh, 1fr) auto; padding: 8px; gap: 9px; }
  .map-panel { min-height: 58dvh; border-radius: 22px; }
  .list-panel { max-height: 42dvh; border-radius: 22px; }
  .intro-card { display: none; }
  .sheet { padding: 8px; align-items: end; }
  .sheet-card { border-radius: 26px 26px 18px 18px; max-height: 91dvh; }
  .form-row { grid-template-columns: 1fr; }
  .status-line { max-width: 46vw; }
  .map-pick-bar { top: 10px; align-items: flex-start; }
}

@media (max-width: 430px) {
  .topbar { padding-left: 10px; padding-right: 10px; }
  .status-line { max-width: 42vw; }
  .brand { font-size: 21px; }
  .logo-mark { width: 40px; height: 40px; }
  .spot-card { grid-template-columns: 60px 1fr; }
  .spot-thumb { height: 60px; }
  .map-actions { bottom: 10px; left: 10px; }
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.caution-badge {
  background: #fff3d8;
  border-color: #ead094;
  color: #74521a;
}

button:disabled,
.secondary-btn:disabled,
.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.version-chip {
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: #f7f3df;
  background: #2f6f4e;
}


/* Plant location UX patch: remove confusing Use map center button. */
#useCenterBtn { display: none !important; }
