/* Research Map, Research Packet and Changelog. Loads after anthropic.css. */

/* ===== Shared bits ======================================================= */
.rp-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.rp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg);
  font-size: 0.82rem; font-weight: 600; color: var(--dtmw-gray-700); text-decoration: none;
}
.rp-chip svg { width: 14px; height: 14px; color: var(--muted); }
a.rp-chip:hover { border-color: var(--dtmw-teal-500); color: var(--text); }
.rp-chip.is-off { color: var(--soft); border-style: dashed; background: var(--dtmw-gray-50); }
.rp-chip.is-off em { font-style: normal; font-weight: 600; font-size: 0.72rem; }
.rp-tag {
  display: inline-block; padding: 1px 7px; border-radius: 4px; font-style: normal;
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0; text-transform: none;
  background: var(--dtmw-gray-100); color: var(--muted);
}
.rp-chip:focus-visible, .rp-file:focus-visible, .rp-date:focus-visible, .rp-side-link:focus-visible,
.rp-select:focus-visible, .md-body a:focus-visible, .md-table-wrap:focus-visible, .md-body tr[data-record]:focus-visible,
.rp-toc a:focus-visible {
  outline: 2px solid var(--dtmw-teal-500); outline-offset: 2px;
}

/* ===== Packet + changelog layout ========================================= */
.rp-viewer { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: var(--ant-gap); align-items: start; }
.rp-sidebar {
  position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 14px;
}
.rp-sidebar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 2px 4px 10px; }
.rp-sidebar-head span { font-size: 0.72rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--muted); }
.rp-sidebar-head strong { font-size: 0.8rem; color: var(--dtmw-gray-700); font-variant-numeric: tabular-nums; }

.rp-select-label { display: none; }
.rp-select { display: none; }

.rp-file-list { display: grid; gap: 4px; }
.rp-file {
  display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 1px 10px; align-items: center;
  padding: 8px 10px; border-radius: 6px; border: 1px solid transparent; text-decoration: none; color: var(--text);
}
.rp-file:hover { background: var(--dtmw-gray-50); border-color: var(--line); }
.rp-file-num {
  grid-row: span 2; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--line); font-size: 0.72rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums;
}
.rp-file strong { font-size: 0.86rem; line-height: 1.25; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-file small { font-size: 0.72rem; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-file.is-missing strong { color: var(--muted); font-weight: 600; }
.rp-file.active { background: var(--ant-ok-soft); border-color: var(--c-teal-2); }
.rp-file.active .rp-file-num { background: var(--dtmw-teal-600); border-color: var(--dtmw-teal-600); color: var(--on-fill); }

.rp-doc { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); min-width: 0; }
.rp-doc-head {
  display: flex; justify-content: space-between; gap: 18px; align-items: flex-start;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--line);
}
.rp-doc-head-main { min-width: 0; }
.rp-doc-kicker { font-size: 0.72rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--muted); }
.rp-doc-head h2 { margin: 6px 0 0; font-size: clamp(1.3rem, 2.2vw, 1.75rem); line-height: 1.15; letter-spacing: -0.015em; font-weight: 600; }
.rp-doc-head h2:focus { outline: none; }
.rp-doc-head h2:focus-visible { outline: 2px solid var(--dtmw-teal-500); outline-offset: 3px; border-radius: 2px; }
.rp-doc-lead { margin: 10px 0 0; max-width: 820px; font-size: 0.98rem; line-height: 1.55; color: var(--dtmw-gray-700); }

.rp-badge {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--c-teal-2); background: var(--ant-ok-soft); color: var(--ant-ok);
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0; text-transform: none; white-space: nowrap;
}
.rp-badge svg { width: 14px; height: 14px; }
.rp-badge[hidden] { display: none; }
.rp-badge.is-muted { border-color: var(--line-strong); background: var(--dtmw-gray-50); color: var(--muted); }
.rp-badge.is-risk { border-color: var(--risk-soft); background: var(--ant-risk-soft); color: var(--ant-risk); }

.rp-toc { padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--dtmw-gray-50); }
.rp-toc[hidden] { display: none; }
.rp-toc-label { display: block; margin-bottom: 6px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--muted); }
.rp-toc ol { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 6px; counter-reset: toc; }
.rp-toc li { counter-increment: toc; }
.rp-toc a {
  display: inline-block; padding: 3px 9px; border-radius: 5px; border: 1px solid var(--line); background: var(--bg);
  font-size: 0.8rem; font-weight: 600; color: var(--dtmw-gray-700); text-decoration: none;
}
.rp-toc a::before { content: counter(toc) ". "; color: var(--soft); font-variant-numeric: tabular-nums; }
.rp-toc a:hover { border-color: var(--dtmw-teal-500); color: var(--text); }

.rp-body { padding: 8px 24px 28px; }
.rp-loading { color: var(--muted); font-size: 0.9rem; }
.rp-notice {
  margin: 12px 0 0; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--ant-clay-line);
  background: var(--ant-clay-soft); color: var(--dtmw-gray-700); font-size: 0.86rem;
}
.rp-empty { display: grid; justify-items: start; gap: 10px; padding: 26px 0 8px; max-width: 640px; }
.rp-empty > svg { width: 28px; height: 28px; color: var(--soft); }
.rp-empty h3 { margin: 0; font-size: 1.08rem; font-weight: 600; }
.rp-empty p { margin: 0; color: var(--dtmw-gray-700); line-height: 1.55; font-size: 0.94rem; }
.rp-empty a:not(.rp-chip) { color: var(--dtmw-teal-600); font-weight: 600; }
.rp-empty-sub { margin: 6px 0 0; font-size: 0.84rem; color: var(--muted); }

/* Changelog jump list */
.rp-date-list { display: grid; gap: 4px; }
.rp-date {
  display: grid; gap: 2px; padding: 8px 10px; border-radius: 6px; border: 1px solid transparent;
  text-decoration: none; color: var(--text);
}
.rp-date strong { font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.rp-date span { font-size: 0.8rem; font-weight: 600; color: var(--dtmw-gray-700); }
.rp-date small { font-size: 0.74rem; color: var(--muted); line-height: 1.35; }
.rp-date:hover { background: var(--dtmw-gray-50); border-color: var(--line); }
.rp-date.active { background: var(--ant-ok-soft); border-color: var(--c-teal-2); }
.rp-side-link {
  display: inline-flex; align-items: center; gap: 6px; margin: 12px 4px 2px;
  font-size: 0.82rem; font-weight: 600; color: var(--dtmw-teal-600); text-decoration: none;
}
.rp-side-link svg { width: 15px; height: 15px; }
.rp-side-link:hover { text-decoration: underline; }

/* ===== Rendered markdown =================================================== */
.md-body { color: var(--dtmw-gray-700); line-height: 1.62; font-size: 0.95rem; overflow-wrap: anywhere; }
.md-body > * { max-width: 880px; }
.md-body > .md-table-wrap { max-width: 100%; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { position: relative; color: var(--text); line-height: 1.2; scroll-margin-top: 16px; }
.md-body h1 { margin: 22px 0 12px; font-size: 1.5rem; font-weight: 600; }
.md-body h2 {
  margin: 30px 0 10px; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em;
}
.md-body > h2:first-child { margin-top: 12px; padding-top: 0; border-top: 0; }
.md-body h3 { margin: 22px 0 8px; font-size: 1rem; font-weight: 600; }
.md-body h4 { margin: 18px 0 6px; font-size: 0.92rem; font-weight: 600; color: var(--dtmw-gray-700); }
.md-body h1:focus, .md-body h2:focus, .md-body h3:focus, .md-body h4:focus { outline: none; }
.md-anchor {
  display: inline-flex; vertical-align: middle; margin-left: 6px; padding: 2px; border-radius: 4px;
  color: var(--soft); opacity: 0; transition: opacity 120ms ease;
}
.md-anchor svg { width: 15px; height: 15px; }
.md-body :is(h1, h2, h3, h4):hover .md-anchor, .md-anchor:focus-visible { opacity: 1; }
.md-anchor:hover { color: var(--dtmw-teal-600); }
.md-body p { margin: 10px 0; }
.md-body a { color: var(--dtmw-teal-600); font-weight: 600; text-underline-offset: 2px; }
.md-body strong { color: var(--text); }
.md-body ul, .md-body ol { margin: 10px 0; padding-left: 22px; }
.md-body li { margin: 4px 0; }
.md-body li > ul, .md-body li > ol { margin: 4px 0; }
.md-body code {
  padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); background: var(--dtmw-gray-50);
  font-size: 0.86em; color: var(--text); overflow-wrap: anywhere;
}
.md-body pre {
  max-width: 100%; overflow: auto; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--dtmw-gray-50); font-size: 0.84rem; line-height: 1.5;
}
.md-body pre code { padding: 0; border: 0; background: transparent; overflow-wrap: normal; }
.md-body blockquote {
  margin: 14px 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--dtmw-gray-50); color: var(--dtmw-gray-700);
}
.md-body blockquote > :first-child { margin-top: 0; }
.md-body blockquote > :last-child { margin-bottom: 0; }
.md-body hr { border: 0; height: 1px; background: var(--line); margin: 22px 0; }
.md-body img { max-width: 100%; height: auto; border-radius: 6px; }

.md-table-wrap { margin: 14px 0 18px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.md-body table { width: 100%; border-collapse: collapse; font-size: 0.85rem; line-height: 1.45; }
.md-body th, .md-body td { padding: 8px 11px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.md-body th {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--muted);
  background: var(--dtmw-gray-50); white-space: nowrap;
}
.md-body td { min-width: 90px; }
.md-body tbody tr:last-child td { border-bottom: 0; }
.md-body th.num, .md-body td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.md-body table.has-records tbody tr { cursor: pointer; }
.md-body table.has-records tbody tr:hover td { background: var(--dtmw-gray-50); }
.md-body tr[data-record]:focus-visible { outline-offset: -2px; }

/* Changelog: dated entries read as a list of releases */
.md-log h2 { font-variant-numeric: tabular-nums; }
.md-log h3 { margin-top: 18px; font-size: 0.78rem; letter-spacing: 0; text-transform: none; color: var(--dtmw-teal-600); }

/* Row detail dialog */
.md-record {
  width: min(560px, calc(100vw - 32px)); max-height: min(80vh, 720px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--dtmw-shadow-md); color: var(--text);
}
.md-record::backdrop { background: rgba(13, 27, 42, 0.45); }
.md-record-head {
  position: sticky; top: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
  padding: 16px 18px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.md-record-kicker { font-size: 0.7rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--muted); }
.md-record h2 { margin: 4px 0 0; font-size: 1.1rem; line-height: 1.3; font-weight: 600; }
.md-record-fields { margin: 0; padding: 8px 18px 18px; display: grid; grid-template-columns: minmax(110px, 34%) minmax(0, 1fr); }
.md-record-fields dt, .md-record-fields dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; line-height: 1.45; }
.md-record-fields dt { padding-right: 14px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--muted); }
.md-record-fields dd { color: var(--dtmw-gray-700); overflow-wrap: anywhere; }
.md-record-fields a { color: var(--dtmw-teal-600); }

/* ===== Research Map ======================================================== */
/* Flat, hairline style: no boxed cards. --rm-color is set inline per cluster or section group. */
.rm-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--rm-color, var(--muted)); }

.rm-strip { display: flex; gap: 2px; height: 30px; border-radius: 4px; overflow: hidden; }
.rm-seg {
  flex-basis: 0; min-width: 6px; border: 0; padding: 0 8px; cursor: pointer;
  display: flex; align-items: center; font: inherit; font-size: 0.74rem; font-weight: 500; color: var(--on-fill);
  background: color-mix(in srgb, var(--rm-color) 28%, var(--bg)); transition: background-color 120ms ease;
}
.rm-seg span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.rm-seg:hover { background: color-mix(in srgb, var(--rm-color) 55%, var(--bg)); }
.rm-seg.is-on { background: var(--rm-color); }
.rm-seg.is-on span { color: var(--on-fill); }
.rm-strip-note { margin: 10px 0 0; min-height: 1.5em; font-size: 0.84rem; line-height: 1.5; color: var(--text-2); }
.rm-legend { align-items: center; margin-top: 8px; }
.rm-legend-total { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.rm-tabs { margin: 40px 0 28px; }
.rm-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.rm-layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 0 56px; align-items: start; }
.rm-layout[hidden] { display: none; }

/* Topic map: clusters of topic buttons. */
.rm-map { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px 28px; }
.rm-cluster { min-width: 0; }
.rm-cluster-head { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 0.92rem; font-weight: 600; letter-spacing: -0.01em; }
.rm-cluster-note { margin: 3px 0 10px; font-size: 0.78rem; line-height: 1.4; color: var(--muted); }
.rm-topics, .rm-section-list, .rm-where, .rm-docs { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.rm-topics > li, .rm-section-list > li, .rm-where > li, .rm-docs > li { border-bottom: 1px solid var(--line); }
.rm-topic {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 8px; margin: 0;
  border: 0; border-radius: 0; background: transparent; font: inherit; font-size: 0.88rem; line-height: 1.3;
  color: var(--text-2); text-align: left; cursor: pointer; transition: background-color 120ms ease, color 120ms ease;
}
.rm-topic svg { flex: none; width: 15px; height: 15px; color: var(--muted); }
.rm-topic:hover { color: var(--text); background: var(--surface); }
.rm-topic[aria-pressed="true"] { color: var(--text); font-weight: 600; background: var(--surface-2); }
.rm-topic[aria-pressed="true"] svg { color: var(--rm-color); }

/* Section list: one line per section. */
.rm-node {
  width: 100%; display: grid; grid-template-columns: 20px minmax(0, 1fr) 46px 64px; gap: 10px; align-items: center;
  padding: 8px 8px; margin: 0; border: 0; border-radius: 0; background: transparent; font: inherit; font-size: 0.86rem;
  color: var(--text-2); text-align: left; cursor: pointer; transition: background-color 120ms ease, color 120ms ease;
}
.rm-node:hover { color: var(--text); background: var(--surface); }
.rm-node[aria-pressed="true"] { color: var(--text); font-weight: 600; background: var(--surface-2); }
.rm-node-num { font-size: 0.76rem; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.rm-node-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-node-pages { font-size: 0.76rem; font-weight: 400; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.rm-node-bar { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.rm-node-bar span { display: block; height: 100%; background: var(--rm-color); }

@media (min-width: 1081px) and (min-height: 760px) {
  .rm-map, .rm-sections { position: sticky; top: 20px; }
}

/* Detail panel. */
.rm-detail { min-width: 0; }
.rm-detail-kicker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.84rem; font-weight: 500; color: var(--muted); }
.rm-detail-title { margin: 8px 0 10px; font-size: clamp(1.3rem, 2vw, 1.6rem); line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
.rm-detail-title:focus { outline: none; }
.rm-detail-what { margin: 0; max-width: 68ch; font-size: 0.96rem; line-height: 1.6; color: var(--text-2); }
.rm-facts { margin-top: 22px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rm-facts .ant-stat-value { font-size: 1.4rem; }

.rm-block { margin-top: 26px; min-width: 0; }
.rm-block h3 { display: flex; align-items: baseline; gap: 8px; margin: 0 0 10px; font-size: 0.86rem; font-weight: 600; color: var(--text); }
.rm-count { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.rm-muted { margin: 0; color: var(--muted); font-size: 0.86rem; }
.rm-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }

.rm-links { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px 22px; }
.rm-link {
  display: inline-flex; align-items: center; gap: 7px; font-size: 0.88rem; font-weight: 500; color: var(--text);
  text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px;
}
.rm-link svg { flex: none; width: 14px; height: 14px; color: var(--muted); }
a.rm-link:hover { color: var(--accent); text-decoration-color: var(--accent); }
.rm-link.is-off { color: var(--soft); text-decoration: none; }
.rm-link em, .rm-off { font-style: normal; font-size: 0.74rem; font-weight: 400; color: var(--soft); }

.rm-where-btn {
  width: 100%; display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 8px 0; border: 0; background: transparent; font: inherit; font-size: 0.86rem; line-height: 1.35;
  color: var(--text-2); text-align: left; cursor: pointer;
}
.rm-where-btn:hover .rm-where-name { color: var(--accent); }
.rm-where-pages { font-size: 0.76rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rm-docs > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 8px 0; }
.rm-docs a { display: inline-flex; align-items: baseline; gap: 10px; font-size: 0.86rem; line-height: 1.35; font-weight: 500; color: var(--text-2); text-decoration: none; }
.rm-docs a:hover { color: var(--accent); }
.rm-doc-num { min-width: 18px; font-size: 0.76rem; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }

.rm-inputs, .rm-flags { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.rm-inputs li { display: grid; gap: 3px; }
.rm-inputs code { justify-self: start; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--text); font-size: 0.78rem; }
.rm-inputs span { font-size: 0.82rem; line-height: 1.4; color: var(--text-2); }
.rm-flags li { font-size: 0.88rem; line-height: 1.45; }
.rm-flags a { color: var(--text-2); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.rm-flags a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.rm-more { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; font-size: 0.84rem; font-weight: 500; color: var(--accent); text-decoration: none; }
.rm-more svg { width: 14px; height: 14px; }
.rm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.rm-back { display: none; margin-top: 26px; }
.rm-actions .rm-back { margin-top: 0; }

/* Reverse table. */
.rm-reverse td { vertical-align: middle; }
.rm-rev-page a, .rm-page-off { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; white-space: nowrap; }
.rm-rev-page a { color: var(--text); text-decoration: none; }
.rm-rev-page a:hover { color: var(--accent); }
.rm-rev-page svg { width: 15px; height: 15px; color: var(--muted); }
.rm-page-off { color: var(--soft); }
.rm-page-off em { font-style: normal; font-size: 0.74rem; font-weight: 400; }
.rm-rev-chips { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.rm-sec-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 0; border: 0; background: transparent;
  font: inherit; font-size: 0.82rem; color: var(--text-2); cursor: pointer; white-space: nowrap;
}
.rm-sec-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--rm-color); }
.rm-sec-chip:hover { color: var(--accent); }
.rm-rev-docs { white-space: nowrap; }
.rm-rev-docs a {
  display: inline-block; min-width: 20px; margin-right: 6px; font-size: 0.8rem; color: var(--text-2); font-variant-numeric: tabular-nums;
  text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px;
}
.rm-rev-docs a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.rm-rev-docs a.is-off { color: var(--soft); text-decoration-style: dashed; }

.rm-topic:focus-visible, .rm-node:focus-visible, .rm-where-btn:focus-visible, .rm-sec-chip:focus-visible, .rm-tab:focus-visible,
.rm-detail a:focus-visible, .rm-reverse a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}

@media (max-width: 1080px) {
  .rm-layout { grid-template-columns: minmax(0, 1fr); }
  .rm-map { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .rm-detail { margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--line); }
  .rm-back { display: inline-flex; }
}
@media (max-width: 760px) {
  .rm-strip { height: 24px; }
  .rm-seg span { display: none; }
  .rm-legend-total { margin-left: 0; }
  .rm-tabs { margin-top: 32px; }
  .rm-map { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 16px; }
  .rm-topic { padding: 8px 4px; gap: 8px; font-size: 0.84rem; align-items: flex-start; }
  .rm-topic svg { margin-top: 1px; }
  .rm-node { grid-template-columns: 20px minmax(0, 1fr) 44px; padding: 9px 4px; }
  .rm-node-bar { display: none; }
  .rm-cols { grid-template-columns: minmax(0, 1fr); }
  .rm-facts .ant-stat-value { font-size: 1.2rem; }
}
@media (max-width: 359px) {
  .rm-map { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .rm-seg, .rm-topic, .rm-node { transition: none; }
}

/* ===== Responsive ========================================================== */
@media (max-width: 1080px) {
  .rp-viewer { grid-template-columns: minmax(0, 1fr); }
  .rp-sidebar { position: static; max-height: none; }
  .rp-file-list { display: none; }
  .rp-select-label {
    display: block; margin: 0 4px 6px; font-size: 0.8rem; font-weight: 600; color: var(--dtmw-gray-700);
  }
  .rp-select {
    display: block; width: 100%; padding: 9px 10px; font: inherit; font-size: 0.92rem; font-weight: 600;
    border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg); color: var(--text);
  }
  .rp-viewer-log .rp-date-list { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
@media (max-width: 760px) {
  .rp-doc-head { flex-direction: column; gap: 10px; padding: 16px 16px 14px; }
  .rp-toc { padding: 10px 16px; }
  .rp-body { padding: 4px 16px 22px; }
  .md-body > * { max-width: 100%; }
  .md-anchor { opacity: 1; }
  .md-record-fields { grid-template-columns: minmax(0, 1fr); }
  .md-record-fields dt { padding-bottom: 0; border-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .md-anchor { transition: none; }
}

/* Empty and error states sit inside .md-body; undo its prose spacing. */
.md-body .rp-empty { gap: 8px; }
.md-body .rp-empty h3, .md-body .rp-empty p { margin: 0; }
.md-body .rp-empty .rp-empty-sub { margin-top: 8px; }
.md-body .rp-empty .rp-chips { margin-top: -2px; }
.md-body a.rp-chip { color: var(--dtmw-gray-700); font-weight: 600; text-decoration: none; }
.md-body a.rp-chip:hover { color: var(--text); }

/* Outside sources in a topic's detail panel (rows are styled by css/pages/sources.css). */
.rm-ext-sum { margin: 0 0 4px; font-size: 0.84rem; color: var(--muted); line-height: 1.5; }
.rm-ext .ant-src-group:first-child { margin-top: 10px; }
.rm-ext .ant-src-more { margin-top: 12px; }
.rm-ext .rm-more { margin-top: 14px; }
.ant-lede a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.ant-lede a:hover { color: var(--accent); text-decoration-color: var(--accent); }
