:root {
  --ru-bg: #030507;
  --ru-panel: rgba(7, 11, 15, 0.9);
  --ru-panel-strong: rgba(12, 17, 22, 0.96);
  --ru-border: rgba(179, 202, 211, 0.18);
  --ru-border-strong: rgba(194, 218, 225, 0.34);
  --ru-text: #f0f4f2;
  --ru-muted: #91a19f;
  --ru-legal: #55d4bd;
  --ru-finance: #ddb86b;
  --ru-risk: #e87875;
  --ru-ice: #b7d0db;
}

body.research-universe-open { overflow: hidden; }

.research-universe {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  grid-template-rows: 82px minmax(0, 1fr);
  overflow: hidden;
  color: var(--ru-text);
  background: var(--ru-bg);
  font-family: "Avenir Next", "Source Han Sans SC", "Microsoft YaHei UI", sans-serif;
}

.research-universe[hidden] { display: none; }

.ru-topbar {
  position: relative;
  z-index: 8;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto minmax(320px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 26px;
  border-bottom: 1px solid var(--ru-border);
  background: rgba(4, 7, 10, 0.92);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.28);
  animation: ru-reveal 560ms ease-out both;
}

.ru-topbar::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 1px;
  content: "";
  background: rgba(220, 235, 237, 0.12);
}

.ru-identity,
.ru-actions,
.ru-stats { display: flex; align-items: center; }

.ru-identity { gap: 14px; min-width: 0; }
.ru-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--ru-border-strong);
  border-radius: 50%;
  color: var(--ru-ice);
  background: #090e12;
  box-shadow: inset 0 0 0 5px #05080a, 0 0 24px rgba(185, 218, 224, 0.12);
  font-family: "STSong", "Songti SC", serif;
  font-size: 17px;
  font-weight: 700;
}

.ru-identity-copy { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.ru-observatory-kicker {
  overflow: hidden;
  color: #7d908e;
  font-family: Optima, "Avenir Next", sans-serif;
  font-size: 9px;
  letter-spacing: 0;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ru-identity strong {
  margin-top: 5px;
  overflow: hidden;
  font-family: "STSong", "Songti SC", serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ru-identity span:last-child { margin-top: 3px; color: var(--ru-muted); font-size: 11px; }
.research-universe[data-type="legal"] .ru-mark { color: var(--ru-legal); border-color: rgba(85, 212, 189, 0.58); }
.research-universe[data-type="finance"] .ru-mark { color: var(--ru-finance); border-color: rgba(221, 184, 107, 0.58); }

.ru-stats { justify-content: center; gap: 10px; color: var(--ru-muted); font-size: 9px; }
.ru-stats span {
  position: relative;
  display: grid;
  min-width: 74px;
  padding: 7px 15px;
  border-right: 1px solid var(--ru-border);
  text-align: center;
}
.ru-stats span:first-child { border-left: 1px solid var(--ru-border); }
.ru-stats b {
  color: var(--ru-text);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 17px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.ru-actions { justify-content: flex-end; gap: 8px; }
.ru-actions button,
.chat-universe-open {
  min-height: 38px;
  border: 1px solid var(--ru-border);
  border-radius: 4px;
  color: #dce7e6;
  background: rgba(17, 24, 29, 0.78);
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}
.ru-actions button:not(.ru-icon-button) { padding: 0 15px; }
.ru-actions button:hover,
.chat-universe-open:hover { border-color: var(--ru-border-strong); color: #fff; background: #151d22; }
.ru-icon-button { display: grid; place-items: center; width: 38px; padding: 0; }
.ru-icon-button svg { width: 18px; height: 18px; }

.ru-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 338px; min-height: 0; }
.ru-stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: #030507;
  box-shadow: inset 0 0 180px rgba(0, 0, 0, 0.96);
}
.ru-stage::after {
  position: absolute;
  inset: 0;
  z-index: 4;
  content: "";
  pointer-events: none;
  box-shadow: inset 0 0 110px rgba(0, 0, 0, 0.82);
  background-image: repeating-linear-gradient(0deg, rgba(197, 218, 219, 0.018) 0, rgba(197, 218, 219, 0.018) 1px, transparent 1px, transparent 3px);
}
.ru-cosmos { position: absolute; inset: 0; z-index: 0; display: block; pointer-events: none; }
.ru-grid { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.ru-grid::before,
.ru-grid::after {
  position: absolute;
  content: "";
  background: rgba(176, 205, 211, 0.055);
}
.ru-grid::before { top: 0; bottom: 0; left: 50%; width: 1px; }
.ru-grid::after { top: 50%; right: 0; left: 0; height: 1px; }
.ru-observation-axis {
  position: absolute;
  inset: 22px;
  z-index: 1;
  border: 0;
  pointer-events: none;
}
.ru-observation-axis::before,
.ru-observation-axis::after {
  position: absolute;
  width: 32px;
  height: 32px;
  content: "";
  opacity: 0.48;
}
.ru-observation-axis::before { top: 0; left: 0; border-top: 1px solid #7fa9b7; border-left: 1px solid #7fa9b7; }
.ru-observation-axis::after { right: 0; bottom: 0; border-right: 1px solid #7fa9b7; border-bottom: 1px solid #7fa9b7; }
.ru-graph { position: absolute; inset: 0; z-index: 2; }
.ru-graph canvas { display: block; }
.ru-node-marker-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}
.ru-node-marker {
  position: absolute;
  display: grid;
  grid-template-columns: 30px max-content;
  align-items: center;
  gap: 6px;
  max-width: 170px;
  margin: 0;
  padding: 0;
  border: 0;
  color: #dfe9e8;
  background: transparent;
  font: inherit;
  text-align: left;
  transform: translate(-15px, -15px);
  transform-origin: 15px 15px;
  pointer-events: auto;
  cursor: pointer;
  transition: filter 160ms ease, opacity 160ms ease;
  animation: ru-node-arrive 420ms cubic-bezier(.2,.82,.2,1) both;
}
@keyframes ru-node-arrive {
  from { opacity: 0; }
  to { opacity: 1; }
}
.ru-node-marker[hidden] { display: none; }
.ru-node-marker:hover,
.ru-node-marker:focus-visible { z-index: 8; filter: brightness(1.35); outline: none; }
.ru-node-marker.is-selected { z-index: 10; filter: brightness(1.45); }
.ru-node-marker.is-selected .ru-node-marker-icon {
  border-color: #e8f4f1;
  box-shadow: inset 0 0 0 3px #071015, 0 0 0 1px rgba(232, 244, 241, 0.72), 0 0 22px var(--ru-node-color);
  transform: scale(1.14);
}
.ru-node-marker.is-selected .ru-node-marker-label { display: block; color: #f2f8f6; }
.ru-node-marker-layer[data-crowded="true"] .ru-node-marker[data-label="detail"] .ru-node-marker-label { display: none; }
.ru-node-marker-layer[data-crowded="true"] .ru-node-marker[data-label="detail"]:hover .ru-node-marker-label,
.ru-node-marker-layer[data-crowded="true"] .ru-node-marker[data-label="detail"]:focus-visible .ru-node-marker-label,
.ru-node-marker-layer[data-crowded="true"] .ru-node-marker.is-selected .ru-node-marker-label { display: block; }
.ru-node-marker-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid color-mix(in srgb, var(--ru-node-color) 78%, white 22%);
  border-radius: 50%;
  background: rgba(4, 9, 12, 0.94);
  box-shadow: inset 0 0 0 3px #071015, 0 0 0 1px rgba(3, 5, 7, 0.86), 0 0 14px color-mix(in srgb, var(--ru-node-color) 38%, transparent);
}
.ru-node-marker-icon::after {
  position: absolute;
  inset: -4px;
  border: 1px solid color-mix(in srgb, var(--ru-node-color) 28%, transparent);
  border-radius: 50%;
  content: "";
  opacity: 0.72;
}
.ru-node-marker-glyph {
  overflow: hidden;
  max-width: 24px;
  color: var(--ru-node-color);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  text-overflow: clip;
  text-transform: uppercase;
  white-space: nowrap;
}
.ru-node-marker-label {
  display: block;
  overflow: hidden;
  max-width: 132px;
  padding: 3px 5px;
  color: rgba(226, 235, 233, 0.86);
  background: rgba(3, 7, 9, 0.58);
  font-size: 9px;
  line-height: 1.35;
  text-overflow: ellipsis;
  text-shadow: 0 1px 5px #000;
  white-space: nowrap;
}
.ru-node-marker--source { grid-template-columns: 27px max-content; transform: translate(-13px, -13px); transform-origin: 13px 13px; }
.ru-node-marker--source .ru-node-marker-icon { width: 27px; height: 27px; }
.ru-node-marker--source .ru-node-marker-label { max-width: 92px; color: #91a6a2; font-size: 8px; }
.ru-node-marker--risk .ru-node-marker-label { color: #f0aaa5; }
.ru-node-marker--validation .ru-node-marker-label { color: #9ee0bd; }
.ru-node-marker[data-status="verified"] .ru-node-marker-icon::before {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 6px;
  height: 6px;
  border: 1px solid #071015;
  border-radius: 50%;
  content: "";
  background: #72dda0;
  box-shadow: 0 0 8px rgba(114, 221, 160, 0.75);
}
.ru-node-marker-layer[data-density="high"] .ru-node-marker-label { display: none; }
.ru-node-marker-layer[data-density="high"] .ru-node-marker.is-selected .ru-node-marker-label { display: block; }
.ru-node-marker-layer[data-density="high"] .ru-node-marker { grid-template-columns: 24px; transform: translate(-12px, -12px); transform-origin: 12px 12px; }
.ru-node-marker-layer[data-density="high"] .ru-node-marker-icon { width: 24px; height: 24px; }
.ru-graph .scene-tooltip {
  max-width: 320px;
  padding: 7px 10px;
  border: 1px solid var(--ru-border-strong);
  border-radius: 3px;
  color: #edf5f3;
  background: rgba(5, 9, 12, 0.94);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.5);
  font-size: 11px;
}
.ru-stage-note {
  position: absolute;
  left: 26px;
  bottom: 24px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid rgba(183, 208, 211, 0.14);
  border-radius: 3px;
  color: #a4b3b1;
  background: rgba(4, 8, 10, 0.84);
  font-size: 11px;
  pointer-events: none;
  animation: ru-rise 620ms 160ms ease-out both;
}
.ru-stage-note::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  content: "";
  background: var(--ru-legal);
  box-shadow: 0 0 10px currentColor;
  animation: ru-pulse 2.4s ease-in-out infinite;
}
.research-universe[data-type="finance"] .ru-stage-note::before { background: var(--ru-finance); }

.ru-feed-panel {
  position: relative;
  z-index: 6;
  min-width: 0;
  overflow: hidden;
  border-left: 1px solid var(--ru-border);
  background: var(--ru-panel);
  box-shadow: -26px 0 70px rgba(0, 0, 0, 0.2);
}
.ru-feed-panel::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 1px;
  content: "";
  background: rgba(203, 224, 225, 0.055);
}
.ru-feed-head { display: grid; gap: 7px; padding: 24px 22px 18px; border-bottom: 1px solid var(--ru-border); }
.ru-feed-head span { color: #718481; font-family: "JetBrains Mono", Consolas, monospace; font-size: 9px; letter-spacing: 0; }
.ru-feed-head b { font-family: "STSong", "Songti SC", serif; font-size: 17px; font-weight: 700; }
.ru-feed { height: calc(100% - 83px); margin: 0; padding: 5px 0; overflow: auto; list-style: none; }
.ru-feed-item {
  position: relative;
  display: grid;
  grid-template-columns: 37px minmax(0, 1fr);
  gap: 11px;
  padding: 14px 20px 14px 23px;
  border-bottom: 1px solid rgba(178, 203, 205, 0.08);
  transition: background 180ms ease;
}
.ru-feed-item:hover { background: rgba(157, 194, 193, 0.045); }
.ru-feed-item::before {
  position: absolute;
  top: 20px;
  left: 14px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  content: "";
  background: #7f9996;
}
.ru-feed-seq { color: #667a77; font-family: "JetBrains Mono", Consolas, monospace; font-size: 10px; }
.ru-feed-item div { min-width: 0; }
.ru-feed-item b { display: block; overflow: hidden; color: #dce7e4; font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.ru-feed-item small { display: block; margin-top: 5px; color: #758683; font-size: 9px; }

.ru-detail {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 7;
  width: min(410px, calc(100% - 48px));
  max-height: 54%;
  padding: 20px;
  overflow: auto;
  border: 1px solid var(--ru-border-strong);
  border-radius: 5px;
  background: var(--ru-panel-strong);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.62);
  animation: ru-rise 260ms ease-out both;
}
.ru-detail::before { display: block; width: 34px; height: 1px; margin-bottom: 14px; content: ""; background: var(--ru-legal); }
.research-universe[data-type="finance"] .ru-detail::before { background: var(--ru-finance); }
.ru-detail-head { display: flex; align-items: center; justify-content: space-between; color: #809390; font-size: 9px; text-transform: uppercase; }
.ru-detail-head button { width: 28px; height: 28px; border: 0; color: #aab9b7; background: transparent; font-size: 20px; cursor: pointer; }
.ru-detail h3 { margin: 13px 0 10px; font-family: "STSong", "Songti SC", serif; font-size: 19px; line-height: 1.5; }
.ru-detail p { color: #a7b5b3; font-size: 12px; line-height: 1.8; }
.ru-detail dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 17px 0; background: var(--ru-border); }
.ru-detail dl div { padding: 11px; background: #0e1519; }
.ru-detail dt { color: #71817f; font-size: 9px; }
.ru-detail dd { margin: 6px 0 0; color: #e3ece9; font-family: "JetBrains Mono", Consolas, monospace; font-size: 10px; }
.ru-detail a { color: #9ecbe1; font-size: 11px; }

.ru-report {
  position: absolute;
  inset: 20px;
  z-index: 8;
  padding: clamp(24px, 4vw, 64px);
  overflow: auto;
  border: 1px solid #d4d9d5;
  border-radius: 5px;
  color: #1b2535;
  background: #f8f9f7;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.72);
}
.research-universe.ru-report-mode .ru-graph,
.research-universe.ru-report-mode .ru-cosmos { opacity: 0.08; }
.research-universe.ru-report-mode .ru-stage-note { display: none; }

.chat-universe-open { display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; }
.chat-universe-open[hidden] { display: none; }
.chat-universe-open svg { width: 17px; height: 17px; }

@keyframes ru-reveal { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ru-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ru-pulse { 0%, 100% { opacity: 0.42; } 50% { opacity: 1; } }

@media (max-width: 820px) {
  .research-universe { grid-template-rows: 68px minmax(0, 1fr); }
  .ru-topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 0 11px; }
  .ru-mark { width: 38px; height: 38px; }
  .ru-observatory-kicker { display: none; }
  .ru-identity strong { margin-top: 0; font-size: 14px; }
  .ru-stats { display: none; }
  .ru-actions button:not(.ru-icon-button) { padding: 0 9px; font-size: 10px; }
  .ru-workspace { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 178px; }
  .ru-feed-panel { border-top: 1px solid var(--ru-border); border-left: 0; }
  .ru-feed-panel::before { display: none; }
  .ru-feed-head { padding: 9px 14px; }
  .ru-feed-head b { font-size: 14px; }
  .ru-feed { display: flex; height: 126px; overflow: auto hidden; }
  .ru-feed-item { flex: 0 0 220px; grid-template-columns: 32px minmax(0, 1fr); padding: 12px 14px 12px 22px; border-right: 1px solid var(--ru-border); border-bottom: 0; }
  .ru-observation-axis { inset: 10px; }
  .ru-node-marker { grid-template-columns: 25px; transform: translate(-12px, -12px); transform-origin: 12px 12px; }
  .ru-node-marker-icon,
  .ru-node-marker--source .ru-node-marker-icon { width: 25px; height: 25px; }
  .ru-node-marker-label { display: none; }
  .ru-stage-note { left: 14px; bottom: 14px; max-width: calc(100% - 28px); }
  .ru-detail { right: 0; bottom: 0; width: 100%; max-height: 66%; border-radius: 5px 5px 0 0; }
  .ru-report { inset: 8px; padding: 22px 18px; }
  .chat-universe-open span { display: none; }
  .chat-universe-open { width: 38px; padding: 0; justify-content: center; }
}

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