:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-tint: #f5f3ff;
  --surface-active: #ece8ff;
  --border: #e6e8f0;
  --border-strong: #d5d9e6;
  --text: #181c2e;
  --text-2: #4b526a;
  --text-3: #838aa2;
  --accent: #5b46f6;
  --accent-hover: #4b36e5;
  --accent-soft: #edeaff;
  --accent-mid: #b9adff;
  --accent-glow: rgba(91, 70, 246, 0.34);
  --ok-bg: #e7f8ee;
  --ok-text: #15803d;
  --ok-dot: #16a34a;
  --bad-bg: #feecec;
  --bad-text: #dc2626;
  --bad-dot: #ef4444;
  --shadow-sm: 0 1px 2px rgba(20, 24, 48, 0.04);
  --shadow-md: 0 4px 16px rgba(20, 24, 48, 0.06);
  --shadow-accent: 0 10px 26px rgba(91, 70, 246, 0.32);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0f111a;
  --surface: #171a26;
  --surface-2: #1d2130;
  --surface-tint: #201e36;
  --surface-active: #29244a;
  --border: #272c3f;
  --border-strong: #363d56;
  --text: #eef0f7;
  --text-2: #b0b6cc;
  --text-3: #767d96;
  --accent: #7360ff;
  --accent-hover: #8473ff;
  --accent-soft: rgba(115, 96, 255, 0.18);
  --accent-mid: #5a49d6;
  --accent-glow: rgba(115, 96, 255, 0.4);
  --ok-bg: rgba(22, 163, 74, 0.16);
  --ok-text: #4ade80;
  --ok-dot: #22c55e;
  --bad-bg: rgba(239, 68, 68, 0.16);
  --bad-text: #f87171;
  --bad-dot: #ef4444;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.38);
  --shadow-accent: 0 10px 28px rgba(115, 96, 255, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

/* ---------------- Top Header ---------------- */
.topbar {
  height: 52px;
  flex: 0 0 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand-logo {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.brand-logo svg {
  width: 22px;
  height: 22px;
}

.topbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border-strong);
}

.topbar-subtitle {
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
}

.topbar-center {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-2);
  white-space: nowrap;
}

.topbar-center strong {
  color: var(--text);
  font-weight: 600;
}

.crumb-slash {
  color: var(--text-3);
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  position: relative;
}

.demo-pill {
  height: 28px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.15s ease;
}

.demo-pill:hover,
.demo-pill[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 310px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 14px 16px;
  z-index: 40;
}

.popover-title {
  font-weight: 650;
  font-size: 13px;
  margin-bottom: 6px;
}

.popover p {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
}

.tag-reported {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.popover-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 11.5px;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  padding-top: 9px;
}

.popover-keys kbd {
  display: inline-block;
  padding: 1px 5px;
  margin-right: 3px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

/* ---------------- Main 3-Column Shell ---------------- */
.shell {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 368px;
  gap: 12px;
  padding: 12px 14px;
  overflow: hidden;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
}

/* ---------------- Left Sidebar ---------------- */
.sidebar-left {
  display: flex;
  flex-direction: column;
  padding: 14px 12px 12px;
  overflow: hidden;
}

.search-wrap {
  position: relative;
  margin-bottom: 10px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-3);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.pill-group {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.facet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 9px;
}

.facet-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.facet-field.facet-wide {
  grid-column: 1 / -1;
}

.facet-field span {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-3);
  padding-left: 2px;
}

.facet-select {
  width: 100%;
  height: 28px;
  padding: 0 7px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.facet-select:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.traj-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.group-bench-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
}

.group-bench-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.group-bench-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
}

.group-method-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 4px 0;
  font-size: 11px;
  color: var(--text-2);
}

.group-method-pill {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
  font-size: 10.5px;
}

.group-task-label {
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-pill {
  height: 27px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.filter-pill.active {
  background: var(--accent-soft);
  border-color: rgba(91, 70, 246, 0.35);
  color: var(--accent);
  font-weight: 650;
}

.traj-list {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-right: 2px;
}

.traj-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  padding: 8px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.16s ease;
}

.traj-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.traj-card.active {
  border-color: var(--accent);
  background: var(--surface-tint);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.traj-thumb {
  position: relative;
  width: 92px;
  height: 68px;
  border-radius: 8px;
  overflow: hidden;
  background: #1a1e2e;
  flex-shrink: 0;
}

.traj-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.traj-thumb-play {
  position: absolute;
  left: 5px;
  bottom: 5px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(15, 18, 30, 0.72);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.traj-thumb-play svg {
  width: 10px;
  height: 10px;
  margin-left: 1px;
}

.traj-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.traj-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.traj-sub {
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.traj-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 6px;
  margin-top: 6px;
  min-width: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.status-pill svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.status-pill.ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.status-pill.bad {
  background: var(--bad-bg);
  color: var(--bad-text);
}

.traj-dur {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 28px 12px;
  color: var(--text-3);
  font-size: 12.5px;
}

.sidebar-footer {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sample-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11.5px;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.text-btn:hover {
  background: var(--accent-soft);
}

.text-btn svg {
  width: 14px;
  height: 14px;
}

/* ---------------- Center Column ---------------- */
.center-col {
  display: grid;
  grid-template-rows: minmax(0, 1.18fr) minmax(245px, 0.92fr);
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

/* Viewer Card */
.viewer-card {
  display: flex;
  flex-direction: column;
  padding: 13px 16px 12px;
  overflow: hidden;
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.viewer-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.viewer-title-wrap h1 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  white-space: nowrap;
}

.v-sep {
  width: 1px;
  height: 14px;
  background: var(--border-strong);
  flex-shrink: 0;
}

.viewer-desc {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cam-mode-switch {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.mode-btn {
  height: 24px;
  padding: 0 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-btn.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 650;
  box-shadow: var(--shadow-sm);
}

/* Stage Viewport */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 160px;
  border-radius: 12px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #2b3042 0%, #161925 100%);
  border: 1px solid rgba(15, 20, 35, 0.12);
}

.stage-single {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
}

.stage-single img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.stage-triple {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: #121520;
}

.cam-tile {
  margin: 0;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #1b2030;
  cursor: zoom-in;
}

.cam-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cam-tile figcaption {
  position: absolute;
  left: 8px;
  bottom: 7px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(14, 17, 28, 0.72);
  color: #e8ecf8;
  font-size: 11px;
  font-weight: 500;
  backdrop-filter: blur(6px);
}

.stage-badge-left {
  position: absolute;
  top: 11px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(20, 24, 36, 0.72);
  color: #f3f5fc;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.stage-step-pill {
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #cbd5f5;
  font-weight: 500;
}

.stage-badge-right {
  position: absolute;
  top: 11px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 9px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 650;
  box-shadow: 0 4px 14px rgba(91, 70, 246, 0.45);
  pointer-events: none;
  transition: transform 0.2s ease, background 0.2s ease;
}

.badge-icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
}

.badge-icon svg {
  width: 14px;
  height: 14px;
}

/* Phase Segment Bar */
.phase-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.phase-seg {
  position: relative;
  flex: 1 1 0;
  height: 26px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phase-seg:hover:not(:disabled) {
  background: rgba(91, 70, 246, 0.08);
  color: var(--text);
}

.phase-seg.active {
  background: linear-gradient(135deg, #c6bbff 0%, #b5a5ff 100%);
  color: #2c1e8f;
  font-weight: 700;
}

[data-theme="dark"] .phase-seg.active {
  background: linear-gradient(135deg, #6b58f7 0%, #5542e0 100%);
  color: #ffffff;
}

.phase-seg.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.phase-seg:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

/* Controls Row */
.controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 11px;
  flex-shrink: 0;
}

.controls-left,
.controls-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.play-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.play-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.play-btn svg {
  width: 16px;
  height: 16px;
}

.ctrl-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ctrl-icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.ctrl-icon-btn svg {
  width: 15px;
  height: 15px;
}

.scrubber-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
}

.scrubber {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--pct, 0%), var(--border) var(--pct, 0%), var(--border) 100%);
  outline: none;
  cursor: pointer;
}

.scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--accent);
  box-shadow: 0 1px 4px rgba(20, 24, 48, 0.25);
  transition: transform 0.12s ease;
}

.scrubber::-webkit-slider-thumb:hover {
  transform: scale(1.16);
}

.scrubber::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--accent);
  box-shadow: 0 1px 4px rgba(20, 24, 48, 0.25);
}

.time-readout {
  font-size: 12px;
  color: var(--text-2);
  min-width: 112px;
  text-align: right;
}

.speed-select {
  height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.stage-subline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  flex-shrink: 0;
}

.current-phase-label {
  color: var(--accent);
  font-weight: 500;
}

.current-phase-label strong {
  font-weight: 700;
}

.event-counter {
  color: var(--text-3);
}

.event-counter strong {
  color: var(--text-2);
}

/* ---------------- Bottom Events + Full LLM/Policy Payload ---------------- */
.bottom-events-card {
  display: grid;
  grid-template-columns: minmax(235px, 0.76fr) minmax(0, 1.45fr);
  gap: 14px;
  padding: 12px 14px;
  overflow: hidden;
}

.events-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-right: 12px;
  border-right: 1px solid var(--border);
}

.payload-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.payload-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.payload-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.payload-head-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.payload-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.p-chip {
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}

.p-chip.reported {
  background: var(--accent-soft);
  border-color: rgba(91, 70, 246, 0.3);
  color: var(--accent);
  font-weight: 650;
}

.payload-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}

.p-block {
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 8px 10px;
}

.p-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.p-block-target {
  font-family: var(--font-mono);
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
  font-weight: 600;
}

.p-summary {
  margin: 0;
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.45;
}

.p-note {
  margin: 6px 0 0;
  padding: 7px 9px;
  border-radius: 7px;
  background: var(--surface-tint);
  border-left: 3px solid var(--accent);
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.5;
}

.p-exact {
  margin: 5px 0 0;
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 600;
}

.p-kv {
  margin: 6px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 11.5px;
}

.p-kv-item {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.p-kv-k {
  font-family: var(--font-mono);
  color: var(--text-3);
  font-size: 11px;
}

.p-kv-v {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 600;
  font-size: 11.5px;
}

.p-code {
  margin: 5px 0 0;
  padding: 7px 9px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.42;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}

/* ---------------- Framework Section (Right Sidebar) ---------------- */
.framework-section {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.framework-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.framework-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sync-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
}

.sync-label svg {
  width: 13px;
  height: 13px;
}

.time-pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
}

.framework-diagram {
  position: relative;
  width: 100%;
  aspect-ratio: 360 / 226;
  max-height: 215px;
  margin: 0 auto;
  flex-shrink: 0;
}

.fw-edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.fw-edge {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1.7;
  transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

.fw-edge-dashed {
  stroke-dasharray: 5 4;
}

.fw-edge.active {
  stroke: var(--accent);
  stroke-width: 2.4;
  filter: drop-shadow(0 0 4px var(--accent-glow));
}

.fw-nodes {
  position: absolute;
  inset: 0;
}

.fw-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  padding: 5px 4px;
  text-align: center;
}

.fw-node:hover:not(.disabled) {
  border-color: var(--accent);
  background: var(--surface);
  transform: translateY(-1px);
}

.fw-node svg {
  width: 18px;
  height: 18px;
  color: var(--text-2);
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.fw-node-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  line-height: 1.2;
}

.fw-node-title {
  font-size: 12px;
  font-weight: 700;
  color: inherit;
  white-space: nowrap;
}

.fw-node-sub {
  font-size: 9.5px;
  font-weight: 500;
  color: var(--text-3);
  margin-top: 1px;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.fw-node.active {
  background: linear-gradient(135deg, #6450ff 0%, #523cf0 100%);
  border-color: #523cf0;
  color: #ffffff;
  box-shadow: var(--shadow-accent);
  transform: translateY(-2px);
}

.fw-node.active svg {
  color: #ffffff;
}

.fw-node.active .fw-node-sub {
  color: rgba(255, 255, 255, 0.82);
}

.fw-node.prev-stage {
  background: var(--accent-soft);
  border-color: rgba(91, 70, 246, 0.48);
  color: var(--accent);
  box-shadow: 0 2px 10px rgba(91, 70, 246, 0.12);
}

.fw-node.prev-stage svg {
  color: var(--accent);
}

.fw-node.prev-stage .fw-node-sub {
  color: var(--accent);
  opacity: 0.78;
}

.fw-node.disabled {
  border-style: dashed;
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text-3);
  opacity: 0.72;
}

.fw-node.disabled svg,
.fw-node.disabled .fw-node-sub {
  color: var(--text-3);
}

.framework-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-2);
  flex-shrink: 0;
}

.fw-role-note-box {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.fw-role-note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

.fw-note-role {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
}

.fw-note-label {
  font-size: 10.5px;
  color: var(--text-3);
}

.fw-role-note {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-2);
  line-height: 1.42;
}

/* ---------------- Right Sidebar Dashboard ---------------- */
.sidebar-right {
  display: flex;
  flex-direction: column;
  padding: 12px 13px 12px;
  overflow-y: auto;
}

.info-list.compact {
  gap: 6px;
}

.section-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0;
  flex-shrink: 0;
}

.dashboard-section {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dashboard-section .panel-header {
  margin-bottom: 2px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.kpi-card {
  padding: 7px 9px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-label {
  font-size: 10.5px;
  color: var(--text-3);
  font-weight: 500;
}

.kpi-val {
  font-size: 14px;
  font-weight: 750;
  color: var(--text);
  line-height: 1.2;
}

.kpi-val.warn {
  color: var(--bad-text);
}

.kpi-val.ok {
  color: var(--ok-text);
}

.kpi-sub {
  font-size: 10.5px;
  color: var(--text-3);
}

.kpi-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-top: 2px;
}

.kpi-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.2s ease;
}

.token-card,
.chart-card,
.dist-card {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.token-total-wrap {
  font-size: 11.5px;
  color: var(--text);
}

.token-total-wrap strong {
  font-weight: 750;
  color: var(--accent);
}

.tok-muted {
  color: var(--text-3);
  font-size: 10.5px;
  margin-left: 2px;
}

.token-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  display: flex;
  gap: 1px;
  margin-bottom: 8px;
}

.token-bar i {
  display: block;
  height: 100%;
  transition: width 0.22s ease;
}

.tok-seg-in {
  background: #5b46f6;
}

.tok-seg-cache {
  background: #0ea5e9;
}

.tok-seg-out {
  background: #10b981;
}

.tok-seg-reason {
  background: #f59e0b;
}

.token-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.tok-cell {
  padding: 5px 5px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tok-lbl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
}

.tok-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tok-dot.in {
  background: #5b46f6;
}

.tok-dot.cache {
  background: #0ea5e9;
}

.tok-dot.out {
  background: #10b981;
}

.tok-dot.reason {
  background: #f59e0b;
}

.tok-cell strong {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px dashed var(--border);
  font-size: 10.5px;
  color: var(--text-3);
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.chart-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-2);
}

.chart-meta {
  font-size: 10.5px;
  color: var(--text-3);
}

.dash-chart {
  width: 100%;
  height: 62px;
}

.dash-chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.role-dist {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dist-row {
  display: grid;
  grid-template-columns: 70px 1fr 24px;
  align-items: center;
  gap: 7px;
  font-size: 11px;
}

.dist-name {
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dist-track {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.dist-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.2s ease;
}

.dist-fill.muted {
  background: var(--text-3);
  opacity: 0.45;
}

.dist-count {
  text-align: right;
  font-family: var(--font-mono);
  color: var(--text-2);
  font-weight: 600;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot-active,
.dot-prev,
.dot-idle,
.dot-disabled {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot-active {
  background: var(--accent);
}

.dot-prev {
  background: var(--accent-soft);
  border: 1.5px solid rgba(91, 70, 246, 0.55);
}

.dot-idle {
  border: 1.5px solid var(--text-3);
  background: var(--surface);
}

.dot-disabled {
  border: 1.5px dashed var(--text-3);
  background: transparent;
}

/* ---------------- Right Sidebar ---------------- */
.sidebar-right {
  display: flex;
  flex-direction: column;
  padding: 12px 13px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.info-section {
  flex-shrink: 0;
}

.info-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.info-row dt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-2);
  font-size: 12.5px;
  margin: 0;
}

.info-row dt svg {
  width: 15px;
  height: 15px;
  color: var(--text-3);
}

.info-row dd {
  margin: 0;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  text-align: right;
}

.section-divider {
  height: 1px;
  background: var(--border);
  margin: 13px 0;
  flex-shrink: 0;
}

/* Stage Events Timeline */
.events-section {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.events-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.events-head h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
}

.mini-pills {
  display: inline-flex;
  gap: 4px;
}

.mini-pill {
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

.mini-pill.active {
  background: var(--accent-soft);
  border-color: rgba(91, 70, 246, 0.35);
  color: var(--accent);
  font-weight: 650;
}

.event-timeline {
  list-style: none;
  margin: 0;
  padding: 2px 2px 4px 0;
  flex: 1 1 auto;
  overflow-y: auto;
  position: relative;
}

.ev-item {
  position: relative;
  display: grid;
  grid-template-columns: 20px 52px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.14s ease;
}

.ev-item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 18.5px;
  top: 22px;
  bottom: -10px;
  width: 1.5px;
  background: var(--border);
  pointer-events: none;
}

.ev-item:hover {
  background: var(--surface-2);
}

.ev-item.active {
  background: var(--surface-active);
}

.ev-dot {
  position: relative;
  z-index: 1;
  width: 10px;
  height: 10px;
  margin: 0 auto;
  border-radius: 50%;
  border: 1.8px solid var(--border-strong);
  background: var(--surface);
  transition: all 0.15s ease;
}

.ev-item.active .ev-dot {
  width: 12px;
  height: 12px;
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ev-time {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-2);
}

.ev-item.active .ev-time {
  color: var(--accent);
  font-weight: 700;
}

.ev-name {
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ev-item.active .ev-name {
  color: var(--accent);
  font-weight: 700;
}

/* Current Event Card */
.current-event-card {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-tint);
  border: 1px solid rgba(91, 70, 246, 0.16);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.ce-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ce-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.ce-role-tag {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
}

.ce-title {
  margin: 0 0 6px;
  font-size: 15.5px;
  font-weight: 750;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ce-time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.ce-time svg {
  width: 13px;
  height: 13px;
  color: var(--text-3);
}

.ce-desc {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1 1 auto;
}

.ce-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

.detail-link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  transition: background 0.14s;
}

.detail-link-btn:hover {
  background: var(--accent-soft);
}

/* ---------------- Bottom Status Bar ---------------- */
.statusbar {
  height: 32px;
  flex: 0 0 32px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
}

.status-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok-dot);
}

.status-sep {
  color: var(--border-strong);
}

.status-sync {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ok-text);
  font-weight: 500;
}

.status-sync svg {
  width: 14px;
  height: 14px;
}

.status-right {
  color: var(--text-3);
  font-size: 11.5px;
}

/* ---------------- Dialogs / Drawer ---------------- */
dialog {
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(10, 14, 30, 0.25);
}

dialog::backdrop {
  background: rgba(15, 18, 30, 0.45);
  backdrop-filter: blur(3px);
}

.drawer {
  margin: 0 0 0 auto;
  height: 100vh;
  max-height: 100vh;
  width: min(520px, 92vw);
  border-radius: 16px 0 0 16px;
  display: flex;
  flex-direction: column;
}

.drawer:not([open]) {
  display: none;
}

.drawer-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}

.drawer-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.drawer-actions {
  display: inline-flex;
  gap: 6px;
}

.drawer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 12px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
}

.meta-chip {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-block {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 14px;
  background: var(--surface-2);
}

.detail-block h3 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.detail-kv {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
  font-size: 12.5px;
}

.detail-kv dt {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.detail-kv dd {
  margin: 0;
  color: var(--text);
  word-break: break-word;
}

.code-block {
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow-x: auto;
  white-space: pre-wrap;
  line-height: 1.45;
}

.modal-box {
  width: min(920px, 92vw);
  border-radius: 16px;
  overflow: hidden;
}

.modal-box:not([open]) {
  display: none;
}

.modal-note {
  margin: 0;
  padding: 10px 18px 0;
  color: var(--text-2);
  font-size: 12.5px;
}

.modal-media-wrap {
  padding: 14px 18px 18px;
  background: #0d1018;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-media-wrap img,
.modal-media-wrap video {
  max-width: 100%;
  max-height: 74vh;
  border-radius: 10px;
  display: block;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}

/* Responsive layout for embedded iframe & smaller viewports */
@media (max-width: 1280px) {
  .shell {
    grid-template-columns: 236px minmax(0, 1fr) 308px;
    gap: 10px;
    padding: 10px 12px;
  }

  .topbar-sep,
  .topbar-subtitle {
    display: none;
  }

  .traj-card {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 8px;
    padding: 7px;
  }

  .traj-thumb {
    width: 64px;
    height: 54px;
  }

  .traj-meta-row {
    gap: 4px;
  }

  .traj-meta-row .status-pill {
    padding: 2px 6px;
    font-size: 11px;
  }

  .traj-dur {
    font-size: 11px;
  }
}

@media (max-width: 1080px) {

  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .shell {
    flex: none;
    grid-template-columns: minmax(0, 1fr) 316px;
    grid-template-rows: auto auto;
    align-items: start;
    overflow: visible;
    gap: 10px;
    padding: 10px 12px 14px;
  }

  .sidebar-left {
    grid-column: 1 / -1;
    max-height: none;
    overflow: visible;
    padding: 10px 12px;
  }

  .sidebar-left .panel-header {
    margin-bottom: 8px;
  }

  .facet-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 8px;
  }

  .facet-field.facet-wide {
    grid-column: auto;
  }

  .traj-list {
    flex-direction: row;
    flex-wrap: wrap;
    overflow: visible;
  }

  .traj-group {
    flex: 1 1 280px;
  }

  .center-col {
    grid-template-rows: auto auto;
    overflow: visible;
    gap: 10px;
  }

  .viewer-card {
    overflow: visible;
  }

  .stage {
    flex: none;
    height: 290px;
  }

  .bottom-events-card {
    height: 340px;
    grid-template-columns: minmax(190px, 0.72fr) minmax(0, 1.4fr);
  }

  .sidebar-right {
    max-height: none;
    overflow: visible;
  }

  .statusbar {
    flex-shrink: 0;
  }
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: auto 1fr;
  }

  .topbar-center {
    display: none;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .facet-grid {
    grid-template-columns: 1fr;
  }

  .stage {
    height: 220px;
  }

  .bottom-events-card {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .events-pane {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 10px;
    max-height: 220px;
  }

  .payload-pane {
    max-height: 320px;
  }
}
