:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --raised: #fbfdff;
  --ink: #18212f;
  --ink-soft: #344155;
  --muted: #637083;
  --line: #d7e1ed;
  --line-strong: #bccbdb;
  --blue: #105fce;
  --blue-deep: #0b3f91;
  --blue-soft: #e9f2ff;
  --green: #127a5a;
  --green-soft: #e7f8f1;
  --amber: #a96100;
  --amber-soft: #fff4df;
  --red: #b42318;
  --shadow: 0 18px 46px rgba(16, 35, 66, 0.12);
  --shadow-soft: 0 8px 24px rgba(16, 35, 66, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #eaf2fb 0%, #f7f9fc 42%, #ffffff 100%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(16, 95, 206, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 122, 90, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 72%);
}

button,
input {
  font: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(16, 95, 206, 0.28);
  outline-offset: 2px;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.topbar,
.hero-panel,
.trace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  position: relative;
  margin-bottom: 14px;
  border: 1px solid rgba(188, 203, 219, 0.78);
  border-radius: 8px;
  padding: 20px 22px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 36px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 22px;
}

h3 {
  margin-bottom: 0;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.lede {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.status-pill,
.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: var(--panel);
  font-size: 13px;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    color 0.2s ease;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c4ccda;
}

.status-pill.is-live {
  color: var(--green);
  border-color: rgba(23, 133, 95, 0.38);
  background: var(--green-soft);
}

.status-pill.is-live .status-dot {
  background: var(--green);
}

.status-pill.is-offline {
  color: var(--muted);
  border-color: rgba(99, 112, 131, 0.32);
  background: #f8fafc;
}

.status-pill.is-error {
  color: var(--red);
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff1f1;
}

.status-pill.is-error .status-dot {
  background: #b42318;
}

.badge.live {
  color: var(--green);
  border-color: rgba(23, 133, 95, 0.35);
}

.badge.offline {
  color: var(--amber);
  border-color: rgba(182, 107, 0, 0.35);
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 18px 0;
  border: 1px solid rgba(188, 203, 219, 0.72);
  border-radius: 8px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-soft);
  overflow-x: auto;
}

.tab,
.primary,
.secondary,
.ghost-button,
.mini-action {
  border: 1px solid var(--line);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    color 0.2s ease;
}

.tab {
  min-width: 112px;
  border-radius: 8px;
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  color: #ffffff;
  border-color: var(--blue);
  background: linear-gradient(180deg, #176fe4, var(--blue));
  box-shadow: 0 8px 20px rgba(16, 95, 206, 0.26);
}

.tab:hover,
.primary:hover,
.secondary:hover,
.ghost-button:hover,
.mini-action:hover {
  transform: translateY(-1px);
}

.primary {
  min-width: 108px;
  border-radius: 8px;
  padding: 12px 16px;
  color: #ffffff;
  border-color: var(--blue);
  background: linear-gradient(180deg, #176fe4, var(--blue));
  box-shadow: 0 10px 24px rgba(16, 95, 206, 0.24);
  font-weight: 800;
}

.secondary {
  min-width: 104px;
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--blue);
  background: #eef5ff;
  font-weight: 800;
}

.ghost-button {
  min-height: 38px;
  border-radius: 8px;
  padding: 9px 14px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 13px;
  font-weight: 800;
}

.mini-action {
  width: 100%;
  margin-top: 16px;
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  background: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.primary:disabled,
.secondary:disabled,
.ghost-button:disabled,
.mini-action:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: view-in 0.18s ease;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.grid {
  display: grid;
  gap: 16px;
}

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

.overview-grid {
  margin-top: 16px;
}

.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
}

.view,
.panel,
.trace-detail {
  min-width: 0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(251, 253, 255, 0.96)),
    var(--panel);
  box-shadow: var(--shadow);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.command-panel {
  overflow: hidden;
  border-color: rgba(16, 95, 206, 0.16);
}

.command-panel::before {
  display: block;
  width: calc(100% + 40px);
  height: 4px;
  margin: -20px -20px 18px;
  content: "";
  background: linear-gradient(90deg, var(--blue), var(--green), var(--amber));
}

.trace-detail {
  border-color: rgba(19, 104, 216, 0.18);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-heading p {
  margin-bottom: 0;
}

.trace-pipeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 20px;
}

.trace-pipeline div {
  position: relative;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbff;
}

.trace-pipeline div:not(:last-child)::after {
  position: absolute;
  top: 28px;
  right: -8px;
  z-index: 1;
  width: 16px;
  height: 16px;
  border-top: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-strong);
  content: "";
  background: #f8fbff;
  transform: rotate(45deg);
}

.trace-pipeline strong,
.trace-pipeline span {
  display: block;
}

.trace-pipeline strong {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 15px;
}

.trace-pipeline span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.mode-card {
  min-height: 166px;
  border: 1px solid var(--line);
  border-top-width: 5px;
  border-radius: 8px;
  padding: 16px;
  background: #fbfdff;
  box-shadow: 0 8px 22px rgba(16, 35, 66, 0.05);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.mode-card:hover,
.mode-card.is-current {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(16, 35, 66, 0.12);
}

.mode-card.is-current {
  border-color: rgba(16, 95, 206, 0.34);
  background: linear-gradient(180deg, #ffffff, #f5f9ff);
}

.mode-card strong,
.mode-card span {
  display: block;
}

.mode-card strong {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 19px;
}

.mode-card span {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.mode-card p {
  margin-bottom: 0;
}

.mode-full {
  border-top-color: var(--blue);
}

.mode-byo {
  border-top-color: var(--green);
}

.mode-mcp {
  border-top-color: var(--amber);
}

.readiness-panel,
.evidence-panel {
  min-height: 320px;
}

.readiness-list {
  display: grid;
  gap: 10px;
}

.readiness {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 12px;
  border: 1px solid rgba(216, 224, 235, 0.84);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdff;
}

.dot {
  width: 10px;
  height: 10px;
  margin-top: 7px;
  border-radius: 50%;
  background: #c4ccda;
}

.dot.ready {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(18, 122, 90, 0.11);
}

.readiness strong {
  display: block;
}

.readiness p {
  margin-bottom: 0;
  word-break: break-word;
}

.flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.flow div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f9fbfe;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  font-weight: 700;
}

.token-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fbfdff;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.token-input:focus {
  border-color: rgba(16, 95, 206, 0.55);
  box-shadow: 0 0 0 4px rgba(16, 95, 206, 0.1);
}

.query,
.answer,
.notice,
.warning {
  border-radius: 8px;
  padding: 12px;
}

.query {
  border: 1px solid rgba(16, 95, 206, 0.12);
  background: #f3f7fc;
  color: var(--ink);
  font-weight: 650;
}

.answer {
  margin: 14px 0;
  border-left: 4px solid var(--green);
  background: #f3faf7;
  color: var(--ink);
  font-size: 16px;
  font-weight: 650;
}

.answer-sources {
  justify-content: flex-start;
  margin-bottom: 14px;
}

.query-panel {
  box-shadow: var(--shadow-soft);
}

.notice {
  border: 1px solid rgba(169, 97, 0, 0.18);
  background: var(--amber-soft);
  color: var(--amber);
}

.warning {
  border: 1px solid rgba(180, 35, 24, 0.16);
  background: #fff1f1;
  color: var(--red);
}

.json-block {
  width: 100%;
  min-width: 0;
  max-height: 440px;
  max-width: 100%;
  overflow: auto;
  border: 1px solid #263247;
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(180deg, #101a2b, #0c1422),
    #0e1624;
  color: #d7e2f2;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.trace-summary {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  align-items: center;
  border-color: rgba(18, 122, 90, 0.2);
}

.trace-summary p {
  margin-bottom: 0;
}

.source-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.source-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.source-mcp {
  border-color: rgba(19, 104, 216, 0.35);
  color: var(--blue);
  background: #eef5ff;
}

.source-fabric {
  border-color: rgba(23, 133, 95, 0.35);
  color: var(--green);
  background: #eefaf5;
}

.source-generic {
  border-color: rgba(99, 112, 131, 0.35);
  color: var(--muted);
}

.trace-metrics {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.trace-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f9fbfe;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.75);
}

.trace-metrics strong,
.trace-metrics span {
  display: block;
}

.trace-metrics strong {
  color: var(--ink);
  font-size: 22px;
}

.trace-metrics span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.reveal {
  opacity: 0;
  transform: translateY(6px);
}

.reveal.is-in {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  .view.active {
    animation: none;
  }
}

@media (max-width: 780px) {
  .grid.two,
  .mode-grid,
  .trace-pipeline,
  .trace-summary,
  .trace-metrics,
  .topbar,
  .hero-panel {
    grid-template-columns: 1fr;
    display: grid;
  }

  .source-badges {
    justify-content: flex-start;
  }

  .topbar {
    align-items: start;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .trace-pipeline div:not(:last-child)::after {
    top: auto;
    right: 28px;
    bottom: -8px;
    transform: rotate(135deg);
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .topbar,
  .panel {
    padding: 16px;
  }

  .command-panel::before {
    width: calc(100% + 32px);
    margin: -16px -16px 16px;
  }

  .tabs {
    gap: 4px;
    padding: 5px;
  }

  .tab {
    min-width: max-content;
    padding: 9px 11px;
    font-size: 13px;
  }

  h1 {
    font-size: 28px;
  }
}
