:root {
  color-scheme: light;
  --ink: #18201d;
  --muted: #66716c;
  --line: #d9dfdc;
  --soft: #f4f7f5;
  --paper: #ffffff;
  --green: #13795b;
  --green-soft: #e2f4ec;
  --cyan: #147d92;
  --cyan-soft: #e3f3f6;
  --amber: #9a6700;
  --amber-soft: #fff3cf;
  --red: #b42318;
  --red-soft: #feeceb;
  --violet: #6750a4;
  --violet-soft: #eee9fb;
  --shadow: 0 10px 28px rgba(20, 32, 27, 0.08);
}

* { box-sizing: border-box; }

html { background: #eef2ef; }

body {
  margin: 0;
  color: var(--ink);
  background: #eef2ef;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button, input { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-header {
  min-height: 72px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand-block, .header-actions, .detail-title-row, .dialog-header {
  display: flex;
  align-items: center;
}

.brand-block { gap: 12px; min-width: 0; }
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 6px;
  color: white;
  background: var(--ink);
  font-weight: 800;
  font-size: 13px;
}

h1, h2, h3, p { margin-top: 0; }
.brand-block h1 { margin: 0; font-size: 18px; line-height: 1.2; }
.brand-block p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.header-actions { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.live-indicator span { width: 8px; height: 8px; border-radius: 50%; background: #27a36a; }

.button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 650;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.button.primary { color: white; background: var(--green); }
.button.secondary { color: var(--ink); background: white; border-color: var(--line); }
.button:hover { filter: brightness(0.96); }

.metrics-band {
  min-height: 88px;
  padding: 15px 24px;
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.metric { padding: 8px 16px; background: var(--paper); }
.metric span { display: block; font-size: 24px; font-weight: 760; line-height: 1.1; }
.metric small { color: var(--muted); font-size: 11px; }
.metric.emphasis { background: var(--amber-soft); }

.workspace {
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 18px 24px 30px;
  display: grid;
  grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.catalog-panel, .detail-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}
.catalog-panel { overflow: hidden; position: sticky; top: 16px; }
.catalog-toolbar { padding: 14px; border-bottom: 1px solid var(--line); }
.search-field span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.search-field input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: var(--soft);
  outline: none;
}
.search-field input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft); }
.filter-row { margin-top: 10px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.filter {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}
.filter.active { color: white; background: var(--ink); border-color: var(--ink); }
.catalog-heading { padding: 12px 14px 8px; display: flex; justify-content: space-between; align-items: baseline; }
.catalog-heading h2 { margin: 0; font-size: 14px; }
.catalog-heading span { color: var(--muted); font-size: 11px; }
.catalog-counts { display: grid; justify-items: end; gap: 2px; }
.catalog-counts #coverage-note { color: var(--amber); font-weight: 700; }
.claim-list { max-height: calc(100vh - 285px); overflow: auto; padding: 0 8px 10px; }
.claim-row {
  width: 100%;
  min-height: 108px;
  padding: 12px 10px;
  display: block;
  text-align: left;
  border: 0;
  border-top: 1px solid var(--line);
  background: white;
  cursor: pointer;
}
.claim-row:hover { background: var(--soft); }
.claim-row.selected { background: var(--green-soft); box-shadow: inset 3px 0 0 var(--green); }
.claim-row-top, .claim-row-meta { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.claim-id { color: var(--cyan); font-size: 11px; font-weight: 750; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.claim-row h3 { margin: 7px 0 9px; font-size: 13px; line-height: 1.35; }
.claim-row-meta { color: var(--muted); font-size: 11px; }

.status-badge, .type-badge, .dimension-value {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}
.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 9px;
  font-weight: 750;
  white-space: nowrap;
}
.role-main_result { color: var(--green); background: var(--green-soft); border-color: #a8d7c5; }
.role-assumption { color: var(--amber); background: var(--amber-soft); border-color: #e4c86f; }
.role-limitation, .role-open_question { color: var(--red); background: var(--red-soft); border-color: #efb4af; }
.status-conditional_corroborated { color: var(--green); background: var(--green-soft); }
.status-conditional_proven { color: var(--violet); background: var(--violet-soft); }
.type-badge { color: var(--muted); background: var(--soft); border: 1px solid var(--line); }

.detail-panel { min-height: 680px; overflow: hidden; }
.detail-header { padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.eyebrow { margin-bottom: 6px; color: var(--cyan); font-size: 11px; font-weight: 780; text-transform: uppercase; }
.detail-title-row { align-items: flex-start; justify-content: space-between; gap: 16px; }
.detail-title-row h2 { margin: 0; max-width: 820px; font-size: 21px; line-height: 1.25; }
.detail-statement { margin: 12px 0 0; max-width: 900px; color: #3f4a45; line-height: 1.55; }
.narrative-lead { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); }
.narrative-lead div { padding: 12px 14px; background: var(--soft); }
.narrative-lead div + div { border-left: 1px solid var(--line); background: var(--green-soft); }
.narrative-lead small { color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.narrative-lead p { margin: 5px 0 0; line-height: 1.45; }
.coverage-disclosure { margin: 10px 0 0; padding-left: 10px; border-left: 3px solid var(--amber); color: #5c4300; font-size: 12px; line-height: 1.45; }
.scope-line { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }

.tabs { padding: 0 22px; display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab {
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { color: var(--green); border-bottom-color: var(--green); }
.tab-content { padding: 20px 22px 24px; }

.section-title { margin: 0 0 12px; font-size: 14px; }
.study-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.study-heading h3 { max-width: 760px; margin: 0; font-size: 19px; line-height: 1.35; }
.coverage-badge { flex: 0 0 auto; padding: 7px 9px; border: 1px solid #e4c86f; border-radius: 4px; color: #5c4300; background: var(--amber-soft); font-size: 11px; font-weight: 750; }
.study-summary-grid { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.study-summary-grid p { color: #3f4a45; line-height: 1.55; }
.chain-title { margin-top: 24px; }
.study-chain { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.study-chain li { min-height: 58px; padding: 9px 10px; display: flex; justify-content: space-between; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.study-chain li.current { box-shadow: inset 3px 0 0 var(--green); background: var(--green-soft); }
.study-chain li.indexed { color: var(--muted); background: #fafbfa; }
.study-chain strong { display: block; margin-top: 3px; font-size: 12px; }
.chain-meta { display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: var(--muted); font-size: 10px; }
.dimension-grid { display: grid; grid-template-columns: repeat(6, minmax(100px, 1fr)); gap: 8px; }
.dimension { min-height: 74px; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--soft); }
.dimension small { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.dimension strong { font-size: 12px; overflow-wrap: anywhere; }

.two-column { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.plain-list { margin: 0; padding: 0; list-style: none; }
.plain-list li { position: relative; padding: 8px 0 8px 18px; border-bottom: 1px solid var(--line); line-height: 1.4; }
.plain-list li::before { content: ""; position: absolute; left: 2px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.plain-list.limitations li::before { background: var(--red); }

.evidence-record { padding: 14px 0 18px; border-bottom: 1px solid var(--line); }
.evidence-record:first-child { padding-top: 0; }
.evidence-heading { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.evidence-heading h3 { margin: 0; font-size: 14px; }
.assertion-table { width: 100%; margin-top: 12px; border-collapse: collapse; table-layout: fixed; }
.assertion-table th, .assertion-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.assertion-table th { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.outcome-satisfied { color: var(--green); font-weight: 750; }
.outcome-indeterminate { color: var(--amber); font-weight: 750; }

.result-strip { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-item { padding: 10px; border-left: 3px solid var(--cyan); background: var(--cyan-soft); }
.result-item.danger { border-left-color: var(--red); background: var(--red-soft); }
.result-item small { display: block; color: var(--muted); font-size: 10px; }
.result-item strong { display: block; margin-top: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.graph { padding: 8px 0 18px; display: flex; align-items: stretch; gap: 8px; overflow-x: auto; }
.graph-node { min-width: 170px; max-width: 210px; padding: 11px; border: 1px solid var(--line); border-radius: 5px; background: white; }
.graph-node.assumption { border-color: #e0b64b; background: var(--amber-soft); }
.graph-node.root { border-color: var(--green); background: var(--green-soft); }
.graph-node small { color: var(--muted); font-size: 10px; }
.graph-node strong { display: block; margin: 5px 0; font-size: 12px; line-height: 1.35; }
.graph-arrow { min-width: 22px; display: grid; place-items: center; color: var(--muted); font-size: 20px; }
.graph-note { padding: 12px; border-left: 3px solid var(--amber); background: var(--amber-soft); line-height: 1.45; }

.context-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-width: 460px; margin-bottom: 14px; }
.context-toggle button { min-height: 36px; border: 1px solid var(--line); border-radius: 4px; background: white; cursor: pointer; font-weight: 700; }
.context-toggle button.active { color: white; border-color: var(--ink); background: var(--ink); }
.context-panel { min-height: 260px; padding: 16px; border: 1px solid var(--line); border-radius: 5px; background: #151b19; color: #e9f0ed; }
.context-panel pre, .json-panel pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.context-warning { margin-top: 12px; padding: 10px; color: #5c4300; background: var(--amber-soft); border-left: 3px solid var(--amber); }

.json-toolbar { margin-bottom: 10px; display: flex; justify-content: flex-end; }
.json-panel { max-height: 500px; padding: 14px; overflow: auto; background: #f6f8f7; border: 1px solid var(--line); border-radius: 5px; }
.loading-state, .empty-state { padding: 60px 24px; color: var(--muted); text-align: center; }

dialog { width: min(620px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 24px 80px rgba(15, 25, 20, 0.25); }
dialog::backdrop { background: rgba(20, 28, 24, 0.45); }
.dialog-content { padding: 22px; }
.dialog-header { justify-content: space-between; align-items: flex-start; gap: 16px; }
.dialog-header h2 { margin: 0; font-size: 20px; }
.icon-button { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: white; cursor: pointer; font-size: 22px; }
.submission-steps { margin: 20px 0; padding-left: 22px; }
.submission-steps li { margin: 10px 0; line-height: 1.45; }
.dialog-note { color: var(--muted); }

@media (max-width: 980px) {
  .app-header { align-items: flex-start; }
  .header-actions { max-width: 400px; }
  .metrics-band { grid-template-columns: repeat(5, minmax(90px, 1fr)); padding-inline: 14px; }
  .workspace { grid-template-columns: 310px minmax(0, 1fr); padding-inline: 14px; }
  .dimension-grid { grid-template-columns: repeat(3, 1fr); }
  .two-column { grid-template-columns: 1fr; }
  .study-summary-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-header { padding: 12px 14px; flex-direction: column; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .live-indicator { margin-right: auto; }
  .metrics-band { grid-template-columns: repeat(2, 1fr); }
  .metric:last-child { grid-column: 1 / -1; }
  .workspace { display: block; padding: 12px; }
  .catalog-panel { position: static; margin-bottom: 12px; }
  .claim-list { max-height: 330px; }
  .detail-panel { min-height: 0; }
  .detail-title-row { flex-direction: column; }
  .narrative-lead { grid-template-columns: 1fr; }
  .narrative-lead div + div { border-left: 0; border-top: 1px solid var(--line); }
  .study-heading, .study-chain li { align-items: flex-start; flex-direction: column; }
  .chain-meta { width: 100%; justify-content: space-between; }
  .dimension-grid { grid-template-columns: repeat(2, 1fr); }
  .result-strip { grid-template-columns: 1fr; }
  .assertion-table th:nth-child(3), .assertion-table td:nth-child(3) { display: none; }
}

@media (max-width: 440px) {
  .brand-block p { display: none; }
  .header-actions .secondary { display: none; }
  .button { min-height: 38px; }
  .metrics-band { grid-template-columns: repeat(2, 1fr); }
  .dimension-grid { grid-template-columns: 1fr 1fr; }
  .tab-content, .detail-header { padding-inline: 15px; }
  .tabs { padding-inline: 10px; }
  .context-toggle { grid-template-columns: 1fr; }
}
