:root {
  --bg: #060a08;
  --surface: #0a110e;
  --surface-hover: #0e1612;
  --border: #1a2e26;
  --border-bright: #243e34;
  --text: #3cd8a8;
  --text-dim: #338f70;
  --text-bright: #50ffc8;
  --accent: #3cd8a8;
  --accent-dim: #2e9e80;
  --accent-glow: rgba(60, 216, 168, 0.15);
  --accent-glow-strong: rgba(60, 216, 168, 0.25);
  --green: #38d870;
  --green-dim: #2aaa5a;
  --red: #e84c4c;
  --yellow: #50ffc8;
  --amber: #50ffc8;
  --cyan: #58a8ff;
  --magenta: #b07ee8;
  --code-bg: #060a08;
  --panel-bg: #0a110e;
  --dot-color: rgba(60, 216, 168, 0.04);
  --scanline-color: rgba(60, 216, 168, 0.012);
}

/* === Themes === */
[data-theme="paper"] {
  --bg: #f0ead6; --surface: #e8e2ce; --surface-hover: #ddd7c4;
  --border: #c5bfa8; --border-bright: #b0aa94;
  --text: #3a3020; --text-dim: #6a6244; --text-bright: #3a3020;
  --accent: #3a3020; --accent-dim: #625840;
  --accent-glow: rgba(58, 48, 32, 0.15); --accent-glow-strong: rgba(58, 48, 32, 0.25);
  --green: #246028; --red: #a03030; --yellow: #5a4a2a; --amber: #5a4a2a;
  --cyan: #2a5a8a; --magenta: #6a3a8a;
  --code-bg: #f0ead6; --panel-bg: #e8e2ce;
  --dot-color: rgba(58, 48, 32, 0.06); --scanline-color: rgba(58, 48, 32, 0.015);
}

[data-theme="mono"] {
  --bg: #0a0a0a; --surface: #111; --surface-hover: #161616;
  --border: #2a2a2a; --border-bright: #3a3a3a;
  --text: #ccc; --text-dim: #7a7a7a; --text-bright: #fff;
  --accent: #ccc; --accent-dim: #888;
  --accent-glow: rgba(204, 204, 204, 0.15); --accent-glow-strong: rgba(204, 204, 204, 0.25);
  --green: #aaa; --red: #e85050; --yellow: #ddd; --amber: #ddd;
  --cyan: #aaa; --magenta: #999;
  --code-bg: #0a0a0a; --panel-bg: #111;
  --dot-color: rgba(204, 204, 204, 0.04); --scanline-color: rgba(204, 204, 204, 0.012);
}

[data-theme="pacman"] {
  --bg: #000010; --surface: #0a0a20; --surface-hover: #10102a;
  --border: #1a1a50; --border-bright: #2a2a70;
  --text: #ff0; --text-dim: #8c7a30; --text-bright: #ff6;
  --accent: #ff0; --accent-dim: #fa0;
  --accent-glow: rgba(255, 255, 0, 0.15); --accent-glow-strong: rgba(255, 255, 0, 0.25);
  --green: #0f0; --red: #ff2020; --yellow: #ff0; --amber: #ff0;
  --cyan: #0ff; --magenta: #ffb8ff;
  --code-bg: #000010; --panel-bg: #0a0a20;
  --dot-color: rgba(255, 255, 0, 0.04); --scanline-color: rgba(255, 255, 0, 0.012);
}

[data-theme="sepia"] {
  --bg: #1a1408; --surface: #221a0e; --surface-hover: #2a2014;
  --border: #4a3a20; --border-bright: #5a4a2a;
  --text: #d4a860; --text-dim: #a58455; --text-bright: #f0cc70;
  --accent: #d4a860; --accent-dim: #a88848;
  --accent-glow: rgba(212, 168, 96, 0.15); --accent-glow-strong: rgba(212, 168, 96, 0.25);
  --green: #a0a048; --red: #e86040; --yellow: #e8b848; --amber: #e8b848;
  --cyan: #c89858; --magenta: #c888a0;
  --code-bg: #1a1408; --panel-bg: #221a0e;
  --dot-color: rgba(212, 168, 96, 0.04); --scanline-color: rgba(212, 168, 96, 0.012);
}

[data-theme="bauhaus"] {
  --bg: #f5f0e8; --surface: #ece7de; --surface-hover: #e0dbd2;
  --border: #c0bab0; --border-bright: #a8a298;
  --text: #1a1a1a; --text-dim: #706860; --text-bright: #1a1a1a;
  --accent: #1a1a1a; --accent-dim: #444;
  --accent-glow: rgba(26, 26, 26, 0.15); --accent-glow-strong: rgba(26, 26, 26, 0.25);
  --green: #1a1a1a; --red: #b80000; --yellow: #b80000; --amber: #b80000;
  --cyan: #004db8; --magenta: #004db8;
  --code-bg: #f5f0e8; --panel-bg: #ece7de;
  --dot-color: rgba(26, 26, 26, 0.04); --scanline-color: rgba(26, 26, 26, 0.012);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  position: relative;
  display: flex;
  min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 2.5rem 1.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-title {
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-shadow: 0 0 12px var(--accent-glow);
  text-decoration: none;
  display: block;
  line-height: 1.4;
}

.sidebar-tagline {
  color: var(--text-dim);
  font-size: 0.7rem;
  font-style: italic;
  margin-top: 0.5rem;
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sidebar-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.35rem 0;
  display: block;
  transition: color 0.15s;
}

.sidebar-nav a::before {
  content: '> ';
  color: var(--border-bright);
}

.sidebar-nav a:hover {
  color: var(--accent);
}

.sidebar-nav a:hover::before {
  color: var(--accent-dim);
}

.sidebar-meta {
  margin-top: auto;
  color: var(--text-dim);
  font-size: 0.65rem;
  opacity: 0.5;
}

/* === Main content area === */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 2rem 12rem;
  position: relative;
}

/* === Table of contents (right side) === */
.toc {
  position: sticky;
  top: 0;
  width: 200px;
  flex-shrink: 0;
  font-size: 0.8rem;
  align-self: flex-start;
  padding: 2rem 1.5rem;
  max-height: 100vh;
  overflow-y: auto;
}

.toc-title {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.toc-list a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
  display: block;
  padding: 0.2rem 0;
}

.toc-list a:hover {
  color: var(--accent);
}

.toc-list a.active {
  color: var(--accent);
}

.toc-sublist {
  list-style: none;
  padding-left: 1em;
  margin-top: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.toc-sublist a {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}

.toc-sublist a:hover {
  color: var(--accent);
}

.toc-divider {
  border-top: 1px solid var(--border);
  margin: 0.3rem 0;
}

/* === Theme switcher === */
.theme-switcher {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.theme-switcher .toc-title {
  font-size: 0.8rem;
}

.theme-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.theme-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.15rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: opacity 0.15s;
  opacity: 0.6;
}

.theme-btn:hover {
  opacity: 1;
}

.theme-btn.active {
  opacity: 1;
}

.theme-swatch {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 2px solid;
  flex-shrink: 0;
}

.theme-name {
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.theme-btn.active .theme-name {
  color: var(--text);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--dot-color) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    var(--scanline-color) 2px, var(--scanline-color) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

body > * { position: relative; z-index: 1; }

h1 {
  margin-bottom: 0.5rem;
  color: var(--accent);
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-shadow: 0 0 20px var(--accent-glow-strong), 0 0 40px rgba(60, 216, 168, 0.1);
}

.subtitle {
  color: var(--text-dim);
  margin-bottom: 2rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* === Assembly Block Container === */
.asm-block {
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin: 1.5rem 0;
  background: var(--code-bg);
  box-shadow:
    0 0 1px var(--accent-glow),
    0 0 30px rgba(60, 216, 168, 0.03),
    inset 0 0 60px rgba(0, 0, 0, 0.5);
}

/* === Section: collapsible unit === */
.asm-section {
  border-bottom: 1px solid var(--border);
}

.asm-section:last-child {
  border-bottom: none;
}

/* === Section header: always visible, clickable === */
.section-header {
  cursor: pointer;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: background 0.15s;
  position: relative;
}

.section-header::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: transparent;
  transition: background 0.2s;
}

.section-header:hover {
  background: var(--surface-hover);
}

.section-header:hover::before {
  background: var(--accent-dim);
}

.asm-section.open .section-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.asm-section.open .section-header::before {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow-strong);
}

.section-arrow {
  color: var(--accent-dim);
  font-size: 0.6rem;
  transition: transform 0.25s;
  flex-shrink: 0;
}

.asm-section.open .section-arrow {
  transform: rotate(90deg);
  color: var(--accent);
}

.section-title {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* === Section body: collapsed by default === */
.section-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.asm-section.open .section-body {
  max-height: 50000px;
}

/* === Code lines: capped height with scroll === */
.code-lines {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  white-space: pre;
  line-height: 1.8;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 24em;
  counter-reset: line-num;
  border-bottom: 1px solid var(--border);
}

.code-line {
  display: block;
  padding: 0 0.25rem;
  border-left: 2px solid transparent;
  transition: background 0.2s, border-color 0.2s;
  margin-left: 2.5em;
  position: relative;
}

.code-line::before {
  counter-increment: line-num;
  content: counter(line-num);
  position: absolute;
  right: calc(100% + 1em);
  color: var(--text-dim);
  opacity: 0.5;
  font-size: 0.75rem;
  -webkit-user-select: none;
  user-select: none;
}

.code-line.empty-line::before {
  counter-increment: line-num;
  content: counter(line-num);
}

.code-line.active-line {
  background: rgba(60, 216, 168, 0.08);
  border-left-color: var(--accent);
}

/* === Section explanation === */
.section-explanation {
  padding: 1rem 1.25rem;
  background: var(--panel-bg);
}

/* === Overview view === */
.overview-text {
  color: var(--text-bright);
  font-size: 0.8rem;
  margin-bottom: 1rem;
  line-height: 1.7;
  font-weight: 300;
}

.overview-list {
  list-style: disc;
  padding-left: 1.5em;
  margin-bottom: 1rem;
  color: var(--text-bright);
  font-size: 0.8rem;
  line-height: 1.7;
  font-weight: 300;
}

.overview-list li {
  margin-bottom: 0.5rem;
}

.overview-text strong,
.overview-list strong {
  color: var(--text-bright);
  font-weight: 600;
}

.overview-text code {
  color: var(--accent);
  background: rgba(60, 216, 168, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
  font-size: 0.78rem;
}

/* === Detail view === */
.view-detail { display: none; }
.view-detail.active { display: flex; gap: 1.25rem; }
.view-overview.hidden { display: none; }

.detail-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detail-left h3 {
  color: var(--cyan);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.detail-left h3::before { content: '$'; color: var(--cyan); }

.detail-desc {
  font-size: 0.75rem;
  color: var(--text);
  line-height: 1.7;
  font-weight: 300;
  height: 2.6em;
  overflow: hidden;
}

.detail-desc code {
  color: var(--text-bright);
  background: rgba(60, 216, 168, 0.05);
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
  font-size: 0.75rem;
}

/* === Register visualization === */
.register-viz {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.reg-box {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.3rem 0.5rem;
  font-size: 0.7rem;
  min-width: 80px;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
  white-space: nowrap;
}

.reg-box.changed {
  border-color: var(--border-bright);
  background: rgba(60, 216, 168, 0.04);
  box-shadow: 0 0 8px rgba(60, 216, 168, 0.06);
}

.reg-name { color: var(--cyan); font-weight: 600; margin-right: 0.25rem; }
.reg-value { color: var(--text-dim); }

/* === Grid (right side) === */
.detail-right {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.grid-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.grid-container { position: relative; width: 192px; height: 192px; }

canvas.grid-canvas {
  display: block;
  width: 192px;
  height: 192px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--code-bg);
  box-shadow: 0 0 12px rgba(60, 216, 168, 0.05);
  image-rendering: pixelated;
}

.grid-status {
  font-size: 0.6rem;
  color: var(--accent-dim);
  letter-spacing: 0.05em;
  text-align: center;
  min-height: 1em;
  max-width: 192px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-controls { display: flex; gap: 0.4rem; }

.grid-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all 0.15s;
}

.grid-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-glow);
}

/* === Scenario selector === */
.scenario-bar {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.scenario-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.25rem 0.6rem;
  border-radius: 2px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
  transition: all 0.15s;
}

.scenario-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-glow);
}

.scenario-btn.active {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 6px rgba(60, 216, 168, 0.08);
}

/* === Toggle button === */
.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: 1px solid var(--border-bright);
  color: var(--accent-dim);
  padding: 0.3rem 0.75rem;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all 0.2s;
}

.mode-toggle:hover {
  background: var(--accent-glow);
  border-color: var(--accent-dim);
  color: var(--accent);
  box-shadow: 0 0 10px rgba(60, 216, 168, 0.1);
}

.mode-toggle.viewing-detail {
  background: var(--accent-glow);
  border-color: var(--accent-dim);
  color: var(--accent);
}

.mode-toggle .arrow { transition: transform 0.2s; font-size: 0.6rem; }
.mode-toggle.viewing-detail .arrow { transform: rotate(180deg); }

/* === Syntax highlighting === */
.kw  { color: var(--cyan); font-weight: 700; }
.reg { color: var(--magenta); }
.num { color: var(--magenta); }
.cmt { color: var(--text-dim); font-style: italic; }
.lbl { color: var(--green); font-weight: 600; }
.str { color: var(--accent); }
.dir { color: var(--cyan); }

/* === Post header === */
.post-header {
  margin-bottom: 3rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.post-title-prefix {
  color: var(--accent-dim);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.4rem;
}

.post-title {
  color: var(--accent);
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
  text-shadow: 0 0 30px var(--accent-glow-strong), 0 0 60px rgba(60, 216, 168, 0.08);
  text-transform: none;
  line-height: 1.2;
}

.post-meta {
  color: var(--text-dim);
  font-size: 0.7rem;
  display: flex;
  gap: 1.5rem;
  letter-spacing: 0.05em;
}

.post-author::before { content: '> '; color: var(--accent-dim); }
.post-date::before { content: '// '; }
.post-tags::before { content: '# '; }

/* === Video embed === */
.video-link {
  display: block;
  position: relative;
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s;
}

.video-link:hover {
  border-color: var(--accent-dim);
}

.video-link img {
  width: 100%;
  display: block;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.video-link:hover img {
  opacity: 0.9;
}

.ascii-ant {
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  line-height: 1.3;
  text-align: center;
  padding: 2rem 0;
  margin: 0;
  text-shadow: 0 0 10px var(--accent-glow);
  -webkit-user-select: none;
  user-select: none;
}

.video-link-small {
  max-width: 60%;
  margin: 1.2rem auto;
}

.video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow-strong);
  pointer-events: none;
}

/* === Blog content === */
.blog-content {
  color: var(--text-bright);
  font-size: 0.9rem;
  line-height: 1.85;
  font-weight: 300;
  margin-bottom: 2rem;
}

div.blog-content h2,
div.blog-content h3 {
  color: var(--cyan);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

div.blog-content h2 { font-size: 1.3rem; }
div.blog-content h3 { font-size: 1.15rem; }

.blog-content p {
  margin-bottom: 1.2rem;
}

.blog-content ul, .blog-content ol {
  padding-left: 2em;
  margin-bottom: 1.2rem;
  list-style-position: inside;
}

.blog-content li {
  margin-bottom: 0.5rem;
}

.blog-content a {
  color: var(--cyan);
  text-decoration: none;
}

.blog-content a:hover {
  text-decoration: underline;
}

.blog-content strong {
  color: var(--text-bright);
  font-weight: 600;
}

.blog-content code {
  color: var(--accent);
  background: rgba(60, 216, 168, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
  font-size: 0.8rem;
}

/* === Conversation blocks === */
.conversation {
  margin: 1.2rem 0;
  border-left: 2px solid var(--border-bright);
  padding-left: 1rem;
}

.msg {
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  line-height: 1.7;
}

.msg-name {
  font-weight: 600;
  margin-right: 0.5rem;
}

.msg-ai .msg-name {
  color: var(--red);
}

.msg-user .msg-name {
  color: var(--cyan);
}

/* === Images and videos === */
.blog-content img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 2px;
  display: block;
}

.blog-content video {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 2px;
  display: block;
}

.blog-content figure {
  margin: 1.5rem 0;
  text-align: center;
}

.blog-content figure img,
.blog-content figure video {
  margin: 0 auto;
  max-width: 90%;
}

.blog-content figcaption {
  color: var(--text-dim);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  margin-top: 0.4rem;
}

/* Map image grid — thumbnails in a row, click to expand */
.map-grid {
  display: flex;
  gap: 0.5rem;
  margin: 1.2rem 0;
  flex-wrap: wrap;
  justify-content: center;
}

.map-item {
  flex: 1;
  min-width: 120px;
  max-width: calc(33% - 0.5rem);
  text-align: center;
}

.map-item img {
  width: 100%;
  margin: 0;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.2s, transform 0.2s;
}

.map-item img:hover {
  opacity: 1;
  transform: scale(1.02);
}

.map-item .map-label {
  color: var(--text-dim);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  margin-top: 0.3rem;
}

/* Single map — centered with label */
.map-single {
  text-align: center;
  margin: 1.2rem 0;
}

.map-single img {
  max-width: 80%;
  margin: 0 auto;
}

.map-single .map-label {
  color: var(--text-dim);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  margin-top: 0.3rem;
}

/* Expanded map overlay */
.map-expanded {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.map-expanded img {
  max-width: 90vw;
  max-height: 90vh;
  border: 1px solid var(--border-bright);
  margin: 0;
}

.blog-content video {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 2px;
  margin: 1.2rem 0;
  display: block;
}

/* === Transcript block (fallback until screenshot replaces it) === */
.blog-content pre.transcript {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1rem 1.25rem;
  font-size: 0.8rem;
  line-height: 1.7;
  overflow-x: auto;
  margin: 1.2rem 0;
  white-space: pre-wrap;
}

/* === Responsive === */
/* === Mobile TOC === */
.toc-mobile-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10000;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
  width: 44px;
  height: 44px;
  border-radius: 2px;
  font-size: 1.3rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.toc-mobile-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--accent-dim);
}

.toc-mobile-panel {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  z-index: 10001;
  width: 260px;
  max-width: 80vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 1.5rem;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.toc-mobile-panel.open {
  transform: translateX(0);
}

.toc-mobile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
}

.toc-mobile-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.toc-mobile-close:hover {
  color: var(--accent);
}

.toc-mobile-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toc-mobile-list a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8rem;
  display: block;
  padding: 0.3rem 0;
  transition: color 0.15s;
}

.toc-mobile-list a:hover {
  color: var(--accent);
}

/* mobile toggle visibility handled at end of file */

@media (max-width: 1400px) {
  .main-content { padding: 2rem 6rem; }
}

@media (max-width: 1100px) {
  .toc { display: none; }
  .main-content { padding: 2rem 4rem; }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { padding: 2rem 2rem; }
}

@media (max-width: 700px) {
  .main-content { padding: 1.5rem 1rem; }
  .view-detail.active { flex-direction: column; }
  .detail-right { align-items: flex-start; }
  .grid-container { width: 156px; height: 156px; }
  canvas.grid-canvas { width: 156px; height: 156px; }
  .code-lines { font-size: 0.7rem; padding-left: 1rem !important; max-height: 18em; }
  .section-title { font-size: 0.65rem; }
  .blog-content { font-size: 0.9rem; }
  .post-title { font-size: 1.8rem; }
}

/* Phone */
@media (max-width: 480px) {
  .main-content { padding: 1rem 0.75rem; }
  .post-title { font-size: 1.4rem; }
  .post-title-prefix { font-size: 0.65rem; }
  .post-meta { flex-wrap: wrap; gap: 0.5rem; font-size: 0.6rem; }
  .blog-content { font-size: 0.85rem; line-height: 1.75; }
  .blog-content h2 { font-size: 1rem; }
  .blog-content h3 { font-size: 0.9rem; }

  /* Viewer */
  .section-header { padding: 0.5rem 0.75rem; }
  .section-title { font-size: 0.6rem; }
  .code-lines { font-size: 0.65rem; max-height: 14em; padding: 0.4rem 0.5rem !important; }
  .code-line { margin-left: 2em; }
  .code-line::before { font-size: 0.6rem; }

  /* Detail view — stack vertically */
  .section-explanation { padding: 0.75rem; }
  .view-detail.active { flex-direction: column; }
  .detail-left { width: 100% !important; }
  .detail-right { align-items: center; }

  /* Bigger touch targets */
  .scenario-btn { padding: 0.4rem 0.7rem; font-size: 0.65rem; }
  .grid-btn { padding: 0.4rem 0.7rem; font-size: 0.6rem; }
  .mode-toggle { padding: 0.4rem 0.9rem; font-size: 0.7rem; }

  /* Registers compact */
  .reg-box { min-width: 70px; padding: 0.3rem 0.4rem; font-size: 0.65rem; }

  /* Conversation blocks */
  .conversation { padding-left: 0.6rem; }
  .msg { font-size: 0.75rem; }

  /* Video */
  .video-play { font-size: 2rem; }
}

/* ===== MOBILE TOC — MUST BE LAST ===== */
@media screen and (max-width: 1100px) {
  .toc-mobile-toggle { display: block !important; }
}
