:root {
  color-scheme: light;
  --page: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e8e7e1;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.09);
  --accent: #1c5cab;
  --c-noise: #d6d5cf;
  --c-impact: #2a78d6;
  --c-vehicle: #eb6834;
  --c-idle: #1baf7a;
  --c-activity: #6f6e69;
  --info: #1c5cab;
  --warning: #fab219;
  --critical: #d03b3b;
  --ok: #0ca30c;
  --radius: 12px;
  --gap: 14px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: clamp(12px, 0.83vw, 20px); }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font: 1rem/1.45 var(--font);
       display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); overflow: hidden; }
.num { font-variant-numeric: tabular-nums; }
.instant, .instant * { transition: none !important; }

/* ---------------- header (same sizes as the main page's topbar) ---------------- */
.top { display: flex; align-items: center; gap: 32px; height: 64px; padding: 0 24px; font-size: 14px;
       background: var(--surface); border-bottom: 1px solid var(--border); view-transition-name: top; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.logo { width: 22px; height: 22px; border-radius: 6px; flex: none; transition: transform .2s;
        background: linear-gradient(135deg, #1c5cab 0 50%, #2a78d6 50% 100%); }   /* the main app's mark */
.brand:hover .logo { transform: scale(1.12); }
.brand div { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-size: 16px; letter-spacing: .01em; }
.brand div span { font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 7px 14px; border-radius: 8px; color: var(--ink-2); text-decoration: none; cursor: pointer; }
.tabs a:hover { background: var(--surface-2); }
.tabs a.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.pill { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-weight: 600; font-size: 13px; }
.clock { font-size: 13px; color: var(--ink-2); min-width: 150px; text-align: right; }
.replay { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 13px; }
.replay:hover { border-color: var(--accent); }

/* ---------------- dashboard ---------------- */
.dash { display: grid; grid-template-columns: 0.95fr 1.4fr 1fr; gap: var(--gap); padding: 1rem 1.4rem 1.2rem; min-height: 0; }
.col { display: flex; flex-direction: column; gap: var(--gap); min-height: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1.1rem 1rem;
        opacity: 0; transform: translateY(10px); transition: opacity .6s, transform .6s, box-shadow .4s, border-color .4s; min-height: 0; }
.card.on { opacity: 1; transform: none; }
.card.active { border-color: rgba(28, 92, 171, 0.45); box-shadow: 0 0 0 3px rgba(28, 92, 171, 0.10); }
.card.grow { flex: 1; display: flex; flex-direction: column; }
.card.grow > .slot { flex: 1; display: flex; flex-direction: column; min-height: 0; }
/* cards never shrink below their content; on a short screen the deployment photo gives up the height instead */
.col > .card:not(.grow):not(#card-site) { flex-shrink: 0; }
#card-site, #card-site > .slot, #card-site .blk-site { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
#card-site .photo { flex: 0 1 auto; min-height: 5rem; aspect-ratio: 1669 / 640; }
#card-site .photo svg { width: 100%; height: 100%; }
#card-site .ctx, #card-site .dts { flex: none; }
#card-das .blk-wf { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#card-das .blk-wf .wf { flex: 1; }
#card-das .blk-wf .xlab { display: none; }          /* the intensity bars below carry the sensor numbers */
#card-das .bars { margin-top: 1.1rem; }
#card-detect { view-transition-name: vt-detect; }
#card-das { view-transition-name: vt-das; }
#card-site { view-transition-name: vt-site; }
#card-dts { view-transition-name: vt-dts; }
#card-fetch { view-transition-name: vt-fetch; }
#card-assess { view-transition-name: vt-assess; }
#card-reason { view-transition-name: vt-reason; }
#card-decide { view-transition-name: vt-decide; }
.card-h { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.6rem; }
/* same block styles as the chat view: neutral icon for data sources, blue tint for the agent's own steps */
.card.agent { background: #f6f8fc; border-color: rgba(28, 92, 171, 0.2); }
.card.agent.active { border-color: rgba(28, 92, 171, 0.45); }
.card.agent.decision { border-left: 6px solid var(--sev, var(--info)); }
.card-h h3 { margin: 0; font-size: 1.05rem; font-weight: 650; }
.card-h .aside { margin-left: auto; color: var(--muted); font-size: 0.85rem; text-align: right; }
.card-h .aside.live { color: var(--ink-2); }
.tag { display: inline-block; font-size: 0.72rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--ink-2);
       background: var(--surface-2); border-radius: 5px; padding: 0.05rem 0.4rem; margin-left: 0.4rem; vertical-align: 0.1em; }
.legend { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.85rem; }
.legend .ramp { width: 5rem; height: 0.55rem; border-radius: 3px; border: 1px solid var(--border);
                background: linear-gradient(90deg, #f4f3ef, #fbe0d2, #f5a987, #eb6834, #b8471b, #6e2a0f); }

.ic { width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.ic svg { width: 0.95rem; height: 0.95rem; fill: none; stroke: var(--ink-2); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.card.agent .ic { background: var(--accent); }
.card.agent .ic svg { stroke: #fff; }

/* live / event status */
.live { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.live:empty { display: none; }
.live::before { content: ""; width: 0.62rem; height: 0.62rem; border-radius: 50%; background: var(--ok); animation: pulse 1.4s ease-in-out infinite; }
.live.event { background: var(--c-vehicle); color: #fff; font-size: 0.95rem; font-weight: 700; padding: 0.22rem 0.75rem 0.22rem 0.6rem;
              border-radius: 999px; box-shadow: 0 4px 14px rgba(235, 104, 52, 0.35); animation: pop .45s cubic-bezier(.3, 1.6, .5, 1); }
.live.event::before { background: #fff; animation: none; }
.card-h .aside.live.event { color: #fff; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { 50% { opacity: 0.25; } }

/* streamed text caret */
.typing::after { content: ""; display: inline-block; width: 0.5em; height: 1em; margin-left: 2px; vertical-align: -0.12em;
                 background: var(--accent); animation: blink .8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------------- detection ---------------- */
.headline { font-size: 1.45rem; font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; min-height: 1.8rem; }
.agree { color: var(--ink-2); font-size: 0.95rem; min-height: 1.4rem; margin: 0.1rem 0 0.5rem; }
.verdicts { display: grid; grid-template-columns: auto 1fr auto; column-gap: 0.9rem; }
.vrow { display: contents; }
.vrow > * { padding: 0.32rem 0; border-top: 1px solid var(--grid); opacity: 0; transition: opacity .35s, background-color 1.4s; }
.vrow.on > * { opacity: 1; }
.vrow .algo { color: var(--ink-2); white-space: nowrap; }
.vrow .algo small { color: var(--muted); font-size: 0.75rem; margin-left: 0.3rem; }
.vrow .v { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vrow .conf { color: var(--ink-2); text-align: right; }
.vrow.flash > * { background: rgba(250, 178, 25, 0.22); transition: none; }
.dot { display: inline-block; width: 0.62rem; height: 0.62rem; border-radius: 50%; margin-right: 0.45rem; vertical-align: 0.03em; }
.dot.vehicle { background: var(--c-vehicle); }
.dot.impact { background: var(--c-impact); }
.dot.idle { background: var(--c-idle); }
.dot.noise { background: var(--c-noise); }
.dot.activity { background: transparent; border: 2px solid var(--c-activity); }

/* ---------------- waterfall + intensity ---------------- */
.wf { display: grid; grid-template-columns: 3.6rem 1fr; grid-template-rows: 1fr auto auto; min-height: 0; }
.wf-y { grid-area: 1 / 1; }
.wf-plot { grid-area: 1 / 2; }
.wf .xlab { grid-area: 2 / 2; }
.wf .legend { grid-area: 3 / 2; justify-content: flex-end; font-size: 0.9rem; padding-top: 0.35rem; }
.wf-y { position: relative; font-size: 0.95rem; color: var(--muted); }
.wf-y span { position: absolute; right: 0.5rem; white-space: nowrap; transition: top .6s; }
.wf-y span.trig { color: var(--ink); font-weight: 600; }
.wf-plot { position: relative; min-height: 0; }
.wf-plot canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.xlab { display: grid; gap: 2px; font-size: 0.95rem; color: var(--muted); text-align: center; padding-top: 0.2rem; }
.xlab span.hi { color: var(--ink); font-weight: 650; }
.ints { display: grid; grid-template-columns: 3.6rem 1fr; }
.bars { display: grid; gap: 2px; height: 4.6rem; align-items: end; margin-top: 0.45rem; border-bottom: 1px solid var(--axis); }
.bar { position: relative; height: 0; background: var(--c-vehicle); border-radius: 4px 4px 0 0; transition: height 1.1s cubic-bezier(.2,.7,.2,1); }
.bar i { position: absolute; bottom: 100%; left: 0; right: 0; text-align: center; font-style: normal; font-size: 0.75rem; color: var(--ink-2);
         padding-bottom: 1px; opacity: 0; transition: opacity .4s .7s; }
.bars.on .bar i { opacity: 1; }
.bars-lab { font-size: 0.8rem; color: var(--muted); align-self: end; text-align: right; padding-right: 0.5rem; line-height: 1.2; }
.xlab-lab { font-size: 0.8rem; color: var(--muted); text-align: right; padding: 0.25rem 0.5rem 0 0; }
.caption { margin-top: 0.6rem; font-size: 0.98rem; min-height: 2.9rem; }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: #fff; font-size: 0.8rem; padding: 0.25rem 0.5rem;
       border-radius: 6px; white-space: nowrap; z-index: 10; }

/* ---------------- site ---------------- */
.photo { position: relative; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.photo svg { display: block; width: 100%; height: auto; }
.photo .pl { font: 600 38px var(--font); fill: var(--ink); }
.photo .pl.on { font-weight: 750; }
.photo .img { opacity: 0; transition: opacity .9s; }
.photo.on .img { opacity: 1; }
.ctx { margin: 0.65rem 0 0; padding: 0; list-style: none; }
.ctx li { font-size: 0.98rem; padding: 0.12rem 0; min-height: 1.6rem; }
.ctx li:first-child { font-weight: 600; }
.dts { margin-top: 0.7rem; }
.dts-line { display: flex; align-items: center; gap: 0.5rem; font-size: 1.05rem; min-height: 1.6rem; margin-top: 0.2rem; }
.st-dot { width: 0.62rem; height: 0.62rem; border-radius: 50%; flex: none; }
.st-dot.ok { background: var(--ok); }
.st-dot.hot { background: var(--critical); }
/* DTS waterfall */
.dtsw-plot { position: relative; height: 6.5rem; }
.dtsw-plot canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.dtsw-x { position: relative; height: 1.45rem; font-size: 0.95rem; color: var(--muted); }
.dtsw-x span { position: absolute; top: 0.15rem; transform: translateX(-50%); white-space: nowrap; }
.dtsw-x span:first-child { transform: none; }
.dtsw-x span:last-child { transform: translateX(-100%); }
.dtsw .legend { display: flex; justify-content: flex-end; font-size: 0.9rem; padding-top: 0.1rem; }
.ramp-t { background: linear-gradient(90deg, #cde2fb, #9ec5f4, #6da7ec, #3987e5, #256abf, #184f95, #0d366b) !important; }
.blk-dtsw .dts-line { margin-top: 0.35rem; }
.chat .blk-dtsw .dtsw { height: 15rem; display: flex; flex-direction: column; }   /* same height as the DAS waterfall beside it */
.chat .blk-dtsw .dtsw-plot { flex: 1; height: auto; }
.msg-row { display: flex; gap: 1rem; flex: none; }
.msg-row > .msg { flex: 1 1 0; min-width: 0; display: flex; }
.msg-row .bubble { flex: 1; min-width: 0; }
.who { flex-wrap: wrap; row-gap: 0.3rem; }

/* ---------------- agent text ---------------- */
.bullets { margin: 0; padding: 0; list-style: none; }
.bullets li { position: relative; padding: 0.28rem 0 0.28rem 1.15rem; font-size: 1.02rem; min-height: 1.9rem; }
.bullets li::before { content: ""; position: absolute; left: 0.1rem; top: 0.8rem; width: 0.42rem; height: 0.42rem; border-radius: 50%; background: var(--ink-2); }
.reqs { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; margin-top: 0.55rem; min-height: 2rem; }
.req { border: 1.5px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 0.18rem 0.75rem; font-size: 0.9rem; font-weight: 600;
       opacity: 0; transform: scale(.9); transition: opacity .35s, transform .35s; }
.req.on { opacity: 1; transform: none; }

/* ---------------- fetch lanes ---------------- */
.lane { display: grid; grid-template-columns: 1.6rem 1fr; column-gap: 0.55rem; padding: 0.5rem 0; border-top: 1px solid var(--grid); }
.lane:first-child { border-top: 0; padding-top: 0.1rem; }
.lane .st { grid-row: span 3; width: 1.3rem; height: 1.3rem; margin-top: 0.1rem; border-radius: 50%; border: 2px solid var(--grid);
            border-top-color: var(--accent); animation: spin .8s linear infinite; }
.lane .st.done { animation: none; border-color: var(--ok); background: var(--ok); position: relative; }
.lane .st.done::after { content: ""; position: absolute; left: 0.34rem; top: 0.14rem; width: 0.32rem; height: 0.62rem;
                        border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
@keyframes spin { to { transform: rotate(360deg); } }
.lane .lh { font-weight: 600; font-size: 0.98rem; }
.lane .lh small { font-weight: 400; color: var(--muted); font-size: 0.82rem; margin-left: 0.4rem; }
.lane .res { font-size: 0.98rem; color: var(--ink); min-height: 1.5rem; }
.lane .res.wait { color: var(--muted); }
.dots::after { content: "..."; display: inline-block; width: 0; overflow: hidden; vertical-align: bottom; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { to { width: 1.1em; } }
.prog { height: 3px; border-radius: 2px; background: var(--grid); overflow: hidden; margin-top: 0.3rem; transition: opacity .6s .4s; }
.prog i { display: block; height: 100%; width: 35%; background: var(--accent); border-radius: 2px; animation: indet 1.3s ease-in-out infinite; }
.prog.det i { width: 0; animation: none; }
@keyframes indet { from { transform: translateX(-110%); } to { transform: translateX(300%); } }
.lane.done .prog { opacity: 0; }
.lane.done .prog i { width: 100%; animation: none; transform: none; background: var(--ok); }

/* ---------------- decision ---------------- */
.decision { border-left: 6px solid var(--sev, var(--info)); }
.act { display: flex; align-items: center; gap: 0.6rem; margin: 0.1rem 0 0.6rem; }
.act svg { width: 1.9rem; height: 1.9rem; flex: none; }
.act b { font-size: 1.55rem; font-weight: 750; letter-spacing: -0.01em; text-transform: uppercase; min-height: 2rem; }
.dec { display: grid; grid-template-columns: auto 1fr; column-gap: 0.9rem; row-gap: 0.4rem; margin: 0; }
.dec dt { color: var(--muted); font-size: 0.9rem; padding-top: 0.08rem; opacity: 0; transition: opacity .35s; }
.dec dt.on { opacity: 1; }
.dec dd { margin: 0; font-size: 1.02rem; min-height: 1.5rem; }
.dec dd.strong { font-weight: 600; }

/* ---------------- chat view ---------------- */
/* scrollable; new messages arrive at the bottom (feed pushed down by margin-top: auto), scrollbar hidden */
.chat { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; display: flex; flex-direction: column;
        -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16%); mask-image: linear-gradient(to bottom, transparent 0, #000 16%); }
.chat::-webkit-scrollbar { display: none; }
.feed { width: min(60rem, calc(100% - 2.8rem)); margin: auto auto 0; display: flex; flex-direction: column; gap: 1rem; padding: 1rem 0 1.6rem; }
.msg { flex: none; }
.bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 0.75rem 1.2rem 0.95rem; }
.msg.me .bubble { background: #f6f8fc; border-color: rgba(28, 92, 171, 0.2); }
.msg .bubble.decision, .msg.me .bubble.decision { border-left: 6px solid var(--sev, var(--info)); }
.who { display: flex; align-items: center; gap: 0.55rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; margin-bottom: 0.5rem; }
.who .role { font-weight: 400; }
.who .live { margin-left: auto; }
.msg.me .ic { background: var(--accent); }
.msg.me .ic svg { stroke: #fff; }
.mtext { font-size: 1.05rem; min-height: 1.5rem; }
.chat .blk-wf .wf { height: 15rem; }

/* ---------------- site camera ---------------- */
.cam { position: fixed; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
       padding: 0.6rem 0.6rem 0.65rem; box-shadow: 0 12px 32px rgba(11, 11, 11, 0.14);
       opacity: 0; transform: translateY(10px); transition: opacity .5s, transform .5s; }
.cam.on { opacity: 1; transform: none; }
.cam-h { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; font-weight: 600; color: var(--ink-2); margin: 0 0 0.45rem 0.2rem; }
.cam-dot { width: 0.62rem; height: 0.62rem; border-radius: 50%; background: var(--ok); animation: pulse 1.4s ease-in-out infinite; }
.cam-v { position: relative; border-radius: 8px; overflow: hidden; background: #000; }
.cam-v video { display: block; width: 100%; height: auto; }
/* identical clock pills in the DAS and camera headers make the sync visible (the DAS clock is the anchor) */
.sync-pill { display: inline-block; background: var(--ink); color: #fff; font-size: 0.9rem; font-weight: 600; line-height: 1.3;
             padding: 0.12rem 0.55rem; border-radius: 6px; font-variant-numeric: tabular-nums; letter-spacing: .02em; white-space: nowrap;
             opacity: 0; transition: opacity .3s; }
.sync-pill.on { opacity: 1; }
.sync-pill:empty { display: none; }
/* event detected: solid pill in the header, pulsing frame */
.card.alert, .bubble.alert { border-color: var(--c-vehicle) !important; animation: alertPulse 1.1s ease-in-out 3; }
@keyframes alertPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(235, 104, 52, 0.45); } 50% { box-shadow: 0 0 0 10px rgba(235, 104, 52, 0.12); } }
.feed { transition: transform .8s cubic-bezier(.3, .7, .2, 1); }

/* video recording (?capture): the dashboard alone */
.capture .top, .capture .tip { display: none !important; }
.capture body { grid-template-rows: minmax(0, 1fr); }

/* chat -> dashboard morph */
::view-transition-group(*) { animation-duration: 1.2s; animation-timing-function: cubic-bezier(.3, .7, .2, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .7s; }

/* ---------------- phones (agent demo: chat only) ---------------- */
@media (max-width: 700px) {
  html { font-size: 14px; }
  .top { height: auto; flex-wrap: wrap; gap: 6px 10px; padding: 10px 14px; }
  .brand strong { font-size: 15px; }
  .brand div span { display: none; }
  .tabs { display: none; }
  .right { margin-left: 0; width: 100%; justify-content: space-between; gap: 8px; }
  .pill { font-size: 12px; padding: 4px 10px; }
  .clock { min-width: 0; font-size: 12px; }
  .chat { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 5%); mask-image: linear-gradient(to bottom, transparent 0, #000 5%); }
  .feed { width: calc(100% - 20px); gap: 0.75rem; padding-bottom: 1rem; }
  .bubble { padding: 0.65rem 0.8rem 0.8rem; border-radius: 12px; }
  .who { flex-wrap: wrap; row-gap: 0.35rem; }
  .who .sync-pill { font-size: 0.8rem; }
  .chat .blk-wf .wf { height: 13rem; }
  .msg-row { flex-direction: column; gap: 0.75rem; }
  .chat .blk-dtsw .dtsw { height: 10rem; }
  .vrow .v { white-space: normal; }
  .headline { font-size: 1.25rem; }
  .act b { font-size: 1.3rem; }
  .cam { width: 64vw; padding: 0.35rem 0.35rem 0.45rem; border-radius: 10px; }
  .cam-h { flex-wrap: wrap; gap: 0.3rem 0.4rem; font-size: 0.75rem; margin: 0 0 0.3rem 0.1rem; }
  .cam-h .sync-pill { font-size: 0.68rem; padding: 0.08rem 0.4rem; }
}
.dts:empty { display: none; }
