/* =========================================================
   FPV 飞行复盘系统 · MVP 样式
   风格：深色、单页工具（与 track-editor 一致）
   ========================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #101418;
  --panel: #161c22;
  --panel-2: #1c242c;
  --line: #2a343e;
  --text: #d7dee6;
  --muted: #8a98a6;
  --accent: #4ea1f2;
  --ch-throttle: #f2c14e;
  --ch-roll: #4ea1f2;
  --ch-pitch: #7ee24e;
  --ch-yaw: #e24e9a;
}

html, body { height: 100%; }

body {
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 50px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 主区 ---------- */
main {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 10px;
  padding: 10px;
  height: calc(100vh - 51px);   /* 占满视口（顶栏固定 50px + 边框 1px） */
  min-height: 0;
}
.left {
  display: grid;                            /* 视频 | 曲线 并排，控制条横跨底部 */
  grid-template-columns: minmax(320px, 52%) 1fr;
  grid-template-rows: 1fr auto;             /* 内容行占满剩余高度；控制条吃底部 */
  gap: 10px;
  align-items: stretch;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;        /* 兜底：窗口极小时可滚动 */
}

/* ---------- 视频区 ---------- */
.video-wrap {
  display: flex;
  align-items: center;
  justify-content: center;   /* 视频在其面板内居中（单飞手 letterbox / 四宫格铺满） */
  background: #000;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
/* 尺寸/适配由 JS layoutVideoBox() 按模式设置：单飞手=原比例居中；四宫格=铺满面板 */
.video-box {
  position: relative;
  background: #05070a;
  overflow: hidden;
  width: 100%;
  height: 100%;
}
.video-box video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  transform-origin: 0 0;
}
.video-box canvas#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.video-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
}

/* ---------- 曲线区 ---------- */
.charts-wrap {
  align-self: stretch;       /* 高度对齐视频行（曲线在视频右侧，互不挤压） */
  min-height: 160px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.charts-wrap canvas { width: 100%; height: 100%; display: block; }

/* ---------- 播放控制 ---------- */
.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  flex-wrap: wrap;
  grid-column: 1 / -1;        /* 横跨视频+曲线两列 */
  position: sticky;           /* 滚动时控制条始终可见 */
  bottom: 0;
  z-index: 5;
}
.clock { font-variant-numeric: tabular-nums; color: var(--muted); }
.status { color: var(--muted); font-size: 12px; }

/* ---------- 侧栏 ---------- */
.right {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;            /* 允许收缩，避免子元素把侧栏撑爆 */
  overflow-y: auto;
  overflow-x: hidden;      /* 兜底：任何子元素溢出都被裁掉而非出现横向滚动 */
}
.right fieldset {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px 10px;
  background: var(--panel-2);
  min-width: 0;              /* fieldset 默认 min-width:min-content，会撑破侧栏导致横向滚动 */
}
/* 实时模式下隐藏仅复盘用的面板（见 app.js updatePanelVisibility） */
.right fieldset[hidden] { display: none !important; }
.right legend { color: var(--accent); font-size: 13px; padding: 0 6px; }
.right label { display: block; margin: 6px 0; color: var(--text); }
.right select, .right input[type="number"], .right input[type="text"] {
  width: 100%;
  margin-top: 2px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 6px;
}
.right .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.right .row > * { min-width: 0; }          /* flex 行内子项允许收缩 */
.right .row label { flex: none; margin: 0; font-size: 12px; color: var(--muted); }
.right .row input { width: 90px; margin: 0; }
.right .row select { width: auto; flex: none; margin: 0; }
#export-progress { min-height: 14px; }
.right .grow { flex: 1; min-width: 0; }
.row .grow { width: auto; margin: 0; }

/* 复选框行（叠加开关等） */
.right label.chk { display: flex; align-items: center; gap: 6px; margin: 6px 0; font-size: 12px; }
.right label.chk input { width: auto; margin: 0; flex: none; }

/* 标注列表 */
.ann-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.ann-row > * { min-width: 0; }
.ann-row select { width: auto; flex: none; margin: 0; }
.ann-row input[type="text"] { flex: 1 1 120px; margin: 0; }
.ann-list { list-style: none; margin: 4px 0 0; padding: 0; max-height: 150px; overflow-y: auto; }
.ann-list li {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 4px; font-size: 12px; color: var(--text);
  border-bottom: 1px dashed var(--line);
}
.ann-list .k { width: 32px; flex: none; font-size: 11px; }
.ann-list .t { font-variant-numeric: tabular-nums; color: var(--muted); width: 64px; flex: none; }
.ann-list .txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ann-list .x { margin-left: 2px; cursor: pointer; color: var(--muted); background: none; border: none; font-size: 12px; padding: 0 3px; }
.ann-list .x:hover { color: #e05e4e; }

/* 统计输出 */
.stats-out {
  margin-top: 6px;
  font: 11px/1.7 monospace;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
}
/* 油门分布直方图（FR-7） */
.stats-hist {
  width: 100%;
  height: 92px;
  display: block;
  margin-top: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
}
/* 会话元数据输入框略宽 */
.right .row input[type="text"] { width: 118px; }

/* ---------- 按钮 ---------- */
.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: #1d3a5c; border-color: #2c5e92; }
.btn.small { font-size: 12px; padding: 3px 8px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---------- 其他 ---------- */
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--muted);
}

@media (max-width: 960px) {
  main { grid-template-columns: 1fr; }
  .left { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }  /* 窄屏上下堆叠 */
  .transport { grid-column: auto; }
  .right { flex-direction: row; flex-wrap: wrap; }
  .right fieldset { flex: 1 1 280px; }
}