:root {
  color-scheme: dark;
  --bg-deep: #0c111d;
  --bg-panel: #151d2e;
  --bg-card: #161d2e;
  --bg-inset: #0f1626;
  --line: #2b3550;
  --line-control: #5d6984;
  --line-soft: #232c42;
  --grid: #263049;
  --fg: #e8e2d4;
  --fg-strong: #fff;
  --fg-mid: #8fa0bd;
  --fg-dim: #7f8ca6;
  --fg-faint: #8a96ad;
  --sel: #8ee0b8;
  --warn: #d9b45f;
  --shadow: 0 24px 70px rgb(0 0 0 / 0.34);
  font-family: system-ui, "PingFang SC", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg-deep);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--fg);
  background:
    radial-gradient(circle at 16% 4%, rgb(87 115 164 / 0.13), transparent 31rem),
    radial-gradient(circle at 82% 17%, rgb(74 117 109 / 0.09), transparent 28rem),
    linear-gradient(180deg, #101727 0, var(--bg-deep) 38rem);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  opacity: 0.25;
  background-image:
    linear-gradient(rgb(255 255 255 / 0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.009) 1px, transparent 1px);
  background-size: 4px 4px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: var(--sel);
}

:focus-visible {
  outline: 2px solid var(--sel);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  color: var(--bg-deep);
  background: var(--sel);
  border-radius: 6px;
  min-height: 44px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(1640px, 100%);
  margin: 0 auto;
  padding: 28px 28px 94px;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 2px 20px;
}

.eyebrow,
.section-kicker,
.subsection-label,
.legend-title {
  margin: 0;
  color: var(--fg-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-block h1 {
  margin: 4px 0 5px;
  font-family: "Songti SC", "STSong", system-ui, sans-serif;
  font-size: clamp(28px, 3vw, 44px);
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1;
}

.masthead-meta,
.map-instruction,
.text-view-heading > p {
  margin: 0;
  color: var(--fg-mid);
  font-size: 12px;
}

.header-note {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.layer-chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  color: var(--fg-mid);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.layer-l1::before,
.layer-l2::before {
  width: 5px;
  height: 5px;
  margin-right: 7px;
  content: "";
  border-radius: 50%;
  background: var(--sel);
}

.layer-l2::before {
  background: var(--warn);
}

.control-deck {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.5fr);
  gap: 22px;
  align-items: center;
  margin-bottom: 16px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(110deg, rgb(142 224 184 / 0.035), transparent 38%),
    rgb(17 24 39 / 0.82);
  box-shadow: 0 18px 48px rgb(0 0 0 / 0.2);
}

.control-intro h2 {
  margin: 4px 0 6px;
  font-size: 16px;
  font-weight: 600;
}

.control-intro > p:last-child {
  max-width: 48em;
  margin: 0;
  color: var(--fg-mid);
  font-size: 10.5px;
  line-height: 1.6;
}

.surname-controls {
  display: grid;
  grid-template-columns: minmax(210px, 0.7fr) minmax(0, 1.3fr);
  gap: 8px 12px;
  align-items: end;
}

.surname-search {
  display: grid;
  gap: 5px;
}

.surname-search > span {
  color: var(--fg-dim);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.surname-search input,
.timeline-controls input,
.timeline-controls select {
  width: 100%;
  min-height: 44px;
  padding: 0 11px;
  color: var(--fg);
  border: 1px solid var(--line-control);
  border-radius: 6px;
  background: var(--bg-inset);
}

.surname-search input::placeholder {
  color: var(--fg-faint);
}

.surname-presets {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.surname-preset,
.surname-option {
  display: inline-flex;
  min-width: 66px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 8px;
  color: var(--fg-mid);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.surname-preset strong,
.surname-option strong {
  color: var(--fg);
  font-size: 13px;
}

.surname-preset span,
.surname-option span {
  font-size: 8.5px;
  white-space: nowrap;
}

.surname-preset:hover,
.surname-option:hover,
.surname-preset.is-selected,
.surname-option.is-selected {
  color: var(--bg-deep);
  border-color: var(--sel);
  background: var(--sel);
}

.surname-preset.is-selected strong,
.surname-option.is-selected strong {
  color: var(--bg-deep);
}

.surname-preset:disabled,
.surname-option:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.selected-surnames {
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 7px;
}

.selected-empty,
.surname-status {
  color: var(--fg-faint);
  font-size: 10px;
  line-height: 1.5;
}

.selected-empty {
  color: var(--fg-mid);
  font-weight: 650;
}

.selected-surname {
  min-height: 32px;
  padding: 0 10px;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-inset);
  cursor: pointer;
}

.selected-surname.compare-1 {
  border-color: #8ee0b8;
}

.selected-surname.compare-2 {
  border-color: #e7a48f;
}

.surname-control-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.surname-browser {
  position: relative;
}

.surname-browser > summary,
.clear-surnames {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  padding: 0 10px;
  color: var(--fg-mid);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  list-style: none;
}

.surname-browser > summary::-webkit-details-marker {
  display: none;
}

.surname-options {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 30;
  display: grid;
  width: min(620px, 76vw);
  max-height: 292px;
  grid-template-columns: repeat(6, minmax(74px, 1fr));
  gap: 5px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid #3b4a6b;
  border-radius: 8px;
  background: rgb(15 22 38 / 0.98);
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.42);
}

.surname-option {
  justify-content: space-between;
}

.surname-status {
  grid-column: 1 / -1;
  min-height: 13px;
  margin: 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 382px;
  gap: 16px;
  min-height: 684px;
}

.map-panel,
.evidence-panel,
.text-view {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(17 24 39 / 0.88);
  box-shadow: var(--shadow);
}

.map-panel {
  min-width: 0;
}

.map-heading,
.text-view-heading {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 17px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgb(21 29 46 / 0.96), rgb(18 26 42 / 0.9));
}

.map-heading h2,
.text-view-heading h2 {
  margin: 3px 0 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.map-stage {
  position: relative;
  min-height: 614px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 56% 48%, rgb(73 94 136 / 0.13), transparent 42%),
    linear-gradient(180deg, var(--bg-panel), var(--bg-deep));
}

.map-stage::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.24;
  background:
    radial-gradient(circle, rgb(232 226 212 / 0.22) 0 0.6px, transparent 0.9px)
      0 0 / 24px 24px;
  mask-image: radial-gradient(ellipse, black 0, transparent 70%);
}

.migration-map {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  min-width: 760px;
  height: 614px;
  overflow: visible;
  pointer-events: none;
}

.migration-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  cursor: default;
}

.migration-canvas.has-hit {
  cursor: pointer;
}

.migration-canvas:focus-visible {
  outline: 2px solid var(--sel);
  outline-offset: -4px;
}

.grid-line {
  stroke: var(--grid);
  stroke-width: 0.6;
  opacity: 0.7;
}

.grid-label {
  fill: var(--fg-faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.route {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  opacity: 0.85;
  pointer-events: none;
  transition:
    opacity 150ms ease,
    stroke-width 150ms ease,
    stroke 150ms ease;
}

.route-comparison-halo {
  fill: none;
  stroke-width: 4.2;
  stroke-linecap: round;
  opacity: 0.35;
  pointer-events: none;
}

.route-comparison-halo.compare-2 {
  stroke-dasharray: 1 3;
}

.route-hit-area {
  fill: none;
  stroke: transparent;
  stroke-width: 12;
  stroke-linecap: round;
  cursor: pointer;
  pointer-events: stroke;
}

.route-hit-area:focus {
  outline: none;
}

.base-origin {
  opacity: 0.82;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.route.confidence-low,
.route.confidence-unknown {
  stroke-dasharray: 4 3;
  opacity: 0.65;
}

.route.is-hovered {
  stroke-width: 2.2;
  opacity: 1;
}

.route.is-muted,
.base-origin.is-muted,
.route.is-muted-selection,
.base-origin.is-muted-selection {
  opacity: 0.25;
}

.route.is-selected {
  stroke: var(--sel);
  stroke-width: 2.6;
  opacity: 1;
}

.route.is-muted {
  opacity: 0.25;
}

.route.is-hovered {
  stroke-width: 2.2;
  opacity: 1;
}

.route.is-selected.is-hovered {
  stroke-width: 2.6;
}

.route.is-filtered,
.base-origin.is-filtered {
  opacity: 0.08;
  pointer-events: none;
}

.route.is-keyboard-focused {
  stroke: var(--sel);
  stroke-width: 2;
  opacity: 1;
}

.selected-origin {
  fill: var(--sel);
  stroke: var(--bg-deep);
  stroke-width: 2;
}

.selected-destination {
  fill: var(--fg-strong);
  stroke: var(--sel);
  stroke-width: 2;
}

.place-label rect {
  fill: var(--bg-inset);
  stroke: #3b4a6b;
}

.place-label text {
  fill: var(--fg);
  font-size: 12px;
  font-weight: 600;
}

.legend {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 334px;
  padding: 10px 11px 9px;
  border: 1px solid rgb(59 74 107 / 0.82);
  border-radius: 8px;
  background: rgb(15 22 38 / 0.88);
  box-shadow: 0 12px 34px rgb(0 0 0 / 0.22);
  backdrop-filter: blur(10px);
}

.render-mode {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 4;
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 9px;
  color: var(--fg-mid);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(15 22 38 / 0.84);
  font-size: 9px;
  backdrop-filter: blur(8px);
}

.render-mode::before {
  width: 6px;
  height: 6px;
  margin-right: 7px;
  content: "";
  border-radius: 50%;
  background: var(--sel);
}

.render-mode.mode-canvas::before {
  background: #5f8fd9;
}

.render-mode.mode-aggregate::before {
  background: var(--warn);
}

.legend-title {
  margin: 0 0 7px;
}

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

.legend-item {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 0 8px;
  color: var(--fg-faint);
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
}

.legend-item:hover,
.legend-item.is-active {
  color: var(--fg);
  border-color: var(--line);
  background: rgb(255 255 255 / 0.035);
}

.legend-item:not(.is-active) .legend-swatch {
  opacity: 0.22;
}

.legend-swatch {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 2px;
  background: var(--swatch);
  box-shadow: 0 0 8px color-mix(in srgb, var(--swatch), transparent 45%);
}

.confidence-key {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 8px 0;
  color: var(--fg-mid);
  border-top: 1px solid var(--line-soft);
  font-size: 10px;
}

.comparison-key {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  padding: 6px 8px 0;
  color: var(--fg-mid);
  border-top: 1px solid var(--line-soft);
  font-size: 10px;
}

.comparison-key:empty {
  display: none;
}

.comparison-key span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.comparison-key i {
  width: 30px;
  border-top: 3px solid var(--compare-color);
}

.comparison-key .compare-2 i {
  border-top-style: dotted;
}

.confidence-line {
  width: 34px;
  border-top: 1.5px dashed var(--warn);
}

.bias-overview {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 3;
  width: min(430px, calc(100% - 28px));
  padding: 10px 11px;
  border: 1px solid rgb(59 74 107 / 0.72);
  border-radius: 8px;
  background: rgb(15 22 38 / 0.88);
  box-shadow: 0 12px 34px rgb(0 0 0 / 0.22);
  backdrop-filter: blur(10px);
}

.bias-overview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--fg-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.bias-overview-heading strong {
  color: var(--warn);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.bias-overview-heading b {
  font-weight: 700;
}

.bias-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 7px;
}

.bias-overview-grid p {
  margin: 0;
  color: var(--fg-mid);
  font-size: 10px;
  line-height: 1.45;
}

.bias-overview-grid span {
  display: block;
  margin-bottom: 2px;
  color: var(--fg);
  font-size: 10px;
  font-weight: 700;
}

.map-tooltip {
  position: absolute;
  z-index: 5;
  display: grid;
  gap: 2px;
  max-width: 220px;
  padding: 8px 10px;
  color: var(--fg);
  border: 1px solid #3b4a6b;
  border-radius: 6px;
  background: rgb(15 22 38 / 0.96);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.28);
  pointer-events: none;
  font-size: 11px;
}

.map-tooltip span {
  color: var(--fg-mid);
}

.empty-state,
.fatal-state {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 4;
  width: min(360px, calc(100% - 36px));
  padding: 22px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-card);
  transform: translate(-50%, -50%);
}

.empty-state button,
.fatal-state button {
  min-height: 44px;
  padding: 0 14px;
  color: var(--bg-deep);
  border: 0;
  border-radius: 6px;
  background: var(--sel);
  cursor: pointer;
}

.evidence-panel {
  width: 382px;
  min-height: 684px;
  overflow-y: auto;
  background:
    linear-gradient(145deg, rgb(39 49 72 / 0.18), transparent 34%),
    var(--bg-card);
}

.timeline-panel {
  padding: 14px 17px 13px;
  border-top: 1px solid var(--line-soft);
  background:
    linear-gradient(180deg, rgb(15 22 38 / 0.92), rgb(12 17 29 / 0.98));
}

.timeline-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.timeline-heading h3 {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 600;
}

.timeline-heading output {
  color: var(--fg);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.timeline-track-wrap {
  position: relative;
  height: 46px;
  margin-top: 8px;
}

.timeline-segments {
  position: absolute;
  inset: 6px 0 auto;
  display: flex;
  height: 23px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-inset);
}

.timeline-segment {
  position: relative;
  min-width: 2px;
  padding: 3px 4px;
  color: var(--fg);
  border-right: 1px solid rgb(12 17 29 / 0.48);
  font-size: 8px;
  transition: opacity 150ms ease;
}

.timeline-segment[data-dynasty="唐"] {
  background: #d98a5f;
}

.timeline-segment[data-dynasty="五代"] {
  background: #b06b8a;
}

.timeline-segment[data-dynasty="宋"] {
  background: #5f8fd9;
}

.timeline-segment[data-dynasty="元"] {
  background: #6fae8f;
}

.timeline-segment[data-dynasty="明"] {
  background: #d9b45f;
  color: var(--bg-deep);
}

.timeline-segment[data-dynasty="清"] {
  background: #8f7fd9;
}

.timeline-segment.is-muted {
  opacity: 0.18;
}

.timeline-segment b,
.timeline-segment i {
  display: block;
  overflow: hidden;
  font-style: normal;
  text-overflow: clip;
  white-space: nowrap;
}

.timeline-segment i {
  opacity: 0.72;
  font-size: 7px;
}

#timeline-range {
  position: absolute;
  inset: 26px 0 auto;
  z-index: 2;
  width: 100%;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--fg-strong);
}

#timeline-range::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
}

.timeline-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 7px;
}

.timeline-controls > button,
.zoom-controls button {
  min-height: 44px;
  padding: 0 12px;
  color: var(--fg-mid);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
}

.timeline-controls .playback-button {
  min-width: 86px;
  color: var(--bg-deep);
  border-color: var(--sel);
  background: var(--sel);
  font-weight: 700;
}

.timeline-controls label {
  display: grid;
  grid-template-columns: auto 104px;
  align-items: center;
  gap: 6px;
  color: var(--fg-dim);
  font-size: 9px;
}

.timeline-controls input,
.timeline-controls select {
  min-height: 44px;
  font-size: 11px;
}

.timeline-controls input.is-inactive::placeholder {
  color: var(--fg-faint);
}

.zoom-controls {
  display: flex;
  margin-left: auto;
}

.zoom-controls button {
  min-height: 44px;
  border-radius: 0;
}

.zoom-controls button:first-child {
  border-radius: 6px 0 0 6px;
}

.zoom-controls button:last-child {
  margin-left: -1px;
  border-radius: 0 6px 6px 0;
}

.zoom-controls button.is-active {
  color: var(--bg-deep);
  border-color: var(--warn);
  background: var(--warn);
}

.timeline-note {
  margin: 7px 0 0;
  color: var(--fg-faint);
  font-size: 9px;
}

.evidence-empty {
  display: grid;
  height: 100%;
  min-height: 680px;
  place-content: center;
  padding: 44px;
  text-align: center;
}

.evidence-empty h2 {
  margin: 12px 0 8px;
  font-size: 18px;
}

.evidence-empty > p:last-child {
  max-width: 25em;
  margin: 0;
  color: var(--fg-mid);
  font-size: 12px;
  line-height: 1.75;
}

.empty-orbit {
  position: relative;
  width: 76px;
  height: 76px;
  margin: 0 auto 26px;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.empty-orbit::before,
.empty-orbit::after {
  position: absolute;
  content: "";
  border-radius: 50%;
}

.empty-orbit::before {
  inset: 15px;
  border: 1px dashed #3b4a6b;
}

.empty-orbit::after {
  top: 7px;
  right: 15px;
  width: 7px;
  height: 7px;
  background: var(--sel);
  box-shadow: 0 0 18px var(--sel);
}

.evidence-card {
  position: relative;
  min-height: 100%;
  padding: 22px 20px 20px;
}

.drawer-handle {
  display: none;
}

.drawer-content {
  min-height: 100%;
}

.evidence-card:focus {
  outline: 2px solid rgb(142 224 184 / 0.72);
  outline-offset: -3px;
}

.dynasty-stripe {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--dynasty-color);
  box-shadow: 0 0 18px color-mix(in srgb, var(--dynasty-color), transparent 42%);
}

.card-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  color: var(--fg-mid);
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
}

.card-close:hover {
  color: var(--fg);
  border-color: var(--line);
  background: rgb(255 255 255 / 0.035);
}

.person-heading {
  padding-right: 42px;
}

.person-heading h2 {
  margin: 6px 0 3px;
  font-size: 20px;
  font-weight: 600;
}

.person-heading > p:last-child {
  margin: 0;
  color: var(--fg-mid);
  font-size: 11px;
}

.route-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 50px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  margin: 18px 0;
  padding: 13px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg-inset);
}

.route-summary > div:not(.route-arrow) {
  min-width: 0;
}

.route-summary strong,
.route-summary span {
  display: block;
}

.route-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.route-summary span {
  margin-top: 4px;
  color: var(--fg-faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.route-summary > div:last-child {
  text-align: right;
}

.route-arrow {
  position: relative;
  height: 18px;
}

.route-arrow i {
  position: absolute;
  top: 8px;
  right: 4px;
  left: 4px;
  height: 1px;
  background: linear-gradient(90deg, var(--line), var(--sel));
}

.route-arrow b {
  position: absolute;
  top: -5px;
  right: 0;
  color: var(--sel);
  font-size: 22px;
  font-weight: 400;
}

.normalization-section,
.work-section {
  padding-top: 17px;
  border-top: 1px solid var(--line-soft);
}

.subsection-label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.subsection-label span {
  padding: 2px 4px;
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn), transparent 48%);
  border-radius: 4px;
  letter-spacing: 0;
}

.evidence-fields {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 11px 9px;
  margin: 14px 0 18px;
  font-size: 11px;
}

.evidence-fields dt {
  color: var(--fg-dim);
}

.evidence-fields dd {
  min-width: 0;
  margin: 0;
  color: var(--fg);
  line-height: 1.55;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.pending-value {
  color: var(--warn);
}

.basis-text {
  color: var(--fg-mid) !important;
}

.confidence-display {
  display: flex;
  align-items: center;
  gap: 9px;
}

.confidence-track {
  width: 94px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line-soft);
}

.confidence-track i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--sel);
}

.confidence-medium .confidence-track i {
  width: 62%;
  background: var(--warn);
}

.confidence-low .confidence-track i {
  width: 30%;
  background: var(--warn);
}

.confidence-unknown .confidence-track i {
  width: 0;
}

.confidence-badge {
  padding: 2px 7px;
  color: var(--fg-mid);
  border: 1px dashed var(--fg-dim);
  border-radius: 4px;
  font-size: 10px;
}

.work-section h3 {
  margin: 10px 0 7px;
  font-family: "Songti SC", "STSong", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}

.work-description {
  margin: 0 0 12px;
  color: var(--fg-mid);
  font-size: 11.5px;
  line-height: 1.6;
}

.work-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.button-primary {
  color: var(--bg-deep);
  background: var(--sel);
}

.button-secondary {
  color: var(--fg);
  border-color: var(--line);
  background: transparent;
}

.button.is-disabled {
  color: var(--fg-faint);
  background: var(--line-soft);
  cursor: not-allowed;
}

.availability-note {
  color: var(--fg-faint);
  font-size: 10px;
}

.copy-status {
  min-height: 14px;
  margin: 5px 0 0;
  color: var(--sel);
  font-size: 9px;
}

.uri-section {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg-inset);
}

.uri-section p {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 6px;
  margin: 0;
  color: var(--fg-faint);
  font-size: 10px;
  line-height: 1.5;
}

.uri-section p + p {
  margin-top: 5px;
}

.uri-section span {
  color: var(--fg-dim);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.uri-section a {
  color: var(--fg-faint);
  word-break: break-all;
}

.lineage-warning {
  margin-top: 12px;
  padding: 7px 0 7px 11px;
  color: var(--fg-faint);
  border-left: 2px solid var(--warn);
  font-size: 10px;
  line-height: 1.6;
}

.intelligence-studio {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    radial-gradient(circle at 12% 0, rgb(95 143 217 / 0.07), transparent 26rem),
    rgb(17 24 39 / 0.88);
}

.intelligence-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 17px;
  border-bottom: 1px solid var(--line-soft);
}

.intelligence-heading h2 {
  margin: 4px 0 0;
  font-size: 16px;
}

.intelligence-heading > p {
  max-width: 54em;
  margin: 0;
  color: var(--fg-mid);
  font-size: 11px;
  line-height: 1.55;
}

.intelligence-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
}

.narrative-panel,
.qa-panel {
  min-width: 0;
  padding: 16px 17px 18px;
}

.qa-panel {
  border-left: 1px solid var(--line-soft);
}

.ai-panel-heading {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-panel-heading > div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.ai-panel-heading h3 {
  margin: 0;
  font-size: 14px;
}

.layer-tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 7px;
  border: 1px solid var(--layer-color);
  border-radius: 5px;
  color: var(--layer-color);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.tag-l1 {
  --layer-color: #6fae8f;
}

.tag-l3 {
  --layer-color: #5f8fd9;
}

.facts-toggle {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  color: var(--fg-mid);
  cursor: pointer;
  font-size: 10px;
}

.facts-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--sel);
}

.ai-boundary {
  min-height: 36px;
  margin: 7px 0 12px;
  color: var(--fg-mid);
  font-size: 10.5px;
  line-height: 1.55;
}

.narrative-scope-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin: 0 0 12px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg-inset);
}

.narrative-scope-form label {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.narrative-scope-form label > span {
  color: var(--fg-faint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.narrative-scope-form input,
.narrative-scope-form select,
.narrative-scope-form button {
  min-width: 0;
  min-height: 40px;
  padding: 0 9px;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgb(17 24 39 / 0.9);
  font-size: 10px;
}

.narrative-scope-form input[readonly] {
  color: var(--fg-mid);
}

.narrative-scope-form button {
  color: var(--bg-deep);
  border-color: var(--sel);
  background: var(--sel);
  cursor: pointer;
  font-weight: 750;
}

.narrative-scope-form button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.narrative-time-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 6px;
  align-items: end;
}

.narrative-time-fields > span {
  padding-bottom: 12px;
  color: var(--fg-faint);
}

#narrative-scope-status {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--fg-faint);
  font-size: 9.5px;
  line-height: 1.5;
}

.narrative-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.narrative-actions button,
.qa-form button,
.qa-presets button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
}

.narrative-actions button:not(:disabled),
.qa-form button {
  color: var(--bg-deep);
  border-color: var(--sel);
  background: var(--sel);
  font-weight: 750;
}

.narrative-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#ai-service-status,
.qa-service-status {
  color: var(--fg-faint);
  font-size: 10px;
}

.narrative-fragments {
  display: grid;
  max-height: 520px;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

.ai-empty {
  display: grid;
  min-height: 116px;
  place-content: center;
  gap: 5px;
  padding: 18px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--fg-mid);
}

.ai-empty strong {
  color: var(--fg);
  font-size: 12px;
}

.ai-empty span {
  font-size: 10px;
}

.narrative-policy-note {
  margin: 0;
  padding: 9px 11px;
  border: 1px solid rgb(217 180 95 / 0.36);
  border-radius: 8px;
  color: var(--fg-mid);
  background: rgb(217 180 95 / 0.07);
  font-size: 10px;
  line-height: 1.55;
}

.narrative-fragment {
  position: relative;
  padding: 11px 12px 11px 15px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg-inset);
}

.narrative-fragment::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
  border-radius: 8px 0 0 8px;
  background: var(--layer-color);
}

.narrative-fragment[data-layer="L1"] {
  --layer-color: #6fae8f;
}

.narrative-fragment[data-layer="L2"] {
  --layer-color: #d9b45f;
}

.narrative-fragment[data-layer="L3"] {
  --layer-color: #5f8fd9;
}

.narrative-fragment[data-layer="L4"] {
  --layer-color: #b06b8a;
  background: rgb(176 107 138 / 0.08);
}

.fragment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--layer-color);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.narrative-fragment > p {
  margin: 0;
  color: var(--fg);
  font-size: 11px;
  line-height: 1.62;
}

.narrative-fragment .fragment-basis,
.narrative-fragment .fragment-bias {
  margin-top: 7px;
  color: var(--fg-mid);
  font-size: 9.5px;
}

.narrative-fragment .fragment-bias {
  padding-left: 9px;
  border-left: 2px solid #5f8fd9;
}

.fragment-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.fragment-refs small {
  flex-basis: 100%;
  color: var(--fg-faint);
  font-size: 10px;
  line-height: 1.45;
}

.fragment-refs a {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  font-size: 10px;
}

.fragment-view-all {
  min-height: 36px;
  margin-top: 8px;
  padding: 0 10px;
  color: var(--sel);
  border: 1px solid color-mix(in srgb, var(--sel) 40%, var(--line));
  border-radius: 6px;
  background: rgb(142 224 184 / 0.05);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.qa-form {
  display: grid;
  gap: 6px;
}

.qa-form > label {
  color: var(--fg-dim);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.qa-form > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.qa-form input {
  min-width: 0;
  min-height: 44px;
  padding: 0 11px;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-inset);
}

.qa-presets {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 8px 0 6px;
}

.qa-presets button {
  min-height: 34px;
  flex: 0 0 auto;
  color: var(--fg-mid);
}

.qa-service-status {
  min-height: 16px;
  margin: 0 0 10px;
  line-height: 1.5;
}

.qa-answer {
  display: grid;
  gap: 8px;
}

.qa-facts,
.qa-inference {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg-inset);
}

.qa-facts {
  border-left: 3px solid #6fae8f;
}

.qa-facts h4 {
  margin: 0;
  padding: 10px 11px 8px;
  color: #8ee0b8;
  font-size: 10px;
}

#qa-facts {
  padding: 0 11px 11px;
}

#qa-facts p,
#qa-inference p {
  margin: 0;
  color: var(--fg-mid);
  font-size: 10.5px;
  line-height: 1.58;
}

#qa-facts p + p {
  margin-top: 8px;
}

.qa-model-fragment {
  display: grid;
  gap: 5px;
}

.qa-model-fragment > strong {
  color: #8ee0b8;
  font-size: 10px;
  letter-spacing: 0.04em;
}

#qa-facts a {
  margin-left: 5px;
  font-size: 9px;
}

.qa-inference {
  border-left: 3px solid #b06b8a;
  background: rgb(176 107 138 / 0.06);
}

.qa-inference summary {
  min-height: 42px;
  padding: 12px 11px;
  color: #cf9bb2;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

#qa-inference {
  padding: 0 11px 12px;
}

#qa-inference p {
  display: grid;
  gap: 6px;
}

#qa-inference strong {
  color: #cf9bb2;
  font-size: 10px;
}

#qa-inference small {
  color: var(--fg-faint);
  font-size: 10px;
}

.qa-unsupported {
  color: var(--warn) !important;
}

.qa-bias {
  margin-top: 10px !important;
  padding: 8px 9px;
  color: var(--fg-faint) !important;
  border-left: 2px solid var(--warn);
  background: rgb(217 180 95 / 0.05);
}

.qa-view-all {
  min-height: 40px;
  padding: 0 11px;
  color: var(--sel);
  border: 1px solid color-mix(in srgb, var(--sel) 40%, var(--line));
  border-radius: 6px;
  background: rgb(142 224 184 / 0.05);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.qa-evidence-control {
  display: grid;
  justify-items: start;
  gap: 5px;
}

.qa-evidence-control small {
  color: var(--fg-mid);
  font-size: 9.5px;
  line-height: 1.5;
}

.distribution-view {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    radial-gradient(circle at 85% 0, rgb(217 180 95 / 0.06), transparent 24rem),
    rgb(17 24 39 / 0.88);
}

.distribution-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 17px;
  border-bottom: 1px solid var(--line-soft);
}

.distribution-heading h2 {
  margin: 4px 0 0;
  font-size: 15px;
}

.distribution-heading > p {
  max-width: 52em;
  margin: 0;
  color: var(--fg-mid);
  font-size: 10px;
  line-height: 1.55;
}

.distribution-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.distribution-grid article {
  min-width: 0;
  padding: 14px 17px 16px;
}

.distribution-grid article + article {
  border-left: 1px solid var(--line-soft);
}

.distribution-grid .raw-place-card {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line-soft);
  border-left: 0;
}

.distribution-grid h3 {
  margin: 0 0 4px;
  font-size: 12px;
}

.distribution-grid article > p {
  min-height: 30px;
  margin: 0 0 10px;
  color: var(--fg-faint);
  font-size: 9px;
  line-height: 1.5;
}

.mini-bars {
  display: grid;
  gap: 6px;
}

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

.raw-place-columns > section {
  min-width: 0;
}

.raw-place-columns > section + section {
  margin-left: 22px;
  padding-left: 22px;
  border-left: 1px solid var(--line-soft);
}

.raw-place-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.raw-place-heading h4 {
  margin: 0;
  color: var(--fg-mid);
  font-size: 10px;
  font-weight: 600;
}

.raw-place-heading span {
  color: var(--fg-faint);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.mini-bar {
  display: grid;
  grid-template-columns: 76px minmax(20px, 1fr) 44px;
  gap: 7px;
  align-items: center;
  font-size: 9px;
}

.mini-bar > span {
  overflow: hidden;
  color: var(--fg-mid);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-bar > i {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line-soft);
}

.mini-bar > i > b {
  display: block;
  height: 100%;
  min-width: 1px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sel), #5f8fd9);
}

.mini-bar > strong {
  text-align: right;
  color: var(--fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pattern-view {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgb(95 143 217 / 0.06), transparent 42%),
    rgb(17 24 39 / 0.9);
}

.pattern-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 17px;
  border-bottom: 1px solid var(--line-soft);
}

.pattern-heading h2 {
  margin: 4px 0 0;
  font-size: 16px;
}

.pattern-heading > p {
  max-width: 48em;
  margin: 0;
  color: var(--fg-mid);
  font-size: 10px;
  line-height: 1.55;
}

.pattern-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.pattern-explanation {
  padding: 12px 17px;
  border-bottom: 1px solid var(--line-soft);
  background: rgb(95 143 217 / 0.05);
}

.pattern-explanation > strong {
  color: var(--sel);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.pattern-explanation > p {
  margin: 4px 0 0;
  color: var(--fg-faint);
  font-size: 9px;
  line-height: 1.55;
}

.pattern-explanation ul {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.pattern-explanation li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--fg-mid);
  font-size: 9px;
  line-height: 1.55;
}

.pattern-explanation li a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--sel);
  font-size: 8px;
  text-underline-offset: 2px;
}

.pattern-explanation small {
  display: block;
  margin-top: 9px;
  color: var(--fg-faint);
  font-size: 8px;
  line-height: 1.5;
}

.pattern-explanation[data-status="stale"],
.pattern-explanation[data-status="invalid"] {
  background: rgb(217 180 95 / 0.05);
}

.pattern-card {
  min-width: 0;
  padding: 16px 17px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.pattern-card:not(:nth-child(3n + 1)) {
  border-left: 1px solid var(--line-soft);
}

.pattern-card:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.pattern-card h3 {
  margin: 0 0 5px;
  font-size: 12px;
}

.pattern-card > p {
  min-height: 46px;
  margin: 0 0 12px;
  color: var(--fg-faint);
  font-size: 9px;
  line-height: 1.55;
}

.pattern-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pattern-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 9px;
  align-items: center;
}

.pattern-list li > div {
  display: flex;
  min-width: 0;
  justify-content: space-between;
  gap: 8px;
  grid-column: 1 / -1;
}

.pattern-list strong {
  overflow: hidden;
  color: var(--fg-mid);
  font-size: 9px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pattern-list span {
  flex: 0 0 auto;
  color: var(--fg-faint);
  font-size: 8px;
  font-variant-numeric: tabular-nums;
}

.pattern-list i {
  display: block;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line-soft);
}

.pattern-list i b {
  display: block;
  height: 100%;
  min-width: 1px;
  border-radius: inherit;
  background: linear-gradient(90deg, #5f8fd9, var(--sel));
}

.pattern-list a {
  color: var(--sel);
  font-size: 8px;
  text-underline-offset: 2px;
}

.pattern-card-bias {
  display: block;
  margin-top: 12px;
  padding-top: 9px;
  color: var(--fg-faint);
  border-top: 1px solid var(--line-soft);
  font-size: 8px;
  line-height: 1.5;
}

.pattern-method {
  margin: 0;
  padding: 10px 17px;
  color: var(--fg-faint);
  border-top: 1px solid var(--line-soft);
  font-size: 9px;
  line-height: 1.55;
}

.pattern-loading,
.pattern-empty {
  color: var(--fg-faint);
  font-size: 10px;
}

.text-view {
  margin-top: 16px;
  box-shadow: none;
}

.text-view-heading {
  cursor: pointer;
  list-style: none;
}

.text-view-heading::-webkit-details-marker {
  display: none;
}

.text-view-action {
  color: var(--sel);
  font-size: 11px;
}

.text-view[open] .text-view-action {
  font-size: 0;
}

.text-view[open] .text-view-action::before {
  content: "收起表格";
  font-size: 11px;
}

.text-view:not([open]) .table-scroll {
  display: none;
}

.text-view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-inset);
}

.text-view-toolbar p {
  margin: 0;
  color: var(--fg-mid);
  font-size: 10px;
}

.text-view-toolbar button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--bg-deep);
  border: 0;
  border-radius: 6px;
  background: var(--sel);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.table-scroll {
  max-height: 620px;
  overflow-x: auto;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
}

thead {
  color: var(--fg-dim);
  background: var(--bg-inset);
}

tbody tr:hover {
  background: rgb(255 255 255 / 0.025);
}

.table-event-button {
  min-width: 44px;
  min-height: 34px;
  padding: 0;
  text-align: left;
  color: var(--sel);
  border: 0;
  background: transparent;
  cursor: pointer;
}

.bias-note {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 24px;
  color: var(--fg-faint);
  border-top: 1px solid var(--line-soft);
  background: rgb(12 17 29 / 0.94);
  box-shadow: 0 -8px 26px rgb(0 0 0 / 0.28);
  backdrop-filter: blur(12px);
  font-size: 10px;
}

.bias-note p {
  margin: 0;
  line-height: 1.45;
}

.bias-marker {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border: 1px solid var(--warn);
  border-radius: 50%;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1080px) {
  .control-deck {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) 360px;
  }

  .evidence-panel {
    width: 360px;
  }

  .map-stage {
    overflow-x: auto;
  }
}

@media (max-width: 800px) {
  .app-shell {
    padding: 18px 12px 112px;
  }

  .masthead {
    align-items: flex-start;
  }

  .header-note,
  .map-instruction {
    display: none;
  }

  .control-deck {
    gap: 14px;
    padding: 14px;
  }

  .surname-controls {
    grid-template-columns: 1fr;
  }

  .surname-presets {
    grid-column: 1;
  }

  .surname-control-actions {
    justify-content: space-between;
  }

  .surname-options {
    position: fixed;
    top: 84px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100vh - 176px);
    grid-template-columns: repeat(3, minmax(86px, 1fr));
  }

  .workspace {
    display: block;
    min-height: 0;
  }

  .map-stage {
    height: 60vh;
    min-height: 0;
    overflow: hidden;
  }

  .migration-map {
    width: 100%;
    min-width: 0;
    height: 100%;
  }

  .legend {
    display: flex;
    align-items: center;
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    gap: 5px;
    overflow-x: auto;
    padding: 7px;
  }

  .render-mode {
    top: 72px;
    left: 10px;
  }

  .legend-title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .legend-items {
    display: flex;
    flex: 0 0 auto;
    width: max-content;
  }

  .legend-item {
    min-width: 57px;
    min-height: 44px;
    justify-content: center;
    border-radius: 999px;
  }

  .confidence-key {
    flex: 0 0 auto;
    width: max-content;
    min-height: 34px;
    margin-top: 0;
    padding: 4px 8px;
    border-top: 0;
    border-left: 1px solid var(--line-soft);
  }

  .comparison-key {
    flex: 0 0 auto;
    grid-auto-flow: column;
    width: max-content;
    margin-top: 0;
    padding: 4px 8px;
    border-top: 0;
    border-left: 1px solid var(--line-soft);
  }

  .evidence-panel {
    position: relative;
    z-index: 8;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    margin-top: -14px;
    overflow: visible;
    border-radius: 16px 16px 12px 12px;
    box-shadow: 0 -24px 60px rgb(0 0 0 / 0.42);
  }

  .evidence-panel.has-selection {
    position: fixed;
    right: 0;
    bottom: 72px;
    left: 0;
    z-index: 40;
    width: auto;
    height: min(72dvh, 680px);
    max-height: none;
    margin: 0;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    transform: translateY(calc(100% - 188px));
    transition: transform 180ms ease;
    overscroll-behavior: contain;
  }

  .evidence-panel.has-selection.is-expanded {
    transform: translateY(0);
  }

  .timeline-panel {
    padding: 13px 12px;
  }

  .timeline-heading {
    align-items: flex-start;
  }

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

  .timeline-controls > button,
  .timeline-controls label,
  .zoom-controls {
    width: 100%;
  }

  .timeline-controls label {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .zoom-controls {
    margin-left: 0;
  }

  .zoom-controls button {
    width: 50%;
  }

  .evidence-empty {
    min-height: 186px;
    padding: 26px;
  }

  .empty-orbit {
    display: none;
  }

  .evidence-card {
    min-height: 100%;
    padding: 0;
  }

  .drawer-handle {
    position: sticky;
    top: 0;
    z-index: 6;
    display: grid;
    width: 100%;
    min-height: 48px;
    place-items: center;
    gap: 3px;
    padding: 5px 16px 6px;
    color: var(--fg-mid);
    border: 0;
    border-bottom: 1px solid var(--line-soft);
    background: rgb(22 29 46 / 0.97);
    cursor: ns-resize;
    touch-action: none;
  }

  .drawer-grip {
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: var(--line);
  }

  .drawer-handle-label {
    font-size: 9px;
  }

  .drawer-content {
    position: relative;
    min-height: calc(100% - 48px);
    padding: 18px 16px;
  }

  .button,
  .table-event-button {
    min-height: 44px;
  }

  .selected-surname,
  .surname-browser > summary,
  .clear-surnames,
  .facts-toggle,
  .narrative-actions button,
  .qa-form button,
  .qa-presets button,
  .text-view-toolbar button,
  .pattern-list a,
  .pattern-explanation li a {
    min-height: 44px;
  }

  .pattern-explanation li a {
    min-width: 44px;
  }

  .qa-inference summary,
  .uri-section a {
    min-height: 44px;
  }

  .uri-section a,
  .fragment-refs a {
    display: inline-flex;
    min-width: 44px;
    align-items: center;
  }

  .facts-toggle input {
    width: 24px;
    height: 24px;
  }

  .timeline-track-wrap {
    height: 58px;
  }

  #timeline-range {
    inset: 14px 0 auto;
    height: 44px;
  }

  .text-view {
    margin-top: 12px;
  }

  .intelligence-heading {
    display: block;
  }

  .intelligence-heading > p {
    margin-top: 8px;
  }

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

  .qa-panel {
    border-top: 1px solid var(--line-soft);
    border-left: 0;
  }

  .narrative-panel,
  .qa-panel {
    padding: 14px;
  }

  .ai-panel-heading {
    align-items: flex-start;
  }

  .narrative-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .narrative-scope-form {
    grid-template-columns: 1fr;
  }

  .narrative-scope-form input,
  .narrative-scope-form select,
  .narrative-scope-form button {
    min-height: 44px;
  }

  .narrative-actions button,
  .qa-form button,
  .qa-presets button,
  .fragment-view-all,
  .qa-view-all,
  .fragment-refs a {
    min-height: 44px;
  }

  .narrative-fragments {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .distribution-heading {
    display: block;
  }

  .distribution-heading > p {
    margin-top: 8px;
  }

  .distribution-grid {
    display: grid;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .distribution-grid article {
    min-width: 0;
  }

  .distribution-grid article + article {
    border-top: 1px solid var(--line-soft);
    border-left: 0;
  }

  .raw-place-columns {
    grid-template-columns: 1fr;
  }

  .raw-place-columns > section + section {
    margin-top: 14px;
    margin-left: 0;
    padding-top: 14px;
    padding-left: 0;
    border-top: 1px solid var(--line-soft);
    border-left: 0;
  }

  .pattern-heading {
    display: block;
  }

  .pattern-heading > p {
    margin-top: 8px;
  }

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

  .pattern-card,
  .pattern-card:nth-last-child(-n + 3) {
    border-bottom: 1px solid var(--line-soft);
    border-left: 0;
  }

  .pattern-card:last-child {
    border-bottom: 0;
  }

  .pattern-card > p {
    min-height: 0;
  }

  .pattern-list a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .text-view-heading > p {
    display: none;
  }

  .bias-overview {
    display: none;
  }

  .bias-overview-grid {
    grid-template-columns: repeat(3, 160px);
    overflow-x: auto;
  }

  .bias-note {
    z-index: 50;
    min-height: 72px;
    align-items: flex-start;
    padding: 10px 14px;
    font-size: 10px;
  }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
