:root {
  --green: #5EA344;
  --deep-green: #2F5233;
  --orange: #D9832E;
  --sky: #BEE3DB;
  --ink: #26301f;
  --card-bg: #ffffffee;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(30, 50, 20, 0.18);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  background: #dff0e6;
}

#app { position: fixed; inset: 0; }

#canvas-root { position: absolute; inset: 0; }
#canvas-root canvas { display: block; touch-action: none; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.55));
  backdrop-filter: blur(6px);
  z-index: 20;
}
.logo { width: 38px; height: 38px; object-fit: contain; border-radius: 8px; }
.brand-name { font-weight: 700; font-size: 15px; color: var(--deep-green); line-height: 1.2; }
.brand-sub { font-size: 11px; color: #5a6b52; }
.topbar-spacer { flex: 1; }

.env-controls { display: flex; gap: 8px; }
.control-group { display: flex; gap: 3px; background: #ffffffcc; border-radius: 999px; padding: 3px; box-shadow: var(--shadow); }
.control-group button {
  border: none; background: transparent; border-radius: 999px;
  padding: 5px 9px; font-size: 13px; cursor: pointer; color: #567;
  transition: background 0.15s;
}
.control-group button.active { background: var(--green); color: #fff; }

/* ---------- 首页 banner ---------- */
.banner-rail {
  position: absolute;
  left: 16px; top: 66px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 15;
  max-width: 250px;
}
.banner-card {
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
}
.banner-card b { display: block; font-size: 14px; margin-bottom: 2px; }
.hint-card {
  margin-top: 4px;
  background: #ffffffe6;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--deep-green);
  box-shadow: var(--shadow);
}
.legend { display: flex; gap: 10px; margin-top: 6px; font-size: 11px; color: #445; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- 侧边面板 ---------- */
.side-panel {
  position: absolute;
  top: 0; right: 0; bottom: 64px;
  width: min(380px, 92vw);
  background: #f5f8f1;
  box-shadow: -6px 0 24px rgba(0,0,0,0.15);
  transform: translateX(105%);
  transition: transform 0.28s ease;
  z-index: 25;
  display: flex; flex-direction: column;
}
.side-panel.open { transform: translateX(0); }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid #e2e8da;
  background: #fff;
}
.panel-header h2 { margin: 0; font-size: 17px; color: var(--deep-green); }
.panel-close { border: none; background: #eef2ea; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 14px; }
.panel-body { flex: 1; overflow-y: auto; padding: 12px 14px 20px; }

/* ---------- 卡片通用 ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 3px 10px rgba(30,50,20,0.08);
}
.card h3 { margin: 0 0 4px; font-size: 14px; color: var(--deep-green); }
.card p { margin: 0; font-size: 12px; color: #667; }
.tag {
  display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 999px;
  background: var(--orange); color: #fff; margin-left: 6px;
}
.price { color: var(--orange); font-weight: 700; font-size: 15px; }

.category-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.category-card { text-align: center; cursor: pointer; }
.category-card .emoji { font-size: 26px; }

.product-row { display: flex; align-items: center; justify-content: space-between; }
.btn {
  border: none; border-radius: 999px; padding: 7px 14px; font-size: 12px; cursor: pointer;
  background: var(--green); color: #fff; font-weight: 600;
}
.btn.secondary { background: #eef2ea; color: var(--deep-green); }
.btn.orange { background: var(--orange); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.progress-bar { height: 8px; border-radius: 999px; background: #e2e8da; overflow: hidden; margin: 6px 0; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--orange)); }

.back-link { font-size: 12px; color: var(--green); cursor: pointer; margin-bottom: 8px; display: inline-block; }

/* ---------- 地块详情浮层 ---------- */
.plot-detail {
  position: absolute;
  left: 50%; bottom: 84px;
  transform: translateX(-50%);
  width: min(360px, 92vw);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  z-index: 30;
}
.plot-detail .live {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: #d1483a; margin-top: 6px;
}
.plot-detail .live .blip { width: 7px; height: 7px; border-radius: 50%; background: #d1483a; animation: blip 1.2s infinite; }
@keyframes blip { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
.plot-detail .close-x { position: absolute; top: 10px; right: 12px; border: none; background: none; font-size: 14px; cursor: pointer; color: #99a; }

/* ---------- AI 助手 ---------- */
.ai-fab {
  position: absolute; right: 16px; bottom: 84px;
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--deep-green); color: #fff; font-size: 22px;
  border: none; box-shadow: var(--shadow); cursor: pointer; z-index: 22;
}
.ai-panel {
  position: absolute; right: 16px; bottom: 144px;
  width: min(300px, 88vw); height: 380px;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 26; display: flex; flex-direction: column; overflow: hidden;
}
.ai-panel[hidden] { display: none; }
.ai-header {
  background: var(--deep-green); color: #fff; padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center; font-size: 13px;
}
.ai-header button { border: none; background: none; color: #fff; cursor: pointer; }
.ai-messages { flex: 1; overflow-y: auto; padding: 10px 12px; font-size: 12px; }
.ai-msg { margin-bottom: 8px; max-width: 85%; padding: 7px 10px; border-radius: 10px; line-height: 1.4; }
.ai-msg.bot { background: #eef2ea; align-self: flex-start; }
.ai-msg.user { background: var(--green); color: #fff; margin-left: auto; }
.ai-messages { display: flex; flex-direction: column; }
.ai-input-row { display: flex; border-top: 1px solid #eee; padding: 8px; gap: 6px; }
.ai-input-row input { flex: 1; border: 1px solid #dde3d8; border-radius: 999px; padding: 6px 12px; font-size: 12px; outline: none; }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 64px;
  background: #ffffffee;
  backdrop-filter: blur(6px);
  display: flex;
  box-shadow: 0 -4px 14px rgba(0,0,0,0.08);
  z-index: 24;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10px; color: #7a8a72;
}
.tab span { font-size: 10px; }
.tab.active { color: var(--green); font-weight: 700; }

@media (max-width: 480px) {
  .brand-sub { display: none; }
  .topbar { flex-wrap: wrap; padding: 8px 12px; }
  .env-controls { order: 3; width: 100%; flex-direction: row; justify-content: center; margin-top: 4px; }
  .banner-rail { top: 104px; }
}

/* ---------- 实时天气 ---------- */
.weather-chip {
  display: flex; align-items: center; gap: 6px;
  background: #ffffffcc; border-radius: 999px;
  padding: 6px 12px; font-size: 12px; color: var(--deep-green);
  box-shadow: var(--shadow); white-space: nowrap;
}
.weather-chip.offline { color: #99a; }
#weather-icon { font-size: 15px; }
#live-controls button { font-weight: 600; }
#live-controls button.active { background: var(--orange); }

/* ---------- 登录 ---------- */
.login-entry {
  border: none; border-radius: 999px;
  background: var(--deep-green); color: #fff;
  padding: 8px 14px; font-size: 13px; cursor: pointer;
  box-shadow: var(--shadow); white-space: nowrap;
}
.login-entry.logged { background: #fff; color: var(--deep-green); }

.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 30, 15, 0.45);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-mask[hidden], .pickup-toast[hidden] { display: none; }
.modal {
  position: relative;
  width: min(360px, calc(100vw - 40px));
  background: #fff; border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.login-modal h3 { margin: 0 0 2px; color: var(--deep-green); }
.modal-sub { margin: 0 0 14px; font-size: 12px; color: #789; }
.field { display: block; margin-bottom: 12px; font-size: 12px; color: #567; }
.field > span { display: block; margin-bottom: 4px; }
.field input {
  width: 100%; border: 1px solid #d8e2d4; border-radius: 10px;
  padding: 9px 12px; font-size: 14px; outline: none;
}
.field input:focus { border-color: var(--green); }
.human-row { display: flex; align-items: center; gap: 8px; }
.human-row b { font-size: 15px; color: var(--deep-green); white-space: nowrap; }
.human-row input { flex: 1; min-width: 0; }
.human-row .btn { white-space: nowrap; flex-shrink: 0; }
.login-hint { min-height: 16px; margin: 0 0 8px; font-size: 12px; color: var(--green); }
.login-hint.err { color: #c4452e; }
.btn.wide { width: 100%; padding: 11px; font-size: 15px; }
.login-foot { margin: 10px 0 0; font-size: 11px; color: #9ab; text-align: center; }

/* ---------- 仓库 ---------- */
.member-card { border: 1px solid #e4d7be; background: #fffaf0ee; }
.pickup-alert {
  background: #fdf1e3; border: 1px solid #eed3b0;
  border-radius: 10px; padding: 8px 10px;
  font-size: 12px; color: #a05a1c; margin: 8px 0;
}
.wh-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 0; border-bottom: 1px dashed #e4ebe0;
  font-size: 13px;
}
.wh-item:last-child { border-bottom: none; }
.wh-meta { margin: 2px 0 0; font-size: 11px; color: #8a9a85; }
.contract-row { padding: 8px 0; border-bottom: 1px dashed #e4ebe0; font-size: 13px; }
.contract-row:last-child { border-bottom: none; }
.contract-row p { margin: 3px 0; font-size: 12px; color: #678; }

.tab { position: relative; }
.tab-badge {
  position: absolute; top: 2px; right: 14%;
  min-width: 16px; height: 16px; line-height: 16px;
  background: var(--orange); color: #fff;
  border-radius: 999px; font-size: 10px; font-style: normal;
  padding: 0 4px;
}

/* ---------- 生命周期时间轴 ---------- */
.lifecycle {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 2px; margin: 8px 0 2px;
}
.lc-step {
  display: flex; flex-direction: column; align-items: center;
  font-size: 10px; color: #aab; min-width: 40px;
  opacity: 0.55;
}
.lc-step.done { color: var(--deep-green); opacity: 1; }
.lc-step.now .lc-icon { transform: scale(1.25); }
.lc-step.now .lc-label { font-weight: 700; color: var(--orange); }
.lc-icon { font-size: 15px; transition: transform 0.2s; }
.lc-label { margin-top: 1px; white-space: nowrap; }
.lc-arrow { color: #ccd5c8; font-size: 11px; }

/* ---------- 提货提示浮层 ---------- */
.pickup-toast {
  position: absolute; left: 50%; top: 74px;
  transform: translateX(-50%);
  z-index: 55; max-width: min(480px, calc(100vw - 40px));
  background: #fffffff2; border: 1px solid #dbe8d4;
  border-radius: 12px; padding: 10px 16px;
  font-size: 13px; color: var(--deep-green);
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 900px) {
  .weather-chip { display: none; }
}

/* ---------- POI 详情 / 官网引导 ---------- */
.poi-facts {
  margin: 8px 0 0; padding-left: 18px;
  font-size: 12px; color: #567; line-height: 1.7;
}
.official-link-box {
  margin-top: 10px; padding: 10px 12px;
  background: #f2f7ef; border: 1px dashed #b9d3ac; border-radius: 10px;
  text-align: center; word-break: break-all;
}
.official-link-box a {
  color: var(--green); font-weight: 700; font-size: 14px;
  text-decoration: underline;
}
