/* ============================================
   磁吸积木在线教程 · 全局样式
   配色模拟纸质手册：米白纸 + 网格 + 青色边框
   ============================================ */

:root {
  --paper: #f6f4ed;
  --paper-2: #fbfaf5;
  --grid: #d8dfd4;
  --grid-2: #e7ebe2;
  --teal: #5eb3a4;
  --teal-deep: #2d8b7a;
  --teal-soft: #d6ece6;
  --red: #d04434;
  --red-soft: #f3d7d1;
  --blue: #4267b2;
  --blue-soft: #d3dcef;
  --ink: #2c2c2c;
  --ink-2: #4a4a4a;
  --mute: #8a8a8a;
  --line: #c8d2cb;

  --cube-red: #d04434;
  --cube-blue: #4267b2;
  --cube-knob: #6a6a6a;

  --shadow-sm: 0 1px 2px rgba(40, 60, 50, 0.06);
  --shadow-md: 0 4px 16px rgba(40, 60, 50, 0.08);
  --shadow-lg: 0 12px 40px rgba(40, 60, 50, 0.12);

  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;

  --side-w: 280px;
  --top-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ============================================
   App layout
   ============================================ */
.app {
  display: flex;
  min-height: 100vh;
  background-image:
    linear-gradient(to right, var(--grid-2) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-2) 1px, transparent 1px);
  background-size: 24px 24px;
  background-attachment: fixed;
}

/* Sidebar */
.sidebar {
  width: var(--side-w);
  flex-shrink: 0;
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.brand {
  padding: 24px 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  display: flex;
  gap: 3px;
  transform: rotate(-6deg);
}
.cube-mini {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.cube-mini::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px; right: 3px; bottom: 3px;
  border: 1px dashed rgba(255,255,255,0.6);
  border-radius: 2px;
}
.cube-mini.cube-red { background: var(--cube-red); }
.cube-mini.cube-blue { background: var(--cube-blue); }
.brand-title {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.5px;
}
.brand-sub {
  font-size: 12px;
  color: var(--mute);
  margin-top: 2px;
}

.toc {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
}
.toc-group {
  margin-bottom: 6px;
}
.toc-group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--teal-deep);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 10px 12px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toc-group-label::before {
  content: '';
  width: 14px; height: 2px;
  background: var(--teal);
  border-radius: 1px;
}
.toc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  position: relative;
}
.toc-item:hover {
  background: var(--teal-soft);
  color: var(--teal-deep);
}
.toc-item.active {
  background: var(--teal);
  color: white;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.toc-item.active .toc-num {
  background: rgba(255,255,255,0.25);
  color: white;
}
.toc-item.is-bonus::after {
  content: 'NEW';
  position: absolute;
  right: 10px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  background: var(--red);
  color: white;
  border-radius: 3px;
}
.toc-num {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--grid);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
}
.toc-title { flex: 1; }

.sidebar-foot {
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--mute);
}
.foot-line { font-weight: 500; }
.foot-mute { font-size: 11px; margin-top: 4px; color: var(--mute); }

/* Main */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--top-h);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 245, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.menu-btn {
  display: none;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
}
.menu-btn:hover { background: var(--teal-soft); color: var(--teal-deep); }
.crumbs {
  font-size: 13px;
  color: var(--mute);
  display: flex;
  align-items: center;
  gap: 8px;
}
.crumbs .crumb-now {
  color: var(--ink);
  font-weight: 700;
}
.topbar-spacer { flex: 1; }
.progress-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}
.pill-dot {
  width: 6px; height: 6px;
  background: var(--teal-deep);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.page {
  flex: 1;
  padding: 36px 40px 80px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* Chapter header */
.chapter {
  animation: fade-in 0.35s ease;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chapter-head {
  margin-bottom: 28px;
}
.chapter-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--teal-deep);
  text-transform: uppercase;
  padding: 4px 10px;
  background: var(--teal-soft);
  border-radius: 4px;
  margin-bottom: 12px;
}
.chapter-title {
  font-size: 32px;
  font-weight: 900;
  margin: 0 0 8px;
  letter-spacing: 1px;
  color: var(--ink);
}
.chapter-sub {
  font-size: 16px;
  color: var(--ink-2);
  margin: 0 0 18px;
}
.chapter-intro {
  font-size: 15px;
  color: var(--ink-2);
  background: var(--paper-2);
  padding: 14px 18px;
  border-left: 3px solid var(--teal);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  line-height: 1.7;
}
.chapter-intro strong { color: var(--red); font-weight: 700; }
.chapter-intro em { color: var(--blue); font-style: normal; font-weight: 600; }

/* Demo card */
.demo-card {
  background: var(--paper-2);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.demo-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.demo-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.demo-title::before {
  content: '';
  width: 4px; height: 16px;
  background: var(--teal);
  border-radius: 2px;
}
.demo-tools {
  display: flex;
  gap: 6px;
}
.btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--r-sm);
  background: var(--paper);
  color: var(--ink-2);
  border: 1px solid var(--line);
  transition: all 0.15s;
  font-weight: 500;
}
.btn:hover { background: var(--teal-soft); color: var(--teal-deep); border-color: var(--teal); }
.btn.primary { background: var(--teal); color: white; border-color: var(--teal); }
.btn.primary:hover { background: var(--teal-deep); color: white; }
.btn.warn { background: var(--red-soft); color: var(--red); border-color: var(--red-soft); }

.demo-stage {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.demo-tip {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  border-radius: var(--r-sm);
  font-size: 13px;
  line-height: 1.6;
}
.demo-tip strong { color: var(--teal-deep); }

/* Cube styles (2D) */
.cube-cell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--cube-red) 0%, var(--cube-red) 49.5%, var(--cube-blue) 50.5%, var(--cube-blue) 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12), inset 0 0 0 1px rgba(255,255,255,0.1);
}
.cube-cell.red {
  background: var(--cube-red);
}
.cube-cell.blue {
  background: var(--cube-blue);
}
.cube-cell.empty {
  background: transparent;
  border: 1px dashed var(--line);
  box-shadow: none;
}
.cube-cell::after {
  content: '';
  position: absolute;
  top: 18%; left: 18%; right: 18%; bottom: 18%;
  border: 1px dashed rgba(255,255,255,0.5);
  border-radius: 2px;
}

.cube-grid {
  display: grid;
  gap: 4px;
}

/* Number picker */
.num-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.num-chip {
  width: 44px; height: 44px;
  border-radius: var(--r-sm);
  background: var(--paper);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800;
  color: var(--ink-2);
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.15s;
}
.num-chip:hover { background: var(--teal-soft); color: var(--teal-deep); border-color: var(--teal); transform: translateY(-1px); }
.num-chip.active { background: var(--teal); color: white; border-color: var(--teal); }

/* Big number display */
.num-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.num-display {
  display: grid;
  gap: 3px;
  padding: 16px;
  background: var(--paper);
  border-radius: var(--r-md);
  border: 1px solid var(--grid);
}
.num-cap {
  font-size: 14px;
  color: var(--mute);
  font-family: 'JetBrains Mono', monospace;
}
.num-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--ink-2);
}
.num-meta .meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.num-meta strong {
  font-family: 'JetBrains Mono', monospace;
  color: var(--red);
  font-size: 16px;
}

/* Step animation */
.step-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--paper);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}
.step-bar button {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-2);
  transition: all 0.15s;
}
.step-bar button:hover:not(:disabled) { background: var(--teal); color: white; border-color: var(--teal); }
.step-bar button:disabled { opacity: 0.3; cursor: not-allowed; }
.step-bar button svg { width: 14px; height: 14px; }
.step-bar .step-progress {
  flex: 1;
  height: 6px;
  background: var(--grid);
  border-radius: 3px;
  overflow: hidden;
}
.step-bar .step-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--teal-deep));
  transition: width 0.3s ease;
}
.step-bar .step-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--mute);
  min-width: 60px;
  text-align: right;
}

/* Quantity practice */
.qty-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.qty-card {
  background: var(--paper);
  border-radius: var(--r-md);
  border: 1px solid var(--grid);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.qty-card .cube3d-stage {
  align-self: stretch;
  width: 100%;
  flex-shrink: 0;
}
.qty-card:hover { border-color: var(--teal); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.qty-fig {
  display: grid;
  gap: 3px;
  padding: 12px;
  background: white;
  border-radius: var(--r-sm);
}
.qty-cap {
  font-size: 13px;
  color: var(--mute);
}
.qty-input {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--ink-2);
}
.qty-input input {
  width: 50px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  color: var(--ink);
  background: white;
}
.qty-input input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.qty-input input.correct { background: var(--teal-soft); border-color: var(--teal); color: var(--teal-deep); }
.qty-input input.wrong { background: var(--red-soft); border-color: var(--red); color: var(--red); }

/* Math practice */
.math-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.math-card {
  background: var(--paper);
  border-radius: var(--r-md);
  border: 1px solid var(--grid);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.math-pill {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.math-pill.add { background: var(--blue-soft); color: var(--blue); }
.math-pill.sub { background: var(--red-soft); color: var(--red); }
.math-pill.mul { background: var(--teal-soft); color: var(--teal-deep); }
.math-pill.div { background: #f0e2c4; color: #946c1a; }
.math-fig {
  display: grid;
  gap: 3px;
  padding: 12px;
  background: white;
  border-radius: var(--r-sm);
  margin: 0 auto;
}
.math-expr {
  font-size: 28px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
  color: var(--ink);
  letter-spacing: 2px;
}
.math-expr input {
  display: inline-block;
  width: 70px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  font-family: inherit;
  vertical-align: middle;
}
.math-expr input.correct { background: var(--teal-soft); border-color: var(--teal); color: var(--teal-deep); }
.math-expr input.wrong { background: var(--red-soft); border-color: var(--red); color: var(--red); }

/* Pattern */
.pattern-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.pattern-fig {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: white;
  border-radius: var(--r-sm);
  border: 1px solid var(--grid);
}
.pattern-q {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-2);
}
.pattern-q .arrow {
  color: var(--teal);
  font-weight: 700;
  margin: 0 4px;
}
.pattern-q .blank {
  display: inline-block;
  width: 40px; height: 40px;
  vertical-align: middle;
  border: 2px dashed var(--mute);
  border-radius: 6px;
  margin: 0 4px;
}
.pattern-options {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.pattern-opt {
  padding: 8px 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.pattern-opt:hover { border-color: var(--teal); color: var(--teal-deep); }
.pattern-opt.chosen { background: var(--teal); color: white; border-color: var(--teal); }
.pattern-opt.correct { background: var(--teal); color: white; border-color: var(--teal); }
.pattern-opt.wrong { background: var(--red-soft); color: var(--red); border-color: var(--red); }

/* 3D viewer */
.cube3d-stage {
  width: 100%;
  height: 380px;
  background: linear-gradient(180deg, #f7f4ec 0%, #e9e4d6 100%);
  border-radius: var(--r-md);
  position: relative;
  overflow: hidden;
}
.cube3d-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.cube3d-controls {
  position: absolute;
  bottom: 12px; left: 12px;
  display: flex;
  gap: 6px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  padding: 6px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.cube3d-controls button {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
}
.cube3d-controls button:hover { background: var(--teal); color: white; }
.cube3d-info {
  position: absolute;
  top: 12px; right: 12px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--ink-2);
  font-family: 'JetBrains Mono', monospace;
}

/* Symmetry */
.sym-stage {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.sym-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.sym-fig {
  display: grid;
  gap: 3px;
  padding: 16px;
  background: white;
  border-radius: var(--r-md);
  border: 1px solid var(--grid);
  position: relative;
}
.sym-mirror {
  display: grid;
  gap: 3px;
  padding: 16px;
  background: var(--teal-soft);
  border-radius: var(--r-md);
  border: 1px solid var(--teal);
  position: relative;
}
.sym-axis {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--teal);
}
.sym-axis::before {
  content: '镜像轴';
  position: absolute;
  top: -22px; left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--teal-deep);
  font-weight: 700;
  white-space: nowrap;
}
.sym-pair {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.sym-pair .arrow-right {
  font-size: 24px;
  color: var(--teal);
  font-weight: 700;
}

/* Projection */
.proj-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.proj-3d {
  height: 360px;
  background: linear-gradient(180deg, #f7f4ec 0%, #e9e4d6 100%);
  border-radius: var(--r-md);
  overflow: hidden;
  position: relative;
}
.proj-views {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.proj-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.proj-view-cap {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  letter-spacing: 0.5px;
}
.proj-grid {
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.proj-cell {
  width: 36px; height: 36px;
  background: white;
  display: flex; align-items: center; justify-content: center;
}
.proj-cell.filled-red { background: var(--cube-red); }
.proj-cell.filled-blue { background: var(--cube-blue); }
.proj-cell.target { background: var(--paper); border: 1px dashed var(--mute); }

/* Letters */
.letters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
}
.letter-cell {
  background: white;
  border: 1px solid var(--grid);
  border-radius: var(--r-sm);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.letter-cell:hover { border-color: var(--teal); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.letter-cell .lcap {
  font-size: 11px;
  color: var(--mute);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}
.letter-cell .lmin {
  display: grid;
  gap: 2px;
  padding: 6px;
  background: var(--paper);
  border-radius: 3px;
}

/* Build3D */
.build3d-stage {
  width: 100%;
  height: 440px;
  background: linear-gradient(180deg, #f7f4ec 0%, #e9e4d6 100%);
  border-radius: var(--r-md);
  position: relative;
  overflow: hidden;
}
.build3d-steps {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.build3d-step {
  padding: 8px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.build3d-step.active { background: var(--teal); color: white; border-color: var(--teal); }
.build3d-step.done { background: var(--teal-soft); color: var(--teal-deep); border-color: var(--teal-soft); }

/* Answer key */
.answer-row {
  display: grid;
  grid-template-columns: 60px 1fr 80px;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--grid);
}
.answer-row:last-child { border-bottom: none; }
.answer-q {
  font-size: 14px;
  color: var(--mute);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}
.answer-fig {
  display: grid;
  gap: 3px;
  padding: 8px;
  background: var(--paper);
  border-radius: var(--r-sm);
}
.answer-text {
  font-size: 16px;
  color: var(--teal-deep);
  font-weight: 700;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

/* Section heading */
.section-h {
  font-size: 13px;
  font-weight: 800;
  color: var(--teal-deep);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 32px 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-h::before {
  content: '';
  width: 18px; height: 2px;
  background: var(--teal);
  border-radius: 1px;
}

/* Sidebar mask */
.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9;
}
.sidebar-mask.show { display: block; }

/* Empty state */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--mute);
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: flex; align-items: center; justify-content: center; }
  .page { padding: 24px 18px 60px; }
  .chapter-title { font-size: 24px; }
  .qty-grid, .math-row, .proj-stage { grid-template-columns: 1fr; }
  .sym-pair { flex-direction: column; }
  .topbar { padding: 0 16px; }
}

@media (max-width: 600px) {
  .proj-views { grid-template-columns: 1fr 1fr 1fr; }
  .proj-cell { width: 28px; height: 28px; }
  .cube3d-stage { height: 300px; }
  .build3d-stage { height: 340px; }
}
