:root {
  color-scheme: light;
  --canvas: #f3f4f6;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --ink: #111827;
  --muted: #667085;
  --line: #d5d9e0;
  --line-dark: #a6afbd;
  --blue: #1f5eff;
  --blue-dark: #184bd1;
  --blue-soft: #eef4ff;
  --green: #147a42;
  --green-soft: #edf9f1;
  --amber: #946200;
  --amber-soft: #fff8e5;
  --red: #b42318;
  --red-soft: #fff1f0;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --sans: Inter, Geist, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; }
button, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; transform: translateY(-150%); background: var(--ink); color: white; padding: 8px 12px; }
.skip-link:focus { transform: translateY(0); }
.shell { width: min(1440px, 100%); margin: 0 auto; padding-left: 32px; padding-right: 32px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand-block { display: flex; align-items: baseline; gap: 18px; }
.brand { color: var(--ink); font-size: 24px; font-weight: 760; letter-spacing: -1px; text-decoration: none; }
.brand span { color: var(--blue); }
.brand-block p { margin: 0; color: var(--muted); font-size: 13px; }
.header-meta { display: flex; align-items: center; gap: 22px; }
.environment { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.environment i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.text-button { border: 0; padding: 6px 0; background: transparent; color: var(--ink); font-size: 13px; font-weight: 650; cursor: pointer; }
.text-button:hover { color: var(--blue); }

.eyebrow-row { min-height: 56px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: .045em; text-transform: uppercase; }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; }
.mode-tab { min-height: 68px; display: flex; align-items: center; gap: 16px; border: 0; border-bottom: 3px solid transparent; background: transparent; padding: 0 24px; color: var(--muted); cursor: pointer; text-align: left; font-weight: 660; }
.mode-tab + .mode-tab { border-left: 1px solid var(--line); }
.mode-tab:hover { background: var(--surface-subtle); color: var(--ink); }
.mode-tab.active { border-bottom-color: var(--blue); color: var(--ink); background: var(--surface); }
.tab-index { color: var(--line-dark); font-family: var(--mono); font-size: 11px; }
.mode-tab.active .tab-index { color: var(--blue); }

.workspace-grid { display: grid; grid-template-columns: minmax(320px, 5fr) minmax(0, 7fr); min-height: 678px; margin-bottom: 64px; border: 1px solid var(--line); border-top: 0; background: var(--surface); }
.query-panel, .result-panel { min-width: 0; padding: 36px 32px; }
.query-panel { display: flex; flex-direction: column; gap: 34px; border-right: 1px solid var(--line); background: var(--surface); }
.result-panel { background: var(--surface-subtle); }
.section-kicker { margin: 0 0 9px; color: var(--blue); font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { max-width: 470px; margin: 0; font-size: clamp(27px, 2.4vw, 38px); line-height: 1.1; letter-spacing: -.035em; }
h2 { margin: 0; font-size: 23px; line-height: 1.25; letter-spacing: -.025em; }
h3 { margin: 0; font-size: 17px; }
.section-copy { max-width: 520px; margin: 14px 0 0; color: var(--muted); }

.field-group { display: flex; flex-direction: column; gap: 8px; }
.field-group label, .label-row { font-size: 12px; font-weight: 700; }
.label-row { display: flex; justify-content: space-between; }
.label-row span { color: var(--muted); font-family: var(--mono); font-weight: 500; }
textarea { width: 100%; resize: vertical; border: 1px solid var(--line-dark); border-radius: 6px; outline: none; background: white; padding: 15px; color: var(--ink); font-family: var(--mono); font-size: 13px; line-height: 1.6; }
textarea:hover { border-color: #7c8799; }
textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,94,255,.12); }
textarea[aria-invalid="true"] { border-color: var(--red); }
.field-help, .field-feedback { margin: 0; font-size: 12px; }
.field-help { color: var(--muted); }
.field-feedback { min-height: 18px; color: var(--red); font-weight: 600; }
.field-feedback.valid { color: var(--green); }
.action-row { display: flex; gap: 10px; }
.primary-button, .secondary-button { min-height: 44px; border-radius: 6px; padding: 0 17px; font-weight: 700; cursor: pointer; transition: background .14s ease, border-color .14s ease, transform .14s ease; }
.primary-button { display: flex; align-items: center; justify-content: space-between; gap: 28px; border: 1px solid var(--blue); background: var(--blue); color: white; }
.primary-button:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.secondary-button { border: 1px solid var(--line-dark); background: white; }
.secondary-button:hover { border-color: var(--ink); }
.scope-note { margin-top: auto; border-top: 1px solid var(--line); padding-top: 18px; display: grid; grid-template-columns: 60px 1fr; gap: 16px; }
.scope-note p { margin: 0; color: var(--muted); font-size: 12px; }
.scope-index { color: var(--line-dark); font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.empty-state { height: 100%; min-height: 380px; display: grid; align-content: center; justify-items: center; text-align: center; padding: 40px; }
.empty-mark { width: 68px; height: 68px; position: relative; display: grid; place-items: center; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 50%; color: var(--blue); font-family: var(--mono); }
.empty-mark::after { content: ""; position: absolute; width: 96px; height: 1px; background: var(--line); transform: rotate(-38deg); }
.empty-state h2 { max-width: 380px; }
.empty-state p { max-width: 440px; margin: 11px 0 0; color: var(--muted); }

.result-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.status-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.status-dot.warning { background: var(--amber); }
.status-dot.error { background: var(--red); }
.status-label { color: var(--green); font-size: 11px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.status-label.warning { color: var(--amber); }
.status-label.error { color: var(--red); }
.result-head p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.confidence { flex: 0 0 auto; align-self: flex-start; border: 1px solid #b9c9ef; border-radius: 4px; background: var(--blue-soft); padding: 6px 9px; color: #21458f; font-size: 11px; font-weight: 700; }

.metric-strip { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-top: 0; background: white; }
.metric { min-width: 0; padding: 14px 16px; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.metric strong { display: block; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 12px; white-space: nowrap; }

.path-section, .evidence-section { margin-top: 28px; }
.section-heading-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 15px; }
.section-heading-row span { color: var(--muted); font-family: var(--mono); font-size: 10px; text-transform: uppercase; }
.path { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.path-node { min-width: 0; position: relative; border: 1px solid var(--line); border-radius: 6px; background: white; padding: 14px; }
.path-node:not(:last-child)::after { content: "→"; position: absolute; right: -11px; top: 50%; z-index: 2; width: 10px; color: var(--blue); font-weight: 800; transform: translateY(-50%); }
.path-node.input-node { border: 2px solid var(--blue); padding: 13px; box-shadow: 0 0 0 3px rgba(31,94,255,.08); }
.path-node.source-node { border-color: #8aa8ef; background: var(--blue-soft); }
.node-top { min-height: 20px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.node-type { color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.tx-badge, .input-badge, .source-badge { border-radius: 3px; padding: 2px 5px; font-family: var(--mono); font-size: 9px; font-weight: 700; }
.tx-badge { background: #eaf0f8; color: #30435e; }
.tx-badge.out { background: #e6f6fb; color: #15546a; }
.input-badge { background: var(--blue); color: white; }
.source-badge { background: #dce8ff; color: #173f99; }
.chain-mark { width: 28px; height: 28px; display: grid; place-items: center; margin: 18px 0 10px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-subtle); font-family: var(--mono); font-size: 9px; font-weight: 800; }
.path-node strong { display: block; font-size: 12px; }
.node-value { display: block; overflow: hidden; margin-top: 4px; color: var(--muted); font-family: var(--mono); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.node-link { text-decoration: none; }
.node-link:hover .node-value { color: var(--blue); text-decoration: underline; }

.evidence-list { border-top: 1px solid var(--line); }
.evidence-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.evidence-row > span:first-child { color: var(--muted); font-size: 11px; font-weight: 700; }
.evidence-value { overflow: hidden; font-family: var(--mono); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.evidence-link { color: var(--blue); font-size: 11px; font-weight: 700; text-decoration: none; }
.evidence-link:hover { text-decoration: underline; }
.boundary { margin: 22px 0 0; border-left: 2px solid var(--line-dark); padding: 3px 0 3px 13px; color: var(--muted); font-size: 11px; }

.alert-state { margin-top: 30px; border: 1px solid var(--line); border-left: 3px solid var(--red); background: white; padding: 24px; }
.alert-state.warning { border-left-color: var(--amber); }
.alert-state h2 { margin-top: 8px; }
.alert-state p { margin: 8px 0 0; color: var(--muted); }

.batch-wrap { overflow-x: auto; margin-top: 26px; }
.batch-table { width: 100%; border-collapse: collapse; background: white; font-size: 11px; }
.batch-table th { border: 1px solid var(--line); padding: 10px 9px; background: #f1f3f6; color: var(--muted); text-align: left; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.batch-table td { max-width: 150px; border: 1px solid var(--line); padding: 11px 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-table .mono { font-family: var(--mono); }
.row-status { color: var(--green); font-weight: 700; }
.row-status.empty { color: var(--amber); }
.details-button { border: 0; background: transparent; color: var(--blue); padding: 0; font-size: 11px; font-weight: 700; cursor: pointer; }
.detail-row td { max-width: none; padding: 18px; white-space: normal; background: var(--surface-subtle); }
.detail-row .path { max-width: 840px; }

dialog { width: min(620px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 8px; padding: 0; box-shadow: 0 24px 80px rgba(17,24,39,.18); }
dialog::backdrop { background: rgba(17,24,39,.42); }
.dialog-card { padding: 28px; }
.dialog-header { display: flex; justify-content: space-between; gap: 20px; }
.icon-button { align-self: flex-start; border: 1px solid var(--line); background: white; width: 34px; height: 34px; border-radius: 4px; font-size: 21px; cursor: pointer; }
.help-list { margin: 28px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.help-list li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; border-bottom: 1px solid var(--line); padding: 16px 0; }
.help-list span { color: var(--blue); font-family: var(--mono); font-size: 10px; }
.help-list p { margin: 0; color: var(--muted); font-size: 13px; }
.help-list strong { color: var(--ink); }

button:focus-visible, a:focus-visible { outline: 3px solid rgba(31,94,255,.28); outline-offset: 3px; }

@media (max-width: 1040px) {
  .shell { padding-left: 20px; padding-right: 20px; }
  .workspace-grid { grid-template-columns: minmax(300px, 4fr) minmax(0, 6fr); }
  .query-panel, .result-panel { padding: 28px 24px; }
  .path { grid-template-columns: 1fr; }
  .path-node:not(:last-child)::after { content: "↓"; right: auto; left: 25px; top: auto; bottom: -14px; transform: none; }
  .chain-mark { margin: 10px 0 6px; }
}

@media (max-width: 760px) {
  .shell { padding-left: 16px; padding-right: 16px; }
  .header-inner { min-height: 70px; }
  .brand-block p, .environment { display: none; }
  .eyebrow-row { min-height: 58px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; font-size: 9px; }
  .eyebrow-row span:last-child { text-align: left; }
  .mode-tab { min-height: 62px; padding: 0 13px; gap: 9px; font-size: 13px; }
  .workspace-grid { display: block; min-height: 0; margin-bottom: 36px; }
  .query-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .query-panel, .result-panel { padding: 26px 18px; }
  h1 { font-size: 28px; }
  .result-head { display: block; }
  .confidence { display: inline-block; margin-top: 14px; }
  .metric-strip { grid-template-columns: 1fr; }
  .metric + .metric { border-left: 0; border-top: 1px solid var(--line); }
  .evidence-row { grid-template-columns: 1fr auto; gap: 7px 14px; }
  .evidence-value { grid-column: 1 / -1; grid-row: 2; }
  .batch-table thead { display: none; }
  .batch-table, .batch-table tbody, .batch-table tr, .batch-table td { display: block; width: 100%; max-width: none; }
  .batch-table tr:not(.detail-row) { margin-bottom: 12px; border: 1px solid var(--line); }
  .batch-table td { border: 0; border-bottom: 1px solid var(--line); padding-left: 42%; position: relative; }
  .batch-table td::before { content: attr(data-label); position: absolute; left: 10px; width: 38%; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
  .detail-row { margin: -12px 0 12px; border: 1px solid var(--line); border-top: 0; }
  .detail-row td { padding: 18px; }
  .detail-row td::before { display: none; }
}

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