:root {
  color-scheme: light;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --paper: #ffffff;
  --field: #f8fafc;
  --bg: #f1f5f9;
  --teal: #0f766e;
  --teal-soft: #14b8a6;
  --blue: #2563eb;
  --amber: #b45309;
  --rose: #be123c;
  --ring: rgba(20, 184, 166, 0.32);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06), 0 12px 32px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.16);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-width: 304px;
  --sidebar-collapsed-width: 56px;
  --nav-square: 44px;
  --agent-width: 270px;
  --results-height: 260px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e5edf7;
  --muted: #9fb0c3;
  --line: #26384f;
  --paper: #101c2b;
  --field: #0b1522;
  --bg: #07111f;
  --teal: #2dd4bf;
  --teal-soft: #5eead4;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --rose: #fb7185;
  --ring: rgba(45, 212, 191, 0.28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.22), 0 1px 3px rgba(0, 0, 0, 0.16);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.24), 0 12px 32px rgba(0, 0, 0, 0.20);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1100px 540px at 12% -10%, rgba(20, 184, 166, 0.10), transparent 60%),
    radial-gradient(900px 460px at 110% 0%, rgba(37, 99, 235, 0.08), transparent 55%),
    var(--bg);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body[data-theme="dark"] {
  background:
    radial-gradient(1100px 540px at 12% -10%, rgba(45, 212, 191, 0.10), transparent 60%),
    radial-gradient(900px 460px at 110% 0%, rgba(96, 165, 250, 0.10), transparent 55%),
    var(--bg);
}

body[data-theme="dark"] .topbar {
  background: linear-gradient(120deg, #050c17 0%, #0b1527 58%, #0d2f32 100%);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.42);
}

body[data-theme="dark"] input,
body[data-theme="dark"] textarea,
body[data-theme="dark"] select {
  color: var(--ink);
  background: var(--field);
}

body[data-theme="dark"] input:focus,
body[data-theme="dark"] textarea:focus,
body[data-theme="dark"] select:focus {
  background: #0e1b2c;
}

body[data-theme="dark"] button {
  background: #122033;
  color: var(--ink);
}

body[data-theme="dark"] button:hover {
  background: #172942;
}

body.isResizing,
body.nodeDragging {
  user-select: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 20px;
  padding: 14px 22px;
  background: linear-gradient(120deg, #0b1d3a 0%, #14213d 55%, #0f3a3a 100%);
  color: #fff;
  box-shadow: 0 6px 28px rgba(8, 18, 38, 0.32);
}

.topbar > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.topActions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topActions button {
  flex: 0 1 auto;
  white-space: nowrap;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 750;
}

.topbar p {
  margin: 4px 0 0;
  color: #dbeafe;
  font-size: 12px;
  letter-spacing: 0.02em;
}

#summary {
  display: block;
  margin-top: 6px;
  color: #cbd5e1;
  font-size: 13px;
}

.topActions,
.segments,
.grid2,
.grid3,
.tableHeader {
  display: flex;
  gap: 8px;
}

button {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease),
    color 140ms var(--ease), box-shadow 140ms var(--ease), transform 140ms var(--ease);
}

button:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--ring);
}

button.primary,
.segments button.active {
  border-color: var(--teal);
  background: linear-gradient(180deg, #14b8a6 0%, #0f766e 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(15, 118, 110, 0.28);
}

button.primary:hover,
.segments button.active:hover {
  background: linear-gradient(180deg, #2dd4bf 0%, #0d9488 100%);
  border-color: #0d9488;
}

.topIconButton,
.accountButton {
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  box-shadow: none;
}

.topIconButton:hover,
.accountButton:hover {
  border-color: rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.20);
  color: #ffffff;
}

.topIconButton span {
  font-size: 20px;
  line-height: 1;
}

.accountButton span {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

input,
textarea,
select {
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease),
    background-color 140ms var(--ease);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--teal);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--ring);
}

.iconButton {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  font-weight: 800;
}

.workspace {
  height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: var(--sidebar-width) 8px minmax(0, 1fr);
  gap: 0;
  padding: 14px;
  transition: grid-template-columns 220ms var(--ease);
}

.panel,
.canvasWrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

body[data-theme="dark"] .panel,
body[data-theme="dark"] .canvasWrap,
body[data-theme="dark"] .settingsPopover,
body[data-theme="dark"] .mapZoomStack {
  background: rgba(16, 28, 43, 0.98);
}

body[data-theme="dark"] .mapSearchResults,
body[data-theme="dark"] .mapDetails {
  background: rgba(16, 28, 43, 0.78);
}

body[data-theme="dark"] .searchResult {
  background: rgba(18, 32, 51, 0.68);
}

body[data-theme="dark"] .searchResult:hover,
body[data-theme="dark"] .searchResult.active {
  background: linear-gradient(90deg, rgba(45, 212, 191, 0.22), rgba(18, 32, 51, 0.72));
}

.controls {
  min-width: 0;
  padding: 14px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  transition: padding 200ms var(--ease);
}

.controls::-webkit-scrollbar {
  width: 8px;
}

.controls::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cbd5e1;
}

.controls::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

body.sidebarCollapsed {
  --sidebar-width: var(--sidebar-collapsed-width);
}

.sidebarToggle {
  position: sticky;
  top: 0;
  z-index: 3;
  width: 100%;
  margin-bottom: 14px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  color: #1f2937;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 160ms var(--ease), color 160ms var(--ease),
    border-color 160ms var(--ease), box-shadow 160ms var(--ease),
    writing-mode 0ms;
}

.sidebarToggle:hover {
  background: linear-gradient(180deg, #ecfeff 0%, #e0f2fe 100%);
  border-color: #67e8f9;
  color: #0e7490;
}

.sidebarToggle::before {
  content: none;
}

.sidebarToggleIcon {
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  transition: transform 220ms var(--ease);
}

body.sidebarCollapsed .sidebarToggleIcon {
  transform: rotate(180deg);
}

.sideNav {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.navItem {
  width: 100%;
  min-height: var(--nav-square);
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 8px;
  text-align: left;
}

.navItem.active {
  border-color: var(--teal);
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.14), rgba(37, 99, 235, 0.08));
  color: var(--teal);
}

.navIcon,
.sectionIcon,
.railAction > span:first-child {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.10);
  color: var(--teal);
  font-weight: 900;
}

.navLabel {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navPanel {
  display: none;
}

.navPanel.active {
  display: block;
}

.actionList {
  display: grid;
  gap: 8px;
}

.railAction {
  width: 100%;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 8px;
  text-align: left;
}

.controls .controlBlock {
  transition: opacity 160ms var(--ease);
}

body.sidebarCollapsed .controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px;
  overflow: hidden;
}

body.sidebarCollapsed .controls .controlBlock {
  opacity: 0;
  pointer-events: none;
  height: 0;
  margin: 0;
  overflow: hidden;
}

body.sidebarCollapsed .sidebarToggle {
  width: var(--nav-square);
  height: var(--nav-square);
  min-height: var(--nav-square);
  padding: 0;
}

body.sidebarCollapsed .sidebarToggleLabel,
body.sidebarCollapsed .navLabel {
  display: none;
}

body.sidebarCollapsed .sideNav {
  width: var(--nav-square);
}

body.sidebarCollapsed .navItem {
  width: var(--nav-square);
  height: var(--nav-square);
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 0;
}

body.sidebarCollapsed .navIcon {
  width: 30px;
  height: 30px;
}

.resizeHandle {
  position: relative;
  z-index: 4;
  background: transparent;
  border-radius: 999px;
}

.resizeHandle::after {
  content: "";
  position: absolute;
  background: #bfd0dd;
  opacity: 0.85;
  transition: background 120ms ease, opacity 120ms ease;
}

.resizeHandle:hover::after,
.resizeHandle.dragging::after {
  background: var(--teal);
  opacity: 1;
}

.resizeHandleVertical {
  cursor: col-resize;
  margin: 0 4px;
}

.resizeHandleVertical::after {
  top: 12px;
  bottom: 12px;
  left: 3px;
  width: 2px;
}

.resizeHandleHorizontal {
  cursor: row-resize;
  margin: 4px 0;
}

.resizeHandleHorizontal::after {
  left: 12px;
  right: 12px;
  top: 3px;
  height: 2px;
}

.workbench {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(360px, 1fr) 8px var(--results-height);
  gap: 0;
}

.explorerGrid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8px var(--agent-width);
  gap: 0;
}

.explorerPanel,
.agentPanel,
.resultsPanel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

label,
.controlBlock,
.selectedPanel {
  display: block;
  margin-bottom: 12px;
}

label span,
.blockLabel {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
}

textarea {
  min-height: 198px;
  resize: vertical;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
}

input,
select {
  height: 36px;
  padding: 7px 9px;
}

.filePick input {
  padding: 6px;
  background: #fff;
}

.grid2,
.grid3 {
  align-items: end;
}

.grid2 label,
.grid3 label {
  flex: 1;
  margin-bottom: 0;
}

.grid3 label {
  min-width: 0;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: 16px;
  height: 16px;
}

.check span {
  margin: 0;
  text-transform: none;
  font-size: 13px;
}

.segments {
  flex-wrap: wrap;
}

.segments button {
  flex: 1;
  min-width: 72px;
}

.segments.mini button {
  min-width: 82px;
  padding-block: 6px;
}

.selectedPanel {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.railSection {
  border-bottom: 1px solid #e6edf5;
  padding-bottom: 12px;
}

.sectionTitle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}

.sectionTitle .blockLabel {
  margin: 0;
}

.sectionIcon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
  font-weight: 900;
}

.subLabel {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

#selectedDetails {
  display: grid;
  gap: 7px;
  font-size: 13px;
}

.detailLine {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #edf2f7;
  padding-bottom: 5px;
}

.explorerHeader,
.resultsHeader,
.agentHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.explorerHeader {
  align-items: start;
}

.explorerHeader > div:first-child {
  min-width: 190px;
}

.explorerHeader strong,
.agentHeader strong {
  display: block;
  font-size: 14px;
}

.explorerHeader > div:first-child span,
.agentHeader span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.compactControls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.compactControls .segments {
  flex-wrap: nowrap;
}

.compactControls .segments button {
  flex: 0 0 auto;
  min-width: 58px;
}

.settingsPopover {
  position: absolute;
  top: 62px;
  right: 18px;
  z-index: 10;
  width: min(760px, calc(100% - 24px));
  max-height: min(520px, calc(100% - 70px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
}

.settingsHeader {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

body[data-theme="dark"] .settingsHeader {
  background: #101c2b;
}

.settingsGrid {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.settingsGrid .filterGroup {
  display: grid;
  grid-template-columns: 78px repeat(6, max-content);
  align-items: center;
  justify-content: start;
  border-bottom: 1px solid #edf2f7;
  padding-bottom: 10px;
}

.settingsGrid .filterGroup:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.filterStrip {
  display: flex;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  overflow-x: auto;
  overflow-y: hidden;
}

.filterGroup {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: max-content;
}

.filterGroup > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.filterGroup input {
  width: 48px;
  height: 30px;
  padding: 5px 6px;
  font-size: 12px;
}

.filterGroup .segments {
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.filterGroup .segments button {
  flex: 0 0 auto;
  min-width: 42px;
  padding: 5px 7px;
  font-size: 12px;
}

.canvasWrap {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 300px;
  overflow: hidden;
  container-type: inline-size;
  container-name: canvas;
}

.mapActionStack,
.mapZoomStack {
  position: absolute;
  z-index: 6;
}

.mapSearchBox {
  position: relative;
  z-index: 9;
  width: min(440px, 100%);
  display: grid;
  gap: 8px;
  margin-left: auto;
}

.explorerSearchLabel {
  position: relative;
  display: block;
  margin: 0;
}

.explorerSearchLabel span {
  position: absolute;
  top: 50%;
  left: 12px;
  z-index: 1;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 900;
}

.mapSearchBox input {
  height: 42px;
  padding-left: 34px;
  border-color: #cbd5e1;
  border-radius: var(--radius);
  background: var(--field);
  box-shadow: none;
}

.mapSearchResults,
.mapDetails {
  border: 1px solid rgba(148, 163, 184, 0.42);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  backdrop-filter: blur(18px) saturate(1.18);
  animation: popIn 160ms var(--ease);
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.mapSearchResults {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(50vh, 460px);
  min-height: 120px;
  padding: 6px;
  overflow-y: auto;
  resize: vertical;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.mapSearchResults::-webkit-scrollbar {
  width: 10px;
}

.mapSearchResults::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cbd5e1;
  border: 2px solid rgba(255, 255, 255, 0.9);
}

.mapSearchResults::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.mapSearchResults::-webkit-resizer {
  background: transparent;
}

.searchResult {
  width: 100%;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  margin-bottom: 4px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.58);
  text-align: left;
  transition: background-color 100ms var(--ease);
  font-weight: 500;
}

.searchResult:last-child {
  margin-bottom: 0;
}

.searchResult:hover,
.searchResult.active {
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.22), rgba(255, 255, 255, 0.62));
}

.searchResult.active {
  box-shadow: inset 3px 0 0 var(--teal);
}

.searchKind {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.searchName {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.searchScore {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mapDetails {
  position: relative;
  max-height: min(280px, calc(100vh - 380px));
  overflow: auto;
  resize: vertical;
  padding-top: 4px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.mapDetailsClose {
  position: sticky;
  top: 6px;
  float: right;
  margin: 0 6px 0 8px;
  width: 24px;
  height: 24px;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  z-index: 2;
}

.mapDetailsClose:hover {
  background: #fef2f2;
  border-color: var(--rose);
  color: var(--rose);
}

.mapDetailsShow {
  justify-self: start;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.97);
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  animation: popIn 160ms var(--ease);
}

.mapDetailsShow::before {
  content: "ⓘ ";
  margin-right: 4px;
  font-weight: 900;
}

.mapDetailsShow:hover {
  background: #ecfeff;
  border-color: #67e8f9;
  color: #0e7490;
}

.mapDetails::-webkit-scrollbar {
  width: 10px;
}

.mapDetails::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cbd5e1;
  border: 2px solid rgba(255, 255, 255, 0.9);
}

.mapDetails details {
  border-bottom: 1px solid #edf2f7;
}

.mapDetails details:last-child {
  border-bottom: 0;
}

.mapDetails summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  color: #334155;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
  list-style: none;
}

.mapDetails summary::-webkit-details-marker {
  display: none;
}

.mapDetails summary::after {
  content: "+";
  color: var(--muted);
  font-weight: 900;
}

.mapDetails details[open] summary::after {
  content: "−";
}

.detailGrid {
  display: grid;
  gap: 6px;
  padding: 0 10px 10px;
}

.detailGrid .detailLine {
  margin: 0;
}

.mapActionStack {
  top: 14px;
  right: 14px;
  display: grid;
  gap: 8px;
}

.mapZoomStack {
  right: 14px;
  bottom: 14px;
  display: grid;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.mapIconButton {
  width: 40px;
  height: 40px;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid #e2e8f0;
  border-radius: 0;
  padding: 0;
  background: rgba(255, 255, 255, 0.96);
  color: #334155;
  font-size: 18px;
  font-weight: 900;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}

body[data-theme="dark"] .mapIconButton {
  border-color: #334967;
  background: rgba(18, 32, 51, 0.96);
  color: var(--ink);
}

.mapActionStack .mapIconButton {
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.mapIconButton:last-child {
  border-bottom: 0;
}

.mapIconButton:hover {
  background: #ecfeff;
  color: var(--teal);
}

.mapIconButton.active {
  background: var(--teal);
  color: #ffffff;
}

body.explorerFullscreen {
  overflow: hidden;
}

body.explorerFullscreen .explorerPanel {
  position: fixed;
  inset: 12px;
  z-index: 40;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

body.explorerFullscreen .explorerHeader {
  flex: 0 0 auto;
}

body.explorerFullscreen .canvasWrap {
  min-height: 0;
}

.mapResetButton {
  font-size: 11px;
}

#networkSvg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  background:
    linear-gradient(90deg, rgba(148, 163, 184, 0.18) 1px, transparent 1px),
    linear-gradient(0deg, rgba(148, 163, 184, 0.18) 1px, transparent 1px),
    #fbfdff;
  background-size: 36px 36px;
}

#networkSvg.panning {
  cursor: grabbing;
}

.edge {
  stroke-linecap: round;
  cursor: pointer;
  transition: opacity 120ms ease, stroke-width 120ms ease;
}

.edge.dim {
  opacity: 0.14;
}

.edge.selected {
  stroke: var(--rose);
  opacity: 1;
}

.edge.route {
  stroke: #f59e0b;
  stroke-dasharray: 10 6;
  opacity: 1;
  animation: routeDash 820ms linear infinite;
}

.edge.route.selected {
  stroke: #f97316;
}

@keyframes routeDash {
  to {
    stroke-dashoffset: -16;
  }
}

.node {
  stroke: #334155;
  stroke-width: 2;
  cursor: grab;
  transition: stroke 120ms var(--ease), stroke-width 120ms var(--ease);
}

.node:hover {
  stroke: var(--teal);
  stroke-width: 3;
}

.node.active {
  stroke: var(--amber);
  stroke-width: 3;
}

.node.route {
  stroke: #f59e0b;
  stroke-width: 3;
}

.node.routeEndpoint {
  stroke: var(--teal);
  stroke-width: 4;
}

#networkSvg.nodeDragging,
#networkSvg.nodeDragging .node {
  cursor: grabbing;
}

.nodePulse {
  fill: rgba(180, 83, 9, 0.15);
  stroke: rgba(180, 83, 9, 0.72);
  stroke-width: 2;
  pointer-events: none;
  animation: nodePulse 720ms ease-out forwards;
}

@keyframes nodePulse {
  from {
    opacity: 0.95;
  }

  to {
    opacity: 0;
  }
}

.nodeLabel {
  pointer-events: none;
  font-size: 12px;
  font-weight: 700;
  fill: #1f2937;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 4px;
}

.graphTooltip {
  position: fixed;
  z-index: 20;
  max-width: 340px;
  border: 1px solid #0f766e;
  border-radius: 8px;
  padding: 10px 11px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18);
  color: var(--ink);
  font-size: 12px;
  pointer-events: none;
}

.edgeLegend,
.sizeLegend {
  position: absolute;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
  color: var(--ink);
  font-size: 10px;
  pointer-events: none;
  backdrop-filter: blur(3px);
}

.edgeLegend {
  right: 70px;
  bottom: 14px;
  left: auto;
  width: 160px;
}

.sizeLegend {
  right: 240px;
  bottom: 14px;
  left: auto;
  width: 150px;
}

.legendTitle {
  font-weight: 800;
  color: #334155;
}

.edgeLegend svg,
.sizeLegend svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.edgeLegend svg {
  height: 28px;
}

.sizeLegend svg {
  height: 32px;
}

.legendNode {
  fill: rgba(15, 118, 110, 0.72);
  stroke: #334155;
  stroke-width: 2;
}

.legendLabels,
.legendMode {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.legendMode {
  justify-content: flex-end;
  margin-top: 3px;
  font-weight: 700;
}

.tipTitle {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 800;
}

.tipGrid {
  display: grid;
  gap: 5px;
}

.tipLine {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  white-space: nowrap;
}

.tipLine span,
.tipSubhead {
  color: var(--muted);
  font-weight: 700;
}

.tipSubhead {
  margin-top: 10px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.tipTable {
  width: 100%;
  border-collapse: collapse;
}

.tipTable th {
  position: static;
  border: 0;
  padding: 2px 0 4px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  text-align: left;
}

.tipTable th:not(:first-child) {
  padding-left: 10px;
  text-align: right;
}

.tipTable td {
  border: 0;
  padding: 3px 0;
}

.tipTable td:not(:first-child) {
  padding-left: 10px;
  text-align: right;
  font-weight: 700;
}

.resultsHeader {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tabs button {
  padding: 8px 14px;
  background: #f1f5f9;
  border-radius: 999px;
  border-color: transparent;
  font-weight: 600;
}

.tabs button:hover {
  background: #e2e8f0;
}

.tabs button.active {
  border-color: var(--teal);
  background: linear-gradient(180deg, #14b8a6 0%, #0f766e 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.28);
}

.resultsHeader .tabs {
  flex: 1 1 auto;
  min-width: 0;
}

.resultsFilter {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  width: clamp(160px, 28vw, 260px);
  margin: 0;
}

.resultsFilter .resultsFilterIcon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 16px;
  color: var(--muted);
  font-weight: 700;
}

.resultsFilter input {
  flex: 0 0 auto;
  width: 100%;
  height: 38px;
  padding: 0 32px 0 36px;
  border-radius: 999px;
  background: #f8fafc;
  font-size: 13px;
}

.resultsFilter input::-webkit-search-cancel-button {
  appearance: none;
}

.resultsFilter input:focus {
  background: #ffffff;
}

.tableScroll {
  flex: 1;
  overflow: auto;
}

.tabPanel {
  min-height: 0;
  display: none;
  flex: 1;
  overflow: hidden;
}

.tabPanel.active {
  display: flex;
}

.edgeTable,
.nodeTable {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
}

.edgeTable {
  min-width: 780px;
}

.nodeTable {
  min-width: 560px;
}

.edgeTable th,
.edgeTable td,
.nodeTable th,
.nodeTable td {
  border-bottom: 1px solid #e6edf5;
  padding: 8px 9px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: normal;
}

.edgeTable th,
.nodeTable th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  text-transform: uppercase;
}

.edgeTable .colEdge {
  width: 17%;
}

.edgeTable .colRaw,
.edgeTable .colScore {
  width: 13%;
}

.edgeTable .colPath {
  width: 12%;
}

.edgeTable .colReason {
  width: 32%;
}

.edgeTable td:nth-child(1),
.edgeTable td:nth-child(2),
.edgeTable td:nth-child(3),
.edgeTable td:nth-child(4),
.edgeTable td:nth-child(5) {
  white-space: nowrap;
}

.edgeTable tbody tr {
  cursor: pointer;
}

.edgeTable tbody tr:hover,
.edgeTable tbody tr.selected,
.nodeTable tbody tr:hover {
  background: #eaf7f5;
}

.mutedRow {
  color: #64748b;
  background: #fbfdff;
}

.rank {
  color: var(--muted);
}

.edgeTable .reason {
  min-width: 0;
  color: #334155;
  overflow-wrap: normal;
  white-space: normal;
}

.badge {
  display: inline-block;
  white-space: nowrap;
  border-radius: 999px;
  padding: 2px 7px;
  background: #e0f2fe;
  color: #075985;
  font-size: 11px;
  font-weight: 700;
}

.error {
  color: #fee2e2;
}

.agentPanel {
  background: #fbfdff;
}

.chatLog {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding: 12px;
}

.chatMessage {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px;
  background: #fff;
  color: #1f2937;
  font-size: 12px;
  line-height: 1.35;
}

.chatMessage.user {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.chatMessage.agent {
  border-color: #c7ece8;
  background: #ecfdf5;
}

.tripPlanner {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.86);
}

body[data-theme="dark"] .tripPlanner {
  background: rgba(11, 21, 34, 0.72);
}

.tripPlanner .sectionTitle {
  margin-bottom: 0;
}

.tripFields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tripFields label {
  margin-bottom: 0;
}

.tripPlanner button {
  justify-self: stretch;
  border-color: var(--teal);
  background: #ecfeff;
  color: var(--teal);
}

.chatComposer {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.chatComposer textarea {
  min-height: 76px;
  max-height: 120px;
  resize: vertical;
}

.chatComposer button {
  justify-self: end;
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.exportPanel {
  flex-direction: column;
  align-content: flex-start;
  gap: 10px;
  padding: 12px;
  overflow: auto;
}

.exportGroup {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.exportGroup .blockLabel {
  flex-basis: 100%;
  margin-bottom: 0;
}

.exportPanel .selectedPanel {
  flex: 1 1 100%;
  margin-top: 4px;
}

@container canvas (max-width: 920px) {
  .sizeLegend {
    display: none;
  }
  .edgeLegend {
    right: 70px;
    bottom: 14px;
  }
}

@container canvas (max-width: 720px) {
  .edgeLegend {
    display: none;
  }
}

@container canvas (max-width: 560px) {
  .mapSearchBox {
    width: calc(100% - 76px);
  }
  .mapSearchResults {
    max-height: 38vh;
  }
  .mapDetails {
    max-height: min(260px, calc(100vh - 320px));
  }
  .mapZoomStack {
    bottom: 10px;
    right: 10px;
  }
  .mapActionStack {
    top: 10px;
    right: 10px;
  }
  .mapIconButton {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }
}

@media (max-width: 1180px) {
  body {
    overflow-y: auto;
  }

  .workspace {
    height: auto;
    min-height: calc(100vh - 76px);
    grid-template-columns: minmax(220px, var(--sidebar-width)) 8px 1fr;
  }

  .controls {
    max-height: calc(100vh - 110px);
  }

  .workbench {
    grid-template-rows: minmax(420px, auto) 8px minmax(220px, var(--results-height));
  }

  .explorerGrid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(380px, auto) 0 minmax(220px, var(--agent-width));
  }

  .explorerPanel {
    grid-row: 1;
  }

  .agentPanel {
    grid-row: 3;
  }

  #agentResizeHandle {
    display: none;
  }

  .filterStrip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .topActions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .topActions button {
    flex: 0 0 auto;
  }
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
  }

  .topbar p {
    display: none;
  }

  #summary {
    font-size: 12px;
  }

  .topActions {
    position: absolute;
    top: 12px;
    right: 12px;
  }

  .workspace {
    height: auto;
    min-height: calc(100vh - 86px);
    grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
    padding: 8px;
    gap: 0;
  }

  #leftResizeHandle,
  #resultsResizeHandle {
    display: none;
  }

  .controls {
    position: sticky;
    top: 88px;
    z-index: 14;
    width: var(--sidebar-collapsed-width);
    max-height: calc(100vh - 104px);
    align-self: start;
    padding: 6px;
    overflow: hidden;
  }

  body:not(.sidebarCollapsed) .controls {
    position: fixed;
    top: 86px;
    left: 8px;
    bottom: 8px;
    z-index: 35;
    width: min(340px, calc(100vw - 16px));
    max-height: none;
    padding: 12px;
    overflow: auto;
  }

  .workbench {
    grid-column: 2;
    grid-template-rows: minmax(420px, auto) 0 minmax(260px, auto);
  }

  .explorerGrid {
    grid-row: 1;
  }

  .resultsPanel {
    grid-row: 3;
  }

  .explorerGrid {
    grid-template-rows: minmax(420px, auto) 0 minmax(260px, auto);
  }

  .agentPanel,
  .resultsPanel {
    min-height: 260px;
  }

  .canvasWrap {
    height: min(58vh, 460px);
    min-height: 360px;
  }

  .mapSearchBox {
    width: 100%;
    margin-left: 0;
  }

  .mapSearchResults {
    max-height: 50vh;
  }

  .edgeLegend,
  .sizeLegend {
    display: none;
  }

  .resultsHeader,
  .explorerHeader {
    align-items: stretch;
    flex-direction: column;
  }

  .explorerHeader > div:first-child {
    min-width: 0;
  }

  .resultsFilter {
    width: 100%;
  }

  .resultsHeader input,
  .tripFields {
    width: 100%;
  }

  .tripFields {
    grid-template-columns: 1fr;
  }

  .settingsPopover {
    top: 74px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: calc(100% - 86px);
  }

  .settingsGrid .filterGroup {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .filterGroup,
  .filterGroup .segments {
    min-width: 0;
    flex-wrap: wrap;
  }

  h1 {
    font-size: 20px;
    padding-right: 100px;
  }
}

@media (max-width: 480px) {
  .canvasWrap {
    height: 380px;
  }
}
