/* ==========================================================================
   Measurer | AR 测量器 — 核心样式表
   设计风格：专业光学/几何精密测量仪器，深色石墨灰底色 + 极光青与琥珀金高精度标线
   ========================================================================== */

:root {
  --bg-deep: #070a0f;
  --bg-base: #0b111a;
  --bg-card: #121924;
  --bg-surface: #182232;
  --bg-surface-hover: #202d40;
  
  --border-dim: #1f2c3f;
  --border-focus: #00e5ff;
  --border-gold: #ffb703;
  
  --laser-cyan: #00e5ff;
  --laser-cyan-glow: rgba(0, 229, 255, 0.28);
  --laser-cyan-subtle: rgba(0, 229, 255, 0.12);
  
  --amber-gold: #ffb703;
  --amber-gold-glow: rgba(255, 183, 3, 0.25);
  --amber-gold-subtle: rgba(255, 183, 3, 0.12);
  
  --emerald-ok: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  
  --rose-warn: #f43f5e;
  --purple-accent: #a855f7;
  
  --text-main: #f8fafc;
  --text-sub: #94a3b8;
  --text-dim: #64748b;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, "Courier New", monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-elevated: 0 10px 30px -5px rgba(0, 0, 0, 0.7), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --shadow-glow: 0 0 20px var(--laser-cyan-glow);
}

/* Light Theme Variables */
body.theme-light,
html.theme-light body,
html.theme-light {
  --bg-deep: #f1f5f9;
  --bg-base: #f8fafc;
  --bg-card: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f5f9;
  
  --border-dim: #cbd5e1;
  --border-focus: #0284c7;
  --border-gold: #d97706;
  
  --laser-cyan: #0284c7;
  --laser-cyan-glow: rgba(2, 132, 199, 0.2);
  --laser-cyan-subtle: rgba(2, 132, 199, 0.08);
  
  --amber-gold: #d97706;
  --amber-gold-glow: rgba(217, 119, 6, 0.2);
  --amber-gold-subtle: rgba(217, 119, 6, 0.08);
  
  --emerald-ok: #059669;
  --emerald-glow: rgba(5, 150, 105, 0.2);
  
  --rose-warn: #e11d48;
  --purple-accent: #7c3aed;
  
  --text-main: #0f172a;
  --text-sub: #475569;
  --text-dim: #64748b;
  
  --shadow-elevated: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 15px rgba(2, 132, 199, 0.15);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* 主布局 */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 50% 0%, #101927 0%, var(--bg-deep) 75%);
}

/* 顶栏 Header */
.app-header {
  height: 52px;
  min-height: 52px;
  background-color: rgba(11, 17, 26, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* YINUNU Cloud 统一品牌门户 Logo 规范 (左上角, 宽高比 4:1) */
.brand-portal-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
}
.brand-portal-link:hover {
  transform: scale(1.08);
  opacity: 0.95;
}

.brand-portal-logo {
  height: 28px;
  width: 112px;
  aspect-ratio: 4 / 1;
  border-radius: 6px;
  object-fit: contain;
  display: block;
}

.brand-divider {
  width: 1px;
  height: 20px;
  background: var(--border-dim);
  margin: 0 4px;
  flex-shrink: 0;
}

.brand-title-box {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.title-text-compact {
  display: none;
}

.brand-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--laser-cyan-subtle);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: var(--laser-cyan);
  text-transform: uppercase;
}

/* 顶部操作区 */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.device-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  color: var(--text-sub);
  white-space: nowrap;
  flex-shrink: 0;
}

.device-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--amber-gold);
  box-shadow: 0 0 8px var(--amber-gold);
  flex-shrink: 0;
}
.device-status-dot.active {
  background-color: var(--emerald-ok);
  box-shadow: 0 0 8px var(--emerald-ok);
}

.unit-select-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  flex-shrink: 0;
}

.unit-select {
  background: transparent;
  border: none;
  color: var(--laser-cyan);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 6px;
  outline: none;
  cursor: pointer;
}
.unit-select option {
  background: var(--bg-card);
  color: var(--text-main);
}

.header-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.header-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--laser-cyan);
}
.header-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.history-pill {
  font-size: 10px;
  font-family: var(--font-mono);
  background: var(--laser-cyan-subtle);
  color: var(--laser-cyan);
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: var(--radius-full);
  padding: 0 5px;
  font-weight: 700;
  line-height: 14px;
}

/* 主题切换按钮与图标控制 */
.theme-toggle .theme-icon {
  width: 14px;
  height: 14px;
}

body.theme-dark .sun-icon { display: block; }
body.theme-dark .moon-icon { display: none; }
body.theme-light .sun-icon { display: none; }
body.theme-light .moon-icon { display: block; }

/* 浅色模式专属规则适配 */
body.theme-light .app-container {
  background: radial-gradient(circle at 50% 0%, #ffffff 0%, var(--bg-deep) 85%);
}

body.theme-light .app-header {
  background-color: rgba(255, 255, 255, 0.92);
}

body.theme-light .mode-tabs-bar {
  background: #f8fafc;
}

body.theme-light .mode-tab-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-main);
}

body.theme-light .mode-tab-btn.active {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.theme-light .photo-toolbar {
  background-color: rgba(255, 255, 255, 0.92);
}

body.theme-light .photo-hud-footer {
  background-color: rgba(255, 255, 255, 0.95);
}

body.theme-light .caliper-workspace {
  background: radial-gradient(circle at center, #f8fafc 0%, var(--bg-deep) 100%);
}

body.theme-light .caliper-toolbar {
  background-color: rgba(255, 255, 255, 0.92);
}

body.theme-light .caliper-readout-card {
  background: rgba(255, 255, 255, 0.96);
  border-color: var(--laser-cyan);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

body.theme-light .empty-guide-card {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-elevated);
}

body.theme-light .calibration-bar {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

body.theme-light .ar-unsupported-card {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-elevated);
}

body.theme-light .canvas-stage {
  background-color: #e2e8f0;
}

body.theme-light .unit-select option,
body.theme-light .tool-select option {
  background: #ffffff;
  color: var(--text-main);
}

body.theme-light .toast-bubble {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  color: var(--text-main);
}

body.theme-light input[type="text"],
body.theme-light input[type="number"] {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

body.theme-light input[type="text"]:focus,
body.theme-light input[type="number"]:focus {
  border-color: var(--laser-cyan) !important;
  outline: none;
  box-shadow: 0 0 0 2px var(--laser-cyan-subtle);
}

/* 导航 Tabs 栏 (支持平滑横向拖拽与短文本自适应) */
.mode-tabs-bar {
  display: flex;
  align-items: center;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-dim);
  padding: 4px 12px;
  gap: 8px;
  z-index: 90;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.mode-tabs-bar::-webkit-scrollbar {
  display: none;
}

.mode-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-sub);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.mode-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}
.mode-tab-btn.active {
  color: var(--laser-cyan);
  background: var(--laser-cyan-subtle);
  border-color: rgba(0, 229, 255, 0.35);
  font-weight: 600;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.15);
}
.mode-tab-btn .tab-badge-rec {
  background: var(--amber-gold);
  color: #000;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 2px;
}

.tab-label-compact {
  display: none;
}

/* 工作区主体 */
.app-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
}

.mode-panel {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  flex-direction: column;
}
.mode-panel.active {
  display: flex;
}

/* ==========================================================================
   模式 1: 照片校准测量面板 (Photo Measurer)
   ========================================================================== */
.photo-workspace {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
}

/* 照片工具顶栏 */
.photo-toolbar {
  height: 46px;
  min-height: 46px;
  background: rgba(18, 25, 36, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 40;
}
.photo-toolbar::-webkit-scrollbar {
  display: none;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-dim);
  margin: 0 4px;
  flex-shrink: 0;
}

.btn-tool {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.btn-tool:hover {
  background: var(--bg-surface-hover);
  border-color: var(--laser-cyan);
}
.btn-tool.active {
  background: var(--laser-cyan-subtle);
  border-color: var(--laser-cyan);
  color: var(--laser-cyan);
  font-weight: 600;
}
.btn-tool.primary {
  background: linear-gradient(135deg, #00b4d8, #0077b6);
  border-color: var(--laser-cyan);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}
.btn-tool.primary:hover {
  background: linear-gradient(135deg, #00e5ff, #0096c7);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.5);
}

.tool-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}
.tool-select option {
  background: var(--bg-card);
  color: var(--text-main);
}

/* 画布主渲染容器 */
.canvas-stage {
  flex: 1;
  position: relative;
  background-color: #030508;
  overflow: hidden;
  cursor: crosshair;
}

#photo-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* 空状态指引卡片 */
.empty-guide-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(18, 25, 36, 0.88);
  border: 1px solid var(--border-dim);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-elevated);
  z-index: 30;
  pointer-events: auto;
}

.guide-icon-box {
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: var(--radius-md);
  background: var(--laser-cyan-subtle);
  border: 1px solid rgba(0, 229, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--laser-cyan);
}

.guide-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-main);
}

.guide-desc {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.6;
  margin-bottom: 20px;
}

.guide-card-ref-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--amber-gold-subtle);
  border: 1px solid rgba(255, 183, 3, 0.3);
  color: var(--amber-gold);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 16px;
}

.guide-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* 标定状态指示条 */
.calibration-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 25, 36, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--amber-gold);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 15px var(--amber-gold-glow);
  z-index: 50;
  max-width: 90%;
  pointer-events: auto;
}

.cal-status-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--amber-gold);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cal-action-btn {
  background: var(--amber-gold);
  color: #000;
  border: none;
  font-weight: 700;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.cal-action-btn:hover {
  opacity: 0.9;
}

/* 亚像素悬浮放大镜 (Sub-pixel Loupe) */
.loupe-lens {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid var(--laser-cyan);
  box-shadow: 0 0 25px rgba(0, 229, 255, 0.6), inset 0 0 15px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  overflow: hidden;
  z-index: 80;
  display: none;
  background-color: #000;
  transform: translate(-50%, -50%);
}

#loupe-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.loupe-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  pointer-events: none;
}
.loupe-crosshair::before, .loupe-crosshair::after {
  content: "";
  position: absolute;
  background-color: var(--laser-cyan);
  box-shadow: 0 0 4px #000;
}
.loupe-crosshair::before {
  top: 11px;
  left: 0;
  width: 24px;
  height: 2px;
}
.loupe-crosshair::after {
  top: 0;
  left: 11px;
  width: 2px;
  height: 24px;
}

.loupe-coord-tag {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: var(--laser-cyan);
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* 底部状态读数 HUD */
.photo-hud-footer {
  height: 40px;
  min-height: 40px;
  background: rgba(11, 17, 26, 0.95);
  border-top: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-sub);
  z-index: 40;
}

.hud-info-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hud-val-highlight {
  color: var(--laser-cyan);
  font-weight: 600;
}

/* ==========================================================================
   模式 2: 空间实景 AR 模式面板 (WebXR Spatial AR)
   ========================================================================== */
.ar-workspace {
  width: 100%;
  height: 100%;
  position: relative;
  background-color: #000;
  overflow: hidden;
}

#ar-viewport-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

/* WebXR DOM Overlay UI */
.ar-overlay-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 16px;
  z-index: 60;
}

.ar-header-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: auto;
}

.ar-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ar-history-badge {
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.35);
  color: var(--laser-cyan);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.ar-live-distance-badge {
  background: rgba(18, 25, 36, 0.88);
  border: 1px solid var(--laser-cyan);
  border-radius: var(--radius-full);
  padding: 8px 20px;
  color: var(--laser-cyan);
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 0 20px var(--laser-cyan-glow);
  letter-spacing: 0.5px;
}

.ar-btn-exit {
  background: rgba(244, 63, 94, 0.2);
  border: 1px solid var(--rose-warn);
  color: var(--rose-warn);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* AR 沉浸态专用浮动消息悬浮架 */
.ar-toast-shelf {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
  width: 90%;
  max-width: 360px;
}

.ar-toast-shelf .toast-bubble {
  background: rgba(18, 25, 36, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid var(--laser-cyan);
  color: #fff;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 24px rgba(0, 229, 255, 0.35);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: none;
}

.ar-toast-shelf .toast-bubble.success {
  border-color: var(--emerald-pass);
  box-shadow: 0 4px 24px rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
}

.ar-toast-shelf .toast-bubble.warn {
  border-color: var(--amber-gold);
  box-shadow: 0 4px 24px rgba(255, 183, 3, 0.4);
  color: #fde68a;
}

.ar-toast-shelf .toast-bubble.error {
  border-color: var(--rose-warn);
  box-shadow: 0 4px 24px rgba(244, 63, 94, 0.4);
  color: #fecdd3;
}

.ar-center-reticle-hint {
  align-self: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  color: #fff;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
}

.ar-controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: auto;
  margin-bottom: 12px;
}

.ar-pin-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--laser-cyan), #0077b6);
  border: 4px solid #fff;
  color: #000;
  box-shadow: 0 0 25px var(--laser-cyan-glow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease;
}
.ar-pin-btn:active {
  transform: scale(0.92);
}
.ar-pin-btn svg {
  pointer-events: none;
}

.ar-tool-btn-sm {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(18, 25, 36, 0.9);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.ar-tool-btn-sm:active {
  transform: scale(0.92);
}

.ar-tool-btn-sm svg {
  pointer-events: none;
}

/* 保存成功与动效状态 */
.btn-saved-flash {
  border-color: var(--emerald-pass) !important;
  color: var(--emerald-pass) !important;
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.8) !important;
  transform: scale(1.15) !important;
}

.badge-bounce {
  animation: badgeBounce 0.35s ease;
}

@keyframes badgeBounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); color: var(--emerald-pass); }
  100% { transform: scale(1); }
}

/* AR 不可用状态卡片 (iOS / 桌面端) */
.ar-unsupported-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(18, 25, 36, 0.92);
  border: 1px solid var(--border-dim);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  max-width: 460px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-elevated);
}

.ar-unsupported-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(255, 183, 3, 0.12);
  border: 1px solid rgba(255, 183, 3, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--amber-gold);
}

/* ==========================================================================
   模式 3: 屏幕贴靠游标卡尺 (Screen Caliper)
   ========================================================================== */
.caliper-workspace {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at center, #0f172a 0%, var(--bg-deep) 100%);
  overflow: hidden;
}

.caliper-toolbar {
  height: 46px;
  min-height: 46px;
  background: rgba(18, 25, 36, 0.92);
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
}

.caliper-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: none;
}

#caliper-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.caliper-readout-card {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 25, 36, 0.94);
  border: 1px solid var(--laser-cyan);
  border-radius: var(--radius-md);
  padding: 10px 24px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 20px var(--laser-cyan-glow);
  z-index: 30;
  pointer-events: none;
}

.caliper-readout-val {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--laser-cyan);
  line-height: 1.1;
}

.caliper-readout-unit {
  font-size: 14px;
  color: var(--text-sub);
  margin-left: 4px;
}

.caliper-readout-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ==========================================================================
   通联组件: 历史记录抽屉 / 标定校准弹窗 / Toast
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-elevated);
  overflow: hidden;
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  display: flex;
}
.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 13px;
  color: var(--text-sub);
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-dim);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-base);
}

/* 历史表格样式 */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
}
.history-table th, .history-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-dim);
}
.history-table th {
  color: var(--text-dim);
  font-weight: 500;
}
.history-table td {
  color: var(--text-main);
}

/* Toast 提示容器 */
.toast-shelf {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}

.toast-bubble {
  background: rgba(18, 25, 36, 0.95);
  border: 1px solid var(--border-dim);
  backdrop-filter: blur(12px);
  color: var(--text-main);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  animation: toastFadeIn 0.25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast-bubble.success {
  border-color: var(--emerald-ok);
  color: var(--emerald-ok);
}
.toast-bubble.warn {
  border-color: var(--amber-gold);
  color: var(--amber-gold);
}
.toast-bubble.error {
  border-color: var(--rose-warn);
  color: var(--rose-warn);
}

@keyframes toastFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   YINUNU Cloud 统一品牌页脚规范样式
   ========================================================================== */
.yinunu-footer {
  margin-top: 1.5rem;
  padding: 1.5rem 1rem 1rem;
  border-top: 1px solid var(--border-dim);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.8;
}

.yinunu-footer-brand {
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 0.3rem;
}

.yinunu-footer-links {
  margin-bottom: 0.35rem;
}

.yinunu-footer-links a {
  color: var(--text-sub);
  text-decoration: none;
  transition: color 0.2s ease;
}

.yinunu-footer-links a:hover {
  color: var(--text-main);
  text-decoration: underline;
}

.yinunu-footer-sep {
  margin: 0 0.5rem;
  opacity: 0.4;
}

.yinunu-footer-copy {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ==========================================================================
   移动端与窄屏设备全面响应式适配 (兼容 iPhone SE 375px 及各类小屏)
   ========================================================================== */
@media (max-width: 640px) {
  .app-header {
    height: 48px;
    min-height: 48px;
    padding: 0 8px;
  }

  .brand-wrapper {
    gap: 6px;
  }

  .brand-portal-logo {
    height: 22px;
    width: 88px;
  }

  .title-text-full {
    display: none;
  }

  .title-text-compact {
    display: inline;
    font-size: 13px;
    font-weight: 700;
  }

  .hide-on-mobile {
    display: none !important;
  }

  .header-actions {
    gap: 5px;
  }

  /* 状态指示器在小屏仅保留呼吸灯圆点，隐藏长文本避免挤压爆行 */
  .device-status-badge {
    padding: 4px 6px;
    background: transparent;
    border-color: transparent;
  }

  .status-text-desktop {
    display: none;
  }

  .unit-select-wrap {
    padding: 1px 3px;
  }

  .unit-select {
    padding: 2px 4px;
    font-size: 11px;
  }

  .header-btn {
    padding: 4px 7px;
    font-size: 11px;
  }

  .header-btn-text {
    display: none;
  }

  .history-pill {
    font-size: 9px;
    padding: 0 4px;
  }

  /* 模式导航栏紧凑单行无折行排布 */
  .mode-tabs-bar {
    padding: 3px 6px;
    gap: 5px;
  }

  .mode-tab-btn {
    padding: 5px 9px;
    font-size: 11px;
    gap: 4px;
  }

  .tab-label-full {
    display: none;
  }

  .tab-label-compact {
    display: inline;
  }

  .tab-badge-rec {
    font-size: 8px;
    padding: 0 3px;
  }

  /* 照片工具栏移动端紧凑无换行横滑 */
  .photo-toolbar {
    height: 42px;
    min-height: 42px;
    padding: 0 6px;
    gap: 4px;
  }

  .toolbar-group {
    gap: 4px;
  }

  .btn-tool {
    padding: 4px 8px;
    font-size: 11px;
  }

  .tool-select {
    padding: 3px 6px;
    font-size: 11px;
  }

  .calibration-bar {
    max-width: 95%;
    padding: 4px 10px;
    font-size: 11px;
    gap: 6px;
  }

  .cal-status-text {
    font-size: 11px;
  }

  .cal-action-btn {
    font-size: 10px;
    padding: 2px 8px;
    white-space: nowrap;
  }

  .empty-guide-card {
    padding: 20px 16px;
    width: 94%;
  }

  .guide-title {
    font-size: 15px;
  }

  .guide-desc {
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 14px;
  }

  .photo-hud-footer {
    padding: 0 8px;
    font-size: 10px;
  }

  .caliper-readout-card {
    padding: 8px 16px;
  }

  .caliper-readout-val {
    font-size: 26px;
  }
}

@media (max-width: 380px) {
  .brand-portal-logo {
    height: 20px;
    width: 80px;
  }

  .brand-title {
    display: none; /* 针对 375px 以下极端小屏，保留品牌 Logo 隐藏冗余文字，确保功能按钮全露出 */
  }

  .mode-tab-btn {
    padding: 4px 7px;
    font-size: 10px;
  }
}


/* ---------- YINUNU 通用模态弹窗（产品矩阵 & 隐私条款） ---------- */
.yinunu-products-modal[hidden] {
  display: none !important;
}

.yinunu-products-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.yinunu-products-modal * {
  box-sizing: border-box;
}

.yinunu-products-modal a {
  text-decoration: none;
}

.yinunu-products-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.yinunu-products-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  background: #181c2a !important;
  color: #f1f5f9 !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: yinunuFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes yinunuFadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.yinunu-products-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: transparent !important;
}

.yinunu-products-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.yinunu-products-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: #f8fafc !important;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.yinunu-products-subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: #94a3b8 !important;
  line-height: 1.4;
}

.yinunu-products-close {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  font-size: 1.5rem;
  line-height: 1;
  color: #94a3b8 !important;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.yinunu-products-close:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

.yinunu-products-body {
  padding: 1.25rem 1.5rem 1.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: transparent !important;
  color: #f1f5f9 !important;
}

.yinunu-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.yinunu-product-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 8px;
  text-decoration: none !important;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.yinunu-product-item:hover {
  transform: translateY(-2px);
  border-color: #38bdf8 !important;
  background: rgba(56, 189, 248, 0.06) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.yinunu-product-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f1f5f9 !important;
  margin-bottom: 0.35rem;
  transition: color 0.15s ease;
}

.yinunu-product-url {
  font-size: 0.75rem;
  color: #94a3b8 !important;
  word-break: break-all;
  transition: color 0.15s ease;
}

.yinunu-product-item:hover .yinunu-product-name {
  color: #38bdf8 !important;
}

.yinunu-product-item:hover .yinunu-product-url {
  color: #cbd5e1 !important;
}

/* ---------- 隐私条款专属样式 ---------- */
.yinunu-privacy-body {
  font-size: 0.85rem;
  line-height: 1.75;
  color: #cbd5e1 !important;
}

.yinunu-privacy-lead {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1) !important;
  color: #f1f5f9 !important;
}

.yinunu-privacy-body h4 {
  margin: 1.1rem 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #38bdf8 !important;
}

.yinunu-privacy-body p {
  margin: 0.4rem 0;
  color: #cbd5e1 !important;
}

.yinunu-privacy-body strong {
  color: #f8fafc !important;
  font-weight: 600;
}

.yinunu-privacy-bullet {
  padding-left: 0.8rem;
  position: relative;
}

.yinunu-privacy-bullet::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #38bdf8 !important;
}

.yinunu-privacy-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.85rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: rgba(0, 0, 0, 0.18) !important;
}

.yinunu-privacy-agree-btn {
  background: #0284c7 !important;
  color: #ffffff !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 6px;
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.yinunu-privacy-agree-btn:hover {
  background: #0369a1 !important;
  opacity: 0.95;
  transform: translateY(-1px);
}

@media (max-width: 480px) {
  .yinunu-products-card { max-height: 90vh; }
  .yinunu-products-grid { grid-template-columns: 1fr; }
  .yinunu-privacy-footer { justify-content: stretch; }
  .yinunu-privacy-agree-btn { width: 100%; text-align: center; }
}
