/* ============================================================
   自然回响 · 样式
   视觉基调：自然标本手册 —— 暖纸色、墨绿、衬线标题
   ============================================================ */

:root {
  --paper: #f6f2e7;
  --paper-deep: #efe9d8;
  --card: #fffdf6;
  --ink: #2b352c;
  --ink-soft: #6b7468;
  --ink-faint: #9aa294;
  --green: #2f5740;
  --green-soft: #4a7a5c;
  --green-wash: #e2eadd;
  --amber: #b9743a;
  --amber-wash: #f3e3d3;
  --line: #ddd5c2;
  --danger: #a84c3f;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(60, 70, 50, .08), 0 1px 3px rgba(60, 70, 50, .06);
}

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

html { background: var(--paper); }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, #fdfaf1 0%, transparent 60%),
    var(--paper);
  min-height: 100vh;
  padding-bottom: 92px; /* 给底部导航留位 */
}

h1, h2, h3, .serif {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  font-weight: 600;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }
.hidden { display: none !important; }

#app { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.view { animation: fadein .28s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 顶部 ---------- */
.page-header { padding: 26px 4px 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--green); color: #f3efdd;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
  box-shadow: inset 0 0 0 2px rgba(243,239,221,.25);
}
.brand h1 { font-size: 26px; letter-spacing: 2px; }
.tagline { font-size: 12px; color: var(--ink-soft); letter-spacing: 3px; margin-top: 2px; }

.stats-row {
  display: flex; margin-top: 16px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.stat {
  flex: 1; text-align: center; padding: 12px 0 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat + .stat { border-left: 1px dashed var(--line); }
.stat b { font-size: 22px; color: var(--green); font-family: "Noto Serif SC", serif; }
.stat span { font-size: 11px; color: var(--ink-soft); letter-spacing: 2px; }

/* ---------- 筛选 ---------- */
.filter-bar {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 8px 2px 12px; scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0; padding: 6px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  font-size: 13px; color: var(--ink-soft);
  transition: all .15s;
}
.chip.active {
  background: var(--green); border-color: var(--green); color: #f3efdd;
}

/* ---------- 标本卡网格 ---------- */
.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  padding-bottom: 20px;
}
.specimen {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer; position: relative;
  transition: transform .15s ease, box-shadow .15s ease;
}
.specimen:active { transform: scale(.97); }
.specimen .cover {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block;
  background: var(--paper-deep);
}
.specimen .cover-ph {
  width: 100%; aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; background: var(--green-wash);
}
.specimen .info { padding: 10px 12px 12px; position: relative; }
.specimen .info::before {
  content: ""; position: absolute; left: 12px; right: 12px; top: 0;
  border-top: 1px dashed var(--line);
}
.specimen .name {
  font-family: "Noto Serif SC", serif; font-weight: 600;
  font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.specimen .meta {
  font-size: 11px; color: var(--ink-faint); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.specimen .cat-tag {
  position: absolute; top: 8px; left: 8px;
  background: rgba(255, 253, 246, .92); border-radius: 999px;
  font-size: 11px; padding: 3px 9px; color: var(--ink-soft);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.specimen .count-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(47, 87, 64, .88); color: #f3efdd;
  border-radius: 999px; font-size: 11px; padding: 3px 9px;
}

/* ---------- 空状态 ---------- */
.empty-state { text-align: center; padding: 46px 20px 40px; }
.empty-art { font-size: 58px; margin-bottom: 14px; animation: sway 3.2s ease-in-out infinite; display: inline-block; }
@keyframes sway { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(5deg); } }
.empty-state h2 { font-size: 20px; margin-bottom: 10px; }
.empty-state p { font-size: 13px; color: var(--ink-soft); line-height: 1.9; }
.empty-actions { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 12px 22px; border-radius: 999px; font-size: 15px;
  transition: transform .12s, opacity .12s;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  background: var(--green); color: #f3efdd;
  box-shadow: 0 3px 12px rgba(47, 87, 64, .3);
  letter-spacing: 2px;
}
.btn-ghost {
  background: var(--card); border: 1px solid var(--line); color: var(--ink-soft);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-small { padding: 8px 14px; font-size: 13px; flex-shrink: 0; }

/* ---------- 子页面头 ---------- */
.sub-header {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 0 12px;
}
.sub-header h2 { font-size: 20px; letter-spacing: 2px; }
.back-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--line);
  font-size: 20px; color: var(--ink-soft); line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- 记录表单 ---------- */
.record-form { padding-bottom: 24px; }
.photo-area {
  position: relative; border: 2px dashed var(--line);
  border-radius: var(--radius); overflow: hidden;
  background: var(--card); margin-bottom: 18px;
  min-height: 220px; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.photo-placeholder { text-align: center; padding: 40px 20px; color: var(--ink-faint); }
.ph-icon { font-size: 40px; margin-bottom: 8px; }
.photo-placeholder p { font-size: 13px; letter-spacing: 1px; }
#photo-preview { width: 100%; display: block; }
.photo-retake {
  position: absolute; right: 10px; bottom: 10px;
  background: rgba(43, 53, 44, .75); color: #fff;
  padding: 7px 14px; border-radius: 999px; font-size: 12px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 7px; letter-spacing: 1px; }
.field label i { color: var(--amber); font-style: normal; }
.field input[type="text"], .field input[type="date"], .field textarea {
  width: 100%; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; font-size: 16px; color: var(--ink); /* 16px 起，避免 iOS 聚焦时页面缩放 */
  outline: none; transition: border-color .15s;
}
.field input:focus, .field textarea:focus { border-color: var(--green-soft); }
.field textarea { resize: vertical; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }
.place-row { display: flex; gap: 8px; }
.place-row input { flex: 1; min-width: 0; }
.gps-note { font-size: 11px; color: var(--ink-faint); margin-top: 5px; }
.ai-hint {
  font-size: 12px; color: var(--green-soft); margin-top: 6px;
}
.cat-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-picker .chip { flex-shrink: 0; }

/* ---------- 详情 ---------- */
.detail-hero {
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); background: var(--card);
  border: 1px solid var(--line);
}
.detail-hero img { width: 100%; display: block; max-height: 420px; object-fit: cover; }
.detail-hero .hero-ph {
  aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center;
  font-size: 80px; background: var(--green-wash);
}
.detail-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-top: 14px;
}
.detail-name { font-size: 24px; }
.detail-latin { font-style: italic; color: var(--ink-faint); font-size: 13px; margin-top: 4px; }
.detail-tags { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.detail-tags .tag {
  background: var(--green-wash); color: var(--green);
  font-size: 12px; padding: 4px 11px; border-radius: 999px;
}
.detail-tags .tag.amber { background: var(--amber-wash); color: var(--amber); }
.encounter-list { margin-top: 14px; }
.encounter-list h3 { font-size: 14px; color: var(--ink-soft); margin-bottom: 10px; letter-spacing: 1px; }
.encounter-item {
  display: flex; gap: 12px; padding: 11px 0;
  border-top: 1px dashed var(--line); align-items: flex-start;
}
.encounter-item:first-of-type { border-top: none; }
.enc-item-date { font-family: "Noto Serif SC", serif; font-size: 14px; color: var(--green); flex-shrink: 0; min-width: 86px; }
.enc-item-body { flex: 1; min-width: 0; }
.enc-item-place { font-size: 13px; color: var(--ink-soft); }
.enc-item-note { font-size: 12px; color: var(--ink-faint); margin-top: 3px; line-height: 1.6; word-break: break-all; }
.enc-item-del { font-size: 12px; color: var(--ink-faint); flex-shrink: 0; padding: 2px 6px; }
.enc-item-del:hover { color: var(--danger); }
.detail-actions { display: flex; gap: 10px; margin-top: 16px; }
.detail-actions .btn { flex: 1; text-align: center; }

/* ---------- 成就 ---------- */
.achieve-summary {
  margin-top: 16px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px;
}
.achieve-summary .bar-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.achieve-summary .bar {
  flex: 1; height: 8px; background: var(--paper-deep);
  border-radius: 999px; overflow: hidden;
}
.achieve-summary .bar i {
  display: block; height: 100%; background: var(--green);
  border-radius: 999px; transition: width .6s ease;
}
.achieve-summary .bar-label { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

.badge-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  padding-bottom: 10px;
}
.badge {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 8px 13px; text-align: center; position: relative;
}
.badge .b-icon {
  width: 52px; height: 52px; margin: 0 auto 8px; border-radius: 50%;
  background: var(--paper-deep); display: flex; align-items: center; justify-content: center;
  font-size: 26px; filter: grayscale(1); opacity: .45;
}
.badge.unlocked .b-icon {
  background: var(--green-wash); filter: none; opacity: 1;
  box-shadow: 0 0 0 3px rgba(74, 122, 92, .18);
}
.badge .b-name { font-size: 13px; font-family: "Noto Serif SC", serif; font-weight: 600; }
.badge .b-desc { font-size: 10px; color: var(--ink-faint); margin-top: 3px; line-height: 1.5; }
.badge .b-date { font-size: 10px; color: var(--green-soft); margin-top: 4px; }
.badge.unlocked::after {
  content: "✓"; position: absolute; top: 7px; right: 9px;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--green); color: #f3efdd; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 560px;
  background: rgba(255, 253, 246, .92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-around;
  padding: 8px 0 calc(10px + env(safe-area-inset-bottom));
  z-index: 50;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--ink-faint); padding: 4px 18px;
  letter-spacing: 1px;
}
.tab.active { color: var(--green); }
.tab-icon { font-size: 21px; }
.tab-record {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--green); color: #f3efdd;
  font-size: 28px; display: flex; align-items: center; justify-content: center;
  margin-top: -30px;
  box-shadow: 0 4px 14px rgba(47, 87, 64, .4), inset 0 0 0 3px rgba(243,239,221,.25);
  transition: transform .12s;
}
.tab-record:active { transform: scale(.92); }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(43, 53, 44, .55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadein .2s ease;
}
.modal-card {
  background: var(--card); border-radius: 18px;
  width: 100%; max-width: 400px; max-height: 92vh;
  padding: 18px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
  display: flex; flex-direction: column;
}
.modal-scroll { overflow-y: auto; flex: 1; }
#share-preview { width: 100%; border-radius: 10px; display: block; box-shadow: var(--shadow); }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; justify-content: center; }
.confirm-card { max-width: 320px; }
.confirm-card p { text-align: center; font-size: 15px; line-height: 1.7; padding: 10px 0 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%) translateY(20px);
  background: rgba(43, 53, 44, .92); color: #f3efdd;
  padding: 11px 22px; border-radius: 999px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .25s ease;
  z-index: 200; max-width: 84vw; text-align: center;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 收录成功动效 */
@keyframes pop-in {
  0% { transform: scale(.6); opacity: 0; }
  70% { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}
.pop-in { animation: pop-in .4s ease; }

/* ---------- 分享提示 & 支持/推荐 ---------- */
.share-hint {
  font-size: 11px; color: var(--ink-faint); text-align: center;
  margin-top: 9px; line-height: 1.6;
}
.support-row { display: flex; gap: 10px; margin-top: 14px; }
.support-row .btn { flex: 1; font-size: 13px; padding: 10px 8px; }
#support-img { width: 200px; display: block; margin: 0 auto; border-radius: 10px; }
.support-placeholder {
  text-align: center; color: var(--ink-faint); font-size: 13px;
  line-height: 1.9; padding: 10px 4px;
}
