/* ==========================================================================
   rustdb Swiss Architectural Components
   Hairline Grids, Centerpiece App Workbench, Barcode Ribbon, Matrix & Traces
   ========================================================================== */

/* Buttons (drayhq 6px sharp proportions) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.94rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.btn-primary {
  background: var(--cta-primary-bg);
  color: var(--cta-primary-fg);
}

.btn-primary:hover {
  background: var(--cta-primary-hover);
}

.btn-secondary {
  background: var(--bg-canvas);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
}

.btn-cobalt {
  background: var(--brand-cobalt);
  color: #ffffff;
}

.btn-cobalt:hover {
  filter: brightness(1.08);
}

.btn-sm {
  min-height: 38px;
  padding: 6px 13px;
  font-size: 0.84rem;
}

/* Pills & Tags */
.file-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  max-width: 100%;
  overflow-wrap: break-word;
}

.sub-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  max-width: 100%;
  overflow-wrap: break-word;
}

.sub-parser { color: var(--sub-parser-fg); background: var(--sub-parser-bg); border-color: var(--sub-parser-border); }
.sub-catalog { color: var(--sub-catalog-fg); background: var(--sub-catalog-bg); border-color: var(--sub-catalog-border); }
.sub-wal { color: var(--sub-wal-fg); background: var(--sub-wal-bg); border-color: var(--sub-wal-border); }
.sub-buffer { color: var(--sub-buffer-fg); background: var(--sub-buffer-bg); border-color: var(--sub-buffer-border); }
.sub-heap { color: var(--sub-heap-fg); background: var(--sub-heap-bg); border-color: var(--sub-heap-border); }
.sub-btree { color: var(--sub-btree-fg); background: var(--sub-btree-bg); border-color: var(--sub-btree-border); }
.sub-exec { color: var(--sub-exec-fg); background: var(--sub-exec-bg); border-color: var(--sub-exec-border); }

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-works { color: var(--status-works-fg); background: var(--status-works-bg); border-color: var(--status-works-border); }
.status-partial { color: var(--status-partial-fg); background: var(--status-partial-bg); border-color: var(--status-partial-border); }
.status-verify { color: var(--status-verify-fg); background: var(--status-verify-bg); border-color: var(--status-verify-border); }
.status-missing { color: var(--status-missing-fg); background: var(--status-missing-bg); border-color: var(--status-missing-border); }
.status-planned { color: var(--status-planned-fg); background: var(--status-planned-bg); border-color: var(--status-planned-border); }

/* Hairline Bento Grids (Seamless 1px shared architectural borders) */
.hairline-grid {
  display: grid;
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
}

.hairline-cols-2 {
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 780px) {
  .hairline-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.hairline-cols-3 {
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 780px) {
  .hairline-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.hairline-cols-6 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 780px) {
  .hairline-cols-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.hairline-cell {
  background: var(--bg-surface);
  padding: var(--space-5);
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-3);
}

.hairline-cell-plain {
  background: var(--bg-canvas);
  padding: var(--space-5);
  min-width: 0;
}

/* Flat Architectural Card */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: var(--space-5);
  min-width: 0;
}

.card-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

/* ==========================================================================
   Hero Editorial + Barcode Graphic Ribbon + Centered Workbench Window
   ========================================================================== */
.hero-editorial {
  text-align: center;
  padding-top: var(--space-7);
  padding-bottom: var(--space-6);
}

.hero-eyebrow {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 12px;
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.hero-editorial h1 {
  max-width: 22ch;
  margin-inline: auto;
}

.hero-editorial .lead {
  margin-inline: auto;
  color: var(--text-secondary);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: var(--space-5);
}

.hero-sublinks {
  margin-top: var(--space-3);
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Electric Cobalt Vertical Barcode / Scanline Backdrop */
.hero-showcase-band {
  position: relative;
  padding-block: var(--space-5) var(--space-7);
  overflow: hidden;
}

.barcode-backdrop {
  position: absolute;
  inset: 18px 0 36px 0;
  pointer-events: none;
  opacity: 0.9;
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(22, 18, 248, 0.85) 0 4px,
      transparent 4px 10px,
      rgba(22, 18, 248, 0.35) 10px 13px,
      transparent 13px 22px,
      rgba(22, 18, 248, 0.6) 22px 25px,
      transparent 25px 38px
    );
  mask-image: linear-gradient(90deg, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.18) 22%, rgba(0,0,0,0.18) 78%, rgba(0,0,0,0.95) 100%);
}

/* 3-Pane Centered Workbench Window */
.workbench-window {
  position: relative;
  z-index: 2;
  max-width: 1080px;
  margin-inline: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-window);
  overflow: hidden;
}

.workbench-titlebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.window-dots {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.window-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.window-dot:nth-child(1) { background: #ef4444; }
.window-dot:nth-child(2) { background: #f59e0b; }
.window-dot:nth-child(3) { background: #22c55e; }

.workbench-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.workbench-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 900px) {
  .workbench-body {
    grid-template-columns: 210px minmax(0, 1.3fr) 260px;
  }
}

.wb-sidebar {
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 900px) {
  .wb-sidebar {
    border-bottom: 0;
    border-right: 1px solid var(--border-subtle);
  }
}

.wb-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.wb-nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.wb-nav-item[aria-pressed="true"] {
  background: var(--bg-elevated);
  border-color: var(--brand-cobalt-fg);
  color: var(--text-primary);
}

.wb-center {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.wb-inspector {
  background: var(--bg-inset);
  border-top: 1px solid var(--border-subtle);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

@media (min-width: 900px) {
  .wb-inspector {
    border-top: 0;
    border-left: 1px solid var(--border-subtle);
  }
}

/* ==========================================================================
   64-Square 4KB Byte Matrix Comparison (drayhq dot-matrix block style)
   ========================================================================== */
.cobalt-banner-cell {
  background: var(--brand-cobalt);
  color: #ffffff;
  padding: var(--space-6);
}

.cobalt-banner-cell h2,
.cobalt-banner-cell p {
  color: #ffffff;
}

.byte-matrix {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 4px;
  margin-block: 14px;
}

.byte-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.byte-cell.is-cobalt {
  background: var(--brand-cobalt);
  border-color: var(--brand-cobalt);
}

.byte-cell.is-green {
  background: #22c55e;
  border-color: #22c55e;
}

.byte-cell.is-muted {
  background: var(--border-strong);
  border-color: var(--border-strong);
}

.matrix-stat {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text-primary);
}

/* FAQ Two-Column Split (drayhq style) */
.faq-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

@media (min-width: 860px) {
  .faq-split {
    grid-template-columns: 0.75fr 1.25fr;
  }
}

.faq-list {
  border-top: 1px solid var(--border-subtle);
}

.faq-item {
  border-bottom: 1px solid var(--border-subtle);
}

.faq-item summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 4px;
  font-weight: 500;
  color: var(--text-primary);
  min-height: 52px;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item[open] summary svg {
  transform: rotate(45deg);
}

.faq-item p {
  padding: 0 4px 16px;
  margin: 0;
  font-size: 0.94rem;
}

/* ==========================================================================
   Shared Interactive Components (Terminals, Callouts, Pills, Traces)
   ========================================================================== */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 5px 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  transition: border-color var(--dur-fast) ease, background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.pill-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.pill-btn[aria-pressed="true"],
.pill-btn[aria-selected="true"],
.pill-btn.is-active {
  border-color: var(--brand-cobalt-fg);
  background: var(--brand-cobalt-tint);
  color: var(--text-primary);
}

.callout {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-left-width: 3px;
  background: var(--bg-surface);
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.callout p {
  margin: 0;
  font-size: 0.93rem;
}

.callout-what { border-left-color: var(--sub-buffer-fg); }
.callout-what .callout-title { color: var(--sub-buffer-fg); }

.callout-limit { border-left-color: var(--sub-wal-fg); }
.callout-limit .callout-title { color: var(--sub-wal-fg); }

.callout-source { border-left-color: var(--sub-catalog-fg); }
.callout-source .callout-title { color: var(--sub-catalog-fg); }

.callout-simulated {
  border-color: var(--brand-cobalt-fg);
  border-left-width: 4px;
  background: var(--brand-cobalt-tint);
}
.callout-simulated .callout-title { color: var(--brand-cobalt-fg); }

/* Terminal */
.terminal-shell {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--bg-terminal);
  color: var(--text-terminal);
  min-width: 0;
  max-width: 100%;
}

.terminal-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 9px 14px;
  background: var(--bg-terminal-bar);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.terminal-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.terminal-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.terminal-dot:nth-child(1) { background: #ef4444; }
.terminal-dot:nth-child(2) { background: #f59e0b; }
.terminal-dot:nth-child(3) { background: #22c55e; }

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-terminal-muted);
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #f4f4f5;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.copy-btn[data-copied="true"] {
  border-color: #4ade80;
  color: #4ade80;
}

.terminal-body {
  margin: 0;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.6;
  overflow-x: auto;
  color: var(--text-terminal);
}

.term-line {
  display: block;
  transition: opacity var(--dur-fast) ease, transform var(--dur-fast) ease;
}

.term-line.is-entering {
  opacity: 0;
  transform: translateY(4px);
}

.term-cmd { color: #fafafa; }
.term-prompt { color: #4ade80; font-weight: 700; }
.term-prompt-arrow { color: #38bdf8; font-weight: 700; }
.term-ok { color: #4ade80; }
.term-warn { color: #fbbf24; }
.term-err { color: #f87171; }
.term-cyan { color: #38bdf8; }
.term-muted { color: #a1a1aa; }

/* Isometric / Flow Animations */
@keyframes floatRamPlate {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-4px); }
}

@keyframes dashFlow {
  to { stroke-dashoffset: -28; }
}

.iso-ram-float {
  animation: floatRamPlate 3.2s ease-in-out infinite;
}

.iso-flow-active {
  stroke-dasharray: 7 5;
  animation: dashFlow 0.85s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .iso-ram-float,
  .iso-flow-active {
    animation: none;
  }
}

html[data-reduced-motion="true"] .iso-ram-float,
html[data-reduced-motion="true"] .iso-flow-active {
  animation: none;
}

/* Learn Workbench */
.learn-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

@media (min-width: 920px) {
  .learn-workbench {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.35fr);
  }
}

.step-list {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  max-width: 100%;
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
}

@media (min-width: 920px) {
  .step-list {
    flex-direction: column;
    overflow-x: visible;
  }
}

.step-item-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 12px 14px;
  border: 0;
  background: var(--bg-surface);
  text-align: left;
  color: var(--text-secondary);
}

@media (min-width: 920px) {
  .step-item-btn {
    width: 100%;
  }
}

.step-item-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.step-item-btn[aria-current="step"] {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: inset 3px 0 0 var(--brand-cobalt);
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--bg-canvas);
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
}

.step-item-btn[aria-current="step"] .step-num {
  background: var(--brand-cobalt);
  color: #ffffff;
  border-color: var(--brand-cobalt);
}

.state-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  margin-top: var(--space-4);
}

@media (min-width: 640px) {
  .state-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.state-box {
  background: var(--bg-surface);
  padding: 12px 14px;
  min-width: 0;
}

.state-box-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.state-box-value {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow-wrap: break-word;
}

/* Internals: Architecture Map + Trace Panel */
.arch-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
}

@media (min-width: 720px) {
  .arch-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.arch-node-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  min-height: 112px;
  border: 0;
  background: var(--bg-surface);
  text-align: left;
}

.arch-node-btn:hover {
  background: var(--bg-elevated);
}

.arch-node-btn[aria-pressed="true"] {
  background: var(--bg-elevated);
  box-shadow: inset 0 2px 0 var(--brand-cobalt);
}

.arch-inspector {
  margin-top: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  padding: var(--space-5);
}

.trace-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  padding: var(--space-4);
}

@media (min-width: 768px) {
  .trace-panel {
    padding: var(--space-5);
  }
}

.trace-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-4);
}

.scrubber-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 12px 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
}

.scrubber-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.scrubber-dots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.step-dot-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.step-dot-btn[aria-current="step"] {
  background: var(--brand-cobalt);
  border-color: var(--brand-cobalt);
  color: #ffffff;
}

.trace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

@media (min-width: 980px) {
  .trace-layout {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.95fr);
  }
}

.trace-diagram-box {
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  padding: var(--space-3);
  min-width: 0;
}

.trace-svg-node {
  transition: opacity var(--dur-trace) ease;
}

.trace-svg-node.is-dim {
  opacity: 0.38;
}

.trace-svg-node.is-active {
  opacity: 1;
}

/* Precision 4KB Page & WAL Tape */
.page-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
}

@media (min-width: 760px) {
  .page-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.page-block {
  background: var(--bg-inset);
  padding: 16px;
  min-width: 0;
}

.page-block-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px dashed var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
}

.wal-tape {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  max-width: 100%;
  padding: 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
}

.wal-frame {
  flex: 0 0 auto;
  min-width: 160px;
  padding: 10px 12px;
  border: 1px solid var(--sub-wal-border);
  background: var(--sub-wal-bg);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.wal-frame.is-checkpoint {
  border-color: var(--sub-buffer-border);
  background: var(--sub-buffer-bg);
}

.wal-frame.is-replayed {
  border-color: var(--brand-cobalt-fg);
  background: var(--brand-cobalt-tint);
}

/* Buffer Pool Grid */
.buffer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.buffer-frame {
  padding: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-inset);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  overflow-wrap: break-word;
}

.buffer-frame.is-dirty {
  border-color: var(--sub-wal-border);
  background: var(--sub-wal-bg);
}

.buffer-frame.is-clean {
  border-color: var(--sub-buffer-border);
  background: var(--sub-buffer-bg);
}

/* Playground Split */
.playground-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

@media (min-width: 960px) {
  .playground-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.sql-editor-area {
  width: 100%;
  min-height: 112px;
  padding: 14px 16px;
  border: 0;
  resize: vertical;
  background: var(--bg-terminal);
  color: var(--text-terminal);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.55;
}

/* Limitations Matrix */
.matrix-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.93rem;
}

.matrix-table th {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-inset);
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-strong);
}

.matrix-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.matrix-table tr:last-child td {
  border-bottom: 0;
}

@media (min-width: 721px) {
  .matrix-table td:last-child {
    min-width: 230px;
  }
}

@media (max-width: 720px) {
  .matrix-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .matrix-table,
  .matrix-table tbody,
  .matrix-table tr,
  .matrix-table td {
    display: block;
    width: 100%;
  }

  .matrix-table tr {
    border-bottom: 1px solid var(--border-strong);
    padding: 10px 0;
  }

  .matrix-table td {
    border-bottom: 0;
    padding: 6px 14px;
  }

  .matrix-table td::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 3px;
  }
}

/* ==========================================================================
   Progressive Disclosure ("Show Rust details") + Animated Lab Primitives
   ========================================================================== */
.rust-details {
  border: 1px solid var(--border-subtle);
  background: var(--bg-inset);
}

.rust-details summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.rust-details summary::-webkit-details-marker {
  display: none;
}

.rust-details summary:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.rust-details[open] summary svg {
  transform: rotate(45deg);
}

.rust-details-body {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Scroll Reveal (always visible by default; WAAPI animates smoothly on scroll) */
.reveal-card {
  opacity: 1;
  transform: none;
}

/* Token Pills & Storage Lab Animators */
.token-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.tok-chip {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 4px 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  transition: border-color 180ms ease, color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.tok-chip.is-lit {
  border-color: var(--sub-parser-fg);
  background: var(--sub-parser-bg);
  color: var(--sub-parser-fg);
  transform: translateY(-2px);
}

.lab-stage {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  padding: var(--space-5);
  display: grid;
  gap: var(--space-4);
}

.slot-list {
  display: grid;
  gap: 8px;
}

@keyframes slotPop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.slot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--sub-heap-border);
  background: var(--sub-heap-bg);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  animation: slotPop 280ms var(--ease-out-expo);
}

.btree-visual {
  display: grid;
  gap: 14px;
}

.btree-node-box {
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  background: var(--bg-inset);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  transition: border-color 240ms ease, background-color 240ms ease, box-shadow 240ms ease;
}

.btree-node-box.is-lit {
  border-color: var(--brand-cobalt-fg);
  background: var(--brand-cobalt-tint);
  box-shadow: 0 0 0 1px var(--brand-cobalt-fg);
}

.wal-frame.is-crashed {
  border-color: var(--status-missing-border);
  background: var(--status-missing-bg);
}

@media (prefers-reduced-motion: reduce) {
  .tok-chip.is-lit,
  .slot-row {
    transform: none;
    animation: none;
  }
}

html[data-reduced-motion="true"] .tok-chip.is-lit,
html[data-reduced-motion="true"] .slot-row {
  transform: none;
  animation: none;
}
