* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a0e1a;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  color: #e0e0e0;
}

.app {
  display: grid;
  grid-template-columns: 340px 1fr;
  width: 100vw;
  height: 100vh;
  transition: grid-template-columns 0.3s;
}

.app.panel-collapsed {
  grid-template-columns: 0 1fr;
}

/* 左侧面板 */
.left-panel {
  position: relative;
  height: 100vh;
  overflow-y: auto;
  background: #0a0e1af2;
  border-right: 1px solid rgba(100, 200, 255, 0.2);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: margin-left 0.3s, opacity 0.3s;
}

.left-panel.collapsed {
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.panel-toggle {
  position: absolute;
  top: 16px;
  left: 348px;
  width: 28px;
  height: 32px;
  border: 1px solid rgba(100, 200, 255, 0.3);
  border-radius: 6px;
  background: rgba(10, 14, 26, 0.8);
  color: #aab;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.3s;
  z-index: 20;
}

.panel-toggle:hover {
  background: rgba(100, 200, 255, 0.15);
  color: #fff;
}

.panel-toggle.open {
  left: 12px;
  top: 16px;
}

.panel-header h1 {
  font-size: 18px;
  background: linear-gradient(90deg, #64b5f6, #ce93d8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.panel-header .sub {
  font-size: 12px;
  color: #667;
}

/* 控制按钮 */
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  flex-wrap: wrap;
}

.controls button {
  padding: 6px 14px;
  border: 1px solid rgba(100, 200, 255, 0.3);
  border-radius: 12px;
  background: transparent;
  color: #aab;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.controls button:hover,
.controls button.active {
  background: rgba(100, 200, 255, 0.15);
  color: #fff;
  border-color: rgba(100, 200, 255, 0.5);
}

.controls .divider {
  width: 1px;
  height: 20px;
  background: rgba(100, 200, 255, 0.2);
}

.controls .label {
  font-size: 11px;
  color: #667;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #aab;
  cursor: pointer;
}

.layer-toggle input[type="checkbox"] {
  accent-color: #64b5f6;
}

/* 路径深度滑动条 */
.slider-control {
  padding: 8px 0;
}

.slider-control .label {
  font-size: 11px;
  color: #667;
  margin-bottom: 6px;
}

.slider-control .label span {
  color: #64b5f6;
  font-weight: 700;
  font-size: 13px;
}

.slider-control input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(100, 200, 255, 0.2);
  border-radius: 2px;
  outline: none;
}

.slider-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #64b5f6;
  cursor: pointer;
  border: 2px solid #0a0e1a;
  box-shadow: 0 0 6px rgba(100, 180, 246, 0.5);
}

/* 搜索 */
.search-section {
  position: relative;
}

.search-section input {
  width: 100%;
  padding: 8px 14px;
  border-radius: 20px;
  background: rgba(10, 14, 26, 0.9);
  border: 1px solid rgba(100, 200, 255, 0.3);
  color: #e0e0e0;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.search-section input:focus {
  border-color: rgba(100, 200, 255, 0.6);
}

.search-results {
  position: absolute;
  top: 40px;
  left: 0;
  width: 100%;
  background: rgba(10, 14, 26, 0.95);
  border: 1px solid rgba(100, 200, 255, 0.3);
  border-radius: 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 25;
}

.search-item {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid rgba(100, 200, 255, 0.1);
  transition: background 0.15s;
}

.search-item:hover {
  background: rgba(100, 200, 255, 0.1);
}

.type-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  margin-right: 6px;
}

.type-tag.symptom { background: rgba(0, 188, 212, 0.2); color: #00bcd4; }
.type-tag.formula { background: rgba(255, 107, 157, 0.2); color: #ff6b9d; }
.type-tag.meridian { background: rgba(255, 215, 0, 0.2); color: #ffd700; }
.type-tag.etiology { background: rgba(120, 144, 156, 0.2); color: #78909c; }
.type-tag.clause { background: rgba(206, 147, 216, 0.2); color: #ce93d8; }

.detail {
  color: #556;
  font-size: 10px;
  margin-left: 4px;
}

/* 已选节点 */
.selected-section .section-title,
.formula-section .section-title,
.clause-section .section-title {
  font-size: 14px;
  font-weight: 700;
  color: #64b5f6;
  margin-bottom: 8px;
}

.formula-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid;
  border-radius: 12px;
  font-size: 12px;
  background: rgba(100, 200, 255, 0.1);
}

.selected-tag button {
  background: none;
  border: none;
  color: #667;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
}

/* 方剂列表 */
.formula-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-bottom: 16px;
}

.formula-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(100, 200, 255, 0.15);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.formula-card:hover {
  background: rgba(255, 107, 157, 0.08);
  border-color: rgba(255, 107, 157, 0.3);
}

.formula-card.active {
  background: rgba(255, 107, 157, 0.12);
  border-color: rgba(255, 107, 157, 0.5);
}

.f-name {
  font-size: 14px;
  font-weight: 700;
  color: #ff6b9d;
  margin-bottom: 4px;
}

.f-meridian {
  font-size: 10px;
  color: #667;
  margin-bottom: 4px;
}

.f-inherit {
  font-size: 10px;
  color: #8b8000;
  margin-bottom: 4px;
}

.f-inherit .label { color: #666; }

.f-symptoms {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  background: rgba(0, 188, 212, 0.12);
  color: #00bcd4;
}

.tag.matched {
  background: rgba(0, 188, 212, 0.3);
  color: #fff;
  border: 1px solid rgba(0, 188, 212, 0.5);
}

.tag.inherited {
  background: rgba(255, 215, 0, 0.1);
  color: gold;
  border: 1px dashed rgba(255, 215, 0, 0.3);
}

.tag.excluded {
  background: rgba(255, 50, 50, 0.1);
  color: #ff6b6b;
  text-decoration: line-through;
  border: 1px dashed rgba(255, 50, 50, 0.3);
}

.f-excluded {
  margin-top: 4px;
}

/* 图形区域 */
.graph-area {
  position: relative;
  width: 100%;
  height: 100%;
}

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

.btn-reset-graph {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 8px 16px;
  border: 1px solid rgba(100, 200, 255, 0.3);
  border-radius: 8px;
  background: rgba(10, 14, 26, 0.8);
  color: #aab;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  z-index: 10;
}

.btn-reset-graph:hover {
  background: rgba(100, 200, 255, 0.15);
  color: #fff;
  border-color: rgba(100, 200, 255, 0.5);
}

/* 提示框 */
.tooltip {
  position: absolute;
  padding: 12px 16px;
  background: rgba(10, 14, 26, 0.95);
  border: 1px solid rgba(100, 200, 255, 0.3);
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 13px;
  line-height: 1.6;
  max-width: 400px;
  box-shadow: 0 0 20px rgba(0, 150, 255, 0.15);
  z-index: 100;
}

.tooltip .title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.tooltip .tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin: 2px;
}

/* 滚动条 */
.left-panel::-webkit-scrollbar,
.formula-list::-webkit-scrollbar,
.clause-list::-webkit-scrollbar,
.search-results::-webkit-scrollbar {
  width: 4px;
}

.left-panel::-webkit-scrollbar-thumb,
.formula-list::-webkit-scrollbar-thumb,
.clause-list::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
  background: rgba(100, 200, 255, 0.2);
  border-radius: 2px;
}

/* 方剂详情弹层 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  background: linear-gradient(135deg, #0f1428 0%, #1a1f3a 100%);
  border: 1px solid rgba(100, 200, 255, 0.3);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(0, 150, 255, 0.2);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #aab;
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 10;
}

.modal-close:hover {
  background: rgba(255, 100, 100, 0.2);
  border-color: rgba(255, 100, 100, 0.5);
  color: #ff6b6b;
}

.modal-header {
  padding: 24px 28px 16px;
  border-bottom: 1px solid rgba(100, 200, 255, 0.15);
}

.modal-header h2 {
  font-size: 24px;
  background: linear-gradient(90deg, #ff6b9d, #ce93d8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.modal-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
}

.modal-source {
  color: #64b5f6;
}

.modal-meridian {
  color: #ffd700;
}

.modal-body {
  padding: 20px 28px;
  overflow-y: auto;
  flex: 1;
}

.modal-section {
  margin-bottom: 20px;
}

.modal-section h3 {
  font-size: 15px;
  color: #64b5f6;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(100, 200, 255, 0.15);
}

.herb-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.herb-item {
  background: rgba(0, 188, 212, 0.08);
  border: 1px solid rgba(0, 188, 212, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

.herb-name {
  font-weight: 600;
  color: #00bcd4;
  margin-bottom: 4px;
}

.herb-dose {
  font-size: 11px;
  color: #889;
}

.modal-section p,
.modal-section div:not(.herb-list):not(.clause-list) {
  font-size: 14px;
  line-height: 1.7;
  color: #c0c0c0;
}

.modal-section .clause-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(100, 200, 255, 0.12);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.modal-section .clause-item .clause-text {
  font-size: 14px;
  color: #e0e0e0;
  line-height: 1.6;
  margin-bottom: 6px;
}

.modal-section .clause-item .clause-vernacular {
  font-size: 12px;
  color: #889;
  line-height: 1.5;
  margin-bottom: 6px;
}

.modal-section .clause-item .clause-chapter {
  font-size: 11px;
  color: #667;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(100, 200, 255, 0.2);
  border-radius: 3px;
}
