/* ============================================================
   生命探索 · LIFE PROBE — H5
   暗场 / 仪器质感 / 琥珀 + 荧光绿
   ============================================================ */

:root {
  --ink:        #070a08;
  --ink-1:      #0a0f0c;
  --ink-2:      #101713;
  --line:       rgba(168, 208, 178, 0.13);
  --line-2:     rgba(168, 208, 178, 0.26);
  --line-3:     rgba(180, 225, 195, 0.42);
  --text:       #eaf0e8;
  --muted:      rgba(214, 228, 216, 0.56);
  --faint:      rgba(214, 228, 216, 0.32);
  --amber:      #e8ab54;
  --amber-2:    #f6cf92;
  --amber-dim:  rgba(232, 171, 84, 0.14);
  --mint:       #8ceab4;
  --mint-dim:   rgba(140, 234, 180, 0.12);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --pad: clamp(24px, 7vw, 40px);
  /* 各步主操作键的统一高度：01/02/03 共用，避免靠 padding 撑出不同高度 */
  --btn-h: clamp(48px, 5.4vh, 68px);
  /* 按钮字号：全站主操作键共用一套，文字按钮用小一号的 --btn-fs-sm */
  --btn-fs: clamp(13px, 2.6vw, 22px);
  --btn-fs-sm: clamp(11px, 2.2vw, 17px);
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
}

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

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  overscroll-behavior: none;
}

body { overflow: hidden; }

#app {
  position: fixed; inset: 0;
  overflow: hidden;
  isolation: isolate;
}

/* ---------------------------------------------------------- 背景层 */
.bg-glow, .bg-grid, .bg-vignette { position: absolute; inset: 0; pointer-events: none; }

/* 中性辉光：原来是两团绿（rgba(72,138,96) / rgba(48,96,78)），
   画布 alpha 透明，标本背后直接透出这层绿，看起来像环境光在染绿。 */
.bg-glow {
  background:
    radial-gradient(70% 46% at 50% 8%,  rgba(255, 255, 255, 0.055) 0%, transparent 62%),
    radial-gradient(52% 40% at 82% 84%, rgba(232, 171, 84, 0.07) 0%, transparent 66%),
    radial-gradient(60% 50% at 12% 70%, rgba(255, 255, 255, 0.04) 0%, transparent 70%);
  transition: opacity 0.8s var(--ease);
}

.bg-grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 42%, #000 8%, transparent 70%);
  -webkit-mask-image: radial-gradient(circle at 50% 42%, #000 8%, transparent 70%);
  opacity: 0.9;
}

.bg-vignette {
  background: radial-gradient(120% 90% at 50% 50%, transparent 42%, rgba(0, 0, 0, 0.72) 100%);
}

/* 进入生态空间时背景整体偏绿 */
#app[data-screen="garden"] .bg-glow { opacity: 0.55; }
#app[data-screen="garden"] .bg-grid { opacity: 0.25; }
#app[data-screen="model"] .bg-grid,
#app[data-screen="release"] .bg-grid { opacity: 0.35; }

/* ---------------------------------------------------------- HUD */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 40;
  display: none;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) var(--pad) 0;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.hud-left { display: flex; align-items: center; gap: 8px; color: var(--faint); }
.mark { width: 13px; height: 13px; color: var(--mint); opacity: 0.85; display: block; }
.mark svg { width: 100%; height: 100%; display: block; }
.mark-text i { font-style: normal; opacity: 0.55; margin-left: 6px; }

.hud-right { display: flex; align-items: center; gap: 10px; color: var(--faint); }
.hud-step { color: var(--line-3); }
.hud-title { color: var(--muted); }
.hud-title::before { content: "/"; margin-right: 8px; opacity: 0.4; }

/* ---------------------------------------------------------- 屏幕 */
#stage { position: absolute; inset: 0; }

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: scale(1.015);
  transition: opacity 0.34s var(--ease), transform 0.34s var(--ease);
  overflow: hidden;
}
.screen.is-active { opacity: 1; visibility: visible; transform: none; }

/* 离场的屏幕立刻收干净。遮罩只压 240ms 就抬起来了，如果离场屏还在做 0.6s 的淡出，
   抬罩那一刻画面会是「旧屏半透明 + 新屏半透明」的混合——看到的就是旧屏闪一下
   （比如开场那屏的琥珀色粒子云忽然铺满）。进场仍然保留淡入。 */
.screen:not(.is-active) { transition: none; }

.pad {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 var(--pad);
}

.center-col {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  gap: 0;
  padding-bottom: 6vh;
}

.overlay-top {
  position: absolute; top: 0; left: 0; right: 0;
  padding-top: calc(env(safe-area-inset-top, 0px) + 58px);
  pointer-events: none;
}
.overlay-bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 30px);
  display: flex; flex-direction: column; gap: 14px;
}
.overlay-top > *, .overlay-bottom > * { pointer-events: auto; }


/* ---------------------------------------------------------- 排版 */
.display {
  font-size: clamp(56px, 17vw, 80px);
  line-height: 0.98;
  font-weight: 300;
  letter-spacing: 0.06em;
  margin: 18px 0 0;
  background: linear-gradient(175deg, #f4f7f0 12%, #b9c8ba 76%, #7d8e80 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

.headline {
  font-size: clamp(22px, 6.4vw, 27px);
  line-height: 1.42;
  font-weight: 300;
  letter-spacing: 0.02em;
  margin: 20px 0 0;
  color: #eef3ec;
}
.headline.sm { font-size: clamp(21px, 6vw, 25px); }

.hint-line {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.7;
  letter-spacing: 0.03em;
  color: rgba(214, 228, 216, 0.34);
  margin: 14px 0 0;
}
.hint-line.tiny { font-size: 9.5px; margin: 2px 0 0; text-align: center; letter-spacing: 0.08em; }
.hint-line code {
  font-family: var(--mono);
  color: var(--mint);
  opacity: 0.7;
  font-size: 10px;
}


.step-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.24em;
  color: rgba(140, 234, 180, 0.5);
  text-transform: uppercase;
}
.step-tag::before {
  content: ""; display: inline-block; width: 14px; height: 1px;
  background: currentColor; vertical-align: middle; margin-right: 8px; opacity: 0.7;
}


/* ---------------------------------------------------------- 按钮 */
.btn {
  appearance: none;
  border: 1px solid var(--line-2);
  background: rgba(14, 22, 18, 0.5);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.14em;
  padding: 15px 24px;
  border-radius: 3px;
  width: 100%;
  cursor: pointer;
  transition: all 0.34s var(--ease);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-primary {
  border-color: rgba(232, 171, 84, 0.42);
  background: linear-gradient(180deg, rgba(232, 171, 84, 0.16), rgba(232, 171, 84, 0.05));
  color: var(--amber-2);
}
.btn-primary:not(:disabled):hover { border-color: rgba(232, 171, 84, 0.7); background: rgba(232, 171, 84, 0.2); }

/* 采集屏「开始记录」：跟开始屏、放置屏共用同一档主操作键外观
   （白实心 + 胶囊圆角 + 黑字）。id 选择器压过 .btn-primary 的琥珀色。 */
.cap-foot #btn-shoot {
  display: flex; align-items: center; justify-content: center;
  /* 尺寸也跟开始屏对齐：大屏下别被 .cap-foot .btn 的 860px 拉宽 */
  width: min(440px, 100%); max-width: 440px; margin: 0 auto;
  border: 1px solid transparent; border-radius: 999px;
  background: #ffffff; color: #0b0f0d;
  height: var(--btn-h); padding: 0 32px;
  font-family: inherit;
  font-size: calc(var(--btn-fs) * 1.3); font-weight: 600; letter-spacing: .14em;
  /* .btn 底子上的毛玻璃会把白底糊成半透明，这里关掉 */
  backdrop-filter: none; -webkit-backdrop-filter: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background .28s, color .28s, opacity .28s, border-color .28s, box-shadow .28s,
              transform .28s cubic-bezier(.2, .7, .3, 1);
}
.cap-foot #btn-shoot:not(:disabled):hover,
.cap-foot #btn-shoot:focus-visible {
  outline: none; background: #eef2ef;
  box-shadow: 0 6px 26px #ffffff2e; transform: translateY(-1px);
}
/* 按下态：跟未选中/禁用时同一个观感 —— 整体压到 30% 不透明度 */
.cap-foot #btn-shoot:active,
.cap-foot #btn-shoot.is-pressed {
  transform: scale(.93) translateY(2px);
  opacity: .3;
}

/* 采集屏「开始生成标本」：与主操作键同尺寸/圆角/字重，配色为橄榄绿实心 + 淡描边 + 白字 */
.cap-foot #btn-scan {
  display: flex; align-items: center; justify-content: center;
  width: min(440px, 100%); max-width: 440px; margin: 0 auto;
  border: 1px solid rgba(150, 166, 142, 0.55); border-radius: 999px;
  background: #43503a; color: #ffffff;
  height: var(--btn-h); padding: 0 32px;
  font-family: inherit;
  font-size: calc(var(--btn-fs) * 1.3); font-weight: 600; letter-spacing: .14em;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background .28s, color .28s, opacity .28s, border-color .28s,
              transform .28s cubic-bezier(.2, .7, .3, 1);
}
.cap-foot #btn-scan:not(:disabled):hover,
.cap-foot #btn-scan:focus-visible {
  outline: none; background: #4d5c43;
  border-color: rgba(168, 184, 160, 0.75);
  transform: translateY(-1px);
}
/* 按下态与另外三颗主操作键一致：整体压到 30% 不透明度 */
.cap-foot #btn-scan:active,
.cap-foot #btn-scan.is-pressed {
  transform: scale(.93) translateY(2px);
  opacity: .3;
}

.btn-solid {
  border-color: var(--line-3);
  background: rgba(28, 42, 34, 0.72);
}


/* 「查看标本」预载模型期间：按钮转圈（覆盖 disabled 的低透明度） */
.btn.is-loading { opacity: 0.9; cursor: progress; pointer-events: none; }
.btn.is-loading .spin {
  display: inline-block;
  width: 13px; height: 13px;
  margin-right: 10px;
  border: 2px solid rgba(232, 171, 84, 0.28);
  border-top-color: var(--amber-2, #e8ab54);
  border-radius: 50%;
  vertical-align: -2px;
  animation: btn-spin 0.8s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.btn-link {
  border: none; background: none; color: var(--faint);
  font-size: 11px; letter-spacing: 0.18em; padding: 10px;
}
.btn-link:hover { color: var(--muted); }


.hidden { display: none !important; }


/* ---------------------------------------------------------- 取景 */
.viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin: 24px 0 0;
  border: 1px solid var(--line);
  background: #050807;
  overflow: hidden;
  isolation: isolate;
}
#cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.6s; }
#cam.on { opacity: 0.55; filter: saturate(0.7) contrast(1.1) brightness(0.75); }

/* 已采集的照片直接铺进取景框，盖掉相机预览与占位虫 */
.vf-photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s;
}
.vf-photo.on { opacity: 1; }
.viewfinder.has-photo .vf-hint { opacity: 0; }

.vf-corner { position: absolute; width: 18px; height: 18px; border: 1px solid rgba(140, 234, 180, 0.55); }
.vf-corner.a { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.vf-corner.b { top: 10px; right: 10px; border-left: 0; border-bottom: 0; }
.vf-corner.c { bottom: 10px; left: 10px; border-right: 0; border-top: 0; }
.vf-corner.d { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }

.vf-cross { position: absolute; top: 50%; left: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%); opacity: 0.5; }
.vf-cross::before, .vf-cross::after {
  content: ""; position: absolute; background: rgba(190, 230, 200, 0.7);
}
.vf-cross::before { left: 50%; top: 0; width: 1px; height: 100%; }
.vf-cross::after { top: 50%; left: 0; height: 1px; width: 100%; }

.vf-meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em;
  color: rgba(200, 228, 208, 0.62);
  background: linear-gradient(0deg, rgba(0,0,0,0.62), transparent);
}
.rec { display: inline-flex; align-items: center; gap: 5px; }
.rec i { width: 5px; height: 5px; border-radius: 50%; background: #e8604a; animation: blink 1.4s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.15; } }

.vf-hint {
  position: absolute; left: 0; right: 0; bottom: 32px;
  text-align: center;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em;
  color: rgba(200, 228, 208, 0.4);
  transition: opacity 0.5s;
}

.viewfinder.flash::after {
  content: ""; position: absolute; inset: 0; background: #fff;
  animation: flash 0.5s ease-out forwards;
}
@keyframes flash { 0% { opacity: 0.86; } 100% { opacity: 0; } }

[data-screen="capture"] .btn { margin-top: 16px; }


/* ---------------------------------------------------------- 扫描 */
/* 扫描画布：观察盒与光束常驻，点云完成后浮现 */
.scan-canvas { opacity: 1; pointer-events: auto; }
[data-screen="scanning"] .scan-head { z-index: 3; pointer-events: none; }

/* 标题下的副标题 */
.scan-sub {
  margin: 6px 0 0;
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.14em;
  color: rgba(190, 230, 200, 0.42);
}

/* 状态区：左侧 agent 阶段步骤列表 + 备注行，右侧大读数 26% */
.scan-status {
  /* 大读数贴着左列底部对齐，同一视觉重心 */
  display: flex; align-items: flex-end; gap: 10px;
  /* 贴在底部主按钮上方，左右与按钮内文字对齐（按钮有 24px 内边距） */
  position: absolute; top: auto;
  left: calc(8% + 24px); right: calc(8% + 24px);
  bottom: calc(54px + var(--btn-h) + 86px);
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.14em;
  color: rgba(190, 230, 200, 0.62);
  text-align: left;
  pointer-events: none;
}
.scan-steps-wrap {
  display: flex; flex-direction: column; gap: 7px;
  min-width: 0;
}
/* agent 工作阶段：滚动式读数。窗口只露一行，完成一个阶段整行
   向上滚出、下一阶段滚进来（连续跳阶段时逐条滚，不生硬跳变） */
.scan-steps {
  position: relative;
  height: 1.55em; overflow: hidden;
  font-size: 0.82em;
}
.scan-steps-roll {
  transition: transform 0.45s var(--ease);
  will-change: transform;
}
.scan-steps-roll span {
  display: flex; align-items: center; gap: 9px;
  height: 1.55em; line-height: 1.55em;
  color: rgba(190, 230, 200, 0.85);
  white-space: nowrap;
}
.scan-steps-roll span i {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--mint);
  box-shadow: 0 0 9px rgba(140, 234, 180, 0.65);
  animation: blink 1.6s infinite;
}
.scan-note { font-size: 0.82em; color: rgba(190, 230, 200, 0.42); }
/* 百分比是这一屏的主读数：单独拉大，标签保持小字 */
.scan-status b {
  margin-left: auto; font-weight: 300;
  font-size: clamp(30px, 9vw, 120px);
  line-height: 0.9; letter-spacing: 0;
  color: var(--mint); font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(140, 234, 180, 0.35);
}
.scan-status b i {
  font-style: normal; font-size: 0.4em; font-weight: 400;
  letter-spacing: 0.04em; margin-left: 0.08em; opacity: 0.75;
}

.scan-actions .btn:disabled { opacity: 0.42; }

/* 完成态提示，压在点云下方 */

/* 底部唯一的主按钮：扫描中 → 查看标本 */
.scan-actions {
  position: absolute; left: 8%; right: 8%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 54px);
  display: flex; gap: 10px;
}
.scan-actions .btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px 12px; font-size: 12.5px; letter-spacing: 0.16em;
  background: rgba(10, 16, 13, 0.72);
}
.scan-actions .btn em { font-style: normal; font-size: 11px; opacity: 0.55; }

/* 扫描屏这颗按钮：形状/尺寸/字重与其它主操作键完全一致（胶囊 + 大字号），
   只是按状态换配色 —— 「生成中」灰，「查看标本」橄榄绿 */
.scan-actions #btn-scan-next {
  flex: 0 1 auto;
  width: min(440px, 100%); max-width: 440px;
  margin: 0 auto;
  height: var(--btn-h);
  padding: 0 32px;
  border-radius: 999px;
  font-size: calc(var(--btn-fs) * 1.3);
  font-weight: 600; letter-spacing: .14em;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  transition: background .28s, color .28s, border-color .28s, opacity .28s,
              transform .28s cubic-bezier(.2, .7, .3, 1);
}
/* 「生成中」= 和前面几颗按钮禁用时同一个灰色观感：
   白胶囊整体压到 30% 不透明度（同 .btn:disabled），不是描边款 */
.scan-actions #btn-scan-next:disabled {
  background: #ffffff;
  border-color: transparent;
  color: #0b0f0d;
  opacity: .3;
}
.scan-actions #btn-scan-next:not(:disabled) {
  background: #43503a;
  border-color: rgba(150, 166, 142, 0.55);
  color: #ffffff;
}
.scan-actions #btn-scan-next:not(:disabled):hover {
  background: #4d5c43;
  border-color: rgba(168, 184, 160, 0.75);
}
.scan-actions #btn-scan-next:not(:disabled):active {
  transform: scale(.93) translateY(2px);
}

/* ---------------------------------------------------------- 3D 画布 */
.stage-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

/* 05 标本屏：真实森林底图（对齐 LUMEN model-gauze-notes 的背景），
   上面压一层暗角光晕保证文字可读，程序化树枝只留很低的一层做层次 */
[data-screen="model"] {
  background:
    radial-gradient(120% 82% at 50% 46%, rgba(4, 9, 8, 0.08) 0%, rgba(4, 9, 8, 0.42) 62%, rgba(3, 7, 6, 0.78) 100%),
    #09100d url("../assets/model-forest.webp") center / cover no-repeat;
}

/* 07 发布屏：深色雾 + 正中一点微光，树枝由 #cv-release-forest 画在底下一层，
   粒子仍是画面主体，背景往后沉 */
[data-screen="release"] {
  background:
    radial-gradient(88% 54% at 50% 34%, rgba(96, 176, 138, 0.10) 0%, rgba(8, 16, 13, 0) 62%),
    radial-gradient(130% 92% at 50% 52%, rgba(4, 9, 8, 0) 0%, rgba(3, 7, 6, 0.62) 68%, rgba(2, 5, 4, 0.92) 100%),
    linear-gradient(180deg, #0c1714 0%, #070e0b 52%, #040806 100%);
}

.forest-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block; pointer-events: none;
  opacity: 0.32; z-index: 0;
}
/* 07 发布屏：林地只做暗底衬托，别盖过点云 */
[data-screen="release"] .forest-bg { opacity: 0.38; }
[data-screen="release"][data-kind="ground"] .forest-bg { opacity: 0.08; }
[data-screen="model"] .stage-canvas,
[data-screen="release"] .stage-canvas { z-index: 1; }

/* 07 的按钮必须压在画布之上：画布铺满全屏且 pointer-events 默认接管，
   之前 overlay 没有 z-index，点「去看图谱 / 再放一只」其实全落在 canvas 上 */
[data-screen="release"] .overlay-bottom {
  z-index: 3;
  pointer-events: none;   /* 容器本身不挡画布，按钮自己 pointer-events:auto */
}

/* ---------------------------------------------------------- 05 标本 · 分散字段 */
.mfield {
  position: absolute; z-index: 2;
  width: 42%;
  font-family: var(--mono);
  pointer-events: none;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.85);
}
.mfield h4 {
  margin: 0 0 6px;
  font-size: 7px; font-weight: 400; letter-spacing: 0.18em;
  color: rgba(190, 230, 200, 0.72);
  white-space: nowrap;
}
.mfield h4::before {
  content: "•"; margin-right: 5px;
  color: rgba(140, 234, 180, 0.6);
}
.mfield h4 i {
  display: inline; margin-left: 6px; font-style: normal;
  font-size: 7.5px; letter-spacing: 0.14em; color: rgba(190, 230, 200, 0.34);
}
.mfield dl { margin: 0; display: grid; gap: 2.5px; }
.mfield dl > div {
  /* 用网格的 max-content 列：同一块里所有数值左边缘对齐，不会再一行一个起点 */
  display: grid; grid-template-columns: max-content 1fr; align-items: baseline; column-gap: 7px;
  font-size: 6.5px; line-height: 1.5;
}
.mfield dt { color: rgba(190, 230, 200, 0.3); white-space: nowrap; }
.mfield dd { margin: 0; color: rgba(226, 238, 228, 0.72); text-align: left; overflow-wrap: anywhere; }
.mfield .m-notes-text,
.mfield p { margin: 0; font-size: 6.5px; line-height: 1.65; color: rgba(226, 238, 228, 0.72); overflow-wrap: anywhere; }

/* 八块散落：照参考稿（01-specimen）的错落——字很小、绕着标本四周边走，
   中间留给模型本体。位置不用对齐网格，看起来是排过的。 */
.m-encounter  { top: 8%;  left: 36%; width: 38%; }
.m-identity   { top: 22%; left: 5%;  width: 34%; }
.m-light      { top: 30%; right: 6%; width: 38%; }
.m-atmos      { top: 37%; left: 4%;  width: 34%; }
.m-morphology { top: 60%; left: 5%;  width: 36%; }
.m-ecology    { top: 56%; right: 8%; width: 36%; }
.m-habitat    { bottom: 14%; left: 5%; width: 40%; }
.m-notes      { bottom: 3%;  left: 5%; width: 42%; }

/* 顶部只有眉标 + 昆虫名 */
/* 顶部/底部覆盖层压在字段之上，保证按钮与徽标可点、可读 */
[data-screen="model"] .overlay-bottom { z-index: 3; }
[data-screen="model"] .model-head { z-index: 3; pointer-events: none; }

/* 05 标本屏「收藏这次相遇」：与其它主操作键同款胶囊（同高/同字号/同字重），
   填充换成蜜桃黄、字用深棕 */
#app [data-screen="model"] .overlay-bottom .btn-primary {
  width: min(440px, 100%); max-width: 440px;
  margin: 0 auto;
  height: var(--btn-h);
  padding: 0 32px;
  border: 1px solid transparent; border-radius: 999px;
  background: #fdc38a; color: #6b3f14;
  font-size: calc(var(--btn-fs) * 1.3);
  font-weight: 600; letter-spacing: .14em;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  transition: background .28s, color .28s, opacity .28s, border-color .28s,
              transform .28s cubic-bezier(.2, .7, .3, 1);
}
#app [data-screen="model"] .overlay-bottom .btn-primary:not(:disabled):hover {
  background: #ffd0a3; border-color: transparent; transform: translateY(-1px);
}
#app [data-screen="model"] .overlay-bottom .btn-primary:active {
  transform: scale(.93) translateY(2px); opacity: .3;
}
[data-screen="release"] .release-head { z-index: 2; pointer-events: none; }


/* ---------------------------------------------------------- 命名 */
/* 命名屏：内容较多，独立排一次版 */
[data-screen="naming"] { overflow-y: auto; }
[data-screen="naming"] .pad {
  padding-top: calc(env(safe-area-inset-top, 0px) + 76px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 34px);
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
[data-screen="naming"] { overflow-y: auto; }
[data-screen="naming"] .headline { margin-top: 16px; }
[data-screen="naming"] .data-list { margin-bottom: auto; }
/* 06 档案：与 05 等页统一为左对齐（标签列 + 值紧跟），不再两端拉开 */
[data-screen="naming"] .data-row { justify-content: flex-start; gap: 12px; }
[data-screen="naming"] .data-row span { flex: none; width: 84px; }
[data-screen="naming"] .data-row b {
  max-width: none; flex: 1; text-align: left; overflow-wrap: anywhere;
}
[data-screen="naming"] .btn-primary { margin-top: 26px; margin-bottom: 26px; }

/* 采集屏标题：位置/字体/字距/颜色统一由 css/place-cocoon.css 提供，
   与 place 屏共用同一份声明；此处只补层级与事件穿透 */
[data-screen="capture"] .capture-head { z-index: 2; pointer-events: none; }

/* 各屏标题 / 副标题统一：标题 24px 加粗，副标题 20px 浅灰。
   加 #app 提高权重，压过 place-cocoon.css 里共用的 [data-screen] 声明。 */
#app .place-title,
#app .capture-title,
#app .release-title,
#app .scan-title {
  font-size: 24px;
  font-weight: 600;
}
/* 05 标本屏的标本名单独用 20px */
#app .model-title {
  font-size: 20px;
  font-weight: 600;
}
/* 07 放归屏：副标题不换行，放同一排（标题区加宽，字距收一点） */
#app [data-screen="release"] .release-head {
  max-width: 88%;
}
#app [data-screen="release"] .release-sub {
  letter-spacing: .02em;
}
#app .capture-sub,
#app .release-sub,
#app .scan-sub,
#app .model-sub {
  font-size: 20px;
  color: #c9c9c9;
}

/* 采集屏内容：在标题与底部按钮之间居中，取景框不压缩，文案与取景框拉开间距 */
[data-screen="capture"] .center-col { padding-top: 15vh; padding-bottom: 12vh; }
[data-screen="capture"] .viewfinder { flex: 0 0 auto; }
[data-screen="capture"] .hint-line { margin-top: 20px; }
[data-screen="capture"] #upload-hint:empty { display: none; }

/* 采集屏主按钮：与 place 屏「已完成放置」同位置（left/right 8%、bottom 7%、440px 居中） */
[data-screen="capture"] .cap-foot {
  position: absolute; left: 8%; right: 8%; bottom: 7%;
  z-index: 2;
}
[data-screen="capture"] .cap-foot .btn {
  display: flex; align-items: center; justify-content: center;
  width: min(440px, 100%); max-width: 440px; margin: 0 auto;
  height: var(--btn-h); padding: 0 24px;
}
/* 「重新拍摄」：纯文字，跟在主按钮下面，和发布屏那几个文字按钮一个调子 */
[data-screen="capture"] .cap-foot #btn-retake {
  height: auto;
  margin: 12px auto 0;
  padding: 10px 24px;
  font-size: var(--btn-fs-sm);
  letter-spacing: 0.18em;
  color: rgba(214, 228, 216, 0.36);
}
[data-screen="capture"] .cap-foot #btn-retake:hover { color: var(--muted); }
/* 「上传照片」：和重新拍摄同排同调，垫在快门/生成按钮下面 */
[data-screen="capture"] .cap-foot #btn-upload {
  height: auto;
  margin: 0 auto;
  padding: 10px 24px;
  font-size: var(--btn-fs-sm);
  letter-spacing: 0.18em;
  color: rgba(214, 228, 216, 0.36);
}
[data-screen="capture"] .cap-foot #btn-upload:hover { color: var(--muted); }


.data-list {
  margin: 30px 0 26px;
  border-top: 1px solid var(--line);
}
.data-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.data-row span { color: rgba(214, 228, 216, 0.4); font-weight: 300; }
.data-row b { font-weight: 400; color: rgba(232, 240, 232, 0.86); font-family: var(--mono); font-size: 11px; letter-spacing: 0.03em; }

/* ---------------------------------------------------------- 放飞 */
/* 「确认放归」：与前面主操作键同款胶囊（同高/同字号/同字重），
   填充用橄榄绿 + 淡描边 + 白字，替掉原来的薄荷色描边长条 */
#app [data-screen="release"] .btn-release {
  display: flex; align-items: center; justify-content: center;
  width: min(440px, 100%); max-width: 440px;
  margin: 0 auto;
  height: var(--btn-h);
  padding: 0 32px;
  border: 1px solid rgba(150, 166, 142, 0.55); border-radius: 999px;
  background: #43503a;
  color: #ffffff;
  font-family: inherit;
  font-size: calc(var(--btn-fs) * 1.3);
  font-weight: 600; letter-spacing: .14em; text-indent: 0;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  transition: background .28s, border-color .28s, opacity .28s,
              transform .28s cubic-bezier(.2, .7, .3, 1);
}
#app [data-screen="release"] .btn-release::after { display: none; }
#app [data-screen="release"] .btn-release:hover {
  background: #4d5c43;
  border-color: rgba(168, 184, 160, 0.75);
}
#app [data-screen="release"] .btn-release:active {
  transform: scale(.93) translateY(2px); opacity: .3;
}
.btn-release span { position: relative; z-index: 2; }

/* 发布屏的「再放一只」：比通用 btn-link 大一号、也亮一点，容易点到 */
#rel-again {
  font-size: var(--btn-fs);
  letter-spacing: 0.18em;
  color: var(--muted);
}
#rel-again:hover { color: var(--text); }

/* 03 采集 / 07 放归 的副标题：换行、左对齐、小一号 */
.capture-sub,
.release-sub {
  margin: 8px 0 0;
  font-size: clamp(11px, 1.5vw, 15px);
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: left;
}

/* 07 放归页的标本铭牌：名字大一号，相遇时间 / 体长小一号 */
.release-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  align-self: center;
  width: max-content;
  max-width: 100%;
  /* 上移一点，离按钮留出呼吸；容器贴底，加底边距即整体抬高 */
  margin: 0 auto 76px;
  padding: 10px 18px;
  /* 用和标题一样的 sans 字体：mono 栈里没有中文字体，
     Windows 上中文会回退成宋体 */
  font-family: var(--sans);
  color: var(--muted);
  text-align: center;
}
.release-card b {
  margin-bottom: 8px;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--text);
}
/* 相遇时间 / 体长：与上面标本名同色同档，不再逐级变灰 */
.release-card span {
  font-size: 20px;
  letter-spacing: 0.05em;
  line-height: 1.6;
  color: var(--text);
}
/* display:flex 会盖掉 UA 的 [hidden]，显式补回来 */
.release-card[hidden] { display: none; }

/* ---------------------------------------------------------- 生态空间 */
.garden-fallback {
  position: absolute; inset: 0;
  background:
    radial-gradient(44% 24% at 20% 76%, rgba(78, 168, 102, 0.34), transparent 66%),
    radial-gradient(40% 22% at 80% 38%, rgba(56, 128, 96, 0.30), transparent 64%),
    radial-gradient(58% 28% at 52% 18%, rgba(40, 98, 70, 0.22), transparent 70%),
    radial-gradient(74% 46% at 50% 106%, rgba(36, 100, 62, 0.52), transparent 72%),
    linear-gradient(180deg, #060d09 0%, #040a07 62%, #020605 100%);
  animation: gardenBreath 12s ease-in-out infinite;
}
.garden-fallback::before {
  content: "";
  position: absolute; left: -20%; right: -20%; bottom: -10%; height: 62%;
  background:
    radial-gradient(30% 60% at 22% 100%, rgba(96, 190, 124, 0.20), transparent 70%),
    radial-gradient(26% 52% at 62% 96%, rgba(70, 160, 110, 0.16), transparent 72%),
    radial-gradient(34% 46% at 88% 100%, rgba(120, 200, 130, 0.14), transparent 70%);
  filter: blur(22px);
  animation: gardenDrift 22s ease-in-out infinite alternate;
}
@keyframes gardenDrift {
  from { transform: translateX(-2%) scaleY(1); }
  to   { transform: translateX(3%) scaleY(1.08); }
}
@keyframes gardenBreath { 0%,100% { opacity: 0.9; } 50% { opacity: 1; } }

.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

/* 有 assets/media/space.mp4 就自动变成视频背景 */
.garden-video-slot { position: absolute; inset: 0; overflow: hidden; }
.garden-video-slot video {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0.55;
  filter: saturate(0.9) contrast(1.05) brightness(0.85);
}

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  z-index: 30;
  transform: translateY(110%);
  transition: transform 0.5s var(--ease);
  background: rgba(8, 14, 11, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--line-2);
  padding: 10px var(--pad) calc(env(safe-area-inset-bottom, 0px) + 26px);
  border-radius: 12px 12px 0 0;
  max-width: 520px;
  margin: 0 auto;
}
.sheet.on { transform: none; }
.sheet-grip { width: 34px; height: 2px; background: var(--line-2); margin: 4px auto 16px; border-radius: 2px; }
.sheet-body h3 { margin: 0 0 14px; font-size: 20px; font-weight: 300; letter-spacing: 0.04em; }

/* ---------------------------------------------------------- 模态 */
.modal {
  position: absolute; inset: 0; z-index: 80;
  display: grid; place-items: center;
  padding: var(--pad);
  background: rgba(4, 7, 5, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0; visibility: hidden;
  transition: opacity 0.4s var(--ease), visibility 0.4s;
}
.modal.on { opacity: 1; visibility: visible; }

/* ---------------------------------------------------------- 转场遮罩 */
.veil {
  position: absolute; inset: 0; z-index: 90;
  background: #040705;
  opacity: 0; visibility: hidden;
  /* 压罩必须比切屏（go() 里等 280ms）快，否则换屏时遮罩还没盖住，
     会看到半透明的旧屏；抬罩保持同样节奏，显得利落 */
  transition: opacity 0.24s var(--ease), visibility 0.24s;
  display: grid; place-items: center;
  pointer-events: none;
}
.veil.on { opacity: 1; visibility: visible; pointer-events: all; }
.veil-line {
  width: 90px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--mint), transparent);
  animation: veilRun 1.4s ease-in-out infinite;
}
@keyframes veilRun { 0%,100% { transform: scaleX(0.3); opacity: 0.4; } 50% { transform: scaleX(1); opacity: 1; } }

/* ---------------------------------------------------------- 页内图谱层
   放归后不再跳新标签页：整屏 iframe 铺满，竖屏全屏的小主机也不用切窗口 */
.gallery-layer {
  position: absolute; inset: 0; z-index: 120;
  background: #040705;
  opacity: 0; visibility: hidden;
  transition: opacity .3s var(--ease), visibility .3s;
}
.gallery-layer.on { opacity: 1; visibility: visible; }
.gallery-layer iframe {
  width: 100%; height: 100%; border: 0; display: block;
  /* 图谱本身要能用：点虫子、WASD 换虫子、Enter 进模型展示界面，
     键盘和指针都直接交给 iframe 里的图谱页 */
  pointer-events: auto;
}
/* 图谱还没把 ready 发回来时的提示：否则兜底一揭示就是一块灰屏，
   看起来像「点了没反应」。图谱层一 on 就自动让位 */
.gallery-loading {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  margin: 0;
  font-family: var(--fp-mono);
  font-size: 12px;
  letter-spacing: .24em;
  color: rgba(229, 238, 217, .55);
  pointer-events: none;
  animation: galleryLoadingPulse 1.6s var(--ease) infinite;
}
@keyframes galleryLoadingPulse {
  0%, 100% { opacity: .35; }
  50% { opacity: .85; }
}

.gallery-back {
  /* 靠右下角的一块小牌：图谱自己的按钮都在底部中间 / 底边，
     放这儿不会和「查看标本」「返回图谱」叠在一起 */
  position: absolute; right: calc(env(safe-area-inset-right, 0px) + 16px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  padding: 9px 18px;
  transition: opacity .2s, background .2s, border-color .2s;
  opacity: .85;
  border: 1px solid rgba(150, 166, 142, 0.55);
  border-radius: 999px;
  background: rgba(8, 12, 11, 0.82);
  color: #e6efe8;
  font: 600 13px/1 var(--sans);
  letter-spacing: .12em;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: pointer;
  z-index: 2;
}
.gallery-back:hover { background: rgba(24, 32, 27, 0.92); }

/* ---------------------------------------------------------- 响应式 */
@media (max-height: 700px) {
  .display { font-size: 46px; }
  .headline { font-size: 20px; margin-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* ------------------------------------------------ 流体字号 */
/* 以 393 设计宽为基准，字号按 vw 连续放大：640 / 852 / 1280 这些中间宽度
   不会掉回手机字号，也不再依赖 900px 这一个断点 */
.place-title, .capture-title, .release-title,
.scan-title, .model-title { font-size: clamp(22px, 5.6vw, 48px); }

.headline { font-size: clamp(22px, 5.8vw, 46px); }
.headline.sm { font-size: clamp(21px, 5.4vw, 42px); }

.eyebrow { font-size: clamp(9px, 2.2vw, 18px); }
.hint-line { font-size: clamp(10px, 2.4vw, 20px); }
.hint-line.tiny { font-size: clamp(9.5px, 2.2vw, 18px); }

.btn { font-size: var(--btn-fs); }
.btn-link { font-size: var(--btn-fs-sm); }
.btn-release { font-size: var(--btn-fs); }

.scan-status { font-size: clamp(10px, 2.2vw, 18px); }
.scan-actions .btn { font-size: var(--btn-fs); }
.scan-actions .btn em { font-size: clamp(11px, 2.6vw, 20px); }

.mfield { font-size: clamp(6.5px, 1.5vw, 13px); }
.mfield h4 { font-size: clamp(7px, 1.55vw, 13px); }
.mfield h4 i { font-size: clamp(6px, 1.35vw, 11px); }
.mfield dl > div { font-size: clamp(6.5px, 1.4vw, 12px); }

.data-row { font-size: clamp(12px, 2.9vw, 22px); }
.data-row b { font-size: clamp(11px, 2.7vw, 20px); }
.data-row span { font-size: clamp(11px, 2.7vw, 20px); }

/* ------------------------------------------------ 宽屏布局（1920×1280 / 1280×1920） */
@media (min-width: 900px) {
  :root { --pad: clamp(40px, 4vw, 120px); }

  /* 内容列不再收在手机宽度里 */
  .pad { max-width: min(1560px, 84vw); }

  /* 03 采集：取景框宽度跟屏走，1:1 正方形，宽度用 vh 兜住不超高 */
  [data-screen="capture"] .center-col { padding-top: 11vh; padding-bottom: 9vh; }
  [data-screen="capture"] .viewfinder {
    width: min(1080px, 62vh);
    aspect-ratio: 1 / 1;
    margin: 30px auto 0;
  }
  [data-screen="capture"] .hint-line {
    max-width: min(1080px, 66vh);
    margin-left: auto; margin-right: auto;
  }
  [data-screen="capture"] .cap-foot .btn { max-width: 860px; margin-left: auto; margin-right: auto; }

  /* 04 扫描：按钮的尺寸（字号由流体规则负责） */
  .scan-status {
    letter-spacing: 0.12em;
    /* 跟着 900px 宽的按钮一起收边 */
    left: max(calc(8% + 24px), calc(50% - 426px));
    right: max(calc(8% + 24px), calc(50% - 426px));
  }
  .scan-actions { max-width: 900px; margin-left: auto; margin-right: auto; }
  .scan-actions .btn { padding: 18px 14px; }

  /* 05 标本 / 07 发布 底部区 */
  [data-screen="model"] .overlay-bottom,
  [data-screen="release"] .overlay-bottom {
    max-width: 900px; margin-left: auto; margin-right: auto; gap: 16px;
  }
  [data-screen="model"] .overlay-bottom .btn,
  [data-screen="release"] .btn-release { max-width: 860px; margin-left: auto; margin-right: auto; }

  /* 05 分散字段：宽屏沿用参考稿式散落，收窄到 30% 贴边 */
  .mfield { width: 30%; }
  .mfield h4 { letter-spacing: 0.18em; }
  .mfield dl > div { column-gap: 10px; }
  .m-encounter  { top: 8%;  left: 36%; width: 30%; }
  .m-identity   { top: 22%; left: 5%;  width: 28%; }
  .m-light      { top: 30%; right: 6%; width: 30%; }
  .m-atmos      { top: 37%; left: 4%;  width: 28%; }
  .m-morphology { top: 60%; left: 5%;  width: 30%; }
  .m-ecology    { top: 56%; right: 8%; width: 30%; }
  .m-habitat    { bottom: 14%; left: 5%; width: 32%; }
  .m-notes      { bottom: 3%;  left: 5%; width: 34%; }

  /* 06 档案：阅读宽度单独收一档，避免一行拉太长 */
  [data-screen="naming"] .pad { max-width: min(1120px, 74vw); padding-top: 11vh; }
  [data-screen="naming"] .data-row { padding: 13px 0; }
  [data-screen="naming"] .data-row span { width: 130px; }
  [data-screen="naming"] .btn-primary { max-width: 860px; margin-left: auto; margin-right: auto; align-self: stretch; }
}

/* ------------------------------------------------ 桌面：画面旋转 · 文字正向 */
/* 画面层（3D 画布 / 背景图 / 观察罩线框）整体顺时针转 90° 铺满横屏，
   文字、按钮、字段这些 UI 层留在原坐标系里正常阅读，不跟着转。
   指针坐标的换算见 js/viewport.js（媒体查询要同步改） */
@media (orientation: landscape) and (min-width: 900px) {
  .screen .stage-canvas,
  .screen .forest-bg,
  .screen .scan-canvas,
  .screen .garden-bg,
  .screen .eco-insects,
  .screen .garden-video-slot,
  .place-cocoon canvas,
  .cocoon-screen #viewer {
    top: 0; left: 0; right: auto; bottom: auto;
    width: 100vh;
    height: 100vw;
    transform-origin: 0 0;
    transform: translateX(100vw) rotate(90deg);
  }
}

/* ------------------------------------------------ 键盘导航（js/keynav.js） */
/* 有得选的屏：选中的那颗变绿变亮（就是它自己那一圈边框和字，不往外套描边），
   其余置灰。:focus 的浏览器默认焦点环也一起关掉。
   按下 Enter 时只有按钮自己的边框亮一下（绿；黄按钮走琥珀）。 */
/* 按钮的浏览器焦点环一律关掉：本站的「选中」由键盘导航自己画（绿边 + 其余置灰），
   再叠一圈系统蓝框就又变成两圈了。Tab 聚焦也不画。 */
button:focus,
button:focus-visible,
a.btn:focus,
a.btn:focus-visible,
[role="button"]:focus,
[role="button"]:focus-visible,
.kbd-nav,
.kbd-focus,
.kbd-dim,
.kbd-press { outline: none !important; }

.kbd-focus {
  color: #ddf6e9 !important;                             /* 带白的淡绿，别那么艳 */
  border-color: rgba(186, 234, 208, 0.72) !important;
  background-color: rgba(186, 234, 208, 0.05) !important;
  text-shadow: 0 0 8px rgba(186, 234, 208, 0.22) !important;
}
/* 黄按钮不染白，走琥珀 */
.kbd-focus.btn-primary {
  color: rgba(248, 206, 142, 0.98) !important;
  border-color: rgba(240, 196, 130, 0.85) !important;
  background-color: rgba(232, 171, 84, 0.06) !important;
  text-shadow: 0 0 10px rgba(232, 171, 84, 0.32) !important;
}
/* 纯文字按钮没有底和边，只亮字 */
.kbd-focus.btn-link { background: none !important; }

.kbd-dim { opacity: 0.45; }

/* 按下：按钮自己那一圈「亮一下」，用内阴影实现——还在框里，不往外套圈。
   不用 border-color 动画：选中态那条 border-color 带 !important，动画会被它压死。 */
@keyframes kbdPress {
  0% { box-shadow: inset 0 0 0 1px rgba(242, 247, 243, 0.9), inset 0 0 16px rgba(238, 246, 240, 0.26); }
}
.kbd-press { animation: kbdPress 0.3s ease-out; }

/* 黄按钮按下闪黄（跟它的琥珀主色对上），不要白圈 */
@keyframes kbdPressAmber {
  0% { box-shadow: inset 0 0 0 1px rgba(250, 208, 144, 0.95), inset 0 0 16px rgba(232, 171, 84, 0.34); }
}
.kbd-press.btn-primary { animation: kbdPressAmber 0.3s ease-out; }

/* 纯文字按钮（重新拍摄 / 再放一只 / 打开图谱）没有边框，按下时只让字闪一下 */
@keyframes kbdPressText {
  0% { text-shadow: 0 0 12px rgba(238, 246, 240, 0.6); }
}
.kbd-press.btn-link { animation: kbdPressText 0.3s ease-out; }
