:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --paper: #ffffff;
  --ink: #17201c;
  --muted: #667067;
  --line: #dce1dc;
  --line-strong: #c4ccc5;
  --teal: #0d7c73;
  --teal-soft: #dff3ef;
  --amber: #b35a1f;
  --amber-soft: #f7e5d2;
  --rose: #9d3453;
  --rose-soft: #f2dfe6;
  --violet: #5f579f;
  --green: #26845b;
  --shadow: 0 12px 28px rgba(21, 31, 27, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

textarea {
  resize: vertical;
}

.topbar {
  display: flex;
  min-height: 112px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.provider-toggle {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.provider-toggle button {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  cursor: pointer;
}

.provider-toggle button[aria-pressed="true"] {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--ink);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: clamp(118px, 15vw, 170px);
  height: auto;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 2vw, 2.35rem);
  line-height: 1.05;
}

h2 {
  max-width: 920px;
  margin-bottom: 0;
  font-size: clamp(1.3rem, 2vw, 2rem);
  line-height: 1.14;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  min-height: calc(100vh - 112px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

.sidebar-header {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.sidebar-header label,
.band-title span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar-header input {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  outline-color: var(--teal);
}

.benchmark-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
}

.tab-button[aria-current="true"] {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--ink);
  font-weight: 800;
}

.case-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 270px);
  overflow: auto;
  padding: 14px 18px 24px;
}

.case-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.case-button[aria-current="true"] {
  border-color: var(--teal);
  box-shadow: inset 4px 0 0 var(--teal);
}

.case-button strong,
.candidate-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.case-button span {
  color: var(--muted);
  font-size: 0.82rem;
}

.neutral-badge {
  align-self: start;
  white-space: nowrap;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 800;
}

.neutral-badge {
  background: #ecefec;
  color: var(--muted);
}

.workspace {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 22px;
}

.is-hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.case-band,
.ask-panel,
.answer-panel,
.phenotype-band,
.trace-pane,
.rank-pane,
.detail-pane {
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.ask-panel {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 12px;
  padding: 6px 0 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.ask-form {
  display: grid;
  width: min(760px, 100%);
  gap: 10px;
}

.ask-form textarea {
  width: 100%;
  min-height: 104px;
  padding: 15px 16px;
  border: 1px solid #050505;
  border-radius: 20px;
  background: #050505;
  color: #ffffff;
  line-height: 1.45;
  outline-color: var(--teal);
  resize: vertical;
}

.ask-form textarea::placeholder {
  color: rgba(255, 255, 255, 0.76);
}

.ask-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 8px;
  font-weight: 850;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
}

.runtime-status {
  width: min(760px, 100%);
  min-height: 22px;
  color: var(--muted);
  font-size: 0.86rem;
}

.runtime-status[data-tone="ok"] {
  color: var(--green);
}

.runtime-status[data-tone="warn"] {
  color: var(--amber);
}

.runtime-status[data-tone="busy"] {
  color: var(--violet);
}

.answer-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.answer-body {
  display: grid;
  gap: 12px;
}

.chat-thread {
  align-items: start;
}

.chat-query-row {
  display: flex;
  justify-content: flex-end;
}

.chat-query-bubble {
  max-width: min(720px, 100%);
  padding: 14px 16px;
  border-radius: 20px;
  background: #050505;
  color: #ffffff;
  font-weight: 760;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.answer-body h2 {
  font-size: clamp(1.15rem, 1.8vw, 1.65rem);
}

.answer-body p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.answer-body ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.answer-body li {
  line-height: 1.45;
}

.agent-markdown {
  display: grid;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.agent-markdown h3 {
  margin-top: 4px;
  font-size: 1rem;
  color: var(--ink);
}

.agent-markdown p,
.agent-markdown li {
  overflow-wrap: anywhere;
}

.agent-work,
.analysis-section,
.references-block {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.agent-toggle,
.agent-step,
.references-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.agent-toggle summary,
.agent-step summary,
.references-block summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

.agent-toggle summary::-webkit-details-marker,
.agent-step summary::-webkit-details-marker,
.references-block summary::-webkit-details-marker {
  display: none;
}

.agent-toggle summary::after,
.agent-step summary::after,
.references-block summary::after {
  content: "^";
  color: var(--muted);
  font-weight: 850;
}

.agent-toggle:not([open]) summary::after,
.agent-step:not([open]) summary::after,
.references-block:not([open]) summary::after {
  content: "v";
}

.agent-toggle > summary > span:first-child,
.references-block > summary > span:first-child {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-weight: 800;
}

.agent-toggle > summary > span:nth-child(2),
.references-block > summary > span:nth-child(2),
.agent-step summary > span:last-child {
  border-radius: 999px;
  padding: 3px 7px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 850;
}

.agent-step-list {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.agent-step summary {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  background: var(--paper);
}

.step-status {
  width: 12px;
  height: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #ffffff;
}

.step-status-complete {
  border-color: var(--teal);
  background: var(--teal);
}

.step-status-active {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.agent-step-body {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px 32px;
}

.agent-step-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.evidence-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fbfcfa;
  font-size: 0.9rem;
}

.evidence-table th,
.evidence-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.evidence-table th {
  background: #f0f2f0;
  color: var(--ink);
  font-weight: 850;
}

.source-chip {
  display: inline-block;
  max-width: 100%;
  margin: 0 5px 5px 0;
  border-radius: 999px;
  padding: 3px 7px;
  background: #f3e1da;
  color: #795345;
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.reference-list {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0 16px 16px 34px;
}

.reference-list li {
  padding-right: 8px;
}

.reference-list a,
.reference-list strong {
  color: #db4b2f;
  font-weight: 650;
  text-decoration: none;
}

.reference-list p {
  margin: 5px 0 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

.citation-list {
  display: grid;
  gap: 8px;
}

.citation-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.citation-item strong {
  color: var(--teal);
}

.citation-item span {
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.case-band {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
}

.case-outcome {
  display: grid;
  justify-items: end;
  gap: 8px;
  min-width: 220px;
  color: var(--muted);
  text-align: right;
}

.gold-text {
  max-width: 380px;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 750;
}

.phenotype-band {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.band-title,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.band-title strong,
.section-head span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.hpo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hpo-chip {
  max-width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.hpo-chip code {
  color: var(--teal);
  font-weight: 800;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(360px, 1.18fr);
  gap: 18px;
}

.rank-pane,
.detail-pane,
.trace-pane {
  display: grid;
  gap: 14px;
  padding: 18px;
}

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

.candidate-card {
  display: grid;
  gap: 10px;
  width: 100%;
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.candidate-card[aria-current="true"] {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.candidate-meta,
.candidate-components,
.detail-grid,
.xref-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.candidate-meta span,
.candidate-components span,
.xref-row span,
.evidence-pill {
  border-radius: 999px;
  padding: 4px 8px;
  background: #edf1ed;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.detail-title {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.detail-title p {
  margin-bottom: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.match-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.match-row {
  display: grid;
  grid-template-columns: minmax(92px, 0.7fr) minmax(0, 1.5fr) auto;
  gap: 8px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  font-size: 0.86rem;
}

.match-row code {
  color: var(--teal);
  font-weight: 800;
}

.match-kind {
  white-space: nowrap;
  color: var(--violet);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

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

.trace-item {
  display: grid;
  gap: 8px;
  min-height: 128px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.trace-item-active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.trace-item-complete {
  border-color: #bfd8cb;
}

.trace-item-pending {
  opacity: 0.68;
}

.trace-item strong {
  color: var(--teal);
}

.trace-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.trace-item ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.35;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .topbar,
  .case-band {
    align-items: stretch;
    flex-direction: column;
  }

  .provider-toggle {
    width: fit-content;
  }

  .shell,
  .ask-panel,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .case-list {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    max-height: none;
  }

  .case-outcome {
    justify-items: start;
    min-width: 0;
    text-align: left;
  }
}

@media (max-width: 640px) {
  .topbar,
  .workspace {
    padding: 16px;
  }

  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
  }

  .case-button,
  .match-row {
    grid-template-columns: 1fr;
  }

  .candidate-card {
    min-height: 0;
  }
}
