@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --bg: oklch(0.97 0.015 80);
  --bg-strong: oklch(0.93 0.03 78);
  --panel: oklch(0.995 0.004 75 / 0.94);
  --panel-border: oklch(0.82 0.03 70 / 0.65);
  --text: oklch(0.24 0.03 52);
  --muted: oklch(0.48 0.03 65);
  --accent: oklch(0.58 0.14 40);
  --accent-deep: oklch(0.41 0.11 32);
  --olive: oklch(0.55 0.08 115);
  --danger: oklch(0.56 0.18 28);
  --warning: oklch(0.72 0.15 74);
  --shadow: 0 24px 80px oklch(0.52 0.04 60 / 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: 'Manrope', sans-serif;
  background:
    radial-gradient(circle at top left, oklch(0.93 0.06 72), transparent 28%),
    radial-gradient(circle at top right, oklch(0.9 0.05 30 / 0.5), transparent 22%),
    linear-gradient(180deg, var(--bg) 0%, oklch(0.95 0.015 82) 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

#root {
  min-height: 100vh;
}

.app-shell {
  padding: clamp(1rem, 2vw, 2rem);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(18rem, 0.7fr);
  gap: 1.5rem;
  align-items: end;
  padding: clamp(1.5rem, 2vw, 2rem);
  border: 1px solid var(--panel-border);
  border-radius: 2rem;
  background:
    linear-gradient(135deg, oklch(0.99 0.005 75 / 0.92), oklch(0.94 0.02 84 / 0.92)),
    var(--panel);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero h1,
.panel h2,
.event-detail h2 {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(2.4rem, 4vw, 4.8rem);
  line-height: 0.95;
}

.hero-copy {
  max-width: 56ch;
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}

.hero-metrics > div,
.session-stats > div,
.detail-grid > div {
  padding: 1rem;
  border-radius: 1.2rem;
  background: color-mix(in oklch, var(--panel), var(--accent) 4%);
  border: 1px solid color-mix(in oklch, var(--panel-border), var(--accent) 22%);
  min-width: 0;
  overflow: hidden;
}

.metric-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.hero-metrics strong,
.session-stats strong,
.detail-grid strong {
  font-size: 1.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-banner {
  margin-top: 1rem;
  padding: 1rem 1.2rem;
  border-radius: 1rem;
  background: color-mix(in oklch, var(--danger), white 85%);
  border: 1px solid color-mix(in oklch, var(--danger), white 50%);
  color: var(--danger);
}

/* Failure Modal Styles */
.failure-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: oklch(0.24 0.03 52 / 0.65);
  backdrop-filter: blur(4px);
}

.failure-modal {
  width: min(42rem, 90vw);
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 1.6rem;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.failure-modal-header {
  padding: 1.4rem 1.6rem;
  border-bottom: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--danger) 6%);
}

.failure-modal-header h2 {
  margin: 0.35rem 0;
  font-family: 'Fraunces', serif;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.failure-mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--danger), white 82%);
  color: var(--danger);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.failure-content {
  padding: 1.4rem 1.6rem;
}

.failure-section {
  margin-bottom: 1.2rem;
}

.failure-section:last-child {
  margin-bottom: 0;
}

.failure-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.failure-symptom {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

.failure-cause {
  margin: 0 0 0.75rem;
  color: var(--text);
  line-height: 1.5;
}

.failure-confidence {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

.failure-confidence-bar-container {
  height: 0.5rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--bg-strong), var(--muted) 20%);
  overflow: hidden;
}

.failure-confidence-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--danger);
  transition: width 200ms ease;
}

.failure-confidence-value {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--danger);
}

.failure-narrative p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.failure-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.2rem 1.6rem;
  border-top: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 25%);
}

.failure-action-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.2rem;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-weight: 600;
  min-height: 44px;
}

.failure-action-primary:hover {
  background: color-mix(in oklch, var(--danger), white 88%);
  color: var(--danger);
}

.failure-action-icon {
  font-size: 1.1rem;
}

.failure-action-secondary {
  padding: 0.85rem 1.2rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--panel), var(--warning) 18%);
  border: 1px solid color-mix(in oklch, var(--warning), white 45%);
  color: var(--text);
  min-height: 44px;
}

.failure-action-secondary:hover {
  background: color-mix(in oklch, var(--panel), var(--warning) 28%);
}

.failure-action-close {
  margin-left: auto;
  padding: 0.85rem 1.2rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 38%);
  color: var(--muted);
  min-height: 44px;
}

.failure-action-close:hover {
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 55%);
  color: var(--text);
}

/* Why Button on Session Cards */
.session-card {
  position: relative;
  display: grid;
  gap: 0.25rem;
}

.session-card-main {
  display: grid;
  justify-items: start;
  gap: 0.25rem;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.why-button {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease;
  z-index: 1;
}

.why-button:hover {
  transform: translateY(-1px);
  background: color-mix(in oklch, var(--danger), white 88%);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(15rem, 17rem) minmax(0, 1fr) minmax(20rem, 25rem);
  gap: 1rem;
  margin-top: 1rem;
  align-items: start;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: 1.6rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.session-rail,
.detail-rail,
.main-stage {
  display: grid;
  gap: 1rem;
  min-width: 0;
  overflow: hidden;
}

.session-rail,
.control-bar,
.analysis-ribbon,
.event-detail,
.alerts-panel,
.search-panel {
  padding: 1.2rem;
}

.rail-head h2,
.control-bar h2,
.analysis-ribbon h2,
.alerts-panel h2,
.search-panel h2 {
  font-size: 1.45rem;
}

.session-list,
.alert-list,
.cluster-list {
  display: grid;
  gap: 0.7rem;
}

.session-card,
.cluster-pill,
.alert-row,
.search-result,
.mode-switches button,
.tree-controls button,
.replay-controls button {
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.session-card {
  display: grid;
  justify-items: start;
  gap: 0.25rem;
  width: 100%;
  padding: 1rem;
  border-radius: 1.1rem;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 38%);
  border: 1px solid transparent;
  text-align: left;
  min-width: 0;
  overflow: hidden;
}

.session-card:hover,
.cluster-pill:hover,
.alert-row:hover,
.search-result:hover,
.mode-switches button:hover,
.checkpoint-card:hover,
.checkpoint-actions button:hover {
  transform: translateY(-1px);
}

.session-card.active,
.mode-switches button.active {
  border-color: color-mix(in oklch, var(--accent), white 50%);
  background: color-mix(in oklch, var(--panel), var(--accent) 14%);
}

.session-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.session-framework,
.session-status {
  font-size: 0.85rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-stats,
.detail-grid,
.inspectors-grid {
  display: grid;
  gap: 0.8rem;
}

.session-stats,
.detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.control-bar,
.analysis-ribbon {
  display: grid;
  gap: 1rem;
}

.mode-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.mode-switches button {
  padding: 0.9rem 1.25rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 35%);
  min-height: 44px;
}

.session-sort-switches {
  margin-bottom: 0.2rem;
}

.retention-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  color: white;
  background: var(--muted);
}

.retention-pill.full {
  background: var(--danger);
}

.retention-pill.summarized {
  background: var(--warning);
  color: var(--text);
}

.retention-pill.downsampled {
  background: var(--olive);
}

.breakpoint-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.breakpoint-grid label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.breakpoint-grid input {
  padding: 0.75rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), white 55%);
  color: var(--text);
}

.cluster-pill,
.alert-row {
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--olive) 10%);
  text-align: left;
}

.search-head {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: start;
}

.search-submit {
  padding: 0.85rem 1.15rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--accent), white 22%);
  color: white;
  min-height: 44px;
}

.search-submit:disabled {
  cursor: progress;
  opacity: 0.72;
}

.search-controls {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.search-controls label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.search-controls input,
.search-controls select {
  padding: 0.8rem 0.95rem;
  border-radius: 0.95rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), white 55%);
  color: var(--text);
}

.search-scope-switches {
  margin-top: 1rem;
}

.search-status,
.search-empty {
  margin: 0.9rem 0 0;
  color: var(--muted);
}

.search-status.error {
  color: var(--danger);
}

.search-results {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.9rem;
}

.search-result {
  display: grid;
  gap: 0.35rem;
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 34%);
  text-align: left;
}

.search-result p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.search-result-topline {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.75rem;
}

.checkpoint-card,
.checkpoint-actions button {
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.trace-layout,
.replay-layout {
  display: grid;
  gap: 1rem;
}

.trace-layout {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.timeline-panel,
.tree-panel,
.replay-panel,
.inspectors {
  overflow: hidden;
}

.trace-timeline,
.decision-tree,
.tool-inspector,
.llm-viewer,
.session-replay,
.conversation-panel {
  height: 100%;
  padding: 1.1rem;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.timeline-header,
.llm-header,
.tool-header,
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}

.conversation-metrics,
.speaker-strip,
.policy-inline,
.compare-header,
.live-badge {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.conversation-metrics,
.conversation-time,
.policy-inline,
.speaker-pill.muted,
.compare-loading {
  color: var(--muted);
  font-size: 0.82rem;
}

.speaker-strip {
  margin-bottom: 1rem;
}

.speaker-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 38%);
  border: 1px solid var(--panel-border);
  font-size: 0.78rem;
}

.conversation-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.conversation-row {
  display: grid;
  gap: 0.45rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 34%);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.conversation-row:hover {
  transform: translateY(-1px);
}

.conversation-row.active {
  border-color: color-mix(in oklch, var(--accent), white 48%);
  background: color-mix(in oklch, var(--panel), var(--accent) 10%);
}

.conversation-row-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.conversation-row p,
.conversation-row pre {
  margin: 0;
  color: var(--muted);
}

.conversation-row pre {
  padding: 0.85rem;
  border-radius: 0.9rem;
  background: color-mix(in oklch, var(--panel), white 24%);
}

.conversation-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  color: white;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--accent-deep);
}

.conversation-chip.prompt_policy {
  background: var(--accent);
}

.conversation-chip.agent_turn {
  background: #0369a1;
}

.compare-select {
  min-width: min(15rem, 100%);
  max-width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), white 50%);
  color: var(--text);
}

.compare-header,
.compare-metric-grid,
.compare-token-grid {
  display: grid;
  gap: 0.85rem;
}

.compare-header,
.compare-token-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compare-session-card,
.compare-metric {
  display: grid;
  gap: 0.25rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 34%);
}

.compare-session-card.primary {
  background: color-mix(in oklch, var(--panel), var(--accent) 10%);
}

.compare-session-card.secondary {
  background: color-mix(in oklch, var(--panel), var(--olive) 10%);
}

.compare-session-card small,
.compare-metric small {
  color: var(--muted);
}

.compare-metric-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1rem;
}

.live-badge {
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 35%);
}

.live-badge.connected {
  background: color-mix(in oklch, var(--panel), var(--olive) 18%);
}

.live-badge.offline {
  background: color-mix(in oklch, var(--panel), var(--danger) 14%);
}

.live-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: var(--olive);
}

.live-badge.offline .live-dot {
  background: var(--danger);
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.live-card {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 34%);
  text-align: left;
  color: var(--text);
}

.live-card.static {
  cursor: default;
}

.live-card:disabled {
  opacity: 0.7;
}

.live-rolling {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), white 28%);
}

.live-rolling h3,
.compare-token-grid h3 {
  margin: 0 0 0.5rem;
}

.live-rolling p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.live-alerts {
  margin-top: 1rem;
}

.live-alerts h3 {
  margin: 0 0 0.75rem;
}

.live-alert-list {
  display: grid;
  gap: 0.75rem;
}

.live-alert-row {
  display: grid;
  gap: 0.3rem;
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 35%);
  text-align: left;
  color: var(--text);
}

.live-alert-row.medium {
  border-color: color-mix(in oklch, var(--warning), white 45%);
}

.live-alert-row.high {
  border-color: color-mix(in oklch, var(--danger), white 45%);
  background: color-mix(in oklch, var(--panel), var(--danger) 8%);
}

.live-alert-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.live-alert-head small,
.live-alert-empty {
  color: var(--muted);
}

.timeline-events {
  display: grid;
  gap: 0.45rem;
  max-height: 28rem;
  overflow: auto;
  min-width: 0;
}

.timeline-event {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.8rem;
  padding: 0.8rem 0.9rem;
  border-radius: 1rem;
}

.timeline-event:hover {
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 40%);
}

.timeline-event.selected {
  background: color-mix(in oklch, var(--panel), var(--accent) 12%);
}

/* Highlight markers */
.timeline-event.highlight {
  border-left: 3px solid #f59e0b;
}

.highlight-marker {
  position: absolute;
  right: 4px;
  top: 4px;
  color: #f59e0b;
  font-weight: bold;
  font-size: 1rem;
}

/* Highlight info card */
.highlight-info-card {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.highlight-info-card h4 {
  margin: 0 0 4px 0;
  font-size: 12px;
  color: #92400e;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.highlight-info-card p {
  margin: 0;
  font-size: 13px;
  color: #78350f;
}

/* Highlight navigation */
.highlight-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: color-mix(in oklch, var(--panel), var(--warning) 12%);
  border-radius: 8px;
}

.highlight-nav button {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--panel), var(--warning) 25%);
  border: 1px solid color-mix(in oklch, var(--warning), white 50%);
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease;
}

.highlight-nav button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: color-mix(in oklch, var(--panel), var(--warning) 35%);
}

.highlight-nav button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.highlight-position {
  font-size: 12px;
  color: #666;
  flex: 1;
  text-align: center;
}

.event-marker {
  width: 0.8rem;
  height: 0.8rem;
  margin-top: 0.35rem;
  border-radius: 999px;
  background: var(--accent);
}

.timeline-event.error .event-marker,
.event-chip.error,
.event-chip.policy_violation,
.event-chip.refusal {
  background: var(--danger);
}

.timeline-event.tool_call .event-marker,
.timeline-event.tool_result .event-marker {
  background: var(--olive);
}

.timeline-event.decision .event-marker,
.timeline-event.safety_check .event-marker,
.event-chip.decision,
.event-chip.safety_check {
  background: var(--warning);
}

.timeline-event.llm_request .event-marker,
.timeline-event.llm_response .event-marker,
.event-chip.prompt_policy {
  background: var(--accent);
}

.event-info {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
  overflow: hidden;
}

.event-type {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.event-summary {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-time,
.event-count,
.model-name {
  color: var(--muted);
  font-size: 0.84rem;
}

.tree-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tree-controls button {
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 42%);
  min-height: 44px;
}

.tree-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 0.7rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
}

.tree-tooltip {
  position: fixed;
  z-index: 20;
  padding: 0.75rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), white 18%);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.replay-controls {
  display: grid;
  grid-template-columns: repeat(5, auto) minmax(0, 1fr) auto auto;
  gap: 0.6rem;
  align-items: center;
}

.replay-controls button,
.speed-select {
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 42%);
  min-height: 44px;
}

.timeline-container {
  position: relative;
  min-width: 0;
}

.timeline-slider {
  width: 100%;
}

.event-counter,
.replay-summary,
.usage {
  color: var(--muted);
  font-size: 0.85rem;
}

.timeline-markers {
  position: absolute;
  inset: 0.2rem 0 0 0;
  pointer-events: none;
}

.timeline-marker {
  position: absolute;
  width: 0.55rem;
  height: 0.55rem;
  margin-left: -0.275rem;
  border-radius: 999px;
  background: var(--accent);
}

.timeline-marker.high-importance {
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent), white 75%);
}

.timeline-marker.breakpoint {
  background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--danger), white 78%);
}

.replay-summary,
.analysis-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1rem;
}

.checkpoint-list,
.checkpoint-compare-grid,
.checkpoint-actions {
  display: grid;
  gap: 0.75rem;
}

.checkpoint-list {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 1rem;
}

.checkpoint-card {
  display: grid;
  gap: 0.25rem;
  padding: 0.9rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 34%);
  text-align: left;
}

.checkpoint-card.active {
  border-color: color-mix(in oklch, var(--accent), white 48%);
  background: color-mix(in oklch, var(--panel), var(--accent) 12%);
}

.checkpoint-card small {
  color: var(--muted);
}

.checkpoint-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.checkpoint-actions button {
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 38%);
  color: var(--text);
}

.checkpoint-compare-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.detail-actions,
.reference-list,
.checkpoint-grid {
  display: grid;
  gap: 0.75rem;
}

.detail-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 1rem 0;
}

.detail-actions button,
.reference-chip {
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 38%);
  color: var(--text);
  text-align: left;
}

.reference-chip {
  display: grid;
  gap: 0.2rem;
  cursor: pointer;
}

.reference-chip span {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.reference-chip strong {
  font-size: 0.95rem;
}

.reference-chip.missing {
  cursor: default;
  color: var(--muted);
}

.checkpoint-preview {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 1.2rem;
  background: color-mix(in oklch, var(--panel), var(--olive) 7%);
  border: 1px solid color-mix(in oklch, var(--panel-border), var(--olive) 16%);
}

.checkpoint-copy h3,
.checkpoint-grid h4 {
  margin: 0;
}

.checkpoint-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 0.85rem;
}

.checkpoint-grid pre {
  margin: 0.5rem 0 0;
  padding: 0.85rem;
  border-radius: 1rem;
  background: color-mix(in oklch, var(--panel), white 28%);
}

.inspectors-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.messages,
.detail-sections {
  display: grid;
  gap: 0.85rem;
}

.diagnosis-overview-grid,
.candidate-list {
  display: grid;
  gap: 0.75rem;
}

.diagnosis-overview-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1rem;
}

.diagnosis-overview-card,
.candidate-card,
.diagnosis-card {
  border: 1px solid var(--panel-border);
  border-radius: 1.1rem;
}

.diagnosis-overview-card,
.candidate-card {
  display: grid;
  gap: 0.45rem;
  padding: 1rem;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 36%);
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.diagnosis-overview-card:hover,
.candidate-card:hover {
  transform: translateY(-1px);
}

.diagnosis-overview-card small,
.candidate-card p {
  color: var(--muted);
}

.diagnosis-card {
  padding: 1rem;
  background: color-mix(in oklch, var(--panel), var(--accent) 6%);
}

.diagnosis-head,
.candidate-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.diagnosis-head span,
.candidate-head span {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.diagnosis-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--danger), white 82%);
  color: var(--danger);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
 }

.message,
.tool-call,
.code-block,
.detail-sections pre,
.detail-sections p {
  margin: 0;
}

.message,
.tool-call,
.detail-sections pre {
  padding: 0.9rem;
  border-radius: 1rem;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 42%);
}

.content,
pre {
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.tool-inspector .tool-section h4,
.llm-section h4,
.detail-sections h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.event-detail h2 {
  font-size: 2rem;
  line-height: 1;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.event-chip {
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  color: white;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--accent-deep);
}

.detail-sections {
  margin-top: 1rem;
}

.detail-sections p,
.detail-sections pre {
  color: var(--muted);
  line-height: 1.6;
}

.empty-panel {
  color: var(--muted);
}

.alerts-panel p:last-child {
  color: var(--muted);
}

@media (max-width: 1200px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .trace-layout,
  .inspectors-grid,
  .conversation-list,
  .compare-header,
  .compare-token-grid,
  .live-grid,
  .diagnosis-overview-grid {
    grid-template-columns: 1fr;
  }

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

/* Intermediate breakpoint for checkpoint-list: 3-column layout */
@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: minmax(14rem, 1fr) minmax(0, 1.5fr);
    gap: 0.875rem;
  }

  /* Stack detail rail below main content on tablets */
  .detail-rail {
    grid-column: 1 / -1;
  }

  .trace-layout {
    grid-template-columns: 1fr;
  }

  .checkpoint-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Intermediate breakpoint for tablets: 2-column grid layouts */
@media (max-width: 1000px) {
  .hero-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compare-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .live-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .checkpoint-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  /* Ensure workspace is single column on mobile */
  .workspace {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Ensure all rails stack vertically */
  .session-rail,
  .detail-rail,
  .main-stage {
    width: 100%;
    max-width: 100%;
  }

  .hero-metrics,
  .breakpoint-grid,
  .session-stats,
  .detail-grid,
  .detail-actions,
  .checkpoint-grid,
  .checkpoint-actions,
  .checkpoint-compare-grid,
  .checkpoint-list,
  .compare-metric-grid,
  .live-grid {
    grid-template-columns: 1fr;
  }

  /* Flex-based replay controls for small tablets */
  .replay-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }

  .replay-controls button {
    flex: 0 0 auto;
  }

  .timeline-container {
    flex: 1 1 100%;
    order: -1;
    margin-bottom: 0.25rem;
  }

  .event-counter,
  .speed-select {
    flex: 1 1 auto;
    min-width: 6rem;
  }
}

/* Mobile touch targets: minimum 44x44px for accessibility */
@media (max-width: 480px) {
  button,
  .session-card,
  .conversation-row,
  .live-card,
  .checkpoint-card,
  .search-result,
  .cluster-pill,
  .alert-row {
    min-height: 44px;
  }
}

/* Intermediate breakpoint for small tablets (600px) - 2-column grids */
@media (max-width: 600px) {
  .hero-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .session-stats,
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .compare-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .live-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .checkpoint-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .diagnosis-overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel {
    border-radius: 1.2rem;
  }

  .session-rail,
  .detail-rail,
  .main-stage,
  .control-bar,
  .analysis-ribbon,
  .event-detail,
  .alerts-panel,
  .search-panel {
    padding: 1rem;
  }

  .hero {
    padding: 1rem;
    border-radius: 1.2rem;
  }

  .hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
  }
}

/* Mobile breakpoint for phones (480px) - single column */
@media (max-width: 480px) {
  .app-shell {
    padding: 0.75rem;
  }

  .hero {
    padding: 1rem;
    border-radius: 1rem;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .hero-copy {
    font-size: 0.9rem;
  }

  .hero-metrics {
    grid-template-columns: 1fr;
  }

  .session-stats {
    grid-template-columns: 1fr;
  }

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

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

  .checkpoint-list {
    grid-template-columns: 1fr;
  }

  .compare-metric-grid {
    grid-template-columns: 1fr;
  }

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

  .diagnosis-overview-grid {
    grid-template-columns: 1fr;
  }

  .replay-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .replay-controls button {
    padding: 0.6rem 0.7rem;
    font-size: 0.85rem;
  }

  .replay-controls .speed-select {
    min-width: 0;
    flex: 1;
  }

  .timeline-container {
    order: 10;
    width: 100%;
    flex-basis: 100%;
  }

  .panel {
    border-radius: 1rem;
  }

  .session-rail,
  .detail-rail,
  .main-stage,
  .control-bar,
  .analysis-ribbon,
  .event-detail,
  .alerts-panel,
  .search-panel {
    padding: 0.85rem;
  }

  .rail-head h2,
  .control-bar h2,
  .analysis-ribbon h2,
  .alerts-panel h2,
  .search-panel h2 {
    font-size: 1.2rem;
  }

  .mode-switches button {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }

  .session-card {
    padding: 0.85rem;
    border-radius: 0.9rem;
  }

  .hero-metrics > div,
  .session-stats > div,
  .detail-grid > div {
    padding: 0.85rem;
    border-radius: 1rem;
  }

  .hero-metrics strong,
  .session-stats strong,
  .detail-grid strong {
    font-size: 1.1rem;
  }

  .conversation-list {
    grid-template-columns: 1fr;
  }

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

  .trace-layout {
    grid-template-columns: 1fr;
  }

  .detail-actions {
    grid-template-columns: 1fr;
  }

  .checkpoint-actions {
    grid-template-columns: 1fr;
  }

  .checkpoint-compare-grid {
    grid-template-columns: 1fr;
  }

  .compare-header,
  .compare-token-grid {
    grid-template-columns: 1fr;
  }

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

  /* Hide less critical elements on very small screens */
  .tree-legend {
    display: none;
  }

  .event-counter {
    display: none;
  }

  .replay-summary {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* Drift panel */
.drift-panel {
  margin-top: 16px;
}

.baseline-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.current-summary {
  padding-top: 8px;
  border-top: 1px solid var(--panel-border);
  margin-top: 4px;
}

.drift-message {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin: 0.5rem 0;
}

.drift-error {
  color: var(--danger);
  font-size: 0.85rem;
}

.drift-alerts h3 {
  margin: 12px 0 8px;
  font-size: 0.9rem;
}

.drift-alert {
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 40%);
  border-radius: 0.75rem;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-left: 3px solid var(--muted);
}

.drift-alert.warning {
  border-left-color: var(--warning);
  background: color-mix(in oklch, var(--panel), var(--warning) 12%);
}

.drift-alert.critical {
  border-left-color: var(--danger);
  background: color-mix(in oklch, var(--panel), var(--danger) 10%);
}

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

.alert-label {
  font-weight: 600;
  font-size: 0.85rem;
}

.alert-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.alert-badge.warning {
  background: var(--warning);
  color: var(--text);
}

.alert-badge.critical {
  background: var(--danger);
  color: white;
}

.alert-description {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--text);
}

.alert-values {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

.alert-cause {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

.no-drift {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Failure Cluster Panel */
.failure-cluster-panel {
  margin-top: 1rem;
}

.cluster-list-detailed {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.cluster-card {
  display: grid;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cluster-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px oklch(0.52 0.04 60 / 0.1);
}

.cluster-card.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, oklch(0.99 0.005 75 / 0.92), oklch(0.96 0.02 84 / 0.92));
}

.cluster-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.cluster-fingerprint {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.cluster-severity {
  font-size: 0.78rem;
  color: var(--warning);
}

.cluster-metrics {
  display: flex;
  gap: 1rem;
}

.cluster-metric {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.cluster-symptom {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.cluster-link {
  font-size: 0.75rem;
  color: var(--accent);
}

/* Policy Diff View */
.policy-diff-panel {
  margin-top: 1rem;
}

.policy-shift-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.policy-shift-card {
  display: grid;
  gap: 0.6rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.policy-shift-card:hover {
  border-color: var(--accent);
}

.shift-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shift-turn {
  font-size: 0.8rem;
  color: var(--muted);
}

.shift-magnitude {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.shift-magnitude.magnitude-major {
  background: var(--danger);
  color: white;
}

.shift-magnitude.magnitude-moderate {
  background: var(--warning);
  color: var(--text);
}

.shift-magnitude.magnitude-minor {
  background: var(--olive);
  color: white;
}

.shift-magnitude.magnitude-subtle {
  background: var(--bg-strong);
  color: var(--muted);
}

.shift-templates {
  font-size: 0.88rem;
}

.template-change {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.template-previous {
  color: var(--muted);
  text-decoration: line-through;
}

.template-arrow {
  color: var(--muted);
}

.template-new {
  font-weight: 500;
  color: var(--text);
}

.template-initial {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.template-badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-strong);
  color: var(--muted);
}

.shift-score {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.magnitude-bar-container {
  flex: 1;
  height: 4px;
  background: var(--bg-strong);
  border-radius: 2px;
  overflow: hidden;
}

.magnitude-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* Rolling Summary Enhancements */
.rolling-metrics {
  margin-top: 1rem;
  padding: 0.9rem;
  border-radius: 0.75rem;
  background: var(--bg-strong);
}

.rolling-metrics h3 {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.metric-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.metric-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 0.78rem;
}

.badge-label {
  color: var(--muted);
}

.badge-value {
  color: var(--text);
}

.rolling-window-info {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Checkpoint Delta */
.checkpoint-delta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.3rem;
  font-size: 0.72rem;
}

.delta-positive {
  color: var(--olive);
}

.delta-negative {
  color: var(--danger);
}

/* Breakpoint Stop Indicator */
.breakpoint-stop-indicator {
  font-weight: 600;
  color: var(--warning);
}

/* Checkbox Label */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

/* Empty Message */
.empty-message {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* ============================================
   Failure Cluster Panel Styles
   ============================================ */

.failure-cluster-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cluster-list-detailed {
  display: grid;
  gap: 0.75rem;
}

.cluster-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 34%);
  text-align: left;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  min-height: 44px;
}

.cluster-card:hover {
  background: color-mix(in oklch, var(--panel), var(--accent) 8%);
  border-color: color-mix(in oklch, var(--accent), white 40%);
}

.cluster-card:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent), white 50%);
}

.cluster-card:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent), white 50%);
}

.cluster-card:active {
  transform: scale(0.995);
}

.cluster-card.active {
  border-color: var(--accent);
  background: color-mix(in oklch, var(--panel), var(--accent) 12%);
}

.cluster-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.cluster-fingerprint {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.cluster-severity {
  color: var(--muted);
  font-size: 0.82rem;
  flex-shrink: 0;
}

.cluster-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.cluster-metric {
  display: grid;
  gap: 0.15rem;
}

.cluster-symptom {
  margin: 0;
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 50%);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cluster-link {
  display: block;
  margin-top: 0.25rem;
  color: var(--accent);
  font-size: 0.82rem;
}

/* ============================================
   Policy Diff View Styles
   ============================================ */

.policy-diff-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.policy-shift-list {
  display: grid;
  gap: 0.75rem;
}

.policy-shift-card {
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 34%);
  text-align: left;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
  min-height: 44px;
}

.policy-shift-card:hover {
  background: color-mix(in oklch, var(--panel), var(--accent) 8%);
  border-color: color-mix(in oklch, var(--accent), white 40%);
}

.policy-shift-card:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent), white 50%);
}

.policy-shift-card:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent), white 50%);
}

.policy-shift-card:active {
  transform: scale(0.995);
}

.policy-shift-card.magnitude-major {
  border-left: 3px solid var(--danger);
}

.policy-shift-card.magnitude-moderate {
  border-left: 3px solid var(--warning);
}

.policy-shift-card.magnitude-minor {
  border-left: 3px solid var(--accent);
}

.policy-shift-card.magnitude-subtle {
  border-left: 3px solid var(--muted);
}

.shift-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.shift-turn {
  font-size: 0.82rem;
  color: var(--muted);
}

.shift-magnitude {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.shift-magnitude.magnitude-major {
  background: color-mix(in oklch, var(--panel), var(--danger) 18%);
  color: var(--danger);
}

.shift-magnitude.magnitude-moderate {
  background: color-mix(in oklch, var(--panel), var(--warning) 18%);
  color: var(--warning);
}

.shift-magnitude.magnitude-minor {
  background: color-mix(in oklch, var(--panel), var(--accent) 18%);
  color: var(--accent);
}

.shift-magnitude.magnitude-subtle {
  background: color-mix(in oklch, var(--panel), var(--muted) 18%);
  color: var(--muted);
}

.shift-templates {
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 50%);
}

.template-change,
.template-initial {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.template-previous {
  color: var(--muted);
  text-decoration: line-through;
}

.template-arrow {
  color: var(--muted);
  font-size: 0.8rem;
}

.template-new {
  font-weight: 600;
  color: var(--text);
}

.template-badge {
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--panel), var(--olive) 18%);
  color: var(--olive);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.shift-score {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.magnitude-bar-container {
  height: 0.5rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--bg-strong), var(--muted) 20%);
  overflow: hidden;
}

.magnitude-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--warning) 50%, var(--danger) 100%);
  transition: width 200ms ease;
}

/* ============================================
   Analytics Panel Styles
   ============================================ */

.analytics-panel {
  padding: 1.4rem;
}

.analytics-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.analytics-header h2 {
  margin: 0;
  font-size: 1.45rem;
}

.time-range-selector {
  display: flex;
  gap: 0.5rem;
}

.time-range-btn {
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 35%);
  border: 1px solid transparent;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
  min-height: 38px;
}

.time-range-btn:hover {
  transform: translateY(-1px);
  background: color-mix(in oklch, var(--panel), var(--accent) 12%);
}

.time-range-btn.active {
  border-color: color-mix(in oklch, var(--accent), white 50%);
  background: color-mix(in oklch, var(--panel), var(--accent) 16%);
}

.analytics-period {
  margin-bottom: 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.analytics-loading,
.analytics-error {
  color: var(--muted);
  font-size: 0.95rem;
}

.analytics-error {
  color: var(--danger);
}

.analytics-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  display: grid;
  gap: 0.35rem;
  padding: 1.25rem;
  border-radius: 1.2rem;
  background: color-mix(in oklch, var(--panel), var(--accent) 4%);
  border: 1px solid color-mix(in oklch, var(--panel-border), var(--accent) 22%);
  text-align: center;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.analytics-section {
  margin-bottom: 1.5rem;
}

.analytics-section:last-child {
  margin-bottom: 0;
}

.analytics-section h3 {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.adoption-bars {
  display: grid;
  gap: 0.85rem;
}

.adoption-bar-row {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) auto auto;
  gap: 0.75rem;
  align-items: center;
}

.adoption-bar-track {
  height: 0.75rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--bg-strong), var(--muted) 15%);
  overflow: hidden;
}

.adoption-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--olive) 100%);
  transition: width 300ms ease;
}

.adoption-bar-label {
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
}

.adoption-bar-percent {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  min-width: 3rem;
  text-align: right;
}

.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 4rem;
  padding: 0.5rem 0;
}

.sparkline-bar {
  flex: 1;
  min-width: 4px;
  max-width: 12px;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, var(--accent) 0%, color-mix(in oklch, var(--accent), var(--bg) 30%) 100%);
  transition: height 200ms ease;
}

.sparkline-bar:hover {
  background: var(--olive);
}

.sparkline-empty {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Tab Navigation */
.app-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0 0.5rem;
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 30%);
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
  min-height: 44px;
}

.tab-btn:hover {
  transform: translateY(-1px);
  background: color-mix(in oklch, var(--panel), var(--accent) 10%);
}

.tab-btn.active {
  border-color: color-mix(in oklch, var(--accent), white 50%);
  background: color-mix(in oklch, var(--panel), var(--accent) 14%);
  font-weight: 600;
}

/* Analytics full-page layout */
.analytics-view {
  padding: 0 1rem;
}

.analytics-view .analytics-panel {
  max-width: 60rem;
}

/* ============================================
   Rolling Summary Styles
   ============================================ */

.rolling-summary-card {
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--panel-border);
  background: color-mix(in oklch, var(--panel), white 28%);
}

.rolling-summary-text {
  margin: 0 0 0.75rem;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.6;
}

.rolling-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rolling-metric-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--panel), var(--bg-strong) 40%);
  font-size: 0.8rem;
}

.rolling-metric-badge strong {
  font-weight: 600;
  color: var(--text);
}

.rolling-metric-badge span {
  color: var(--muted);
}

/* ============================================
   Reduced Motion Preference
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .cluster-card,
  .policy-shift-card,
  .magnitude-bar-fill,
  .highlight-nav button {
    transition: none;
  }
  
  .cluster-card:hover,
  .policy-shift-card:hover {
    transform: none;
  }
}
