/*
 * 家居样板间 UI 样式。
 *
 * 设计取向：暖中性色 + 半透明面板（宜家样板间的气质），信息层浮在场景之上但不遮挡视线。
 * 移动端优先：3D 交互由 OrbitControls 处理触摸，UI 不拦截画布手势。
 */

:root {
  --ink: #2f2a24;
  --ink-soft: #5c5348;
  --ink-faint: #7d7365;
  --paper: #f6f2ec;
  --panel: rgba(255, 255, 255, 0.9);
  --line: rgba(47, 42, 36, 0.1);
  --accent: #0f766e;
  --warm: #b5651d;
  --shadow: 0 10px 28px rgba(47, 42, 36, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, 'PingFang SC', 'Microsoft YaHei', -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  flex: 0 0 auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warm);
  align-self: center;
}

.brand-name {
  letter-spacing: 0.02em;
}

.brand-note {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-faint);
}

.nav {
  display: flex;
  gap: 6px;
}

.nav-btn {
  font: inherit;
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
  cursor: pointer;
}

.nav-btn-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* ---------------------------------------------------------------- 场景 */
.screen-host {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.scene-screen {
  position: absolute;
  inset: 0;
}

.scene-host {
  position: absolute;
  inset: 0;
}

.scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------------------------------------------------------------- 热区标签 */
.hotspot-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.hotspot {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(28, 24, 20, 0.74);
  color: #f8f3ea;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  transition: opacity 0.18s ease;
  opacity: 0;
}

.hotspot-badge {
  color: #ffd39a;
  font-size: 10px;
}

/* ---------------------------------------------------------------- 浮层面板 */
.hud-panels {
  position: absolute;
  left: 14px;
  top: 14px;
  width: min(310px, 40vw);
  max-height: calc(100% - 28px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel,
.checklist {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.panel-title {
  margin: 0 0 8px;
  font-size: 11.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.panel-foot {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--ink-faint);
  line-height: 1.5;
}

.state-row {
  display: flex;
  gap: 8px;
  /* 允许换行：院子里的活动有四个按钮（玩水 / 草地打滚 / 刨地 / 晒太阳），
     左栏放不下一行 —— 不换行的话每个按钮会被压到 50 多像素，中文标签挤成两行看不清。 */
  flex-wrap: wrap;
}

.state-btn {
  flex: 1 1 0;
  /* 换行之后的**每行最少多宽**：够放最长的那个标签（草地打滚）且不挤成两行。
     它只在放不下时生效，所以上面的两按钮行（自主行为 / 暂停、抽搐 / 呕吐）完全不变。 */
  min-width: 72px;
  font: inherit;
  font-size: 13.5px;
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.state-btn-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.state-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.boundary-note {
  margin: 10px 0 0;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.55;
  color: #7a4a12;
  background: #fdf3e3;
  border-left: 3px solid #b45309;
  border-radius: 6px;
}

/* ---- 猫头顶的状态标签：把行为模型外显 ----
   与资源标签（.hotspot）在视觉上刻意区分：状态标签是**主线信息**，
   用深色实底 + 小尾巴，读起来像「贴在猫头上」，而不是另一个资源说明。 */

.cat-status-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.cat-status {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(24, 22, 20, 0.82);
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 0.18s ease;
  backdrop-filter: blur(2px);
}

/* 指向猫头的小尾巴 */
.cat-status::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  background: inherit;
  transform: rotate(45deg);
  border-radius: 1px;
}

.cat-status-name {
  font-weight: 600;
}

.cat-status-detail {
  font-size: 11px;
  opacity: 0.72;
}

/* 段内进展计数：让「长时间不变的活动名」也能看出时间在走 */
.cat-status-time {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  opacity: 0.55;
  padding-left: 2px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  margin-left: 2px;
  padding-left: 6px;
}

/* 突发演示：换成醒目配色，因为那一刻最该被看到的就是「发生了什么动作」 */
.cat-status[data-state='incident'] {
  background: rgba(160, 64, 12, 0.92);
  box-shadow: 0 2px 14px rgba(180, 83, 9, 0.45);
}

.cat-status[data-state='incident'] .cat-status-name::before {
  content: '●';
  font-size: 9px;
  margin-right: 5px;
  vertical-align: 1px;
}

/* ---- 首屏提示卡：说明这页最值得看的东西，避免演示时找不到重点 ---- */

.intro-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf8 0%, #fff8ec 100%);
  border-radius: 12px;
  padding: 12px 14px;
}

.intro-card .panel-title {
  margin-top: 0;
}

.intro-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-soft);
}

/* ---- 猫的行为面板：分段小标题、行为状态行、突发演示按钮 ---- */

.panel-subtitle {
  margin: 14px 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  text-transform: none;
}

.behavior-line {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* 突发演示按钮与「手动演示档位」在视觉上区分开：
   前者是瞬时动作，后者是持续档位 */
.incident-btn {
  border-style: dashed;
  font-size: 12.5px;
}

.incident-btn:hover {
  border-color: #b45309;
  color: #7a4a12;
}

/* 院子里的活动按钮：与突发按钮**刻意长得不一样**，因为两者点下去的语义不同 ——
   突发是"原地发生"，这一组是"走过去、然后做这件事"（实线 vs 虚线即这层区分）。 */
.activity-btn {
  border-style: solid;
  font-size: 12.5px;
}

.activity-btn:hover {
  border-color: #3f6212;
  color: #33510f;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-btn {
  font: inherit;
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.preset-btn:hover {
  background: #f1ece4;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 6px 0;
}

.quality-select {
  font: inherit;
  font-size: 12.5px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.stats-line,
.issue-line {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--ink-faint);
  line-height: 1.5;
}

.issue-line:empty {
  display: none;
}

/* ---------------------------------------------------------------- 资源清单 */
.checklist {
  position: absolute;
  right: 14px;
  top: 14px;
  bottom: 14px;
  width: min(360px, 38vw);
  overflow: auto;
}

.checklist-head {
  margin-bottom: 8px;
}

.pillar {
  border-top: 1px solid var(--line);
  padding: 8px 0 4px;
}

.pillar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
}

.pillar-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-faint);
}

.check-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}

.check {
  margin: 8px 0;
}

.check-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.check-status {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

.check-status-ok {
  background: #dff3e4;
  color: #1c6b3a;
}

.check-status-gap {
  background: #fbe3d8;
  color: #a33c14;
}

.check-status-unknown {
  background: #eee7dc;
  color: #6b6257;
}

.check-req {
  font-size: 12px;
  line-height: 1.5;
}

.check-actual {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.check-note {
  margin: 2px 0 0;
  font-size: 10.5px;
  color: #8a7f70;
  line-height: 1.45;
}

.tier {
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

.tier-strong {
  color: #0f766e;
}

.tier-moderate {
  color: #7a6a12;
}

.tier-weak {
  color: #8a5a12;
}

.tier-unverified,
.tier-disputed {
  color: #a33c14;
}

/* ---------------------------------------------------------------- 加载与降级 */
.loading,
.fatal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(246, 242, 236, 0.95);
  z-index: 20;
  transition: opacity 0.45s ease;
}

.loading-done {
  opacity: 0;
  pointer-events: none;
}

.loading[hidden],
.fatal[hidden] {
  display: none;
}

.loading-card {
  width: min(430px, 88vw);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.progress-track {
  height: 6px;
  background: #e9e2d8;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--warm), var(--accent));
  transition: width 0.3s ease;
}

.progress-text {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--ink-soft);
}

.fatal {
  z-index: 30;
}

/* 自检徽章：仅在 ?debug=1 时挂载，用于人工与自动化（dump-dom）核对 */
.selftest {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 40;
  max-width: min(92vw, 900px);
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(28, 24, 20, 0.82);
  color: #f6f2ea;
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selftest[data-ok='false'] {
  background: rgba(163, 60, 20, 0.9);
}

/* ---------------------------------------------------------------- 工程自检屏 */
.status-screen {
  height: 100%;
  overflow: auto;
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  line-height: 1.75;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.status-title {
  margin: 0 0 14px;
  font-size: 28px;
}

.status-lead {
  margin: 0 0 24px;
  color: var(--ink-soft);
}

.status-list {
  margin: 0 0 24px;
  padding-left: 0;
  list-style: none;
}

.status-list li {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.status-key {
  color: var(--ink-faint);
  min-width: 200px;
}

/* ---------------------------------------------------------------- 生理读数屏 */
/*
 * 这一屏的重点是"读数与真值并排看"，因此图表与卡片都做窄，让两组折线在同一屏内可比较。
 * 坏值/无效读数用删除线与灰底表示——**可见**是这个设计的目的，藏起来就失去了意义。
 */
.vitals-screen {
  max-width: 820px;
}

.vitals-scenario {
  margin-bottom: 18px;
}

.vitals-boundary {
  margin-bottom: 26px;
  padding: 12px 14px;
  border-left: 3px solid var(--warm);
  background: rgba(181, 101, 29, 0.07);
  border-radius: 0 8px 8px 0;
}

.vitals-boundary .boundary-note {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.7;
}

.vitals-boundary .boundary-note + .boundary-note {
  margin-top: 8px;
  color: var(--ink-soft);
}

.vitals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.vitals-card,
.vitals-chart {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.vitals-card-head,
.vitals-chart-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.vitals-card-name {
  font-weight: 700;
  font-size: 13.5px;
}

.vitals-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.vitals-number {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.vitals-unit {
  font-size: 12px;
  color: var(--ink-faint);
}

.vitals-meta {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.65;
}

.vitals-note {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.7;
}

.vitals-bar {
  margin-top: 10px;
  height: 6px;
  border-radius: 999px;
  background: rgba(47, 42, 36, 0.1);
  overflow: hidden;
}

.vitals-bar-fill {
  height: 100%;
  background: var(--accent);
}

.vitals-legend {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-faint);
}

.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.legend-read {
  background: var(--warm);
}

.legend-truth {
  background: var(--accent);
}

.vitals-spark {
  width: 100%;
  height: auto;
  display: block;
}

.spark-read {
  fill: none;
  stroke: var(--warm);
  stroke-width: 1.6;
}

.spark-truth {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-dasharray: 4 3;
}

/*
 * 状态程序图里的第三条线：体动伪影。
 * 点线 + 更细的线宽，让它在与心率/呼吸同框时不抢视线——
 * 它回答的是「这一段读数值不值得信」，不是「猫怎么了」。
 */
.spark-motion {
  fill: none;
  stroke: #c0392b;
  stroke-width: 1.2;
  stroke-dasharray: 2 3;
  opacity: 0.75;
}

/* 读数不可采信的窗口带：一条条红色竖纹，提醒逻辑必须先跳过这些段。 */
.unusable-band {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 4px 0 8px;
}

.unusable-tick {
  display: block;
  width: 4px;
  height: 10px;
  border-radius: 1px;
  background: #c0392b;
  opacity: 0.7;
}

@media (max-width: 900px) {
  .vitals-screen {
    padding-top: 18px;
  }

  .vitals-number {
    font-size: 24px;
  }
}

/* ---------------------------------------------------------------- 折叠面板 */
/*
 * 「图层与画质」收进 <details>：这些是看房间时的调节项，不是主线信息。
 * summary 复用 `.panel-title` 的外观，但要去掉浏览器默认的三角标记与 margin。
 */
.panel-fold > summary {
  cursor: pointer;
  list-style: none;
  margin-bottom: 0;
}

.panel-fold > summary::-webkit-details-marker {
  display: none;
}

.panel-fold[open] > summary {
  margin-bottom: 8px;
}

.panel-fold > summary::after {
  content: '▾';
  float: right;
  color: var(--ink-faint);
}

.panel-fold[open] > summary::after {
  content: '▴';
}

/* ---------------------------------------------------------------- App 预览（iPhone 机模） */
/*
 * 为什么做成机模而不是"再放一个面板"：本项目的产品形态就是主人手机上的 App。
 * 机模把那件事变成一眼可见的事实，而 3D 房间退回到它真正的角色——数据从哪来。
 */
.app-dock {
  --phone-w: 268px;
  position: absolute;
  right: 14px;
  top: 14px;
  width: var(--phone-w);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 4;
  /* 机身高度是算出来的：若不加这个上限，短窗口里手机会顶出屏幕 */
  max-height: calc(100% - 28px);
}

.app-dock-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.app-dock-title {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

.app-dock-toggle {
  margin-left: auto;
  font: inherit;
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
}

/* 收起时只留标题条，不再占右侧空间 */
.app-dock[data-collapsed='true'] {
  width: auto;
}

.app-dock[data-collapsed='true'] .phone {
  display: none;
}

/*
 * 机身尺寸**由宽度算出来**，与内容无关。
 *
 * 为什么必须写死高度，而不是只给 `aspect-ratio`：
 * flex 子项的 `min-height` 默认是 `auto`（内容最小高度），当模块内容很长时，
 * 这个下限会**压过** `aspect-ratio` 推出来的高度——手机就被内容撑长了
 * （用户反馈 ③：事件流/健康/档案一长，iPhone 就变大）。
 * 现在高度是确定的：内容只能在机身内滚动（见 `.app-body`）。
 */
.phone {
  position: relative;
  width: 100%;
  height: min(calc(var(--phone-w) * 19 / 9), 68vh);
  min-height: 0;
  overflow: hidden;
  padding: 9px;
  border-radius: 34px;
  background: linear-gradient(160deg, #2b2b30 0%, #14141a 55%, #26262c 100%);
  box-shadow: 0 18px 40px rgba(20, 18, 16, 0.32), inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.phone-notch {
  position: absolute;
  left: 50%;
  top: 15px;
  transform: translateX(-50%);
  width: 68px;
  height: 18px;
  border-radius: 12px;
  background: #08080a;
  z-index: 2;
}

.phone-screen {
  position: relative;
  height: 100%;
  min-height: 0;
  border-radius: 26px;
  background: #f7f6f3;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.phone-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 14px 2px;
  font-size: 9.5px;
  color: var(--ink-faint);
}

.phone-time {
  opacity: 0.7;
}

.phone-clock {
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.phone-battery {
  opacity: 0.7;
}

.app-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 12px 8px;
  border-bottom: 1px solid var(--line);
}

.app-title {
  font-size: 13px;
  font-weight: 700;
}

.app-sub {
  font-size: 9.5px;
  color: var(--ink-faint);
}

/*
 * 机身内**唯一**的滚动容器。
 *
 * `flex: 1 1 0`（basis 0 而不是 auto）是关键：basis 为 auto 时，内容会把这一项的
 * 基准高度顶大，进而把机身撑长。basis 0 + `min-height: 0` 之后，它的高度只由
 * 机身剩余空间决定，内容超出就在**这里**滚。
 */
.app-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 12px;
  font-size: 11.5px;
  line-height: 1.5;
}

.app-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.app-tab {
  font: inherit;
  font-size: 10.5px;
  padding: 8px 2px;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
}

.app-tab-active {
  color: var(--accent);
  font-weight: 700;
  box-shadow: inset 0 2px 0 var(--accent);
}

.phone-homebar {
  height: 4px;
  width: 84px;
  margin: 6px auto 8px;
  border-radius: 999px;
  background: rgba(47, 42, 36, 0.28);
}

.app-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: #fff;
}

.app-card-label {
  display: block;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.app-now-value {
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin-top: 2px;
}

.app-now-where {
  display: block;
  font-size: 10.5px;
  color: var(--ink-soft);
}

.app-card-value {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
}

.app-vital {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.app-vital-name {
  min-width: 52px;
  color: var(--ink-soft);
}

.app-vital-value {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

/* 无效读数：划线 + 变灰。**可见**是重点，藏起来就失去了意义。 */
.app-vital-invalid {
  text-decoration: line-through;
  color: var(--ink-faint);
  font-weight: 500;
}

/* ---------------------------------------------------------------- 读数变化的提示 */
/*
 * 红色只用于"读数偏离达到阈值，或急性窗口里读不到"。
 * 它不是装饰：每一种红色都有一条可核查的理由，理由在下面「读数说明」里逐条列出。
 */
.app-vital-alert {
  background: rgba(180, 40, 30, 0.07);
  border-radius: 8px;
  padding-left: 8px;
  padding-right: 8px;
  margin: 0 -8px;
}

.app-vital-value-alert {
  color: #b3281e;
  font-weight: 800;
}

/* 弹窗做成**覆盖层**而不是内联块：内联会把机身里那点空间挤没，
 * 而弹出的意义正是"这件事比当前页面更重要"。 */
.app-alert-host {
  position: absolute;
  inset: 0;
  z-index: 3;
  padding: 34px 8px 8px;
  background: rgba(24, 20, 18, 0.28);
  overflow-y: auto;
}

.app-alert-host:empty {
  display: none;
}

.app-alert {
  border-radius: 12px;
  border: 1px solid rgba(180, 40, 30, 0.35);
  background: #fff5f4;
  box-shadow: 0 10px 22px rgba(120, 24, 18, 0.22);
  padding: 10px 11px;
}

@keyframes app-alert-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.app-alert-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-alert-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b3281e;
  flex: 0 0 auto;
}

.app-alert-title {
  font-size: 13px;
  font-weight: 800;
  color: #8e1f17;
}

.app-alert-sub {
  margin: 4px 0 6px;
  font-size: 10.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.app-alert-details {
  list-style: none;
  margin: 0;
  padding: 0;
}

.app-alert-details li {
  font-size: 10px;
  line-height: 1.55;
  color: var(--ink-soft);
  padding-left: 9px;
  position: relative;
}

.app-alert-details li::before {
  content: '·';
  position: absolute;
  left: 2px;
  color: #b3281e;
}

.app-alert-boundary,
.app-alert-referral {
  margin: 7px 0 0;
  font-size: 9.5px;
  line-height: 1.55;
  color: #7a4a12;
  background: #fdf3e3;
  border-radius: 6px;
  padding: 6px 7px;
}

.app-alert-referral {
  color: var(--ink-soft);
  background: rgba(47, 42, 36, 0.05);
}

.app-alert-accept {
  margin-top: 8px;
  width: 100%;
  font: inherit;
  font-size: 11px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid rgba(180, 40, 30, 0.4);
  background: #fff;
  color: #8e1f17;
  cursor: pointer;
}

/* 急性生理窗口的说明卡片 */
.app-acute {
  border-color: rgba(180, 83, 9, 0.4);
  background: #fdf7ef;
}

/* ---------------------------------------------------------------- 实时页：项圈相机画面 */
/*
 * 画布是**离屏渲染的一帧**（176×132）铺满机身宽度：分辨率故意取小，
 * 因为每次都要把像素从 GPU 读回 CPU（见 scene.ts 的 updatePovFeed）。
 */
.app-pov-wrap {
  position: relative;
  margin-bottom: 8px;
  border-radius: 10px;
  overflow: hidden;
  background: #16181c;
}

.app-pov {
  display: block;
  width: 100%;
  height: auto;
}

.app-pov-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
}

/* ---------------------------------------------------------------- 事件流：次数 + 可滚动记录 */
.app-count-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.app-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(47, 42, 36, 0.03);
}

.app-count-value {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.app-count-label {
  font-size: 9.5px;
  color: var(--ink-soft);
}

.app-count-sub {
  font-size: 9px;
  color: var(--ink-faint);
}

/*
 * 列表不再自己滚动：**机身（`.app-body`）是唯一的滚动容器**。
 * 两层嵌套滚动条在手机大小的容器里读起来很糟，而且外层不滚会让人以为"滑不动"。
 * `max-height` 保留作为兜底（万一外层 flex 计算出现意外，也不会溢出机身）。
 */
.app-scroll {
  max-height: none;
  overflow: visible;
}

/* ---------------------------------------------------------------- 档案页：可选品种与年龄 */
.app-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.app-field-label {
  min-width: 40px;
  font-size: 11px;
  color: var(--ink-faint);
}

.app-select {
  flex: 1 1 auto;
  font: inherit;
  font-size: 11.5px;
  padding: 5px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  .app-alert {
    animation: none;
  }
}

.app-vital-unit {
  font-size: 9.5px;
  color: var(--ink-faint);
}

.app-vital-flag {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  white-space: nowrap;
}

.app-flag-valid {
  color: var(--accent);
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.07);
}

.app-flag-motion-artifact,
.app-flag-poor-contact,
.app-flag-rejected-out-of-range {
  color: #7a4a12;
  border-color: rgba(180, 83, 9, 0.35);
  background: #fdf3e3;
}

.app-list {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.app-event-row,
.app-kv {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}

.app-event-row:last-child,
.app-kv:last-child {
  border-bottom: 0;
}

.app-event-time {
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
  font-size: 10px;
}

.app-event-name {
  font-weight: 600;
}

.app-event-mag {
  margin-left: auto;
  font-size: 10px;
  color: var(--ink-faint);
}

.app-kv-key {
  color: var(--ink-faint);
  min-width: 92px;
}

.app-kv-value {
  flex: 1;
}

.app-note {
  margin: 8px 0 0;
  font-size: 10px;
  line-height: 1.55;
  color: var(--ink-faint);
}

.app-note-boundary {
  color: #7a4a12;
  background: #fdf3e3;
  border-radius: 6px;
  padding: 7px 8px;
}

.app-drift {
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 8px;
  padding: 7px 9px;
  margin-bottom: 7px;
  background: #fff;
}

.app-drift-notable {
  border-left-color: #b45309;
}

.app-drift-watch {
  border-left-color: #b7a06a;
}

.app-drift-none {
  border-left-color: var(--accent);
}

.app-drift-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.app-drift-name {
  font-weight: 700;
}

.app-drift-badge {
  margin-left: auto;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}

.app-drift-detail {
  display: block;
  font-size: 10px;
  color: var(--ink-faint);
  margin-top: 3px;
}

/* ---------------------------------------------------------------- 居家资源页 */
.resources-screen {
  max-width: 780px;
}

.resources-summary {
  margin: 0 0 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.resource-list {
  margin-bottom: 20px;
}

/* 资源清单的 <details> 与 <summary> 沿用 .pillar / .pillar-head 的外观 */
.resource-list summary {
  list-style: none;
  cursor: pointer;
}

.resource-list summary::-webkit-details-marker {
  display: none;
}

.resource-list summary::after {
  content: '▾';
  margin-left: auto;
  color: var(--ink-faint);
  font-size: 11px;
}

.resource-list details[open] summary::after {
  content: '▴';
}

.resource-list .check {
  list-style: none;
}

/* ---------------------------------------------------------------- 移动端 */
@media (max-width: 900px) {
  .hud-panels {
    width: min(268px, 64vw);
    left: 8px;
    top: 8px;
    gap: 8px;
  }

  /* 窄屏下 App 预览贴右下角，并且默认收起（由 home.ts 读 media query 决定） */
  .app-dock {
    right: 8px;
    left: auto;
    top: auto;
    bottom: 8px;
    width: min(240px, 62vw);
  }

  .app-dock[data-collapsed='true'] {
    left: auto;
    bottom: 8px;
  }

  .panel {
    padding: 10px;
  }

  .checklist {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 8px;
    width: auto;
    max-height: 40vh;
  }

  .status-key {
    min-width: 140px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hotspot,
  .state-btn,
  .progress-bar,
  .loading {
    transition: none;
  }
}

/*
 * 狗版场景清单（`ui/dog-hud.ts`）。
 *
 * 为什么不做成逐项打勾的「清单核对」控件：这一屏交付的是**场景**，
 * 清单的作用是让人一眼看到「这个场景里有什么」，不是一份需要交互的检查表。
 * 三组（房间 / 狗的用品 / 院子）用小标题 + 紧凑列表分开即可。
 */
.dog-checklist {
  list-style: none;
  margin: 4px 0 10px;
  padding: 0;
  display: grid;
  gap: 3px;
}

.dog-checklist li {
  position: relative;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-soft);
  padding-left: 12px;
}

.dog-checklist li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.58em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

/* Collective: give the scene the full narrow screen; open one panel at a time. */
.mobile-controls { display:none; }
@media (max-width:600px) {
  .topbar { height:auto; align-items:stretch; flex-direction:column; gap:8px; padding:10px 12px; }
  .brand, .nav-btn { white-space:nowrap; }
  .nav { overflow-x:auto; padding-bottom:3px; flex-shrink:0; }
  .nav-btn { flex-shrink:0; }
  .mobile-controls { display:block; position:fixed; left:8px; bottom:60px; z-index:8; border:1px solid var(--line); background:var(--panel); border-radius:10px; padding:10px 16px; color:var(--ink); font:inherit; }
  .hud-panels { display:none; width:calc(100% - 16px); max-height:calc(100% - 120px); z-index:7; }
  .controls-open .hud-panels { display:flex; }
  .app-dock, .app-dock[data-collapsed='true'] { bottom:60px; }
  .app-dock { width:min(268px, calc(100vw - 16px)); max-height:calc(100% - 72px); }
  .phone { min-height:0; }
}

.asset-warning { position:absolute;z-index:9;top:10px;left:50%;transform:translateX(-50%);width:max-content;max-width:calc(100% - 20px);background:#fff7e6;color:#493b24;border:1px solid #cba569;border-radius:8px;padding:12px;font-size:14px; }
.asset-warning button { margin-left:8px;padding:6px 10px;border:1px solid #ad8f5c;border-radius:5px;background:#fff;font:inherit;cursor:pointer; }
