/* ============================================================
   Chess Move Cipher — Stylesheet
   ============================================================ */

:root {
  --bg:           #0d1117;
  --bg-2:         #161b22;
  --bg-3:         #21262d;
  --border:       #30363d;
  --border-light: #3d444d;
  --gold:         #d4a843;
  --gold-dim:     #a07830;
  --green:        #2ea043;
  --red:          #f85149;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-dim:     #6e7681;
  --sq-light:     #f0d9b5;
  --sq-dark:      #b58863;
  --hl-from:      rgba(20, 160, 50, 0.65);
  --hl-to:        rgba(255, 200, 0, 0.60);
  --hl-last:      rgba(155, 199, 0, 0.40);
  --radius:       10px;
  --radius-lg:    16px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: #e8c060; }

code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #79c0ff;
}

.mono { font-family: 'JetBrains Mono', monospace; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ─── Navbar ─── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 40px;
  background: rgba(13,17,23,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.nav-piece {
  font-size: 1.6rem;
  color: var(--gold);
  filter: drop-shadow(0 0 8px rgba(212,168,67,0.6));
}

.nav-links {
  display: flex;
  gap: 32px;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--text); }
.nav-links .nav-link-highlight {
  color: var(--gold);
  border: 1px solid rgba(212,168,67,0.3);
  padding: 4px 12px;
  border-radius: 6px;
  background: rgba(212,168,67,0.06);
}
.nav-links .nav-link-highlight:hover { background: rgba(212,168,67,0.14); color: var(--gold); }

/* ─── Hero ─── */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 100px 80px 60px;
  gap: 60px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -200px; left: -200px;
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(212,168,67,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-content { flex: 1; max-width: 560px; }

.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  border: 1px solid var(--gold-dim);
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 24px;
  background: rgba(212,168,67,0.06);
}

.hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--gold) 0%, #e8c060 50%, #f0a030 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 36px;
  line-height: 1.7;
}

.hero-cta { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }

/* ─── Buttons ─── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: linear-gradient(135deg, var(--gold) 0%, #c08020 100%);
  color: #0d1117;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(212,168,67,0.4);
  color: #0d1117;
}
.btn-primary:active { transform: translateY(0); }

.btn-primary.btn-full { width: 100%; justify-content: center; padding: 14px; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-ghost:hover { border-color: var(--border-light); color: var(--text); background: var(--bg-2); }

.btn-ghost.btn-sm { padding: 7px 14px; font-size: 0.82rem; }

/* ─── Hero Board (decoration) ─── */
.hero-visual {
  position: relative;
  flex-shrink: 0;
}

.floating-board {
  width: 360px;
  height: 360px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow), 0 0 60px rgba(212,168,67,0.15);
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-12px) rotate(-2deg); }
}

.board-glow {
  position: absolute;
  bottom: -40px; left: 50%;
  transform: translateX(-50%);
  width: 300px; height: 80px;
  background: radial-gradient(ellipse, rgba(212,168,67,0.25) 0%, transparent 70%);
  filter: blur(20px);
}

/* ─── Sections ─── */
.section {
  padding: 100px 0;
}

.section-header {
  text-align: center;
  margin-bottom: 60px;
}

.section-header h2 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.section-header p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* ─── Steps ─── */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.step-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}

.step-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.step-card:hover {
  border-color: var(--border-light);
  transform: translateY(-4px);
}
.step-card:hover::before { opacity: 1; }

.step-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.step-icon-wrap {
  margin-bottom: 16px;
}

.step-piece {
  font-size: 2.4rem;
  filter: drop-shadow(0 0 6px rgba(212,168,67,0.4));
}

.step-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.step-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.7;
  margin-bottom: 20px;
}

.step-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  line-height: 1.8;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-all;
}

.code-comment { color: var(--text-dim); }
.code-header { color: #79c0ff; }
.code-data { color: #a5d6ff; }

/* ─── Info card ─── */
.info-card {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-top: 32px;
}

.info-card.accent {
  border-color: rgba(212,168,67,0.3);
  background: rgba(212,168,67,0.04);
}

.info-icon { font-size: 1.6rem; flex-shrink: 0; }

.info-text {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.info-text strong { color: var(--text); }

/* ─── Cipher Tool ─── */
.cipher-section { background: var(--bg-2); }

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.tool-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}

/* ─── Form ─── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group textarea,
.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  padding: 12px 16px;
  transition: border-color 0.2s;
  resize: vertical;
  font-family: inherit;
  outline: none;
}

.form-group textarea:focus,
.form-group input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(212,168,67,0.1);
}

.form-group textarea.mono,
.pgn-textarea {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

.input-wrap {
  position: relative;
}

.input-wrap input { padding-right: 44px; }

.toggle-pw {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-dim);
  padding: 4px;
  transition: color 0.2s;
}
.toggle-pw:hover { color: var(--text); }

.btn-icon { font-size: 1rem; }

/* ─── Chess Board ─── */
.tool-board { position: sticky; top: 100px; }

.board-wrap {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
}

.chess-board {
  display: grid;
  /* column/row sizes are set by JS so every square is identical px size */
  grid-template-columns: repeat(8, 52px);
  grid-template-rows: repeat(8, 52px);
  width: 416px;
  height: 416px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow);
  user-select: none;
  flex-shrink: 0;
}

.board-coords-files,
.board-coords-ranks {
  display: flex;
  position: absolute;
}

.board-coords-files {
  bottom: -20px; left: 0; right: 0;
  justify-content: space-around;
}

.board-coords-ranks {
  top: 0; bottom: 0;
  left: -18px;
  flex-direction: column;
  justify-content: space-around;
}

.board-coords-files span,
.board-coords-ranks span {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
}

.sq {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  cursor: default;
  transition: background 0.25s;
  position: relative;
}

.sq.light { background: var(--sq-light); }
.sq.dark  { background: var(--sq-dark); }

.sq.hl-from { background: var(--hl-from) !important; }
.sq.hl-to   { background: var(--hl-to)   !important; }
.sq.hl-last { background: var(--hl-last)  !important; }

.piece-white { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.8), 0 0 1px #000; }
.piece-black { color: #1a1a1a; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }

/* ─── Step Info ─── */
.step-info {
  margin-top: 30px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.step-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.step-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.highlight-bits { color: var(--gold); }

/* ─── Animation Controls ─── */
.anim-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.ctrl-btn {
  width: 36px; height: 36px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ctrl-btn:hover { background: var(--border); }
.ctrl-btn.ctrl-play {
  background: var(--gold);
  color: #0d1117;
  border-color: var(--gold);
  font-weight: 700;
}
.ctrl-btn.ctrl-play:hover { background: #e8c060; }

.ctrl-btn.paused { background: var(--bg-3); color: var(--gold); border-color: var(--gold); }

.anim-progress {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  min-width: 60px;
}

.speed-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.speed-wrap label {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.speed-wrap input[type="range"] {
  width: 80px;
  accent-color: var(--gold);
}

/* ─── Bits Stream ─── */
.bits-section {
  margin-top: 48px;
}

.bits-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.bits-hint {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(212,168,67,0.12);
  border: 1px solid rgba(212,168,67,0.3);
  border-radius: 4px;
  font-size: 0.72rem;
  color: var(--gold);
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}

.bits-stream {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  padding: 16px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 140px;
  overflow-y: auto;
}

.bit-block {
  padding: 2px 5px;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  white-space: nowrap;
}

.bit-block:hover { transform: scale(1.05); opacity: 0.9; }

.bit-block.header {
  background: rgba(121,192,255,0.15);
  color: #79c0ff;
  border: 1px solid rgba(121,192,255,0.3);
}

.bit-block.active {
  background: rgba(212,168,67,0.25);
  color: var(--gold);
  border: 1px solid rgba(212,168,67,0.5);
  box-shadow: 0 0 8px rgba(212,168,67,0.3);
}

.bit-block.done {
  background: rgba(46,160,67,0.12);
  color: #56d364;
  border: 1px solid rgba(46,160,67,0.2);
}

.bit-block.pending {
  background: var(--bg);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

/* ─── Stats bar ─── */
.stats-bar {
  display: flex;
  gap: 8px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.stat-item {
  flex: 1;
  min-width: 100px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-n {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.stat-lbl {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── PGN section ─── */
.pgn-section { margin-top: 32px; }

.pgn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pgn-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.pgn-actions { display: flex; gap: 8px; }

.pgn-textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 14px 16px;
  resize: vertical;
  outline: none;
  font-size: 0.8rem;
  line-height: 1.6;
}

/* ─── Decrypt result ─── */
.dec-result {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
}

.result-icon { font-size: 3rem; margin-bottom: 16px; }

.dec-result h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--green);
}

.message-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  font-size: 1.05rem;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
  text-align: left;
  margin-bottom: 16px;
  min-height: 60px;
  line-height: 1.7;
}

.dec-placeholder {
  background: var(--bg-3);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 60px 32px;
  text-align: center;
}

.placeholder-piece {
  font-size: 3.5rem;
  color: var(--text-dim);
  display: block;
  margin-bottom: 12px;
}

.dec-placeholder p {
  color: var(--text-dim);
  font-size: 0.92rem;
}

/* ─── Error ─── */
.error-msg {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(248,81,73,0.08);
  border: 1px solid rgba(248,81,73,0.3);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 0.88rem;
}

/* ─── Algorithm section ─── */
.algo-section { background: var(--bg); }

.algo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.algo-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: border-color 0.2s;
}
.algo-card:hover { border-color: var(--border-light); }

.algo-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.algo-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 16px;
}

.algo-table {
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.algo-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.algo-row:last-child { border-bottom: none; }
.algo-row.header {
  background: var(--bg-3);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.algo-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  color: #a5d6ff;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  overflow-x: auto;
}

/* ─── Footer ─── */
.footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
  text-align: center;
}

.footer-brand {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.footer p {
  color: var(--text-dim);
  font-size: 0.85rem;
  max-width: 500px;
  margin: 0 auto;
}

/* ─── Loading spinner ─── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .hero { flex-direction: column; padding: 100px 24px 60px; text-align: center; }
  .hero-cta { justify-content: center; }
  .hero-visual { display: none; }
  .tool-layout { grid-template-columns: 1fr; }
  .tool-board { position: static; }
  .chess-board { max-width: 340px; }
  .step-row { grid-template-columns: repeat(2, 1fr); }
  .navbar { padding: 16px 20px; }
  .nav-links { display: none; }
}

@media (max-width: 600px) {
  .steps-grid { grid-template-columns: 1fr; }
  .algo-grid { grid-template-columns: 1fr; }
  .stats-bar { gap: 6px; }
  .stat-item { min-width: 80px; }
  .hero { padding: 90px 16px 40px; }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── Pulse animation for encrypting ─── */
@keyframes pulseBorder {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,168,67,0); }
  50% { box-shadow: 0 0 0 6px rgba(212,168,67,0.15); }
}
.chess-board.encrypting { animation: pulseBorder 1.2s ease-in-out infinite; }

/* ─── Tooltip ─── */
.bit-block[data-tip] { position: relative; }

/* ============================================================
   Step Demo Animations
   ============================================================ */

.step-demo {
  margin-top: 16px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  min-height: 120px;
  position: relative;
}

.d1-micro-label,
.d3-micro-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

/* Demo 1 — Text to Bits */
.d1-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.d1-char-box, .d1-bin-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.d1-char {
  width: 40px;
  height: 40px;
  background: rgba(212,168,67,0.12);
  border: 1px solid rgba(212,168,67,0.35);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.25s;
}

.d1-char.flash {
  background: rgba(212,168,67,0.28);
  transform: scale(1.08);
}

.d1-arrow {
  font-size: 1.2rem;
  color: var(--text-dim);
  padding-top: 16px;
}

.d1-bits {
  display: flex;
  gap: 3px;
  font-family: 'JetBrains Mono', monospace;
}

.bc {
  width: 18px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: all 0.15s;
}

.bc.lit {
  background: rgba(121,192,255,0.15);
  border-color: rgba(121,192,255,0.4);
  color: #79c0ff;
}

.d1-stream-box { display: flex; flex-direction: column; gap: 4px; }

.d1-stream {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.d1-block {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  padding: 3px 6px;
  border-radius: 4px;
  font-weight: 600;
  border: 1px solid transparent;
  animation: blockIn 0.25s ease;
}

@keyframes blockIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

.d1-block.hdr {
  background: rgba(121,192,255,0.1);
  border-color: rgba(121,192,255,0.3);
  color: #79c0ff;
}

.d1-block.chr {
  background: rgba(212,168,67,0.12);
  border-color: rgba(212,168,67,0.3);
  color: var(--gold);
}

/* Demo 2 — HMAC Ordering */
.d2-status {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
  min-height: 18px;
  transition: color 0.3s;
}

.d2-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}

.d2-row {
  display: grid;
  grid-template-columns: 18px 52px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  transition: all 0.4s;
}

.d2-row.usable {
  background: rgba(46,160,67,0.08);
  border-color: rgba(46,160,67,0.3);
}

.d2-row.selected {
  background: rgba(212,168,67,0.14);
  border-color: rgba(212,168,67,0.45);
}

.d2-idx { color: var(--text-dim); font-size: 0.68rem; text-align: right; }
.d2-move { color: var(--gold); font-weight: 700; }
.d2-hmac { color: var(--text-dim); font-size: 0.7rem; overflow: hidden; text-overflow: ellipsis; }
.d2-badge {
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
}
.d2-badge.use { background: rgba(46,160,67,0.18); color: #56d364; }
.d2-badge.skip { background: rgba(248,81,73,0.12); color: #f85149; }

.d2-calc {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  min-height: 18px;
  transition: opacity 0.4s;
}

.d2-calc strong { color: var(--gold); }

/* Demo 3 — Bits to Moves */
.d3-chunks {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.d3-chunk {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  transition: all 0.25s;
}

.d3-chunk.active {
  background: rgba(212,168,67,0.2);
  border-color: rgba(212,168,67,0.6);
  color: var(--gold);
  box-shadow: 0 0 10px rgba(212,168,67,0.25);
  transform: scale(1.08);
}

.d3-chunk.done {
  background: rgba(46,160,67,0.08);
  border-color: rgba(46,160,67,0.25);
  color: #56d364;
}

.d3-eq {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 20px;
  margin-bottom: 10px;
  transition: opacity 0.3s;
}

.d3-eq strong { color: var(--gold); }
.d3-eq em { color: #79c0ff; font-style: normal; }

.d3-moves {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.d3-move {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  transition: all 0.3s;
}

.d3-move.selected {
  background: rgba(212,168,67,0.15);
  border-color: rgba(212,168,67,0.5);
  transform: translateX(3px);
}

.d3-move-idx { color: var(--text-dim); width: 18px; text-align: right; font-size: 0.68rem; }
.d3-move-uci { color: var(--text); font-weight: 600; }
.d3-move.selected .d3-move-uci { color: var(--gold); }
.d3-move-arrow { color: var(--gold); font-size: 0.8rem; margin-left: auto; opacity: 0; transition: opacity 0.2s; }
.d3-move.selected .d3-move-arrow { opacity: 1; }
