:root {
  color-scheme: light;
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eef2ee;
  --ink: #111514;
  --muted: #60706b;
  --line: #d8ded8;
  --line-strong: #aeb9b2;
  --accent: #126a58;
  --accent-2: #b04924;
  --accent-3: #2b5e8d;
  --warn: #8a5a00;
  --shadow: 0 18px 48px rgba(26, 35, 31, 0.1);
  --radius: 8px;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Aptos", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background:
    linear-gradient(180deg, rgba(18, 106, 88, 0.08), transparent 340px),
    linear-gradient(90deg, rgba(176, 73, 36, 0.08), transparent 420px),
    var(--bg);
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1560px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 32px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0 22px;
}

.source-line {
  margin: 0 0 5px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 15px;
  line-height: 1.2;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.top-actions a,
.record-actions a,
.record-actions button,
.pdf-load {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
}

.top-actions a:hover,
.record-actions a:hover,
.record-actions button:hover,
.pdf-load:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.overview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric,
.chart-block,
.atlas-card,
.toolbar,
.results-panel,
.detail-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 96px;
  padding: 16px;
}

.metric-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: 28px;
  line-height: 1.05;
}

.insight-strip {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr;
  gap: 12px;
  margin-bottom: 12px;
}

.chart-block {
  min-height: 150px;
  padding: 16px;
}

.block-heading,
.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.block-heading span,
.result-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.bar-stack {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.agency-row {
  display: grid;
  grid-template-columns: 132px 1fr 38px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.agency-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.agency-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.timeline {
  display: flex;
  align-items: end;
  gap: 4px;
  height: 92px;
  margin-top: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.timeline-bar {
  position: relative;
  flex: 1 1 0;
  min-width: 5px;
  padding: 0;
  border: 0;
  border-radius: 4px 4px 0 0;
  background: var(--accent-3);
  appearance: none;
}

.timeline-bar[data-active="true"] {
  background: var(--accent-2);
}

.timeline-bar:hover::after {
  content: attr(aria-label);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  z-index: 4;
  width: max-content;
  max-width: 190px;
  transform: translateX(-50%);
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  font-size: 12px;
  white-space: nowrap;
}

.research-atlas {
  margin-bottom: 12px;
}

.atlas-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin: 6px 0 10px;
}

.atlas-header h2 {
  font-size: 18px;
}

.atlas-header span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.atlas-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.35fr) minmax(270px, 1fr) minmax(260px, 0.95fr) minmax(230px, 0.8fr);
  gap: 12px;
}

.atlas-card {
  min-height: 256px;
  padding: 16px;
}

.topic-map,
.coverage-map,
.review-map {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.topic-row,
.coverage-row {
  display: grid;
  align-items: center;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
}

.topic-row {
  grid-template-columns: minmax(132px, 0.62fr) minmax(90px, 1fr) 56px;
  gap: 10px;
  min-height: 34px;
  padding: 7px 9px;
  text-align: left;
}

.topic-row:hover,
.topic-row[aria-pressed="true"],
.coverage-row:hover,
.coverage-row[aria-pressed="true"] {
  border-color: var(--accent);
  background: #f2faf6;
}

.topic-name {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-track,
.coverage-row i {
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.topic-track i,
.coverage-row b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.topic-row strong,
.coverage-row strong,
.entity-button strong,
.keyword-token span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 750;
}

.entity-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.entity-bucket {
  min-width: 0;
}

.entity-bucket h3 {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.entity-bucket > div {
  display: grid;
  gap: 5px;
}

.entity-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 29px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.entity-button:hover,
.keyword-token:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.entity-button span {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.keyword-cloud {
  display: flex;
  align-content: flex-start;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.keyword-token {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: calc(11px * var(--weight));
  font-weight: 720;
}

.coverage-row {
  grid-template-columns: minmax(92px, 0.7fr) minmax(70px, 1fr) 52px;
  gap: 9px;
  min-height: 38px;
  padding: 8px 9px;
  text-align: left;
}

.coverage-row span {
  font-size: 12px;
  font-weight: 750;
}

.review-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.review-row:hover,
.review-row[aria-pressed="true"] {
  border-color: var(--accent);
  background: #f2faf6;
}

.review-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 750;
}

.review-row strong {
  color: var(--muted);
  font-size: 11px;
}

.muted-review {
  color: var(--muted);
}

.review-export {
  min-height: 36px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
}

.review-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.page-shell {
  max-width: 1180px;
}

.page-main {
  display: grid;
  gap: 12px;
}

.page-hero,
.page-panel,
.source-table,
.method-steps > div,
.page-stat-grid > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.page-hero {
  padding: 24px;
}

.page-hero h2 {
  max-width: 920px;
  margin-bottom: 12px;
  font-size: 30px;
  line-height: 1.12;
}

.page-hero p {
  max-width: 860px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.page-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.page-stat-grid > div {
  min-height: 104px;
  padding: 16px;
}

.page-stat-grid span {
  display: block;
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.page-stat-grid strong {
  display: block;
  font-size: 29px;
  line-height: 1.05;
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.page-panel {
  padding: 20px;
}

.page-panel h2,
.method-steps h2 {
  margin-bottom: 10px;
  font-size: 17px;
}

.page-panel p,
.method-steps p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.62;
}

.page-panel p:last-child,
.method-steps p:last-child {
  margin-bottom: 0;
}

.plain-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.source-table {
  display: grid;
}

.source-table > div {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.source-table > div:last-child {
  border-bottom: 0;
}

.source-table span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.source-table a,
.source-table code {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.method-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.method-steps > div {
  padding: 18px;
}

.method-steps span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 12px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
}

.script-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.script-list code {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 12px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 140px 210px 180px 42px 42px;
  gap: 9px;
  padding: 10px;
  margin-bottom: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 10px;
}

.search-box svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.search-box input {
  width: 100%;
  min-height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

select,
.icon-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

select {
  min-width: 0;
  padding: 0 10px;
  font-size: 13px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-button:hover,
select:hover,
.search-box:focus-within {
  border-color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(440px, 0.94fr) minmax(430px, 1.06fr);
  gap: 12px;
  align-items: start;
}

.results-panel,
.detail-panel {
  min-height: 620px;
}

.results-panel {
  padding: 14px;
}

.detail-panel {
  position: sticky;
  top: 12px;
  overflow: hidden;
}

.type-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.type-pill,
.type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.type-badge[data-type="PDF"] {
  color: #7f2d18;
  background: #f7e7df;
}

.type-badge[data-type="VID"] {
  color: #154f7c;
  background: #e1eef8;
}

.type-badge[data-type="IMG"] {
  color: #0f6656;
  background: #deefe8;
}

.records-list {
  display: grid;
  gap: 8px;
  max-height: 72vh;
  margin-top: 14px;
  overflow: auto;
  padding-right: 4px;
}

.record-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.record-row:hover,
.record-row[aria-selected="true"] {
  border-color: var(--accent);
}

.record-row[aria-selected="true"] {
  background: #f2faf6;
}

.record-thumb {
  display: grid;
  place-items: center;
  width: 78px;
  min-height: 62px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #151817;
  color: white;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
}

.record-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.record-row-body {
  min-width: 0;
}

.record-row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.record-row h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.record-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.record-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
}

.record-topics {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 9px;
}

.topic-chip {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  max-width: 100%;
  padding: 0 8px;
  border: 1px solid #cfe0d9;
  border-radius: 999px;
  background: #eef8f4;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.topic-chip.more,
.muted-pill {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--muted);
}

.record-snippet {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.record-snippet b {
  color: var(--ink);
}

.quality-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid #dbe5dc;
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.quality-high {
  border-color: #b7d3b9;
  background: #f4fbf4;
  color: #27633a;
}

.quality-medium {
  border-color: #e2cf94;
  background: #fff8df;
  color: #72560d;
}

.quality-low {
  border-color: #e3aaa2;
  background: #fff3f1;
  color: #8a2d22;
}

mark {
  padding: 0 2px;
  border-radius: 3px;
  background: #ffe08a;
  color: var(--ink);
}

.detail-content {
  display: grid;
  grid-template-rows: auto minmax(280px, 44vh) auto;
  min-height: 620px;
}

.detail-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-header h2 {
  margin: 10px 0 8px;
  font-size: 21px;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.detail-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.preview {
  display: grid;
  place-items: center;
  min-height: 280px;
  background:
    linear-gradient(135deg, rgba(17, 21, 20, 0.03) 25%, transparent 25%) 0 0 / 18px 18px,
    var(--surface-2);
}

.preview img,
.preview video,
.preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  background: #111514;
}

.pdf-preview {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 280px;
}

.pdf-preview .pdf-load {
  position: absolute;
  right: 18px;
  bottom: 18px;
  background: rgba(255, 255, 255, 0.94);
}

.pdf-placeholder {
  display: grid;
  place-items: center;
  gap: 14px;
  width: 100%;
  height: 100%;
  min-height: 280px;
  padding: 28px;
  text-align: center;
}

.pdf-placeholder strong {
  font-size: 19px;
}

.pdf-placeholder span {
  max-width: 420px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}

.detail-field {
  min-height: 70px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.detail-field:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.detail-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.detail-field strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.research-panel {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fbf8;
}

.research-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.research-head h3 {
  margin: 0;
  font-size: 13px;
  line-height: 1.2;
}

.research-head span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.quality-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.quality-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.entity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.entity-group {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.entity-group > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.entity-list {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.entity-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 23px;
  padding: 0 7px;
  border: 1px solid #dde5de;
  border-radius: 6px;
  background: #fbfcfa;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.hash-field {
  grid-column: 1 / -1;
  font-family: var(--mono);
}

.quality-panel {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.quality-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.quality-head p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.quality-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
}

.quality-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.quality-metrics span {
  min-height: 22px;
  padding: 3px 7px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.quality-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
}

.quality-panel p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
}

.review-note {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.review-note span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.review-note textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid #dbe5dc;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
}

.text-panel {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.text-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.text-panel-header span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.text-panel-header a {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.text-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  margin-bottom: 8px;
  border: 1px solid #dbe5dc;
  border-radius: 7px;
  background: #fff;
}

.text-tabs button {
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.text-tabs button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

.text-panel p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
}

.text-body {
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
}

.translation-note {
  margin: 0 0 10px !important;
  color: var(--muted) !important;
  font-size: 12px !important;
}

.ocr-reader {
  display: grid;
  gap: 10px;
}

.reader-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.reader-controls select {
  min-width: min(100%, 260px);
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid #dbe5dc;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

.reader-controls button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #dbe5dc;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.reader-controls span {
  color: var(--muted);
  font-size: 12px;
}

.reader-chunks {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding-right: 3px;
}

.reader-chunk {
  min-width: 0;
  padding: 12px;
  border: 1px solid #e2e8e1;
  border-radius: 7px;
  background: #fff;
}

.reader-chunk[data-active="true"] {
  border-color: #b7cbb9;
  box-shadow: inset 3px 0 0 var(--accent);
}

.reader-chunk h4 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 12px;
}

.reader-chunk h4 span,
.reader-chunk b {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.reader-chunk p {
  margin-top: 6px;
  white-space: pre-wrap;
}

.reader-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.reader-pair > div {
  min-width: 0;
}

.parallel-grid {
  display: grid;
  gap: 10px;
}

.parallel-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.parallel-cell {
  min-width: 0;
  padding: 10px;
  border: 1px solid #e2e8e1;
  border-radius: 7px;
  background: #fff;
}

.parallel-cell b {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
}

.parallel-cell p {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
}

.record-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 18px 18px;
}

.empty-state {
  display: grid;
  min-height: 620px;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.no-results {
  padding: 42px 14px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1100px) {
  .overview,
  .insight-strip,
  .atlas-grid,
  .method-steps,
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1560px);
    padding-top: 12px;
  }

  .topbar {
    flex-direction: column;
  }

  h1 {
    font-size: 28px;
  }

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

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

  .atlas-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .search-box {
    grid-column: 1 / -1;
  }

  .records-list {
    max-height: none;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .entity-grid {
    grid-template-columns: 1fr;
  }

  .parallel-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .reader-pair {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-field:nth-child(odd) {
    border-right: 0;
  }
}

@media (max-width: 520px) {
  .overview,
  .page-stat-grid,
  .page-grid,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .page-hero {
    padding: 18px;
  }

  .page-hero h2 {
    font-size: 24px;
  }

  .source-table > div {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .atlas-card {
    padding: 12px;
  }

  .topic-row,
  .coverage-row {
    grid-template-columns: 1fr auto;
  }

  .topic-track,
  .coverage-row i {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .entity-map {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 82px;
  }

  .agency-row {
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
  }

  .agency-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .record-row {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .record-thumb {
    width: 66px;
    min-height: 58px;
  }
}
