/* ==========================================================================
   量尺宝 · 全局样式
   风格：简洁工装风、低饱和度，兼顾工地强光可读性与夜间弱光
   ========================================================================== */

:root {
  --bg: #f2f4f7;
  --bg-elev: #ffffff;
  --bg-sunken: #e7eaf0;
  --line: #d7dce5;
  --text: #1b2432;
  --text-dim: #6b7787;
  --brand: #1f6feb;
  --brand-ink: #ffffff;
  --danger: #d64545;
  --ok: #2f855a;
  --warn: #b7791f;
  --measure: #2f7cf6;   /* 测量线蓝 */
  --reference: #e5484d; /* 标定参考线红 */
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .08);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --appbar-h: 56px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0f172a;
  --bg-elev: #172236;
  --bg-sunken: #0b1322;
  --line: #26324a;
  --text: #e7edf7;
  --text-dim: #93a2b8;
  --brand: #4d8dff;
  --brand-ink: #0b1220;
  --danger: #ff6b6b;
  --ok: #48bb78;
  --warn: #ecc94b;
  --measure: #63a4ff;
  --reference: #ff6b6b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  display: flex;
  flex-direction: column;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ------------------------------ 顶栏 ------------------------------ */
.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--appbar-h);
  padding: calc(var(--safe-t) + 6px) 10px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.appbar-titles { flex: 1; min-width: 0; }
.appbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar-sub {
  margin: 1px 0 0;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
}
.icon-btn:active { background: var(--bg-sunken); }

/* ------------------------------ 页面 ------------------------------ */
.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px calc(96px + var(--safe-b));
}
.section-label {
  margin: 6px 2px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* 列表卡片 */
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .08s ease;
}
.card:active { transform: scale(.985); }
.card-main { flex: 1; min-width: 0; }
.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-meta { margin: 3px 0 0; font-size: 12px; color: var(--text-dim); }
.card-chev { color: var(--text-dim); font-size: 20px; }
.card-actions { display: flex; gap: 2px; }

.avatar {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  color: var(--brand);
  font-size: 18px;
  font-weight: 600;
}

/* 空状态 */
.empty {
  margin: 42px auto;
  max-width: 300px;
  text-align: center;
  color: var(--text-dim);
}
.empty-emoji { font-size: 40px; display: block; margin-bottom: 10px; opacity: .8; }
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 15px; }
.empty p { margin: 0; font-size: 13px; line-height: 1.6; }

/* 悬浮新建按钮 */
.fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(18px + var(--safe-b));
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 50px;
  padding: 0 20px 0 16px;
  border: none;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--brand) 42%, transparent);
}
.fab:active { transform: scale(.96); }
.fab span { font-size: 20px; line-height: 1; }

/* ------------------------------ 文件中心 ------------------------------ */
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.file-icon {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 19px;
}
.file-main { flex: 1; min-width: 0; }
.file-name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-all;
}
.file-meta { margin-top: 3px; font-size: 11.5px; color: var(--text-dim); }
.file-actions { display: flex; gap: 2px; flex: none; }
.file-actions .icon-btn { width: 34px; height: 34px; font-size: 16px; }

/* ------------------------------ 素材多选 ------------------------------ */
.sel-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.sel-bar .btn { flex: 1; }
.media-tile.selected { outline: 3px solid var(--brand); outline-offset: -3px; }
.tile-check {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .92);
  background: rgba(8, 14, 26, .45);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.tile-check.on { background: var(--brand); border-color: var(--brand); }

/* ------------------------------ 素材网格 ------------------------------ */
.media-cell { position: relative; aspect-ratio: 1 / 1; }
.media-cell .media-tile { width: 100%; height: 100%; }
.tile-more {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(8, 14, 26, .55);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.tile-more:active { background: rgba(8, 14, 26, .85); }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.media-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
}
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile .badge {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(8, 14, 26, .72);
  color: #fff;
  font-size: 10.5px;
  letter-spacing: .02em;
}
.media-tile .badge.video { background: rgba(31, 111, 235, .82); }
.media-tile .badge.done { background: rgba(47, 133, 90, .85); }
.media-tile .tile-name {
  position: absolute;
  inset: auto 0 0 0;
  padding: 14px 6px 5px;
  font-size: 10.5px;
  color: #fff;
  background: linear-gradient(to top, rgba(4, 8, 16, .78), transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 操作按钮组 */
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
}
.btn:active { background: var(--bg-sunken); }
.btn.primary {
  border-color: transparent;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
}
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ------------------------------ 弹窗 ------------------------------ */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 10, 18, .55);
  backdrop-filter: blur(3px);
  animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: min(420px, 100%);
  max-height: 84vh;
  overflow-y: auto;
  padding: 18px;
  border-radius: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(4, 8, 16, .4);
}
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.modal .hint { margin: 0 0 14px; font-size: 12.5px; color: var(--text-dim); line-height: 1.6; }
.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 6px; font-size: 12.5px; color: var(--text-dim); }
.input, .select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* ≥16px 防止 iOS 聚焦缩放 */
}
.input:focus, .select:focus { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 1px; }
.unit-group { display: flex; gap: 6px; }
.unit-group .chip {
  flex: 1;
  min-height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 14px;
}
.unit-group .chip[aria-pressed="true"] {
  border-color: transparent;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
}
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
.space-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.space-presets .chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 13px;
}

/* ------------------------------ 轻提示 ------------------------------ */
.toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(24px + var(--safe-b));
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: min(88vw, 420px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(12, 18, 30, .92);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 8px 24px rgba(4, 8, 16, .35);
  animation: toastIn .18s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
.toast.out { opacity: 0; transition: opacity .22s ease; }

.offline-bar {
  position: fixed;
  left: 0; right: 0; top: 0;
  z-index: 200;
  padding: 5px 12px;
  background: var(--warn);
  color: #1b1300;
  font-size: 12px;
  text-align: center;
}

/* 键盘打开时把轻提示移到顶部，避免压住确认按钮 */
/* 键盘打开时隐藏画布提示条，避免和键盘/提示重叠 */
body.keypad-open .canvas-hint { display: none; }
body.sheet-open .canvas-hint { display: none; }
body.sheet-open .toast-root { bottom: auto; top: calc(88px + var(--safe-t)); }

body.keypad-open .toast-root {
  bottom: auto;
  top: calc(96px + var(--safe-t));
}

/* 数值面板里的实时预览 */
.value-preview {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg-sunken);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}
.value-preview.is-empty { color: var(--text-dim); font-weight: 400; }

/* ------------------------------ 数字键盘 ------------------------------ */
.keypad-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  /* 只做很轻的压暗：输入时仍能看清画布上的尺寸线 */
  background: rgba(6, 10, 18, .14);
  animation: fade .14s ease;
}
.keypad {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 520px);
  bottom: 0;
  z-index: 101;
  padding: 6px 12px calc(12px + var(--safe-b));
  background: var(--bg-elev);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -10px 34px rgba(4, 8, 16, .38);
  animation: sheetIn .18s ease;
}
.keypad.out { opacity: 0; transform: translate(-50%, 14px); transition: .18s ease; }
.keypad-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 2px 10px;
}
.keypad-cancel, .keypad-clear {
  flex: none;
  min-width: 52px;
  height: 34px;
  border: none;
  border-radius: 9px;
  background: var(--bg-sunken);
  color: var(--text-dim);
  font-size: 13px;
}
.keypad-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.keypad-title b { font-size: 13px; font-weight: 600; }
.keypad-title small {
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--text-dim);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.keypad-display {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 16px;
  margin-bottom: 8px;
  background: var(--bg-sunken);
  border-radius: 12px;
}
.keypad-value {
  font-size: 30px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  line-height: 1.1;
}
.keypad-unit { font-size: 14px; color: var(--text-dim); }
.keypad-units { display: flex; gap: 6px; margin-bottom: 8px; }
.keypad-units .chip {
  flex: 1;
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 13px;
}
.keypad-units .chip[aria-pressed="true"] {
  border-color: transparent;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
}
.keypad-quick { display: flex; gap: 6px; margin-bottom: 8px; }
.keypad-quick .chip {
  flex: 1;
  min-height: 32px;
  border-radius: 8px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
}
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.keypad-key {
  min-height: 54px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 22px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: transform .06s ease, background .06s ease;
}
.keypad-key:active { transform: scale(.96); background: var(--bg-sunken); }
.keypad-fn { font-size: 19px; color: var(--text-dim); }
.keypad-ok {
  width: 100%;
  min-height: 50px;
  margin-top: 10px;
  border: none;
  border-radius: 12px;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 16px;
  font-weight: 600;
}
.keypad-ok:active { transform: scale(.985); }

/* ------------------------------ 编辑器 ------------------------------ */

/* 编辑页占满整个视口，隐藏全局顶栏 */
body.editing .appbar { display: none; }
.view.editor-page {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 视频帧标注画布 */
.annot-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.editor-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: #0b0f17;
}
.editor-top {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(var(--safe-t) + 6px) 8px 6px;
  background: rgba(10, 15, 25, .94);
  color: #eaf1ff;
  border-bottom: 1px solid #1e2a40;
}
.editor-title { flex: 1; min-width: 0; font-size: 13px; line-height: 1.2; }
.editor-title b { display: block; font-size: 14px; font-weight: 600; }
.editor-title small { color: #8fa2bd; font-size: 11px; }
.editor-top .icon-btn { color: #eaf1ff; }
.editor-top .icon-btn:active { background: #1c2740; }

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  background: #0b0f17;
}
#editorCanvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* 状态提示条（如"请先设置比例尺"） */
.canvas-hint {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  max-width: calc(100% - 20px);
  padding: 7px 14px;
  border-radius: 14px;
  background: rgba(8, 14, 26, .82);
  color: #dbe6f7;
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
  border: 1px solid #22304a;
}

/* 放大镜 */
.loupe {
  position: absolute;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .3);
  pointer-events: none;
  overflow: hidden;
  background: #111;
  transform: translate(-50%, -50%);
  z-index: 5;
}

/* 编辑器工具栏 */
.toolbar {
  flex: none;
  padding: 8px 8px calc(8px + var(--safe-b));
  background: #0d1420;
  border-top: 1px solid #1b2537;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tool-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.tool-scroll::-webkit-scrollbar { display: none; }
.tool {
  flex: none;
  min-width: 54px;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 8px;
  border-radius: 12px;
  border: 1px solid #1e2a40;
  background: #121c2e;
  color: #c9d6ea;
  font-size: 11px;
  line-height: 1.1;
}
.tool i { font-size: 18px; font-style: normal; }
.tool[aria-pressed="true"] {
  background: var(--brand);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.tool:disabled { opacity: .38; }
.tool-row { display: flex; gap: 6px; align-items: stretch; }
.tool-row .btn {
  flex: 1;
  min-height: 42px;
  padding: 0 6px;
  font-size: 12.5px;
  white-space: nowrap;
}
.seg {
  display: flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
}
.seg button {
  flex: 1;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  white-space: nowrap;
}
.seg button[aria-pressed="true"] {
  background: var(--bg-elev);
  color: var(--text);
  font-weight: 600;
}
/* 编辑器内是深色工具条，用深色变体 */
.seg.dark { background: #121c2e; border-color: #1e2a40; }
.seg.dark button { color: #9fb0c8; }
.seg.dark button[aria-pressed="true"] { background: #24354f; color: #eaf1ff; }

/* 底部抽屉（标注列表 / 设置） */
.sheet {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 560px);
  bottom: 0;
  max-height: 62%;
  overflow-y: auto;
  padding: 14px 14px calc(14px + var(--safe-b));
  background: var(--bg-elev);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .35);
  z-index: 8;
  animation: sheetIn .18s ease;
}
@keyframes sheetIn { from { transform: translate(-50%, 18px); opacity: .6 } to { transform: translate(-50%, 0); opacity: 1 } }
.sheet h3 { margin: 0 0 10px; font-size: 15px; }
/* 数值面板字段多，给高一点；底部按钮吸附，永远可见 */
.sheet-tall { max-height: 86%; }
.sheet .modal-actions {
  position: sticky;
  bottom: 0;
  padding-top: 10px;
  padding-bottom: 2px;
  background: var(--bg-elev);
}
.mark-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.mark-row:last-child { border-bottom: none; }
.mark-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.mark-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 滑块（线条粗细） */
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--brand); }

/* ------------------------------ 视频页 ------------------------------ */
.video-stage {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
}
.video-stage video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.video-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.timeline { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.timeline input[type="range"] { flex: 1; accent-color: var(--brand); }
.time-label { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* 关键帧列表 */
.frame-list { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 8px; }
.frame-item {
  flex: none;
  width: 96px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  text-align: left;
  padding: 0;
}
.frame-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.frame-item span { display: block; padding: 5px 6px; font-size: 11px; color: var(--text); }

/* ------------------------------ 设置页 ------------------------------ */
.setting-group {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
}
.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
  text-align: left;
  width: 100%;
}
.setting-row:last-child { border-bottom: none; }
.setting-row .grow { flex: 1; }
.setting-row .value { color: var(--text-dim); font-size: 13px; }
.color-dots { display: flex; gap: 8px; }
.color-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
  padding: 0;
}
.color-dot[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--text);
}
.legal {
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text-dim);
  padding: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ------------------------------ 登录 / 会员 ------------------------------ */
body.no-appbar .appbar { display: none; }
body.no-appbar .view { padding-top: calc(18px + var(--safe-t)); }

.login-view {
  display: flex;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
}
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.login-logo { font-size: 46px; text-align: center; line-height: 1; }
.login-title { margin: 0; font-size: 26px; text-align: center; }
.login-sub { margin: 0 0 6px; font-size: 12.5px; color: var(--text-dim); text-align: center; }
.login-foot { text-align: center; margin-top: 12px; }
.form-error { color: var(--danger); font-size: 13px; margin: 2px 0; }
.btn.block { width: 100%; }

/* 顶栏同步状态 */
.sync-pill {
  flex: 0 0 auto;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--text-dim);
  margin-left: auto;
  margin-right: 6px;
  white-space: nowrap;
}
.sync-pill.busy { color: var(--brand); background: rgba(31, 111, 235, .14); }
.sync-pill.warn { color: var(--warn); background: rgba(183, 121, 31, .16); }
.sync-pill.bad { color: var(--danger); background: rgba(214, 69, 69, .14); }

/* 会员管理 */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.stat b { display: block; font-size: 17px; }
.stat span { font-size: 11px; color: var(--text-dim); }

.member-list { display: flex; flex-direction: column; gap: 8px; }
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
}
.member-main { flex: 1; min-width: 0; }
.member-name { display: flex; align-items: center; gap: 6px; font-size: 14.5px; flex-wrap: wrap; }
.member-meta { margin-top: 4px; font-size: 11.5px; color: var(--text-dim); display: flex; gap: 6px; align-items: center; }
.expiry.ok { color: var(--ok); }
.expiry.warn { color: var(--warn); }
.expiry.bad { color: var(--danger); }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: var(--bg-sunken); color: var(--text-dim); }
.tag.admin { background: rgba(31, 111, 235, .14); color: var(--brand); }
.tag.me { background: rgba(47, 133, 90, .14); color: var(--ok); }
.tag.bad { background: rgba(214, 69, 69, .14); color: var(--danger); }
.usage { margin-top: 6px; display: flex; align-items: center; gap: 8px; }
.usage-bar { flex: 1; height: 5px; border-radius: 3px; background: var(--bg-sunken); overflow: hidden; }
.usage-bar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.usage-bar i.bad { background: var(--danger); }
.usage-text { font-size: 10.5px; color: var(--text-dim); white-space: nowrap; }
.chevron { color: var(--text-dim); font-size: 18px; }
/* 填写 / 编辑面板打开时，底部工具栏让位（否则键盘 + 工具栏会把输入框挤到看不见） */
body.sheet-open .toolbar,
body.keypad-open .toolbar {
  display: none;
}

/* 面板打开时画布底部留白，保证面板离键盘有距离 */
body.sheet-open .canvas-wrap,
body.keypad-open .canvas-wrap {
  padding-bottom: 0;
}
/* ------------------------------ 数值面板紧凑布局 ------------------------------ */
.sheet-compact { padding-top: 12px; }
.field-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.field-inline-label {
  flex: 0 0 auto;
  width: 62px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.2;
}
.field-inline .input {
  flex: 1;
  min-width: 0;
  height: 42px;
}
.field-inline-preview { margin-bottom: 10px; }
.field-inline-preview .value-preview {
  flex: 1;
  min-width: 0;
  margin: 0;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}