:root {
  --green: #2e7d32;
  --green-dark: #1b5e20;
  --green-light: #e8f5e9;
  --bg: #f4f6f4;
  --card: #ffffff;
  --text: #24312a;
  --text-light: #7a8a80;
  --border: #e2e8e2;
  --danger: #c62828;
  --radius: 14px;
  --shadow: 0 1px 4px rgba(30, 60, 30, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
}

/* 桌面预览时限制宽度，模拟手机 */
body { max-width: 560px; margin: 0 auto; min-height: 100vh; }

/* ---------- 顶部 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  color: #fff;
  box-shadow: 0 2px 8px rgba(27, 94, 32, 0.35);
}
.app-header .logo {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  font-size: 22px;
}
.app-header h1 { margin: 0; font-size: 18px; line-height: 1.2; }
.app-header p { margin: 2px 0 0; font-size: 12px; opacity: 0.85; }

/* ---------- 主区域 ---------- */
main { padding: 12px 12px calc(80px + env(safe-area-inset-bottom)); }

.view { display: none; animation: fadeIn 0.18s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}
.step {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--green);
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
}
.badge {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 999px;
  background: #eceff1;
  color: var(--text-light);
}
.badge.ok { background: var(--green-light); color: var(--green-dark); }
.badge.manual { background: #fff3e0; color: #e65100; }

/* ---------- 定位 ---------- */
.loc-info {
  background: var(--green-light);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 10px;
  word-break: break-all;
}
.loc-info.empty { background: #f5f5f5; color: var(--text-light); text-align: center; }
.loc-info .coord { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; font-weight: 600; }
.loc-info .meta { color: var(--text-light); font-size: 12px; }

.manual-box { margin-top: 10px; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--text-light); font-weight: 500; }
.field:last-child { margin-bottom: 0; }
.field input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  font-size: 16px;              /* 防止 iOS 聚焦自动放大 */
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfa;
  color: var(--text);
  outline: none;
}
.field input:focus { border-color: var(--green); background: #fff; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 8px; }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 3px 10px rgba(46, 125, 50, 0.35); }
.btn-outline { background: #fff; color: var(--green); border: 1.5px solid var(--green); }
.btn-danger-outline { background: #fff; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-save { padding: 15px; font-size: 17px; margin-top: 2px; }

.link-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--green);
  font-size: 13px;
  text-align: center;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px;
}

/* ---------- 拍照 ---------- */
.photo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 180px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: #fafbfa;
  cursor: pointer;
  overflow: hidden;
}
.photo-area:active { border-color: var(--green); }
.photo-placeholder { text-align: center; font-size: 34px; line-height: 1.3; color: var(--text-light); }
.photo-placeholder span { font-size: 15px; font-weight: 600; color: var(--text); }
.photo-placeholder small { display: block; font-size: 12px; margin-top: 4px; }
#photo-preview { max-width: 100%; max-height: 300px; object-fit: contain; }

/* ---------- 列表 ---------- */
.search-card { display: flex; gap: 8px; padding: 10px; }
.search-card input {
  flex: 1;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfa;
  outline: none;
}
.search-card input:focus { border-color: var(--green); }

.list-summary { font-size: 13px; color: var(--text-light); margin: 0 2px 10px; }

.record-card {
  display: flex;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
}
.record-thumb {
  width: 72px; height: 72px;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: cover;
  background: var(--green-light);
}
.record-thumb.empty-thumb {
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--text-light);
}
.record-main { flex: 1; min-width: 0; }
.record-main h4 { margin: 0 0 4px; font-size: 16px; }
.record-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 500;
}
.record-coord {
  font-size: 12px;
  color: var(--text-light);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.record-time { font-size: 12px; color: var(--text-light); margin-top: 2px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 15px;
  line-height: 2;
}
.empty-state small { font-size: 13px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  background: none;
  border: none;
  font-size: 12px;
  color: var(--text-light);
  cursor: pointer;
}
.tab-icon { font-size: 20px; }
.tab.active { color: var(--green); font-weight: 600; }

/* ---------- 详情弹层 ---------- */
.detail-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.detail-box {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 18px 18px 0 0;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
#detail-photo { display: block; width: 100%; max-height: 320px; object-fit: cover; background: #eee; }
.detail-body { padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
.detail-body h3 { margin: 0 0 10px; font-size: 18px; }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: #f7f9f7;
  border-radius: 10px;
  padding: 12px;
}
.detail-grid label { display: block; font-size: 12px; color: var(--text-light); margin-bottom: 2px; }
.detail-grid span { font-size: 15px; font-weight: 600; font-family: ui-monospace, Menlo, Consolas, monospace; }
.detail-remark {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: #fff8e1;
  border-radius: 10px;
  font-size: 13px;
}
.detail-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.detail-actions > * { flex: 1; }
.detail-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 40, 32, 0.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 100;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

.hidden { display: none !important; }
