/* ═══════════════ 帧相 · PhySenLab 清新实验室主题 ═══════════════ */
:root {
  --primary: #4A90E2;
  --primary2: #6BB6FF;
  --grad: linear-gradient(135deg, #4A90E2, #6BB6FF);
  --text: #2C3E50;
  --text2: #5A6C7D;
  --text3: #8B9DC3;
  --border: #E1EEF7;
  --bg: #F8FBFF;
  --card: #ffffff;
  --shadow: 0 2px 12px rgba(74,144,226,.1);
  --shadow2: 0 6px 20px rgba(74,144,226,.2);
  --ok: #27ae60;
  --warn: #F39C12;
  --danger: #e74c3c;
  --amber: #d9930d;
  --radius: 12px;
  font-size: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  display: flex; flex-direction: column;
  overflow: hidden;
  user-select: none;
}
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ─── 顶部栏 · 毛玻璃白 ─── */
#topbar {
  height: 70px; flex: 0 0 70px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; color: #fff;
  box-shadow: 0 4px 14px rgba(74,144,226,.35);
}
.brand-text h1 { font-size: 18px; letter-spacing: 2px; }
.brand-text span { font-size: 10.5px; color: var(--text3); letter-spacing: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.tb-btn {
  display: flex; align-items: center; gap: 6px;
  background: #fff; color: var(--text2);
  border: 1.5px solid var(--border); border-radius: 22px;
  padding: 8px 16px; font-size: 12.5px; font-weight: 600;
  transition: all .3s ease;
}
.tb-btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow2); }
.tb-sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.topbar-status { margin-left: auto; font-size: 12px; color: var(--text3); font-family: Consolas, monospace; }
.back-link {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  background: var(--grad); color: #fff; text-decoration: none;
  border-radius: 22px; padding: 8px 18px; font-size: 12.5px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(74,144,226,.3);
  transition: all .3s ease;
}
.back-link:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(74,144,226,.4); }

/* ─── 工作区 ─── */
#workspace { flex: 1; display: flex; min-height: 0; gap: 12px; padding: 12px; }
#leftPanel { width: 280px; flex: 0 0 280px; overflow-y: auto; padding-right: 2px; }
#rightPanel { width: 400px; flex: 0 0 400px; display: flex; flex-direction: column; min-height: 0; gap: 10px; overflow-y: auto; }
.panel-title {
  font-size: 13px; font-weight: 700; color: var(--text2); letter-spacing: 3px; flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
}
.panel-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ─── 步骤卡片 ─── */
.step-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px; overflow: hidden;
  box-shadow: var(--shadow); transition: all .3s ease;
}
.step-card:hover { box-shadow: 0 4px 16px rgba(74,144,226,.16); }
.step-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; font-size: 13.5px; font-weight: 700;
  cursor: pointer; transition: all .3s ease;
}
.step-head:hover { background: #F4F9FF; }
.step-no {
  width: 22px; height: 22px; border-radius: 8px; flex: 0 0 22px;
  background: var(--grad); color: #fff; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(74,144,226,.3);
}
.step-head .chev { margin-left: auto; color: var(--text3); font-size: 11px; transition: transform .3s ease; }
.step-card:not(.open) .chev { transform: rotate(-90deg); }
.step-card:not(.open) .step-body { display: none; }
.step-body { padding: 2px 14px 14px; }

.drop-hint {
  border: 1.5px dashed #BCD9F5; border-radius: 10px;
  color: var(--text3); font-size: 12px; text-align: center;
  padding: 12px 8px; margin: 6px 0 10px; line-height: 1.7;
}
.video-info {
  font-size: 11.5px; color: var(--text2); line-height: 1.8;
  background: #F4F9FF; border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; margin: 6px 0 10px; word-break: break-all;
}
.video-info b { color: var(--primary); font-family: Consolas, monospace; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--text2); }
.form-grid input[type=number], .form-grid select {
  background: #fff; border: 1.5px solid var(--border); border-radius: 10px;
  color: var(--text); padding: 7px 9px; font-size: 12.5px; outline: none; width: 100%;
  font-family: Consolas, monospace; transition: all .3s ease;
}
.form-grid select { font-family: inherit; }
.form-grid input:focus, .form-grid select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(74,144,226,.15); }
.form-grid .chk { flex-direction: row; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer; }
.chk { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.chk input { accent-color: var(--primary); width: 14px; height: 14px; }
.chk-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 2px 0; font-size: 11.5px; color: var(--text2); }
.hint-line { font-size: 11px; color: var(--text3); line-height: 1.7; margin: 4px 0 8px; }

/* 按钮 */
.wide-btn {
  width: 100%; padding: 9px 12px; margin: 4px 0;
  background: #fff; color: var(--text2); font-weight: 600;
  border: 1.5px solid var(--border); border-radius: 24px;
  font-size: 12.5px; transition: all .3s ease;
}
.wide-btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow2); }
.wide-btn.accent { background: var(--grad); border: none; color: #fff; font-weight: 700; box-shadow: 0 4px 12px rgba(74,144,226,.3); }
.wide-btn.accent:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(74,144,226,.4); filter: brightness(1.05); }
.wide-btn.subtle { color: var(--text3); }
.wide-btn.armed {
  background: rgba(243,156,18,.1); border-color: var(--warn); color: var(--amber); font-weight: 700;
  animation: pulse 1.2s ease infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(243,156,18,.12); } }
.btn-row { display: flex; gap: 6px; }
.mini-btn {
  background: #fff; border: 1.5px solid var(--border); color: var(--text2);
  border-radius: 16px; font-size: 11px; padding: 3px 10px; transition: all .3s ease;
}
.mini-btn:hover { color: var(--primary); border-color: var(--primary); }

/* 播放 */
.playback { margin: 8px 0; }
.pb-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pb-btn {
  width: 36px; height: 32px; border-radius: 50%;
  background: #fff; border: 1.5px solid var(--border); color: var(--primary);
  font-size: 13px; transition: all .3s ease;
}
.pb-btn:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow2); }
.pb-btn.primary { background: var(--grad); border: none; color: #fff; width: 46px; height: 36px; border-radius: 20px; }
.time-label { font-size: 11px; color: var(--primary); margin-left: auto; font-family: Consolas, monospace; }
#timeSlider { width: 100%; accent-color: var(--primary); }

/* 进度 */
.progress-wrap { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.progress-bar { flex: 1; height: 8px; background: #EAF2FB; border-radius: 4px; overflow: hidden; }
#trackBar { height: 100%; width: 0; background: var(--grad); transition: width .1s; border-radius: 4px; }
#trackLabel { font-size: 11px; color: var(--primary); white-space: nowrap; font-family: Consolas, monospace; }

.result-box {
  font-size: 11.5px; color: var(--text2); line-height: 1.8;
  background: #F4F9FF; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-top: 8px; max-height: 150px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all; font-family: Consolas, monospace;
}

/* ─── 中央视频区 ─── */
#center { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#stageWrap {
  flex: 1; position: relative; min-height: 0;
  background: #EDF5FD; overflow: hidden;
  border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#stageEmpty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  color: var(--text3); text-align: center; line-height: 2.1; font-size: 13.5px;
}
#stageEmpty .empty-icon { font-size: 46px; opacity: .45; }
#modeBanner {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(243,156,18,.95); color: #fff;
  font-size: 12.5px; font-weight: 700; padding: 7px 18px; border-radius: 20px;
  box-shadow: 0 4px 16px rgba(243,156,18,.35); pointer-events: none; white-space: nowrap;
  z-index: 12;
}
#toast {
  position: absolute; top: 50%; left: 50%; z-index: 30;
  transform: translate(-50%, -50%) scale(.94);
  background: rgba(255,255,255,.97); color: var(--text);
  border: 1.5px solid var(--border);
  padding: 13px 30px; border-radius: 30px;
  font-size: 13.5px; font-weight: 600; text-align: center; line-height: 1.7;
  box-shadow: 0 10px 36px rgba(74,144,226,.25);
  opacity: 0; pointer-events: none;
  transition: opacity .7s ease, transform .7s ease;
  max-width: 82%; white-space: pre-line;
}
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#toast.ok { border-color: var(--ok); color: var(--ok); }
#toast.err { border-color: var(--danger); color: var(--danger); }
#toast.warn { border-color: var(--warn); color: var(--amber); }

/* ─── 右侧输出区 ─── */
#outputWrap {
  position: relative; flex: 0 0 auto;
  background: repeating-conic-gradient(#eef3f9 0% 25%, #fff 0% 50%) 0 0 / 20px 20px;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; min-height: 200px;
  display: flex; align-items: center; justify-content: center;
}
#output { display: block; max-width: 100%; }
#outputEmpty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 12.5px; background: transparent; pointer-events: none;
}

/* ─── 状态栏 ─── */
#statusbar {
  flex: 0 0 30px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; font-size: 11.5px; color: var(--text2);
  background: rgba(255,255,255,.85); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
#statusText.busy { color: var(--primary); }
#statusText.ok { color: var(--ok); }
#statusText.err { color: var(--danger); }
#statusRight { font-family: Consolas, monospace; color: var(--text3); }

/* ─── 帮助 ─── */
#helpModal {
  position: fixed; inset: 0; z-index: 95; background: rgba(44,62,80,.35);
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px);
}
.help-box {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 26px 30px; width: 460px; box-shadow: 0 20px 60px rgba(44,62,80,.25);
}
.help-box h2 { font-size: 17px; margin-bottom: 14px; }
.help-box table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.help-box td { padding: 7px 8px; border-bottom: 1px solid var(--border); color: var(--text2); }
.help-box td:first-child { color: var(--primary); font-weight: 700; white-space: nowrap; font-family: Consolas, monospace; }
.help-tip { font-size: 11.5px; color: var(--text3); line-height: 1.9; margin: 12px 0; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #CBDEEF; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #A9C8E6; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1180px) {
  #leftPanel { width: 250px; flex-basis: 250px; }
  #rightPanel { width: 320px; flex-basis: 320px; }
}
@media (max-width: 900px) {
  #workspace { flex-direction: column; overflow-y: auto; }
  #leftPanel, #rightPanel { width: 100%; flex: none; }
  #center { min-height: 60vh; }
  .brand-text span { display: none; }
  .topbar-status { display: none; }
  .back-link { margin-left: auto; padding: 7px 14px; }
}

/* 追踪模式切换 */
.mode-row { display: flex; gap: 6px; margin: 8px 0 6px; }
.mode-btn {
  flex: 1; padding: 8px 0; border-radius: 999px; border: 1.5px solid var(--line, #d9e6f5);
  background: #fff; color: var(--text2, #5a6b80); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .18s ease;
}
.mode-btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.mode-btn.active {
  background: var(--grad); border: none; color: #fff; font-weight: 700;
  box-shadow: 0 4px 12px rgba(74,144,226,.3);
}
