:root {
  color-scheme: dark;
  --bg: #070b10;
  --surface: #0d141c;
  --surface-2: #121c26;
  --surface-3: #172332;
  --text: #eef5f7;
  --muted: #9badb8;
  --soft: #cad7de;
  --line: rgba(168, 197, 213, 0.18);
  --line-strong: rgba(168, 197, 213, 0.32);
  --link: #7dd3fc;
  --accent: #41d6b3;
  --accent-2: #d7f171;
  --danger: #ffb86b;
  --code: #182330;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --module-shell-width: min(1580px, calc(100% - 40px));
  --module-panel-radius: 8px;
  --module-control-radius: 6px;
  --module-topbar-bg: color-mix(in srgb, var(--surface) 91%, transparent);
  --module-panel-bg: color-mix(in srgb, var(--surface) 84%, transparent);
  --module-side-bg: color-mix(in srgb, var(--surface) 91%, transparent);
  --module-control-bg: color-mix(in srgb, var(--surface) 86%, var(--bg));
  --module-panel-shadow: 0 18px 54px rgba(31, 41, 55, 0.1);
  --module-grid-line: color-mix(in srgb, var(--line) 40%, transparent);
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8f7;
  --surface: #ffffff;
  --surface-2: #eef4f4;
  --surface-3: #e5eef1;
  --text: #16212a;
  --muted: #5d6f7a;
  --soft: #394b55;
  --line: rgba(32, 62, 72, 0.14);
  --line-strong: rgba(32, 62, 72, 0.24);
  --link: #08769b;
  --accent: #0f927a;
  --accent-2: #687a16;
  --code: #edf2f2;
  --shadow: 0 20px 56px rgba(28, 48, 58, 0.14);
  --module-topbar-bg: color-mix(in srgb, var(--surface) 91%, transparent);
  --module-panel-bg: color-mix(in srgb, var(--surface) 84%, transparent);
  --module-side-bg: color-mix(in srgb, var(--surface) 91%, transparent);
  --module-control-bg: color-mix(in srgb, var(--surface) 86%, var(--bg));
  --module-panel-shadow: 0 18px 48px rgba(28, 48, 58, 0.11);
  --module-grid-line: color-mix(in srgb, var(--line) 48%, transparent);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.72 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input {
  font: inherit;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-weight: 760;
  min-width: 0;
}

.brand-mark:hover {
  text-decoration: none;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 0 0 5px rgba(65, 214, 179, 0.11);
  flex: 0 0 auto;
}

/* Landing page */
.landing-page {
  background: #071019;
  color: #edf7f8;
}

.landing-nav {
  position: fixed;
  z-index: 20;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1120px, calc(100% - 32px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 12px 10px 16px;
  border: 1px solid rgba(222, 241, 246, 0.18);
  border-radius: 999px;
  background: rgba(6, 13, 19, 0.76);
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.25);
}

.landing-nav nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.landing-nav nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  color: #dcebed;
  font-size: 14px;
}

.landing-nav .tool-button {
  border-color: rgba(222, 241, 246, 0.18);
  background: transparent;
  color: #dcebed;
}

.landing-nav .product-nav-link:hover {
  background: #e9fbff;
  color: #071019;
  text-decoration: none;
}

.landing-hero {
  position: relative;
  min-height: 86svh;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 420px);
  gap: min(6vw, 72px);
  align-items: center;
  padding: 132px min(7vw, 96px) 74px;
}

.hero-image,
.hero-scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-image {
  object-fit: cover;
  object-position: center right;
}

.hero-scrim {
  background: rgba(2, 8, 14, 0.6);
}

.hero-copy,
.preview-card {
  position: relative;
  z-index: 1;
}

.hero-copy {
  max-width: 720px;
}

.eyebrow,
.section-head span,
.preview-card span {
  color: #9ee8d9;
  font-size: 13px;
  font-weight: 760;
  letter-spacing: 0;
}

.hero-copy h1 {
  margin: 14px 0 18px;
  max-width: 780px;
  font-size: clamp(48px, 7vw, 88px);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-lead {
  max-width: 660px;
  margin: 0;
  color: #d8e6ea;
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.68;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.primary-action,
.secondary-action,
.link-action,
.rail-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 6px;
  font-weight: 740;
}

.primary-action {
  background: #e7faff;
  color: #071019;
}

.secondary-action {
  border: 1px solid rgba(230, 244, 247, 0.35);
  color: #effbff;
  background: rgba(255, 255, 255, 0.07);
}

.link-action {
  color: #cff7ef;
}

.preview-card {
  padding: 24px;
  border: 1px solid rgba(226, 245, 250, 0.2);
  border-radius: 8px;
  background: rgba(7, 14, 20, 0.78);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.preview-card h2 {
  margin: 8px 0 10px;
  font-size: 27px;
  line-height: 1.22;
}

.preview-card p {
  margin: 0 0 20px;
  color: #c2d4dc;
}

.preview-card .primary-action,
.preview-card .link-action {
  width: 100%;
  margin-top: 10px;
}

.landing-band {
  padding: 72px min(7vw, 96px);
  background: #f7faf9;
  color: #16242c;
}

.section-head {
  max-width: 760px;
  margin-bottom: 28px;
}

.section-head span {
  color: #0f927a;
}

.section-head h2 {
  margin: 8px 0 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.15;
}

.scope-grid,
.entry-grid,
.stat-grid {
  display: grid;
  gap: 14px;
}

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

.scope-grid article,
.entry-grid a,
.stat-grid div {
  border: 1px solid rgba(27, 65, 76, 0.14);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 46px rgba(27, 65, 76, 0.08);
}

.scope-grid article {
  padding: 24px;
}

.scope-grid strong,
.entry-grid b {
  color: #11232b;
  font-size: 18px;
}

.scope-grid p {
  margin: 10px 0 0;
  color: #546a75;
}

.stats-band {
  padding-top: 30px;
  padding-bottom: 30px;
  background: #10202a;
  color: #eef7f8;
}

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

.stat-grid div {
  padding: 22px;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

.stat-grid strong {
  display: block;
  font-size: 34px;
  line-height: 1;
}

.stat-grid span {
  color: #b8cbd2;
  font-size: 14px;
}

.entry-band {
  background: #eef4f4;
}

.entry-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.entry-grid a {
  min-height: 150px;
  padding: 22px;
  color: inherit;
}

.entry-grid a:hover {
  border-color: rgba(15, 146, 122, 0.45);
  text-decoration: none;
}

.entry-grid span {
  display: block;
  margin-top: 10px;
  color: #596d77;
}

.landing-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px min(7vw, 96px);
  color: #aabdc5;
  background: #071019;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Wiki shell */
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-actions,
.landing-product-nav {
  scrollbar-width: none;
}

.topbar-actions::-webkit-scrollbar,
.landing-product-nav::-webkit-scrollbar {
  display: none;
}

.tool-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.tool-button:hover {
  border-color: var(--line-strong);
  text-decoration: none;
}

.product-nav-link.active {
  border-color: color-mix(in srgb, var(--accent) 62%, var(--line));
  background: var(--text);
  color: var(--bg);
  font-weight: 760;
  flex: 0 0 auto;
}

.topbar-secondary {
  color: var(--soft);
}

.wiki-layout {
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr) 280px;
  gap: 28px;
  max-width: 1680px;
  margin: 0 auto;
  padding: 26px 26px 80px;
}

body.wide .wiki-layout {
  max-width: 1920px;
  grid-template-columns: 300px minmax(0, 1fr) 300px;
}

.sidebar,
.right-rail {
  position: sticky;
  top: 82px;
  align-self: start;
  max-height: calc(100svh - 104px);
  overflow: auto;
}

.sidebar {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sidebar-title {
  padding-bottom: 14px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.sidebar-title a {
  display: block;
  color: var(--text);
  font-weight: 780;
}

.sidebar-title span {
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 3px;
}

.nav a {
  display: flex;
  min-height: 34px;
  align-items: center;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--soft);
  font-size: 14px;
}

.nav a:hover,
.nav a.active {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.page {
  min-width: 0;
  padding: 4px 0 40px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.breadcrumb a::after {
  content: "/";
  color: var(--muted);
  margin-left: 8px;
}

.article-prologue {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
}

.article-prologue span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface);
}

.article-prologue .kicker {
  color: var(--accent);
}

.content {
  max-width: 900px;
  min-width: 0;
}

body.wide .content {
  max-width: 1080px;
}

.content h1 {
  margin: 0 0 22px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.12;
  letter-spacing: 0;
}

.content h2 {
  margin: 46px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 25px;
  line-height: 1.28;
}

.content h3 {
  margin: 30px 0 10px;
  font-size: 19px;
  line-height: 1.35;
}

.content p,
.content ul,
.content ol,
.content blockquote,
.table-wrap {
  margin: 14px 0;
}

.content ul,
.content ol {
  padding-left: 1.25em;
}

.content li + li {
  margin-top: 5px;
}

.content blockquote {
  border-left: 4px solid var(--accent);
  padding: 6px 0 6px 16px;
  color: var(--muted);
  background: var(--surface);
}

.content code {
  background: var(--code);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  color: var(--soft);
}

.content pre {
  overflow: auto;
  background: var(--code);
  padding: 16px;
  border-radius: 8px;
}

/* Wiki home */
.wiki-home-page .content {
  max-width: 1080px;
}

body.wide.wiki-home-page .content {
  max-width: 1220px;
}

.home-hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.75fr);
  gap: 24px;
  align-items: stretch;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface-2) 82%, transparent), color-mix(in srgb, var(--surface) 94%, transparent)),
    var(--surface);
  box-shadow: var(--shadow);
}

.home-eyebrow,
.home-section-head span,
.home-final-panel span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 760;
}

.home-hero-panel h1 {
  margin: 10px 0 16px;
  max-width: 820px;
  font-size: clamp(38px, 5vw, 66px);
  line-height: 1.06;
  letter-spacing: 0;
}

.home-hero-panel p {
  max-width: 760px;
  margin: 0;
  color: var(--soft);
  font-size: 17px;
  line-height: 1.75;
}

.home-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.wiki-home-page .primary-action,
.wiki-home-page .secondary-action {
  min-height: 40px;
}

.wiki-home-page .primary-action {
  background: var(--accent);
  color: #061017;
}

.wiki-home-page .secondary-action {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

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

.home-metric {
  display: flex;
  min-height: 92px;
  flex-direction: column;
  justify-content: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.home-metric strong {
  display: block;
  color: var(--text);
  font-size: 30px;
  line-height: 1;
}

.home-metric span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.home-section {
  margin-top: 42px;
}

.home-section-head {
  margin-bottom: 16px;
}

.home-section-head h2,
.home-final-panel h2 {
  margin: 5px 0 0;
  padding: 0;
  border: 0;
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1.2;
}

.home-module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.home-module-card {
  display: grid;
  min-height: 210px;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface-2) 70%, transparent), color-mix(in srgb, var(--surface) 92%, transparent)),
    var(--surface);
  color: var(--text);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.12);
}

.home-module-card:hover {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line));
  text-decoration: none;
  transform: translateY(-1px);
}

.home-module-card > span {
  display: inline-flex;
  width: fit-content;
  min-width: 36px;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--accent) 44%, var(--line));
  border-radius: 999px;
  padding: 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 780;
}

.home-module-card strong {
  font-size: 22px;
  line-height: 1.22;
}

.home-module-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.62;
}

.home-module-card small {
  color: var(--soft);
  font-size: 12px;
}

.home-workflow {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}

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

.home-workflow-grid article {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
}

.home-workflow-grid article > span {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 780;
}

.home-workflow-grid strong {
  font-size: 16px;
  line-height: 1.25;
}

.home-workflow-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

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

.topic-card {
  --topic: var(--accent);
  display: flex;
  min-height: 258px;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--topic);
  border-radius: 8px;
  background: var(--surface);
}

.topic-card[data-tone="blue"] {
  --topic: #7dd3fc;
}

.topic-card[data-tone="yellow"] {
  --topic: #f4d35e;
}

.topic-card[data-tone="pink"] {
  --topic: #f57bc1;
}

.topic-card[data-tone="purple"] {
  --topic: #b795ff;
}

.topic-card[data-tone="red"] {
  --topic: #f06f6f;
}

.topic-card > span {
  color: var(--topic);
  font-size: 12px;
  font-weight: 780;
}

.topic-card h3 {
  margin: 8px 0 10px;
  font-size: 22px;
  line-height: 1.22;
}

.topic-card p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.64;
}

.topic-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin-top: auto;
  border: 1px solid color-mix(in srgb, var(--topic) 52%, var(--line));
  border-radius: 6px;
  background: color-mix(in srgb, var(--topic) 16%, var(--surface-2));
  color: var(--text);
  font-weight: 740;
}

.topic-primary:hover,
.topic-links a:hover,
.entity-chip-grid a:hover,
.home-index-grid a:hover,
.home-final-panel a:hover {
  text-decoration: none;
  border-color: var(--line-strong);
}

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

.topic-links a,
.entity-chip-grid a,
.home-index-grid a {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--soft);
}

.topic-links a {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  font-size: 13px;
}

.home-split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 22px;
}

.entity-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.entity-chip-grid a {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  padding: 0 12px;
}

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

.home-index-grid a {
  display: flex;
  min-height: 58px;
  flex-direction: column;
  justify-content: center;
  padding: 10px 12px;
}

.home-index-grid strong {
  color: var(--text);
  line-height: 1.25;
}

.home-index-grid span {
  color: var(--muted);
  font-size: 12px;
}

.home-final-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.home-final-panel p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 720px;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 9px 11px;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
}

.asset-placeholder {
  color: var(--muted);
}

.rail-card {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.rail-card h2 {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.3;
}

.rail-card p {
  margin: 0 0 12px;
}

.local-graph-card {
  overflow: hidden;
}

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

.local-graph-head h2 {
  margin: 0;
}

.local-graph-head button {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.local-graph-canvas {
  display: block;
  width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.local-graph-status {
  margin: 8px 0 10px;
}

.local-graph-selection {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.local-node-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 740;
  line-height: 1.4;
}

.local-node-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 7px 0;
}

.local-node-meta span {
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
}

.local-graph-selection a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.rail-muted {
  color: var(--muted);
  font-size: 13px;
}

.rail-button {
  width: 100%;
  min-height: 38px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.toc-list,
.backlink-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-list li,
.backlink-list li {
  margin: 0;
}

.toc-list a,
.backlink-list a {
  display: block;
  padding: 5px 0;
  color: var(--soft);
  font-size: 13px;
}

.toc-level-3 {
  padding-left: 12px;
}

/* Search */
.search-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  padding: 84px 18px 18px;
  background: rgba(2, 7, 10, 0.72);
}

.search-dialog {
  width: min(760px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.search-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.search-dialog-head button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.search-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 16px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.search-results {
  max-height: min(62svh, 560px);
  overflow: auto;
}

.search-empty {
  padding: 18px 16px;
  color: var(--muted);
}

.search-hit {
  display: block;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.search-hit:hover {
  background: var(--surface-2);
  text-decoration: none;
}

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

.hit-top b {
  line-height: 1.35;
}

.hit-top em {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.search-hit p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.search-hit mark {
  background: rgba(215, 241, 113, 0.28);
  color: var(--text);
  padding: 0 2px;
}

/* Full graph */
.graph-page {
  min-height: 100svh;
  overflow: hidden;
  background: var(--bg);
}

.graph-topbar {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(18px);
}

.graph-shell {
  position: relative;
  display: block;
  height: calc(100svh - 58px);
  min-height: 640px;
  overflow: hidden;
}

.graph-controls {
  position: absolute;
  z-index: 8;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: min(332px, calc(100% - 28px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  padding: 0;
  box-shadow: 0 24px 70px rgba(31, 41, 55, 0.16);
  backdrop-filter: blur(18px);
}

.graph-panel {
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  margin-bottom: 0;
}

.graph-panel:last-child {
  border-bottom: 0;
}

.graph-title-panel h1 {
  margin: 5px 0 7px;
  font-size: 22px;
  line-height: 1.18;
}

.graph-title-panel p,
.graph-selection p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.58;
}

.graph-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.graph-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  background: color-mix(in srgb, var(--surface) 86%, var(--bg));
  color: var(--text);
  outline: none;
}

.graph-input:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
}

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

.graph-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 76%, var(--surface));
  color: var(--text);
  cursor: pointer;
}

.graph-button:hover {
  border-color: var(--line-strong);
}

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

.graph-stat-grid div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 62%, var(--surface));
}

.graph-stat-grid strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.graph-stat-grid span {
  color: var(--muted);
  font-size: 12px;
}

.graph-check,
.graph-range,
.graph-type-check {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--soft);
  font-size: 13px;
}

.graph-check + .graph-check,
.graph-check + .graph-range {
  margin-top: 10px;
}

.graph-range {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.graph-range input {
  width: 100%;
}

.graph-panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

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

.graph-panel-head h2 {
  margin: 0;
}

.graph-mini-button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: color-mix(in srgb, var(--surface-2) 76%, var(--surface));
  color: var(--soft);
  font-size: 12px;
  cursor: pointer;
}

.graph-mini-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.graph-visual-panel {
  background: transparent;
}

.graph-visual-range span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.graph-visual-range b {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.graph-visual-range + .graph-visual-range {
  margin-top: 12px;
}

.graph-advanced-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  color: var(--text);
  font-size: 15px;
  font-weight: 740;
  cursor: pointer;
  list-style: none;
}

.graph-advanced-panel summary::-webkit-details-marker {
  display: none;
}

.graph-advanced-panel summary::after {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
}

.graph-advanced-panel[open] summary {
  margin-bottom: 10px;
}

.graph-advanced-panel[open] summary::after {
  content: "−";
}

.graph-advanced-panel h2 {
  margin-top: 16px;
}

.graph-type-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.graph-type-check {
  min-width: 0;
}

.graph-type-check span:last-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.graph-relation-type-list,
.graph-evidence-list {
  display: grid;
  gap: 7px;
}

.graph-relation-type-list {
  grid-template-columns: 1fr;
}

.graph-evidence-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.graph-relation-check,
.graph-evidence-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--soft);
  font-size: 12px;
}

.graph-relation-check span:nth-of-type(2),
.graph-evidence-check span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-relation-check b,
.graph-evidence-check b {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.type-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.graph-node-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.graph-node-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 12px;
}

.graph-relation-summary {
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 54%, transparent);
}

.graph-relation-summary strong {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 12px;
}

.graph-relation-summary div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.graph-relation-summary span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.graph-relation-summary i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
}

.graph-evidence-summary {
  margin-top: 6px;
}

.graph-path-panel .graph-label + .graph-input {
  margin-bottom: 9px;
}

.graph-path-actions {
  margin-top: 8px;
}

.graph-path-result {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 54%, transparent);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.graph-path-result p {
  margin: 0;
}

.graph-path-result ol {
  display: grid;
  gap: 8px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.graph-path-result li {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.graph-path-result li > span {
  color: var(--muted);
  font-size: 11px;
}

.graph-path-result em {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--soft);
  font-style: normal;
  font-size: 11px;
}

.graph-path-result i,
.graph-relation-tag i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.graph-path-result small {
  color: var(--muted);
  font-size: 11px;
}

.graph-core-relations {
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 42%, transparent);
}

.graph-core-relations strong {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 12px;
}

.graph-core-relations ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.graph-core-relations li {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
}

.graph-relation-peer {
  overflow: hidden;
  color: var(--soft);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-relation-tag,
.graph-relation-evidence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.graph-core-relations small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 76%, var(--surface));
  color: var(--text);
  font-weight: 720;
}

.graph-selection-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.graph-selection-actions .graph-open-link {
  margin-top: 0;
}

.graph-clear-focus {
  cursor: pointer;
}

.graph-open-link:hover {
  text-decoration: none;
  border-color: var(--line-strong);
}

.graph-stage {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(circle at 18% 22%, rgba(15, 146, 122, 0.06), transparent 25%),
    radial-gradient(circle at 72% 18%, rgba(8, 118, 155, 0.05), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(238, 244, 244, 0.72)),
    var(--bg);
}

body[data-theme="dark"] .graph-stage {
  background:
    radial-gradient(circle at 18% 22%, rgba(65, 214, 179, 0.08), transparent 26%),
    radial-gradient(circle at 82% 18%, rgba(125, 211, 252, 0.08), transparent 28%),
    var(--bg);
}

#graph-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.graph-status {
  position: absolute;
  left: 18px;
  bottom: 18px;
  max-width: min(520px, calc(100% - 36px));
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  color: var(--soft);
  font-size: 13px;
  pointer-events: none;
  backdrop-filter: blur(12px);
}

.graph-legend {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  max-width: min(760px, calc(100% - 390px));
  pointer-events: none;
}

.graph-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--soft);
  font-size: 12px;
  backdrop-filter: blur(10px);
}

.graph-legend i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

/* Industry brain */
.brain-page {
  min-height: 100svh;
  overflow: hidden;
  background: var(--bg);
}

.brain-topbar {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
}

.brain-shell {
  position: relative;
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr) 320px;
  height: calc(100svh - 58px);
  min-height: 640px;
  overflow: hidden;
}

.brain-controls,
.brain-detail {
  position: relative;
  z-index: 8;
  overflow: auto;
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  backdrop-filter: blur(18px);
}

.brain-controls {
  border-right: 1px solid var(--line);
}

.brain-detail {
  border-left: 1px solid var(--line);
  padding: 14px;
}

.brain-panel {
  margin: 0;
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.brain-panel:last-child {
  border-bottom: 0;
}

.brain-title-panel h1 {
  margin: 5px 0 7px;
  font-size: 22px;
  line-height: 1.18;
}

.brain-title-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.58;
}

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

.brain-stat-grid div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 62%, var(--surface));
}

.brain-stat-grid strong {
  display: block;
  font-size: 22px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.brain-stat-grid span {
  color: var(--muted);
  font-size: 12px;
}

.brain-panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

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

.brain-segments button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 72%, var(--surface));
  color: var(--soft);
  cursor: pointer;
}

.brain-segments button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.brain-segments button.active {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
  background: var(--text);
  color: var(--bg);
  font-weight: 740;
}

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

.brain-cluster-list,
.brain-relation-list {
  display: grid;
  gap: 7px;
}

.brain-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--soft);
  font-size: 12px;
}

.brain-check span:nth-of-type(2) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brain-check b {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.brain-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--line) 42%, transparent) 1px, transparent 1px),
    linear-gradient(180deg, color-mix(in srgb, var(--line) 42%, transparent) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(238, 244, 244, 0.72)),
    var(--bg);
  background-size: 48px 48px, 48px 48px, auto, auto;
}

body[data-theme="dark"] .brain-stage {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--line) 36%, transparent) 1px, transparent 1px),
    linear-gradient(180deg, color-mix(in srgb, var(--line) 36%, transparent) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px, 48px 48px, auto;
}

#brain-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.brain-status {
  position: absolute;
  left: 18px;
  bottom: 18px;
  max-width: min(560px, calc(100% - 36px));
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  color: var(--soft);
  font-size: 12px;
  box-shadow: var(--shadow);
  pointer-events: none;
  backdrop-filter: blur(12px);
}

.brain-legend {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}

.brain-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--soft);
  font-size: 12px;
  backdrop-filter: blur(10px);
}

.brain-legend i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.brain-detail h2 {
  margin: 4px 0 8px;
  font-size: 20px;
  line-height: 1.25;
}

.brain-detail h3 {
  margin: 16px 0 8px;
  font-size: 14px;
}

.brain-detail p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.brain-detail ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.brain-detail li {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 48%, transparent);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.brain-detail li strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brain-node-meta,
.brain-detail-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.brain-node-meta span,
.brain-detail-pills span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.brain-detail-pills i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
}

.brain-open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 76%, var(--surface));
  color: var(--text);
  font-weight: 720;
}

.brain-open-link:hover {
  border-color: var(--line-strong);
  text-decoration: none;
}

/* Research cockpit */
.insights-page {
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 0%, rgba(15, 146, 122, 0.12), transparent 28%),
    radial-gradient(circle at 86% 10%, rgba(6, 182, 212, 0.1), transparent 30%),
    var(--bg);
}

.insights-topbar {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  backdrop-filter: blur(18px);
}

.insights-shell {
  width: min(1560px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.insights-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  padding: 10px 0 24px;
  border-bottom: 1px solid var(--line);
}

.insights-hero h1 {
  margin: 4px 0 10px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.03;
}

.insights-hero p {
  max-width: 780px;
  margin: 0;
  color: var(--soft);
  font-size: 15px;
  line-height: 1.7;
}

.insights-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.insights-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 0;
}

.insights-metrics div,
.insights-overview-grid div,
.insights-focus-grid article,
.insights-card,
.insights-side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: 0 18px 54px rgba(31, 41, 55, 0.08);
  backdrop-filter: blur(16px);
}

.insights-metrics div {
  padding: 13px 14px;
}

.insights-metrics strong,
.insights-overview-grid strong {
  display: block;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.insights-metrics span,
.insights-overview-grid span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.insights-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 14px;
  align-items: end;
  padding: 4px 0 18px;
}

.insights-segments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.insights-segments button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: color-mix(in srgb, var(--surface-2) 72%, var(--surface));
  color: var(--soft);
  cursor: pointer;
}

.insights-segments button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.insights-segments button.active {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
  background: var(--text);
  color: var(--bg);
  font-weight: 740;
}

.insights-search {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.insights-search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: color-mix(in srgb, var(--surface) 86%, var(--bg));
  color: var(--text);
  outline: none;
}

.insights-search input:focus {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
}

.insights-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.insights-section-title {
  margin-bottom: 14px;
}

.insights-section-title span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0;
}

.insights-section-title h2 {
  margin: 4px 0 6px;
  font-size: 28px;
  line-height: 1.2;
}

.insights-section-title p {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.insights-overview-grid,
.insights-focus-grid,
.insights-card-grid {
  display: grid;
  gap: 12px;
}

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

.insights-overview-grid div {
  padding: 14px;
}

.insights-overview-grid p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.insights-focus-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.insights-focus-grid article,
.insights-card {
  padding: 14px;
}

.insights-focus-grid article > span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
}

.insights-focus-grid h3,
.insights-card h3 {
  margin: 5px 0 7px;
  font-size: 18px;
  line-height: 1.28;
}

.insights-focus-grid p,
.insights-card p,
.insights-muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.58;
}

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

.insights-card.compact h3 {
  font-size: 16px;
}

.insights-card-top,
.insights-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.insights-card-top strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.insights-pill-row,
.insights-evidence-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.insights-pill-row span,
.insights-evidence-row span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 11px;
}

.insights-pill-row i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--pill, var(--accent));
}

.insights-evidence-row span[data-level="D"],
.insights-evidence-row span[data-level="E"],
.insights-evidence-row span[data-level="U"] {
  color: var(--danger);
}

.insights-card-foot {
  justify-content: flex-start;
  margin-top: 10px;
}

.insights-neighbors {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.insights-neighbors li {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.insights-neighbors a {
  overflow: hidden;
  color: var(--text);
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insights-neighbors span,
.insights-debt-item span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.insights-neighbors i,
.insights-debt-item i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--rel, var(--accent));
}

.insights-aside {
  position: sticky;
  top: 78px;
  display: grid;
  gap: 12px;
}

.insights-side-panel {
  padding: 14px;
}

.insights-side-panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.insights-hotspots,
.insights-clusters,
.insights-debt {
  display: grid;
  gap: 10px;
}

.insights-hotspot {
  display: grid;
  gap: 6px;
}

.insights-hotspot div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.insights-hotspot strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.insights-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-3) 64%, transparent);
}

.insights-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.insights-debt-item {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 46%, transparent);
  font-size: 12px;
}

.insights-debt-item a {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insights-debt-item small {
  color: var(--muted);
}

.insights-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--muted);
}

/* Company radar */
.radar-page {
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 4%, rgba(99, 102, 241, 0.1), transparent 28%),
    radial-gradient(circle at 86% 6%, rgba(15, 146, 122, 0.12), transparent 30%),
    var(--bg);
}

.radar-topbar {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  backdrop-filter: blur(18px);
}

.radar-shell {
  width: min(1600px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.radar-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  padding: 10px 0 24px;
  border-bottom: 1px solid var(--line);
}

.radar-hero h1 {
  margin: 4px 0 10px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.03;
}

.radar-hero p {
  max-width: 850px;
  margin: 0;
  color: var(--soft);
  font-size: 15px;
  line-height: 1.7;
}

.radar-hero-actions {
  display: flex;
  gap: 10px;
  white-space: nowrap;
}

.radar-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 0;
}

.radar-metrics div,
.radar-panel,
.radar-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  box-shadow: 0 18px 54px rgba(31, 41, 55, 0.08);
  backdrop-filter: blur(16px);
}

.radar-metrics div {
  padding: 13px 14px;
}

.radar-metrics strong {
  display: block;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.radar-metrics span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.radar-workbench {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.radar-sidebar {
  position: sticky;
  top: 78px;
  display: grid;
  gap: 12px;
}

.radar-panel {
  padding: 14px;
}

.radar-panel h2,
.radar-section-head h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.radar-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.radar-panel-head button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  background: color-mix(in srgb, var(--surface-2) 72%, var(--surface));
  color: var(--soft);
  font-size: 12px;
  cursor: pointer;
}

.radar-field {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.radar-field input,
.radar-field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: color-mix(in srgb, var(--surface) 86%, var(--bg));
  color: var(--text);
  outline: none;
}

.radar-field input:focus,
.radar-field select:focus {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
}

.radar-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--soft);
  font-size: 13px;
}

.radar-company-list {
  display: grid;
  gap: 7px;
  max-height: calc(100svh - 330px);
  overflow: auto;
  padding-right: 2px;
}

.radar-company-list button {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 2px 8px;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: color-mix(in srgb, var(--surface-2) 50%, transparent);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.radar-company-list button:hover,
.radar-company-list button.active {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
}

.radar-company-list button.active {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.radar-company-list span {
  grid-row: span 2;
  color: var(--muted);
  font-size: 12px;
}

.radar-company-list strong {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.radar-company-list small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.radar-section-head {
  margin-bottom: 12px;
}

.radar-section-head span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
}

.radar-section-head h2 {
  margin: 4px 0 6px;
  font-size: 28px;
  line-height: 1.2;
}

.radar-section-head p,
.radar-muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.radar-selection {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.radar-selection button,
.radar-selection p {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--soft);
  font-size: 12px;
}

.radar-selection button {
  cursor: pointer;
}

.radar-selection span {
  margin-left: 8px;
  color: var(--muted);
}

.radar-compare-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.radar-card {
  padding: 14px;
}

.radar-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.radar-card-head span {
  color: var(--muted);
  font-size: 12px;
}

.radar-card-head h3 {
  margin: 4px 0 0;
  font-size: 18px;
  line-height: 1.25;
}

.radar-card-head strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-variant-numeric: tabular-nums;
}

.radar-card-body {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.radar-card-body p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.radar-svg {
  width: 180px;
  height: 180px;
}

.radar-ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}

.radar-axis {
  stroke: var(--line);
  stroke-width: 1;
}

.radar-svg text {
  fill: var(--muted);
  font: 10px system-ui, sans-serif;
}

.radar-shape {
  fill: color-mix(in srgb, var(--accent) 24%, transparent);
  stroke: var(--accent);
  stroke-width: 2;
}

.radar-point {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 1.5;
}

.radar-kpis,
.radar-relation-pills,
.radar-evidence {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.radar-kpis span,
.radar-relation-pills span,
.radar-evidence span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 11px;
}

.radar-relation-pills i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--rel, var(--accent));
}

.radar-evidence span[data-level="D"],
.radar-evidence span[data-level="E"],
.radar-evidence span[data-level="U"] {
  color: var(--danger);
}

.radar-stacked {
  display: flex;
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-3) 64%, transparent);
}

.radar-stacked i[data-level="A"] { background: #10b981; }
.radar-stacked i[data-level="B"] { background: #06b6d4; }
.radar-stacked i[data-level="C"] { background: #f59e0b; }
.radar-stacked i[data-level="D"] { background: #ef4444; }
.radar-stacked i[data-level="E"] { background: #8b5cf6; }
.radar-stacked i[data-level="U"] { background: #64748b; }

.radar-dimensions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.radar-dimensions div {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 34px;
  gap: 6px 10px;
  align-items: center;
}

.radar-dimensions span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--soft);
  font-size: 12px;
}

.radar-dimensions span i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.radar-dimensions strong {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.radar-dimensions em {
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-3) 64%, transparent);
}

.radar-dimensions b {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.radar-card h4 {
  margin: 14px 0 8px;
  font-size: 14px;
}

.radar-neighbors {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.radar-neighbors li {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.radar-neighbors a {
  overflow: hidden;
  color: var(--text);
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.radar-neighbors span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.radar-neighbors i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--rel, var(--accent));
}

/* Evidence audit */
.audit-page {
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 4%, rgba(239, 68, 68, 0.1), transparent 28%),
    radial-gradient(circle at 86% 8%, rgba(100, 116, 139, 0.12), transparent 30%),
    var(--bg);
}

.audit-topbar {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  backdrop-filter: blur(18px);
}

.audit-shell {
  width: min(1580px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.audit-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  padding: 10px 0 24px;
  border-bottom: 1px solid var(--line);
}

.audit-hero h1 {
  margin: 4px 0 10px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.03;
}

.audit-hero p {
  max-width: 860px;
  margin: 0;
  color: var(--soft);
  font-size: 15px;
  line-height: 1.7;
}

.audit-hero-actions {
  display: flex;
  gap: 10px;
  white-space: nowrap;
}

.audit-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 0;
}

.audit-metrics div,
.audit-panel,
.audit-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  box-shadow: 0 18px 54px rgba(31, 41, 55, 0.08);
  backdrop-filter: blur(16px);
}

.audit-metrics div {
  padding: 13px 14px;
}

.audit-metrics strong {
  display: block;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.audit-metrics span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.audit-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 180px 220px;
  gap: 10px;
  align-items: end;
  padding-bottom: 18px;
}

.audit-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.audit-field input,
.audit-field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: color-mix(in srgb, var(--surface) 86%, var(--bg));
  color: var(--text);
  outline: none;
}

.audit-field input:focus,
.audit-field select:focus {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
}

.audit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 18px;
  align-items: start;
}

.audit-section-head {
  margin-bottom: 12px;
}

.audit-section-head span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
}

.audit-section-head h2 {
  margin: 4px 0 6px;
  font-size: 28px;
  line-height: 1.2;
}

.audit-section-head p {
  max-width: 840px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-item {
  padding: 12px;
}

.audit-item[data-priority="P0"] {
  border-color: color-mix(in srgb, #ef4444 52%, var(--line));
}

.audit-item-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 9px;
}

.audit-item-head span,
.audit-item-head strong,
.audit-labels span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 11px;
}

.audit-priority {
  color: var(--text) !important;
  font-weight: 760;
}

.audit-evidence[data-level="D"],
.audit-evidence[data-level="E"],
.audit-evidence[data-level="U"] {
  color: var(--danger);
}

.audit-relation i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--rel, var(--accent));
}

.audit-item-head strong {
  margin-left: auto;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.audit-edge {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.audit-edge a {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 740;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-edge span {
  color: var(--muted);
}

.audit-meta,
.audit-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.audit-meta span {
  color: var(--muted);
  font-size: 11px;
}

.audit-aside {
  position: sticky;
  top: 78px;
  display: grid;
  gap: 12px;
}

.audit-panel {
  padding: 14px;
}

.audit-panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.audit-panel [data-audit-relations] {
  display: grid;
  gap: 8px;
}

.audit-panel [data-audit-relations] button {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: color-mix(in srgb, var(--surface-2) 48%, transparent);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.audit-panel [data-audit-relations] button.active {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.audit-panel [data-audit-relations] button > span,
.audit-panel [data-audit-relations] button > small {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.audit-panel [data-audit-relations] i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.audit-panel [data-audit-relations] strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.audit-panel [data-audit-relations] em {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-3) 64%, transparent);
}

.audit-panel [data-audit-relations] b {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.audit-node,
.audit-rule {
  display: grid;
  gap: 4px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.audit-node:first-child,
.audit-rule:first-child {
  border-top: 0;
}

.audit-node a {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-node span,
.audit-node small,
.audit-rule p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.audit-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  color: var(--muted);
}

/* Unified product modules */
:is(.graph-page, .brain-page, .insights-page, .radar-page, .audit-page) {
  background:
    radial-gradient(circle at 10% 0%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 28%),
    radial-gradient(circle at 88% 8%, color-mix(in srgb, var(--link) 8%, transparent), transparent 30%),
    var(--bg);
}

:is(.graph-topbar, .brain-topbar, .insights-topbar, .radar-topbar, .audit-topbar) {
  border-bottom: 1px solid var(--line);
  background: var(--module-topbar-bg);
  backdrop-filter: blur(18px);
}

body[data-theme="light"] :is(.graph-topbar, .brain-topbar, .insights-topbar, .radar-topbar, .audit-topbar) {
  --bg: #070b10;
  --surface-2: #121c26;
  --text: #eef5f7;
  --line: rgba(168, 197, 213, 0.22);
  --line-strong: rgba(168, 197, 213, 0.38);
  color: var(--text);
  background: rgba(7, 11, 16, 0.9);
}

:is(.insights-shell, .radar-shell, .audit-shell) {
  width: var(--module-shell-width);
  padding: 28px 0 56px;
}

:is(.insights-hero, .radar-hero, .audit-hero) {
  gap: 24px;
  padding: 10px 0 24px;
  border-bottom: 1px solid var(--line);
}

:is(.insights-hero h1, .radar-hero h1, .audit-hero h1) {
  letter-spacing: 0;
}

:is(.insights-metrics, .radar-metrics, .audit-metrics) {
  gap: 10px;
  padding: 18px 0;
}

:is(
  .insights-metrics div,
  .insights-overview-grid div,
  .insights-focus-grid article,
  .insights-card,
  .insights-side-panel,
  .radar-metrics div,
  .radar-panel,
  .radar-card,
  .audit-metrics div,
  .audit-panel,
  .audit-item,
  .graph-controls,
  .brain-controls,
  .brain-detail
) {
  border-color: var(--line);
  border-radius: var(--module-panel-radius);
  background: var(--module-panel-bg);
  box-shadow: var(--module-panel-shadow);
  backdrop-filter: blur(16px);
}

:is(.graph-controls, .brain-controls, .brain-detail) {
  background: var(--module-side-bg);
}

.brain-controls {
  border-radius: 0;
  border-right: 1px solid var(--line);
  box-shadow: none;
}

.brain-detail {
  border-radius: 0;
  border-left: 1px solid var(--line);
  box-shadow: none;
}

:is(.graph-stage, .brain-stage) {
  background:
    linear-gradient(90deg, var(--module-grid-line) 1px, transparent 1px),
    linear-gradient(180deg, var(--module-grid-line) 1px, transparent 1px),
    color-mix(in srgb, var(--surface) 26%, var(--bg));
  background-size: 48px 48px, 48px 48px, auto;
}

:is(.graph-input, .insights-search input, .radar-field input, .radar-field select, .audit-field input, .audit-field select) {
  border-radius: var(--module-control-radius);
  background: var(--module-control-bg);
}

:is(.graph-button, .graph-mini-button, .brain-segments button, .insights-segments button, .radar-panel-head button) {
  border-radius: var(--module-control-radius);
}

:is(.graph-status, .brain-status, .graph-legend span, .brain-legend span) {
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--soft);
  backdrop-filter: blur(12px);
}

/* Graph and dashboard fusion */
.graph-controls {
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: min(348px, calc(100% - 36px));
  overflow: hidden auto;
}

.brain-shell {
  gap: 14px;
  padding: 14px;
}

.brain-controls,
.brain-detail,
.brain-stage {
  border: 1px solid var(--line);
  border-radius: var(--module-panel-radius);
  overflow: auto;
}

.brain-controls,
.brain-detail {
  box-shadow: var(--module-panel-shadow);
}

.brain-stage {
  position: relative;
  overflow: hidden;
}

.brain-controls {
  border-right: 1px solid var(--line);
}

.brain-detail {
  border-left: 1px solid var(--line);
}

:is(.graph-title-panel, .brain-title-panel) {
  padding: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface-2) 76%, transparent), color-mix(in srgb, var(--surface) 92%, transparent)),
    var(--module-panel-bg);
}

:is(.graph-title-panel, .brain-title-panel) .eyebrow {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line));
  border-radius: 999px;
  padding: 0 9px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 780;
}

:is(.graph-title-panel h1, .brain-title-panel h1) {
  margin-top: 10px;
  font-size: 24px;
}

:is(.graph-panel h2, .brain-panel h2, .radar-panel h2, .audit-panel h2) {
  color: var(--text);
  font-weight: 780;
}

:is(.graph-stat-grid div, .brain-stat-grid div) {
  border-radius: var(--module-panel-radius);
  background: color-mix(in srgb, var(--surface-2) 68%, var(--surface));
}

:is(.graph-stat-grid strong, .brain-stat-grid strong, .insights-metrics strong, .radar-metrics strong, .audit-metrics strong) {
  font-variant-numeric: tabular-nums;
}

:is(.graph-button, .graph-mini-button, .brain-segments button, .insights-segments button, .radar-selection button, .audit-panel [data-audit-relations] button) {
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

:is(.graph-button, .graph-mini-button, .brain-segments button, .insights-segments button, .radar-selection button, .audit-panel [data-audit-relations] button):hover {
  transform: translateY(-1px);
}

@media (max-width: 1180px) {
  .wiki-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .right-rail {
    display: none;
  }

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

  .home-hero-panel,
  .home-split {
    grid-template-columns: 1fr;
  }

  .home-metric-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

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

  .graph-type-list {
    grid-template-columns: 1fr;
  }

  .brain-shell {
    grid-template-columns: 286px minmax(0, 1fr);
  }

  .brain-detail {
    position: absolute;
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: min(308px, calc(100% - 320px));
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(31, 41, 55, 0.16);
  }

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

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

  .insights-aside {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }

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

  .radar-workbench {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .radar-compare-grid {
    grid-template-columns: 1fr;
  }

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

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

  .audit-aside {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }
}

@media (max-width: 860px) {
  .landing-nav {
    position: absolute;
    left: 14px;
    right: 14px;
    width: auto;
    transform: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    border-radius: 8px;
  }

  .landing-nav nav {
    display: flex;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .landing-hero {
    grid-template-columns: 1fr;
    min-height: 88svh;
    padding: 168px 20px 46px;
  }

  .hero-copy h1 {
    font-size: clamp(42px, 15vw, 62px);
  }

  .preview-card {
    display: none;
  }

  .landing-band {
    padding: 46px 20px;
  }

  .scope-grid,
  .entry-grid,
  .stat-grid,
  .topic-card-grid,
  .home-module-grid,
  .home-workflow-grid,
  .home-index-grid {
    grid-template-columns: 1fr;
  }

  .home-hero-panel {
    padding: 22px;
  }

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

  .topic-links {
    grid-template-columns: 1fr;
  }

  .home-final-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .landing-footer {
    flex-direction: column;
    padding: 22px 20px;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .product-nav-link,
  .topbar-actions .tool-button {
    flex: 0 0 auto;
  }

  .wiki-layout {
    display: block;
    padding: 18px 18px 64px;
  }

  .sidebar {
    display: none;
    position: static;
    max-height: none;
    margin-bottom: 20px;
  }

  body.sidebar-open .sidebar {
    display: block;
  }

  .page {
    padding-top: 0;
  }

  .content h1 {
    font-size: 34px;
  }

  table {
    min-width: 640px;
  }

  .graph-page {
    overflow: hidden;
  }

  .graph-shell {
    display: block;
    height: calc(100svh - 102px);
    min-height: 0;
  }

  .graph-controls {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: 48svh;
    overflow: auto;
  }

  .graph-stage {
    position: absolute;
    top: 0;
    right: 0;
    bottom: calc(48svh + 22px);
    left: 0;
    height: auto;
    min-height: 0;
  }

  .graph-legend {
    display: none;
  }

  .graph-status {
    bottom: calc(48svh + 24px);
    left: 10px;
    max-width: calc(100% - 20px);
  }

  .brain-page {
    overflow: hidden;
  }

  .brain-shell {
    display: block;
    height: calc(100svh - 102px);
    min-height: 0;
  }

  .brain-stage {
    position: absolute;
    top: 0;
    right: 0;
    bottom: calc(44svh + 22px);
    left: 0;
    height: auto;
    min-height: 0;
  }

  .brain-controls {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-height: 44svh;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(31, 41, 55, 0.16);
  }

  .brain-detail {
    display: none;
  }

  .brain-legend {
    display: none;
  }

  .brain-status {
    bottom: calc(44svh + 24px);
    left: 10px;
    max-width: calc(100% - 20px);
  }

  .insights-shell {
    width: min(100% - 28px, 760px);
    padding-top: 20px;
  }

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

  .insights-hero-actions {
    align-items: stretch;
    flex-direction: column;
    white-space: normal;
  }

  .insights-metrics,
  .insights-overview-grid,
  .insights-focus-grid,
  .insights-card-grid,
  .insights-aside {
    grid-template-columns: 1fr;
  }

  .radar-shell {
    width: min(100% - 28px, 760px);
    padding-top: 20px;
  }

  .radar-hero,
  .radar-workbench {
    grid-template-columns: 1fr;
  }

  .radar-hero-actions {
    align-items: stretch;
    flex-direction: column;
    white-space: normal;
  }

  .radar-metrics,
  .radar-compare-grid {
    grid-template-columns: 1fr;
  }

  .radar-sidebar {
    position: static;
  }

  .radar-company-list {
    max-height: 360px;
  }

  .audit-shell {
    width: min(100% - 28px, 760px);
    padding-top: 20px;
  }

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

  .audit-hero-actions {
    align-items: stretch;
    flex-direction: column;
    white-space: normal;
  }

  .audit-metrics,
  .audit-aside {
    grid-template-columns: 1fr;
  }

  .audit-edge {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .audit-edge span {
    display: none;
  }
}

@media (max-width: 520px) {
  .hero-actions,
  .home-hero-actions,
  .primary-action,
  .secondary-action {
    width: 100%;
  }

  .hero-actions a,
  .home-hero-actions a,
  .home-final-panel a {
    width: 100%;
  }

  .home-metric-grid {
    grid-template-columns: 1fr;
  }

  .home-module-card {
    min-height: auto;
  }

  .home-workflow {
    padding: 14px;
  }

  .tool-button {
    padding: 0 10px;
  }

  .brain-segments,
  .brain-actions,
  .brain-stat-grid {
    grid-template-columns: 1fr;
  }

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

  .insights-segments button {
    border-radius: 8px;
  }

  .radar-card-body {
    grid-template-columns: 1fr;
  }

  .radar-svg {
    justify-self: center;
  }
}
