:root {
  --paper: #f5ecd9;
  --paper-light: #faf3e0;
  --paper-dark: #e8dcb9;
  --ink: #3d2f1f;
  --ink-soft: #6b5942;
  --ink-faint: #a89878;
  --red: #c8553d;
  --orange: #e89c50;
  --yellow: #e8c547;
  --green: #6a9b5e;
  --blue: #4a87a8;
  --purple: #8b6db5;
  --pink: #d68fa8;
  --line: #c4b289;
  --line-soft: #d8c8a3;
  --cream: #fff8e7;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

/* Paper texture using SVG noise */
html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Noto Serif TC', 'Shippori Mincho', serif;
  line-height: 1.7;
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(232, 197, 71, 0.08), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(200, 85, 61, 0.05), transparent 50%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.24 0 0 0 0 0.18 0 0 0 0 0.12 0 0 0 0.08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.5'/></svg>");
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: '';
  position: fixed; inset: 0;
  background-image: repeating-linear-gradient(
    transparent 0,
    transparent 31px,
    rgba(180, 150, 90, 0.06) 32px
  );
  pointer-events: none;
  z-index: 0;
}
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
  position: relative;
  z-index: 1;
}

/* ============= HEADER ============= */
header {
  padding: 56px 0 32px;
  position: relative;
}
.corner-decoration {
  position: absolute;
  top: 30px; right: 32px;
  font-family: 'Gloria Hallelujah', cursive;
  color: var(--ink-faint);
  font-size: 13px;
  transform: rotate(3deg);
  text-align: right;
  line-height: 1.5;
}
.corner-decoration::before {
  content: '★';
  color: var(--orange);
  margin-right: 6px;
}
h1.title {
  font-family: 'Shippori Mincho', 'Noto Serif TC', serif;
  font-weight: 800;
  font-size: clamp(38px, 6vw, 64px);
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}
h1.title .highlight {
  background: linear-gradient(180deg, transparent 60%, var(--yellow) 60%, var(--yellow) 90%, transparent 90%);
  padding: 0 6px;
  font-style: italic;
}
h1.title .scribble {
  font-family: 'Caveat', cursive;
  color: var(--red);
  font-weight: 700;
  font-size: 0.85em;
  transform: rotate(-2deg);
  display: inline-block;
}
.subtitle {
  font-family: 'Patrick Hand', cursive;
  font-size: 22px;
  color: var(--ink-soft);
  max-width: 720px;
  line-height: 1.5;
  margin-bottom: 36px;
}
.meta-row {
  display: flex; flex-wrap: wrap; gap: 12px 24px;
  align-items: center;
  padding: 18px 0;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
  font-family: 'Kalam', cursive;
  font-size: 14px;
  color: var(--ink-soft);
}
.meta-stamp {
  display: inline-block;
  padding: 4px 10px;
  border: 2px dashed var(--red);
  color: var(--red);
  font-weight: 700;
  transform: rotate(-2deg);
  font-family: 'Caveat', cursive;
  font-size: 16px;
}
.help-banner {
  margin-top: 28px;
  padding: 16px 20px;
  background: var(--cream);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  box-shadow: 4px 4px 0 var(--ink);
  font-family: 'Patrick Hand', cursive;
  font-size: 16px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  transform: rotate(-0.3deg);
}
.help-banner-icon {
  width: 32px; height: 32px;
  background: var(--orange);
  border: 2px solid var(--ink);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Caveat', cursive;
  font-weight: 700;
  color: var(--ink);
  flex-shrink: 0;
  font-size: 22px;
}

/* ============= TOOLTIP / TERMS ============= */
.term {
  color: var(--red);
  cursor: help;
  border-bottom: 2px wavy var(--red);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s;
  padding: 0 2px;
}
.term:hover { background: var(--yellow); }

.term-tip {
  position: fixed;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 16px 18px;
  max-width: 380px;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.6;
  z-index: 1000;
  box-shadow: 6px 6px 0 var(--ink);
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.15s;
  font-family: 'Noto Serif TC', serif;
  display: none;
}
.term-tip.visible { opacity: 1; display: block; }
.term-tip a {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1.5px solid var(--blue);
}
.term-tip a:hover { background: var(--yellow); }
.term-tip .tip-title {
  font-family: 'Caveat', cursive;
  font-size: 20px;
  color: var(--red);
  margin-bottom: 6px;
  font-weight: 700;
}
.term-tip .tip-link {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-family: 'Patrick Hand', cursive;
  font-size: 13px;
}

/* ============= TAB NAV ============= */
nav.tabs {
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 100;
  border-bottom: 2px solid var(--ink);
  margin: 0 -32px;
  padding: 0;
  backdrop-filter: blur(8px);
}
.tabs-wrapper {
  position: relative;
  padding: 0 32px;
}
.tabs-inner {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 0;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}
.tabs-inner:active {
  cursor: grabbing;
}
.tabs-inner::-webkit-scrollbar { display: none; }

.tabs-scroll-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s, transform 0.2s;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.tabs-scroll-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
.tabs-scroll-btn:hover {
  transform: translateY(-50%) scale(1.1);
}
.tabs-scroll-btn.left {
  left: 4px;
}
.tabs-scroll-btn.right {
  right: 4px;
}

.tabs-wrapper::before,
.tabs-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 48px;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s;
}
.tabs-wrapper::before {
  left: 0;
  background: linear-gradient(to right, var(--paper) 0%, transparent 100%);
}
.tabs-wrapper::after {
  right: 0;
  background: linear-gradient(to left, var(--paper) 0%, transparent 100%);
}
.tabs-wrapper.scroll-left::before { opacity: 1; }
.tabs-wrapper.scroll-right::after { opacity: 1; }

.tabs-scroll-hint {
  display: none;
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Patrick Hand', cursive;
  font-size: 11px;
  color: var(--ink-faint);
  white-space: nowrap;
  animation: hintBounce 2s ease-in-out infinite;
}
.tabs-wrapper.scroll-right .tabs-scroll-hint {
  display: block;
}
@keyframes hintBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-3px); }
}
.tab {
  padding: 10px 16px;
  background: transparent;
  border: 2px solid transparent;
  color: var(--ink-soft);
  font-family: 'Kalam', cursive;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 8px;
  transition: all 0.2s;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab:hover {
  background: var(--paper-dark);
  color: var(--ink);
}
.tab.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.tab-icon { font-size: 16px; }

/* ============= TAB CONTENT ============= */
.tab-content {
  display: none;
  padding: 48px 0;
  animation: fadeIn 0.3s ease;
}
.tab-content.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

h2.section-title {
  font-family: 'Shippori Mincho', serif;
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--ink);
  position: relative;
  display: inline-block;
}
h2.section-title::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 0; right: 0;
  height: 4px;
  background: var(--yellow);
  z-index: -1;
  border-radius: 2px;
}
.section-tag {
  display: inline-block;
  font-family: 'Caveat', cursive;
  color: var(--red);
  font-size: 18px;
  margin-left: 12px;
  transform: rotate(-3deg);
  font-weight: 700;
}
.section-desc {
  color: var(--ink-soft);
  margin: 24px 0 32px;
  max-width: 800px;
  font-size: 16px;
}

/* Concept cards */
.concept-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}
.concept-card {
  padding: 18px 18px 16px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink);
  position: relative;
  transition: transform 0.2s;
}
.concept-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.concept-card:nth-child(1) { transform: rotate(-0.6deg); }
.concept-card:nth-child(2) { transform: rotate(0.4deg); }
.concept-card:nth-child(3) { transform: rotate(-0.3deg); }
.concept-card:nth-child(4) { transform: rotate(0.5deg); }
.concept-card-pin {
  position: absolute;
  top: -8px; left: 16px;
  width: 18px; height: 18px;
  background: var(--red);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: inset -3px -3px 4px rgba(0,0,0,0.2);
}
.concept-card-title {
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--red);
  margin-bottom: 8px;
  font-weight: 700;
  margin-left: 28px;
}
.concept-card-text {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* Demo grid */
.demo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 1000px) { .demo-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 24px;
  min-width: 0;
}
.panel-label {
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--ink);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}
.panel-label::before {
  content: '✎';
  color: var(--red);
  font-size: 20px;
}

/* Canvas styling */
.conv-canvas-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
canvas.demo-canvas {
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 3px 3px 0 var(--ink-faint);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  max-width: 100%;
  height: auto;
}

/* Kernel grid */
.kernel-section { width: 100%; margin-top: 14px; }
.kernel-grid {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  gap: 6px;
  justify-content: center;
  margin: 0 auto;
}
.kernel-cell {
  width: 60px; height: 60px;
  background: #fff;
  border: 2px solid var(--ink);
  color: var(--ink);
  font-family: 'Patrick Hand', cursive;
  font-size: 18px;
  text-align: center;
  border-radius: 6px;
  transition: all 0.15s;
  padding: 0;
  font-weight: 700;
}
.kernel-cell:focus {
  outline: none;
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(232, 197, 71, 0.4);
}

/* Buttons */
.btn {
  padding: 8px 16px;
  background: var(--cream);
  border: 2px solid var(--ink);
  color: var(--ink);
  font-family: 'Kalam', cursive;
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s;
  font-weight: 700;
  box-shadow: 2px 2px 0 var(--ink);
}
.btn:hover {
  background: var(--yellow);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}
.btn:active {
  transform: translate(1px, 1px);
  box-shadow: 0 0 0 var(--ink);
}
.btn.primary {
  background: var(--orange);
  color: var(--ink);
}
.btn.primary:hover { background: var(--yellow); }
.btn.danger { color: var(--red); }
.btn.tiny { padding: 5px 10px; font-size: 12px; }
.btn[data-active="true"] {
  background: var(--ink);
  color: var(--paper);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  justify-content: center;
}

.img-row { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.img-thumb {
  width: 44px; height: 44px;
  border: 2px solid var(--ink);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  image-rendering: pixelated;
  background: #fff;
}
.img-thumb:hover { transform: translateY(-2px); }
.img-thumb.active {
  border-color: var(--red);
  box-shadow: 0 0 0 2px var(--red), 3px 3px 0 var(--ink-faint);
}

/* Sliders */
.controls-box {
  padding: 18px 22px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink);
  margin-bottom: 24px;
}
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}
.slider-wrap { display: flex; flex-direction: column; gap: 8px; }
.slider-label {
  font-family: 'Kalam', cursive;
  font-size: 15px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}
.slider-label .val {
  background: var(--yellow);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'Patrick Hand', cursive;
  font-size: 14px;
}
.slider-help {
  font-family: 'Patrick Hand', cursive;
  font-size: 13px;
  color: var(--ink-faint);
  line-height: 1.4;
}
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--paper-dark);
  outline: none;
  border-radius: 3px;
  border: 1.5px solid var(--ink);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  background: var(--red);
  border-radius: 50%;
  cursor: pointer;
  border: 2.5px solid var(--ink);
  box-shadow: 1px 1px 0 var(--ink);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  background: var(--red);
  border-radius: 50%;
  cursor: pointer;
  border: 2.5px solid var(--ink);
}
input[type="range"]:disabled::-webkit-slider-thumb {
  background: var(--ink-faint);
  cursor: not-allowed;
}

/* Layer bars */
.layers-vis {
  display: flex;
  gap: 2px;
  height: 80px;
  align-items: stretch;
  margin-bottom: 8px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.5);
  border: 1.5px dashed var(--line);
  border-radius: 4px;
}
.layer-bar {
  flex: 1;
  background: var(--green);
  border-radius: 2px;
  transition: all 0.3s;
  min-width: 4px;
}
.layers-label {
  display: flex;
  justify-content: space-between;
  font-family: 'Patrick Hand', cursive;
  font-size: 13px;
  color: var(--ink-faint);
  margin-top: 4px;
}

/* Info cells */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.info-cell {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  border: 1.5px dashed var(--line);
}
.info-cell-label {
  font-family: 'Patrick Hand', cursive;
  font-size: 13px;
  color: var(--ink-faint);
  margin-bottom: 2px;
}
.info-cell-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  color: var(--red);
  font-weight: 700;
  word-break: break-all;
}

/* Note callout */
.note {
  margin-top: 28px;
  padding: 20px 22px;
  background: rgba(232, 197, 71, 0.18);
  border: 2px solid var(--ink);
  border-left: 6px solid var(--orange);
  border-radius: 8px;
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 15px;
  color: var(--ink);
  line-height: 1.7;
  position: relative;
}
.note-title {
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--red);
  margin-bottom: 6px;
  font-weight: 700;
}
.note strong { background: var(--yellow); padding: 0 4px; border-radius: 2px; }

/* Resources */
.resources {
  margin-top: 24px;
  padding: 20px 22px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink);
}
.resources-title {
  font-family: 'Caveat', cursive;
  font-size: 24px;
  color: var(--ink);
  margin-bottom: 12px;
  font-weight: 700;
}
.resources-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.resource-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1.5px dashed var(--line);
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  font-family: 'Kalam', cursive;
  font-size: 14px;
  transition: all 0.15s;
}
.resource-link:hover {
  background: var(--yellow);
  border-style: solid;
  border-color: var(--ink);
}
.resource-link::before {
  content: '→ ';
  color: var(--red);
  font-weight: 700;
  margin-right: 4px;
}
.resource-tag {
  font-family: 'Patrick Hand', cursive;
  font-size: 12px;
  color: var(--ink-faint);
  padding: 2px 8px;
  background: var(--paper-dark);
  border-radius: 4px;
}

/* PyTorch code */
pre.code-output {
  background: #2d2419;
  color: #f5ecd9;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  overflow-x: auto;
  line-height: 1.6;
  max-height: 500px;
  overflow-y: auto;
}
.code-output .kw { color: #e89c50; }
.code-output .cls { color: #e8c547; }
.code-output .num { color: #6ab7ff; }
.code-output .com { color: #a89878; font-style: italic; }

/* Mode toggle */
.mode-toggle {
  display: inline-flex;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 3px 3px 0 var(--ink);
}
.mode-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-family: 'Kalam', cursive;
  font-size: 14px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  font-weight: 700;
}
.mode-btn.active {
  background: var(--ink);
  color: var(--paper);
}

/* Builder */
.builder-grid {
  display: grid;
  grid-template-columns: 200px 1fr 1fr;
  gap: 18px;
}
@media (max-width: 1100px) { .builder-grid { grid-template-columns: 1fr; } }

.palette { display: flex; flex-direction: column; gap: 8px; }
.palette-item {
  padding: 10px 14px;
  background: var(--cream);
  border: 2px solid var(--ink);
  color: var(--ink);
  font-family: 'Kalam', cursive;
  font-size: 13px;
  cursor: grab;
  border-radius: 8px;
  transition: all 0.15s;
  user-select: none;
  box-shadow: 2px 2px 0 var(--ink);
  font-weight: 700;
}
.palette-item:hover {
  background: var(--yellow);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}
.palette-item:active { cursor: grabbing; }
.palette-item-label { display: flex; justify-content: space-between; align-items: center; }
.palette-item-hint {
  font-family: 'Patrick Hand', cursive;
  font-size: 12px;
  color: var(--ink-faint);
  font-weight: 400;
  margin-top: 2px;
}

.stack {
  min-height: 320px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.4);
  border: 2px dashed var(--line);
  border-radius: 8px;
}
.stack.drag-over { border-color: var(--red); background: rgba(232, 197, 71, 0.2); }
.stack-empty {
  color: var(--ink-faint);
  font-family: 'Caveat', cursive;
  font-size: 18px;
  text-align: center;
  padding: 80px 20px;
}
.stack-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  background: var(--cream);
  border: 1.5px solid var(--ink);
  border-left: 5px solid var(--green);
  border-radius: 6px;
  font-family: 'Kalam', cursive;
  font-size: 13px;
  font-weight: 700;
}
.stack-item-shape {
  font-family: 'JetBrains Mono', monospace;
  color: var(--blue);
  font-size: 11px;
  text-align: right;
}
.stack-item-remove {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  padding: 0 4px;
  font-size: 18px;
  font-weight: 700;
}
.params-display {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--orange);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-family: 'Kalam', cursive;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 2px 2px 0 var(--ink);
}
.params-display .value { font-family: 'JetBrains Mono', monospace; }

/* Pooling viz cells */
.pool-grid {
  display: grid;
  gap: 3px;
  margin: 16px auto;
  background: var(--ink);
  padding: 3px;
  border-radius: 6px;
  border: 2px solid var(--ink);
  width: fit-content;
}
.pool-cell {
  width: 36px; height: 36px;
  background: #fff;
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  transition: all 0.3s;
}
.pool-cell.in-window { background: var(--yellow); box-shadow: inset 0 0 0 2px var(--orange); }
.pool-cell.is-max { background: var(--red); color: var(--paper); }
.pool-output-cell {
  width: 64px; height: 64px;
  background: var(--green);
  color: var(--paper);
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 2px solid var(--ink);
}

/* SVG plots base */
svg.plot {
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: 3px 3px 0 var(--ink-faint);
  max-width: 100%;
  height: auto;
}

/* Nice headings inline */
h3.subhead {
  font-family: 'Caveat', cursive;
  font-size: 26px;
  color: var(--ink);
  margin: 24px 0 12px;
  font-weight: 700;
}
h3.subhead::before {
  content: '◆ ';
  color: var(--orange);
}

/* Mobile */
@media (max-width: 600px) {
  .container { padding: 0 20px; }
  nav.tabs { margin: 0 -20px; padding: 0; }
  .tabs-wrapper { padding: 0 20px; }
  .corner-decoration { display: none; }
}

/* Small chip */
.chip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--paper-dark);
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink);
  margin: 0 2px;
}
.chip.red { background: var(--red); color: var(--paper); border-color: var(--ink); }
.chip.green { background: var(--green); color: var(--paper); }
.chip.blue { background: var(--blue); color: var(--paper); }
.chip.yellow { background: var(--yellow); }

/* FC vs Conv comparison bars */
.compare-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1.5px dashed var(--line);
  border-radius: 6px;
  margin-bottom: 10px;
}
.compare-bar-label {
  width: 100px;
  font-family: 'Kalam', cursive;
  font-size: 14px;
  font-weight: 700;
}
.compare-bar-fill {
  flex: 1;
  height: 28px;
  background: var(--paper-dark);
  border-radius: 4px;
  border: 1.5px solid var(--ink);
  overflow: hidden;
  position: relative;
}
.compare-bar-inner {
  height: 100%;
  background: var(--red);
  transition: width 0.5s;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: var(--paper);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* Residual flow diagram */
.resblock-svg-wrap {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

/* ============= ACCORDION ============= */
.accordion { margin-bottom: 12px; }
.accordion-header {
  padding: 14px 18px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Kalam', cursive;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
  box-shadow: 2px 2px 0 var(--ink);
}
.accordion-header:hover { background: var(--yellow); transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.accordion-header.open { border-radius: 8px 8px 0 0; background: var(--ink); color: var(--paper); }
.accordion-header::after { content: '\25B8'; transition: transform 0.2s; }
.accordion-header.open::after { transform: rotate(90deg); }
.accordion-body {
  display: none;
  padding: 18px 20px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-top: none;
  border-radius: 0 0 8px 8px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}
.accordion-body.open { display: block; animation: fadeIn 0.3s ease; }

/* ============= PROGRESS BAR ============= */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  background: var(--red);
  z-index: 9999;
  transition: width 0.3s;
}

/* ============= QUIZ ============= */
.quiz-box {
  margin-top: 24px;
  padding: 20px 22px;
  background: var(--cream);
  border: 2px solid var(--green);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink);
}
.quiz-title {
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--green);
  margin-bottom: 12px;
  font-weight: 700;
}
.quiz-option {
  display: block;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: rgba(255,255,255,0.6);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Kalam', cursive;
  font-size: 14px;
  transition: all 0.15s;
}
.quiz-option:hover { background: var(--yellow); border-color: var(--ink); }
.quiz-option.correct { background: rgba(106, 155, 94, 0.3); border-color: var(--green); }
.quiz-option.wrong { background: rgba(200, 85, 61, 0.2); border-color: var(--red); }
.quiz-feedback {
  margin-top: 12px;
  padding: 12px;
  border-radius: 6px;
  font-family: 'Patrick Hand', cursive;
  font-size: 14px;
  display: none;
}
.quiz-feedback.show { display: block; }
.quiz-feedback.correct { background: rgba(106, 155, 94, 0.2); color: var(--green); }
.quiz-feedback.wrong { background: rgba(200, 85, 61, 0.15); color: var(--red); }

/* ============= CODE BLOCKS ============= */
.code-block {
  background: #2d2419;
  color: #f5ecd9;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 16px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  margin: 16px 0;
  white-space: pre;
}
.code-block .kw { color: #e89c50; }
.code-block .fn { color: #6ab7ff; }
.code-block .str { color: #6a9b5e; }
.code-block .cm { color: #a89878; font-style: italic; }
.code-block .num { color: #d68fa8; }
.code-block .cls { color: #e8c547; }

/* ============= TIMELINE ============= */
.timeline {
  position: relative;
  padding-left: 30px;
  margin: 24px 0;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--ink);
  border-radius: 2px;
}
.timeline-item {
  position: relative;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--ink);
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -26px;
  top: 18px;
  width: 14px;
  height: 14px;
  background: var(--red);
  border: 2px solid var(--ink);
  border-radius: 50%;
}
.timeline-year {
  font-family: 'Caveat', cursive;
  font-size: 20px;
  color: var(--red);
  font-weight: 700;
}
.timeline-title {
  font-family: 'Kalam', cursive;
  font-size: 16px;
  font-weight: 700;
  margin: 4px 0;
}
.timeline-desc {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
}

/* ============= COMPARISON TABLE ============= */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 12px;
  font-family: 'Kalam', cursive;
}
.compare-table th {
  background: var(--ink);
  color: var(--paper);
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  position: sticky;
  top: 0;
}
.compare-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.compare-table tr:hover td { background: rgba(232, 197, 71, 0.15); }
.compare-table-wrap {
  overflow-x: auto;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--ink);
}

/* ============= CHECKLIST ============= */
.checklist { list-style: none; padding: 0; }
.checklist li {
  padding: 10px 14px;
  margin-bottom: 8px;
  background: rgba(255,255,255,0.5);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  font-family: 'Kalam', cursive;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.checklist li:hover { background: var(--yellow); }
.checklist li.checked { text-decoration: line-through; color: var(--ink-faint); border-color: var(--green); }
.checklist li::before {
  content: '\2610';
  font-size: 18px;
  color: var(--ink-faint);
}
.checklist li.checked::before { content: '\2611'; color: var(--green); }

/* ============= GRADING TABLE ============= */
.grading-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-family: 'Kalam', cursive;
  font-size: 14px;
}
.grading-table th {
  background: var(--ink);
  color: var(--paper);
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
}
.grading-table td {
  padding: 10px 16px;
  border-bottom: 1.5px solid var(--line);
}
.grading-table tr:hover td { background: rgba(232, 197, 71, 0.12); }
.grading-table .pct {
  font-family: 'JetBrains Mono', monospace;
  color: var(--red);
  font-weight: 700;
}

/* ============= FORWARD PASS ANIMATION ============= */
.fp-network {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 30px 10px;
  overflow-x: auto;
  position: relative;
  min-height: 180px;
}
.fp-layer {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
  position: relative;
  z-index: 1;
}
.fp-layer-box {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  border: 2.5px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  transition: all 0.3s;
  box-shadow: 2px 2px 0 var(--ink);
}
.fp-layer-box.active {
  transform: scale(1.15);
  box-shadow: 0 0 16px var(--yellow), 3px 3px 0 var(--ink);
}
.fp-layer-name {
  font-family: 'Patrick Hand', cursive;
  font-size: 11px;
  margin-top: 6px;
  color: var(--ink-soft);
}
.fp-layer-shape {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  margin-top: 3px;
  color: var(--ink-faint);
  opacity: 0;
  transition: opacity 0.3s;
}
.fp-layer-shape.show { opacity: 1; }
.fp-arrow {
  width: 30px;
  height: 2px;
  background: var(--line);
  position: relative;
  flex-shrink: 0;
}
.fp-arrow::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -4px;
  border: 4px solid transparent;
  border-left: 6px solid var(--line);
}
.fp-ball {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 12px var(--red);
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  opacity: 0;
  transition: left 0.5s ease-in-out, opacity 0.2s;
}
.fp-ball.visible { opacity: 1; }
.fp-desc {
  min-height: 48px;
  padding: 12px 16px;
  background: rgba(74, 135, 168, 0.1);
  border: 1.5px dashed var(--blue);
  border-radius: 8px;
  font-family: 'Patrick Hand', cursive;
  font-size: 14px;
  color: var(--ink);
  margin-top: 16px;
  transition: all 0.3s;
}

/* ============= NMS INTERACTIVE ============= */
.nms-canvas-wrap {
  position: relative;
  width: 320px;
  height: 320px;
  margin: 0 auto;
}
.nms-legend {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 10px;
  font-family: 'Patrick Hand', cursive;
  font-size: 13px;
}
.nms-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.nms-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1.5px solid var(--ink);
}

/* ============= TRAINING SIMULATOR ============= */
.train-sim-canvas {
  width: 100%;
  height: 200px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--cream);
}
.train-sim-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 8px;
  font-family: 'Patrick Hand', cursive;
  font-size: 13px;
}
.train-sim-legend span::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 3px;
  margin-right: 5px;
  vertical-align: middle;
  border-radius: 2px;
}
.train-sim-legend .train-line::before { background: var(--blue); }
.train-sim-legend .val-line::before { background: var(--red); }

/* ============= RECEPTIVE FIELD CALCULATOR ============= */
.rf-calc-layers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
  min-height: 36px;
  padding: 10px;
  background: var(--cream);
  border: 1.5px dashed var(--line);
  border-radius: 8px;
}
.rf-calc-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  border: 1.5px solid var(--ink);
  background: rgba(255,255,255,0.6);
}
.rf-calc-chip .rf-remove {
  cursor: pointer;
  color: var(--red);
  font-weight: 700;
  margin-left: 4px;
}
.rf-grid-vis {
  display: grid;
  width: fit-content;
  margin: 12px auto;
  gap: 1px;
}
.rf-grid-vis .rf-cell {
  width: 12px;
  height: 12px;
  background: var(--paper-dark);
  border: 0.5px solid var(--line-soft);
  transition: background 0.3s;
}
.rf-grid-vis .rf-cell.active {
  background: rgba(200, 85, 61, 0.4);
  border-color: var(--red);
}

/* ============= FLIP CARDS ============= */
.flip-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.flip-card {
  perspective: 1000px;
  height: 180px;
  cursor: pointer;
}
.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  box-shadow: 4px 4px 0 var(--ink);
}
.flip-card-front {
  background: var(--cream);
  font-family: 'Caveat', cursive;
  font-size: 20px;
  color: var(--red);
  font-weight: 700;
}
.flip-card-back {
  background: var(--ink);
  color: var(--paper);
  transform: rotateY(180deg);
  font-family: 'Kalam', cursive;
  font-size: 14px;
  line-height: 1.6;
}

/* ============= MATCH EXERCISE ============= */
.match-exercise {
  margin: 24px 0;
  padding: 20px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink);
}
.match-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 16px;
}
.match-item {
  padding: 12px 16px;
  background: rgba(255,255,255,0.7);
  border: 2px solid var(--line);
  border-radius: 8px;
  font-family: 'Kalam', cursive;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.match-item:hover { background: var(--yellow); border-color: var(--ink); }
.match-item.selected { border-color: var(--red); background: rgba(200, 85, 61, 0.1); box-shadow: 0 0 0 2px var(--red); }
.match-item.correct { border-color: var(--green); background: rgba(106, 155, 94, 0.2); }
.match-item.wrong { border-color: var(--red); background: rgba(200, 85, 61, 0.2); }

/* ============= FORMULA / CALC BOX ============= */
.formula-box {
  margin: 16px 0;
  padding: 16px 20px;
  background: rgba(74, 135, 168, 0.08);
  border: 2px solid var(--blue);
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  text-align: center;
  color: var(--ink);
}
.calc-box {
  margin: 24px 0;
  padding: 20px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink);
}
.calc-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.calc-input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.calc-input-group label {
  font-family: 'Kalam', cursive;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 700;
}
.calc-input-group input {
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  width: 100%;
  background: #fff;
  text-align: center;
}
.calc-input-group input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(200, 85, 61, 0.2);
}
.calc-result {
  padding: 14px 18px;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  text-align: center;
  color: var(--ink);
  font-weight: 700;
}

/* ============= ENHANCED OUTPUT SIZE CALCULATOR ============= */
.calc-box-enhanced {
  position: relative;
  overflow: hidden;
}
.calc-box-enhanced::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 30% 30%, rgba(232, 197, 71, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 70%, rgba(106, 155, 94, 0.06) 0%, transparent 40%);
  pointer-events: none;
  animation: calcBgFloat 8s ease-in-out infinite alternate;
}
@keyframes calcBgFloat {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-2%, -2%); }
}

.calc-visual-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 20px 0 24px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.5);
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  position: relative;
}
.calc-visual-grid-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.calc-visual-label {
  font-family: 'Patrick Hand', cursive;
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 700;
}
.calc-visual-grid {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-light);
  border-radius: 8px;
  border: 2px solid var(--line);
  overflow: hidden;
}
.calc-grid-inner {
  display: grid;
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  gap: 1px;
}
.calc-grid-inner .calc-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 2px;
  transition: all 0.4s ease;
}
#calcGridInput .calc-cell {
  background: var(--blue);
  opacity: 0.6;
}
#calcGridOutput .calc-cell {
  background: var(--green);
  opacity: 0.7;
}
.calc-grid-inner .calc-cell.highlight {
  opacity: 1;
  transform: scale(1.1);
  box-shadow: 0 0 4px rgba(0,0,0,0.2);
}
.calc-grid-size {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  background: rgba(255,255,255,0.85);
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--ink-soft);
}

.calc-visual-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.calc-visual-arrow-label {
  font-family: 'Caveat', cursive;
  font-size: 14px;
  color: var(--red);
  font-weight: 700;
}

.calc-formula-breakdown {
  margin: 16px 0;
  padding: 14px 16px;
  background: rgba(255,255,255, 0.6);
  border: 1.5px solid var(--line);
  border-radius: 8px;
}
.calc-formula-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--ink);
  transition: all 0.3s;
}
.calc-formula-step:not(:last-child) {
  border-bottom: 1px dashed var(--line-soft);
}
.calc-formula-label {
  font-family: 'Kalam', cursive;
  font-size: 12px;
  color: var(--ink-faint);
  min-width: 36px;
  font-weight: 700;
}
.calc-formula-expr {
  flex: 1;
}
.calc-hl-input { color: var(--blue); font-weight: 700; }
.calc-hl-kernel { color: var(--purple); font-weight: 700; }
.calc-hl-stride { color: var(--red); font-weight: 700; }
.calc-hl-pad { color: var(--green); font-weight: 700; }

.calc-slider {
  width: 100%;
  margin-top: 4px;
  accent-color: var(--red);
  height: 4px;
  cursor: pointer;
}

.calc-result-enhanced {
  padding: 18px 24px;
  background: linear-gradient(135deg, var(--yellow) 0%, #f0d85a 100%);
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  box-shadow: 4px 4px 0 var(--ink);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}
.calc-result-enhanced::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
  transform: translateX(-100%);
  animation: calcShine 3s ease-in-out infinite;
}
@keyframes calcShine {
  0%, 80% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.calc-result-enhanced.invalid {
  background: linear-gradient(135deg, var(--red) 0%, #d46b55 100%);
  color: white;
}
.calc-result-enhanced.pulse {
  animation: calcPulse 0.5s ease;
}
@keyframes calcPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.calc-result-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
  transition: all 0.3s;
}
.calc-result-enhanced.invalid .calc-result-number {
  color: white;
}
.calc-result-label {
  font-family: 'Kalam', cursive;
  font-size: 14px;
  color: var(--ink-soft);
}
.calc-result-enhanced.invalid .calc-result-label {
  color: rgba(255,255,255,0.8);
}

.calc-presets {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.calc-presets-label {
  font-family: 'Kalam', cursive;
  font-size: 13px;
  color: var(--ink-faint);
}
.calc-preset-btn {
  font-size: 11px !important;
  transition: all 0.2s;
}
.calc-preset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.calc-tips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.calc-tip {
  padding: 8px 12px;
  background: rgba(255,255,255,0.5);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  font-family: 'Patrick Hand', cursive;
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}
.calc-tip-icon {
  font-size: 14px;
}

/* ============= STEP REVEAL ============= */
.step-reveal {
  margin: 16px 0;
}
.step-reveal-item {
  padding: 14px 18px;
  margin-bottom: 8px;
  background: var(--cream);
  border: 2px solid var(--line);
  border-radius: 8px;
  opacity: 0.4;
  transition: all 0.3s;
  font-family: 'Kalam', cursive;
  font-size: 14px;
}
.step-reveal-item.revealed {
  opacity: 1;
  border-color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

/* ============= SORTABLE LIST ============= */
.sortable-list {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sortable-item {
  padding: 12px 16px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-family: 'Kalam', cursive;
  font-size: 14px;
  cursor: grab;
  user-select: none;
  transition: all 0.2s;
  box-shadow: 2px 2px 0 var(--ink);
}
.sortable-item:active { cursor: grabbing; }
.sortable-item.dragging { opacity: 0.5; }
.sortable-item.correct { border-color: var(--green); background: rgba(106, 155, 94, 0.15); }
.sortable-item.wrong { border-color: var(--red); background: rgba(200, 85, 61, 0.15); }

/* ============= TAB LOADING ============= */
.tab-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--ink-faint);
}
.tab-loading::after {
  content: '';
  width: 24px;
  height: 24px;
  margin-left: 12px;
  border: 3px solid var(--line);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============= FILL BLANKS ============= */
.fill-blank {
  display: inline-block;
  min-width: 120px;
  padding: 4px 8px;
  border-bottom: 3px dashed var(--red);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.fill-blank:hover { background: rgba(232, 197, 71, 0.3); }
.fill-blank.filled { border-bottom-color: var(--green); color: var(--green); }
.fill-blank.wrong-fill { border-bottom-color: var(--red); color: var(--red); }

/* ============= SANDBOX ============= */
.sandbox {
  margin: 16px 0;
  padding: 20px;
  background: #2d2419;
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink);
}
.sandbox-editor {
  width: 100%;
  min-height: 150px;
  background: transparent;
  border: none;
  color: #f5ecd9;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.sandbox-output {
  margin-top: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #6a9b5e;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  white-space: pre-wrap;
  min-height: 40px;
}
