/*
 * Copyright 2026 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 *
 * IoT + Agentic AI Pipeline Studio — Google Cloudstyle 2.0 Light theme.
 * Two-screen architecture: Scenario Menu (#/) + 3-Act Guided Demo Stage (#/demo/<id>).
 */

:root {
  --bg: #FFFFFF;
  --surface: #F8F9FA;
  --border: #DADCE0;
  --border-strong: #BDC1C6;
  --title: #202124;
  --text: #3C4043;
  --muted: #5F6368;
  --blue: #4285F4;
  --blue-ink: #1A73E8;
  --blue-deep: #174EA6;
  --blue-bg: #E8F0FE;
  --blue-border: #AECBFA;
  --red: #EA4335;
  --red-ink: #C5221F;
  --red-bg: #FCE8E6;
  --red-border: #F6AEA9;
  --yellow: #FBBC04;
  --yellow-ink: #B06000;
  --yellow-bg: #FEF7E0;
  --yellow-border: #FDD663;
  --green: #34A853;
  --green-ink: #137333;
  --green-bg: #E6F4EA;
  --green-border: #A8DAB5;
  --amber: #F29900;
  --amber-ink: #B06000;
  --amber-bg: #FEF7E0;
  --amber-border: #FDD663;

  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 28px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;

  --radius: 8px;
  --font: "Google Sans", "Google Sans Text", Inter, Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Roboto Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(60, 64, 67, .12), 0 1px 3px rgba(60, 64, 67, .08);
  --shadow-pop: 0 6px 20px rgba(32, 33, 36, .16);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { color: var(--title); margin: 0; font-weight: 500; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-lg); }
h2 { font-size: var(--fs-md); }
h3 { font-size: var(--fs-sm); }
h4 { font-size: var(--fs-xs); }
b, strong, th { font-weight: 500; }
p { margin: 0; }
code, pre { font-family: var(--mono); font-size: var(--fs-xs); }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue-ink); outline-offset: 2px; }

/* ---------- Topbar (48px single-line on both Menu and Demo) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  height: 48px;
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: nowrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  flex: 0 1 auto;
  flex-wrap: nowrap;
}
.brand-mark { display: grid; grid-template-columns: 8px 8px; gap: 3px; flex: none; }
.brand-mark i { width: 8px; height: 8px; border-radius: 2px; display: block; }
.brand-mark .b { background: var(--blue); }
.brand-mark .r { background: var(--red); }
.brand-mark .y { background: var(--yellow); }
.brand-mark .g { background: var(--green); }
.brand-text { min-width: 0; }
.brand-title {
  font-size: var(--fs-md);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub { display: none; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }

.demo-pill, .offline-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  font-size: var(--fs-xs);
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 var(--sp-2);
  cursor: help;
  white-space: nowrap;
}
.offline-pill { color: var(--yellow-ink); background: var(--yellow-bg); border-color: var(--yellow-border); }

.topbar-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: none;
  flex-wrap: nowrap;
}
body.route-demo #historyBtn,
body.route-demo #exportLink {
  display: none;
}
@media (min-width: 1280px) {
  body.route-demo .topbar-controls {
    flex: 1 1 0;
    justify-content: flex-end;
  }
}
.topbar .btn {
  min-height: 32px;
  font-size: var(--fs-xs);
  padding: var(--sp-1) var(--sp-3);
}
.topbar .seg-btn {
  min-height: 32px;
  font-size: var(--fs-xs);
  padding: var(--sp-1) var(--sp-3);
}

/* Demo Header Left Navigation + Center 3-Act Stepper + More Menu */
.demo-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  flex: 1 1 0;
  flex-wrap: nowrap;
}
.back-btn {
  flex: none;
  gap: var(--sp-1);
}
.demo-switcher {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-width: 0;
  flex: 0 1 auto;
}
.demo-scenario-title {
  min-width: 0;
  max-width: 240px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 var(--sp-1);
}

.act-stepper {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.act-step {
  border: 0;
  background: transparent;
  min-height: 32px;
  padding: 0 var(--sp-3);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.act-step:hover { color: var(--title); }
.act-step-num,
.act-num,
.act-dot {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1;
  background: var(--bg);
  color: var(--muted);
  border: 1.5px solid var(--border-strong);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.act-step-num svg,
.act-num svg,
.act-dot svg { width: 12px; height: 12px; }
.act-step.is-active {
  background: var(--bg);
  color: var(--blue-ink);
  box-shadow: var(--shadow);
}
.act-step.is-active .act-step-num,
.act-step.is-active .act-num,
.act-step.is-active .act-dot {
  border-color: var(--blue-ink);
  background: var(--blue-bg);
  color: var(--blue-ink);
}
.act-step.is-done { color: var(--green-ink); }
.act-step.is-done .act-step-num,
.act-step.is-done .act-num,
.act-step.is-done .act-dot {
  background: var(--green-ink);
  border-color: var(--green-ink);
  color: #FFFFFF;
}
.act-step.is-noise { color: var(--yellow-ink); }
.act-step.is-noise .act-step-num,
.act-step.is-noise .act-num,
.act-step.is-noise .act-dot {
  background: var(--yellow-bg);
  border-color: var(--yellow);
  color: var(--yellow-ink);
}
.act-step.is-ready:not(.is-active) {
  background: var(--amber-bg);
  color: var(--amber-ink);
  box-shadow: 0 0 0 2px rgba(242, 153, 0, .26);
  animation: pulseReady 1.8s ease-in-out infinite;
}
.act-step.is-ready .act-step-num,
.act-step.is-ready .act-num,
.act-step.is-ready .act-dot {
  background: var(--amber-ink);
  border-color: var(--amber-ink);
  color: #FFFFFF;
}

.more-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.more-btn {
  min-width: 32px;
  min-height: 32px;
  padding: var(--sp-1) var(--sp-2) !important;
}
.more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 48;
  min-width: 248px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: var(--sp-1);
  display: grid;
  gap: 2px;
}
.more-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  width: 100%;
  min-height: 36px;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--title);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.more-item:hover {
  background: var(--surface);
  color: var(--blue-ink);
}

/* ---------- Buttons, Pills & Segmented Controls ---------- */
.segmented {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0;
  gap: 0;
}
.seg-btn {
  border: 0;
  background: transparent;
  min-width: 32px;
  min-height: 32px;
  padding: var(--sp-1) var(--sp-3);
  border-radius: calc(var(--radius) - 1px);
  cursor: pointer;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--title); }
.seg-btn.is-active { background: var(--bg); color: var(--blue-ink); box-shadow: var(--shadow); }
.segmented-sm .seg-btn { min-width: 32px; min-height: 32px; padding: var(--sp-1) var(--sp-2); font-size: var(--fs-xs); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 36px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.3;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { background: var(--surface); border-color: var(--border-strong); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; }
.btn-ghost[aria-pressed="true"] { color: var(--blue-ink); border-color: var(--blue-border); background: var(--blue-bg); }
.btn-primary { background: var(--blue-ink); border-color: var(--blue-ink); color: #FFFFFF; }
.btn-primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn-secondary { background: var(--blue-bg); border-color: var(--blue-border); color: var(--blue-deep); }
.btn-secondary:hover { background: #D2E3FC; border-color: var(--blue-ink); }
.btn-approve { background: var(--green-ink); border-color: var(--green-ink); color: #FFFFFF; }
.btn-approve:hover { background: #0D652D; border-color: #0D652D; }
.btn-danger-ghost { color: var(--red-ink); }
.btn-danger-ghost:hover { background: var(--red-bg); border-color: var(--red-border); }
.btn-sm { min-height: 32px; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); }
.btn-link {
  border: 0;
  background: none;
  color: var(--blue-ink);
  min-height: 32px;
  padding: 0 var(--sp-2);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  cursor: pointer;
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}
.btn-link:hover { text-decoration: underline; }
.is-next {
  box-shadow: 0 0 0 3px rgba(26, 115, 232, .26);
}

.rail-arrow {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: var(--fs-md);
  line-height: 1;
  transition: background .15s ease, border-color .15s ease;
}
.rail-arrow svg { width: 16px; height: 16px; }
.rail-arrow:hover:not(:disabled) { background: var(--surface); border-color: var(--border-strong); }
.rail-arrow:disabled { opacity: .35; cursor: default; }

.pill {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-xs);
  font-weight: 500;
  border-radius: 999px;
  padding: 2px var(--sp-2);
  white-space: nowrap;
  background: var(--green-bg);
  color: var(--green-ink);
  line-height: 1.35;
}
.pill-red { background: var(--red-bg); color: var(--red-ink); }
.pill-yellow { background: var(--yellow-bg); color: var(--yellow-ink); }
.pill-blue { background: var(--blue-bg); color: var(--blue-deep); }
.pill-grey { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.pill-amber { background: var(--amber-bg); color: var(--amber-ink); box-shadow: inset 0 0 0 1px var(--amber-border); }

.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }

/* ---------- Screen 1: Scenario Menu (#menuView, body.route-menu) ---------- */
body.route-menu {
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
}
.main {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-6) var(--sp-8);
}

.menu-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.menu-hero-text,
.menu-hero-copy,
.menu-hero > div:first-child {
  min-width: 0;
  flex: 1 1 360px;
}
.menu-title,
.menu-hero h2 {
  font-size: var(--fs-lg);
  font-weight: 500;
  color: var(--title);
  line-height: 1.3;
}
.menu-sub,
.menu-hero p {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-top: var(--sp-1);
  line-height: 1.45;
}

.sector-filter {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.filter-label { display: none; }
.filter-pill {
  min-height: 32px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.3;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.filter-pill:hover { border-color: var(--border-strong); background: var(--surface); }
.filter-pill.is-active { border-color: var(--blue-ink); background: var(--blue-bg); color: var(--blue-deep); }

.menu-sections {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}
.menu-sector-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.menu-sector-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.menu-sector-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--title);
  line-height: 1.3;
}
.menu-sector-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 var(--sp-2);
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-4);
  align-items: stretch;
}
.scenario-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  text-align: left;
  text-decoration: none;
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  cursor: pointer;
  min-width: 0;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.scenario-card:hover,
.scenario-card:focus-visible {
  border-color: var(--blue-ink);
  box-shadow: 0 4px 12px rgba(60, 64, 67, .12);
  transform: translateY(-1px);
}
.scenario-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 14 / 9;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  flex: none;
}
.scenario-thumb img,
.scenario-thumb-img,
.scenario-thumb .scene-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 0;
  transition: transform .25s ease;
}
.scenario-card:hover .scenario-thumb img,
.scenario-card:hover .scenario-thumb-img {
  transform: scale(1.03);
}
.scenario-thumb-svg,
.scenario-thumb .scene-svg {
  position: absolute;
  inset: 0;
}
.scenario-thumb-svg > svg,
.scenario-thumb .scene-svg > svg,
.scenario-thumb > svg {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.scenario-card-body {
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  flex: 1;
  min-width: 0;
}
.scenario-sector {
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}
.scenario-card-title {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--title);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.chip-tag {
  flex: none;
  align-self: flex-start;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--yellow-ink);
  background: var(--yellow-bg);
  border-radius: 4px;
  padding: 0 var(--sp-1);
}

.scenario-card-new {
  border: 1.5px dashed var(--border-strong);
  background: var(--surface);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  min-height: 220px;
  gap: var(--sp-2);
}
.scenario-card-new:hover,
.scenario-card-new:focus-visible {
  border-style: solid;
  border-color: var(--blue-ink);
  background: var(--blue-bg);
}
.scenario-new-plus,
.scenario-new-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--blue-ink);
  display: grid;
  place-items: center;
  font-size: var(--fs-lg);
  font-weight: 500;
  line-height: 1;
}
.scenario-card-new .scenario-card-title {
  color: var(--blue-deep);
}
.scenario-new-sub,
.scenario-card-new p {
  font-size: var(--fs-xs);
  color: var(--muted);
  max-width: 240px;
  line-height: 1.4;
}

/* ---------- Screen 2: 3-Act Guided Demo Stage (#demoView, body.route-demo) ---------- */
body.route-demo {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
body.route-demo .main {
  flex: 1;
  min-height: 0;
  padding: var(--sp-6) var(--sp-6) var(--sp-4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.view-demo {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
[data-act-panel] {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  align-content: start;
  animation: actIn .22s ease-out;
}

.act-grid {
  display: grid;
  gap: var(--sp-4);
  align-items: start;
  width: 100%;
}
.act-grid-1 {
  grid-template-columns: minmax(0, 1.32fr) minmax(0, 1fr);
}
.act-grid-2 {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
}
.act-grid-3 {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
}
.act2-layout {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: 100%;
  min-width: 0;
}
.col {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  min-width: 0;
  position: relative;
}
.card.surface { background: var(--surface); }
.card.is-live { box-shadow: 0 0 0 3px rgba(66, 133, 244, .16); }

.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  flex-wrap: wrap;
}
.card-title {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--title);
  margin-bottom: var(--sp-2);
  line-height: 1.35;
}
.card-head-row .card-title,
.card-head-row h3,
.cctv-bar .card-title { margin-bottom: 0; }
.card-sub {
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- Act 1: 3D Scene + Numbered Pins + Leaders + Tooltip ---------- */
.scene {
  position: relative;
  width: 100%;
  aspect-ratio: 560 / 360;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: visible;
}
.scene-img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: 560 / 360;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: calc(var(--radius) - 1px);
  user-select: none;
  -webkit-user-drag: none;
}
.scene-svg {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: calc(var(--radius) - 1px);
  overflow: hidden;
}
.scene-svg > svg {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.scene-leaders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}
.scene-leaders .leader {
  stroke: var(--text);
  stroke-width: 1.5;
  opacity: .92;
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, .96));
}
.scene-leaders .leader-dot {
  fill: var(--blue-ink);
  stroke: #FFFFFF;
  stroke-width: 1.5;
}

.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  border: 2px solid #FFFFFF;
  background: var(--green-ink);
  color: #FFFFFF;
  box-shadow: 0 1px 3px rgba(32, 33, 36, .32);
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1;
  transition: background .2s ease, transform .15s ease, box-shadow .15s ease;
}
.pin-num {
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1;
  pointer-events: none;
}
.pin:hover, .pin:focus-visible, .pin.is-hover {
  transform: translate(-50%, -50%) scale(1.16);
  z-index: 5;
  box-shadow: 0 0 0 4px rgba(26, 115, 232, .3), 0 2px 6px rgba(32, 33, 36, .35);
}
.pin.is-anomaly {
  background: var(--red-ink);
  box-shadow: 0 0 0 4px rgba(197, 34, 31, .24), 0 1px 3px rgba(32, 33, 36, .32);
}
.pin.is-anomaly:hover, .pin.is-anomaly:focus-visible, .pin.is-anomaly.is-hover {
  box-shadow: 0 0 0 5px rgba(197, 34, 31, .34), 0 2px 6px rgba(32, 33, 36, .35);
}
.pin-shield {
  display: none;
  position: absolute;
  top: -8px;
  left: -8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--amber-ink);
  color: #FFFFFF;
  border: 1.5px solid #FFFFFF;
  place-items: center;
  pointer-events: none;
}
.pin-shield svg { width: 9px; height: 9px; display: block; }
.pin.is-spoofed {
  background: var(--amber-ink);
  box-shadow: 0 0 0 4px rgba(242, 153, 0, .3), 0 1px 3px rgba(32, 33, 36, .32);
}
.pin.is-spoofed .pin-shield { display: grid; }

.scene-tip {
  position: absolute;
  z-index: 12;
  max-width: min(240px, calc(100% - 16px));
  background: var(--title);
  color: #FFFFFF;
  font-size: var(--fs-xs);
  line-height: 1.4;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(32, 33, 36, .25);
  pointer-events: none;
  white-space: normal;
  text-align: left;
}
.scene-tip-name {
  display: block;
  font-weight: 500;
  color: #FFFFFF;
  margin-bottom: 2px;
}
.scene-tip-val {
  display: block;
  color: #E8EAED;
}

.actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.actions-grid .btn {
  width: 100%;
  min-height: 36px;
  font-size: var(--fs-xs);
  white-space: normal;
  text-align: center;
}

/* ---------- CCTV + Vector HUD ---------- */
.cctv-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.cctv-rec {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--muted);
  white-space: nowrap;
}
.cctv-rec::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  animation: blink 1.6s steps(2, start) infinite;
}
.cctv-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 280 / 150;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
}
.cctv-layer { position: absolute; inset: 0; z-index: 0; }
.cctv-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  user-select: none;
  pointer-events: none;
}
.cctv-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.cctv-svg { width: 100%; height: 100%; }
.cctv-svg > svg,
.cctv-layer > svg { width: 100% !important; height: 100% !important; display: block; }
.cctv-hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100% !important;
  height: 100% !important;
  display: block;
  pointer-events: none;
}
.cctv-hud text { font-variant-numeric: tabular-nums; }
.cctv-replay {
  position: absolute;
  right: 8px;
  bottom: 6px;
  z-index: 3;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .92);
  color: var(--title);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.cctv-replay:hover,
.cctv-replay:focus-visible {
  background: var(--bg);
  border-color: var(--blue-ink);
  color: var(--blue-ink);
  transform: scale(1.06);
}
.cctv-frame.is-fallback .cctv-hud,
.cctv.is-fallback .cctv-hud,
.cctv-frame.is-fallback .cctv-replay,
.cctv.is-fallback .cctv-replay { display: none !important; }
.cctv-layer.anomaly { display: none; visibility: hidden; }
.cctv.is-anomaly .cctv-layer.anomaly { display: block; visibility: visible; }
.cctv.is-anomaly .cctv-layer.normal { display: none; visibility: hidden; }
.cctv-caption {
  font-size: var(--fs-xs);
  margin-top: var(--sp-2);
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cctv.is-anomaly .cctv-caption { color: var(--red-ink); }

/* ---------- Unified Sensor & Cross-Verification List (Act 1) ---------- */
.sensor-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-1);
  align-content: start;
}
.sensor-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: var(--sp-2);
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-1) var(--sp-3);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.sensor-row:hover, .sensor-row:focus-visible, .sensor-row.is-hover {
  border-color: var(--blue-ink);
  background: var(--blue-bg);
  box-shadow: 0 0 0 2px rgba(26, 115, 232, .14);
}
.sensor-row.is-anomaly { border-color: var(--red-border); background: #FFFBFA; }
.sensor-row.is-anomaly.is-hover, .sensor-row.is-anomaly:hover { border-color: var(--red-ink); }
.sensor-row.is-spoofed { border-color: var(--amber-border); background: #FFFDF5; }
.sensor-row.is-spoofed.is-hover, .sensor-row.is-spoofed:hover { border-color: var(--amber-ink); }

.sensor-ico {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--green-bg);
  color: var(--green-ink);
  font-size: var(--fs-xs);
  font-weight: 500;
}
.sensor-ico svg { width: 14px; height: 14px; }
.sensor-ico .pin-letter, .sensor-idx { font-size: var(--fs-xs); font-weight: 500; line-height: 1; }
.sensor-row.is-anomaly .sensor-ico { background: var(--red-bg); color: var(--red-ink); }
.sensor-row.is-spoofed .sensor-ico { background: var(--amber-bg); color: var(--amber-ink); }

.sensor-text { display: block; min-width: 0; }
.sensor-name {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--title);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sensor-meta {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.35;
  overflow: hidden;
  white-space: normal;
}
.sensor-val {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sensor-meta .sensor-val {
  display: inline;
  white-space: normal;
}
.sensor-role {
  color: var(--blue-deep);
  font-weight: 500;
}
.sensor-row.is-anomaly .sensor-val,
.sensor-row.is-anomaly .sensor-meta { color: var(--red-ink); }
.sensor-row.is-spoofed .sensor-val,
.sensor-row.is-spoofed .sensor-meta { color: var(--amber-ink); }

.sensor-noise-note {
  margin: var(--sp-2) 0 0;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  border-left: 3px solid var(--yellow);
  background: var(--yellow-bg);
  color: var(--title);
  font-size: var(--fs-xs);
  line-height: 1.4;
}
.sensor-noise-note.is-alert {
  border-left-color: var(--red);
  background: var(--red-bg);
}
.sensor-noise-note .btn-link {
  margin-left: var(--sp-1);
  font-size: var(--fs-xs);
}

/* ---------- Act 2 Top Strip: 5-Node Cloud Chain (.chain-strip) ---------- */
.chain-strip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.chain-strip.is-flowing {
  border-color: var(--blue-border);
  box-shadow: 0 0 0 3px rgba(66, 133, 244, .14);
}
.chain-strip.is-flowing .chain-node {
  border-color: var(--blue-border);
}
.chain-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.chain-strip.has-head {
  flex-direction: column;
  align-items: stretch;
  gap: var(--sp-2);
}
.chain,
.chain-nodes {
  flex: 1 1 0;
  min-width: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--sp-3);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='10' viewBox='0 0 6 10'%3E%3Cpath d='M1.25 1.5L4.75 5L1.25 8.5' fill='none' stroke='%235F6368' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='10' viewBox='0 0 6 10'%3E%3Cpath d='M1.25 1.5L4.75 5L1.25 8.5' fill='none' stroke='%235F6368' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='10' viewBox='0 0 6 10'%3E%3Cpath d='M1.25 1.5L4.75 5L1.25 8.5' fill='none' stroke='%235F6368' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='10' viewBox='0 0 6 10'%3E%3Cpath d='M1.25 1.5L4.75 5L1.25 8.5' fill='none' stroke='%235F6368' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 6px 10px;
  background-position:
    left calc(20% - 6.6px) center,
    left calc(40% - 4.2px) center,
    left calc(60% - 1.8px) center,
    left calc(80% + 0.6px) center;
}
.chain-node {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--sp-2) var(--sp-2);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2px;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.chain-node.is-lit {
  border-color: var(--blue-border);
  background: var(--blue-bg);
  box-shadow: inset 0 2px 0 var(--blue-ink);
}
.chain-node[data-node="bq"].is-lit,
.chain-node[data-node="ticket"].is-lit,
.chain-node[data-node="3"].is-lit,
.chain-node[data-node="5"].is-lit {
  border-color: var(--green-border);
  background: var(--green-bg);
  box-shadow: inset 0 2px 0 var(--green-ink);
}
.chain-title {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--title);
  line-height: 1.3;
  overflow-wrap: break-word;
}
.chain-meta {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chain-node.is-lit .chain-meta { color: var(--text); }
.chain-tech,
.chain-strip-action {
  flex: none;
}

/* ---------- Act 2 Left Card: Unified ADK Agent & Tool Trace (.unified-steps) ---------- */
.unified-steps,
.agent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
}
.unified-step,
.ustep,
.agent-step {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: var(--sp-3);
  position: relative;
  padding-bottom: var(--sp-3);
  min-width: 0;
}
.unified-step:last-child,
.ustep:last-child,
.agent-step:last-child { padding-bottom: 0; }

.unified-step:not(:last-child)::before,
.ustep:not(:last-child)::before,
.agent-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 26px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.unified-step.is-done:not(:last-child)::before,
.ustep.is-done:not(:last-child)::before,
.agent-step.is-done:not(:last-child)::before {
  background: var(--green);
}

.agent-badge,
.ustep-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
  border: 1.5px solid var(--border-strong);
  background: var(--bg);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  flex: none;
}
.agent-badge svg,
.ustep-badge svg { width: 13px; height: 13px; }

.unified-step.is-active .agent-badge,
.unified-step.is-active .ustep-badge,
.ustep.is-active .ustep-badge,
.agent-step.is-active .agent-badge {
  border-color: var(--blue-ink);
  color: var(--blue-ink);
  background: var(--blue-bg);
}
.unified-step.is-active .agent-badge::after,
.unified-step.is-active .ustep-badge::after,
.ustep.is-active .ustep-badge::after,
.agent-step.is-active .agent-badge::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--blue);
  animation: spin .8s linear infinite;
}
.unified-step.is-done .agent-badge,
.unified-step.is-done .ustep-badge,
.ustep.is-done .ustep-badge,
.agent-step.is-done .agent-badge {
  background: var(--green-ink);
  border-color: var(--green-ink);
  color: #FFFFFF;
}
.unified-step.is-skipped .agent-badge,
.unified-step.is-skipped .ustep-badge,
.ustep.is-skipped .ustep-badge,
.agent-step.is-skipped .agent-badge {
  border-style: dashed;
  color: var(--border-strong);
}
.unified-step.is-skipped .ustep-body,
.unified-step.is-skipped .agent-body,
.ustep.is-skipped .ustep-body,
.agent-step.is-skipped .agent-body { opacity: .55; }

.unified-step.is-filter .agent-badge,
.unified-step.is-filter .ustep-badge,
.ustep.is-filter .ustep-badge,
.agent-step.is-filter .agent-badge {
  background: var(--yellow-bg);
  border-color: var(--yellow);
  color: var(--yellow-ink);
}

.ustep-body,
.agent-body {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.ustep-top,
.agent-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--sp-2);
  min-width: 0;
}
.ustep-title,
.agent-title {
  flex: 1 1 0;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--title);
  line-height: 1.3;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ustep-call,
.ustep-sub {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  flex-wrap: nowrap;
}
.trace-tool,
.ustep-tool {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--blue-deep);
  background: var(--blue-bg);
  border-radius: 4px;
  padding: 0 var(--sp-1);
  line-height: 1.45;
  white-space: nowrap;
  flex: none;
}
.trace-lat,
.ustep-lat {
  flex: none;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 var(--sp-2);
  line-height: 1.4;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.is-active .trace-lat,
.is-active .ustep-lat {
  color: var(--blue-deep);
  background: var(--blue-bg);
  border-color: var(--blue-border);
}
.is-done .trace-lat,
.is-done .ustep-lat {
  color: var(--green-ink);
  background: var(--green-bg);
  border-color: var(--green-border);
}
.trace-io,
.ustep-io,
.agent-detail {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
}
.is-active .trace-io,
.is-active .ustep-io { color: var(--blue-deep); }
.is-filter .trace-io,
.is-filter .ustep-io,
.is-filter .agent-detail { color: var(--yellow-ink); }

.trace-note {
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.4;
}

/* ---------- Act 2 Right Card: Score + Verdict + 5-Layer Matrix (.verdict-card) ---------- */
.verify-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 2px var(--sp-2);
  border-radius: 999px;
  background: var(--blue-bg);
  color: var(--blue-deep);
  border: 1px solid var(--blue-border);
  white-space: nowrap;
}
.verify-badge svg { width: 13px; height: 13px; }
.verdict-card.is-alert .verify-badge,
.verify.is-alert .verify-badge {
  background: var(--red-bg);
  color: var(--red-ink);
  border-color: var(--red-border);
}
.verdict-card.is-tamper .verify-badge,
.verify.is-tamper .verify-badge {
  background: var(--amber-bg);
  color: var(--amber-ink);
  border-color: var(--amber-border);
}

.score {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: 0 0 var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.score-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.score-fill { display: block; height: 100%; width: 0; background: var(--green); border-radius: 3px; transition: width .5s ease; }
.score-fill.is-noise { background: var(--yellow); }
.score-fill.is-alert { background: var(--red); }
.score-val { font-family: var(--mono); font-size: var(--fs-xs); font-weight: 500; color: var(--title); min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.score-label { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }

.verify-verdict {
  margin: 0 0 var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  line-height: 1.45;
  color: var(--title);
  border-left: 3px solid var(--border-strong);
  background: var(--surface);
  border-radius: 0 6px 6px 0;
}
.verdict-card.is-alert .verify-verdict,
.verify.is-alert .verify-verdict { border-left-color: var(--red); background: var(--red-bg); }
.verdict-card.is-tamper .verify-verdict,
.verify.is-tamper .verify-verdict { border-left-color: var(--amber); background: var(--amber-bg); }
.verdict-card.is-noise .verify-verdict,
.verify.is-noise .verify-verdict { border-left-color: var(--yellow); background: var(--yellow-bg); }

.layer-matrix {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-1);
}
.layer-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-2);
  min-height: 36px;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  min-width: 0;
  transition: border-color .2s ease, background .2s ease;
}
.lrow,
.vcheck {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
  min-height: 36px;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  min-width: 0;
  transition: border-color .2s ease, background .2s ease;
}
.layer-row.is-confirmed,
.lrow.is-confirmed,
.vcheck.is-confirmed {
  border-color: var(--red-border);
  background: #FFFBFA;
  box-shadow: inset 3px 0 0 var(--red);
}
.layer-row.is-spoofed,
.lrow.is-spoofed,
.vcheck.is-spoofed {
  border-color: var(--amber-border);
  background: #FFFDF5;
  box-shadow: inset 3px 0 0 var(--amber);
}
.layer-left,
.vcheck-layer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  flex: 1 1 0;
}
.layer-num,
.vcheck-num {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--blue-deep);
  background: var(--blue-bg);
}
.is-confirmed .layer-num,
.is-confirmed .vcheck-num { color: var(--red-ink); background: var(--red-bg); }
.is-spoofed .layer-num,
.is-spoofed .vcheck-num { color: var(--amber-ink); background: var(--amber-bg); }

.layer-label,
.vcheck-label {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.layer-claim {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-left: 3px solid var(--amber);
  background: var(--amber-bg);
  border-radius: 0 6px 6px 0;
  font-size: var(--fs-xs);
  color: var(--amber-ink);
  line-height: 1.4;
}
.verdict-jump {
  margin-top: var(--sp-2);
  font-size: var(--fs-xs);
  align-self: flex-start;
}
.vcheck-claim {
  flex: 1 1 100%;
  font-size: var(--fs-xs);
  color: var(--amber-ink);
  line-height: 1.35;
  padding-left: 28px;
}

/* ---------- Act 3: Ticket + Audited Evidence ---------- */
.ticket {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
.ticket-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.ticket-code { font-family: var(--mono); font-size: var(--fs-xs); font-weight: 500; color: var(--title); }
.ticket-body { padding: var(--sp-3); display: grid; gap: var(--sp-2); }
.ticket-title { font-size: var(--fs-md); font-weight: 500; color: var(--title); line-height: 1.35; }
.kv {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: var(--sp-1) var(--sp-3);
  font-size: var(--fs-xs);
  margin: 0;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--title); overflow-wrap: break-word; line-height: 1.45; }
.ticket-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: center;
}
.ticket-actions .note { font-size: var(--fs-xs); color: var(--muted); flex: 1 1 180px; }
.ticket.is-new { animation: rise .35s ease-out; }

.notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--sp-4);
  background: var(--surface);
  display: grid;
  gap: var(--sp-2);
}
.notice.notice-yellow { border-left-color: var(--yellow); background: var(--yellow-bg); }
.notice.notice-green { border-left-color: var(--green); background: var(--green-bg); }
.notice.notice-blue { border-left-color: var(--blue); background: var(--blue-bg); }
.notice-title { font-size: var(--fs-sm); font-weight: 500; color: var(--title); }
.notice p { font-size: var(--fs-xs); color: var(--text); line-height: 1.45; }

.evidence-card .cctv {
  padding: 0;
  border: 0;
  background: transparent;
}
.evidence-card .cctv-caption {
  -webkit-line-clamp: 3;
}
.evidence-summary,
.evidence-list {
  list-style: none;
  margin: var(--sp-3) 0 0;
  padding: var(--sp-3) 0 0;
  border-top: 1px solid var(--border);
  display: grid;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
}
.evidence-item,
.evidence-list li {
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: 0 6px 6px 0;
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-xs);
  line-height: 1.4;
}
.evidence-item[data-kind="layers"] { border-left-color: var(--blue); }
.evidence-item[data-kind="layers"].is-alert { border-left-color: var(--red); background: #FFFBFA; color: var(--red-ink); }
.evidence-item[data-kind="tamper"].is-alert { border-left-color: var(--amber); background: var(--amber-bg); color: var(--amber-ink); }
.evidence-item[data-kind="failclosed"] { border-left-color: var(--green); }
.evidence-k { color: var(--muted); }
.evidence-v { color: var(--title); font-weight: 500; overflow-wrap: break-word; }

/* ---------- Modals: Create Prototype, Technical Details (SQL), History ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(32, 33, 36, .42);
  display: grid;
  place-items: center;
  padding: var(--sp-6);
}
.modal {
  width: min(860px, 100%);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 8px 28px rgba(32, 33, 36, .22);
  display: flex;
  flex-direction: column;
}
.modal.modal-wide {
  width: min(1040px, 100%);
}
.modal-head {
  padding: var(--sp-4) var(--sp-6);
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.modal-head .grow { flex: 1 1 240px; min-width: 0; }
.modal-head-actions { display: flex; align-items: center; gap: var(--sp-2); flex: none; margin-left: auto; }
.modal-head > button:first-of-type { margin-left: auto; }
.modal-head h2 { font-size: var(--fs-lg); line-height: 1.25; }
.modal-body {
  padding: var(--sp-4) var(--sp-6);
  display: grid;
  gap: var(--sp-4);
  overflow-y: auto;
}
.modal-body h4 { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: var(--sp-2); }
.modal-foot {
  padding: var(--sp-3) var(--sp-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}
.modal-foot-right { display: flex; gap: var(--sp-2); margin-left: auto; }

/* Technical Modal Components (Compare Table, Hop Facts, SQL, Engine Modes) */
.hop-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.fact { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-2) var(--sp-3); background: var(--surface); min-width: 0; }
.fact-k { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.fact-v { font-size: var(--fs-xs); color: var(--title); margin-top: 2px; }

.compare {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  table-layout: fixed;
}
.compare th, .compare td {
  text-align: left;
  padding: var(--sp-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
  vertical-align: top;
  overflow-wrap: break-word;
}
.compare th { font-weight: 500; color: var(--muted); background: var(--surface); }
.compare td.is-anomaly { color: var(--red-ink); font-weight: 500; }
.compare td.target { color: var(--muted); font-family: var(--mono); overflow-wrap: anywhere; }
.compare tr.is-anomaly td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.compare td.is-spoofed { color: var(--amber-ink); font-weight: 500; }
.compare tr.is-spoofed td:first-child { box-shadow: inset 3px 0 0 var(--amber); }

pre.code {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--sp-3);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--title);
  max-height: 220px;
  overflow: auto;
}

.engine-modes { margin: 0; display: grid; gap: var(--sp-2); }
.engine-modes dt { font-size: var(--fs-xs); font-weight: 500; color: var(--title); }
.engine-modes dd {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text);
  line-height: 1.45;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.engine-modes dd + dt + dd { border-left-color: var(--border-strong); }

/* Technical Modal Tabs & Licensing Matrix (Gemini Enterprise vs. Vertex AI) */
.tech-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}
.tech-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px var(--sp-2);
  font-family: var(--font);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color .15s ease, border-color .15s ease;
}
.tech-tab:hover { color: var(--title); }
.tech-tab.is-active { color: var(--blue-ink); border-bottom-color: var(--blue); }
.tech-tab:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; border-radius: 4px; }
.tech-jump-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.lic-intro {
  margin: 0;
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--text);
}
.lic-routes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}
.lic-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 4px solid var(--green);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  display: grid;
  gap: var(--sp-2);
  align-content: start;
  min-width: 0;
}
.lic-card.is-adk { border-top-color: var(--blue); }
.lic-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.lic-card-title { margin: 0; font-size: var(--fs-sm); font-weight: 500; color: var(--title); line-height: 1.3; }
.lic-pill {
  flex: none;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--green-bg);
  color: var(--green-ink);
  border: 1px solid var(--green-border);
  white-space: nowrap;
}
.lic-card.is-adk .lic-pill {
  background: var(--blue-bg);
  color: var(--blue-ink);
  border-color: var(--blue-border);
}
.lic-list {
  margin: 0;
  padding-left: 16px;
  display: grid;
  gap: 5px;
  font-size: var(--fs-xs);
  line-height: 1.45;
  color: var(--text);
}
.lic-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--fs-xs);
}
.lic-links a {
  color: var(--blue-ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.lic-links a:hover { text-decoration: underline; }
@media (max-width: 780px) {
  .lic-routes { grid-template-columns: 1fr; }
  .hop-facts { grid-template-columns: 1fr; }
}

/* History Modal Components */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-2);
}
.stat {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  min-width: 0;
}
.stat-v {
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.stat-k { font-size: var(--fs-xs); color: var(--muted); line-height: 1.3; }
.history { width: 100%; border-collapse: collapse; table-layout: fixed; }
.history th, .history td {
  text-align: left;
  padding: var(--sp-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history th { color: var(--muted); font-weight: 500; background: var(--surface); }
.history tbody tr { min-height: 36px; transition: background .15s ease; }
.history tbody tr[data-action],
.history tbody tr.js-history-row { cursor: pointer; }
.history tbody tr:hover { background: var(--blue-bg); }
.history td.mono { font-family: var(--mono); }
.history th.num, .history td.num { text-align: right; font-variant-numeric: tabular-nums; }
.history-empty { font-size: var(--fs-xs); color: var(--muted); padding: var(--sp-3) 0; }

/* Create Custom Scenario Form */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-4); }
.field { display: grid; gap: var(--sp-1); min-width: 0; }
.field label { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.field input, .field select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg);
  color: var(--title);
  font-size: var(--fs-sm);
}
.field input:focus, .field select:focus { border-color: var(--blue-ink); outline: none; box-shadow: 0 0 0 2px rgba(26, 115, 232, .18); }
.sensor-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.sensor-table th { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; text-align: left; padding: var(--sp-1); }
.sensor-table td { padding: var(--sp-1); }
.sensor-table input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--fs-xs);
}
.sensor-table input:focus { border-color: var(--blue-ink); outline: none; }
.form-error { color: var(--red-ink); font-size: var(--fs-xs); min-height: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  right: var(--sp-6);
  bottom: var(--sp-6);
  z-index: 70;
  max-width: 420px;
  background: var(--title);
  color: #FFFFFF;
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  box-shadow: 0 4px 16px rgba(32, 33, 36, .25);
  animation: rise .25s ease-out;
}
.toast.is-error { background: var(--red-ink); }

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { to { visibility: hidden; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes actIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pulseReady {
  0%, 100% { box-shadow: 0 0 0 2px rgba(242, 153, 0, .24); }
  50% { box-shadow: 0 0 0 4px rgba(242, 153, 0, .38); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- Responsive Calibration (1280px, 1024x768, <960px) ---------- */
@media (max-width: 1279px) {
  .menu-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
  .topbar-inner { padding: 0 var(--sp-4); gap: var(--sp-2); }
  .topbar .btn, .topbar .seg-btn { padding: var(--sp-1) var(--sp-2); }
  .demo-scenario-title { max-width: 148px; font-size: var(--fs-xs); }
  .demo-nav .demo-pill { display: none; }
  .act-step { padding: 0 var(--sp-2); gap: var(--sp-1); }

  body.route-menu .main { padding: var(--sp-4) var(--sp-4) var(--sp-6); }
  body.route-demo .main { padding: var(--sp-3) var(--sp-4); }

  body.route-demo .card { padding: var(--sp-3); }
  body.route-demo .col { gap: var(--sp-2); }
  body.route-demo .actions-grid { margin-top: var(--sp-2); }
  body.route-demo .actions-grid .btn { min-height: 32px; padding: var(--sp-1) var(--sp-2); }
  body.route-demo .sensor-row { min-height: 38px; padding: var(--sp-1) var(--sp-2); }
  body.route-demo .cctv-caption { -webkit-line-clamp: 1; margin-top: var(--sp-1); }
  body.route-demo .evidence-card .cctv-caption { -webkit-line-clamp: 3; }

  .chain, .chain-nodes {
    gap: var(--sp-2);
    background-position:
      left calc(20% - 5.4px) center,
      left calc(40% - 3.8px) center,
      left calc(60% - 2.2px) center,
      left calc(80% - 0.6px) center;
  }
  .chain-node { padding: var(--sp-1) var(--sp-2); }
  .unified-step, .ustep, .agent-step { padding-bottom: var(--sp-2); }
  .kv { grid-template-columns: 116px minmax(0, 1fr); }
}

@media (max-width: 959px) {
  body.route-demo { height: auto; overflow-y: auto; }
  body.route-demo .main,
  .view-demo,
  [data-act-panel] { overflow: visible; }
  .topbar-inner { height: auto; min-height: 48px; padding: var(--sp-2) var(--sp-4); flex-wrap: wrap; }
  .menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .act-grid-1, .act-grid-2, .act-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .chain-strip { flex-direction: column; align-items: stretch; }
  .chain, .chain-nodes { grid-template-columns: repeat(2, minmax(0, 1fr)); background-image: none; }
  .hop-facts, .form-grid { grid-template-columns: minmax(0, 1fr); }
}
