:root {
  --background: #071016;
  --surface: #0b171f;
  --surface-strong: #101d25;
  --surface-raised: #13242d;
  --border: #29404d;
  --border-subtle: #1a303b;
  --text: #e7edf0;
  --muted: #a8b5bd;
  --lime: #a8e63a;
  --amber: #f5ad3d;
  --red: #ff727a;
  --blue: #6bbdf7;
  --focus: #d7ff83;
  --mono: "SFMono-Regular", "PT Mono", "Andale Mono", ui-monospace, monospace;
  --radius: 3px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  min-width: 320px;
  color-scheme: dark;
  background: var(--background);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background: var(--background);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
select { cursor: pointer; }

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button { border-radius: var(--radius); }

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

h1,
h2,
h3 {
  letter-spacing: -0.03em;
  line-height: 1.1;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 52px);
  font-weight: 650;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
  font-weight: 650;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 650;
}

kbd {
  display: inline-grid;
  min-width: 23px;
  min-height: 21px;
  place-items: center;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface-strong);
  font: inherit;
}

.app-header,
#app-main,
.app-footer {
  width: min(1800px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header { padding-top: 16px; }

.trust-strip {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.045em;
}

.trust-state,
.trust-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.trust-state strong { color: var(--text); font-weight: 650; }

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
}

.trust-state[data-state="connected"] .status-dot { background: var(--lime); }
.trust-state[data-state="warning"] .status-dot { background: var(--amber); }
.trust-state[data-state="error"] .status-dot { background: var(--red); }

.product-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 440px);
  align-items: end;
  gap: 32px;
  padding: 28px 4px 24px;
  border-bottom: 1px solid var(--border);
}

.kicker,
.section-index,
.state-code {
  margin-bottom: 6px;
  color: var(--lime);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.product-promise {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.heading-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  text-align: right;
}

.heading-actions p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 10px;
}

body[data-mode="public-sample"] .kicker::after {
  content: " · SAMPLE WORKSPACE";
  color: var(--blue);
}

body[data-mode="share-safe"] .kicker::after {
  content: " · SHARE-SAFE VIEW";
  color: var(--amber);
}

.mode-card {
  --mode-accent: var(--lime);
  width: min(100%, 440px);
  display: grid;
  gap: 2px;
  padding: 10px 12px 10px 15px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--mode-accent);
  text-align: left;
}

body[data-mode="public-sample"] .mode-card { --mode-accent: var(--blue); }
body[data-mode="share-safe"] .mode-card { --mode-accent: var(--amber); }

.mode-label {
  color: var(--mode-accent);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.09em;
}

.mode-card strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.mode-card > span:last-child {
  color: var(--muted);
  font-size: 9px;
}

.heading-button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

#app-main { padding-block: 20px 48px; }

.discovery,
.inventory,
.selected-region,
.lineage-lens {
  border: 1px solid var(--border);
  background: var(--surface);
}

.discovery { padding: 16px; }

.section-heading,
.inventory-heading,
.selected-heading,
.lens-heading,
.pareto-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}

.section-heading { margin-bottom: 14px; }

.shortcut-hint {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 10px;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(300px, 2fr) repeat(4, minmax(140px, 1fr));
  gap: 8px;
}

label {
  min-width: 0;
  display: grid;
  gap: 5px;
}

label > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

input,
select {
  height: 39px;
  padding: 0 10px;
}

input::placeholder { color: #74858f; }

.advanced-filters {
  margin-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.advanced-filters summary {
  width: max-content;
  padding-top: 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
}

.advanced-filters summary::marker { color: var(--lime); }

.count-badge {
  display: inline-block;
  margin-left: 5px;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 8px;
  text-transform: uppercase;
}

.count-badge.is-active {
  border-color: var(--lime);
  color: var(--lime);
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 260px)) auto;
  align-items: end;
  gap: 8px;
  padding-top: 10px;
}

.button,
.icon-button,
.back-button,
.row-copy,
.match-toggle {
  min-height: 34px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 11px;
  font-size: 10px;
  font-weight: 650;
  text-decoration: none;
}

.button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.row-copy:hover:not(:disabled),
.match-toggle:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue);
}

.button-primary {
  border-color: var(--lime);
  background: var(--lime);
  color: var(--background);
}

.button-primary:hover:not(:disabled) {
  border-color: var(--focus);
  background: var(--focus);
  color: var(--background);
}

.evidence-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(250px, 1.25fr);
  margin-block: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.evidence-strip article,
.evidence-flags {
  min-height: 78px;
  padding: 12px;
  border-right: 1px solid var(--border);
}

.evidence-strip article {
  display: grid;
  align-content: space-between;
}

.evidence-strip article > span,
.selected-metrics article > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.evidence-strip article strong {
  margin-block: 3px;
  color: var(--text);
  font-size: 26px;
  font-weight: 650;
  line-height: 1;
}

.evidence-strip article small,
.selected-metrics article small {
  color: var(--muted);
  font-size: 9px;
}

.evidence-flags {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  border-right: 0;
}

.evidence-chip,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.evidence-chip.is-warning,
.badge-warning {
  border-color: #7d5b28;
  color: var(--amber);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.workspace[data-lens="open"] {
  grid-template-columns: 300px minmax(0, 1fr);
}

.primary-workspace {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.lineage-lens {
  position: sticky;
  top: 12px;
  min-width: 0;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.lens-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.icon-button {
  width: 30px;
  min-height: 30px;
  padding: 0;
  font-size: 19px;
  line-height: 1;
}

#lineage-content { padding: 12px; }

.lens-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 10px;
}

.lens-summary strong {
  color: var(--lime);
  font-size: 25px;
  line-height: 1;
}

.lens-summary span {
  color: var(--muted);
  font-size: 8px;
  text-transform: uppercase;
}

.lens-path,
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--muted);
  font-size: 9px;
}

.lens-path {
  padding: 9px 0 11px;
  border-block: 1px solid var(--border-subtle);
}

.lens-path span[aria-current="page"],
.breadcrumb span[aria-current="page"] { color: var(--text); }

.lens-path i,
.breadcrumb i {
  color: var(--blue);
  font-style: normal;
}

.branch-list { margin-top: 7px; }

.branch-row {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 10px 6px;
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.branch-row:hover,
.branch-row.is-selected {
  background: var(--surface-strong);
}

.branch-row.is-selected { border-left: 2px solid var(--lime); }

.branch-title strong,
.branch-title small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.branch-title strong { font-size: 10px; }
.branch-title small { margin-top: 3px; color: var(--muted); font-size: 8px; }

.branch-share,
.pareto-share {
  display: grid;
  grid-template-columns: minmax(45px, 1fr) 43px;
  align-items: center;
  gap: 7px;
}

.branch-share progress,
.pareto-share progress {
  width: 100%;
  height: 4px;
  border: 0;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
  background: var(--border-subtle);
}

.branch-share progress::-webkit-progress-bar,
.pareto-share progress::-webkit-progress-bar { background: var(--border-subtle); }

.branch-share progress::-webkit-progress-value,
.pareto-share progress::-webkit-progress-value,
.branch-share progress::-moz-progress-bar,
.pareto-share progress::-moz-progress-bar {
  background: var(--blue);
}

.branch-share em,
.pareto-share em {
  color: var(--muted);
  font-size: 8px;
  font-style: normal;
  text-align: right;
}

.lens-rollup {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 6px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--muted);
  font-size: 8px;
}

.lens-rollup strong { color: var(--text); font-weight: 600; }

.lens-unavailable,
.pareto-empty,
.pareto-error {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #7d5b28;
  background: #171a18;
  color: var(--muted);
  font-size: 10px;
}

.lens-unavailable p:last-child,
.pareto-empty p:last-child,
.pareto-error p:last-child { margin-bottom: 0; }

.lens-empty { color: var(--muted); font-size: 9px; }

.inventory-heading,
.selected-heading { padding: 14px; }

.subhead {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.inventory-actions,
.selected-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.inventory-table { border-top: 1px solid var(--border); }

.inventory-columns,
.session-row {
  display: grid;
  grid-template-columns: minmax(310px, 2.1fr) 105px minmax(145px, 0.9fr) 60px 100px 105px 94px;
  align-items: stretch;
}

.inventory-columns {
  min-height: 31px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-strong);
}

.inventory-columns span {
  display: flex;
  align-items: center;
  padding: 7px 8px;
  border-right: 1px solid var(--border-subtle);
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.session-row-wrap { border-bottom: 1px solid var(--border-subtle); }

.session-row-wrap.is-selected {
  border-left: 2px solid var(--lime);
  background: #0e1c22;
}

.session-row > * {
  min-width: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 7px 8px;
  border: 0;
  border-right: 1px solid var(--border-subtle);
  border-radius: 0;
}

.session-row > :last-child { border-right: 0; }

.session-cell {
  position: relative;
  display: grid;
  align-content: center;
  padding: 0 !important;
}

.session-select {
  min-width: 0;
  min-height: 47px;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.session-select:hover { background: var(--surface-strong); }

.row-marker {
  width: 5px;
  height: 5px;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.session-select[aria-current="true"] .row-marker {
  border-color: var(--lime);
  background: var(--lime);
}

.session-title { min-width: 0; }

.session-title > strong {
  max-width: 100%;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 650;
}

.mobile-row-meta { display: none; }

.row-badges {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: 5px;
  vertical-align: middle;
}

.row-badges .badge {
  min-height: 17px;
  padding: 1px 4px;
  font-size: 7px;
}

.match-preview {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, auto) 1fr;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: var(--blue);
  font-size: 8px;
}

.match-preview strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.match-preview small { color: var(--muted); font-size: 8px; }

.match-toggle {
  width: max-content;
  min-height: 19px;
  margin: 0 8px 6px 24px;
  padding: 1px 5px;
  color: var(--muted);
  font-size: 7px;
}

.updated-cell,
.model-cell {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.numeric { justify-content: flex-end; text-align: right; }
.emphasis { color: var(--lime); font-weight: 650; }

.row-copy {
  min-height: 47px;
  justify-content: center;
  padding: 6px;
  color: var(--blue);
  background: transparent;
  font-size: 8px;
  font-weight: 650;
}

.match-list {
  padding: 5px 8px 8px 24px;
  border-top: 1px solid var(--border-subtle);
  background: var(--background);
}

.match-option {
  width: 100%;
  min-height: 39px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.match-option:hover,
.match-option[aria-selected="true"] { background: var(--surface-strong); }
.match-option[aria-selected="true"] { border-left: 2px solid var(--lime); }
.match-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-option small { color: var(--muted); font-size: 8px; }

.skeleton-row {
  height: 48px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
}

.skeleton-row::before {
  content: "";
  width: 28%;
  height: 7px;
  display: block;
  margin: 20px 16px;
  background: var(--border-subtle);
}

.empty-state {
  min-height: 240px;
  display: grid;
  place-content: center;
  justify-items: start;
  padding: 28px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.empty-state h3 { color: var(--text); font-size: 18px; }
.empty-state > p:not(.state-code) { max-width: 650px; }
.empty-state > div { display: flex; gap: 6px; }

.system-state .state-code { color: var(--amber); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 9px;
}

.selected-region { min-width: 0; }

.back-button {
  display: none;
  margin: 10px 12px 0;
  padding: 6px 8px;
  color: var(--blue);
}

.selected-heading { border-bottom: 1px solid var(--border); }
.selected-heading > div:first-child { min-width: 0; }
.selected-heading h2 { margin-bottom: 7px; font-size: 19px; }

.selected-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.selected-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
  background: var(--background);
}

.selected-metrics article {
  min-height: 86px;
  display: grid;
  align-content: space-between;
  padding: 12px;
  border-right: 1px solid var(--border);
}

.selected-metrics article:last-child { border-right: 0; }

.selected-metrics article strong {
  margin-block: 4px;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.selected-metrics article:first-child strong,
.selected-metrics article:last-child strong { color: var(--lime); }

.pareto-region { padding: 14px; }

.pareto-heading { margin-bottom: 10px; }
.pareto-heading h3 { margin-bottom: 0; font-size: 16px; }
.pareto-heading > p { margin-bottom: 0; color: var(--muted); font-size: 9px; }
.pareto-heading > p strong { color: var(--lime); font-size: 14px; }

.pareto-table { border: 1px solid var(--border); }

.pareto-columns,
.pareto-row {
  display: grid;
  grid-template-columns: 55px minmax(260px, 2fr) 110px minmax(160px, 1fr) 90px;
  align-items: center;
}

.pareto-columns {
  min-height: 30px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pareto-columns > *,
.pareto-row > * { padding: 7px 9px; }

.pareto-row {
  min-height: 47px;
  border-top: 1px solid var(--border-subtle);
}

.pareto-row.is-selected {
  border-left: 2px solid var(--lime);
  background: var(--surface-strong);
}

.pareto-rank { color: var(--muted); font-size: 9px; }

.pareto-thread { min-width: 0; }
.pareto-thread > strong,
.pareto-thread > small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pareto-thread > strong { font-size: 10px; }
.pareto-thread > small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.pareto-tokens { color: var(--lime); }
.pareto-cumulative { color: var(--muted); }
.pareto-group { background: #0c151b; }

.selected-match-subline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  color: var(--blue);
  font-size: 8px;
}

.selected-match-subline > span { text-transform: uppercase; }
.selected-match-subline > small { color: var(--muted); }

.scope-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 8px;
}

.lens-scrim { display: none; }

.copy-fallback {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(7, 16, 22, 0.88);
}

.copy-fallback > div {
  width: min(620px, 100%);
  padding: 18px;
  border: 1px solid var(--amber);
  background: var(--surface);
}

.copy-fallback textarea {
  margin-block: 12px;
  padding: 10px;
  resize: vertical;
}

.app-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 16px 4px 32px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 9px;
}

.app-footer p { margin-bottom: 0; }
.app-footer strong { color: var(--text); }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 1199px) {
  .filter-grid { grid-template-columns: minmax(280px, 2fr) repeat(2, minmax(150px, 1fr)); }
  .search-field { grid-row: span 2; }
  .workspace,
  .workspace[data-lens="open"] { grid-template-columns: minmax(0, 1fr); }

  .lineage-lens {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 31;
    width: min(380px, calc(100% - 40px));
    max-height: none;
    border-block: 0;
    border-right: 0;
  }

  .lens-scrim:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: block;
    border: 0;
    border-radius: 0;
    background: rgba(7, 16, 22, 0.72);
  }

  .inventory-columns,
  .session-row {
    grid-template-columns: minmax(280px, 2fr) 100px minmax(140px, 1fr) 58px 105px 90px;
  }

  .inventory-columns > :nth-child(5),
  .root-tokens-cell { display: none; }
}

@media (max-width: 900px) {
  .app-header,
  #app-main,
  .app-footer { width: min(100% - 20px, 1800px); }

  .trust-strip { align-items: flex-start; flex-direction: column; gap: 5px; }
  .trust-meta { flex-wrap: wrap; }
  .product-heading { grid-template-columns: 1fr; gap: 16px; }
  .heading-actions { align-items: flex-start; text-align: left; }
  .heading-button-row { justify-content: flex-start; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; grid-row: auto; }
  .evidence-strip { grid-template-columns: repeat(3, 1fr); }
  .evidence-flags { grid-column: 1 / -1; min-height: 48px; justify-content: flex-start; border-top: 1px solid var(--border); }
  .evidence-strip article:nth-child(3) { border-right: 0; }
  .inventory-columns,
  .session-row { grid-template-columns: minmax(260px, 2fr) 95px 58px 100px 88px; }
  .inventory-columns > :nth-child(3),
  .model-cell { display: none; }
  .selected-heading { align-items: flex-start; flex-direction: column; }
  .selected-actions { justify-content: flex-start; }
  .pareto-columns,
  .pareto-row { grid-template-columns: 48px minmax(220px, 2fr) 95px minmax(130px, 1fr) 78px; }
}

@media (max-width: 767px) {
  body { font-size: 12px; }
  .app-header { padding-top: 8px; }
  .product-heading { padding-block: 20px; }
  h1 { font-size: 31px; }
  #app-main { padding-block: 10px 30px; }
  .discovery { padding: 12px; }
  .section-heading { align-items: flex-start; }
  .filter-grid { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .advanced-grid { grid-template-columns: 1fr; }
  .evidence-strip { grid-template-columns: 1fr 1fr; }
  .evidence-strip article { min-height: 70px; }
  .evidence-strip article:nth-child(2) { border-right: 0; }
  .evidence-strip article:nth-child(3) { grid-column: 1 / -1; border-top: 1px solid var(--border); }
  .evidence-flags { grid-column: 1 / -1; }

  .workspace,
  .workspace[data-lens="open"] { display: block; }
  body[data-view="list"] .lineage-lens,
  body[data-view="list"] .selected-region { display: none !important; }
  body[data-view="detail"] .inventory { display: none; }

  .lineage-lens {
    position: static;
    width: 100%;
    max-height: none;
    margin-bottom: 10px;
    border: 1px solid var(--border);
  }

  .lens-scrim:not([hidden]) { display: none; }
  .lens-heading { position: static; }

  .inventory-heading { align-items: flex-start; flex-direction: column; }
  .inventory-actions { justify-content: flex-start; }
  .inventory-columns { display: none; }
  .session-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .updated-cell,
  .model-cell,
  .descendants-cell,
  .root-tokens-cell { display: none !important; }
  .subtree-tokens-cell { min-width: 70px; }
  .row-copy { min-width: 76px; }
  .session-title > strong { font-size: 10px; }
  .mobile-row-meta {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: var(--muted);
    font-size: 7px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .match-preview { grid-template-columns: 1fr; gap: 1px; }
  .match-option { grid-template-columns: 1fr; gap: 2px; }
  .pagination { justify-content: space-between; }

  .back-button { display: inline-flex; }
  .selected-heading { padding-top: 10px; }
  .selected-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .selected-actions .button-primary { grid-column: 1 / -1; }
  .selected-metrics { grid-template-columns: 1fr 1fr; }
  .selected-metrics article:nth-child(2) { border-right: 0; }
  .selected-metrics article:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .pareto-region { padding: 10px; }
  .pareto-heading { align-items: flex-start; flex-direction: column; }
  .pareto-columns { display: none; }
  .pareto-row {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 0;
    padding-block: 3px;
  }
  .pareto-share,
  .pareto-cumulative { display: none; }
  .pareto-row > * { padding-inline: 6px; }
  .selected-match-subline { display: grid; }
  .app-footer { grid-template-columns: 1fr; gap: 10px; }
}

@media (max-width: 430px) {
  .trust-meta > span[aria-hidden="true"] { display: none; }
  .trust-meta { align-items: flex-start; flex-direction: column; gap: 2px; }
  .evidence-strip { grid-template-columns: 1fr; }
  .evidence-strip article,
  .evidence-strip article:nth-child(2),
  .evidence-strip article:nth-child(3) {
    grid-column: auto;
    border-right: 0;
    border-top: 1px solid var(--border);
  }
  .evidence-strip article:first-child { border-top: 0; }
  .selected-actions { grid-template-columns: 1fr; }
  .selected-actions .button-primary { grid-column: auto; }
  .selected-metrics { grid-template-columns: 1fr; }
  .selected-metrics article,
  .selected-metrics article:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .selected-metrics article:last-child { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
