/* ===== 毛选思想地图 ===== */
:root {
  --bg: #0f0e0c;
  --surface: #1a1814;
  --surface2: #24211b;
  --border: #2e2a22;
  --text: #d4cec2;
  --text2: #9b9484;
  --text3: #6b6558;
  --amber: #c8a44e;
  --amber2: #8b6914;
  --red: #c0392b;
  --orange: #d4784c;
  --blue: #5a7d9a;
  --green: #6b8e5a;
  --radius: 6px;
  --transition: 0.2s;
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  font-size: 15px; line-height: 1.7; overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { border:none; background:none; font:inherit; color:inherit; cursor:pointer; }
input { border:none; outline:none; font:inherit; color:inherit; background:none; }
input::placeholder { color: var(--text3); }
a { color: var(--amber); text-decoration: none; }

/* ===== Header ===== */
#header {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: baseline; gap: 10px; flex-shrink: 0; }
.logo { font-size: 18px; font-weight: 700; color: var(--amber); white-space: nowrap; }
.logo-sub { font-size: 12px; color: var(--text3); white-space: nowrap; }
.header-center { flex: 1; position: relative; max-width: 400px; }

.search-input {
  width: 100%; height: 36px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0 14px; font-size: 14px; transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--amber); }

.search-dropdown {
  position: absolute; top: 42px; left: 0; right: 0;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); max-height: 360px; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 110;
}
.search-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.search-item:hover { background: rgba(200,164,78,0.08); }
.search-item-type {
  font-size: 11px; padding: 2px 8px; border-radius: 3px;
  color: var(--bg); font-weight: 600; flex-shrink: 0;
}
.type-article { background: var(--amber); }
.type-event { background: var(--red); }
.type-figure { background: var(--orange); }
.type-concept { background: var(--blue); }
.search-item-title { font-size: 14px; color: var(--text); flex: 1; }
.search-item-date { font-size: 12px; color: var(--text3); }

.mode-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; color: var(--text2);
  transition: all var(--transition); white-space: nowrap;
}
.mode-btn:hover { border-color: var(--amber); color: var(--amber); }
.mode-icon { font-size: 16px; }

/* ===== Filter Bar ===== */
#filterBar {
  display: flex; gap: 16px; padding: 10px 20px; overflow-x: auto;
  background: var(--surface); border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
#filterBar::-webkit-scrollbar { display: none; }
.filter-group { display: flex; gap: 6px; flex-shrink: 0; }
.filter-chip {
  padding: 5px 14px; border: 1px solid var(--border);
  border-radius: 14px; font-size: 13px; color: var(--text3);
  transition: all var(--transition); white-space: nowrap;
}
.filter-chip:hover { border-color: var(--amber); color: var(--text2); }
.filter-chip.active {
  background: rgba(200,164,78,0.15); border-color: var(--amber); color: var(--amber);
}

/* ===== Main View ===== */
#mainView { position: relative; height: calc(100vh - 104px); overflow: hidden; }
.view { display: none; width: 100%; height: 100%; }
.view.active { display: block; }

/* ===== Timeline ===== */
#timelineView { overflow-x: auto; overflow-y: hidden; }
#timelineCanvas { position: relative; min-width: 100%; height: 100%; padding: 0 40px; }

#periodRibbon {
  position: sticky; top: 0; display: flex; height: 60px;
  z-index: 5; background: var(--bg);
}
.period-band {
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.9);
  letter-spacing: 2px; cursor: pointer; transition: opacity 0.15s;
}
.period-band:hover { opacity: 0.85; }
.period-band.p1 { background: var(--red); }
.period-band.p2 { background: var(--orange); }
.period-band.p3 { background: var(--blue); }
.period-band.p4 { background: var(--green); }

.timeline-row {
  position: relative; padding: 8px 0 24px;
}
.timeline-row-label {
  font-size: 12px; color: var(--text3); margin-bottom: 8px;
  position: sticky; left: 0; z-index: 3; background: var(--bg);
  padding: 4px 0; font-weight: 600;
}

.article-node {
  position: absolute; width: 280px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  transition: all var(--transition); font-size: 13px;
}
.article-node:hover {
  border-color: var(--amber); transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.article-node.vol1 { border-left: 3px solid var(--red); }
.article-node.vol2 { border-left: 3px solid var(--orange); }
.article-node.vol3 { border-left: 3px solid var(--blue); }
.article-node.vol4 { border-left: 3px solid var(--green); }
.an-title { font-weight: 700; color: var(--text); margin-bottom: 4px; }
.an-meta { font-size: 11px; color: var(--text3); }
.an-concepts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.an-concept {
  font-size: 11px; padding: 1px 8px; border-radius: 10px;
  background: rgba(200,164,78,0.1); color: var(--amber);
}

/* ===== Graph ===== */
#graphView { position: relative; background: var(--bg); }
#graphLegend {
  position: absolute; top: 16px; left: 16px; z-index: 5;
  display: flex; gap: 16px; padding: 8px 16px;
  background: rgba(26,24,20,0.9); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.article-dot { background: var(--amber); }
.event-dot { background: var(--red); }
.figure-dot { background: var(--orange); }
.concept-dot { background: var(--blue); }

#graphSvg { width: 100%; height: 100%; }
.graph-node { cursor: pointer; }
.graph-node circle { stroke-width: 2px; }
.graph-node.article circle { fill: var(--amber); stroke: var(--amber2); }
.graph-node.event circle { fill: var(--red); stroke: #96281b; }
.graph-node.figure circle { fill: var(--orange); stroke: #b36230; }
.graph-node.concept circle { fill: var(--blue); stroke: #4a6b82; }
.graph-node text { font-size: 11px; fill: var(--text); pointer-events: none; }
.graph-link { stroke: rgba(200,164,78,0.2); stroke-width: 1px; }

#graphTooltip {
  position: absolute; padding: 10px 14px; pointer-events: none;
  background: rgba(26,24,20,0.95); border: 1px solid var(--amber);
  border-radius: var(--radius); font-size: 13px; max-width: 260px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* ===== Detail Panel ===== */
.overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7); z-index: 200;
  display: flex; justify-content: flex-end;
}
.detail-panel {
  width: 100%; max-width: 560px; height: 100%;
  background: var(--surface); overflow-y: auto;
  padding: 40px 32px 60px;
  animation: slideIn 0.25s ease-out;
}
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.close-btn {
  position: fixed; top: 16px; right: 24px;
  width: 36px; height: 36px; line-height: 36px; text-align: center;
  font-size: 28px; color: var(--text2); background: var(--surface2);
  border-radius: 50%; z-index: 201; transition: opacity var(--transition);
}
.close-btn:hover { opacity: 0.7; }

.detail-title { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.detail-meta { font-size: 13px; color: var(--text3); margin-bottom: 20px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.detail-meta .vol-tag { padding: 2px 10px; border-radius: 3px; font-size: 12px; color: var(--bg); font-weight: 600; }
.vol1-tag { background: var(--red); }
.vol2-tag { background: var(--orange); }
.vol3-tag { background: var(--blue); }
.vol4-tag { background: var(--green); }

.detail-section { margin-bottom: 24px; }
.detail-section h3 { font-size: 14px; color: var(--amber); margin-bottom: 10px; font-weight: 600; }
.detail-summary { font-size: 15px; color: var(--text2); line-height: 1.8; padding: 14px; background: var(--surface2); border-radius: var(--radius); }
.detail-text { font-size: 15px; color: var(--text); line-height: 2; }
.detail-text p { margin-bottom: 14px; text-indent: 2em; }

.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-tag {
  padding: 4px 12px; border: 1px solid var(--border); border-radius: 12px;
  font-size: 12px; color: var(--text2); cursor: pointer; transition: all var(--transition);
}
.detail-tag:hover { border-color: var(--amber); color: var(--amber); }
.detail-tag.event { border-color: rgba(192,57,43,0.3); color: var(--red); }
.detail-tag.figure { border-color: rgba(212,120,76,0.3); color: var(--orange); }
.detail-tag.concept { border-color: rgba(90,125,154,0.3); color: var(--blue); }

.detail-related { display: flex; flex-direction: column; gap: 6px; }
.detail-related a { font-size: 14px; color: var(--amber); padding: 6px 0; border-bottom: 1px solid var(--border); }

/* ===== Node Popup ===== */
.node-popup {
  position: fixed; z-index: 150; padding: 14px 18px;
  background: rgba(26,24,20,0.97); border: 1px solid var(--amber);
  border-radius: var(--radius); max-width: 320px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5); font-size: 13px;
}
.node-popup h4 { font-size: 15px; color: var(--text); margin-bottom: 4px; }
.node-popup p { color: var(--text2); line-height: 1.6; margin: 4px 0; }
.node-popup .np-tag {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  font-size: 11px; color: var(--bg); margin: 2px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ===== Mobile ===== */
@media (max-width: 640px) {
  #header { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .header-center { order: 3; max-width: none; width: 100%; }
  #filterBar { padding: 8px 12px; }
  .detail-panel { max-width: 100%; padding: 30px 20px 60px; }
  .article-node { width: 240px; }
  #graphLegend { top: 8px; left: 8px; gap: 8px; font-size: 11px; }
  .mode-btn span:last-child { display: none; }
}
