:root {
  --bg: #f3f6fb;
  --bg-accent: radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 34%);
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --secondary-soft: #ecfeff;
  --accent: #7c3aed;
  --border: #dbe3ef;
  --shadow: 0 20px 40px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-accent);
  line-height: 1.6;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 16px 56px;
}

.detail-wrap {
  max-width: 860px;
}

.insight-wrap {
  max-width: 1200px;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.01em;
}

.sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.96rem;
  max-width: 680px;
}

.site-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #334155;
  background: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary);
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--primary-soft);
}

.search-shell,
.insight-toolbar,
article,
.detail-body,
.detail-origin,
.panel,
.search-placeholder {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.search-shell,
.insight-toolbar {
  padding: 16px;
  margin-bottom: 16px;
}

.search-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.search-input-wrap {
  flex: 1 1 340px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.search-sort-field {
  flex: 0 0 148px;
}

.search-label {
  font-size: 0.88rem;
  color: var(--muted);
}

.search-input-wrap input,
.field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  font: inherit;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: #334155;
}

.toggle input {
  margin: 0;
}

.ghost-button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font: inherit;
}

.ghost-button-compact {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 0.84rem;
}

.ghost-button:hover {
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--primary);
}

.ghost-button.is-active {
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--primary);
  background: var(--primary-soft);
}

.ghost-button:disabled,
.ghost-button:disabled:hover {
  cursor: default;
  opacity: 0.6;
  color: #94a3b8;
  border-color: var(--border);
  background: #fff;
}

.search-meta,
.insight-summary {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
}

#search-status.is-ready {
  color: #047857;
}

#search-status.is-error {
  color: #b91c1c;
}

.toolbar,
.preset-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar {
  margin: 18px 0 14px;
}

.insight-toolbar .toolbar {
  margin: 14px 0 0;
}

.chip {
  border: 1px solid var(--border);
  background: #fff;
  color: #374151;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}

.chip.active {
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--primary);
  background: var(--primary-soft);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.field-range strong {
  color: var(--primary);
  font-size: 1rem;
}

.field-range input[type="range"] {
  width: 100%;
}

.list,
.search-section-list,
.term-article-list,
.evidence-list,
.clue-list {
  display: grid;
  gap: 12px;
}

.day-card {
  padding: 0;
  overflow: hidden;
}

.day-card-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.day-card-date {
  font-size: 1.1rem;
  font-weight: 700;
}

.day-card-count {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

.day-card-list {
  display: grid;
}

.day-card-item {
  padding: 14px 16px;
}

.day-card-item + .day-card-item {
  border-top: 1px solid var(--border);
}

.day-card-item h2,
article h2 {
  margin: 0 0 6px;
}

article {
  padding: 16px;
}

article h2 {
  font-size: 1.08rem;
}

article h2 a,
.mini-card h4 a,
.home-link {
  color: var(--text);
  text-decoration: none;
}

article h2 a:hover,
.mini-card h4 a:hover,
.home-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.meta {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  flex-wrap: wrap;
}

.tag,
.mini-tag,
.match-badge,
.term-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
}

.tag {
  background: #eef2ff;
  color: #3730a3;
}

.mini-tag,
.match-badge {
  background: #f1f5f9;
  color: #475569;
}

.term-pill {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 600;
}

.search-section {
  display: grid;
  gap: 12px;
}

.search-section-head,
.panel-head,
.clue-card-head,
.search-card-top,
.term-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.search-section h2,
.panel-head h2,
.clue-card h3 {
  margin: 0;
}

.search-section-sub,
.search-section-count,
.search-snippet,
.term-stats,
.term-placeholder,
.insight-notes,
.search-placeholder p {
  color: var(--muted);
}

.search-card {
  padding: 16px;
}

.search-signals {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search-section-actions {
  display: flex;
  justify-content: center;
}

.search-snippet {
  font-size: 0.94rem;
}

.search-placeholder {
  padding: 24px;
}

.search-placeholder h2 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

.search-placeholder.is-error h2 {
  color: #b91c1c;
}

mark {
  background: #fde68a;
  color: inherit;
  padding: 0 0.15em;
  border-radius: 4px;
}

.empty,
.loading {
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--border);
  margin-top: 12px;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 64px;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 3px solid #dbeafe;
  border-top-color: var(--primary);
  animation: loading-spin 0.85s linear infinite;
  flex: 0 0 auto;
}

.loading-text {
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

.loading.is-complete .loading-spinner {
  display: none;
}

@keyframes loading-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.hidden { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

footer {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.86rem;
}

code {
  background: #eef2f7;
  border-radius: 6px;
  padding: 2px 6px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  margin-bottom: 10px;
  color: var(--primary);
  background: none;
  border: 0;
  padding: 0;
  text-decoration: none;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
}

.back-link:hover {
  text-decoration: underline;
}

.detail-header {
  margin-bottom: 12px;
}

.detail-meta {
  margin-top: 8px;
}

.detail-body {
  margin-bottom: 12px;
  padding: 18px;
}

.detail-body p {
  margin: 0 0 10px;
}

.detail-body p:last-child {
  margin-bottom: 0;
}

.detail-tip {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.detail-origin {
  padding: 18px;
}

.detail-origin h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.detail-origin a {
  color: var(--primary);
  word-break: break-all;
}

.insight-layout {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.insight-layout-wordcloud {
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.95fr);
}

.insight-layout-clues {
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
}

.panel {
  padding: 18px;
}

.panel-head {
  margin-bottom: 14px;
}

.panel-head h2 {
  font-size: 1.08rem;
}

.wordcloud-canvas,
.graph-canvas {
  border-radius: 16px;
  border: 1px dashed var(--border);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(255, 255, 255, 0.98));
}

.wordcloud-canvas {
  min-height: 520px;
  padding: 12px;
}

.graph-canvas {
  min-height: 620px;
  position: relative;
  overflow: hidden;
}

.clue-graph-stage {
  position: absolute;
  inset: 0;
}

.clue-graph-host {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.clue-graph-toolbar {
  z-index: 4;
}

.clue-graph-toolbar .ghost-button[disabled] {
  opacity: 0.62;
  cursor: not-allowed;
}

.wordcloud-canvas:fullscreen,
.wordcloud-canvas.is-fullscreen-view {
  width: 100vw;
  height: 100vh;
  max-width: none;
  min-height: 100vh;
  padding: 24px;
  border: 0;
  border-radius: 0;
  box-sizing: border-box;
}

.graph-canvas:fullscreen,
.graph-canvas.is-fullscreen-view {
  width: 100vw;
  height: 100vh;
  max-width: none;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  box-sizing: border-box;
}

.term-detail,
.insight-notes {
  display: grid;
  gap: 16px;
}

.term-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.84rem;
}

.term-section h3 {
  margin: 0 0 10px;
  font-size: 0.98rem;
}

.term-day-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #f8fbff;
}

.mini-card h4 {
  margin: 0 0 8px;
  font-size: 0.98rem;
}

.mini-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.clue-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
}

.clue-card.is-active {
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.08);
  background: #f8fbff;
}

.clue-card p {
  margin: 0 0 12px;
  color: var(--muted);
}

.evidence-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.control-grid-insight {
  grid-template-columns: minmax(220px, 360px);
}

.clue-signal-list,
.theme-signal-list,
.report-observation-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dynamic-graph-root {
  position: relative;
  overflow: hidden;
}

.dynamic-graph-svg {
  display: block;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 34%),
    radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.08), transparent 36%),
    linear-gradient(180deg, rgba(248, 250, 252, 0.88), rgba(255, 255, 255, 0.98));
}

.dynamic-graph-empty {
  position: absolute;
  inset: 16px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.86);
  border: 1px dashed var(--border);
  border-radius: 16px;
  backdrop-filter: blur(6px);
}

.dynamic-graph-controls,
.dynamic-graph-legend {
  position: absolute;
  z-index: 3;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dynamic-graph-controls {
  top: 16px;
  left: 16px;
}

.dynamic-graph-legend {
  left: 16px;
  bottom: 16px;
  max-width: min(60%, 520px);
  padding: 10px 12px;
  border: 1px solid rgba(219, 227, 239, 0.9);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.dynamic-graph-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 0.82rem;
}

.dynamic-graph-legend-dot {
  width: 10px;
  height: 10px;
  border: 2px solid transparent;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.88);
}

.graph-edge {
  fill: none;
  stroke: #94a3b8;
  stroke-opacity: 0.52;
  transition: stroke 0.18s ease, stroke-opacity 0.18s ease;
  cursor: pointer;
}

.graph-edge-article-source {
  stroke: #f59e0b;
  stroke-opacity: 0.48;
}

.graph-edge-article-category {
  stroke: #22c55e;
  stroke-opacity: 0.45;
}

.graph-edge-article-entity,
.graph-edge-article-event {
  stroke: #64748b;
}

.graph-edge-event-entity,
.graph-edge-explicit-relation {
  stroke: #2563eb;
  stroke-opacity: 0.6;
}

.graph-edge.is-selected,
.graph-edge-label.is-selected {
  stroke: var(--primary);
  stroke-opacity: 0.98;
}

.graph-edge.is-dim,
.graph-node.is-dim,
.graph-edge-label.is-dim,
.graph-edge-label-bg.is-dim {
  opacity: 0.16;
}

.graph-node {
  cursor: pointer;
}

.graph-node circle {
  transition: transform 0.18s ease, opacity 0.18s ease, stroke-width 0.18s ease;
}

.graph-node:hover circle:first-child,
.graph-node.is-selected circle:first-child {
  transform: scale(1.06);
  stroke-width: 2.8px;
}

.graph-node-ring {
  fill: none;
  stroke: rgba(37, 99, 235, 0.22);
  stroke-width: 0;
  opacity: 0;
}

.graph-node.is-selected .graph-node-ring {
  stroke-width: 6px;
  opacity: 1;
}

.graph-node-label {
  font-size: 12px;
  fill: #0f172a;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}

.graph-edge-label {
  font-size: 10.5px;
  fill: #334155;
  text-anchor: middle;
  dominant-baseline: middle;
  cursor: pointer;
}

.graph-edge-label-bg {
  fill: rgba(255, 255, 255, 0.84);
  stroke: rgba(148, 163, 184, 0.26);
  stroke-width: 1px;
}

.graph-detail-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 4;
  width: min(340px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(219, 227, 239, 0.92);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
}

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

.graph-detail-head h3 {
  margin: 2px 0 0;
  font-size: 1rem;
  line-height: 1.35;
}

.graph-detail-kicker {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.graph-detail-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font: inherit;
  cursor: pointer;
}

.graph-detail-close:hover {
  color: var(--primary);
  border-color: rgba(37, 99, 235, 0.35);
}

.graph-detail-body {
  display: grid;
  gap: 12px;
}

.graph-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: #475569;
  font-size: 0.88rem;
}

.graph-detail-row strong,
.graph-detail-section strong {
  color: #0f172a;
}

.graph-detail-section {
  display: grid;
  gap: 8px;
}

.graph-detail-section p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.graph-detail-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.graph-detail-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.78rem;
}

.graph-detail-muted {
  color: var(--muted);
  font-size: 0.84rem;
}

.report-overview-panel,
.report-memory-panel {
  margin-top: 16px;
}

.report-overview,
.report-memory {
  display: grid;
  gap: 12px;
}

.report-headline {
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.4;
}

.report-summary,
.theme-summary,
.theme-conclusion {
  margin: 0;
}

.report-summary,
.theme-summary {
  color: var(--muted);
}

.report-memory-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.report-memory-row strong {
  color: #0f172a;
}

.report-memory-row span {
  color: #475569;
  text-align: right;
}

.theme-list {
  margin-top: 16px;
  display: grid;
  gap: 16px;
}

.theme-card {
  padding: 18px;
}

.theme-card-head {
  margin-bottom: 10px;
}

.theme-kicker {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.theme-card h2 {
  margin: 2px 0 0;
  font-size: 1.16rem;
}

.theme-meta {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
}

.theme-conclusion {
  padding: 12px 14px;
  border-left: 4px solid rgba(37, 99, 235, 0.35);
  border-radius: 0 14px 14px 0;
  background: #f8fbff;
  color: #0f172a;
}

.insight-layout-report {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  align-items: start;
}

.theme-graph-panel,
.theme-evidence-panel {
  min-height: 100%;
}

.theme-graph-canvas {
  min-height: 360px;
}

@media (max-width: 980px) {
  .site-header,
  .search-row,
  .search-section-head,
  .search-card-top,
  .term-head,
  .clue-card-head {
    flex-direction: column;
    align-items: stretch;
  }

  .control-grid,
  .control-grid-insight,
  .insight-layout-wordcloud,
  .insight-layout-clues,
  .insight-layout-report,
  .evidence-grid {
    grid-template-columns: 1fr;
  }

  .graph-canvas {
    min-height: 520px;
  }

  .dynamic-graph-legend {
    max-width: calc(100% - 32px);
  }

  .graph-detail-panel {
    top: auto;
    right: 12px;
    bottom: 12px;
    width: min(360px, calc(100% - 24px));
    max-height: min(52%, 340px);
  }
}

@media (max-width: 640px) {
  .wrap {
    padding: 20px 12px 44px;
  }

  h1 {
    font-size: 1.7rem;
  }

  .nav-link,
  .ghost-button,
  .toggle,
  .search-input-wrap input,
  .field select {
    min-height: 38px;
  }

  .wordcloud-canvas {
    min-height: 420px;
  }

  .graph-canvas {
    min-height: 460px;
  }

  .dynamic-graph-controls {
    top: 12px;
    left: 12px;
  }

  .dynamic-graph-legend {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
    padding: 8px 10px;
  }

  .graph-detail-panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: min(56%, 320px);
    padding: 12px;
  }

  .report-memory-row,
  .graph-detail-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .report-memory-row span {
    text-align: left;
  }

  .theme-graph-canvas {
    min-height: 300px;
  }
}
