/* 动作帧 MotionFrame · 完整网页版 设计系统
   深色绿主题（对齐 iOS App）；手机端底部 Tab，桌面端左侧边栏 */

:root {
  --bg: #0b1210;
  --bg-2: #0f1a15;
  --card: rgba(255, 255, 255, 0.055);
  --card-2: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.1);
  --ink: #f3f7f4;
  --sub: rgba(235, 245, 238, 0.62);
  --faint: rgba(235, 245, 238, 0.38);
  --green: #34d399;
  --green-deep: #16a34a;
  --green-soft: rgba(52, 211, 153, 0.14);
  --orange: #fb923c;
  --orange-soft: rgba(251, 146, 60, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.14);
  --purple: #c084fc;
  --radius: 16px;
  --radius-s: 10px;
  --tabbar-h: 62px;
  --sidebar-w: 224px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, var(--bg-2), var(--bg) 320px);
  min-height: 100%;
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: var(--ink); }

/* ---------- 布局骨架 ---------- */
#app { display: flex; min-height: 100vh; }
#sidebar { display: none; }
#content {
  flex: 1;
  min-width: 0;
  padding: 14px 14px calc(var(--tabbar-h) + 26px + env(safe-area-inset-bottom, 0px));
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}
.page { display: none; animation: fadeIn 0.22s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 顶部标题条 */
.page-head { padding: 12px 4px 4px; }
.page-head h1 { font-size: 24px; font-weight: 800; letter-spacing: 0.5px; }
.page-head .sub { color: var(--sub); font-size: 13px; margin-top: 2px; }

/* 组内分段切换（训练|趋势 等） */
.group-seg {
  display: flex; gap: 6px; margin: 10px 0 4px; padding: 4px;
  background: var(--card); border-radius: 12px; width: fit-content;
}
.group-seg button {
  border: none; background: transparent; color: var(--sub); font-size: 14px; font-weight: 600;
  padding: 7px 18px; border-radius: 9px; cursor: pointer; transition: all 0.15s;
}
.group-seg button.on { background: var(--green); color: #06281a; }

/* 手机底部 Tab 栏 */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(12, 20, 16, 0.92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
#tabbar button {
  flex: 1; border: none; background: none; color: var(--faint); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 600;
}
#tabbar button .ic { font-size: 21px; line-height: 1.15; filter: grayscale(1) opacity(0.7); }
#tabbar button.on { color: var(--green); }
#tabbar button.on .ic { filter: none; }

/* 桌面端：侧边栏 + 隐藏底栏 */
@media (min-width: 920px) {
  #tabbar { display: none; }
  #sidebar {
    display: block; width: var(--sidebar-w); flex: none;
    border-right: 1px solid var(--line);
    padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  }
  #sidebar .brand { font-size: 19px; font-weight: 800; padding: 0 10px 16px; }
  #sidebar .brand .badge {
    font-size: 10px; vertical-align: 2px; background: var(--green); color: #06281a;
    border-radius: 99px; padding: 2px 8px; margin-left: 6px;
  }
  #sidebar .nav-h { font-size: 11px; color: var(--faint); padding: 14px 10px 4px; font-weight: 700; }
  #sidebar .nav-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    border: none; background: none; color: var(--sub); font-size: 14px; font-weight: 600;
    padding: 9px 10px; border-radius: 10px; cursor: pointer; text-align: left;
  }
  #sidebar .nav-item:hover { background: var(--card); color: var(--ink); }
  #sidebar .nav-item.on { background: var(--green-soft); color: var(--green); }
  #content { padding: 20px 34px 60px; max-width: 1060px; }
  .group-seg { display: none !important; }  /* 桌面侧栏直接列出每页，无需组内分段（压过 JS 内联 display:flex） */
}

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-top: 14px;
}
.card.tight { padding: 12px 14px; }
.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title .grow { flex: 1; }
.hint { color: var(--sub); font-size: 13px; margin-top: 4px; }
.sec-h { font-size: 14px; font-weight: 700; margin: 16px 0 8px; display: flex; align-items: center; gap: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--green); color: #06281a; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; padding: 12px 18px; cursor: pointer; transition: opacity 0.15s;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { background: rgba(255, 255, 255, 0.14); color: var(--faint); cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--green); border: 1.5px solid var(--green); }
.btn.subtle { background: var(--card-2); color: var(--ink); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.sm { font-size: 13px; padding: 8px 13px; border-radius: 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--green-soft); color: var(--green); border: none;
  font-size: 12px; font-weight: 600; border-radius: 999px; padding: 5px 11px; cursor: pointer;
}
.chip.orange { background: var(--orange-soft); color: var(--orange); }
.chip.plain { background: var(--card-2); color: var(--sub); }

.tag {
  display: inline-block; font-size: 11px; font-weight: 700; border-radius: 6px;
  padding: 2px 7px; background: var(--card-2); color: var(--sub);
}
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.orange { background: var(--orange-soft); color: var(--orange); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }

.spinner {
  width: 16px; height: 16px; flex: none;
  border: 2.5px solid rgba(255, 255, 255, 0.25); border-top-color: currentColor;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.err-box {
  background: var(--red-soft); border: 1px solid rgba(248, 113, 113, 0.3); color: var(--red);
  border-radius: var(--radius-s); padding: 10px 12px; font-size: 13px; margin-top: 10px;
}
.ok-box {
  background: var(--green-soft); border: 1px solid rgba(52, 211, 153, 0.3); color: var(--green);
  border-radius: var(--radius-s); padding: 10px 12px; font-size: 13px; margin-top: 10px;
}

/* 输入 */
.field { margin-top: 12px; }
.field label { font-size: 13px; color: var(--sub); font-weight: 600; display: block; margin-bottom: 5px; }
.input, textarea.input, select.input {
  width: 100%; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 10px 12px; font-size: 15px; outline: none;
}
.input:focus { border-color: var(--green); }
textarea.input { resize: vertical; min-height: 74px; }
select.input option { background: #14201a; color: var(--ink); }

/* 列表行 */
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-size: 15px; font-weight: 600; }
.row .d { font-size: 12.5px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .ar { color: var(--faint); flex: none; }

/* 网格卡（图库） */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.gcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; cursor: pointer; transition: transform 0.15s;
}
.gcard:hover { transform: translateY(-2px); }
.gcard img { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #14201a; }
.gcard .b { padding: 9px 11px 11px; }
.gcard .n { font-size: 13.5px; font-weight: 700; line-height: 1.35; }
.gcard .m { font-size: 11.5px; color: var(--sub); margin-top: 2px; }

/* 横向滚动分类条 */
.cat-bar {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 4px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.cat-bar::-webkit-scrollbar { display: none; }
.cat-bar button {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--sub);
  font-size: 13px; font-weight: 600; border-radius: 999px; padding: 7px 14px; cursor: pointer;
}
.cat-bar button.on { background: var(--green); border-color: var(--green); color: #06281a; }

/* 进度条 */
.bar { height: 8px; background: rgba(255, 255, 255, 0.1); border-radius: 99px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width 0.5s; }
.bar i.orange { background: var(--orange); }

/* 大数字统计 */
.stat-row { display: flex; gap: 10px; margin-top: 14px; }
.stat {
  flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 8px; text-align: center;
}
.stat .v { font-size: 22px; font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11.5px; color: var(--sub); margin-top: 1px; }

/* 空状态 */
.empty { text-align: center; padding: 44px 20px; color: var(--sub); }
.empty .ic { font-size: 44px; }
.empty .t { font-size: 16px; font-weight: 700; color: var(--ink); margin-top: 10px; }
.empty .d { font-size: 13px; margin-top: 4px; }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.62);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.18s ease; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.modal {
  background: #101b15; border: 1px solid var(--line); width: 100%; max-width: 620px;
  border-radius: 20px 20px 0 0; max-height: 88vh; overflow-y: auto;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom, 0px));
  animation: slideUp 0.22s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0.5; } to { transform: none; opacity: 1; } }
@media (min-width: 920px) {
  .modal-mask { align-items: center; padding: 30px; }
  .modal { border-radius: 20px; max-height: 84vh; }
}
.modal .m-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.modal .m-head h3 { flex: 1; font-size: 17px; font-weight: 800; }
.modal .m-close {
  border: none; background: var(--card-2); color: var(--sub); width: 30px; height: 30px;
  border-radius: 50%; cursor: pointer; font-size: 15px; flex: none;
}

/* Toast */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 22px + env(safe-area-inset-bottom, 0px)); z-index: 200;
  background: rgba(20, 32, 26, 0.96); border: 1px solid var(--line); color: var(--ink);
  font-size: 13.5px; font-weight: 600; padding: 10px 18px; border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  opacity: 0; pointer-events: none; transition: opacity 0.25s; max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; }
@media (min-width: 920px) { #toast { bottom: 34px; } }

/* 图表 */
.chart-wrap { margin-top: 8px; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-cap { font-size: 12px; color: var(--sub); margin-top: 4px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--sub); margin-top: 6px; flex-wrap: wrap; }
.legend .l { display: inline-flex; align-items: center; gap: 5px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* 视频分析区（analyze 模块用） */
.video-box { position: relative; border-radius: 14px; overflow: hidden; background: #000; margin-top: 12px; }
.video-box video { width: 100%; max-height: 60vh; display: block; }
/* object-fit: contain 让骨架 canvas 与 video 的留边完全一致——竖屏视频触发 max-height 截断时骨架才不会拉偏 */
.video-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; object-fit: contain; }
.live-badge {
  position: absolute; top: 10px; right: 10px; background: rgba(0, 0, 0, 0.62); color: #4ade80;
  font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 999px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.file-zone {
  border: 2px dashed rgba(255, 255, 255, 0.22); border-radius: 14px; padding: 30px 16px;
  text-align: center; cursor: pointer; transition: border-color 0.2s; margin-top: 12px;
}
.file-zone:hover, .file-zone.drag { border-color: var(--green); }
.file-zone .big { font-size: 15px; font-weight: 700; }
.file-zone .small { font-size: 12px; color: var(--sub); margin-top: 4px; }

/* 对错双图对比 */
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.vs .side { border-radius: 12px; overflow: hidden; border: 1.5px solid var(--line); }
.vs .side.w { border-color: rgba(248, 113, 113, 0.45); }
.vs .side.r { border-color: rgba(52, 211, 153, 0.45); }
.vs .side .lab { font-size: 12px; font-weight: 700; text-align: center; padding: 5px; }
.vs .side.w .lab { background: var(--red-soft); color: var(--red); }
.vs .side.r .lab { background: var(--green-soft); color: var(--green); }
.vs .side img { aspect-ratio: 3/4; object-fit: cover; width: 100%; background: #14201a; }

/* 加载屏 */
#splash {
  position: fixed; inset: 0; background: var(--bg); z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
#splash .logo { font-size: 46px; }
#splash .name { font-size: 20px; font-weight: 800; letter-spacing: 2px; }
#splash .spinner { width: 22px; height: 22px; color: var(--green); }

a { color: var(--green); }
::selection { background: rgba(52, 211, 153, 0.3); }
