.agent-messages .agent-reply { justify-self:start; }
.agent-messages .agent-reply small { text-align:left; }
.agent-reply p { background:#f8fbff; border-radius:4px 12px 12px; }
.agent-result {
  display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:10px;
  width:100%; margin-top:8px; padding:11px 13px; text-align:left; border:1px solid #bfd7f9;
  border-radius:10px; background:#edf5ff; color:#174781;
}
.agent-result:hover { background:#e2efff; border-color:#6d9de2; }
.agent-result strong { display:block; font-variant-numeric:tabular-nums; }
.agent-result span:last-child { display:flex; align-items:center; gap:5px; font-size:12px; }
.agent-result .ui-icon { width:16px; height:16px; }
.agent-result small { margin:3px 0 0; }

.agent-progress:not([hidden]) {
  display:flex; flex-wrap:wrap; align-items:center; gap:8px 16px;
  margin:0 0 14px; padding:9px 13px; border:1px solid #bcd5f7; border-radius:10px;
  background:#f4f9ff; color:#234167; font-size:12px;
}
.agent-progress-heading { display:flex; flex-wrap:wrap; align-items:center; gap:6px 9px; }
.agent-progress-heading strong { color:#183e74; font-size:14px; }
.agent-progress-heading small { color:#486589; font-size:11px; }
.agent-progress-query { padding:2px 6px; border-radius:5px; background:#e2efff; color:#204b8e; font-variant-numeric:tabular-nums; }
.agent-progress ol { display:flex; flex-wrap:wrap; align-items:center; gap:4px; margin:0; padding:0; list-style:none; }
.agent-progress li { padding:3px 6px; color:#506782; }
.agent-progress li+li::before { content:'→'; display:inline-block; margin-right:7px; color:#6e86a3; }
.agent-progress li[data-state=done] { color:#245da0; }
.agent-progress li[aria-current] { border-radius:5px; background:#1f54a7; color:white; font-weight:700; }
.agent-progress li[aria-current]::before { color:#c8deff; }
.agent-progress-status { color:#1d4c87; }
.agent-progress .small-btn:not([hidden]) { display:inline-flex; margin-inline-start:auto; white-space:nowrap; }
#workspace-view[data-page=playback]:has(.agent-progress:not([hidden])) .case-head { display:none; }

#library-app:has(>#agent-vehicle-library:not([hidden])) > :not(#agent-vehicle-library),
#page-library:has(#agent-vehicle-library:not([hidden])) > #local-upload { display:none; }
.vehicle-library-heading h2 { margin:0; color:#183e74; }
.vehicle-library-heading { display:flex; justify-content:space-between; align-items:center; gap:8px; margin:0 0 12px; }
.vehicle-library-heading p { margin:5px 0 0; color:#4d6889; font-size:13px; }
.vehicle-library-count { flex:none; color:#315888; font-size:13px; font-variant-numeric:tabular-nums; }
.vehicle-library-stage {
  position:relative; display:grid; align-items:center; overflow:hidden; isolation:isolate; height:clamp(370px,61vh,620px);
  border:1px solid #284a74; border-radius:16px; background:radial-gradient(ellipse at 50% 47%,#244773,#101f37 78%);
}
.vehicle-library-stage > p {
  position:absolute; z-index:50; inset:auto 0 0; margin:0; padding:13px 12px 14px; text-align:center;
  color:#e0edff; font-size:14px; font-weight:600; background:#10213ded; border-top:1px solid #6493c33b;
}
.vehicle-atlas {
  --atlas-columns:14;
  position:absolute; inset:10px 12px 58px; display:grid; grid-auto-rows:minmax(0,1fr);
  gap:5px; opacity:0; transform:scale(1.12); filter:blur(2px);
  transition:opacity 580ms ease,transform 620ms ease,filter 550ms ease; pointer-events:none;
}
.vehicle-atlas > div { display:flex; gap:inherit; min-width:0; }
.vehicle-atlas img {
  display:block; flex:1 1 0; min-width:0; height:100%; object-fit:cover;
  border:1px solid #537da854; background:#132842; border-radius:3px;
}
#agent-vehicle-library[data-phase=overview] .vehicle-atlas { opacity:1; transform:none; filter:none; }
.vehicle-scan {
  position:relative; display:grid; grid-template-columns:repeat(9,minmax(0,1fr)); gap:9px;
  padding:12px 21px 57px; opacity:0; transform:scale(.92);
  transition:opacity 550ms ease,filter 550ms ease,transform 600ms ease;
}
.vehicle-scan-small { display:flex; justify-content:center; flex-wrap:wrap; }
.vehicle-scan-small .vehicle-scan-card { width:clamp(86px,15%,180px); }
#agent-vehicle-library[data-phase=focus] .vehicle-scan { opacity:1; transform:none; }
#agent-vehicle-library[data-phase=focus] .vehicle-scan::after {
  content:''; position:absolute; inset:5% 0 12%; pointer-events:none;
  background:linear-gradient(90deg,transparent 36%,#48a7ff00 45%,#76baff26 49.8%,#a0d5ff85 50%,#66b2ff1a 50.2%,transparent 62%);
  animation:vehicle-sweep 1900ms cubic-bezier(.26,.55,.42,1) both;
}
.vehicle-library-stage .lib-video-card { border:1px solid #6787ac; border-radius:11px; overflow:hidden; background:#132b48; color:#f0f6ff; }
.vehicle-library-stage .lib-thumbnail { display:block; width:100%; aspect-ratio:16/9; background:#0c192e; }
.vehicle-library-stage .lib-thumbnail img { display:block; width:100%; height:100%; object-fit:cover; }
.vehicle-library-stage .lib-card-copy { display:grid; gap:3px; padding:10px 12px; }
.vehicle-library-stage .lib-card-copy span { min-height:16px; color:#bed7f8; font-size:11px; }
.vehicle-library-stage .lib-card-copy strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; }
.vehicle-scan .vehicle-scan-card { border-radius:6px; transition:opacity 280ms ease,border-color 200ms ease,transform 135ms ease; }
.vehicle-scan .lib-thumbnail { max-height:clamp(58px,11vh,110px); }
.vehicle-scan .lib-card-copy { display:block; padding:5px 7px; }
.vehicle-scan .lib-card-copy strong { display:block; font-size:11px; }
.vehicle-scan .lib-card-copy span { display:none; }
.vehicle-scan .vehicle-scan-card.is-pulled { opacity:.22; }
#agent-vehicle-library[data-phase=extract] .vehicle-scan { opacity:.55; transform:scale(.98); }
.vehicle-scan .vehicle-scan-card.is-source {
  position:relative; z-index:1; transform:scale(1.08); border-color:#d4eaff;
  box-shadow:0 0 0 2px #81bbf2a6,0 4px 14px #74abf271;
}
.vehicle-extract {
  position:absolute; inset:0 13% 50px; display:grid; grid-template-columns:repeat(4,minmax(0,1fr));
  align-content:center; gap:10px; pointer-events:none;
}
.vehicle-extract .vehicle-candidate { border-color:#8ab6e0; box-shadow:0 10px 24px #050f249c; }
.vehicle-review {
  position:absolute; inset:22px 23px 64px; display:grid;
  grid-template-columns:minmax(0,1fr) minmax(232px,30%); gap:13px; align-items:center; pointer-events:none;
  visibility:hidden; opacity:0; transition:opacity 450ms ease,visibility 0s linear 450ms;
}
#agent-vehicle-library:is([data-phase=candidates],[data-phase=review]) .vehicle-review {
  visibility:visible; opacity:1; transition-delay:0s;
}
#agent-vehicle-library:is([data-phase=candidates],[data-phase=review],[data-phase=selected]) .vehicle-scan {
  opacity:.16; filter:blur(1.5px); transform:scale(.97);
}
.vehicle-review-list,.vehicle-monitor {
  min-width:0; align-self:stretch; align-content:center; padding:12px;
  border:1px solid #466588; border-radius:9px; background:#10223aeF;
}
.vehicle-review header {
  display:flex; justify-content:space-between; align-items:center; gap:8px;
  padding:1px 1px 9px; color:#d7e5f7; font-variant-numeric:tabular-nums;
}
.vehicle-review h3 { margin:0; color:#e7f1ff; font-size:14px; }
.vehicle-review-count { color:#a8c5e6; font-size:12px; }
.vehicle-candidates { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; }
.vehicle-candidate-slot { position:relative; min-width:0; aspect-ratio:1.22; }
.vehicle-candidates .vehicle-candidate-slot:empty::before {
  content:''; position:absolute; inset:0; border:1px solid #3b5576; border-radius:6px; background:#172d4885;
}
.vehicle-candidates .vehicle-candidate {
  position:relative; border-radius:6px; border-color:#4b6585; background:#152c48;
  transition:border-color 120ms linear,box-shadow 120ms linear;
}
:is(.vehicle-candidates,.vehicle-extract) .lib-card-copy { padding:6px 8px; }
:is(.vehicle-candidates,.vehicle-extract) .lib-card-copy strong { font-size:12px; }
:is(.vehicle-candidates,.vehicle-extract) .lib-card-copy span { min-height:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:10px; }
.vehicle-candidates .vehicle-candidate.is-current {
  border-color:#a3d5ff; box-shadow:0 0 0 1px #7dbbfa78;
}
.vehicle-candidates .is-current .lib-thumbnail { position:relative; overflow:hidden; }
.vehicle-candidates .is-current .lib-thumbnail::after {
  content:''; position:absolute; z-index:1; inset-inline:0; top:0; height:2px; background:#c7e7ff;
  box-shadow:0 -4px 12px 3px #779dca7a; animation:vehicle-check 450ms ease-out both;
}
.vehicle-monitor-image {
  overflow:hidden; aspect-ratio:16/9; border:1px solid #496585; border-radius:6px; background:#0c1a2e;
}
.vehicle-monitor-image img:not([hidden]) { display:block; width:100%; height:100%; object-fit:cover; }
.vehicle-monitor strong,.vehicle-monitor > span { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.vehicle-monitor strong { margin-top:10px; color:#e3efff; font-size:13px; }
.vehicle-monitor > span { margin-top:3px; min-height:15px; color:#a8c5e6; font-size:11px; }
.vehicle-lock { position:absolute; inset:0 0 48px; display:grid; place-items:center; pointer-events:none; }
.vehicle-lock .vehicle-candidate {
  width:min(48%,500px); border-color:#acd7ff; box-shadow:0 0 0 1px #8fc5fb65,0 16px 42px #061024;
}
.vehicle-lock .lib-thumbnail { position:relative; }
.vehicle-lock .lib-thumbnail::after {
  content:''; position:absolute; inset:12px; --corner:linear-gradient(#d7ebff,#d7ebff);
  background:var(--corner) top left/17px 2px,var(--corner) top left/2px 17px,
    var(--corner) top right/17px 2px,var(--corner) top right/2px 17px,
    var(--corner) bottom left/17px 2px,var(--corner) bottom left/2px 17px,
    var(--corner) bottom right/17px 2px,var(--corner) bottom right/2px 17px;
  background-repeat:no-repeat; animation:agent-frame-reveal 300ms 470ms both;
}
.vehicle-lock .lib-card-copy { padding:10px 14px; }
.vehicle-lock .lib-card-copy strong { font-size:18px; }
.vehicle-lock .lib-card-copy span { color:#bbdfff; }
@keyframes vehicle-check { from { top:0; } to { top:100%; } }
@keyframes vehicle-sweep {
  from { transform:translateX(-60%); }
  to { transform:translateX(60%); }
}

.agent-evidence {
  box-sizing:border-box; width:min(1060px,calc(100vw - 30px)); max-height:calc(100dvh - 28px);
  padding:0; border:1px solid #406590; border-radius:16px; color:#eef5ff; background:#11223b;
  box-shadow:0 24px 80px #050f26b3;
}
.agent-evidence::backdrop { background:#071528ae; }
.agent-evidence > header,.agent-evidence > footer { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:9px 14px; padding:13px 17px; }
.agent-evidence header h2 { margin:3px 0 0; color:#f0f6ff; font-size:21px; }
.agent-evidence header small { color:#badbff; font-size:12px; }
.agent-evidence-body { display:grid; grid-template-columns:minmax(0,1fr) minmax(135px,22%); gap:13px; align-items:center; padding:0 17px; }
.agent-evidence-body figure { margin:0; }
.agent-original-frame { position:relative; overflow:hidden; border:1px solid #436489; border-radius:8px; }
.agent-evidence-body img { display:block; width:100%; height:auto; }
.agent-plate-box { box-sizing:border-box; position:absolute; border:2px solid #9bd6ff; border-radius:2px; box-shadow:0 0 0 1px #132742; animation:agent-frame-reveal 320ms 650ms both; }
.agent-plate-detail { padding:9px; border:1px solid #436489; border-radius:8px; background:#1b3453; animation:agent-frame-reveal 360ms 1050ms both; }
.agent-plate-detail figcaption { margin-bottom:7px; color:#d0e3fb; font-size:12px; }
.agent-evidence-note { margin:8px 0 0; color:#d0e3fb; font-size:12px; line-height:1.5; }
.agent-evidence-instant :is(.agent-plate-detail,.agent-plate-box) { animation:none; }
.agent-evidence footer > div { display:flex; align-items:center; flex-wrap:wrap; gap:9px; }
.agent-evidence footer time { color:#d0e3ff; font-variant-numeric:tabular-nums; }
.agent-evidence-error { color:#ffcfb8; }
@keyframes agent-frame-reveal { from { opacity:0; } to { opacity:1; } }

@media(max-width:700px) {
  .agent-evidence-body { grid-template-columns:1fr; }
  .agent-plate-detail { width:min(160px,50%); }
  .vehicle-atlas { --atlas-columns:9; gap:3px; }
  .vehicle-scan { grid-template-columns:repeat(auto-fill,minmax(65px,1fr)); gap:5px; padding-inline:8px; }
  .vehicle-extract { inset-inline:9px; gap:5px; }
  .vehicle-review { inset:10px 9px 50px; grid-template-columns:minmax(0,1fr); gap:8px; align-content:center; }
  .vehicle-review-list,.vehicle-monitor { padding:7px; }
  .vehicle-candidates { gap:5px; }
  .vehicle-candidates .lib-card-copy { padding:3px; }
  .vehicle-candidates .lib-card-copy strong { font-size:10px; }
  .vehicle-monitor { display:grid; grid-template-columns:minmax(68px,26%) minmax(0,1fr); gap:0 8px; }
  .vehicle-monitor header { grid-column:1/-1; }
  .vehicle-monitor-image { grid-row:2/4; }
  .vehicle-lock .vehicle-candidate { width:76%; }
}
@media(prefers-reduced-motion:reduce) {
  .vehicle-atlas,.vehicle-scan,.vehicle-scan::after,.vehicle-candidate .lib-thumbnail::after,.agent-plate-detail,.agent-plate-box { animation:none; transition:none; }
}
