/* Doc-02 专用样式 */
.code-purpose {
  font-size: 0.875rem;
  color: #475569;
  margin: 8px 0;
  padding-left: 12px;
  border-left: 3px solid #cbd5e1;
}

/* ---------- 流程图节点（D4.1） ---------- */
.flow-svg text {
  font-family: inherit;
  font-size: 13px;
  fill: #1e293b;
}
.flow-svg .node rect {
  fill: white;
  stroke: #94a3b8;
  stroke-width: 1.5;
  rx: 6;
  ry: 6;
  cursor: pointer;
  transition:
    stroke 0.2s,
    fill 0.2s;
}
.flow-svg .node:hover rect {
  fill: #fef3c7;
  stroke: #f59e0b;
}
.flow-svg .node.selected rect {
  fill: #dbeafe;
  stroke: #2563eb;
  stroke-width: 2.5;
}
.flow-svg .node-label {
  pointer-events: none;
  font-weight: 600;
}
.flow-svg .arrow {
  stroke: #cbd5e1;
  stroke-width: 2;
  fill: none;
  marker-end: url(#arrowhead);
}
.flow-svg .arrow-label {
  font-size: 11px;
  fill: #64748b;
}
.flow-detail {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 14px 16px;
  margin-top: 10px;
  font-size: 0.875rem;
  line-height: 1.65;
  color: #334155;
  min-height: 80px;
}

/* ---------- 树节点（D4.2 / D4.3 / D4.4） ---------- */
.tree-svg {
  width: 100%;
  display: block;
}
.tree-svg .link {
  fill: none;
  stroke: #cbd5e1;
  stroke-width: 1.5;
}
.tree-svg .node circle {
  fill: white;
  stroke: #6366f1;
  stroke-width: 2;
  cursor: pointer;
  transition: all 0.2s;
}
.tree-svg .node:hover circle {
  fill: #eef2ff;
  stroke: #4338ca;
  stroke-width: 3;
}
.tree-svg .node.collapsed > circle {
  fill: #fef3c7;
  stroke: #f59e0b;
}
.tree-svg .node text {
  font-size: 12px;
  fill: #1e293b;
  pointer-events: none;
}
.tree-svg .node text.weight {
  font-size: 11px;
  fill: #6b7280;
}

/* 树布局可视化（D4.3） */
.tree-layout-svg .coord-bg {
  fill: #f8fafc;
  stroke: #e2e8f0;
  stroke-width: 1;
}
.tree-layout-svg .axis text {
  font-size: 10px;
  fill: #94a3b8;
}
.tree-layout-svg .axis line {
  stroke: #cbd5e1;
  stroke-width: 1;
  stroke-dasharray: 2 2;
}

/* 树列表（D4.4） */
.tree-list {
  font-family: -apple-system, "PingFang SC", sans-serif;
  font-size: 0.875rem;
  line-height: 1.8;
  padding: 8px 0;
}
.tree-list ul {
  list-style: none;
  padding-left: 20px;
  border-left: 1px dashed #cbd5e1;
  margin: 2px 0;
  transition: opacity 0.2s ease;
}
.tree-list > ul {
  padding-left: 0;
  border-left: none;
}
.tree-list li {
  margin: 2px 0;
  cursor: pointer;
}
.tree-list li > .label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 4px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  transition: all 0.15s;
  font-size: 0.875rem;
}
.tree-list li > .label:hover {
  background: #eef2ff;
  border-color: #6366f1;
  color: #1e1b4b;
}
.tree-list li.selected > .label {
  background: #dbeafe;
  border-color: #2563eb;
  color: #1e40af;
  font-weight: 600;
}
.tree-list .toggle {
  display: inline-block;
  width: 14px;
  text-align: center;
  font-weight: 700;
  color: #6366f1;
}
.tree-list .count {
  font-size: 0.8125rem;
  color: #6b7280;
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
}

/* ---------- 控制条（共用） ---------- */
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0;
}
.controls label {
  font-size: 0.875rem;
  color: #475569;
}
.controls select,
.controls input {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  font-size: 0.875rem;
  font-family: inherit;
  background: white;
}
.controls input[type="range"] {
  width: 160px;
}

/* ---------- 演示区 ---------- */
.demo-hint {
  background: #f0f9ff;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.875rem;
  color: #0c4a6e;
  margin-bottom: 12px;
}

.demo-mount {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 16px;
  min-height: 200px;
}
.demo-mount svg {
  display: block;
  margin: 8px 0;
}

.demo-sub {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px;
  margin: 12px 0;
}
.demo-sub h4 {
  font-size: 0.875rem;
  color: #475569;
  margin-bottom: 8px;
  font-weight: 600;
}

.demo-btn {
  padding: 6px 14px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.875rem;
  cursor: pointer;
  font-family: inherit;
  margin: 4px 4px 4px 0;
}
.demo-btn:hover {
  background: #1d4ed8;
}

.demo-detail {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 14px;
  font-size: 0.875rem;
  color: #475569;
  min-height: 140px;
}
.demo-detail h4 {
  color: #1e293b;
  margin-bottom: 6px;
}

.demo-legend {
  font-size: 0.8125rem;
  color: #64748b;
  margin-top: 8px;
}

.console {
  background: #0f172a;
  color: #cbd5e1;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.8125rem;
  padding: 12px 16px;
  border-radius: 6px;
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 8px 0;
}

.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin: 12px 0;
}
.controls select {
  padding: 5px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.875rem;
  font-family: inherit;
}

.lesson-footer {
  text-align: center;
  color: #94a3b8;
  font-size: 0.8125rem;
  padding: 24px;
  border-top: 1px solid #e2e8f0;
}
/* =========================================
   Doc-03 专用样式
   ========================================= */

/* 颜色模型 demo：4 色块 + CVD 模拟 */
.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.color-cell {
  aspect-ratio: 1.6;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  color: #fff;
}
.color-cell small {
  font-size: 0.8125rem;
  opacity: 0.9;
  font-weight: 400;
}

.color-picker-row {
  display: grid;
  grid-template-columns: repeat(3, 80px) 1fr;
  gap: 8px;
  align-items: end;
  margin: 8px 0;
  font-size: 0.8125rem;
}
.color-picker-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #475569;
}
.color-picker-row input[type="range"] {
  width: 80px;
}

.color-space-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.color-space-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.8125rem;
}
.color-space-card h5 {
  margin: 0 0 6px;
  font-size: 0.875rem;
  color: #4338ca;
  font-family: "JetBrains Mono", Consolas, monospace;
}
.color-space-card p {
  margin: 4px 0;
  color: #475569;
  line-height: 1.6;
}
.color-space-card .note {
  color: #92400e;
  font-style: italic;
  font-size: 0.8125rem;
}

/* CVD 模拟显示：3 个并排色块 */
.cvd-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 8px 0;
}
.cvd-cell {
  aspect-ratio: 2;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* colormap 横向条带 */
.colormap-strip {
  display: flex;
  height: 36px;
  border-radius: 4px;
  margin: 6px 0;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
.colormap-strip > div {
  flex: 1;
}

/* 热图 */
.heatmap-svg {
  display: block;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

/* 颜色原则 demo：决策表 */
.decision-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 12px 0;
}
.decision-table th,
.decision-table td {
  border: 1px solid #e2e8f0;
  padding: 8px 10px;
  text-align: left;
}
.decision-table th {
  background: #ede9fe;
  color: #4338ca;
  font-weight: 600;
}
.decision-table td.swatch {
  width: 110px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.8125rem;
}

/* 曲线对比：左右双图 */
.curve-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
.curve-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px 12px;
}
.curve-card h5 {
  margin: 0 0 6px;
  font-size: 0.875rem;
  color: #4338ca;
  font-family: "JetBrains Mono", Consolas, monospace;
}
.curve-card p {
  margin: 0;
  font-size: 0.8125rem;
  color: #64748b;
}

/* 倾角 demo */
.slope-svg {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  display: block;
}
.slope-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  font-size: 0.875rem;
}
.slope-control input[type="range"] {
  width: 220px;
}
.slope-control .slope-readout {
  font-family: "JetBrains Mono", Consolas, monospace;
  background: #1e293b;
  color: #f1f5f9;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.875rem;
}

/* Marching Squares 网格 */
.ms-svg {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  display: block;
}
.ms-cell-rect {
  fill: #fff;
  stroke: #cbd5e1;
  stroke-width: 0.5;
}
.ms-fill {
  stroke: none;
  opacity: 0.85;
}
.ms-contour {
  fill: none;
  stroke: #1e293b;
  stroke-width: 1.5;
}
.ms-threshold-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
  font-size: 0.875rem;
}
.ms-threshold-control input[type="range"] {
  width: 280px;
}

/* 通用 demo 控件 */
.demo-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
  align-items: center;
  font-size: 0.875rem;
}
.demo-control label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 4px;
  color: #475569;
  cursor: pointer;
}
.demo-control label.active {
  background: #ede9fe;
  color: #4338ca;
  font-weight: 600;
}
.demo-control select {
  padding: 4px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  font-size: 0.875rem;
}

/* 章节内 cross-ref 提示框（指向其它章节/文档） */
.cross-ref {
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  padding: 10px 14px;
  margin: 12px 0;
  border-radius: 4px;
  font-size: 0.875rem;
  line-height: 1.7;
}
.cross-ref a {
  color: #b45309;
  font-weight: 600;
  text-decoration: underline;
}

/* =========================================
   颜色专题（5.1.3 ~ 5.1.10）专用样式
   原 doc-05 整段并入本章
   ========================================= */

/* Lab 色域图 */
.lab-gamut-svg {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  display: block;
}
.lab-marker {
  fill: #1e293b;
  stroke: #fff;
  stroke-width: 1.5;
}
.lab-ring {
  fill: none;
  stroke: #cbd5e1;
  stroke-width: 0.5;
}

/* 色系搭配：5 张配色方案并排 */
.harmony-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 12px 0;
}
.harmony-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px;
  font-size: 0.8125rem;
}
.harmony-card.active {
  background: #fef3c7;
  border-color: #f59e0b;
}
.harmony-card h5 {
  margin: 0 0 6px;
  font-size: 0.8125rem;
  color: #4338ca;
  font-family: "JetBrains Mono", Consolas, monospace;
}
.harmony-card p {
  margin: 4px 0;
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.5;
}
.harmony-swatch {
  display: flex;
  height: 32px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  margin: 4px 0;
}
.harmony-swatch > div {
  flex: 1;
}
.harmony-preview {
  height: 60px;
  border-radius: 4px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* 科研经典配色：横评矩阵 */
.palette-matrix {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px;
  margin: 12px 0;
  font-size: 0.8125rem;
}
.palette-name {
  display: flex;
  align-items: center;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 4px;
}
.palette-strip {
  display: flex;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
.palette-strip > div {
  flex: 1;
}
.palette-source {
  grid-column: 1 / -1;
  font-size: 0.8125rem;
  color: #64748b;
  padding: 0 0 8px 4px;
  font-style: italic;
}

/* 对错案例对比：投票 + 揭晓 */
.quiz-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 12px 0;
}
.quiz-card {
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.quiz-card:hover {
  border-color: #6366f1;
}
.quiz-card.correct {
  border-color: #10b981;
  background: #ecfdf5;
}
.quiz-card.wrong {
  border-color: #ef4444;
  background: #fef2f2;
}
.quiz-card svg {
  display: block;
  margin: 6px auto;
}
.quiz-card-label {
  font-size: 0.8125rem;
  text-align: center;
  color: #475569;
  margin-top: 6px;
  font-weight: 600;
}
.quiz-result {
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.875rem;
  color: #4338ca;
  margin: 8px 0;
}

/* 鲜艳+低饱和 哲学生成器 */
.philosophy-row {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  margin: 12px 0;
}
.philosophy-inputs {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px;
}
.philosophy-inputs label {
  display: flex;
  flex-direction: column;
  font-size: 0.8125rem;
  color: #475569;
  margin-bottom: 10px;
}
.philosophy-inputs input[type="range"] {
  width: 100%;
}
.philosophy-output {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px;
}
.philosophy-output h5 {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  color: #4338ca;
}
.philosophy-paper {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 6px 0;
}
.philosophy-paper-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 6px;
  font-size: 0.8125rem;
  color: #64748b;
}

/* CVD 论文图测：原图 vs CVD 模拟 */
.cvd-paper {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}
.cvd-paper-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}
.cvd-paper-card h5 {
  margin: 0 0 4px;
  font-size: 0.8125rem;
  color: #475569;
  font-weight: 600;
}
.cvd-paper-card svg {
  display: block;
  margin: 0 auto;
}
.cvd-paper-card p {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: #94a3b8;
  line-height: 1.5;
}

/* =========================================
   Doc-05 时序数据可视化 专用样式
   ========================================= */

/* 时序图通用 */
.ts-svg {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  display: block;
}
.ts-svg .hover-line {
  stroke: #1e293b;
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.ts-svg .tip {
  fill: #1e293b;
}

/* 属性卡片（5.1） */
.attr-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 12px 0;
}
.attr-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.attr-card:hover {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.attr-icon {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}
.attr-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
}
.attr-key {
  font-size: 0.8125rem;
  color: #94a3b8;
  margin-top: 2px;
  font-family: "JetBrains Mono", monospace;
}

.attr-detail-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 14px 18px;
  font-size: 0.875rem;
  line-height: 1.7;
  color: #334155;
}
.attr-detail-card h4 {
  margin: 0 0 4px;
  font-size: 1.0rem;
  color: #1e293b;
}
.attr-detail-card .example {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 0.8125rem;
  color: #475569;
}

/* 日历热图（5.3） */
.cal-svg {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  display: block;
  margin: 10px 0;
}
.cal-svg rect.cell {
  stroke: #fff;
  stroke-width: 1;
}
.cal-legend-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: #64748b;
  margin: 8px 0;
}
.legend-strip {
  display: flex;
  flex: 1;
  height: 14px;
  border-radius: 3px;
  overflow: hidden;
}
.legend-strip > div {
  flex: 1;
}
.legend-low,
.legend-high {
  font-family: "JetBrains Mono", monospace;
}

/* 螺旋（5.4） */
.spiral-svg {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  display: block;
  margin: 10px 0;
}
.spiral-svg path.seg {
  cursor: pointer;
  transition: stroke 0.15s;
}

/* Storyline（5.5） */
.storyline-svg {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  display: block;
}
.storyline-svg .event-layer circle {
  transition: r 0.15s;
}
.storyline-svg .event-layer g.event:hover circle {
  r: 22;
}

/* === 章节翻页导航 === */
@media (min-width: 561px) and (max-width: 900px) {
  .color-space-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .color-space-cards {
    grid-template-columns: 1fr;
  }
}
