/* ========== Teach (教学视频) Styles ========== */

/* ──── Tag Filter Bar ──── */
.teach-tags-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 12px;
  max-width: 1100px;
  margin: 0 auto;
  flex-wrap: wrap;
}
.teach-tags-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-light, #6b7280);
  white-space: nowrap;
}
.teach-tags-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}
.teach-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--tag-border, #e5e7eb);
  background: var(--tag-bg, #f8fafb);
  color: var(--tag-text, #374151);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.teach-tag-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.teach-tag-chip.active {
  box-shadow: 0 0 0 2px var(--tag-text, #374151);
  border-color: var(--tag-text, #374151);
}
.teach-tag-count {
  font-size: 0.7rem;
  background: rgba(0,0,0,0.08);
  padding: 0 5px;
  border-radius: 100px;
  min-width: 16px;
  text-align: center;
}
.teach-tags-clear {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 100px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #ef4444;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.teach-tags-clear:hover { background: #fef2f2; border-color: #fca5a5; }

/* Card tag badges */
.card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 0 14px 6px;
}
.card-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--tag-border, #e5e7eb);
  background: var(--tag-bg, #f8fafb);
  color: var(--tag-text, #374151);
  transition: all 0.15s;
  line-height: 1.6;
}
.card-tag:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.card-tag.tag-active {
  box-shadow: inset 0 0 0 1.5px var(--tag-text, #374151);
}

/* ---- Problem List ---- */
.teach-header {
  text-align: center;
  padding: 32px 16px 16px;
}
.teach-header h2 { margin: 0 0 8px; font-size: 1.6rem; }
.teach-header p { color: var(--text-light); margin: 0; font-size: 0.9rem; }

.teach-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

/* Filters */
.teach-filters {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 0 16px 8px;
}

/* Level tabs */
.teach-tabs {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 0 16px 12px;
}
.tt-btn {
  padding: 8px 24px;
  border-radius: 8px 8px 0 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-light, #6b7280);
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
}
.tt-btn:hover { color: var(--text, #1f2937); }
.tt-btn.active {
  color: var(--primary, #2563eb);
  border-bottom-color: var(--primary, #2563eb);
  font-weight: 700;
}

.gesp-index {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 4px; padding: 8px 4px;
  background: var(--bg, #f5f6fa);
  border-radius: 10px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.gesp-index-item {
  padding: 4px 12px; border-radius: 100px;
  font-size: 0.78rem; font-weight: 600;
  color: var(--text-light, #6b7280);
  text-decoration: none; cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--card-bg, #fff);
}
.gesp-index-item:hover {
  color: var(--primary, #2563eb);
  border-color: var(--primary, #2563eb);
}
.gesp-level-title { font-size: 1.1rem; padding: 8px 4px 4px; }
.tf-btn {
  padding: 6px 18px;
  border-radius: 100px;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--card-bg, #fff);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
  color: var(--text-light, #6b7280);
}
.tf-btn:hover { border-color: var(--primary, #2563eb); color: var(--primary, #2563eb); }
.tf-btn.active {
  background: var(--primary, #2563eb);
  color: #fff;
  border-color: var(--primary, #2563eb);
}

/* Year groups */
.teach-year-group { }
.teach-year-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #1f2937);
  margin-bottom: 12px;
  padding-left: 4px;
}
.teach-year-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.teach-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.teach-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  border-color: var(--primary, #2563eb);
}
.teach-card.card-dim {
  opacity: 0.6;
}
.teach-card.card-dim:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}
.teach-card .card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.teach-card .card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.teach-card .badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 500;
}
.teach-card .badge-diff1 { background: #dcfce7; color: #166534; }
.teach-card .badge-diff2 { background: #fef3c7; color: #92400e; }
.teach-card .badge-diff3 { background: #fde68a; color: #92400e; }
.teach-card .badge-diff4 { background: #fecaca; color: #991b1b; }
.teach-card .badge-diff5 { background: #fca5a5; color: #7f1d1d; }
.teach-card .badge-default { background: #f3f4f6; color: #374151; }
.teach-card .badge-exam { background: #dbeafe; color: #1e40af; }

.teach-card .card-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-light, #6b7280);
}
.teach-card .progress-bar {
  flex: 1;
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}
.teach-card .progress-fill {
  height: 100%;
  background: var(--primary, #2563eb);
  border-radius: 2px;
  transition: width 0.3s;
}

.teach-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light, #6b7280);
}
.teach-empty .empty-icon { font-size: 3rem; margin-bottom: 12px; }

/* ---- Player Layout ---- */
.tp-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  animation: tpFadeIn 0.2s;
}
@keyframes tpFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tp-topbar {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  gap: 12px;
  flex-shrink: 0;
}
.tp-topbar .back-btn {
  background: none;
  border: 1px solid #d1d5db;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #374151;
  transition: background 0.15s;
}
.tp-topbar .back-btn:hover { background: #f3f4f6; }
.tp-topbar .tp-title {
  flex: 1;
  font-weight: 600;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tp-topbar .tp-exam-tag {
  font-size: 0.78rem;
  padding: 3px 10px;
  background: #dbeafe;
  color: #1e40af;
  border-radius: 100px;
}

.tp-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Step Sidebar (左侧步骤导航) */
.tp-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  padding: 16px 0;
  overflow-y: auto;
}
.tp-sidebar-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  padding: 0 16px 12px;
}
.tp-step-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.tp-step-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #6b7280;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.tp-step-nav-item:hover {
  background: #f9fafb;
  color: #374151;
}
.tp-step-nav-item.active {
  background: #eff6ff;
  color: #2563eb;
  border-left-color: #2563eb;
  font-weight: 600;
}
.tp-step-nav-item.done {
  color: #059669;
}
.tp-step-nav-item .step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}
.tp-step-nav-item .step-num {
  background: #f3f4f6;
  color: #6b7280;
}
.tp-step-nav-item.active .step-num {
  background: #2563eb;
  color: #fff;
}
.tp-step-nav-item.done .step-num {
  background: #d1fae5;
  color: #059669;
}
.tp-step-nav-item .icon { font-size: 1rem; }

/* Main Content (右侧内容) */
.tp-content {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
  background: #f8fafc;
}

.tp-step-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e5e7eb;
}

/* Step Content - Markdown Rendering */
.tp-step-content {
  max-width: 800px;
}
.tp-step-content h2 {
  font-size: 1.2rem;
  margin: 24px 0 12px;
  color: #1f2937;
}
.tp-step-content h3 {
  font-size: 1.05rem;
  margin: 20px 0 10px;
  color: #374151;
}
.tp-step-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.88rem;
}
.tp-step-content th, .tp-step-content td {
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  text-align: left;
}
.tp-step-content th {
  background: #f3f4f6;
  font-weight: 600;
}
.tp-step-content tr:nth-child(even) {
  background: #fafafa;
}
.tp-step-content code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #dc2626;
}
.tp-step-content pre {
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: clamp(0.7rem, 1.8vw, 0.85rem);
  line-height: 1.6;
  margin: 12px 0;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.tp-step-content pre code {
  font-family: 'Consolas', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', monospace;
  background: transparent;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
  white-space: pre;
  color: #24292e;
}
/* Code line numbers — same as practice mode */
.tp-step-content pre table { margin: 0; padding: 0; border: none; width: auto; }
.tp-step-content pre table tr { background: transparent !important; border: none; }
.tp-step-content pre table tr:nth-child(even) { background: transparent !important; }
.tp-step-content pre table td { padding: 0; border: none; vertical-align: top; text-align: left; }
.tp-step-content pre .hljs-ln-numbers {
  text-align: right;
  color: #94a3b8 !important;
  border-right: 1px solid #d0d7de;
  padding: 0 0.8em 0 0.5em !important;
  width: 1%;
  user-select: none;
  -webkit-user-select: none;
}
.tp-step-content pre .hljs-ln-code {
  padding: 0 0 0 1em !important;
  text-align: left;
}
.tp-step-content blockquote {
  border-left: 3px solid #2563eb;
  padding: 8px 16px;
  margin: 16px 0;
  background: #eff6ff;
  border-radius: 0 8px 8px 0;
  color: #374151;
}
.tp-step-content .katex {
  font-size: 1.1em;
}

/* Animation Area */
.tp-animation-area {
  margin: 20px 0;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.tp-animation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}
.tp-animation-canvas {
  min-height: 200px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.tp-animation-desc {
  padding: 12px 16px;
  background: #f0fdf4;
  border-top: 1px solid #e5e7eb;
  font-size: 0.88rem;
  color: #166534;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tp-animation-desc::before {
  content: "💡";
}

/* Animation Controls */
.tp-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}
.tp-controls button {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
  color: #374151;
}
.tp-controls button:hover { background: #e5e7eb; }
.tp-controls button:disabled { opacity: 0.4; cursor: default; }
.tp-controls .play-btn {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  min-width: 80px;
}
.tp-controls .play-btn:hover { background: #1d4ed8; }
.tp-controls .frame-info {
  font-size: 0.82rem;
  color: #6b7280;
  padding: 0 8px;
}
.tp-controls .speed-select {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.82rem;
  color: #374151;
  cursor: pointer;
}
.tp-controls .speed-select:hover { background: #e5e7eb; }

/* ---- Animation Renderers ---- */

/* Keyword Highlight */
.anim-keyword-wrap {
  position: relative;
  line-height: 2;
}
.anim-keyword {
  display: inline;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
}
.anim-keyword.highlight {
  background: #fef08a;
  box-shadow: 0 0 0 2px #facc15;
  font-weight: 700;
}
.anim-keyword.blurred {
  opacity: 0.3;
}
.anim-popup {
  position: absolute;
  background: #1e293b;
  color: #f8fafc;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  max-width: 300px;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  animation: popIn 0.3s;
}
.anim-popup::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 20px;
  width: 12px;
  height: 12px;
  background: #1e293b;
  transform: rotate(45deg);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Code Build */
.anim-code-wrap {
  display: flex;
  gap: 20px;
  width: 100%;
}
.anim-code-lines {
  flex: 1;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.9rem;
  line-height: 1.8;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
}
.anim-code-line {
  white-space: pre;
  opacity: 0.15;
  transition: all 0.3s;
  padding-left: 8px;
  border-left: 3px solid transparent;
}
.anim-code-line.visible { opacity: 1; }
.anim-code-line.highlight {
  background: #334155;
  border-left-color: #facc15;
  opacity: 1;
  color: #fef08a;
}
.anim-var-panel {
  width: 220px;
  flex-shrink: 0;
  background: #0f172a;
  border-radius: 8px;
  padding: 12px 16px;
  color: #e2e8f0;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
}
.anim-var-panel h4 {
  color: #94a3b8;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #334155;
}
.anim-var-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}
.anim-var-name {
  color: #94a3b8;
}
.anim-var-value {
  color: #a5f3fc;
  font-weight: 600;
}
.anim-var-value.changed {
  color: #fbbf24;
  animation: varPulse 0.3s;
}
@keyframes varPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Mind Map SVG */
.anim-mindmap {
  width: 100%;
  overflow: visible;
}
.anim-mindmap text {
  font-size: 13px;
  font-weight: 500;
}
.anim-mindmap .node-rect {
  rx: 6;
  ry: 6;
  transition: all 0.3s;
}
.anim-mindmap .node-label {
  text-anchor: middle;
  dominant-baseline: middle;
  fill: #fff;
  font-size: 12px;
}
.anim-mindmap .edge-line {
  stroke: #94a3b8;
  stroke-width: 2;
  fill: none;
  transition: all 0.3s;
}

/* Slider Sim */
.anim-slider-wrap {
  width: 100%;
  max-width: 500px;
  text-align: center;
}
.anim-slider-wrap .slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
}
.anim-slider-wrap .slider-row label {
  width: 30px;
  font-weight: 700;
  color: #374151;
}
.anim-slider-wrap input[type=range] {
  flex: 1;
}
.anim-slider-wrap .slider-value {
  width: 80px;
  text-align: right;
  font-family: monospace;
  font-size: 0.9rem;
  color: #2563eb;
  font-weight: 600;
}
.anim-slider-result {
  margin-top: 20px;
  padding: 16px;
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: 700;
}
.anim-slider-result.safe {
  background: #d1fae5;
  color: #065f46;
}
.anim-slider-result.danger {
  background: #fef2f2;
  color: #991b1b;
}
.anim-slider-result .tip {
  display: block;
  font-size: 0.82rem;
  font-weight: 400;
  margin-top: 6px;
  color: #6b7280;
}

/* Complexity Bar Chart */
.anim-chart-wrap {
  width: 100%;
  max-width: 500px;
  padding: 10px 0;
}
.anim-chart-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}
.anim-chart-bar-row .bar-label {
  width: 60px;
  font-size: 0.82rem;
  color: #374151;
  text-align: right;
}
.anim-chart-bar-row .bar-track {
  flex: 1;
  height: 28px;
  background: #f3f4f6;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.anim-chart-bar-row .bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: 0.75rem;
  color: #fff;
  font-weight: 600;
  min-width: 24px;
}
.anim-chart-conclusion {
  margin-top: 16px;
  padding: 10px 16px;
  background: #eff6ff;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #2563eb;
  font-weight: 600;
  text-align: center;
}

/* ===== Bottom Controls Bar ===== */
.tp-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 24px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.tp-bottom-bar button {
  padding: 8px 20px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s;
  color: #374151;
}
.tp-bottom-bar button:hover:not(:disabled) {
  background: #f3f4f6;
}
.tp-bottom-bar button:disabled {
  opacity: 0.4;
  cursor: default;
}
.tp-bottom-bar .btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.tp-bottom-bar .btn-primary:hover {
  background: #1d4ed8;
}
.tp-bottom-bar .step-counter {
  font-size: 0.85rem;
  color: #6b7280;
}

/* Responsive */
/* =====================================================
   天天练-style Episode Player v2
   白色基底 · 大字 · 多彩 · 小朋友喜欢
   ===================================================== */

.ep-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #f8fafc;
  color: #1e293b;
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* Split body: problem panel + stage */
.ep-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Problem panel */
.ep-problem-panel {
  width: 340px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 2;
}
.ep-problem-header {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.85rem;
  color: #1e293b;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.ep-problem-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
  font-size: 0.82rem;
  line-height: 1.7;
  color: #374151;
}
.ep-problem-scroll .ep-problem-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: #1e293b;
}
.ep-problem-scroll .ep-problem-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}
.ep-problem-scroll .ep-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
}
.ep-problem-scroll .ep-problem-section {
  font-weight: 600;
  color: #3b82f6;
  margin: 12px 0 4px;
  font-size: 0.78rem;
}
.ep-problem-scroll .ep-problem-text {
  margin-bottom: 8px;
}
/* Markdown rendering in problem panel */
.ep-problem-scroll .ep-problem-md {
  line-height: 1.8;
}
.ep-problem-scroll .ep-problem-md p {
  margin: 0 0 8px;
}
.ep-problem-scroll .ep-problem-md pre {
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 10px 14px;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 8px 0;
  font-family: 'Consolas', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', monospace;
}
.ep-problem-scroll .ep-problem-md pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  white-space: pre;
  color: #24292e;
}
.ep-problem-scroll .ep-problem-md ul,
.ep-problem-scroll .ep-problem-md ol {
  padding-left: 20px;
  margin: 4px 0 8px;
}
.ep-problem-scroll .ep-problem-md li {
  margin: 2px 0;
}
.ep-problem-scroll .ep-problem-md strong {
  font-weight: 700;
  color: #1e293b;
}
.ep-problem-scroll .ep-problem-md code {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #dc2626;
}
.ep-problem-scroll .ep-problem-text code {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #dc2626;
}
.ep-problem-scroll .ep-problem-sample {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 6px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
}
/* Knowledge point hint box */
.ep-kp-box-stage {
  margin: 0 20px 6px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.6;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  z-index: 3;
  flex-shrink: 0;
  animation: epFadeIn 0.3s ease;
}
.ep-kp-box-stage .kp-label {
  font-weight: 700;
  color: #2563eb;
  font-size: 0.72rem;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}
.ep-kp-box-stage .kp-text { color: #1e293b; font-size: 0.82rem; }
.ep-kp-box-stage .kp-highlight {
  background: #fef08a;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}
@keyframes epFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ep-divider {
  width: 6px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 5;
  transition: background 0.15s;
}
.ep-divider:hover, .ep-divider.dragging { background: #e5e7eb; }
.ep-divider::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 32px;
  background: #d1d5db;
  border-radius: 1px;
  transition: background 0.15s;
}
.ep-divider:hover::after, .ep-divider.dragging::after { background: #3b82f6; }

.ep-kp-badge {
  position: absolute; top: 10px; right: 12px; z-index: 10;
  font-size: 0.72rem; color: #3b82f6;
  background: rgba(255,255,255,0.92); border: 1px solid #bfdbfe;
  border-radius: 100px; padding: 4px 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  pointer-events: none; max-width: 55%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ep-mindmap {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 20px 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  width: 100%; max-width: 90%; animation: epPopIn 0.35s ease;
}
.mm-node { font-size: 0.9rem; line-height: 1.8; color: #374151; padding: 3px 8px; margin: 1px 0; border-left: 3px solid #e5e7eb; }

/* Scene accent strip */
.ep-scene-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  z-index: 5;
  transition: background 0.5s ease;
}
/* All scene types use blue accent */
.ep-scene-accent.type-intro { background: #3b82f6; }
.ep-scene-accent.type-error { background: #3b82f6; }
.ep-scene-accent.type-thinking { background: #3b82f6; }
.ep-scene-accent.type-aha { background: #3b82f6; }
.ep-scene-accent.type-demo { background: #3b82f6; }
.ep-scene-accent.type-trap { background: #3b82f6; }
.ep-scene-accent.type-code { background: #3b82f6; }
.ep-scene-accent.type-summary { background: #3b82f6; }
.ep-scene-accent.type-weapon { background: #3b82f6; }
.ep-scene-accent.type-quiz { background: #3b82f6; }

/* Top bar */
.ep-topbar {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  z-index: 10;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.ep-back {
  background: #f1f5f9;
  border: none;
  color: #475569;
  padding: 8px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s;
}
.ep-back:hover { background: #e2e8f0; }
.ep-toggle-problem {
  display: none;
  background: #f1f5f9;
  border: none;
  color: #475569;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
}
.ep-toggle-problem:hover { background: #e2e8f0; }
.ep-title {
  flex: 1;
  font-weight: 700;
  font-size: 1.05rem;
  color: #1e293b;
}
.ep-time {
  font-size: 0.85rem;
  color: #94a3b8;
  font-family: 'SF Mono', 'JetBrains Mono', monospace;
  font-weight: 500;
}

/* Stage */
.ep-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  background: #f8fafc;
  transition: background 0.5s ease;
}
.ep-stage.has-code .ep-visual,
.ep-stage.has-code .ep-codevars {
  overflow-y: auto;
}
/* Scene tint */
.ep-stage.has-intro { background: #f8fafc; }
.ep-stage.has-error { background: #fef2f2; }
.ep-stage.has-thinking { background: #f0f9ff; }
.ep-stage.has-aha { background: #f0fdf4; }
.ep-stage.has-demo { background: #faf5ff; }
.ep-stage.has-trap { background: #fffbeb; }
.ep-stage.has-code { background: #f8fafc; }
.ep-stage.has-summary { background: #ecfeff; }
.ep-stage.has-weapon { background: #fff7ed; }

/* Subtle geometric pattern overlay — very faint */
.ep-stage::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  opacity: 0.03;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle at 20% 30%, #3b82f6 1px, transparent 1px),
    radial-gradient(circle at 80% 70%, #3b82f6 1px, transparent 1px),
    radial-gradient(circle at 40% 80%, #3b82f6 1px, transparent 1px),
    radial-gradient(circle at 70% 20%, #22c55e 1px, transparent 1px);
  background-size: 80px 80px, 100px 100px, 60px 60px, 90px 90px;
}
/* Tech-y circuit-like lines on some scenes */
.ep-stage.has-code::before {
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 40px, rgba(59,130,246,0.05) 40px, rgba(59,130,246,0.05) 41px),
    repeating-linear-gradient(90deg, transparent, transparent 40px, rgba(59,130,246,0.05) 40px, rgba(59,130,246,0.05) 41px);
  opacity: 0.06;
}
.ep-stage.has-weapon::before {
  background-image:
    radial-gradient(circle at 15% 85%, #f97316 2px, transparent 2px),
    radial-gradient(circle at 85% 15%, #f59e0b 2px, transparent 2px),
    radial-gradient(circle at 50% 50%, #3b82f6 1px, transparent 1px);
  background-size: 60px 60px, 80px 80px, 100px 100px;
  opacity: 0.04;
}
.ep-stage.has-thinking::before {
  background-image:
    linear-gradient(135deg, transparent 18px, rgba(59,130,246,0.04) 18px, rgba(59,130,246,0.04) 20px, transparent 20px),
    linear-gradient(225deg, transparent 18px, rgba(59,130,246,0.04) 18px, rgba(59,130,246,0.04) 20px, transparent 20px);
  background-size: 28px 28px;
  opacity: 0.05;
}

/* Visual area */
.ep-visual {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  padding: 6px 24px 16px;
  min-height: 0;
  overflow-y: auto;
}
.ep-visual::-webkit-scrollbar { width: 6px; }
.ep-visual::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.ep-visual::-webkit-scrollbar-track { background: transparent; }
.ep-visual.has-codevars {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 6px 20px 16px;
}
.ep-visual.has-deck,
.ep-visual.has-flowchart,
.ep-visual.has-treedemo {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 10px 24px 18px;
}
.ep-visual > * {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  padding: 16px 20px;
  max-width: 100%;
}
.ep-visual > .ep-bigtext {
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 0;
}
.ep-visual > .ep-code,
.ep-visual > .ep-code-trace,
.ep-visual > .ep-nl {
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
/* Deck and code_vars are self-contained — strip the generic wrapper styles */
.ep-visual > .ep-deck {
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 8px 16px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.ep-visual > .ep-codevars {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0 !important;
  width: 100%;
}
.ep-emoji-bg {
  position: absolute;
  font-size: 7rem;
  opacity: 0.08;
  right: 5%;
  top: 5%;
  pointer-events: none;
  animation: epFloat 4s ease-in-out infinite;
}
@keyframes epFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-16px) rotate(3deg); }
}

/* Big text display */
.ep-bigtext {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.8;
  color: #1e293b;
  z-index: 1;
  animation: epPopIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ep-bigtext div { margin: 6px 0; }
.ep-bigtext div:first-child { font-size: 1.8rem; }
@keyframes epPopIn {
  from { opacity: 0; transform: scale(0.85) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ─── Deck: structured rich text ─── */
.ep-deck {
  width: 100%;
  max-width: 100%;
  padding: 8px 12px;
  animation: epPopIn 0.3s ease;
  box-sizing: border-box;
}
.ep-deck-h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e293b;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 3px solid #2563eb;
  line-height: 1.3;
  width: 100%;
  box-sizing: border-box;
}
.ep-deck-h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #2563eb;
  margin: 14px 0 8px 0;
  line-height: 1.3;
  width: 100%;
  box-sizing: border-box;
}
.ep-deck-para {
  font-size: 1rem;
  color: #475569;
  line-height: 1.7;
  margin: 6px 0;
  width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.ep-deck-callout {
  background: #eff6ff;
  border-left: 4px solid #2563eb;
  border-radius: 0 8px 8px 0;
  padding: 12px 20px;
  margin: 10px 0;
  font-size: 1rem;
  color: #1e293b;
  line-height: 1.6;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
}
.ep-deck-tip {
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  border-radius: 0 8px 8px 0;
  padding: 12px 20px;
  margin: 10px 0;
  font-size: 0.95rem;
  color: #92400e;
  line-height: 1.6;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
}
.ep-deck-formula {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  background: #f1f5f9;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 12px 20px;
  margin: 10px 0;
  font-size: 0.95rem;
  color: #1e293b;
  white-space: pre-wrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  word-break: break-word;
}
.ep-deck-formula .katex,
.ep-deck-formula .katex * {
  white-space: nowrap;
}
.ep-deck-formula .katex-display,
.ep-deck .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  padding-bottom: 2px;
}
.ep-deck-bullet {
  padding: 4px 0 4px 8px;
  font-size: 1rem;
  color: #334155;
  line-height: 1.6;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.ep-deck-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  min-width: 8px;
  background: #2563eb;
  border-radius: 50%;
  margin-top: 7px;
}
.ep-deck-sbullet {
  padding: 2px 0 2px 28px;
  font-size: 0.92rem;
  color: #475569;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.ep-deck-sdot {
  display: inline-block;
  width: 5px;
  height: 5px;
  min-width: 5px;
  background: #94a3b8;
  border-radius: 50%;
  margin-top: 7px;
}
.ep-deck-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 5px 0;
}
.ep-deck-card-label {
  font-weight: 600;
  color: #334155;
  font-size: 0.95rem;
}
.ep-deck-card-val {
  font-family: 'JetBrains Mono', monospace;
  color: #2563eb;
  font-weight: 700;
  font-size: 1rem;
  background: #eff6ff;
  padding: 2px 10px;
  border-radius: 4px;
}

/* ──── Deck Table (rendered from | lines) ──── */
.ep-deck-tw {
  margin: 8px 0;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.ep-deck-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}
.ep-deck-table th {
  background: #f1f5f9;
  color: #1e293b;
  font-weight: 700;
  padding: 8px 12px;
  text-align: center;
  border-bottom: 2px solid #cbd5e1;
  border-right: 1px solid #e2e8f0;
  font-size: 0.82rem;
  white-space: nowrap;
}
.ep-deck-table th:last-child { border-right: none; }
.ep-deck-table td {
  padding: 8px 16px;
  text-align: center;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
  color: #334155;
  font-size: clamp(0.85rem, 1.4vw, 0.95rem);
  line-height: 1.6;
}
.ep-deck-table td:last-child { border-right: none; }
.ep-deck-table tbody tr:hover { background: #f8fafc; }
.ep-deck-table tbody tr:last-child td { border-bottom: none; }
/* Row header (first column) */
.ep-dt-rh {
  font-weight: 700;
  color: #1e293b;
  background: #fafbfc;
  border-right: 1px solid #e2e8f0 !important;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  min-width: 32px;
}
/* Highlight rows with ← marker */
.ep-deck-table td:last-child:matches(←) { background: #fef3c7; }

/* ──── DP Grid (animated DP table) ──── */
.ep-dpgrid { margin: 10px 0; }
.ep-dpgrid-wrap { overflow-x: auto; }
.ep-dpgrid-tbl {
  border-collapse: collapse;
  font-size: 0.82rem;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  margin: 0 auto;
}
.ep-dpgrid-tbl th {
  background: #f1f5f9;
  color: #1e293b;
  font-weight: 700;
  padding: 7px 10px;
  text-align: center;
  border: 1px solid #e2e8f0;
  min-width: 32px;
}
.ep-dpgrid-cnr { background: #e9eef3 !important; min-width: 28px; }
.ep-dpgrid-rh {
  background: #f8fafb !important;
  font-family: 'JetBrains Mono', monospace;
}
.ep-dpgrid-cell {
  padding: 7px 10px;
  text-align: center;
  border: 1px solid #f1f5f9;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-weight: 600;
  font-size: 0.9rem;
  color: #94a3b8;
  background: #fafbfc;
  transition: all 0.3s ease;
  min-width: 36px;
}
.ep-dpgrid-ready {
  color: #475569;
  background: #fff;
}
.ep-dpgrid-done {
  color: #065f46;
  background: #d1fae5;
  border-color: #6ee7b7;
}
.ep-dpgrid-hl {
  color: #fff !important;
  background: #3b82f6 !important;
  border-color: #2563eb !important;
  animation: dpg-pulse 0.8s ease-in-out infinite alternate;
  box-shadow: 0 0 12px rgba(59,130,246,0.4);
  transform: scale(1.05);
  z-index: 1;
  position: relative;
}
@keyframes dpg-pulse {
  from { box-shadow: 0 0 8px rgba(59,130,246,0.3); transform: scale(1.03); }
  to   { box-shadow: 0 0 16px rgba(59,130,246,0.6); transform: scale(1.07); }
}
.ep-dpgrid-desc {
  text-align: center;
  font-size: 0.9rem;
  color: #1e293b;
  margin-top: 10px;
  font-weight: 600;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .ep-dpgrid-tbl { background: #0d1117; border-color: #30363d; }
  .ep-dpgrid-tbl th { background: #161b22; color: #c9d1d9; border-color: #30363d; }
  .ep-dpgrid-cnr { background: #0d1117 !important; }
  .ep-dpgrid-rh { background: #161b22 !important; color: #c9d1d9; }
  .ep-dpgrid-cell { color: #484f58; background: #0d1117; border-color: #21262d; }
  .ep-dpgrid-ready { color: #c9d1d9; background: #0d1117; }
  .ep-dpgrid-done { color: #7ee787; background: #0a2e1a; border-color: #238636; }
  .ep-deck-table { background: #0d1117; border-color: #30363d; }
  .ep-deck-table th { background: #161b22; color: #c9d1d9; border-bottom-color: #30363d; border-right-color: #30363d; }
  .ep-deck-table td { color: #c9d1d9; border-bottom-color: #21262d; border-right-color: #21262d; }
  .ep-deck-table tbody tr:hover { background: #161b22; }
  .ep-dt-rh { background: #0d1117; color: #c9d1d9; border-right-color: #30363d !important; }
}
.ep-deck-para {
  font-size: clamp(0.9rem, 1.6vw, 1.05rem);
  color: #475569;
  line-height: 1.7;
  margin: 6px 0;
  width: 100%;
  box-sizing: border-box;
}
/* Code blocks in deck */
.ep-deck-code {
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 16px 20px;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 12px 0;
  font-size: clamp(0.85rem, 1.6vw, 1rem);
  line-height: 1.7;
  max-width: 100%;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}
.ep-deck-code code {
  font-family: 'Consolas', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', monospace;
  background: transparent;
  padding: 0;
  font-size: inherit;
  white-space: pre;
  color: #24292e;
}

/* Code display */
.ep-code {
  background: #f6f8fa;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px 24px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: clamp(0.85rem, 1.5vw, 1rem);
  line-height: 2;
  max-width: 100%;
  width: 100%;
  overflow-x: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  animation: epPopIn 0.35s ease;
  box-sizing: border-box;
}
.ep-code-line {
  white-space: pre;
  color: #24292e;
  transition: all 0.2s;
}
.ep-code-line.highlight {
  color: #b91c1c;
  background: #fef2f2;
  border-left: 3px solid #ef4444;
  padding-left: 14px;
  margin-left: -17px;
  font-weight: 600;
}
.ep-code-trace {
  background: #f6f8fa;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px 20px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.95rem;
  line-height: 1.9;
  max-width: 92%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  animation: epPopIn 0.35s ease;
}
.ep-code-trace .trace-line { color: #374151; white-space: pre; }
.ep-code-trace .trace-line.highlight {
  color: #b91c1c;
  background: #fef2f2;
  border-left: 3px solid #ef4444;
  padding-left: 12px;
  margin-left: -15px;
  font-weight: 600;
}
.ep-code-trace .trace-label {
  color: #3b82f6;
  font-weight: 700;
  font-size: 0.82rem;
  margin-bottom: 8px;
}

/* Number line */
.ep-nl {
  text-align: center;
  animation: epPopIn 0.35s ease;
  background: #f8fafc;
  border-radius: 12px;
  padding: 24px 32px;
  border: 1px solid #e5e7eb;
  max-width: 90%;
}
.ep-nl-label {
  font-size: 1.2rem;
  margin-bottom: 16px;
  font-weight: 600;
  color: #1e293b;
}
.ep-nl-track {
  width: 280px;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  margin: 12px auto;
  position: relative;
}
.ep-nl-point {
  position: absolute;
  top: -14px;
  transform: translateX(-50%);
  font-size: 1.4rem;
  animation: epBounce 1s ease-in-out infinite;
}
@keyframes epBounce {
  0%, 100% { top: -14px; }
  50% { top: -22px; }
}
.ep-nl-extra {
  margin-top: 10px;
  font-size: 0.95rem;
  color: #64748b;
}

/* Dialogue area */
/* Chat area — top of stage */
.ep-chat {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 20px 6px;
  z-index: 3;
  flex-shrink: 0;
  min-height: 70px;
}
.ep-chat-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.ep-chat-content { flex: 1; min-width: 0; }
.ep-chat-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 3px;
  padding-left: 4px;
}
.ep-chat-name.xiaowen { color: #1d4ed8; }
.ep-chat-name.xiaozhi { color: #15803d; }
.ep-chat-name.narrator { color: #64748b; }
.ep-chat-bubble {
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 6px 18px 18px 18px;
  padding: 12px 18px;
  font-size: 1.1rem;
  line-height: 1.6;
  color: #1e293b;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
  display: inline-block;
  max-width: 100%;
  word-break: break-word;
  font-weight: 500;
}
.ep-stage.has-intro .ep-chat-bubble { border-color: #3b82f6; }
.ep-stage.has-error .ep-chat-bubble { border-color: #ef4444; }
.ep-stage.has-thinking .ep-chat-bubble { border-color: #3b82f6; }
.ep-stage.has-aha .ep-chat-bubble { border-color: #22c55e; }
.ep-stage.has-demo .ep-chat-bubble { border-color: #3b82f6; }
.ep-stage.has-trap .ep-chat-bubble { border-color: #f59e0b; }
.ep-stage.has-code .ep-chat-bubble { border-color: #1e293b; }
.ep-stage.has-summary .ep-chat-bubble { border-color: #06b6d4; }
.ep-stage.has-weapon .ep-chat-bubble { border-color: #f97316; }

/* Progress bar */
.ep-progress {
  padding: 0 16px;
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #f1f5f9;
}
.ep-progress-track {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.ep-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #3b82f6);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.ep-progress-dots {
  display: flex;
  gap: 5px;
  padding: 8px 0 4px;
  justify-content: center;
  flex-wrap: wrap;
}
.ep-dot { width: 8px; height: 8px; border-radius: 50%; background: #e5e7eb; cursor: pointer; transition: all 0.2s; flex-shrink: 0; }
.ep-dot.active { background: #3b82f6; transform: scale(1.6); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }
.ep-dot.done { background: #93c5fd; }
.ep-dot-star { background: #f59e0b; }

/* End-of-episode card overlay */
.ep-end-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  animation: epFadeIn 0.3s ease;
}
.ep-end-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  max-width: 400px;
  width: 90%;
  animation: epPopIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.ep-end-icon { font-size: 4rem; margin-bottom: 12px; }
.ep-end-title { font-size: 1.4rem; font-weight: 800; color: #1e293b; margin-bottom: 8px; }
.ep-end-sub { font-size: 0.95rem; color: #64748b; margin-bottom: 24px; line-height: 1.5; }
.ep-end-btn {
  display: block;
  width: 100%;
  padding: 14px 0;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  background: linear-gradient(135deg,#2563eb,#3b82f6);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
  margin-bottom: 10px;
}
.ep-end-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(37,99,235,0.4); }
.ep-end-btn-ghost {
  background: #f1f5f9;
  color: #475569;
  box-shadow: none;
}
.ep-end-btn-ghost:hover { background: #e2e8f0; transform: translateY(-1px); box-shadow: none; }

/* Controls */
.ep-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 20px 14px;
  background: #fff;
  flex-shrink: 0;
  border-top: 1px solid #f1f5f9;
}
.ep-ctrl {
  background: #f1f5f9; border: none; color: #475569; padding: 8px 16px; border-radius: 10px;
  cursor: pointer; font-size: 1.05rem; transition: all 0.15s; min-width: 44px; font-weight: 600;
}
.ep-ctrl:hover { background: #e2e8f0; color: #1e293b; }
.ep-ctrl:disabled { opacity: 0.35; cursor: default; }
.ep-play-btn { background: #3b82f6; color: #fff; min-width: 60px; font-size: 1.1rem; box-shadow: 0 2px 8px rgba(59,130,246,0.3); }
.ep-play-btn:hover { background: #2563eb; color: #fff; }
.ep-speed {
  background: #f1f5f9; border: none; color: #475569; padding: 6px 12px; border-radius: 8px;
  font-size: 0.85rem; cursor: pointer; margin-left: 8px; font-weight: 500;
}
.ep-speed option { background: #fff; color: #1e293b; }
.ep-frame-num { font-size: 0.85rem; color: #94a3b8; margin-left: 8px; font-family: 'SF Mono', 'JetBrains Mono', monospace; font-weight: 500; }
.ep-viz-btn { background: #059669; color: #fff; border-color: #059669; font-size: 0.8rem; margin-left: auto; padding: 4px 12px; white-space: nowrap; }
.ep-viz-btn:hover { background: #047857; color: #fff; }
.dark-mode .ep-viz-btn { background: #059669; color: #fff; border-color: #059669; }
.dark-mode .ep-viz-btn:hover { background: #047857; }

/* End Screen */
.ep-endscreen { text-align: center; z-index: 1; animation: epPopIn 0.5s ease; padding: 40px 20px; }
.ep-end-icon { font-size: 5rem; margin-bottom: 16px; animation: epBounce 1.5s ease-in-out infinite; }
.ep-endscreen h2 { font-size: 1.8rem; margin: 0 0 10px; color: #1e293b; }
.ep-endscreen p { font-size: 1.1rem; color: #64748b; margin: 0 0 28px; }
.ep-end-btn {
  background: #3b82f6; border: none; color: #fff; padding: 12px 32px; border-radius: 100px;
  font-size: 1.05rem; font-weight: 600; cursor: pointer; margin: 0 6px; transition: all 0.2s;
  box-shadow: 0 2px 10px rgba(59,130,246,0.3);
}
.ep-end-btn:hover { background: #2563eb; transform: translateY(-1px); }
.ep-end-btn-ghost { background: #f1f5f9; color: #475569; box-shadow: none; }
.ep-end-btn-ghost:hover { background: #e2e8f0; }

/* Quiz */
.ep-quiz { text-align: center; z-index: 1; max-width: 560px; width: 92%; animation: epPopIn 0.4s ease; }
.ep-quiz-header { font-size: 0.9rem; color: #94a3b8; margin-bottom: 16px; font-weight: 500; }
.ep-quiz-question { font-size: 1.25rem; font-weight: 700; line-height: 1.6; margin-bottom: 24px; color: #1e293b; }
.ep-quiz-options { display: flex; flex-direction: column; gap: 12px; }
.ep-quiz-opt {
  background: #fff; border: 2px solid #e5e7eb; color: #1e293b; padding: 16px 22px; border-radius: 14px;
  font-size: 1.1rem; font-weight: 500; cursor: pointer; transition: all 0.2s; text-align: left;
}
.ep-quiz-opt:hover { border-color: #3b82f6; background: #eff6ff; }
.ep-quiz-opt:disabled { cursor: default; }
.ep-quiz-opt.correct { background: #f0fdf4; border-color: #22c55e; color: #166534; }
.ep-quiz-opt.wrong { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
.ep-quiz-feedback { margin-top: 20px; }
.ep-quiz-fb { padding: 14px 20px; border-radius: 12px; font-weight: 600; font-size: 1.05rem; margin-bottom: 16px; }
.ep-quiz-fb.correct { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.ep-quiz-fb.wrong { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.ep-quiz-explain { font-weight: 400; font-size: 0.95rem; margin-top: 10px; color: #64748b; line-height: 1.5; }
.ep-quiz-next {
  background: #3b82f6; border: none; color: #fff; padding: 12px 28px; border-radius: 100px;
  font-size: 1.05rem; font-weight: 600; cursor: pointer; transition: all 0.15s;
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}
.ep-quiz-next:hover { background: #2563eb; transform: translateY(-1px); }

/* Quiz Page (separate from animation) */
.tq-root { max-width: 600px; margin: 0 auto; padding: 0 16px 40px; }
.tq-topbar { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border,#e5e7eb); position: sticky; top: 0; z-index: 10; background: var(--bg,#f5f6fa); }
.tq-back { color: var(--primary,#2563eb); text-decoration: none; font-size: 0.9rem; }
.tq-back:hover { text-decoration: underline; }
.tq-title { flex: 1; font-weight: 700; font-size: 1rem; color: #1e293b; }
.tq-score { font-size: 0.85rem; font-weight: 700; color: #3b82f6; }
.tq-progress-bar { height: 4px; background: #e5e7eb; border-radius: 2px; margin-bottom: 20px; overflow: hidden; }
.tq-progress-fill { height: 100%; background: linear-gradient(90deg,#3b82f6,#3b82f6); border-radius: 2px; transition: width 0.4s ease; }
.tq-quiz-card { background: #fff; border-radius: 16px; padding: 24px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); margin-top: 16px; }
.tq-q-header { font-size: 0.8rem; color: #94a3b8; margin-bottom: 12px; font-weight: 500; }
.tq-q-question { font-size: 1.15rem; font-weight: 700; line-height: 1.6; margin-bottom: 20px; color: #1e293b; }
.tq-q-options { display: flex; flex-direction: column; gap: 10px; }
.tq-q-opt { background: #f8fafc; border: 2px solid #e5e7eb; color: #1e293b; padding: 14px 18px; border-radius: 12px; font-size: 1rem; font-weight: 500; cursor: pointer; transition: all 0.15s; text-align: left; }
.tq-q-opt:hover { border-color: #3b82f6; background: #eff6ff; }
.tq-q-opt:disabled { cursor: default; }
.tq-q-opt.correct { background: #f0fdf4; border-color: #22c55e; color: #166534; }
.tq-q-opt.wrong { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
.tq-q-feedback { margin-top: 16px; }
.tq-fb { padding: 12px 16px; border-radius: 10px; font-weight: 600; font-size: 1rem; margin-bottom: 12px; }
.tq-fb.correct { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.tq-fb.wrong { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.tq-explain { font-weight: 400; font-size: 0.88rem; margin-top: 8px; color: #64748b; line-height: 1.5; }
.tq-next-btn { background: #3b82f6; border: none; color: #fff; padding: 10px 24px; border-radius: 100px; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.15s; box-shadow: 0 2px 8px rgba(59,130,246,0.3); }
.tq-next-btn:hover { background: #2563eb; transform: translateY(-1px); }
.tq-result { text-align: center; padding: 40px 20px; }
.tq-result-icon { font-size: 4rem; margin-bottom: 12px; }
.tq-result h2 { font-size: 1.4rem; margin: 0 0 8px; color: #1e293b; }
.tq-result-score { font-size: 1.1rem; color: #64748b; margin: 0 0 24px; }
.tq-result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.tq-btn { display: inline-block; background: #3b82f6; color: #fff; padding: 10px 24px; border-radius: 100px; font-size: 0.9rem; font-weight: 600; text-decoration: none; transition: all 0.15s; box-shadow: 0 2px 8px rgba(59,130,246,0.3); }
.tq-btn:hover { background: #2563eb; }
.tq-btn-ghost { background: #f1f5f9; color: #475569; box-shadow: none; }
.tq-btn-ghost:hover { background: #e2e8f0; }

/* =====================================================
   Problem View (题目预览页)
   ===================================================== */
.tpv-root {
  max-width: 960px;
  margin: 0 auto;
}
.tpv-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--bg, #fff);
  position: sticky;
  top: 0;
  z-index: 20;
}
.tpv-topbar::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0; right: 0;
  height: 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.04), transparent);
  pointer-events: none;
}
.tpv-problem {
  padding: 0 16px 40px;
}
.tpv-back {
  color: var(--primary, #2563eb);
  text-decoration: none;
  font-size: 0.9rem;
}
.tpv-back:hover { text-decoration: underline; }
.tpv-badge {
  font-size: 0.78rem;
  padding: 2px 10px;
  background: #dbeafe;
  color: #1e40af;
  border-radius: 100px;
}
.tpv-diff { font-size: 0.85rem; color: #f59e0b; }
.tpv-title {
  font-size: 1.5rem;
  margin: 0 0 8px;
}
.tpv-meta {
  font-size: 0.82rem;
  color: var(--text-light, #6b7280);
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}
.tpv-section {
  margin: 20px 0;
}
.tpv-section h2 {
  font-size: 1.05rem;
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  color: var(--text, #1f2937);
}
.tpv-md {
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--text, #374151);
}
.tpv-md code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: #dc2626;
}
.tpv-md pre {
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: clamp(0.7rem, 1.8vw, 0.85rem);
  line-height: 1.6;
  margin: 12px 0;
}
.tpv-md pre code {
  font-family: 'Consolas', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', monospace;
  background: transparent;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
  white-space: pre;
  color: #24292e;
}
/* ──── Markdown tables in problem view ──── */
.tpv-md table,
.ep-problem-scroll .ep-problem-md table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.85rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tpv-md th,
.tpv-md td,
.ep-problem-scroll .ep-problem-md th,
.ep-problem-scroll .ep-problem-md td {
  border: 1px solid #d0d7de;
  padding: 6px 10px;
  text-align: center;
  white-space: nowrap;
}
.tpv-md th,
.ep-problem-scroll .ep-problem-md th {
  background: #f3f4f6;
  font-weight: 700;
  color: #1f2937;
  font-size: 0.82rem;
}
.tpv-md tbody tr:nth-child(even),
.ep-problem-scroll .ep-problem-md tbody tr:nth-child(even) {
  background: #fafbfc;
}
.tpv-md tbody tr:hover,
.ep-problem-scroll .ep-problem-md tbody tr:hover {
  background: #f0f4ff;
}
/* Style the ^ (same-as-above) marker in Luogu-style tables */
.tpv-md td:first-child,
.ep-problem-scroll .ep-problem-md td:first-child {
  font-weight: 600;
  color: #4b5563;
}

.tpv-sample {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin: 10px 0;
  overflow: hidden;
}
.tpv-sample-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.tpv-sample-col {
  padding: 10px 14px;
}
.tpv-sample-col:first-child {
  border-right: 1px solid #e5e7eb;
}
.tpv-sample-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-light, #6b7280);
  margin-bottom: 6px;
}
.tpv-sample-col pre {
  margin: 0;
  font-size: 0.85rem;
  background: none;
  padding: 0;
  color: inherit;
  white-space: pre-wrap;
}

/* Cartoon entry button */
.tpv-cartoon-entry {
  text-align: center;
  margin: 32px 0;
}
.tpv-play-btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border: none;
  padding: 16px 36px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(37,99,235,0.4);
}
.tpv-play-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(37,99,235,0.5);
}
.tpv-play-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.tpv-play-text {
  font-size: 1.2rem;
  font-weight: 700;
}
.tpv-play-sub {
  font-size: 0.8rem;
  opacity: 0.7;
  display: block;
  font-weight: 400;
  margin-top: 2px;
}

.tpv-original {
  text-align: center;
  margin-top: 24px;
  font-size: 0.82rem;
}
.tpv-original a {
  color: var(--text-light, #6b7280);
  text-decoration: none;
}
.tpv-original a:hover { color: var(--primary, #2563eb); text-decoration: underline; }

/* ──── Meta items ──── */
.tpv-meta { display: flex; gap: 16px; padding: 0; flex-wrap: wrap; margin: 8px 0 16px; }
.tpv-meta-item { display: inline-flex; align-items: center; gap: 4px; font-size: 0.82rem; color: var(--text-light, #6b7280); background: #f8fafb; padding: 4px 12px; border-radius: 100px; border: 1px solid #e5e7eb; }
.tpv-meta-icon { font-size: 0.9rem; }

/* =====================================================
   Mobile Optimizations
   ===================================================== */

@media (max-width: 768px) {
  /* Teach List */
  .teach-header { padding: 20px 12px 12px; }
  .teach-header h2 { font-size: 1.2rem; }
  .teach-header p { font-size: 0.8rem; }
  .teach-tabs { gap: 0; padding: 0 8px 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tt-btn { padding: 8px 16px; font-size: 0.82rem; white-space: nowrap; }
  .teach-filters { gap: 6px; padding: 0 12px 8px; overflow-x: auto; justify-content: flex-start; }
  .tf-btn { padding: 5px 14px; font-size: 0.78rem; white-space: nowrap; flex-shrink: 0; }
  .teach-list { padding: 8px; gap: 16px; }
  .teach-year-label { font-size: 0.9rem; padding-left: 2px; }
  .teach-year-grid { grid-template-columns: 1fr; gap: 8px; }
  .teach-card { padding: 14px; }
  .teach-card .card-title { font-size: 0.95rem; }
  .teach-card .badge { font-size: 0.72rem; padding: 1px 8px; }

  /* Problem View */
  .tpv-root { padding: 0; }
  .tpv-topbar { padding: 10px 12px; }
  .tpv-topbar::after { display: none; }
  .tpv-back { font-size: 0.82rem; padding: 6px 12px; }
  .tpv-badge { font-size: 0.7rem; padding: 1px 8px; }
  .tpv-diff { font-size: 0.75rem; }
  .tpv-title { font-size: 1.2rem; padding: 0 12px; }
  .tpv-meta { font-size: 0.75rem; padding: 0 12px; gap: 10px; }
  .tpv-problem { padding: 0 12px 24px; }
  .tpv-section h2 { font-size: 0.95rem; }
  .tpv-md { font-size: 0.85rem; }
  .tpv-md pre { font-size: 0.78rem; padding: 10px 12px; }
  .tpv-sample-row { grid-template-columns: 1fr; }
  .tpv-sample-col:first-child { border-right: none; border-bottom: 1px solid #e5e7eb; }
  .tpv-sample-col { padding: 8px 12px; }
  .tpv-sample-col pre { font-size: 0.78rem; }

  /* Cartoon Button */
  .tpv-cartoon-entry { margin: 20px 0; }
  .tpv-play-btn { padding: 12px 24px; width: 90%; max-width: 320px; }
  .tpv-play-icon { width: 36px; height: 36px; font-size: 1rem; }
  .tpv-play-text { font-size: 1rem; }
  .tpv-play-sub { font-size: 0.75rem; }

  /* Episode Player */
  .ep-topbar { padding: 8px 12px; }
  .ep-back { padding: 6px 12px; font-size: 0.82rem; }
  .ep-title { font-size: 0.9rem; }
  .ep-time { font-size: 0.72rem; }
  .ep-visual { padding: 4px 12px 10px; }
  .ep-visual > * { padding: 10px 14px; }
  .ep-bigtext { font-size: 1.2rem; }
  .ep-bigtext div:first-child { font-size: 1.35rem; }
  .ep-bigtext div { margin: 3px 0; }
  .ep-chat { padding: 10px 12px 4px; min-height: 56px; }
  .ep-chat-avatar { width: 32px; height: 32px; font-size: 1.1rem; }
  .ep-chat-name { font-size: 0.7rem; }
  .ep-chat-bubble { font-size: 0.92rem; padding: 10px 14px; border-radius: 6px 14px 14px 14px; }
  .ep-code { font-size: 0.78rem; padding: 12px 14px; line-height: 1.7; max-width: 98%; }
  .ep-code-line.highlight { padding-left: 10px; margin-left: -13px; }
  .ep-code-trace { font-size: 0.78rem; padding: 10px 14px; line-height: 1.6; max-width: 98%; }
  .ep-nl { padding: 16px 20px; }
  .ep-nl-label { font-size: 1rem; }
  .ep-nl-track { width: 180px; }
  .ep-emoji-bg { font-size: 4rem; }
  .ep-visual.has-deck,
  .ep-visual.has-flowchart,
  .ep-visual.has-treedemo { padding: 8px 16px 16px; }
  .ep-deck { max-width: 100%; }
  .ep-deck-h1 { font-size: 1.15rem; }
  .ep-deck-h2 { font-size: 0.95rem; }
  .ep-deck-formula { font-size: 0.8rem; padding: 8px 12px; }
  .ep-deck-callout, .ep-deck-tip { padding: 10px 14px; font-size: 0.88rem; }

  /* Controls - bigger touch targets */
  .ep-controls { padding: 6px 12px 12px; gap: 6px; }
  .ep-ctrl { padding: 10px 14px; min-width: 44px; min-height: 44px; font-size: 1rem; }
  .ep-play-btn { min-width: 52px; }
  .ep-speed { padding: 8px 10px; min-height: 44px; }
  .ep-frame-num { font-size: 0.75rem; }
  .ep-progress-dots { gap: 4px; padding: 6px 0 2px; }
  .ep-dot { width: 6px; height: 6px; }

  /* Quiz & End screen */
  .ep-quiz { max-width: 100%; width: 95%; }
  .ep-quiz-question { font-size: 1.05rem; }
  .ep-quiz-opt { padding: 14px 16px; font-size: 0.95rem; border-radius: 12px; }
  .ep-endscreen { padding: 24px 16px; }
  .ep-end-icon { font-size: 3.5rem; }
  .ep-endscreen h2 { font-size: 1.35rem; }
  .ep-end-btn { padding: 10px 22px; font-size: 0.9rem; display: block; width: 80%; margin: 8px auto; }
  .ep-end-btn-ghost { margin-top: 4px; }

  /* Code Vars */
  .ep-codevars {
    flex-direction: column;
    gap: 10px;
  }
  .ep-codevars-code {
    font-size: 0.72rem;
    padding: 6px 0;
  }
  .ep-codevars-line { padding: 0 8px 0 0; }
  .ep-codevars-line .ep-cv-ln {
    width: 2.2em;
    min-width: 2.2em;
    padding: 0 0.6em 0 0.3em;
  }
  .ep-codevars-vars {
    width: 100%;
    font-size: 0.78rem;
  }
  .ep-cv-toprow {
    flex-direction: column;
  }
  .ep-cv-rightstack {
    width: 100%;
  }
  .ep-cv-desc {
    position: static;
    transform: none;
    border-radius: 6px;
    white-space: normal;
    text-align: center;
  }
}

/* =====================================================
   Code Vars — code animation with variable tracking
   (matches practice mode code styling)
   ===================================================== */
.ep-codevars {
  display: flex;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  align-items: flex-start;
  animation: epPopIn 0.3s ease;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  position: relative; /* anchor for .ep-cv-desc */
  min-height: 0;
  overflow-y: auto;
}

.ep-codevars-code {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  overflow-x: auto;
  overflow-y: auto;
  font-family: 'Consolas', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', monospace;
  font-size: clamp(0.7rem, 1.6vw, 0.85rem);
  line-height: 1.7;
  padding: 10px 0;
}

.ep-codevars-line {
  white-space: pre;
  padding: 0 16px 0 0;
  color: #24292e;
  transition: background 0.2s, border-color 0.2s;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
}

.ep-codevars-line .ep-cv-ln {
  display: inline-block;
  width: 3em;
  min-width: 3em;
  text-align: right;
  color: #94a3b8;
  padding: 0 1em 0 0.5em;
  border-right: 1px solid #d0d7de;
  margin-right: 1em;
  user-select: none;
  font-size: 0.9em;
}

.ep-codevars-line.highlight {
  background: #fef2f2;
  border-left-color: #ef4444;
  font-weight: 600;
}

.ep-codevars-line.highlight .ep-cv-ln {
  color: #ef4444;
  font-weight: 700;
}

/* Syntax highlighting — matches practice mode C++ feel */
.ep-cv-kw { color: #d73a49; font-weight: 600; }       /* keywords */
.ep-cv-comment { color: #6a737d; font-style: italic; } /* comments */
.ep-cv-num { color: #0550ae; }                         /* number literals */

/* Variable panel */
.ep-codevars-vars {
  width: 280px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 12px 16px;
  font-family: 'Consolas', 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 0.82rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.ep-cv-vars-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e5e7eb;
}

.ep-cv-var-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid #f3f4f6;
  transition: all 0.3s;
}

.ep-cv-var-row:last-child {
  border-bottom: none;
}

.ep-cv-var-name {
  color: #2563eb;
  font-weight: 600;
  font-size: 0.85rem;
}

.ep-cv-var-val {
  color: #374151;
  font-weight: 500;
  background: #f3f4f6;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 0.82rem;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ep-cv-var-row.changed {
  background: #fefce8;
  border-radius: 4px;
  margin: 0 -4px;
  padding: 4px;
}

.ep-cv-var-row.changed .ep-cv-var-val {
  background: #fef08a;
  color: #92400e;
  font-weight: 700;
  animation: cvVarPulse 0.4s ease;
}

@keyframes cvVarPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Description below code */
.ep-cv-desc {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30,41,59,0.85);
  color: #f8fafc;
  padding: 6px 16px;
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
}

/* Interactive trace button inside code_vars */
.ep-cv-interact-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
.ep-cv-interact-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,99,235,0.4);
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
}
.ep-cv-interact-btn:active {
  transform: translateY(0);
}
.ep-cv-ib-sub { font-weight:400; font-size:0.75rem; opacity:0.85; }
.dark-mode .ep-cv-interact-btn {
  box-shadow: 0 2px 8px rgba(37,99,235,0.2);
}

/* Top row: code + right panel */
.ep-cv-toprow {
  display: flex;
  gap: 12px;
  width: 100%;
  align-items: flex-start;
}

/* Right stack: variables + tree */
.ep-cv-rightstack {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Tree visualization panel */
.ep-cv-tree {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 10px 8px 6px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.ep-cv-tree svg {
  max-width: 100%;
  height: auto;
}

/* Dark mode for code_vars — matches practice mode */
@media (prefers-color-scheme: dark) {
  .ep-codevars-code {
    background: #161b22;
    border-color: #30363d;
  }
  .ep-codevars-line { color: #c9d1d9; }
  .ep-codevars-line .ep-cv-ln {
    color: #6e7681;
    border-right-color: #30363d;
  }
  .ep-codevars-line.highlight {
    background: #2d1b1b;
    border-left-color: #ef4444;
  }
  .ep-codevars-line.highlight .ep-cv-ln { color: #ef4444; }
  .ep-cv-kw { color: #ff7b72; }
  .ep-cv-comment { color: #8b949e; }
  .ep-cv-num { color: #79c0ff; }
  .ep-codevars-vars {
    background: #161b22;
    border-color: #30363d;
  }
  .ep-cv-vars-title {
    color: #8b949e;
    border-bottom-color: #30363d;
  }
  .ep-cv-var-name { color: #93c5fd; }
  .ep-cv-var-val {
    color: #c9d1d9;
    background: #21262d;
  }
  .ep-cv-var-row.changed {
    background: #3d2e00;
  }
  .ep-cv-var-row.changed .ep-cv-var-val {
    background: #3d2e00;
    color: #fbbf24;
  }
  .ep-cv-tree {
    background: #161b22;
    border-color: #30363d;
  }
  .ep-cv-tree .ep-cv-vars-title {
    color: #8b949e;
    border-bottom-color: #30363d;
  }
}

/* =====================================================
   Flowchart — algorithm steps as process diagram
   ===================================================== */
.ep-flowchart {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 8px 0;
  animation: epPopIn 0.35s ease;
}
.ep-fw-box {
  width: 85%;
  max-width: 520px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: all 0.2s;
}
.ep-fw-box:hover {
  border-color: #bfdbfe;
  box-shadow: 0 4px 16px rgba(59,130,246,0.1);
}
.ep-fw-step-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: #3b82f6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.ep-fw-step-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.4;
}
.ep-fw-step-title code {
  background: #eff6ff;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #2563eb;
}
.ep-fw-details {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ep-fw-detail-row {
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.5;
  padding: 2px 0 2px 12px;
  border-left: 3px solid #e5e7eb;
  margin-left: 4px;
}
.ep-fw-detail-row code {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #dc2626;
}
.ep-fw-detail-row.cond-true {
  border-left-color: #22c55e;
}
.ep-fw-detail-row.cond-false {
  border-left-color: #ef4444;
}
.ep-fw-detail-row.cond-branch {
  border-left-color: #f59e0b;
}
.ep-fw-arrow {
  font-size: 1.3rem;
  color: #94a3b8;
  padding: 2px 0;
  line-height: 1;
  user-select: none;
}
/* Flowchart sub-branch container */
.ep-fw-branches {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}
.ep-fw-branch {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
  text-align: center;
  color: #374151;
  line-height: 1.3;
  transition: all 0.15s;
}
.ep-fw-branch.cond-true {
  border-top: 3px solid #22c55e;
  background: #f0fdf4;
}
.ep-fw-branch.cond-false {
  border-top: 3px solid #ef4444;
  background: #fef2f2;
}
.ep-fw-branch.cond-leaf {
  border-top: 3px solid #3b82f6;
  background: #eff6ff;
}
.ep-fw-branch code {
  background: transparent;
  padding: 0;
  font-size: 0.85em;
  color: #dc2626;
}

@media (prefers-color-scheme: dark) {
  .ep-fw-box {
    background: #161b22;
    border-color: #30363d;
  }
  .ep-fw-box:hover {
    border-color: #3b82f6;
  }
  .ep-fw-step-title {
    color: #c9d1d9;
  }
  .ep-fw-step-num {
    color: #93c5fd;
  }
  .ep-fw-detail-row {
    color: #8b949e;
    border-left-color: #30363d;
  }
  .ep-fw-detail-row code {
    background: #21262d;
    color: #f87171;
  }
  .ep-fw-details {
    border-top-color: #30363d;
  }
  .ep-fw-branch {
    background: #0d1117;
    border-color: #30363d;
    color: #c9d1d9;
  }
  .ep-fw-branch.cond-true {
    background: #1a2e1a;
    border-top-color: #22c55e;
  }
  .ep-fw-branch.cond-false {
    background: #2d1b1b;
    border-top-color: #ef4444;
  }
  .ep-fw-branch.cond-leaf {
    background: #1c1a3e;
    border-top-color: #3b82f6;
  }
  .ep-fw-branches {
    border-top-color: #30363d;
  }
  .ep-fw-arrow {
    color: #6e7681;
  }
}

/* ─── Tree Demo: annotated tree walkthrough ─── */
.ep-treedemo {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 560px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px 20px 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  animation: epPopIn 0.35s ease;
}
.ep-treedemo svg {
  width: 100%;
  max-height: 200px;
  overflow: visible;
}
.ep-treedemo-label {
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #1e293b;
  text-align: center;
  font-weight: 500;
}
.ep-treedemo-label .hl { color: #3b82f6; font-weight: 700; }
.ep-treedemo-label.is-current {
  background: #eff6ff;
  border-color: #3b82f6;
  font-weight: 600;
}

/* Accumulated results list — stays across steps */
.ep-treedemo-results {
  width: 100%;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ep-treedemo-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
  animation: epResultIn 0.3s ease;
}
@keyframes epResultIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}
.ep-treedemo-result.is-ok {
  background: #f0fdf4;
  color: #166534;
  border-left: 3px solid #22c55e;
}
.ep-treedemo-result.is-fail {
  background: #fef2f2;
  color: #991b1b;
  border-left: 3px solid #ef4444;
}
.ep-treedemo-result.is-info {
  background: #f8fafc;
  color: #475569;
  border-left: 3px solid #94a3b8;
}

@media (prefers-color-scheme: dark) {
  .ep-treedemo-result.is-ok {
    background: #1a2e1a;
    color: #4ade80;
    border-left-color: #22c55e;
  }
  .ep-treedemo-result.is-fail {
    background: #2d1b1b;
    color: #f87171;
    border-left-color: #ef4444;
  }
  .ep-treedemo-result.is-info {
    background: #0d1117;
    color: #8b949e;
    border-left-color: #30363d;
  }
  .ep-treedemo-label.is-current {
    background: #1c1a3e;
    border-color: #3b82f6;
  }
}
.ep-treedemo-label .ok { color: #22c55e; font-weight: 700; }
.ep-treedemo-label .fail { color: #ef4444; font-weight: 700; }
.ep-treedemo-step {
  width: 100%;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #eff6ff;
  border-radius: 100px;
  font-size: 0.85rem;
}
.ep-treedemo-step-num {
  background: #3b82f6;
  color: #fff;
  padding: 2px 10px;
  border-radius: 100px;
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}
.ep-treedemo-step-text {
  color: #1d4ed8;
  font-weight: 500;
}

@media (prefers-color-scheme: dark) {
  .ep-treedemo {
    background: #161b22;
    border-color: #30363d;
  }
  .ep-treedemo-label {
    background: #0d1117;
    border-color: #30363d;
    color: #c9d1d9;
  }
  .ep-treedemo-step {
    background: #1c1a3e;
  }
  .ep-treedemo-step-text {
    color: #93c5fd;
  }
}

/* =====================================================
   Dark Mode (match practice code style)
   ===================================================== */
@media (prefers-color-scheme: dark) {
  .tp-step-content pre { background: #161b22; border-color: #30363d; }
  .tp-step-content pre code { color: #c9d1d9; }
  .tp-step-content pre .hljs-ln-numbers { color: #6e7681 !important; border-right-color: #30363d; }
  .tpv-md pre { background: #161b22; border-color: #30363d; }
  .tpv-md pre code { color: #c9d1d9; }
  .ep-problem-scroll .ep-problem-md pre { background: #161b22; border-color: #30363d; }
  .ep-problem-scroll .ep-problem-md pre code { color: #c9d1d9; }
  .ep-problem-scroll .ep-meta-item { background: #1e293b; color: #94a3b8; }
  .ep-deck-code { background: #161b22; border-color: #30363d; }
  .ep-deck-code code { color: #f0f6fc; }
  /* Code visual type dark mode */
  .ep-code { background: #161b22; border-color: #30363d; }
  .ep-code-line { color: #f0f6fc; }
  .ep-code-line.highlight { color: #fca5a5; background: #3d1c1c; border-left-color: #ef4444; }
  .ep-code-trace { background: #161b22; border-color: #30363d; }
  .ep-code-trace .trace-line { color: #f0f6fc; }
  /* Dark mode tables */
  .tpv-md th, .ep-problem-scroll .ep-problem-md th { background: #161b22; color: #c9d1d9; border-color: #30363d; }
  .tpv-md td, .ep-problem-scroll .ep-problem-md td { border-color: #30363d; color: #c9d1d9; }
  .tpv-md tbody tr:nth-child(even), .ep-problem-scroll .ep-problem-md tbody tr:nth-child(even) { background: #0d1117; }
  .tpv-md tbody tr:hover, .ep-problem-scroll .ep-problem-md tbody tr:hover { background: #1c2333; }
  /* Dark mode deck tables */
  .ep-deck-table { background: #0d1117; border-color: #30363d; }
  .ep-deck-table th { background: #161b22; color: #f0f6fc; border-bottom-color: #30363d; border-right-color: #30363d; }
  .ep-deck-table td { color: #f0f6fc; border-bottom-color: #21262d; border-right-color: #21262d; }
  .ep-deck-table tbody tr:hover { background: #161b22; }
  .ep-dt-rh { color: #f0f6fc; background: #0d1117; border-right-color: #30363d !important; }
  /* Dark mode formula */
  .ep-deck-formula { background: #161b22; border-color: #30363d; color: #c9d1d9; }
  .ep-deck-formula ::-webkit-scrollbar { height: 4px; }
  .ep-deck-formula ::-webkit-scrollbar-thumb { background: #484f58; border-radius: 2px; }
  .ep-deck-formula ::-webkit-scrollbar-track { background: transparent; }
  /* Keep top and stage backgrounds light in dark mode */
  .ep-root, .ep-topbar, .ep-stage { background: #f8fafc !important; }
  .ep-stage.has-intro, .ep-stage.has-error, .ep-stage.has-thinking,
  .ep-stage.has-aha, .ep-stage.has-demo, .ep-stage.has-trap,
  .ep-stage.has-code, .ep-stage.has-summary, .ep-stage.has-weapon { background: #f8fafc !important; }
  .ep-problem-panel { background: #fff !important; }
  .ep-problem-scroll .ep-meta-item { background: #1e293b; color: #94a3b8; }
}

/* ──── p5.js Canvas ──── */
.ep-p5-canvas {
  width: 100%;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  overflow: hidden;
}
.ep-p5-canvas canvas {
  display: block;
  max-width: 100%;
  height: auto !important;
  border-radius: 8px;
}
.ep-visual.has-p5canvas {
  padding: 0;
  background: transparent;
}

/* Dark mode p5 canvas */
.dark-mode .ep-p5-canvas {
  background: #0d1117;
}

/* ──── Manim Video ──── */
.ep-manim-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.ep-manim-video {
  width: 100%;
  display: block;
  border-radius: 12px;
}
.dark-mode .ep-manim-wrap {
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* ===== Interactive Code Visualizer (icode-viz) ===== */

.icv-root {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.icv-container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
  overflow: hidden;
}

/* Header */
.icv-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  color: #fff;
}
.icv-back {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}
.icv-back:hover { background: rgba(255,255,255,0.25); }
.icv-title { font-size: 1rem; font-weight: 700; letter-spacing: 0.01em; }

/* Input area */
.icv-input-area {
  padding: 14px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}
.icv-input-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
  display: block;
}
.icv-input-row {
  display: flex;
  gap: 8px;
}
.icv-input {
  flex: 1;
  padding: 8px 14px;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: 'Consolas', 'JetBrains Mono', 'Fira Code', monospace;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
  color: #111827;
}
.icv-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.icv-run-btn {
  padding: 8px 22px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.icv-run-btn:hover { background: #1d4ed8; }
.icv-input-readonly {
  background: #f3f4f6 !important;
  color: #6b7280 !important;
  cursor: default !important;
  border-color: #e5e7eb !important;
}
.icv-readonly-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  color: #9ca3af;
  background: #f3f4f6;
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
  font-weight: 500;
}
.dark-mode .icv-input-readonly { background: #1c2128 !important; color: #484f58 !important; border-color: #30363d !important; }
.dark-mode .icv-readonly-badge { background: #1c2128; color: #484f58; }

/* Body: code + vars side by side */
.icv-body {
  display: flex;
  gap: 0;
  min-height: 320px;
}
.icv-code-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e5e7eb;
}
.icv-viz-panel {
  width: 320px;
  flex-shrink: 0;
  display: none;
  flex-direction: column;
  border-right: 1px solid #e5e7eb;
  background: #fafbfc;
}
.icv-viz-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
  min-height: 200px;
}
.dark-mode .icv-viz-panel { background: #161b22; }
.dark-mode .icv-viz-content svg text { fill: #c9d1d9; }
.icv-vars-panel {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #fafbfc;
}
@media (max-width: 720px) {
  .icv-body { flex-direction: column; }
  .icv-vars-panel { width: 100%; border-top: 1px solid #e5e7eb; }
  .icv-code-panel { border-right: none; }
}

.icv-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  background: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.icv-code-hint { font-weight: 400; color: #9ca3af; font-size: 0.75rem; }
.icv-vars-changed {
  font-size: 0.75rem;
  color: #d97706;
  font-weight: 500;
  animation: icv-fadeIn 0.2s;
}

/* Code scroll area */
.icv-code-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  background: #fff;
  font-family: 'Consolas', 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 0.88rem;
  line-height: 1.55;
  max-height: 420px;
}
.icv-code-line {
  display: flex;
  padding: 1px 0;
  transition: background 0.15s;
  min-height: 22px;
}
.icv-code-line:hover { background: #f8fafc; }
.icv-code-line.icv-code-hl {
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
}
.icv-code-line.icv-code-active {
  background: #fef3c7;
  border-left: 3px solid #d97706;
  font-weight: 600;
}
.icv-line-num {
  width: 3em;
  flex-shrink: 0;
  text-align: right;
  padding-right: 12px;
  color: #94a3b8;
  font-size: 0.78rem;
  user-select: none;
  border-right: 1px solid #e5e7eb;
  margin-right: 10px;
}
.icv-code-hl .icv-line-num, .icv-code-active .icv-line-num {
  color: #d97706;
  font-weight: 700;
}
.icv-line-content {
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1e293b;
}

/* Syntax highlighting */
.icv-syn-comment { color: #6a737d; font-style: italic; }
.icv-syn-kw { color: #d73a49; font-weight: 700; }
.icv-syn-num { color: #0550ae; }
.icv-syn-str { color: #0a3069; }
.icv-syn-inc { color: #8250df; }
.icv-code-hl .icv-syn-comment, .icv-code-active .icv-syn-comment { color: #9a8560; }
.icv-code-hl .icv-syn-kw, .icv-code-active .icv-syn-kw { color: #b33644; }

/* Variable panel */
.icv-vars-body {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
  max-height: 300px;
}
.icv-vars-empty {
  color: #9ca3af;
  font-size: 0.85rem;
  text-align: center;
  padding: 40px 0;
  font-style: italic;
}
.icv-var-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  margin-bottom: 2px;
  font-family: 'Consolas', 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.icv-var-row:hover { background: #f3f4f6; }
.icv-var-row.icv-var-changed {
  background: #fefce8;
  animation: icv-var-flash 0.6s ease-out;
}
.icv-var-row.icv-var-output {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}
.icv-var-name {
  color: #4f46e5;
  font-weight: 600;
  min-width: 60px;
}
.icv-var-val {
  color: #111827;
  font-weight: 500;
  word-break: break-all;
}
.icv-var-pulse {
  font-size: 0.75rem;
  animation: icv-pulse 0.6s ease-out;
}
@keyframes icv-var-flash {
  0% { background: #fef08a; transform: translateX(0); }
  100% { background: #fefce8; transform: translateX(0); }
}
@keyframes icv-pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes icv-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Output section */
.icv-output { border-top: 1px solid #e5e7eb; }
.icv-output-text {
  padding: 8px 12px;
  margin: 0;
  font-family: 'Consolas', 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  color: #059669;
  background: #f0fdf4;
  white-space: pre-wrap;
  max-height: 80px;
  overflow-y: auto;
}

/* Description */
.icv-desc {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  border-bottom: 1px solid #fde68a;
  font-size: 0.88rem;
  color: #92400e;
  min-height: 44px;
}
.icv-desc-icon { flex-shrink: 0; }
.icv-desc-text { line-height: 1.45; }

/* Controls */
.icv-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: #f8fafc;
  border-top: 1px solid #e5e7eb;
}
.icv-controls-left {
  display: flex;
  align-items: center;
  gap: 6px;
}
.icv-ctrl {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s;
  color: #374151;
}
.icv-ctrl:hover:not(:disabled) { background: #f3f4f6; border-color: #9ca3af; }
.icv-ctrl:disabled { opacity: 0.4; cursor: not-allowed; }
.icv-ctrl.icv-play { background: #2563eb; color: #fff; border-color: #2563eb; }
.icv-ctrl.icv-play:hover { background: #1d4ed8; border-color: #1d4ed8; }
.icv-step-info {
  font-size: 0.82rem;
  color: #6b7280;
  font-weight: 500;
  min-width: 60px;
  text-align: center;
}
.icv-controls-center {
  flex: 1;
  min-width: 60px;
}
.icv-progress-bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}
.icv-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.icv-controls-right {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #6b7280;
  white-space: nowrap;
}
.icv-speed {
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 0.82rem;
  background: #fff;
  color: #374151;
  cursor: pointer;
}
.icv-input-compact {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}
.icv-input-compact .icv-input {
  width: 110px;
  padding: 3px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.78rem;
  font-family: 'SF Mono','Consolas',monospace;
  background: #fff;
  color: #374151;
}
.icv-input-compact .icv-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
  outline: none;
}
.icv-input-compact .icv-run-btn {
  padding: 3px 8px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.78rem;
  cursor: pointer;
  font-weight: 600;
}
.icv-input-compact .icv-run-btn:hover { background: #1d4ed8; }
.dark-mode .icv-input-compact .icv-input { background: #0d1117; border-color: #30363d; color: #c9d1d9; }
.dark-mode .icv-input-compact .icv-input:focus { border-color: #58a6ff; box-shadow: 0 0 0 2px rgba(88,166,255,0.15); }
.dark-mode .icv-input-compact .icv-run-btn { background: #1f6feb; }

/* Dark mode */
.dark-mode .icv-container { background: #1a1d23; box-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2); }
.dark-mode .icv-header { background: linear-gradient(135deg, #0f2744 0%, #1e3a5f 100%); }
.dark-mode .icv-input-area { background: #161b22; border-color: #30363d; }
.dark-mode .icv-input-label { color: #c9d1d9; }
.dark-mode .icv-input { background: #0d1117; border-color: #30363d; color: #c9d1d9; }
.dark-mode .icv-input:focus { border-color: #58a6ff; box-shadow: 0 0 0 3px rgba(88,166,255,0.15); }
.dark-mode .icv-code-panel { border-color: #30363d; }
.dark-mode .icv-vars-panel { background: #161b22; }
.dark-mode .icv-panel-header { background: #1c2128; border-color: #30363d; color: #c9d1d9; }
.dark-mode .icv-code-scroll { background: #0d1117; }
.dark-mode .icv-code-line:hover { background: #161b22; }
.dark-mode .icv-code-line.icv-code-hl { background: #3d2e00; border-left-color: #d29922; }
.dark-mode .icv-code-line.icv-code-active { background: #3d2e00; border-left-color: #bb8009; }
.dark-mode .icv-line-num { color: #484f58; border-color: #30363d; }
.dark-mode .icv-code-hl .icv-line-num, .dark-mode .icv-code-active .icv-line-num { color: #d29922; }
.dark-mode .icv-line-content { color: #c9d1d9; }
.dark-mode .icv-syn-comment { color: #8b949e; }
.dark-mode .icv-syn-kw { color: #ff7b72; }
.dark-mode .icv-syn-num { color: #79c0ff; }
.dark-mode .icv-syn-str { color: #a5d6ff; }
.dark-mode .icv-syn-inc { color: #d2a8ff; }
.dark-mode .icv-vars-empty { color: #484f58; }
.dark-mode .icv-var-row:hover { background: #1c2128; }
.dark-mode .icv-var-row.icv-var-changed { background: #3d2e00; }
.dark-mode .icv-var-name { color: #a5d6ff; }
.dark-mode .icv-var-val { color: #c9d1d9; }
.dark-mode .icv-output-text { background: #0d2818; color: #3fb950; }
.dark-mode .icv-desc { background: #3d2e00; border-color: #bb8009; color: #d29922; }
.dark-mode .icv-controls { background: #161b22; border-color: #30363d; }
.dark-mode .icv-ctrl { background: #21262d; border-color: #30363d; color: #c9d1d9; }
.dark-mode .icv-ctrl:hover:not(:disabled) { background: #30363d; }
.dark-mode .icv-ctrl.icv-play { background: #1f6feb; border-color: #1f6feb; }
.dark-mode .icv-step-info { color: #8b949e; }
.dark-mode .icv-speed { background: #21262d; border-color: #30363d; color: #c9d1d9; }
.icv-fullscreen { background: #fff; }
.icv-fullscreen.icv-root {
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
.dark-mode .icv-fullscreen { background: #0d1117; }
