:root {
  --bg: #11111b;
  --panel: #1a1a26;
  --panel2: #22222f;
  --line: #2e2e40;
  --txt: #e8e8f0;
  --dim: #9a9ab0;
  --acc: #8000ff;
  --acc2: #b366ff;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  min-height: 100vh;
}
.hidden { display: none !important; }
.error { color: var(--bad); }

/* header */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: #15151f; position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; font-size: 18px; }
.brand .sub { color: var(--dim); font-weight: 400; font-size: 13px; margin-left: 8px; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.counts { color: var(--dim); font-size: 13px; }

/* buttons */
.btn {
  background: var(--panel2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 14px;
}
.btn:hover { border-color: var(--acc); }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; font-weight: 700; }
.btn.danger { border-color: var(--bad); color: #ffb4b4; }
.btn.small { padding: 5px 10px; font-size: 13px; }
a.btn { text-decoration: none; display: inline-block; }

/* filter chips */
.filters { display: flex; gap: 8px; padding: 10px 16px; flex-wrap: wrap; }
.chip {
  background: transparent; color: var(--dim);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; font-size: 13px;
}
.chip.active { background: var(--acc); border-color: var(--acc); color: #fff; }

/* layout */
main { display: flex; gap: 0; align-items: flex-start; }
aside#clipList {
  width: 340px; min-width: 300px; max-height: calc(100vh - 110px);
  overflow-y: auto; border-right: 1px solid var(--line);
}
section#detail { flex: 1; padding: 16px; min-width: 0; }
section#detail.empty {
  display: flex; align-items: center; justify-content: center;
  min-height: 50vh; color: var(--dim); text-align: center;
}
.empty-msg span { font-size: 13px; }

/* clip cards */
.clip {
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.clip:hover { background: var(--panel); }
.clip.selected { background: var(--panel2); border-left: 3px solid var(--acc); }
.clip .t { font-weight: 700; }
.clip .m { color: var(--dim); font-size: 12.5px; margin-top: 2px; }
.clip .badges { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--dim);
}
.badge.fire { color: #ffb020; border-color: #5a3a10; }
.badge.ok { color: var(--good); border-color: #14532d; }
.badge.veto { color: #ffb4b4; border-color: var(--bad); }
.badge.rend { color: var(--acc2); border-color: var(--acc); }

/* detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.detail-head h2 { margin: 0 0 4px; }
.d-meta { color: var(--dim); font-size: 13px; }
.d-actions { display: flex; gap: 8px; }
.players { display: flex; gap: 16px; margin: 16px 0; flex-wrap: wrap; }
.player-block { flex: 1; min-width: 260px; }
.player-block h3 { margin: 0 0 8px; font-size: 14px; }
.player-block video { width: 100%; max-height: 420px; background: #000; border-radius: 8px; }
.inout { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.d-norender { color: var(--dim); font-size: 13px; padding: 20px; border: 1px dashed var(--line); border-radius: 8px; }
.d-renderstate { color: var(--acc2); font-size: 12px; font-weight: 400; }

/* trajectory */
.traj-block { margin: 8px 0 16px; }
.traj-block h3, .panel h3 { margin: 0 0 8px; font-size: 14px; }
.hint { color: var(--dim); font-size: 12px; font-weight: 400; }
canvas.d-traj { width: 100%; max-width: 640px; background: var(--panel); border-radius: 8px; border: 1px solid var(--line); }
.cropcam-row { display: flex; gap: 12px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
canvas.d-cropcam { background: #000; border-radius: 8px; border: 1px solid var(--line); }
.cropcam-note { color: var(--dim); font-size: 13px; max-width: 420px; }

/* panels */
.grid2 { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.panel {
  flex: 1; min-width: 280px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 14px;
}
.winrow { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.winrow label { font-size: 13px; color: var(--dim); }
.winrow input, .labelline input {
  background: var(--bg); border: 1px solid var(--line); color: var(--txt);
  border-radius: 6px; padding: 6px 8px; font-size: 14px; width: 90px;
}
.labelline input { width: 220px; }
.labelline { font-size: 13px; color: var(--dim); display: block; margin-top: 10px; }
.d-dur { color: var(--dim); font-size: 13px; }
.moderow { display: flex; gap: 14px; margin-bottom: 10px; flex-wrap: wrap; font-size: 14px; }
canvas.d-manualcanvas { width: 100%; max-width: 480px; background: #000; border-radius: 8px; border: 1px solid var(--line); cursor: crosshair; }
.d-boxlabel { font-size: 12px; color: var(--dim); margin-top: 4px; font-family: monospace; }
.d-analysis { font-size: 13px; color: var(--dim); margin-top: 8px; line-height: 1.5; }
.d-analysis b { color: var(--txt); }

/* action bar */
.actionbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 30px; }
.d-status { font-size: 13px; color: var(--dim); }

/* token overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.token-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; width: 320px; text-align: center;
}
.token-card input {
  width: 100%; padding: 10px; margin: 12px 0; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--txt);
}
.token-card button {
  background: var(--acc); color: #fff; border: none; border-radius: 8px;
  padding: 10px 24px; cursor: pointer; font-weight: 700;
}

@media (max-width: 900px) {
  main { flex-direction: column; }
  aside#clipList { width: 100%; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--line); }
}
