/* CollisionDetect — video-review dark UI. Severity ramp is the palette's core:
   the domain (impact severity) drives the color system. */
:root {
  --bg: #101418;
  --panel: #1a2028;
  --panel-2: #222a34;
  --line: #2e3844;
  --text: #e8edf2;
  --muted: #8d99a6;
  --accent: #4fc3f7;        /* analysis / machine blue */
  --sev1: #57b97a; --sev2: #a4c65b; --sev3: #e0b23f; --sev4: #e07b39; --sev5: #d94f46;
  font-size: 15px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Archivo", system-ui, sans-serif;
  font-variation-settings: "wdth" 92;
}
.mono, #cur-time, .tl-time { font-family: "JetBrains Mono", monospace; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--sev5); }
.spacer { flex: 1; }

/* topbar */
#topbar { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.brand span { color: var(--accent); font-weight: 400; }
.brand.big { font-size: 1.9rem; }
.navbtn { background: none; border: none; color: var(--muted); font: inherit;
  padding: .45rem .8rem; border-radius: 6px; cursor: pointer; }
.navbtn.active, .navbtn:hover { color: var(--text); background: var(--panel-2); }

main { max-width: 1280px; margin: 0 auto; padding: 1.2rem; }
main.centered { display: flex; min-height: 100vh; align-items: center; justify-content: center; }

/* buttons + inputs */
button { font: inherit; cursor: pointer; border-radius: 6px; border: 1px solid var(--line); }
button.primary { background: var(--accent); border-color: var(--accent); color: #05222f;
  font-weight: 700; padding: .55rem 1.1rem; }
button.primary:hover { filter: brightness(1.1); }
button.ghost { background: transparent; color: var(--muted); padding: .45rem .8rem; }
button.ghost:hover { color: var(--text); border-color: var(--muted); }
button.small { padding: .2rem .5rem; font-size: .8rem; }
.wide { width: 100%; }
input, select, textarea { width: 100%; background: var(--bg); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: .5rem .6rem; font: inherit; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; margin-bottom: .7rem; font-size: .85rem; color: var(--muted); }
label input, label select, label textarea, label .time-set, label .sev-picker { margin-top: .25rem; }
.req { color: var(--sev5); margin-left: 2px; }
.hint { display: block; font-size: .75rem; margin-top: .2rem; }

/* login */
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 2rem; width: 340px; text-align: center; }
.login-card form { text-align: left; margin-top: 1.2rem; }

/* library */
.add-video { display: flex; gap: .6rem; margin-bottom: 1.2rem; }
.add-video input { flex: 1; }
.add-video select { width: auto; }
.video-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .9rem; }
.video-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem; cursor: pointer; transition: border-color .15s; }
.video-card:hover { border-color: var(--accent); }
.video-card h3 { margin: 0 0 .4rem; font-size: 1rem; }
.video-card .meta { display: flex; gap: .5rem; flex-wrap: wrap; font-size: .78rem; }
.pill { background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px;
  padding: .1rem .55rem; font-size: .75rem; color: var(--muted); }
.pill.ok { color: var(--sev1); border-color: var(--sev1); }
.pill.warn { color: var(--sev3); border-color: var(--sev3); }
.pill.err { color: var(--sev5); border-color: var(--sev5); }
.pill.blue { color: var(--accent); border-color: var(--accent); }
.del-video { float: right; }

/* jobs */
.jobs-head { display: flex; align-items: center; gap: 1rem; }
.jobs-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.jobs-table th, .jobs-table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
.jobs-table th { color: var(--muted); font-weight: 600; }

/* video detail */
.video-layout { display: grid; grid-template-columns: 1fr 380px; gap: 1.2rem; margin-top: .8rem; }
video { width: 100%; background: #000; border-radius: 8px; }
.player-controls { display: flex; align-items: center; gap: .4rem; margin-top: .5rem; }

/* timeline — signature element: labels above the track, machine events below */
#timeline { position: relative; margin-top: .6rem; user-select: none; }
#tl-track { height: 10px; background: var(--panel-2); border-radius: 5px; cursor: pointer; position: relative; overflow: hidden; }
#tl-progress { height: 100%; width: 0; background: color-mix(in srgb, var(--accent) 35%, transparent); }
#tl-labels, #tl-events { position: relative; height: 14px; }
.tl-mark { position: absolute; width: 4px; border-radius: 2px; cursor: pointer; }
#tl-labels .tl-mark { height: 12px; bottom: 1px; }
#tl-events .tl-mark { height: 12px; top: 1px; opacity: .85; }
.sev-1 { background: var(--sev1); } .sev-2 { background: var(--sev2); }
.sev-3 { background: var(--sev3); } .sev-4 { background: var(--sev4); }
.sev-5 { background: var(--sev5); }
.cls-light { background: var(--sev1); } .cls-moderate { background: var(--sev3); } .cls-heavy { background: var(--sev5); }

/* severity picker */
.sev-picker { display: flex; gap: .35rem; }
.sev-picker button { flex: 1; padding: .45rem 0; background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line); font-weight: 700; }
.sev-picker button.sel-1 { background: var(--sev1); } .sev-picker button.sel-2 { background: var(--sev2); }
.sev-picker button.sel-3 { background: var(--sev3); } .sev-picker button.sel-4 { background: var(--sev4); }
.sev-picker button.sel-5 { background: var(--sev5); }
.sev-picker button[class*="sel-"] { color: #10161c; border-color: transparent; }

.label-col, .analysis-panel { background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 1rem; }
.analysis-panel { margin-top: 1rem; }
.label-col h3, .analysis-panel h3 { margin: .2rem 0 .8rem; font-size: .95rem; display: flex; align-items: center; gap: .5rem; }
.time-row, .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.time-set { display: flex; gap: .3rem; }
.checks { display: flex; flex-wrap: wrap; gap: .8rem; margin-bottom: .7rem; }
.check { display: flex; align-items: center; gap: .35rem; margin: 0; }
.check input { width: auto; }
.check.risk { color: var(--sev4); }
.form-actions { display: flex; gap: .6rem; }
.export { margin-left: .3rem; font-size: .75rem; color: var(--accent); text-decoration: none; }
.export:hover { text-decoration: underline; }

.scroll-list { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; }
.item { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: .55rem .7rem; font-size: .83rem; }
.item .head { display: flex; align-items: center; gap: .5rem; }
.sev-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.item .tl-time { color: var(--accent); cursor: pointer; }
.item .tl-time:hover { text-decoration: underline; }
.item .detail { color: var(--muted); margin-top: .2rem; }
.item .actions { margin-left: auto; display: flex; gap: .3rem; }

@media (max-width: 980px) {
  .video-layout { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
