:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #ff5000;
  --primary-soft: rgba(255, 80, 0, 0.1);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-alt: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #263144;
  --primary: #ff6b2b;
  --primary-soft: rgba(255, 107, 43, 0.15);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ff5000, #ff8a00);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  display: grid;
  place-items: center;
}
.brand h1 { margin: 0; font-size: 16px; font-weight: 700; }
.subtitle { margin: 0; font-size: 12px; color: var(--text-muted); }

.nav-tabs {
  display: flex;
  gap: 6px;
  background: var(--surface-alt);
  padding: 4px;
  border-radius: 10px;
}
.nav-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
}

/* Views */
.view-container { display: none; flex: 1; }
.view-container.active { display: flex; }

/* Study View Layout */
#view-study { max-width: 1440px; width: 100%; margin: 0 auto; padding: 20px; gap: 20px; }
.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  height: fit-content;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  position: sticky;
  top: 84px;
}
.search-box input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.search-box input:focus { border-color: var(--primary); }

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 12px 0 16px;
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}
.chip.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
}

.chapter-list-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chapter-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.chapter-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
  transition: background 0.15s;
}
.chapter-item:hover { background: var(--surface-alt); }
.chapter-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.chapter-item.scroll-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--primary);
}
.chapter-count { font-size: 11px; color: var(--text-muted); background: var(--surface-alt); padding: 2px 7px; border-radius: 999px; }

.content-area { flex: 1; min-width: 0; }
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.content-header h2 { margin: 0 0 4px; font-size: 20px; }
.muted { color: var(--text-muted); font-size: 13px; margin: 0; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
}
.knowledge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.knowledge-card.mastered { border-left: 4px solid var(--success); }
.knowledge-card.starred { border-top: 3px solid var(--primary); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.card-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge {
  background: var(--surface-alt);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.card-title { margin: 0; font-size: 16px; font-weight: 700; }

.card-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.points-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
}
.points-list li { margin-bottom: 4px; }

.audio-box {
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  white-space: pre-line;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.audio-item {
  line-height: 1.68;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--surface);
  border-left: 3px solid var(--border);
}
.audio-item.is-key { border-left-color: var(--primary); }
.audio-item.is-case { border-left-color: #2563eb; }
.audio-item.is-warn { border-left-color: #ef4444; background: rgba(239, 68, 68, 0.04); }
.audio-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: 1px;
}
.audio-tag.key { background: var(--primary-soft); color: var(--primary); }
.audio-tag.case { background: rgba(37, 99, 235, 0.12); color: #2563eb; }
.audio-tag.warn { background: rgba(239, 68, 68, 0.14); color: #dc2626; }
[data-theme="dark"] .audio-tag.case { color: #60a5fa; }
[data-theme="dark"] .audio-tag.warn { color: #f87171; }
.hl-num {
  color: var(--primary);
  font-weight: 700;
  background: var(--primary-soft);
  padding: 0 3px;
  border-radius: 4px;
}
.hl-quote {
  font-weight: 700;
  color: var(--text);
  border-bottom: 1.5px dashed var(--primary);
}

/* Visual Diagram System */
.viz-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.viz-title-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.viz-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.viz-node {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.35;
}
.viz-node.highlight {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.viz-node.success {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}
.viz-step-num {
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}
.viz-arrow {
  color: var(--primary);
  font-weight: 800;
  font-size: 14px;
  user-select: none;
}

/* Cycle Ring */
.viz-cycle-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.viz-cycle-center {
  background: linear-gradient(135deg, #ff5000, #ff8a00);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(255, 80, 0, 0.25);
}
.viz-cycle-ring {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

/* VS Comparison */
.viz-vs-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 8px;
}
.viz-vs-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.viz-vs-badge {
  align-self: center;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 4px 7px;
  border-radius: 999px;
}

/* Stacked / Comparison Bars */
.viz-bar-stack {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
}
.viz-bar-seg { height: 100%; }
.viz-bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11.5px;
}
.viz-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.viz-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Formula & KPI Grid */
.viz-formula {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.viz-op {
  font-weight: 800;
  color: var(--primary);
  font-size: 14px;
}
.viz-kpi-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.viz-kpi-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 600;
}

/* Panorama Banner */
.panorama-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.panorama-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.panorama-head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.panorama-steps {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.pano-step {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}
.pano-step:hover, .pano-step.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.pano-role {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}
.pano-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
@media (max-width: 960px) {
  .panorama-steps { grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); }
}
.audio-box.empty {
  color: var(--text-muted);
  font-style: italic;
}

.user-note-input {
  width: 100%;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  resize: vertical;
  min-height: 44px;
  font-family: inherit;
}
.user-note-input:focus { outline: none; border-color: var(--primary); border-style: solid; }

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-actions { display: flex; gap: 6px; }

/* Buttons */
.btn {
  border: 1px solid transparent;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.btn-success { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.btn-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }

/* Slides Gallery */
#view-slides { flex-direction: column; max-width: 1440px; width: 100%; margin: 0 auto; padding: 20px; gap: 16px; }
.slides-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: var(--radius);
  flex-wrap: wrap;
  gap: 12px;
}
.slides-toolbar-left { display: flex; align-items: center; gap: 10px; }
.slides-toolbar-left h2 { margin: 0; font-size: 18px; }
.slides-jump { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.slides-jump input {
  width: 80px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
}
.slides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.slide-thumb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s;
}
.slide-thumb-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.slide-thumb-card img { width: 100%; aspect-ratio: 16/11; object-fit: cover; display: block; }
.slide-thumb-caption { padding: 8px 10px; font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; }
.slides-pagination { display: flex; justify-content: center; gap: 8px; padding: 12px 0; flex-wrap: wrap; }

/* Quiz & Flashcards */
#view-quiz { justify-content: center; padding: 28px 20px; }
.quiz-wrapper { max-width: 720px; width: 100%; display: flex; flex-direction: column; gap: 20px; }
.quiz-mode-switch { display: flex; gap: 10px; justify-content: center; }
.quiz-panel.hidden { display: none; }
.flashcard-counter { text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }

.flashcard {
  perspective: 1000px;
  cursor: pointer;
  min-height: 280px;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 280px;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-front, .flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 14px;
}
.flashcard-back { transform: rotateY(180deg); align-items: flex-start; text-align: left; justify-content: flex-start; overflow-y: auto; }
.card-tag { background: var(--primary-soft); color: var(--primary); padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.card-tag.success { background: var(--success-soft); color: var(--success); }
.fc-answer { font-size: 15px; line-height: 1.7; }
.fc-source { font-size: 12px; color: var(--text-muted); margin-top: auto; }
.hint { font-size: 12px; color: var(--text-muted); }
.flashcard-controls { display: flex; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.choice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.choice-options { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.choice-opt {
  text-align: left;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
  font-size: 13.5px;
}
.choice-opt.correct { background: var(--success-soft); border-color: var(--success); color: var(--success); font-weight: 600; }
.choice-opt.wrong { background: rgba(239,68,68,0.12); border-color: #ef4444; color: #ef4444; }
.choice-explain { margin-top: 10px; font-size: 13px; color: var(--text-muted); padding: 10px; background: var(--surface-alt); border-radius: 8px; }

/* Tools Sandbox */
#view-tools { max-width: 1440px; width: 100%; margin: 0 auto; padding: 20px; }
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
  width: 100%;
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tool-card h3 { margin: 0; font-size: 17px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid label, .slider-group label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.form-grid input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.slider-group { display: flex; flex-direction: column; gap: 10px; }
.slider-group input[type="range"] { width: 100%; accent-color: var(--primary); }
.result-box {
  background: var(--surface-alt);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.metric-item { display: flex; flex-direction: column; }
.metric-label { font-size: 11.5px; color: var(--text-muted); }
.metric-value { font-size: 18px; font-weight: 800; color: var(--text); }
.metric-value.good { color: var(--success); }
.metric-value.bad { color: #ef4444; }
.metric-value.highlight { color: var(--primary); }

/* Lightbox Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); }
.modal-content {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 1100px;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}
.modal-actions { display: flex; gap: 8px; }
.modal-body {
  padding: 16px;
  overflow: auto;
  display: grid;
  place-items: center;
  background: #0f172a;
}
.modal-body img { max-width: 100%; max-height: 76vh; border-radius: 6px; }

@media (max-width: 860px) {
  #view-study { flex-direction: column; }
  .sidebar { width: 100%; position: static; }
  .cards-grid { grid-template-columns: 1fr; }
}

/* Dynamic Relationship Graph View */
#view-graph { max-width: 1480px; width: 100%; margin: 0 auto; padding: 20px; }
.graph-shell { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.graph-toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.graph-toolbar-left h2 { margin: 0 0 2px; font-size: 18px; }
.graph-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.graph-workspace {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  align-items: stretch;
}
.graph-stage {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  min-height: 580px;
}
.graph-stage.panning { cursor: grabbing; }
.graph-zoom-bar {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.zoom-pct {
  font-size: 12px;
  font-weight: 700;
  min-width: 42px;
  text-align: center;
  color: var(--text);
}
#graphSvg {
  width: 100%;
  height: 100%;
  min-height: 560px;
  display: block;
  user-select: none;
}
.graph-edge-pill {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 1;
  rx: 5;
  ry: 5;
  transition: opacity 0.25s, stroke 0.25s;
}
.graph-edge-pill.active { stroke: var(--primary); }
.graph-edge-pill.dimmed { opacity: 0.15; }

.graph-edge {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
  transition: opacity 0.25s, stroke 0.25s, stroke-width 0.25s;
}
.graph-edge.flowing {
  stroke: var(--primary);
  stroke-width: 2.6;
  stroke-dasharray: 8 6;
  animation: edgeFlow 1.1s linear infinite;
}
.graph-edge.feedback {
  stroke-dasharray: 5 5;
}
.graph-edge.dimmed { opacity: 0.16; }
.graph-edge-label {
  font-size: 10.5px;
  font-weight: 600;
  fill: var(--text-muted);
  pointer-events: none;
  transition: opacity 0.25s;
}
.graph-edge-label.active { fill: var(--primary); font-weight: 700; }
.graph-edge-label.dimmed { opacity: 0.15; }

@keyframes edgeFlow {
  to { stroke-dashoffset: -28; }
}

.graph-node {
  cursor: pointer;
  transition: opacity 0.25s, transform 0.2s;
}
.graph-node.dimmed { opacity: 0.22; }
.graph-node rect {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 1.8;
  rx: 12;
  ry: 12;
  transition: stroke 0.2s, fill 0.2s, filter 0.2s;
}
.graph-node.role-boss rect { stroke: #7c3aed; }
.graph-node.role-ops rect { stroke: #2563eb; }
.graph-node.role-ads rect { stroke: #ff5000; }
.graph-node.role-core rect { stroke: #16a34a; }

.graph-node:hover rect,
.graph-node.selected rect {
  stroke-width: 2.8;
  filter: drop-shadow(0 4px 12px rgba(255, 80, 0, 0.25));
}
.graph-node.selected rect { fill: var(--primary-soft); stroke: var(--primary); }
.graph-node.neighbor rect { stroke-width: 2.4; }
.graph-node.tour-pulse rect {
  stroke: var(--primary);
  stroke-width: 3.2;
  filter: drop-shadow(0 0 14px rgba(255, 80, 0, 0.45));
}

.graph-node-role { font-size: 10px; font-weight: 700; fill: var(--text-muted); }
.graph-node-title { font-size: 13px; font-weight: 700; fill: var(--text); }
.graph-node-sub { font-size: 10.5px; fill: var(--text-muted); }

.graph-detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: fit-content;
}
.graph-detail-panel h3 { margin: 0; font-size: 17px; }
.graph-rel-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.graph-rel-item {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.graph-rel-item:hover { border-color: var(--primary); }

@media (max-width: 1060px) {
  .graph-workspace { grid-template-columns: 1fr; }
}
