:root {
  --bg: #f0f2f5;
  --panel: #ffffff;
  --panel-soft: #fafafa;
  --ink: rgba(0, 0, 0, 0.88);
  --muted: rgba(0, 0, 0, 0.45);
  --line: rgba(5, 5, 5, 0.08);
  --accent: #1890ff;
  --accent-dark: #096dd9;
  --accent-light: #e6f4ff;
  --green-light: #f6ffed;
  --danger: #ff4d4f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-size: 14px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin: 10px 14px 8px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.topbar h1 { margin: 0; font-size: 16px; font-weight: 600; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.eyebrow { display: none; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.top-actions select { min-width: 280px; }
.top-actions a { color: var(--accent-dark); font-size: 13px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 14px 8px; }
.steps button { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--muted); padding: 10px 12px; text-align: left; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.steps button.active { color: var(--accent-dark); background: var(--accent-light); border-color: rgba(24,144,255,.45); }
.steps b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--panel-soft); border: 1px solid var(--line); }
.steps .active b { color: white; background: var(--accent); border-color: var(--accent); }
.layout { display: grid; grid-template-columns: 360px 1fr; height: calc(100vh - 151px); gap: 12px; padding: 0 14px 10px; }
.controls { padding: 16px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.page { display: none; }
.page.active { display: block; }
.page h2 { font-size: 18px; margin: 0 0 12px; }
.page h3 { font-size: 14px; margin-bottom: 6px; }
.page p { color: var(--muted); font-size: 13px; line-height: 1.5; }
label { display: grid; gap: 5px; margin: 10px 0; font-size: 12px; color: var(--muted); }
input, select, button { font: inherit; }
input, select { width: 100%; padding: 8px 10px; color: var(--ink); background: var(--panel); border: 1px solid #d9d9d9; border-radius: 6px; }
input:focus, select:focus { outline: 2px solid rgba(24,144,255,.2); border-color: var(--accent); }
button { padding: 8px 12px; color: white; background: var(--accent); border: 1px solid var(--accent); border-radius: 6px; cursor: pointer; }
button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.secondary { color: var(--ink); background: var(--panel); border-color: #d9d9d9; }
button.secondary:hover { color: var(--accent-dark); border-color: var(--accent); background: var(--accent-light); }
button.danger { background: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .45; cursor: not-allowed; }
.row, .nav-row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.stack { display: grid; gap: 8px; }
.nav-row { margin-top: 20px; }
.nav-row button { flex: 1; }
.pose-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.status { margin: 12px 0; padding: 10px; color: var(--muted); background: var(--panel-soft); border: 1px solid var(--line); border-radius: 6px; font-size: 12px; line-height: 1.5; }
.status.good { color: #389e0d; background: var(--green-light); border-color: rgba(82,196,26,.35); }
.status.warn { color: #ad6800; background: #fffbe6; border-color: rgba(250,173,20,.45); }
.status.warn ul { margin: 6px 0 8px; padding-left: 18px; }
.status.warn code { color: var(--ink); font-size: 11px; }
.status.warn .row { margin-top: 10px; }
input.warn { border-color: #faad14; outline: 2px solid rgba(250,173,20,.2); }
button.danger-ghost { color: #cf1322; background: var(--panel); border-color: rgba(255,77,79,.5); }
button.danger-ghost:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
button.link { padding: 0; color: var(--accent-dark); background: none; border: 0; text-decoration: underline; }
button.link:hover { background: none; color: var(--accent); }
.archived-toggle { display: flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; }
.archived-toggle input { width: auto; margin: 0; }
.tag { display: inline-block; padding: 1px 7px; font-size: 11px; line-height: 18px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel-soft); color: var(--muted); white-space: nowrap; }
.tag.warn { color: #ad6800; background: #fffbe6; border-color: rgba(250,173,20,.45); }
.project-banner { margin: 0 14px 8px; }
.confirm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; background: #fff1f0; border: 1px solid rgba(255,77,79,.35); border-radius: 8px; font-size: 13px; }
.confirm-bar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.confirm-bar .row { flex: none; }
.confirm-bar.delete { flex-direction: column; align-items: stretch; border: 2px solid var(--danger); }
.confirm-bar.delete .head { display: flex; gap: 10px; align-items: flex-start; }
.confirm-bar.delete .icon { display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--danger); color: #fff; font-weight: 700; }
.confirm-bar.delete ul { margin: 6px 0 0; padding-left: 18px; color: rgba(0,0,0,.65); font-size: 12px; line-height: 1.6; }
.confirm-bar.delete .typed { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.confirm-bar.delete .typed label { flex: 1; min-width: 220px; margin: 0; color: rgba(0,0,0,.65); }
.confirm-bar.delete .typed code { color: #cf1322; font-weight: 600; }
.toast { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; background: var(--green-light); border: 1px solid rgba(82,196,26,.35); border-radius: 8px; color: #389e0d; font-size: 13px; }
.toast.neutral { color: var(--ink); background: var(--panel-soft); border-color: var(--line); }
.status.bad { color: #cf1322; background: #fff1f0; border-color: rgba(255,77,79,.35); }
.workspace { position: relative; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr auto; gap: 12px; min-width: 0; min-height: 0; padding: 0; }
.canvas-card { display: grid; grid-template-rows: 42px 1fr; min-width: 0; min-height: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.canvas-card header { display: flex; justify-content: space-between; align-items: center; padding: 0 12px; color: var(--ink); background: var(--panel-soft); border-bottom: 1px solid var(--line); font-size: 12px; }
.canvas-card canvas { width: 100%; height: 100%; min-height: 0; }
.compatibility-proof { grid-column: 1 / -1; display: grid; grid-template-rows: 42px 1fr; min-height: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.compatibility-proof > header { display: flex; justify-content: space-between; align-items: center; padding: 0 12px; color: var(--ink); background: var(--panel-soft); border-bottom: 1px solid var(--line); font-size: 12px; }
.compatibility-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; padding: 10px; overflow: auto; min-height: 0; }
.compatibility-card { display: grid; grid-template-rows: 30px minmax(180px, 1fr); min-height: 220px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; }
.compatibility-card header { display: flex; justify-content: space-between; align-items: center; padding: 0 9px; color: var(--ink); background: var(--panel-soft); font-size: 11px; }
.compatibility-card canvas { width: 100%; height: 100%; min-height: 180px; }
.compatibility-card.missing { padding: 12px; color: #cf1322; font-size: 12px; }
.legend { grid-column: 1 / -1; display: flex; gap: 18px; color: var(--muted); font-size: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 50%; }
.dot.input { background: #ef3340; border: 2px solid white; }
.dot.camera { background: #13c2c2; }
.check-list { display: grid; gap: 6px; margin: 10px 0; }
.check-list label, .check { display: flex; align-items: center; gap: 8px; }
.check-list input, .check input { width: auto; }
#log { max-height: 140px; overflow: auto; white-space: pre-wrap; color: var(--muted); font-size: 11px; }
hr { margin: 16px 0; border: 0; border-top: 1px solid var(--line); }
.workspace.cross-camera-mode #frameInputView, .workspace.cross-camera-mode #frameCalculatedView, .workspace.cross-camera-mode #mapInputView, .workspace.cross-camera-mode .legend { display: none !important; }
#compatibilityProof[hidden] { display: none !important; }
@media (max-width: 1000px) {
  .steps span { display: none; }
  .layout { grid-template-columns: 310px 1fr; }
  .workspace { grid-template-columns: 1fr; }
  .canvas-card { min-height: 280px; }
  .legend { grid-column: 1; }
  .top-actions { flex-wrap: wrap; }
}

.loading { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(255, 255, 255, .6); color: var(--accent); font-size: 14px; }
.loading[hidden] { display: none; }
.spin { position: relative; width: 32px; height: 32px; transform: rotate(45deg); animation: spin-rotate 1.2s linear infinite; }
.spin i { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); opacity: .3; animation: spin-move 1s linear infinite alternate; }
.spin i:nth-child(1) { top: 0; left: 0; }
.spin i:nth-child(2) { top: 0; right: 0; animation-delay: .4s; }
.spin i:nth-child(3) { bottom: 0; right: 0; animation-delay: .8s; }
.spin i:nth-child(4) { bottom: 0; left: 0; animation-delay: 1.2s; }
@keyframes spin-rotate { to { transform: rotate(405deg); } }
@keyframes spin-move { to { opacity: 1; } }
.restricted { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 24px; }
.restricted h1 { margin: 0; }
.restricted p { margin: 0; color: var(--muted, #667085); max-width: 420px; }
