/* web — light, elegant theme (轻松淡雅) */
:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --text: #333333;
  --text-muted: #666666;
  --accent: #6b9b9b;
  --accent-soft: #e8f0f0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
  --border: rgba(0, 0, 0, 0.06);
  --font-sans: "Segoe UI", "Noto Sans SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
}

/* Layout */
.site-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header & nav */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}

.site-header .site-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.site-title a {
  color: inherit;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  display: block;
  padding: 0.4rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  transition: color 0.2s, background 0.2s;
}

.site-nav a:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.site-nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 500;
}

/* Main content */
main {
  padding: 2rem 0 3rem;
}

.page-title {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text);
}

.page-lead {
  margin: 0 0 2rem;
  color: var(--text-muted);
  font-size: 1rem;
}

/* Cards grid (home) */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.card-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Buttons / links */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--surface);
  text-decoration: none;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  transition: opacity 0.2s, background 0.2s;
}

.btn:hover {
  opacity: 0.9;
  background: #5d8989;
}

/* Footer */
.site-footer {
  margin-top: auto;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
}

/* Content block (for app pages) */
.content-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow);
}

.content-block h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.content-block p {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
}

.content-block p:last-child {
  margin-bottom: 0;
}

/* Chapter outline list (e.g. DSA app) */
.chapter-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chapter-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.chapter-num {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chapter-body {
  flex: 1;
  min-width: 0;
}

.chapter-title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.chapter-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Chapter content: make chapter-item a link */
a.chapter-item {
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s;
}
a.chapter-item:hover {
  box-shadow: var(--shadow-hover);
}

/* Article (long-form chapter content) */
.article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow);
}
.article .article-title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}
.article .article-meta {
  margin: 0 0 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.article h2 {
  margin: 1.75rem 0 0.6rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}
.article h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.article p {
  margin: 0 0 0.85rem;
  color: var(--text);
  line-height: 1.75;
}
.article ul, .article ol {
  margin: 0 0 0.85rem;
  padding-left: 1.5rem;
  color: var(--text);
  line-height: 1.75;
}
.article li { margin: 0.25rem 0; }
.article .tip, .article .story-box {
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.article .tip strong, .article .story-box strong { color: var(--accent); }
.article .story-box { font-style: italic; }
.article .article-nav {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.article .article-nav a { color: var(--accent); text-decoration: none; }
.article .article-nav a:hover { text-decoration: underline; }

/* Figures and diagrams */
.article .figure {
  margin: 1.5rem 0;
  text-align: center;
}
.article .figure-caption {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.article .diagram-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.article .diagram-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.article .diagram-panel svg { display: block; margin: 0 auto; }
.article .diagram-panel .label { font-size: 0.85rem; font-weight: 600; margin-top: 0.5rem; color: var(--text); }
.article .diagram-panel .sublabel { font-size: 0.8rem; color: var(--text-muted); }

/* Efficiency comparison bars */
.article .compare-bars { margin: 1.5rem 0; max-width: 360px; margin-left: auto; margin-right: auto; }
.article .compare-row { display: flex; align-items: center; gap: 0.75rem; margin: 0.5rem 0; }
.article .compare-row .label { flex: 0 0 120px; font-size: 0.9rem; color: var(--text); }
.article .compare-row .bar-wrap { flex: 1; height: 24px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.article .compare-row .bar { height: 100%; border-radius: 6px; transition: width 0.8s ease-out; }
.article .compare-row .bar.slow { background: rgba(200, 120, 120, 0.5); animation: barFull 0.8s ease-out; }
.article .compare-row .bar.fast { width: 8%; background: var(--accent-soft); color: var(--accent); animation: barGrow 0.8s ease-out 0.4s both; }
@keyframes barFull { from { width: 0; } to { width: 100%; } }
@keyframes barGrow { from { width: 0; } to { width: 8%; } }
.article .compare-row .bar-value { flex: 0 0 60px; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }

/* Binary search demo: numbered cells + shrinking range + step labels */
.article .binary-demo-wrap { max-width: 420px; margin: 1.5rem auto; }
.article .binary-demo-title { font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; text-align: center; }
.article .binary-demo {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 3px;
  margin: 0 auto;
  max-width: 380px;
  height: 48px;
  position: relative;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 6px;
  border: 1px solid var(--border);
}
.article .binary-demo .cell {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  transition: opacity 0.35s, background 0.35s;
}
.article .binary-demo .cell.discarded { opacity: 0.35; background: var(--bg); }
.article .binary-demo .highlight-range {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: calc(100% - 12px);
  background: rgba(107, 155, 155, 0.35);
  border: 2px solid var(--accent);
  border-radius: 4px;
  pointer-events: none;
  z-index: 0;
  animation: binary-shrink 14s ease-in-out infinite;
}
.article .binary-demo .cell.c1 { animation: binary-dim-left 14s ease-in-out infinite; }
.article .binary-demo .cell.c2 { animation: binary-dim-left 14s ease-in-out infinite; }
.article .binary-demo .cell.c3 { animation: binary-dim-left 14s ease-in-out infinite; }
.article .binary-demo .cell.c4 { animation: binary-dim-left 14s ease-in-out infinite; }
.article .binary-demo .cell.c5 { animation: binary-dim-mid-keep 14s ease-in-out infinite; }
.article .binary-demo .cell.c6 { animation: binary-dim-mid-early 14s ease-in-out infinite; }
.article .binary-demo .cell.c7 { animation: binary-dim-right 14s ease-in-out infinite; }
.article .binary-demo .cell.c8 { animation: binary-dim-right 14s ease-in-out infinite; }
@keyframes binary-dim-left {
  0%, 10% { opacity: 1; background: var(--surface); }
  14%, 100% { opacity: 0.35; background: var(--bg); }
}
@keyframes binary-dim-right {
  0%, 48% { opacity: 1; background: var(--surface); }
  52%, 100% { opacity: 0.35; background: var(--bg); }
}
@keyframes binary-dim-mid-early {
  0%, 62% { opacity: 1; background: var(--surface); }
  66%, 100% { opacity: 0.35; background: var(--bg); }
}
@keyframes binary-dim-mid-keep {
  0%, 76% { opacity: 1; background: var(--surface); }
  80%, 100% { opacity: 0.35; background: var(--bg); }
}
@keyframes binary-shrink {
  0%, 8% { left: 6px; width: calc(100% - 12px); }
  12% { left: 50%; width: 50%; }
  20%, 32% { left: 50%; width: 50%; }
  36% { left: 62.5%; width: 25%; }
  42%, 58% { left: 62.5%; width: 25%; }
  62% { left: 56.25%; width: 12.5%; }
  68%, 78% { left: 56.25%; width: 12.5%; }
  82% { left: 6px; width: calc(100% - 12px); }
  88%, 100% { left: 6px; width: calc(100% - 12px); }
}
.article .binary-steps {
  position: relative;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  min-height: 2.5em;
}
.article .binary-steps .step {
  position: absolute;
  left: 0;
  right: 0;
  animation: binary-step-fade 14s ease-in-out infinite;
  opacity: 0;
}
.article .binary-steps .step:nth-child(1) { animation-delay: 0s; }
.article .binary-steps .step:nth-child(2) { animation-delay: 3.5s; }
.article .binary-steps .step:nth-child(3) { animation-delay: 7s; }
.article .binary-steps .step:nth-child(4) { animation-delay: 10.5s; }
@keyframes binary-step-fade {
  0%, 8% { opacity: 0; }
  10%, 28% { opacity: 1; }
  32%, 100% { opacity: 0; }
}

/* Soft entrance animation for story and tips */
.article .story-box { animation: fadeIn 0.6s ease-out; }
.article .tip { animation: fadeIn 0.6s ease-out 0.15s both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Subtle pulse for "key idea" callouts (optional) */
.article .key-idea { position: relative; }
.article .key-idea::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
  border-radius: 2px;
  animation: pulseSoft 2.5s ease-in-out infinite;
}
@keyframes pulseSoft { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* Staggered entrance for article sections */
.article h2 { animation: fadeIn 0.5s ease-out both; }
.article h2:nth-of-type(1) { animation-delay: 0.05s; }
.article h2:nth-of-type(2) { animation-delay: 0.1s; }
.article h2:nth-of-type(3) { animation-delay: 0.15s; }
.article h2:nth-of-type(4) { animation-delay: 0.2s; }
.article h2:nth-of-type(5) { animation-delay: 0.25s; }
.article h2:nth-of-type(6) { animation-delay: 0.3s; }
.article .figure { animation: fadeIn 0.55s ease-out both; }
.article .figure:nth-of-type(1) { animation-delay: 0.1s; }
.article .figure:nth-of-type(2) { animation-delay: 0.2s; }
.article .figure:nth-of-type(3) { animation-delay: 0.35s; }
.article .figure:nth-of-type(4) { animation-delay: 0.5s; }
.article .figure:nth-of-type(5) { animation-delay: 0.6s; }
.article .figure:nth-of-type(6) { animation-delay: 0.7s; }
.article .figure:nth-of-type(7) { animation-delay: 0.8s; }
.article .figure:nth-of-type(8) { animation-delay: 0.9s; }
.article .figure:nth-of-type(9) { animation-delay: 1s; }
.article .figure:nth-of-type(n+10) { animation-delay: 1.1s; }

/* Data structure family: grid of small cards */
.ds-family {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
.ds-family .ds-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
  animation: fadeIn 0.4s ease-out both;
  transition: transform 0.2s, box-shadow 0.2s;
}
.ds-family .ds-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.ds-family .ds-card:nth-child(1) { animation-delay: 0.1s; }
.ds-family .ds-card:nth-child(2) { animation-delay: 0.18s; }
.ds-family .ds-card:nth-child(3) { animation-delay: 0.26s; }
.ds-family .ds-card:nth-child(4) { animation-delay: 0.34s; }
.ds-family .ds-card:nth-child(5) { animation-delay: 0.42s; }
.ds-family .ds-card:nth-child(6) { animation-delay: 0.5s; }
.ds-family .ds-card:nth-child(7) { animation-delay: 0.58s; }
.ds-family .ds-card .ds-icon { margin-bottom: 0.35rem; }
.ds-family .ds-card .ds-name { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.ds-family .ds-card .ds-desc { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.2rem; line-height: 1.3; }

/* Array vs Linked list side-by-side */
.array-vs-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem auto;
  max-width: 400px;
}
.array-vs-list .panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  animation: fadeIn 0.5s ease-out both;
}
.array-vs-list .panel:first-child { animation-delay: 0.2s; }
.array-vs-list .panel:last-child { animation-delay: 0.35s; }
.array-vs-list .panel-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text); }
.array-vs-list .panel .sublabel { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.35rem; }
.array-vs-list .panel svg { display: block; margin: 0 auto; }

/* Stack demo: clear labels + push then pop */
.stack-demo-wrap { max-width: 160px; margin: 1.25rem auto; }
.stack-demo-label-top {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 0.25rem;
  position: relative;
  min-height: 1.4em;
}
.stack-demo-label-top .phase-push { color: var(--accent); animation: stack-show-push 4.5s ease-in-out infinite; }
.stack-demo-label-top .phase-pop {
  color: var(--text-muted);
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  animation: stack-show-pop 4.5s ease-in-out infinite;
  white-space: nowrap;
}
@keyframes stack-show-push {
  0%, 28% { opacity: 1; }
  35%, 100% { opacity: 0; }
}
@keyframes stack-show-pop {
  0%, 45% { opacity: 0; }
  52%, 85% { opacity: 1; }
  92%, 100% { opacity: 0; }
}
.stack-demo {
  width: 100%;
  margin: 0 auto;
  position: relative;
  min-height: 150px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 8px;
}
.stack-demo .stack-label { position: absolute; left: -2px; top: 50%; transform: translateY(-50%); font-size: 0.7rem; color: var(--text-muted); writing-mode: vertical-rl; }
.stack-demo .stack-base {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 3px;
}
.stack-demo .stack-cell {
  width: 48px;
  height: 30px;
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  border-radius: 4px;
  animation: stackAppear 0.4s ease-out both;
}
.stack-demo .stack-cell:nth-child(1) { animation-delay: 0.2s; }
.stack-demo .stack-cell:nth-child(2) { animation-delay: 0.5s; }
.stack-demo .stack-cell:nth-child(3) { animation-delay: 0.8s; }
/* 栈顶：放在栈框上方单独一行，不压住栈 */
.stack-demo-wrap .stack-top-label {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.stack-demo .stack-pusher {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 30px;
  background: var(--accent);
  border: 2px solid #5a8a8a;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  animation: stackPushPop 4.5s ease-in-out infinite;
  top: -36px;
  z-index: 2;
}
/* 入栈：从上方(-36px)落到栈顶(0)；出栈：从栈顶升回上方 */
@keyframes stackAppear { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes stackPushPop {
  0% { top: -36px; opacity: 1; }
  12% { top: -36px; opacity: 1; }
  28% { top: 0; opacity: 1; }
  35% { top: 0; opacity: 1; }
  50% { top: 0; opacity: 1; }
  58% { top: -36px; opacity: 1; }
  72% { top: -36px; opacity: 0.3; }
  100% { top: -36px; opacity: 0.3; }
}
.stack-demo-legend { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin-top: 0.5rem; }
.stack-demo-legend span { margin: 0 0.5rem; }
.stack-demo-legend .push { color: var(--accent); }
.stack-demo-legend .pop { color: var(--text-muted); }

/* Queue demo: 队尾/队头 + 方块在队列通道内从左到右 */
.queue-demo-wrap { max-width: 320px; margin: 1.25rem auto; }
.queue-demo-title { font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; text-align: center; }
.queue-demo {
  min-height: 80px;
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--border);
  overflow: hidden;
}
.queue-demo .queue-ends {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
  height: 26px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.queue-demo .queue-ends .tail { color: var(--accent); font-weight: 600; }
.queue-demo .queue-ends .head { color: var(--text-muted); font-weight: 600; }
.queue-demo .queue-track {
  position: relative;
  height: 52px;
  margin: 0 32px;
  background: rgba(107, 155, 155, 0.08);
  border-left: 3px solid var(--accent);
  border-right: 3px solid var(--border);
  box-sizing: border-box;
}
.queue-demo .queue-cell {
  position: absolute;
  width: 32px;
  height: 32px;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  animation: queueMove 5s ease-in-out infinite;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  box-sizing: border-box;
}
.queue-demo .queue-cell:nth-child(2) { animation-delay: 1.25s; }
.queue-demo .queue-cell:nth-child(3) { animation-delay: 2.5s; }
@keyframes queueMove {
  0% { left: -40px; opacity: 0; transform: translateY(-50%) scale(0.9); }
  10% { left: 6px; opacity: 1; transform: translateY(-50%) scale(1); }
  45% { left: calc(50% - 16px); opacity: 1; transform: translateY(-50%) scale(1); }
  75% { left: calc(100% - 36px); opacity: 1; transform: translateY(-50%) scale(1); }
  88% { left: calc(100% + 8px); opacity: 0; transform: translateY(-50%) scale(0.95); }
  100% { left: calc(100% + 8px); opacity: 0; transform: translateY(-50%) scale(0.95); }
}
.queue-demo-legend { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin-top: 0.5rem; }

/* Structure vs Algorithm contrast box */
.struct-vs-algo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: linear-gradient(135deg, var(--accent-soft) 0%, rgba(255,255,255,0.9) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: fadeIn 0.6s ease-out 0.2s both;
}
.struct-vs-algo .side { text-align: center; }
.struct-vs-algo .side .heading { font-size: 1rem; font-weight: 600; color: var(--accent); margin-bottom: 0.35rem; }
.struct-vs-algo .side .text { font-size: 0.85rem; color: var(--text-muted); }
.struct-vs-algo .side svg { margin: 0.4rem auto; display: block; }
.article .struct-vs-algo-note { text-align: center; margin-top: -0.25rem; margin-bottom: 0; font-size: 0.9rem; color: var(--text-muted); }

/* Life DSA icons row */
.life-dsa {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin: 1.25rem 0;
}
.life-dsa .life-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 72px;
  animation: fadeIn 0.4s ease-out both;
  transition: transform 0.2s;
}
.life-dsa .life-item:hover { transform: scale(1.05); }
.life-dsa .life-item:nth-child(1) { animation-delay: 0.1s; }
.life-dsa .life-item:nth-child(2) { animation-delay: 0.2s; }
.life-dsa .life-item:nth-child(3) { animation-delay: 0.3s; }
.life-dsa .life-item:nth-child(4) { animation-delay: 0.4s; }
.life-dsa .life-item:nth-child(5) { animation-delay: 0.5s; }
.life-dsa .life-item .life-label { font-size: 0.75rem; font-weight: 600; color: var(--text); }
.life-dsa .life-item .life-ds { font-size: 0.65rem; color: var(--text-muted); }

/* Chapter 2: Complexity growth curve + O(n) vs O(n²) comparison */
.complexity-curve-wrap { max-width: 460px; margin: 1.5rem auto; overflow: visible; }
.complexity-curve-wrap svg { display: block; margin: 0 auto; border-radius: var(--radius); max-width: 100%; height: auto; }
.big-o-table {
  width: 100%;
  max-width: 360px;
  margin: 1rem auto;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.big-o-table th, .big-o-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.big-o-table th { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.big-o-table tr:last-child td { border-bottom: none; }
.big-o-table .notation { font-family: monospace; color: var(--accent); font-weight: 600; }
.o-compare-wrap { max-width: 380px; margin: 1.5rem auto; }
.o-compare-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; text-align: center; color: var(--text); }
.o-compare-bars { display: flex; flex-direction: column; gap: 0.75rem; margin: 0.75rem 0; }
.o-compare-row { display: flex; align-items: center; gap: 0.5rem; }
.o-compare-row .label { flex: 0 0 70px; font-size: 0.8rem; font-weight: 600; color: var(--text); }
.o-compare-row .bar-wrap { flex: 1; height: 28px; background: var(--bg); border-radius: 6px; overflow: hidden; position: relative; }
.o-compare-row .bar { height: 100%; border-radius: 6px; transition: width 0.6s ease-out; }
.o-compare-row .bar.linear { background: var(--accent-soft); }
.o-compare-row .bar.quad { background: rgba(200, 120, 120, 0.5); }
.o-compare-row .value { flex: 0 0 48px; font-size: 0.8rem; color: var(--text-muted); text-align: right; }
.o-compare-n-label { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin-top: 0.35rem; }
.o-compare-n-label strong { color: var(--accent); }
.o-compare-n-slider { width: 100%; max-width: 200px; margin: 0.5rem auto; display: block; accent-color: var(--accent); }
/* 用 CSS 动画模拟 n 增大时两条 bar 的变化（无 JS 时循环演示） */
.o-compare-animated .o-compare-row .bar.linear { animation: o-linear-grow 8s ease-in-out infinite; }
.o-compare-animated .o-compare-row .bar.quad { animation: o-quad-grow 8s ease-in-out infinite; }
@keyframes o-linear-grow {
  0%, 10% { width: 5%; }
  25% { width: 15%; }
  40% { width: 30%; }
  55% { width: 50%; }
  70% { width: 75%; }
  85%, 100% { width: 100%; }
}
@keyframes o-quad-grow {
  0%, 10% { width: 2%; }
  25% { width: 8%; }
  40% { width: 25%; }
  55% { width: 55%; }
  70% { width: 88%; }
  85%, 100% { width: 100%; }
}
.complexity-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; margin: 1rem 0; max-width: 480px; margin-left: auto; margin-right: auto; }
.complexity-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; box-shadow: var(--shadow); }
.complexity-card .sym { font-family: monospace; font-weight: 700; font-size: 1rem; color: var(--accent); margin-bottom: 0.25rem; }
.complexity-card .name { font-size: 0.8rem; color: var(--text-muted); }
.complexity-card .example { font-size: 0.75rem; color: var(--text); margin-top: 0.35rem; line-height: 1.4; }

/* Chapter 3: Array and string figures */
.array-fig-wrap { max-width: 420px; margin: 1.25rem auto; }
.array-fig-wrap svg { display: block; margin: 0 auto; }
/* 动态：数组格子顺序高亮，模拟顺序访问 */
.array-fig-wrap.array-fig-dynamic svg rect:nth-of-type(n+2) {
  animation: arrayCellHighlight 2.8s ease-in-out infinite;
}
.array-fig-wrap.array-fig-dynamic svg rect:nth-of-type(2) { animation-delay: 0s; }
.array-fig-wrap.array-fig-dynamic svg rect:nth-of-type(3) { animation-delay: 0.18s; }
.array-fig-wrap.array-fig-dynamic svg rect:nth-of-type(4) { animation-delay: 0.36s; }
.array-fig-wrap.array-fig-dynamic svg rect:nth-of-type(5) { animation-delay: 0.54s; }
.array-fig-wrap.array-fig-dynamic svg rect:nth-of-type(6) { animation-delay: 0.72s; }
.array-fig-wrap.array-fig-dynamic svg rect:nth-of-type(7) { animation-delay: 0.9s; }
.array-fig-wrap.array-fig-dynamic svg rect:nth-of-type(8) { animation-delay: 1.08s; }
.array-fig-wrap.array-fig-dynamic svg rect:nth-of-type(9) { animation-delay: 1.26s; }
@keyframes arrayCellHighlight {
  0%, 100% { opacity: 1; filter: brightness(1); }
  35% { opacity: 1; filter: brightness(1.15); }
  70% { opacity: 1; filter: brightness(1); }
}
.array-ops-table { width: 100%; max-width: 360px; margin: 1rem auto; border-collapse: collapse; font-size: 0.85rem; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.array-ops-table th, .array-ops-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.array-ops-table th { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.array-ops-table .complexity { font-family: monospace; color: var(--accent); font-size: 0.8rem; }
.app-pattern-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 1rem 0; box-shadow: var(--shadow); }
.app-pattern-card h3 { margin: 0 0 0.5rem; font-size: 1rem; font-weight: 600; color: var(--text); }
.app-pattern-card p { margin: 0 0 0.35rem; font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; }
.app-pattern-card .example { font-size: 0.8rem; color: var(--text); margin-top: 0.5rem; font-family: monospace; background: var(--bg); padding: 0.4rem 0.6rem; border-radius: 4px; }

/* Chapter 4: Linked list figures */
.ll-fig-wrap { max-width: 480px; margin: 1.25rem auto; }
.ll-fig-wrap svg { display: block; margin: 0 auto; }
/* 动态：链表节点顺序高亮，模拟沿链访问 */
.ll-fig-wrap.ll-fig-dynamic svg rect {
  animation: llNodePulse 2.5s ease-in-out infinite;
}
.ll-fig-wrap.ll-fig-dynamic svg rect:nth-of-type(1) { animation-delay: 0s; }
.ll-fig-wrap.ll-fig-dynamic svg rect:nth-of-type(2) { animation-delay: 0.28s; }
.ll-fig-wrap.ll-fig-dynamic svg rect:nth-of-type(3) { animation-delay: 0.56s; }
.ll-fig-wrap.ll-fig-dynamic svg rect:nth-of-type(4) { animation-delay: 0.84s; }
@keyframes llNodePulse {
  0%, 100% { opacity: 1; filter: brightness(1); }
  50% { opacity: 1; filter: brightness(1.12); }
}
.ll-ops-table { width: 100%; max-width: 380px; margin: 1rem auto; border-collapse: collapse; font-size: 0.85rem; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.ll-ops-table th, .ll-ops-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.ll-ops-table th { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.ll-ops-table .complexity { font-family: monospace; color: var(--accent); font-size: 0.8rem; }
.ll-compare-table { width: 100%; max-width: 360px; margin: 1rem auto; border-collapse: collapse; font-size: 0.85rem; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.ll-compare-table th, .ll-compare-table td { padding: 0.45rem 0.65rem; text-align: left; border-bottom: 1px solid var(--border); }
.ll-compare-table th { background: var(--accent-soft); color: var(--text); font-weight: 600; font-size: 0.8rem; }
.ll-compare-table td:first-child { font-weight: 500; }

/* Chapter 6: Hash table figures */
.hash-fig-wrap { max-width: 520px; margin: 1.25rem auto; }
.hash-fig-wrap svg { display: block; margin: 0 auto; }
/* 动态：哈希表各桶顺序高亮，模拟键分布到桶 */
.hash-fig-wrap.hash-fig-dynamic svg g.hash-bucket {
  animation: hashBucketPulse 3s ease-in-out infinite;
}
.hash-fig-wrap.hash-fig-dynamic svg g.hash-bucket:nth-of-type(1) { animation-delay: 0s; }
.hash-fig-wrap.hash-fig-dynamic svg g.hash-bucket:nth-of-type(2) { animation-delay: 0.5s; }
.hash-fig-wrap.hash-fig-dynamic svg g.hash-bucket:nth-of-type(3) { animation-delay: 1s; }
.hash-fig-wrap.hash-fig-dynamic svg g.hash-bucket:nth-of-type(4) { animation-delay: 1.5s; }
.hash-fig-wrap.hash-fig-dynamic svg g.hash-bucket:nth-of-type(5) { animation-delay: 2s; }
.hash-fig-wrap.hash-fig-dynamic svg g.hash-bucket:nth-of-type(6) { animation-delay: 2.5s; }
@keyframes hashBucketPulse {
  0%, 100% { opacity: 1; filter: brightness(1); }
  50% { opacity: 1; filter: brightness(1.12); }
}

/* 链地址法图：沿链顺序高亮，模拟从桶头沿链查找 */
.chaining-fig-dynamic .chaining-node rect {
  animation: chainingNodePulse 2.5s ease-in-out infinite;
}
.chaining-fig-dynamic .chaining-node:nth-of-type(1) rect { animation-delay: 0s; }
.chaining-fig-dynamic .chaining-node:nth-of-type(2) rect { animation-delay: 0.35s; }
.chaining-fig-dynamic .chaining-node:nth-of-type(3) rect { animation-delay: 0.7s; }
.chaining-fig-dynamic .chaining-node:nth-of-type(4) rect { animation-delay: 1.05s; }
@keyframes chainingNodePulse {
  0%, 100% { opacity: 1; filter: brightness(1); }
  50% { opacity: 1; filter: brightness(1.12); }
}

/* Chapter 7: Tree and binary tree figures */
.tree-fig-wrap { max-width: 520px; margin: 1.25rem auto; }
.tree-fig-wrap svg { display: block; margin: 0 auto; }
/* 动态：二叉树节点按前序顺序高亮，模拟遍历 */
.tree-fig-dynamic .tree-node circle {
  animation: treeNodePulse 2.8s ease-in-out infinite;
}
.tree-fig-dynamic .tree-node:nth-of-type(1) circle { animation-delay: 0s; }
.tree-fig-dynamic .tree-node:nth-of-type(2) circle { animation-delay: 0.35s; }
.tree-fig-dynamic .tree-node:nth-of-type(3) circle { animation-delay: 0.7s; }
.tree-fig-dynamic .tree-node:nth-of-type(4) circle { animation-delay: 1.05s; }
.tree-fig-dynamic .tree-node:nth-of-type(5) circle { animation-delay: 1.4s; }
.tree-fig-dynamic .tree-node:nth-of-type(6) circle { animation-delay: 1.75s; }
.tree-fig-dynamic .tree-node:nth-of-type(7) circle { animation-delay: 2.1s; }
@keyframes treeNodePulse {
  0%, 100% { opacity: 1; filter: brightness(1); }
  50% { opacity: 1; filter: brightness(1.15); }
}
