/* ==========================================================================
   瞳孔测量 H5 · 暗色移动端样式
   - 移动优先，兼容 iOS Safari 刘海安全区
   - 单手操作：底部主操作区大按钮（>=52px）
   ========================================================================== */

:root {
  --bg: #0b0f14;
  --bg-2: #0f151d;
  --card: #121a24;
  --card-2: #16202c;
  --line: #23303f;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --muted-2: #667789;
  --accent: #2dd4bf;
  --accent-2: #22b8a5;
  --accent-dim: rgba(45, 212, 191, 0.14);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --blue: #60a5fa;
  --radius: 16px;
  --radius-sm: 11px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabbar-h: 58px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b));
}

button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p, ul, ol { margin: 0; }
h2 { font-size: 16px; font-weight: 650; margin-bottom: 8px; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 5px;
}
sub { font-size: 0.7em; }

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
}

/* ---------------- 顶部栏 ---------------- */
#app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-t)) 14px 10px;
  background: rgba(11, 15, 20, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-title { flex: 1; min-width: 0; }
.header-title h1 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-title span {
  display: block;
  font-size: 11px;
  color: var(--muted-2);
  margin-top: -2px;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  padding: 0 0 4px;
  flex: none;
}
.icon-btn:active { background: var(--card-2); }
.badge {
  flex: none;
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.badge-loading { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.08); }
.badge-ready { color: var(--accent); border-color: rgba(45, 212, 191, 0.4); background: var(--accent-dim); }
.badge-error { color: var(--bad); border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.08); }
.badge-idle { color: var(--muted); }

/* ---------------- 提示条 ---------------- */
.banner {
  margin: 10px 14px 0;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.1);
  color: #fde68a;
}
.banner[data-type="error"] {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.1);
  color: #fecaca;
}
.banner[data-type="info"] {
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(96, 165, 250, 0.1);
  color: #bfdbfe;
}
.banner[hidden] { display: none; }

/* ---------------- 主内容 / 屏幕 ---------------- */
#main { padding: 0 14px 18px; }
.screen { display: none; animation: fade-in 0.16s ease; }
.screen.active { display: block; }
@keyframes fade-in { from { opacity: 0.4; } to { opacity: 1; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 10px;
}
.muted { color: var(--muted); }
.tiny { font-size: 11px; }
.hint { font-size: 12px; line-height: 1.55; margin-top: 8px; }
.hidden, [hidden] { display: none !important; }

/* ---------------- 首页 ---------------- */
.hero {
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(45, 212, 191, 0.16), transparent 55%),
    radial-gradient(100% 100% at 100% 100%, rgba(96, 165, 250, 0.1), transparent 60%),
    var(--card);
  padding: 18px 16px;
  margin-top: 14px;
}
.hero-kicker {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--accent);
  margin-bottom: 6px;
}
.hero-title { font-size: 21px; font-weight: 700; letter-spacing: 0.3px; }
.hero p { margin-top: 4px; font-size: 12.5px; }
.status-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  flex: none;
}
.dot.ok { background: var(--good); box-shadow: 0 0 8px rgba(52, 211, 153, 0.7); }
.dot.warn { background: var(--warn); box-shadow: 0 0 8px rgba(251, 191, 36, 0.6); }
.dot.bad { background: var(--bad); box-shadow: 0 0 8px rgba(248, 113, 113, 0.6); }

.mode-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 14px;
  margin-top: 12px;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.06s;
}
.mode-card:active { transform: scale(0.99); background: var(--card-2); }
.mode-card[disabled] { opacity: 0.5; }
.mode-ico {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  color: var(--accent);
  background: var(--accent-dim);
  flex: none;
}
.mode-card-secondary .mode-ico { color: var(--blue); background: rgba(96, 165, 250, 0.12); }
.mode-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mode-body strong { font-size: 15.5px; font-weight: 650; }
.mode-body small { font-size: 11.5px; color: var(--muted); }
.chev { color: var(--muted-2); font-size: 22px; flex: none; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-2 .mode-card { margin-top: 10px; padding: 13px 12px; }
.home-footer { text-align: center; font-size: 11px; margin-top: 18px; }

/* ---------------- 实时测量：相机舞台 ---------------- */
.stage {
  position: relative;
  margin-top: 12px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #05080c;
  border: 1px solid var(--line);
  aspect-ratio: 4 / 3;
  max-height: 58vh;
}
.camera-video,
.overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.overlay-canvas { pointer-events: none; }
.enhanced-canvas {
  /* 增强画面预览：铺在视频上方、叠加层下方，像素放大时保持硬边便于看边缘 */
  image-rendering: pixelated;
  opacity: 0.98;
}
.stage-btn-2 { top: 42px; right: 8px; }
.stage-btn-3 { top: 76px; right: 8px; }
.stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 18px;
  background: rgba(5, 8, 12, 0.86);
}
.stage-empty-title { font-size: 15px; font-weight: 600; }
.stage-hud {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 112px; /* 给右上角的补光/滤镜按钮留位置 */
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 10.5px;
  color: #cbd5e1;
  pointer-events: none;
}
.stage-hud span {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
.stage-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  backdrop-filter: blur(4px);
}
.stage-btn[aria-pressed="true"] { background: var(--accent); color: #04211d; border-color: transparent; }

/* ---------------- 指标卡 ---------------- */
.metrics { padding-top: 12px; }
.metric-main { display: flex; align-items: baseline; gap: 8px; padding-bottom: 8px; }
.m-label { font-size: 11.5px; color: var(--muted); display: block; }
.metric-main .m-label { flex: 1; }
.m-value {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1.05;
}
.m-unit { font-size: 12px; color: var(--muted); }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.metric-cell b { font-size: 16px; font-variant-numeric: tabular-nums; }
.metric-cell small { color: var(--muted); font-size: 10.5px; }
.quality-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  font-size: 12px;
}
.qbar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #1d2938;
  overflow: hidden;
}
.qbar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--muted-2);
  transition: width 0.15s ease, background 0.15s;
}
.qbar i.good { background: var(--good); }
.qbar i.warn { background: var(--warn); }
.qbar i.bad { background: var(--bad); }
.reasons { font-size: 11.5px; margin-top: 6px; min-height: 17px; }

/* ---------------- 图表 ---------------- */
.chart-card { padding-bottom: 8px; }
.chart {
  display: block;
  width: 100%;
  height: 132px;
}
.chart-sm { height: 96px; }

/* ---------------- 进度条 ---------------- */
.progress {
  height: 9px;
  border-radius: 999px;
  background: #1d2938;
  overflow: hidden;
  margin-top: 12px;
}
.progress.thin { height: 5px; margin-top: 6px; }
.progress i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.15s linear;
}

/* ---------------- 30 秒静息统计 ---------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 12px;
  text-align: center;
}
.stats-grid b { font-size: 14.5px; font-variant-numeric: tabular-nums; display: block; }
.stats-grid small { color: var(--muted); font-size: 9.5px; }

/* ---------------- 底部主操作区 ---------------- */
.bottom-bar {
  position: sticky;
  bottom: 0;
  z-index: 30;
  display: flex;
  gap: 9px;
  padding: 10px 0 calc(10px + var(--safe-b));
  margin-top: 12px;
  background: linear-gradient(to top, var(--bg) 62%, rgba(11, 15, 20, 0));
}
.btn {
  flex: 1;
  min-height: 52px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.06s, filter 0.15s;
}
.btn:active { transform: scale(0.98); filter: brightness(1.15); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-primary {
  flex: 2;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04211d;
  border-color: transparent;
}
.btn-danger {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.5);
  color: #fca5a5;
}
.btn-ghost { background: transparent; }
.btn-small { min-height: 40px; font-size: 13px; padding: 0 12px; border-radius: 11px; flex: none; }
.btn-block { width: 100%; flex: none; }

/* ---------------- 底部导航 ---------------- */
#tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-width: 640px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: var(--safe-b);
  background: rgba(13, 18, 25, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
#tabbar button {
  height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  font-size: 18px;
}
#tabbar button small { font-size: 10px; }
#tabbar button.active { color: var(--accent); }

/* ---------------- PLR ---------------- */
.plr-steps {
  display: flex;
  justify-content: space-between;
  gap: 2px;
  margin: 12px 0 4px;
  font-size: 10.5px;
  color: var(--muted-2);
}
.plr-steps span {
  flex: 1;
  text-align: center;
  padding: 5px 0;
  border-radius: 999px;
  background: #101823;
  border: 1px solid transparent;
  white-space: nowrap;
}
.plr-steps span.active { color: var(--accent); border-color: rgba(45, 212, 191, 0.4); background: var(--accent-dim); }
.plr-steps span.done { color: var(--muted); }
.plr-trial-label { font-size: 11.5px; text-align: center; margin-bottom: 6px; }

.plr-preview {
  position: relative;
  height: 108px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #05080c;
  border: 1px solid var(--line);
  margin-bottom: 4px;
}
.plr-cam-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  color: var(--muted-2);
  text-align: center;
  padding: 10px;
}
.plr-panel { margin-top: 10px; }
.plr-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 14px;
  text-align: center;
}
.plr-count {
  font-size: 52px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  color: var(--text);
  line-height: 1;
}
.plr-countdown {
  font-size: 64px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1;
}
.plr-prompt-main { font-size: 16px; font-weight: 600; }
.plr-dim { color: var(--muted); font-size: 12.5px; }
.plr-center .progress { width: 100%; max-width: 300px; }

.prep-card h2 { margin-bottom: 10px; }
.checklist, .bullet-list, .num-list {
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.7;
  color: #c7d2de;
}
.checklist { list-style: none; padding-left: 0; }
.checklist li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 5px;
}
.checklist li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
}
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
}
.form-row:first-of-type { margin-top: 10px; }
.form-row select {
  max-width: 60%;
  min-width: 0;
}
#model-profile-hint {
  margin: 2px 0 4px;
  line-height: 1.55;
  font-size: 12px;
}
#model-profile-hint code {
  background: var(--card-2);
  border-radius: 4px;
  padding: 0 4px;
}
select {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  min-width: 150px;
  -webkit-appearance: none;
  appearance: none;
}
.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 12px;
  font-size: 12.5px;
  color: #c7d2de;
  line-height: 1.5;
}
.checkbox-row input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  flex: none;
}

/* PLR 测量进行中：全屏暗色，隐藏导航，避免额外光线干扰 */
body.plr-dark { background: #000; }
body.plr-dark #app-header,
body.plr-dark #tabbar,
body.plr-dark .plr-steps,
body.plr-dark .plr-trial-label { display: none; }
/* 测量进行中：保留相机实时画面（可在准备页关闭） */
body.plr-dark .plr-preview {
  display: block;
  height: 168px;
  max-width: 260px;
  width: 100%;
  margin: 0 auto 10px;
  border-color: #1b232b;
}
body.plr-dark .plr-cam-hint { font-size: 11px; color: #4b5563; }
body.plr-nopreview .plr-preview { display: none !important; }
/* 暗适应阶段不显示画面：这段时间屏幕越暗越好 */
/* 暗适应阶段默认隐藏取景窗（屏幕越暗越好）；但临床「保留取景窗」模式下
   操作者需要一直盯着对准，所以压暗+viewfinder 时保留这块调暗的画面 */
body.plr-adapt .plr-preview { display: none !important; }
body.plr-adapt.plr-screen-dim:not(.dim-black) .plr-preview {
  display: block !important;
  opacity: 1;
}
body.plr-dark #app { background: #000; }
body.plr-dark #main { padding: 0 16px; }
body.plr-dark .screen.active { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; }
body.plr-dark .plr-body { flex: 1; display: flex; flex-direction: column; justify-content: center; }
body.plr-dark .plr-panel { margin: 0; }
body.plr-dark .plr-count,
body.plr-dark .plr-countdown { color: #6b7787; }
body.plr-dark .plr-prompt-main { color: #8b98a8; }
body.plr-dark .plr-dim { color: #4b5563; }
body.plr-dark .progress { background: #141414; }
body.plr-dark .progress i { background: #2a3138; }
body.plr-dark .bottom-bar {
  background: transparent;
  justify-content: center;
}
body.plr-dark .btn-danger { opacity: 0.5; }
body.plr-dark .btn-ghost { color: #4b5563; border-color: #1d2329; }

#plr-fixation {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  z-index: 60;
  pointer-events: none;
  opacity: 0.55;
}
#plr-fixation i {
  position: absolute;
  background: #9ca3af;
  border-radius: 2px;
}
#plr-fixation .v { left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px; }
#plr-fixation .h { top: 50%; left: 0; height: 2px; width: 100%; margin-top: -1px; }

/* 全屏白光刺激 */
#flash-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #fff;
  display: block;
}
#flash-overlay[hidden] { display: none !important; }

/* ---------------- PLR 结果 ---------------- */
.result-hero {
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 10px;
  border: 1px solid rgba(45, 212, 191, 0.35);
  background: linear-gradient(140deg, rgba(45, 212, 191, 0.14), rgba(45, 212, 191, 0.02));
}
.result-hero.empty {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}
.result-hero h3 { font-size: 15px; margin-bottom: 4px; }
.result-hero p { font-size: 12.5px; color: var(--muted); }
.result-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.result-metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
}
.result-metric .m-label { margin-bottom: 3px; }
.result-metric b {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}
.result-metric small { color: var(--muted); font-size: 10.5px; }
.result-metric .sub { font-size: 10.5px; color: var(--muted-2); margin-top: 3px; }
.result-section-title {
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0 8px;
  display: flex;
  justify-content: space-between;
  color: #cbd5e1;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.data-table th, .data-table td {
  padding: 7px 5px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table th { color: var(--muted); font-weight: 500; font-size: 10.5px; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table td.bad { color: var(--bad); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.result-actions .btn { flex: 1 1 40%; }
.result-note { font-size: 11.5px; color: var(--muted); margin-top: 10px; line-height: 1.6; }
.metric-mean { font-weight: 650; }
.cv-tag { color: var(--muted-2); font-size: 10px; margin-left: 3px; }

/* ---------------- 记录 ---------------- */
.records-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 2px 6px;
  font-size: 12.5px;
}
.records-head > div { display: flex; align-items: center; gap: 8px; }
.record-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  margin-top: 10px;
}
.record-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
}
.record-top .badge { font-weight: 500; }
.record-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.record-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.record-actions .btn { min-height: 34px; padding: 0 11px; font-size: 12px; border-radius: 9px; }
.record-chart { margin-top: 10px; }
.record-chart canvas { width: 100%; height: 110px; display: block; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 13px; }
.empty p + p { margin-top: 6px; }

/* ---------------- 说明页 ---------------- */
.kv-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.kv-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 7px;
}
.kv-list span { color: var(--muted); flex: none; }
.kv-list b { text-align: right; font-weight: 500; word-break: break-all; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.file-btn { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.warn-card { border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.06); }
.warn-card h2 { color: var(--warn); }
#screen-about .card { margin-top: 12px; }
#screen-about p + p { margin-top: 8px; }
#screen-about p, #screen-about li { font-size: 13px; }

/* ---------------- 轻提示 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
  transform: translateX(-50%) translateY(8px);
  z-index: 10000;
  max-width: 86vw;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(24, 33, 44, 0.96);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
  backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[data-type="error"] { border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }
.toast[data-type="success"] { border-color: rgba(52, 211, 153, 0.5); color: #bbf7d0; }

.noscript { padding: 24px; text-align: center; }

/* ---------------- 小屏适配 ---------------- */
@media (max-width: 420px) {
  .stage-hud { font-size: 9.5px; gap: 3px 4px; }
  .stage-hud span { padding: 2px 6px; }
  .form-row select { max-width: 58%; }
}
@media (max-width: 360px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); row-gap: 10px; }
  .m-value { font-size: 30px; }
  .mode-ico { width: 38px; height: 38px; }
  .result-metric b { font-size: 18px; }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  * { transition: none !important; }
}

/* PLR 实时画面叠字 */
.plr-live-hud {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: #b8f5ea;
  text-shadow: 0 1px 3px #000, 0 0 8px rgba(0, 0, 0, 0.9);
}
.plr-live-q { opacity: 0.8; }

/* ---------- 模型列表（说明页 · 已安装到本机） ---------- */
.model-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 12px; }
.model-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid #1b232b; background: rgba(255,255,255,0.02);
}
.model-row.active { border-color: #2bbf9a; background: rgba(43,191,154,0.08); }
.model-row-main { flex: 1 1 auto; min-width: 0; }
.model-row-title { font-size: 14px; font-weight: 600; color: #e6f2ef; }
.model-row-note { font-size: 12px; color: #8aa0a8; margin-top: 2px; }
.model-row-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.model-progress { font-size: 12px; color: #2bbf9a; font-variant-numeric: tabular-nums; }


/* ===== 压暗屏幕（临床测量他人时，屏幕朝向测量者，避免漏光影响患者暗适应） ===== */
.plr-dim-veil {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 70;
  pointer-events: none;
}
.plr-dim-hud {
  position: fixed;
  inset: 0;
  z-index: 71;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #000;
  pointer-events: none;
}
body:not(.plr-screen-dim) .plr-dim-veil,
body:not(.plr-screen-dim) .plr-dim-hud {
  display: none !important;
}
body.plr-screen-dim #screen-plr { background: #000; }
.plr-dim-phase {
  font-size: 15px;
  letter-spacing: .3em;
  color: #6b0d0d;
  font-weight: 600;
}
.plr-dim-time {
  font-size: 58px;
  line-height: 1;
  color: #8c1616;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.plr-dim-tip {
  font-size: 11px;
  color: #4a0b0b;
  letter-spacing: .08em;
}
.plr-dim-abort {
  pointer-events: auto;
  margin-top: 18px;
  padding: 6px 18px;
  font-size: 12px;
  color: #7a1010;
  background: #140606;
  border: 1px solid #4a0b0b;
  border-radius: 8px;
}

/* 取景窗口：不压暗，提示贴底显示，避免挡住取景画面 */
body.plr-aim .plr-dim-veil { display: none !important; }
body.plr-aim .plr-dim-hud {
  background: transparent;
  justify-content: flex-end;
  padding-bottom: 34px;
}
body.plr-aim .plr-dim-phase { color: #f0a0a0; text-shadow: 0 1px 4px #000; }
body.plr-aim .plr-dim-time { color: #ffd0d0; text-shadow: 0 1px 6px #000; }
body.plr-aim .plr-dim-tip { color: #d09090; }

/* 取景窗口：只隐藏压暗层，画面可见；提示走 #plr-cam-hint 一行文字 */
body.plr-aim .plr-dim-veil { display: none !important; }
body.plr-aim .plr-dim-hud { display: none !important; }

/* 取景提示：压在取景画面底部，白字+阴影保证可读 */
body.plr-aim #plr-cam-hint {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 40px;
  margin: 0;
  z-index: 6;
  text-align: center;
  color: #ffe2e2;
  font-weight: 600;
  letter-spacing: .04em;
  text-shadow: 0 1px 8px #000, 0 0 2px #000;
}

/* ---------- 对光反射判读徽标 ---------- */
.reflex-badge {
  margin: 0 0 12px;
  padding: 14px 16px 12px;
  border-radius: 14px;
  border: 1px solid var(--line, #24303c);
  background: linear-gradient(180deg, #0f1c22, #0b1418);
}
.reflex-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.reflex-title { font-size: 13px; letter-spacing: .18em; color: #7f96a5; }
.reflex-level { font-size: 30px; font-weight: 800; line-height: 1.1; }
.reflex-pct { font-size: 13px; color: #8fa6b4; margin-left: auto; }
.reflex-note { margin: 8px 0 0; font-size: 12.5px; color: #9fb3c0; line-height: 1.5; }
.reflex-note.warn { color: #d99a6c; }
.reflex-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.reflex-chip { font-size: 11.5px; padding: 3px 8px; border-radius: 999px; border: 1px solid #26333f; color: #9fb3c0; }
.reflex-foot { margin: 10px 0 0; color: #6f8593; }
.reflex-badge.lv-brisk .reflex-level { color: #39d3a7; }
.reflex-badge.lv-present .reflex-level { color: #6fd8b4; }
.reflex-badge.lv-sluggish .reflex-level { color: #e5b567; }
.reflex-badge.lv-absent .reflex-level { color: #e07a7a; }
.reflex-badge.lv-indeterminate .reflex-level { color: #9a9a9a; }
.reflex-chip.lv-brisk { color: #39d3a7; border-color: #1f5d4c; }
.reflex-chip.lv-present { color: #6fd8b4; border-color: #245c4c; }
.reflex-chip.lv-sluggish { color: #e5b567; border-color: #5e4a24; }
.reflex-chip.lv-absent { color: #e07a7a; border-color: #5e2b2b; }
.reflex-chip.lv-indeterminate { color: #9a9a9a; }

/* ---------- 抢救模式 ---------- */
.mode-card-rescue {
  border-color: #5b2a2a;
  background: linear-gradient(135deg, #2a1114, #16100f 60%);
}
.mode-card-rescue .mode-ico {
  color: #ff8f8f;
  border-color: #5b2a2a;
  background: #2a1114;
}
.mode-card-rescue strong { color: #ffd2d2; }
.mode-card-rescue small { color: #c89a9a; }

.rescue-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #5b2a2a;
  background: #21100f;
  color: #ffd2d2;
  font-size: 12.5px;
  line-height: 1.4;
}
.rescue-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ff6b6b; box-shadow: 0 0 8px #ff6b6b;
  flex: 0 0 auto;
}
.rescue-text { flex: 1 1 auto; }
.rescue-exit {
  flex: 0 0 auto;
  border: 1px solid #6b3a3a;
  background: transparent;
  color: #ffb3b3;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
}

.verdict {
  margin: 0 0 12px;
  padding: 22px 18px 18px;
  border-radius: 18px;
  text-align: center;
  border: 1px solid #24303c;
  background: radial-gradient(120% 100% at 50% 0%, #10202a, #0a1116 70%);
}
.verdict-cap { font-size: 12px; letter-spacing: .22em; color: #7f96a5; }
.verdict-main {
  margin: 8px 0 4px;
  font-size: 58px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: .02em;
}
.verdict-detail { font-size: 15px; color: #cfe0ea; margin-bottom: 6px; }
.verdict-meta { font-size: 12.5px; color: #8fa6b4; font-variant-numeric: tabular-nums; }
.verdict-note { margin-top: 10px; font-size: 12.5px; color: #9fb3c0; line-height: 1.5; }
.verdict-hint { margin-top: 12px; font-size: 11.5px; color: #6f8593; line-height: 1.5; }
.verdict-has { border-color: #1f5d4c; }
.verdict-has .verdict-main { color: #39d3a7; text-shadow: 0 0 24px rgba(57,211,167,.35); }
.verdict-none { border-color: #5e2b2b; }
.verdict-none .verdict-main { color: #ff8080; text-shadow: 0 0 24px rgba(255,128,128,.3); }
.verdict-unknown { border-color: #3a4450; }
.verdict-unknown .verdict-main { color: #b9c4cd; }

/* 抢救模式：时序设置由模式接管，界面上弱化常规时序控件 */
body.plr-rescue .prep-card .kv-row.timing,
body.plr-rescue #plr-adapt-sec,
body.plr-rescue #plr-recover-sec {
  opacity: .45;
  pointer-events: none;
}

.verdict-warn {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #7a3a1a;
  background: #2a160f;
  color: #ffbe8a;
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
}

/* ===== 压暗屏幕（临床）两种方式 =====
   viewfinder（默认）：整屏几乎全黑，但顶部保留一块「调暗的实时取景窗」，
                       操作者要边看画面边对准患者瞳孔；
   black：全黑，只留阶段名/倒计时（最不漏光，靠提示音判断阶段）。 */

/* 取景窗：盖在压暗层之上，整体调暗，圆角+细边提示这是取景区域 */
body.plr-screen-dim:not(.dim-black) .plr-preview {
  position: relative;
  z-index: 72;
  width: min(92vw, 340px);
  height: 42vh;
  margin: 8px auto 0;
  border-radius: 16px;
  border: 1px solid #2a2f36;
  overflow: hidden;
  filter: brightness(0.55) contrast(1.05) saturate(0.75);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.0);
}
/* 取景窗上的读数保持可读（不跟着压暗） */
body.plr-screen-dim:not(.dim-black) .plr-preview .plr-live-hud {
  filter: brightness(2.4);
  font-weight: 600;
}
/* 取景窗上角提示：这块画面是「压暗版」，不是没画 */
body.plr-screen-dim:not(.dim-black) .plr-preview::after {
  content: '取景窗已调暗';
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 10px;
  letter-spacing: .06em;
  color: #8fa7b8;
  background: rgba(0,0,0,.35);
  padding: 1px 6px;
  border-radius: 6px;
  pointer-events: none;
}

/* 全黑模式：连取景窗一起藏起来 */
body.plr-screen-dim.dim-black .plr-preview { display: none; }

/* 压暗层与 HUD 的层级：veil 在最下面，HUD 透明并压在底部，不遮挡取景窗 */
body.plr-screen-dim .plr-dim-veil {
  background: #000;
  z-index: 70;
}
body.plr-screen-dim .plr-dim-hud {
  background: transparent;
  z-index: 73;
  justify-content: flex-end;
  padding-bottom: 28px;
  gap: 10px;
}
body.plr-screen-dim .plr-dim-phase { color: #8e1a1a; text-shadow: 0 0 12px #000; }
body.plr-screen-dim .plr-dim-time { font-size: 46px; color: #a51d1d; text-shadow: 0 0 16px #000; }
body.plr-screen-dim .plr-dim-tip { color: #5c1717; }
body.plr-screen-dim .plr-dim-abort { pointer-events: auto; }

/* 全黑模式：隐藏页面自身的大号倒计时/阶段文字（避免与压暗 HUD 重复、且从黑色里透出来） */
body.plr-screen-dim.dim-black .plr-panel,
body.plr-screen-dim.dim-black .plr-preview,
body.plr-screen-dim.dim-black .plr-steps,
body.plr-screen-dim.dim-black .plr-trial-label,
body.plr-screen-dim.dim-black .plr-head { visibility: hidden; }
