:root {
  --font-main: "Microsoft YaHei", "微软雅黑", "PingFang SC", Arial, sans-serif;
  --paper: #f8faf8;
  --surface: #ffffff;
  --surface-soft: #f3f6f3;
  --ink: #132232;
  --muted: #60707d;
  --line: rgba(19, 34, 50, 0.12);
  --sweetener: #0c376d;
  --dose: #985421;
  --model: #0f6f73;
  --gut: #2e7a4f;
  --outcome: #a14f25;
  --reference: #8a6c29;
  --highlight: #e5bc58;
  --shadow: 0 16px 36px rgba(19, 34, 50, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-width: 1180px;
  min-height: 100%;
}

body {
  font-family: var(--font-main);
  color: var(--ink);
  background: var(--paper);
}

.atlas-app {
  display: grid;
  grid-template-rows: auto auto auto;
  width: 100vw;
  min-height: 100vh;
  min-height: 720px;
  overflow: visible;
  background:
    linear-gradient(90deg, rgba(46, 122, 79, 0.05), transparent 25%, transparent 75%, rgba(161, 79, 37, 0.05)),
    var(--paper);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 14px 22px 12px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.title-block {
  min-width: 0;
}

.title-block h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2rem);
  font-weight: 760;
  letter-spacing: 0;
}

.title-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 6px;
}

.title-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(12, 55, 109, 0.14);
  border-radius: 999px;
  background: rgba(12, 55, 109, 0.06);
  color: #284257;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
}

.title-positioning {
  max-width: 980px;
  margin: 6px 0 0;
  color: #526471;
  font-size: 0.72rem;
  font-weight: 520;
  line-height: 1.35;
}

.path-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.path-strip b {
  color: #778692;
  font-weight: 600;
}

.path-label,
.section-kicker,
.search-label {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 999px;
  vertical-align: -1px;
}

.dot.sweetener {
  background: var(--sweetener);
}

.dot.dose {
  background: var(--dose);
}

.dot.model {
  background: var(--model);
}

.dot.gut {
  background: var(--gut);
}

.dot.outcome {
  background: var(--outcome);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.icon-button,
.tab-button,
.qa-list-button,
.hint-button {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(19, 34, 50, 0.06);
}

.reset-icon {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.graph-stage {
  position: relative;
  min-width: 0;
  height: min(70vh, 820px);
  min-height: 640px;
  border-bottom: 1px solid var(--line);
}

.graph-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: zoom-in;
  touch-action: none;
  background:
    radial-gradient(circle at center, rgba(12, 55, 109, 0.06), transparent 26%),
    linear-gradient(90deg, rgba(46, 122, 79, 0.035), transparent 22%, transparent 78%, rgba(161, 79, 37, 0.035));
}

.graph-viewport.is-panning {
  cursor: grabbing;
  user-select: none;
}

.graph-viewport.is-panning * {
  cursor: grabbing !important;
}

#graph-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qa-panel {
  --qa-body-height: clamp(500px, 50vh, 620px);
  display: grid;
  grid-template-columns: 270px 360px minmax(420px, 1fr);
  grid-template-rows: auto var(--qa-body-height);
  column-gap: 18px;
  row-gap: 12px;
  width: min(1180px, calc(100vw - 48px));
  min-width: 0;
  min-height: 280px;
  margin: 16px auto 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  border-left: 0;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.qa-header {
  grid-column: 1;
  grid-row: 1;
}

.search-area {
  grid-column: 2;
  grid-row: 1;
}

.tab-strip {
  grid-column: 3;
  grid-row: 1;
  align-self: end;
}

.list-panel {
  grid-column: 1 / span 2;
  grid-row: 2;
}

.summary-panel {
  grid-column: 3;
  grid-row: 2;
}

.qa-header h2,
.summary-head h3 {
  margin: 6px 0 0;
  font-size: 1.18rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.search-area {
  position: relative;
  margin-top: 0;
}

.search-label {
  display: block;
  margin-bottom: 8px;
}

.search-input-wrap {
  display: grid;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.search-input-wrap input {
  width: 100%;
  min-height: 38px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
}

.hint-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 12;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.search-area:hover .hint-panel,
.search-area:focus-within .hint-panel {
  display: block;
}

.hint-head {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hint-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.hint-button {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  font-size: 0.8rem;
  line-height: 1.3;
}

.tab-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 0;
}

.tab-button {
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.tab-button.is-active {
  border-color: rgba(12, 55, 109, 0.32);
  background: rgba(12, 55, 109, 0.08);
  color: var(--ink);
}

.list-panel,
.summary-panel {
  height: var(--qa-body-height);
  min-height: 0;
  margin-top: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.list-panel {
  display: flex;
  flex-direction: column;
}

.summary-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-head,
.summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.list-head {
  align-items: center;
  font-size: 0.82rem;
  font-weight: 760;
}

.list-count,
.summary-type {
  color: var(--muted);
  font-size: 0.78rem;
}

.summary-type {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-soft);
}

.qa-list {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 7px;
  max-height: none;
  min-height: 0;
  margin-top: 10px;
  overflow: auto;
}

.qa-list-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 9px;
  border: 1px solid rgba(19, 34, 50, 0.1);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: left;
}

.qa-list-button:hover,
.qa-list-button.is-active {
  border-color: rgba(12, 55, 109, 0.28);
  background: rgba(12, 55, 109, 0.07);
}

.qa-item-label {
  min-width: 0;
  font-size: 0.8rem;
  line-height: 1.35;
}

.qa-item-count {
  color: var(--muted);
  font-size: 0.74rem;
}

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

.summary-stat {
  padding: 9px;
  border: 1px solid rgba(19, 34, 50, 0.08);
  border-radius: 8px;
  background: var(--surface-soft);
}

.summary-stat strong {
  display: block;
  font-size: 1rem;
}

.summary-stat span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.summary-body {
  flex: 0 1 84px;
  max-height: 84px;
  min-height: 0;
  margin-top: 12px;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.summary-body p {
  margin: 0 0 10px;
  color: #243342;
  font-size: 0.83rem;
  line-height: 1.55;
}

.change-word {
  color: var(--gut);
  font-weight: 760;
  font-style: normal;
}

.reference-shell {
  display: flex;
  flex: 1 1 220px;
  min-height: 200px;
  flex-direction: column;
  margin-top: 10px;
}

.reference-list {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 7px;
  margin-top: 9px;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.reference-count {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 7px 8px;
  border: 1px solid rgba(19, 34, 50, 0.08);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.reference-link {
  display: flex;
  gap: 6px;
  align-items: baseline;
  padding: 8px;
  border: 1px solid rgba(19, 34, 50, 0.1);
  border-radius: 8px;
  background: var(--surface-soft);
  color: #193b63;
  font-size: 0.76rem;
  line-height: 1.35;
  text-decoration: none;
  word-break: break-all;
}

.reference-link span {
  flex: 0 0 auto;
  color: var(--muted);
}

.reference-note,
.empty-state {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.empty-state {
  padding: 14px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.reading-bar {
  display: grid;
  grid-template-columns: 1.45fr 0.9fr 1fr 0.7fr;
  gap: 16px;
  align-items: center;
  padding: 10px 24px 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.copyright {
  grid-column: 1 / -1;
  justify-self: center;
  padding-top: 4px;
  color: #526471;
  font-size: 0.72rem;
  font-weight: 650;
  text-align: center;
}

.ring-guide {
  fill: none;
  stroke-width: 1.2;
  stroke-dasharray: 5 10;
  opacity: 0.35;
}

.core-title {
  fill: rgba(19, 34, 50, 0.72);
  font-size: 22px;
  font-weight: 780;
}

.core-subtitle {
  fill: rgba(96, 112, 125, 0.8);
  font-size: 12px;
}

.edge {
  fill: none;
  stroke-linecap: round;
  opacity: 0.1;
  transition: opacity 160ms ease, stroke-width 160ms ease;
}

.edge.edge-sweetener_to_dose {
  stroke: rgba(12, 55, 109, 0.42);
}

.edge.edge-dose_to_model {
  stroke: rgba(152, 84, 33, 0.4);
}

.edge.edge-model_to_gut_change {
  stroke: rgba(46, 122, 79, 0.38);
}

.edge.edge-model_to_outcome {
  stroke: rgba(161, 79, 37, 0.42);
}

.node,
.node-core,
.node-halo {
  cursor: pointer;
}

.node-halo {
  fill: rgba(229, 188, 88, 0.16);
  stroke: rgba(229, 188, 88, 0.62);
  stroke-width: 0;
  opacity: 0;
}

.node-core {
  stroke-width: 1.3;
}

.node.is-slash .node-core {
  stroke-dasharray: 4 3;
}

.node-label {
  fill: rgba(19, 34, 50, 0.94);
  dominant-baseline: middle;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.node-label.type-nas {
  font-size: 18px;
  font-weight: 800;
}

.node-label.type-dose {
  font-size: 10.8px;
  font-weight: 680;
}

.node-label.type-model {
  font-size: 11.4px;
  font-weight: 720;
}

.node-label.type-gut-change {
  font-size: 10.2px;
  font-weight: 650;
}

.node-label.type-outcome {
  font-size: 11.8px;
  font-weight: 720;
}

.node-label.is-hidden {
  opacity: 0 !important;
}

.node-label.is-faded {
  opacity: 0.18;
}

.node.is-focus .node-halo,
.node.is-active .node-halo {
  opacity: 1;
  stroke-width: 8;
}

.node.is-active .node-core {
  stroke: var(--highlight) !important;
  stroke-width: 3;
}

.node.is-dimmed {
  opacity: 0.16;
}

.edge.is-dimmed {
  opacity: 0.04;
}

.edge.is-focus {
  opacity: 0.86;
  stroke-width: 2.2;
}

.graph-tooltip {
  position: absolute;
  z-index: 20;
  width: min(360px, calc(100% - 24px));
  padding: 12px;
  border: 1px solid rgba(19, 34, 50, 0.12);
  border-radius: 10px;
  background: rgba(19, 34, 50, 0.95);
  color: #fff;
  pointer-events: auto;
  user-select: text;
  box-shadow: 0 18px 36px rgba(19, 34, 50, 0.22);
}

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

.graph-tooltip h4 {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.35;
}

.graph-tooltip p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.8rem;
  line-height: 1.5;
}

.graph-tooltip p + p {
  margin-top: 7px;
}

.tooltip-copy {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  font-size: 0.74rem;
  cursor: pointer;
}

em {
  font-style: italic;
}

@media (max-width: 1300px) {
  .qa-panel {
    --qa-body-height: clamp(460px, 50vh, 600px);
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto var(--qa-body-height) var(--qa-body-height);
  }

  .qa-header {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .search-area {
    grid-column: 2;
    grid-row: 1;
  }

  .tab-strip {
    grid-column: 2;
    grid-row: 2;
  }

  .list-panel {
    grid-column: 1 / span 2;
    grid-row: 3;
  }

  .summary-panel {
    grid-column: 1 / span 2;
    grid-row: 4;
  }

  .reading-bar {
    grid-template-columns: 1fr 1fr;
    font-size: 0.7rem;
  }
}
