/* ==========================================================================
   SQLens - Design Tokens & Stylesheet
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Light Theme Palette */
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-subtle: #f8fafc;
  --border-main: #e2e8f0;
  --border-subtle: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-primary: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-glow: rgba(37, 99, 235, 0.15);
  --success: #059669;
  --success-bg: rgba(5, 150, 105, 0.12);
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.1);
  --warning: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.12);
  --highlight-clause: #8b5cf6;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --nav-bg: rgba(255, 255, 255, 0.85);
  --card-glow: rgba(37, 99, 235, 0.04);
}

html.dark {
  /* Dark Theme Palette (Deep Slate Architecture) */
  --bg-page: #0b0f19;
  --bg-surface: #111827;
  --bg-surface-elevated: #1e293b;
  --bg-subtle: #0f172a;
  --border-main: #1f293d;
  --border-subtle: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.16);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --highlight-clause: #a78bfa;
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  --nav-bg: rgba(17, 24, 39, 0.85);
  --card-glow: rgba(59, 130, 246, 0.08);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

code,
pre,
.font-mono {
  font-family: var(--font-mono);
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.top-nav {
  height: 64px;
  border-bottom: 1px solid var(--border-main);
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background-color 200ms ease, border-color 200ms ease;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* SQLQuokka brand: mascot mark + "SQL" in the accent colour */
.brand-mark {
  display: block;
  flex: none;
}

.brand-sql {
  color: var(--accent-primary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-link {
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: color 150ms ease;
}

.nav-link:hover {
  color: var(--text-primary);
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px;
}

.mobile-menu-drawer {
  display: none;
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-main);
  padding: 20px 24px;
  flex-direction: column;
  gap: 16px;
  z-index: 49;
  box-shadow: var(--shadow-lg);
}

.mobile-menu-drawer.open {
  display: flex;
}

@media (max-width: 820px) {
  .nav-links {
    display: none;
  }

  .mobile-menu-btn {
    display: block;
  }
}

/* ==========================================================================
   Buttons & Interactive
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 16px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  border-color: var(--border-main);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--border-main);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--text-muted);
}

/* Busy state set by setButtonBusy(): the label stays, a spinner takes the icon's place */
button.is-busy {
  cursor: progress;
  pointer-events: none;
}

button.is-busy > svg {
  display: none;
}

.btn-spinner {
  display: inline-block;
  flex: none;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: btnSpin 700ms linear infinite;
}

button:not(.btn) > .btn-spinner {
  margin-right: 6px;
}

@keyframes btnSpin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-spinner {
    animation-duration: 1.6s;
  }
}

.btn-icon-only {
  width: 36px;
  height: 36px;
  padding: 0 !important;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* User Auth Profile Dropdown */
.auth-menu-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.auth-avatar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-main);
  padding: 3px 7px 3px 3px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 180ms ease;
  color: var(--text-muted);
}

.auth-avatar-btn:hover,
.auth-avatar-btn[aria-expanded="true"] {
  background: var(--border-subtle);
  border-color: var(--accent-primary);
  color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.auth-avatar-circle {
  width: 30px;
  height: 30px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
}

.auth-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-avatar-chevron {
  transition: transform 180ms ease;
}

.auth-avatar-btn[aria-expanded="true"] .auth-avatar-chevron {
  transform: rotate(180deg);
}

.auth-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  padding: 6px;
  display: none;
  flex-direction: column;
  z-index: 1000;
  animation: authMenuFadeIn 150ms cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-dropdown-menu.open {
  display: flex;
}

@keyframes authMenuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-dropdown-header {
  padding: 8px 10px 10px;
  line-height: 1.3;
}

.auth-dropdown-name {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-dropdown-email {
  color: var(--text-muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.auth-dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 2px 0 6px;
}

.auth-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 140ms ease;
  text-decoration: none;
}

.auth-dropdown-item:hover {
  background: var(--border-subtle);
  color: var(--text-primary);
}

.auth-dropdown-item.auth-dropdown-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.auth-mobile-profile {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.auth-mobile-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
  border-radius: 10px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-easy {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-medium {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-hard {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-topic {
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-main);
}

/* ==========================================================================
   Route View Transitions
   ========================================================================== */

#app-root {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.route-view {
  animation: routeFadeIn 200ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes routeFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Landing Page: Hero Section
   ========================================================================== */

.hero-section {
  position: relative;
  padding: 64px 24px 80px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}


.hero-blob-bg {
  position: absolute;
  top: 10%;
  left: 25%;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.12) 0%, rgba(139, 92, 246, 0.05) 50%, transparent 70%);
  filter: blur(50px);
  pointer-events: none;
  z-index: 0;
}

.hero-grid-pattern {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--border-subtle) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.35;
  mask-image: radial-gradient(ellipse 60% 60% at 50% 40%, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 40%, black 30%, transparent 80%);
  pointer-events: none;
  z-index: 0;
}

.hero-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 0.92fr 1.32fr;
  gap: 44px;
  align-items: center;
}

@media (max-width: 1100px) {
  .hero-layout {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .mini-demo-card {
    max-width: 780px;
    margin: 0 auto;
  }
}

.hero-title {
  font-size: clamp(32px, 4.5vw, 54px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
  color: var(--text-primary);
  text-wrap: balance;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent-primary) 0%, #8b5cf6 50%, #ec4899 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 540px;
}

.trust-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* Hero Mini-Demo Live Visualizer */
.mini-demo-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  position: relative;
  width: 80%;
  justify-self: end;
}

/* Stacked hero layout: the demo takes the full row again (capped by max-width above) */
@media (max-width: 1100px) {
  .mini-demo-card {
    width: 100%;
    justify-self: center;
  }
}

.mini-demo-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-main);
  background: var(--bg-surface-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mini-editor-box {
  padding: 14px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-main);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-primary);
  min-height: 48px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow-x: auto;
}

#mini-typed-query {
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.typing-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--accent-primary);
  margin-left: 2px;
  animation: cursorBlink 800ms infinite;
}

@keyframes cursorBlink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

.mini-pipeline-chips {
  padding: 10px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-main);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
}

.mini-chip {
  padding: 4px 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  border-radius: 5px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-main);
  transition: all 250ms ease;
  white-space: nowrap;
}

.mini-chip.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px var(--accent-glow);
}

.mini-table-scroll {
  max-height: 260px;
  overflow: hidden;
  padding: 8px 18px 14px;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.mini-table th {
  padding: 6px 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--border-main);
}

.mini-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-main);
  color: var(--text-primary);
  transition: all 300ms ease;
}

.mini-row {
  transition: all 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

.mini-row.dimmed-out {
  opacity: 0.2;
  text-decoration: line-through;
  background: var(--danger-bg);
}

.mini-row.collapsed {
  display: none;
}

.mini-row.matched {
  background: var(--success-bg);
}

.mini-row.below-limit {
  opacity: 0.2;
  filter: grayscale(1);
}

.mini-cutoff-row {
  border-top: 2px dashed #ef4444;
  color: #ef4444;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}

/* ==========================================================================
   Marquee & Stats Strip
   ========================================================================== */

.marquee-section {
  border-top: 1px solid var(--border-main);
  border-bottom: 1px solid var(--border-main);
  background: var(--bg-surface);
  padding: 24px 0;
  overflow: hidden;
}

.marquee-inner {
  display: flex;
  width: max-content;
  animation: marqueeScroll 32s linear infinite;
}

.marquee-inner:hover {
  animation-play-state: paused;
}

@keyframes marqueeScroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-50%);
  }
}

.marquee-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  margin: 0 8px;
  border-radius: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-main);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  max-width: 1200px;
  margin: 48px auto 0;
  padding: 0 24px;
  text-align: center;
}

@media (max-width: 768px) {
  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
}

.stat-item-number {
  font-size: clamp(28px, 3.5vw, 44px);
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-sans);
  letter-spacing: -0.02em;
}

.stat-item-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   Bento Features Grid
   ========================================================================== */

.features-section {
  padding: 96px 24px;
  max-width: 1280px;
  margin: 0 auto;
}

.section-kicker {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  margin-bottom: 8px;
}

.section-title {
  font-size: clamp(26px, 3.2vw, 40px);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 600px;
  margin-bottom: 48px;
}

.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
}

.bento-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 16px;
  padding: 24px;
  transition: all 240ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.bento-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-primary);
  box-shadow: 0 12px 28px -6px var(--card-glow);
}

.bento-card.col-span-4 {
  grid-column: span 4;
}

.bento-card.col-span-6 {
  grid-column: span 6;
}

.bento-card.col-span-8 {
  grid-column: span 8;
}

.bento-card.col-span-12 {
  grid-column: span 12;
}

@media (max-width: 900px) {

  .bento-card.col-span-4,
  .bento-card.col-span-6,
  .bento-card.col-span-8 {
    grid-column: span 12;
  }
}

.bento-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-main);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  margin-bottom: 16px;
}

.bento-card-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.bento-card-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
  flex: 1;
}

.bento-micro-widget {
  background: var(--bg-subtle);
  border: 1px solid var(--border-main);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12px;
  margin-top: auto;
}

/* ==========================================================================
   How It Works (3 Steps)
   ========================================================================== */

.how-it-works-section {
  padding: 80px 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-main);
  border-bottom: 1px solid var(--border-main);
}

.steps-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  max-width: 1200px;
  margin: 40px auto 0;
  position: relative;
}

@media (max-width: 768px) {
  .steps-row {
    grid-template-columns: 1fr;
    gap: 40px;
  }
}

.step-card {
  position: relative;
  padding: 24px;
  border-radius: 14px;
  background: var(--bg-page);
  border: 1px solid var(--border-main);
}

.step-num-pill {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 16px;
}

/* ==========================================================================
   Top Asked SQL Questions Section
   ========================================================================== */

.questions-section {
  padding: 96px 24px;
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
}

.filter-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filter-primary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 38px;
  border-radius: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.company-chips-scroll {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.company-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-main);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 150ms ease;
}

.company-filter-chip:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.company-filter-chip.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

@media (max-width: 1100px) {
  .question-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 680px) {
  .question-grid {
    grid-template-columns: 1fr;
  }
}

.question-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 14px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: all 220ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.question-card-skeleton {
  min-height: 190px;
  gap: 14px;
  pointer-events: none;
}

.skeleton-line {
  display: block;
  width: 78%;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--bg-surface-elevated) 25%, var(--border-main) 50%, var(--bg-surface-elevated) 75%);
  background-size: 200% 100%;
  animation: question-skeleton-shimmer 1.4s ease-in-out infinite;
}

.skeleton-line.skeleton-badge {
  width: 64px;
  height: 20px;
}

.skeleton-line.skeleton-title {
  width: 62%;
  height: 18px;
}

.skeleton-line.skeleton-summary {
  width: 92%;
  height: 12px;
}

.skeleton-line.skeleton-tags {
  width: 42%;
  margin-top: auto;
}

.route-question-skeleton {
  width: min(1120px, calc(100% - 48px));
  margin: 80px auto;
}

.question-load-error {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 28px;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

@keyframes question-skeleton-shimmer {
  to {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-line {
    animation: none;
  }
}

.question-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: 0 10px 24px -4px var(--card-glow);
}

.question-card.featured-card {
  grid-column: span 3;
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-surface-elevated) 100%);
  border-color: rgba(59, 130, 246, 0.3);
}

@media (max-width: 1100px) {
  .question-card.featured-card {
    grid-column: span 2;
  }
}

@media (max-width: 680px) {
  .question-card.featured-card {
    grid-column: span 1;
  }
}

/* Company Accordion View */
.company-accordion {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.company-accordion-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 12px;
  overflow: hidden;
}

.company-accordion-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  background: var(--bg-surface);
  transition: background-color 150ms ease;
}

.company-accordion-header:hover {
  background: var(--bg-surface-elevated);
}

.company-accordion-body {
  display: none;
  padding: 16px 20px;
  border-top: 1px solid var(--border-main);
  background: var(--bg-subtle);
}

.company-accordion-item.open .company-accordion-body {
  display: block;
}

/* ==========================================================================
   Topics Roadmap Section
   ========================================================================== */

.roadmap-section {
  padding: 80px 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-main);
  border-bottom: 1px solid var(--border-main);
}

/* Study plan cards: home page roadmap and /study-plans */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  max-width: 1180px;
  margin: 40px auto 0;
}

.plan-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 22px 20px;
  background: var(--bg-page);
  border: 1px solid var(--border-main);
  border-radius: 14px;
  color: inherit;
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.plan-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: 0 10px 24px -8px var(--card-glow);
}

.plan-card:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.plan-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-glow);
  color: var(--accent-primary);
  font-size: 13px;
  font-weight: 800;
}

.plan-card-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 4px 0 0;
}

.plan-card-desc {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
}

.plan-card-meta {
  margin-top: auto;
  padding-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.plan-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.plan-progress[hidden] {
  display: none;
}

.plan-progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-surface-elevated);
  overflow: hidden;
}

.plan-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
  transition: width 400ms ease;
}

.plan-progress-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Question of the day */
.daily-section {
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px 24px 0;
}

.daily-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-left: 4px solid var(--accent-primary);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.daily-card.is-solved {
  border-left-color: var(--success);
}

.daily-card-main {
  min-width: 0;
}

.daily-kicker {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 6px;
}

.daily-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  margin: 0;
}

.daily-kicker time {
  font-size: 12px;
  color: var(--text-muted);
}

.daily-title {
  font-size: clamp(19px, 2.2vw, 24px);
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 0 0 6px;
}

.daily-title a {
  color: var(--text-primary);
  text-decoration: none;
}

.daily-title a:hover {
  color: var(--accent-primary);
}

.daily-summary {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0 0 12px;
  max-width: 720px;
}

.daily-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.daily-card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: none;
}

.daily-status {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.daily-card.is-solved .daily-status {
  color: var(--success);
}

@media (max-width: 720px) {
  .daily-section {
    padding: 32px 16px 0;
  }

  .daily-card {
    flex-direction: column;
    align-items: stretch;
    padding: 20px;
  }

  .daily-card-side {
    align-items: stretch;
    text-align: center;
  }
}

/* /study-plans pages */
.plan-page {
  /* #app-root is a flex column: without a fixed width, wide tables or code would stretch the page */
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 96px;
}

.plan-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
  font-size: 13px;
  color: var(--text-muted);
}

.plan-breadcrumb li + li::before {
  content: '/';
  margin-right: 6px;
}

.plan-breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}

.plan-breadcrumb a:hover {
  color: var(--accent-primary);
}

.plan-header {
  max-width: 760px;
  margin-bottom: 32px;
}

.plan-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 14px;
  color: var(--text-primary);
}

.plan-intro {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.plan-facts {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.plan-header .plan-progress {
  max-width: 420px;
}

.plan-skills {
  margin-bottom: 36px;
  padding: 20px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 14px;
  max-width: 760px;
}

.plan-skills h2,
.plan-list-heading {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 12px;
  color: var(--text-primary);
}

.plan-skills ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 20px;
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  color: var(--text-secondary);
}

.plan-skills a {
  color: var(--accent-primary);
  font-weight: 600;
  text-decoration: none;
}

.plan-skills a:hover {
  text-decoration: underline;
}

.plan-question-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan-question {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 12px;
}

.plan-question-num {
  flex: none;
  width: 28px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  text-align: center;
}

.plan-question-body {
  flex: 1;
  min-width: 0;
}

.plan-question-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.plan-question-title a {
  color: var(--text-primary);
  text-decoration: none;
}

.plan-question-title a::after {
  content: '';
  position: absolute;
  inset: 0;
}

.plan-question {
  position: relative;
}

.plan-question:hover {
  border-color: var(--accent-primary);
}

.plan-question-summary {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.plan-question-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.plan-question-solved {
  display: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--success);
}

.plan-question.is-solved .plan-question-solved {
  display: inline;
}

.plan-question.is-solved .plan-question-num {
  color: var(--success);
}

.plan-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 40px;
  font-size: 14px;
  font-weight: 600;
}

.plan-pager a {
  color: var(--accent-primary);
  text-decoration: none;
}

/* /learn concept lessons */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.concept-page article {
  max-width: 820px;
}

.concept-section {
  margin: 0 0 40px;
}

.concept-section h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
  color: var(--text-primary);
}

.concept-section h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text-primary);
}

.concept-section p,
.concept-mistakes li,
.concept-faq dd {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.concept-section p {
  margin: 0 0 12px;
}

.concept-section code,
.plan-skills code,
.plan-intro code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.concept-data-table {
  margin-bottom: 18px;
}

.concept-example {
  padding: 20px 22px;
  margin-bottom: 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 14px;
}

pre.concept-code {
  margin: 10px 0 12px;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--bg-page);
  border: 1px solid var(--border-main);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
}

pre.concept-code code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.concept-result-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.concept-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-main);
  border-radius: 10px;
  margin-bottom: 12px;
}

.concept-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.concept-table th {
  text-align: left;
  padding: 7px 12px;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-weight: 700;
  border-bottom: 1px solid var(--border-main);
  white-space: nowrap;
}

.concept-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-subtle, var(--border-main));
  color: var(--text-primary);
  white-space: nowrap;
}

.concept-table tbody tr:last-child td {
  border-bottom: none;
}

.concept-null {
  color: var(--text-muted) !important;
  font-style: italic;
}

.concept-runner {
  margin-top: 12px;
}

.concept-runner[hidden] {
  display: none;
}

.concept-editor {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  border: 1px solid var(--border-main);
  border-radius: 10px;
  resize: vertical;
}

.concept-editor:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
}

.concept-runner-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.concept-run-note {
  font-size: 12px !important;
  color: var(--text-muted) !important;
  margin: 0 !important;
}

.concept-run-error {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
}

.concept-run-error p {
  margin: 4px 0 0;
  color: var(--text-primary);
  font-size: 13px;
}

.concept-mistakes {
  margin: 0;
  padding-left: 20px;
}

.concept-mistakes li {
  margin-bottom: 8px;
}

.concept-mistakes strong,
.concept-faq dt {
  color: var(--text-primary);
}

.concept-faq {
  margin: 0;
}

.concept-faq > div {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-main);
}

.concept-faq dt {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}

.concept-faq dd {
  margin: 0;
}

.concept-related {
  margin: 0;
  padding-left: 20px;
  line-height: 2;
}

.concept-related a,
.concept-plan-link a {
  color: var(--accent-primary);
  font-weight: 600;
  text-decoration: none;
}

.concept-related a:hover,
.concept-plan-link a:hover {
  text-decoration: underline;
}

.concept-plan-link {
  margin-top: 14px;
}

@media (max-width: 640px) {
  .concept-example {
    padding: 16px;
  }
}

@media (max-width: 640px) {
  .plan-page {
    padding: 24px 16px 72px;
  }

  .plan-question {
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px;
  }

  .plan-question-meta {
    margin-left: 44px;
  }

  .plan-pager {
    flex-wrap: wrap;
  }
}

/* ==========================================================================
   FAQ Section
   ========================================================================== */

.faq-section {
  padding: 96px 24px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.faq-item {
  border: 1px solid var(--border-main);
  border-radius: 12px;
  background: var(--bg-surface);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}

.faq-answer {
  display: none;
  padding: 0 22px 18px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.faq-item.open .faq-answer {
  display: block;
}

/* ==========================================================================
   Final CTA Banner
   ========================================================================== */

.cta-section {
  padding: 80px 24px 100px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.cta-banner {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12) 0%, rgba(139, 92, 246, 0.12) 100%);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 20px;
  padding: 56px 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--border-main);
  background: var(--bg-surface);
  padding: 56px 24px 32px;
  margin-top: auto;
}

.footer-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
}

@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

.footer-col h4 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.footer-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-col a {
  font-size: 13.5px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 150ms ease;
}

.footer-col a:hover {
  color: var(--text-primary);
}

.footer-bottom {
  max-width: 1200px;
  margin: 40px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 12px;
}

/* ==========================================================================
   Playground Layout Styles
   ========================================================================== */

.playground-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: calc(100vh - 64px);
}

.playground-subnav {
  height: 48px;
  border-bottom: 1px solid var(--border-main);
  background: var(--bg-surface);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12.5px;
  flex-wrap: wrap;
}

.playground-grid {
  --default-left-pane-width: clamp(420px, 40vw, 820px);
  --left-pane-width: var(--default-left-pane-width);
  display: grid;
  grid-template-columns: minmax(360px, var(--left-pane-width)) 12px minmax(0, 1fr);
  flex: 1;
  min-height: calc(100vh - 112px);
}

@media (min-width: 1024px) {
  .playground-shell {
    height: calc(100vh - 64px);
    max-height: calc(100vh - 64px);
    overflow: hidden;
  }

  .playground-grid {
    height: calc(100vh - 112px);
    max-height: calc(100vh - 112px);
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }
}

@media (max-width: 1279px) and (min-width: 1024px) {
  .playground-grid {
    --default-left-pane-width: max(380px, 36vw);
  }
}

@media (max-width: 1023px) {
  .playground-grid {
    display: flex;
    flex-direction: column;
  }
}

.playground-splitter {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 10;
}

.playground-splitter::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5px;
  width: 2px;
  background: var(--border-main);
  transition: background-color 150ms ease, width 150ms ease;
}

.playground-splitter-grip {
  position: relative;
  z-index: 1;
  width: 6px;
  height: 28px;
  border-radius: 3px;
  background: var(--border-subtle);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, background-color 150ms ease;
}

.playground-splitter-grip::after {
  content: '';
  display: block;
  width: 2px;
  height: 14px;
  margin: 7px auto;
  border-left: 1px solid var(--text-muted);
  border-right: 1px solid var(--text-muted);
}

.playground-splitter:hover::before,
.playground-splitter:focus-visible::before,
.playground-splitter.is-dragging::before {
  left: 4.5px;
  width: 3px;
  background: var(--accent-primary);
}

.playground-splitter:hover .playground-splitter-grip,
.playground-splitter:focus-visible .playground-splitter-grip,
.playground-splitter.is-dragging .playground-splitter-grip {
  opacity: 1;
  background: var(--bg-surface-elevated);
  box-shadow: 0 0 0 1px var(--accent-primary), 0 2px 6px rgba(0, 0, 0, 0.15);
}

.playground-splitter:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

body.is-resizing-panes {
  cursor: col-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

body.is-resizing-panes * {
  user-select: none !important;
  -webkit-user-select: none !important;
}

body.is-resizing-panes iframe,
body.is-resizing-panes .CodeMirror {
  pointer-events: none !important;
}

.playground-left {
  border-right: 1px solid var(--border-main);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.playground-right {
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

@media (min-width: 1024px) {
  #pg-editor-section {
    flex: 1;
    min-height: 0;
  }

  .pg-sql-editor-wrap {
    flex: 1;
    min-height: 180px;
  }

  #pg-editor-section .CodeMirror {
    flex: 1;
    height: 100% !important;
    min-height: 180px;
    max-height: none;
  }

  #pg-editor-section .CodeMirror-scroll {
    min-height: 0;
    max-height: none;
  }
}

@media (max-width: 1023px) {
  .playground-splitter {
    display: none;
  }

  .playground-grid {
    min-height: 0;
  }

  .playground-left {
    max-height: 85vh;
  }
}

/* Card components in playground */
.panel-section {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-main);
}

/* Question Workspace Tabs: Question, Solution, Discussion, Submissions */
.pg-tab-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 18px 0 18px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-main);
  position: sticky;
  top: 0;
  z-index: 10;
  user-select: none;
  overflow-x: auto;
}

.pg-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  position: relative;
  bottom: -1px;
  white-space: nowrap;
}

.pg-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.pg-tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  border-color: var(--border-main);
  border-bottom-color: var(--bg-surface);
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.02);
}

.pg-tab-btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

.pg-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-main);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.pg-tab-panes {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pg-tab-pane {
  display: none;
}

.pg-tab-pane.active {
  display: block;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

#pg-pane-discussion {
  overflow-y: auto;
  overflow-x: hidden;
}

.pg-code-preview {
  background: var(--bg-subtle);
  border: 1px solid var(--border-main);
  border-radius: 8px;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-x: auto;
}

.pg-submissions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pg-submissions-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-main);
}

.pg-submissions-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-main);
  vertical-align: middle;
}

/* Community Discussions & Q&A */
.pg-discussion-composer {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-main);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

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

.pg-composer-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pg-avatar-mini {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pg-composer-username {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.pg-composer-username strong {
  color: var(--text-primary);
}

.pg-btn-pill-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pg-btn-pill-action:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.08);
}

.pg-comment-textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  color: var(--text-primary);
  resize: vertical;
  min-height: 72px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pg-comment-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.pg-composer-code-box {
  margin-top: 10px;
  margin-bottom: 8px;
}

.pg-composer-code-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.pg-composer-code-label .pg-text-hint {
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  color: var(--text-muted);
}

.pg-code-textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-main);
  background: var(--bg-subtle);
  color: var(--text-primary);
  resize: vertical;
  min-height: 84px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pg-code-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.pg-composer-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 10px;
}

.pg-post-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  padding: 6px 18px;
  border-radius: 7px;
}

.pg-discussion-guest-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(99, 102, 241, 0.05) 100%);
  border: 1px dashed var(--border-main);
  border-radius: 12px;
  padding: 22px 18px;
  text-align: center;
  margin-bottom: 22px;
}

.pg-guest-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin: 0 auto 10px;
}

.pg-guest-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.pg-guest-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  max-width: 440px;
  margin: 0 auto 14px;
  line-height: 1.5;
}

.pg-signin-cta {
  font-weight: 600;
  gap: 7px;
  display: inline-flex;
  align-items: center;
  padding: 7px 18px;
  border-radius: 7px;
}

.pg-discussion-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.pg-discussion-card:hover {
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
}

.pg-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pg-card-author-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pg-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.pg-author-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.pg-author-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 6px;
}

.pg-card-content {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 6px 0 10px;
}

.pg-inline-code {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-primary);
  word-break: break-word;
}

.pg-comment-code-card {
  margin: 12px 0;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-main);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.pg-comment-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-main);
}

.pg-comment-code-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pg-load-comment-sql-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pg-load-comment-sql-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.08);
  transform: translateY(-1px);
}

.pg-comment-code-body {
  margin: 0;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-surface);
  white-space: pre-wrap;
  overflow-x: auto;
}

.pg-card-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-main);
  font-size: 12px;
  color: var(--text-muted);
}

.pg-upvote-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-main);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.pg-upvote-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.08);
  transform: translateY(-1px);
}

.pg-upvote-btn.upvoted {
  background: rgba(59, 130, 246, 0.14);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.pg-replies-pill,
.pg-replies-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 10px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.pg-replies-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
  border-color: var(--border-main);
}

.pg-replies-chevron {
  transition: transform 0.2s ease;
  opacity: 0.7;
}

.pg-replies-chevron.open {
  transform: rotate(180deg);
  opacity: 1;
}

.pg-reply-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 10px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: auto;
  font-family: inherit;
}

.pg-reply-trigger-btn:hover {
  color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.2);
}

/* Replies Section & Nested Tree */
.pg-replies-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding-left: 14px;
  border-left: 2px solid var(--border-main);
  animation: pgFadeIn 0.2s ease-out;
}

.pg-replies-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pg-reply-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pg-reply-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pg-reply-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pg-reply-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.pg-reply-author {
  font-weight: 600;
  color: var(--text-primary);
}

.pg-reply-time {
  color: var(--text-muted);
  font-size: 11px;
}

.pg-reply-content {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.pg-reply-code-card {
  margin-top: 6px;
  font-size: 11px;
}

.pg-reply-code-card .pg-comment-code-body {
  max-height: 180px;
  font-size: 11px;
}

/* Inline Reply Composer */
.pg-reply-composer {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-main);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 4px;
}

.pg-reply-composer-inner {
  display: flex;
  gap: 10px;
}

.pg-reply-avatar-mini {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.pg-reply-composer-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pg-reply-textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-primary);
  resize: vertical;
  min-height: 52px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pg-reply-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.pg-reply-code-toggle-wrap {
  margin-top: 2px;
}

.pg-reply-code-input {
  font-size: 11.5px;
  min-height: 60px;
}

.pg-reply-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pg-reply-actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pg-reply-guest-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-surface-elevated);
  border: 1px dashed var(--border-main);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

@keyframes pgFadeIn {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pipeline Stepper */
.pipeline-bar {
  position: relative;
  z-index: 10;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-main);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.pipeline-steps {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pipeline-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-main);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  position: relative;
}

.pipeline-chip.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.pipeline-chip.current-scrub {
  box-shadow: 0 0 0 2px var(--accent-primary);
  border-color: var(--accent-primary);
}

.pipeline-chip.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pipeline-chip:not(.disabled):hover {
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.step-arrow {
  color: var(--text-muted);
  font-size: 11px;
}

/* Tooltip */
[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover {
  z-index: 30;
}

[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 5px 6px 5px;
  border-style: solid;
  border-color: transparent transparent #0f172a transparent;
  pointer-events: none;
  z-index: 51;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 6px;
  background: #0f172a;
  color: #f8fafc;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  z-index: 50;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Visualizer Table Area */
.visualizer-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.table-stage-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  position: relative;
  display: flex;
  flex-direction: column;
}

.table-header-meta {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-main);
  gap: 12px;
  flex-wrap: wrap;
}

.table-scroll-wrapper {
  overflow: auto;
  position: relative;
  max-height: 520px;
}

.sql-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: left;
}

.sql-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--bg-surface-elevated);
}

.sql-table thead tr {
  background-color: var(--bg-surface-elevated);
}

.sql-table th {
  background-color: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-main);
  font-family: var(--font-mono);
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--border-main);
  transition: all 250ms ease;
}

.sql-table th.col-selected {
  color: var(--accent-primary);
  background: linear-gradient(rgba(59, 130, 246, 0.14), rgba(59, 130, 246, 0.14)), var(--bg-surface-elevated);
}

.sql-table th.col-unselected {
  opacity: 0.35;
  background-color: var(--bg-surface-elevated);
}

.sql-table th.col-sorted {
  color: #8b5cf6;
  background: linear-gradient(rgba(139, 92, 246, 0.14), rgba(139, 92, 246, 0.14)), var(--bg-surface-elevated);
}

.sql-table td {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-main);
  font-family: var(--font-sans);
  color: var(--text-primary);
  white-space: nowrap;
  transition: all 250ms ease;
}

.sql-table tr {
  transition: background-color 200ms ease;
}

.sql-table tr:hover td {
  background-color: var(--bg-surface-elevated);
}

/* FLIP & Animation Specific Classes */
.row-item {
  will-change: transform, opacity;
}

/* Staggered Row Fade-in on FROM */
@keyframes rowEnterStagger {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.row-enter-stagger {
  animation: rowEnterStagger 300ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* WHERE Stage Styles: red-tint, strikethrough, smooth collapse */
.row-dimmed-out {
  opacity: 0.28;
  text-decoration: line-through;
  background-color: var(--danger-bg) !important;
  transition: all 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.row-collapsed {
  max-height: 0 !important;
  opacity: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
  border: none !important;
  overflow: hidden !important;
  transform: scaleY(0);
  transform-origin: top;
  display: none !important;
  transition: all 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.row-matched-glow {
  background-color: var(--success-bg) !important;
}

/* Condition cell underline */
.cell-condition-highlight {
  position: relative;
  border-bottom: 2px solid var(--warning) !important;
  font-weight: 600;
  background-color: var(--warning-bg) !important;
}

/* LIMIT Cutoff Line */
.limit-cutoff-marker {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.02) 100%);
  border-top: 2px dashed #ef4444 !important;
}

.limit-cutoff-marker td {
  padding: 9px 18px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  color: #ef4444 !important;
  letter-spacing: 0.02em;
  font-family: var(--font-mono) !important;
}

.row-below-limit {
  opacity: 0.25;
  filter: grayscale(0.8);
}

/* Computed Column Badge */
.computed-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
  margin-left: 5px;
  vertical-align: middle;
}

/* Status Bar */
.status-bar {
  border-top: 1px solid var(--border-main);
  background: var(--bg-surface);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 12px;
  width: 90%;
  max-width: 580px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  padding: 24px;
  transform: scale(0.95);
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Wrong-answer rows that open the visualizer */
.diff-row-link {
  cursor: pointer;
}

.diff-row-link:hover td,
.diff-row-link:focus-visible td {
  box-shadow: inset 0 1px 0 var(--accent-primary), inset 0 -1px 0 var(--accent-primary);
}

.diff-row-link:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

.diff-focus-hint {
  margin: -2px 0 6px;
}

.visualizer-focus-note {
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent-primary);
  background: var(--accent-glow);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
}

.sql-table tr.row-diff-focus td {
  background: var(--danger-bg) !important;
  box-shadow: inset 0 2px 0 var(--danger), inset 0 -2px 0 var(--danger);
}

/* "Learn the concept" links on question pages */
.pg-learn-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.pg-learn-links svg {
  flex: none;
  color: var(--accent-primary);
}

.pg-learn-link {
  color: var(--accent-primary);
  font-weight: 600;
  text-decoration: none;
}

.pg-learn-link:hover {
  text-decoration: underline;
}

.pg-learn-stuck {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border-main);
  font-size: 13px;
  color: var(--text-secondary);
}

.modal-card.modal-card-wide {
  max-width: 860px;
}

/* "Explain my error" details in the wrong-answer dialog */
.diff-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 12px;
}

.diff-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.diff-chip.match {
  color: var(--success);
  background: var(--success-bg);
}

.diff-chip.wrong {
  color: var(--danger);
  background: var(--danger-bg);
}

.diff-chip.misplaced,
.diff-chip.missing {
  color: var(--warning);
  background: var(--warning-bg);
}

.diff-note {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 8px 0 12px;
}

.diff-muted {
  font-size: 12px;
  color: var(--text-muted);
  margin: 6px 0;
}

.diff-table-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 14px 0 6px;
}

.diff-table-wrap {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border-main);
  border-radius: 8px;
}

.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
}

.diff-table th {
  position: sticky;
  top: 0;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-weight: 700;
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-main);
  white-space: nowrap;
}

.diff-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle, var(--border-main));
  color: var(--text-primary);
  vertical-align: top;
  white-space: nowrap;
}

.diff-row-status {
  width: 18px;
  font-weight: 800;
  text-align: center;
}

.diff-row-num {
  width: 28px;
  color: var(--text-muted);
}

.diff-row.match .diff-row-status {
  color: var(--success);
}

.diff-row.wrong {
  background: var(--danger-bg);
}

.diff-row.wrong .diff-row-status {
  color: var(--danger);
}

.diff-row.misplaced {
  background: var(--warning-bg);
}

.diff-row.misplaced .diff-row-status {
  color: var(--warning);
}

.diff-cell-bad {
  box-shadow: inset 0 0 0 2px var(--danger);
  border-radius: 4px;
}

.diff-kind {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--danger);
  background: var(--danger-bg);
}

.diff-expected {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--success);
}

.diff-null {
  color: var(--text-muted);
  font-style: italic;
}

.diff-table.missing td {
  background: var(--warning-bg);
}

.diff-kind-notes {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.diff-columns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.diff-columns > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.diff-columns-label {
  width: 70px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.diff-col-chip {
  padding: 2px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid var(--border-main);
}

.diff-col-chip.ok {
  color: var(--success);
  background: var(--success-bg);
}

.diff-col-chip.bad {
  color: var(--danger);
  background: var(--danger-bg);
}

.modal-backdrop.open .modal-card {
  transform: scale(1);
}

/* CodeMirror overrides */
.CodeMirror {
  height: auto;
  min-height: 136px;
  max-height: 310px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-main);
  border-radius: 8px;
  padding: 4px 0;
}

.CodeMirror-scroll {
  min-height: 136px;
  max-height: 310px;
  overflow-y: auto !important;
  overflow-x: auto !important;
}

.CodeMirror-gutters {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-main);
}

.CodeMirror-linenumber {
  color: var(--text-muted);
  font-size: 12px;
}

.CodeMirror-cursor {
  border-left: 2px solid var(--accent-primary);
}

.CodeMirror-focused {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

/* Syntax Highlighting */
html.dark .cm-keyword {
  color: #f43f5e;
  font-weight: 600;
}

html.dark .cm-string {
  color: #34d399;
}

html.dark .cm-number {
  color: #fbbf24;
}

html.dark .cm-comment {
  color: #64748b;
  font-style: italic;
}

html.dark .cm-operator {
  color: #38bdf8;
}

html.dark .cm-variable {
  color: #e2e8f0;
}

html:not(.dark) .cm-keyword {
  color: #e11d48;
  font-weight: 600;
}

html:not(.dark) .cm-string {
  color: #059669;
}

html:not(.dark) .cm-number {
  color: #d97706;
}

html:not(.dark) .cm-comment {
  color: #94a3b8;
  font-style: italic;
}

html:not(.dark) .cm-operator {
  color: #0284c7;
}

html:not(.dark) .cm-variable {
  color: #1e293b;
}

.cm-keyword {
  cursor: pointer;
  border-radius: 3px;
  transition: background-color 150ms ease;
}

.cm-keyword:hover {
  background: rgba(255, 255, 255, 0.14);
  text-decoration: underline;
}

/* Coming Soon & 404 Pages */
.state-page-card {
  max-width: 600px;
  margin: 80px auto;
  padding: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 16px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 18px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-main);
  color: var(--text-primary);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(12px);
  transition: all 220ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* SQL Linting Diagnostics & Squiggles */
.cm-lint-error {
  text-decoration: underline wavy #ef4444 2px !important;
  text-underline-offset: 3px !important;
  background-color: rgba(239, 68, 68, 0.12) !important;
  border-radius: 2px !important;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.cm-lint-error:hover {
  background-color: rgba(239, 68, 68, 0.25) !important;
}

.cm-lint-warning {
  text-decoration: underline wavy #eab308 2px !important;
  text-underline-offset: 3px !important;
  background-color: rgba(234, 179, 8, 0.12) !important;
  border-radius: 2px !important;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.cm-lint-warning:hover {
  background-color: rgba(234, 179, 8, 0.25) !important;
}

.cm-lint-hint {
  text-decoration: underline dotted #94a3b8 1.5px !important;
  text-underline-offset: 3px !important;
  background-color: rgba(148, 163, 184, 0.08) !important;
  border-radius: 2px !important;
  cursor: pointer;
}

.sql-lint-tooltip {
  position: fixed;
  z-index: 10000;
  max-width: 320px;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #ef4444;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(239, 68, 68, 0.2);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms cubic-bezier(0.16, 1, 0.3, 1), transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sql-lint-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.sql-lint-tooltip-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #ef4444;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.sql-lint-tooltip-body {
  color: #e2e8f0;
  line-height: 1.45;
  font-family: var(--font-sans);
}

.sql-lint-tooltip-actions {
  margin-top: 8px;
}

.sql-lint-btn-fix {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(234, 179, 8, 0.18);
  border: 1px solid rgba(234, 179, 8, 0.4);
  color: #fef08a;
  border-radius: 4px;
  cursor: pointer;
  transition: all 120ms ease;
}

.sql-lint-btn-fix:hover {
  background: rgba(234, 179, 8, 0.35);
  border-color: rgba(234, 179, 8, 0.7);
  color: #fff;
}

/* Multi-Table Visualizer Enhancements */
.visualizer-legend-bar {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-main);
  border-radius: 8px;
  padding: 8px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.legend-items {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--text-secondary);
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.kept {
  background: var(--success);
}

.legend-dot.removed {
  background: var(--danger);
}

.legend-dot.group {
  background: #8b5cf6;
}

.legend-dot.null {
  background: var(--text-muted);
}

.cte-tabs-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}

.cte-tab-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid var(--border-main);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cte-tab-btn.active {
  background: rgba(139, 92, 246, 0.15);
  border-color: #8b5cf6;
  color: #8b5cf6;
  font-weight: 600;
}

.table-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
}

@media (max-width: 768px) {
  .table-cards-grid {
    grid-template-columns: 1fr;
  }
}

.table-name-chip,
.name-chip {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 12.5px;
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 1px 7px;
  display: inline-flex;
  align-items: center;
  text-transform: lowercase;
  letter-spacing: normal;
}

#pg-btn-run {
  min-height: 44px;
}

.last-valid-banner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  width: fit-content;
}

.alias-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
}

.join-key-highlight {
  background: rgba(59, 130, 246, 0.12) !important;
  color: var(--accent-primary) !important;
  border-bottom: 2px solid var(--accent-primary) !important;
}

.cell-join-key {
  background: rgba(59, 130, 246, 0.06);
  font-weight: 600;
}

.join-key-badge {
  font-size: 10px;
  margin-left: 4px;
}

.null-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  background: var(--bg-surface-elevated);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.group-band-header {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.group-member-row {
  font-size: 12.5px;
}

.sort-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  background: rgba(139, 92, 246, 0.2);
  color: #8b5cf6;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
}

.row-linked-hover {
  background-color: rgba(59, 130, 246, 0.18) !important;
  box-shadow: inset 3px 0 0 var(--accent-primary);
}

/* JOIN step of the visualizer (js/visualizer/visualizer.js renderJoinStage): source tables side by side,
   the join divider, and the connector-line overlay. Ported from the legacy index.html styles. */
.badge-dropped {
  background: rgba(239, 68, 68, 0.18) !important;
  color: #f87171 !important;
  border: 1px solid rgba(239, 68, 68, 0.35);
  font-size: 10px !important;
  padding: 1px 6px !important;
  border-radius: 4px;
  font-weight: 600;
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
}

.badge-no-match {
  background: rgba(148, 163, 184, 0.18) !important;
  color: #94a3b8 !important;
  border: 1px solid rgba(148, 163, 184, 0.3);
  font-size: 10px !important;
  padding: 1px 6px !important;
  border-radius: 4px;
  font-weight: 500;
  font-style: italic;
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
}

.row-source-linked {
  background-color: rgba(245, 158, 11, 0.22) !important;
  box-shadow: inset 3px 0 0 #f59e0b, 0 0 12px rgba(245, 158, 11, 0.35);
  position: relative;
  z-index: 5;
}

.join-stage-wrapper {
  position: relative;
  width: 100%;
}

.join-source-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
  margin-bottom: 12px;
}

@media (max-width: 768px) {
  .join-source-cards-grid {
    grid-template-columns: 1fr;
  }
}

.join-slide-left {
  animation: slideTogetherLeft 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.join-slide-right {
  animation: slideTogetherRight 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.join-slide-up {
  animation: slideUpJoined 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideTogetherLeft {
  0% {
    transform: translateX(-36px);
    opacity: 0.4;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideTogetherRight {
  0% {
    transform: translateX(36px);
    opacity: 0.4;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideUpJoined {
  0% {
    transform: translateY(20px);
    opacity: 0.4;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.join-merge-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  margin: 10px 0 14px 0;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-main);
  border-radius: 8px;
  position: relative;
}

.join-operator-pill {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(59, 130, 246, 0.16);
  color: var(--accent-primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 3px 10px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.join-counter-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.join-connector-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
  overflow: visible;
}

@media (prefers-reduced-motion: reduce) {
  .join-slide-left,
  .join-slide-right,
  .join-slide-up {
    animation: none !important;
    transform: none !important;
  }
}

.table-stage-card.collapsed .table-scroll-wrapper {
  display: none !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

  *,
  ::after,
  ::before {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Question pane (js/playground-layout.js): status badge, clamped task,
   foldable Expected output and Tables, editor that grows upward, pinned Run bar
   ========================================================================== */

.pg-header-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

/* Long task text shows 4 lines until "Show more" */
.pg-task {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pg-task.is-expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.pg-task-more {
  display: inline-block;
  margin: -8px 0 12px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.pg-task-more[hidden] {
  display: none;
}

/* Foldable sections */
.pg-collapse-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-align: left;
}

.pg-collapse-toggle[aria-expanded="false"] {
  margin-bottom: 0;
}

.pg-collapse-toggle:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.pg-collapse-chevron {
  display: inline-block;
  transition: transform 150ms ease;
}

.pg-collapse-toggle[aria-expanded="false"] .pg-collapse-chevron {
  transform: rotate(-90deg);
}

.pg-collapse-body[hidden] {
  display: none;
}

/* Expected output */
.pg-expected-cols {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.pg-expected-cols code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.pg-expected-note {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.pg-expected-locked {
  font-weight: 600;
  color: var(--text-secondary);
}

.pg-expected-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
  border: 1px solid var(--border-main);
  border-radius: 8px;
}

.pg-expected-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.pg-expected-table th {
  text-align: left;
  padding: 6px 12px;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-main);
}

.pg-expected-table td {
  padding: 5px 12px;
  border-bottom: 1px solid var(--border-subtle, var(--border-main));
  color: var(--text-primary);
}

.pg-expected-table tbody tr:last-child td {
  border-bottom: none;
}

.pg-expected-null {
  color: var(--text-muted) !important;
  font-style: italic;
}

/* Run bar pinned to the bottom of the scrolling question pane */
#pg-pane-question > .editor-action-row {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 10px 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-main);
  box-shadow: 0 -6px 12px -8px rgba(0, 0, 0, 0.25);
}

#pg-pane-question #pg-editor-section {
  border-bottom: none;
}

/* Editor header buttons wrap instead of overflowing */
#pg-editor-section > div:first-child > div:last-child {
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Editor grows upward while you work in it */
.pg-shrink-btn {
  display: none;
  gap: 4px;
}

#pg-pane-question.is-editor-expanded .pg-shrink-btn {
  display: inline-flex;
}

#pg-pane-question #pg-editor-section .CodeMirror {
  transition: height 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* IDs so this beats the desktop "#pg-editor-section .CodeMirror { height: 100% !important }" rule,
   and flex: none so the editor's flex: 1 does not override the height */
#pg-pane-question.is-editor-expanded #pg-editor-section .CodeMirror {
  flex: none !important;
  height: var(--editor-expanded-h, 320px) !important;
  max-height: none;
}

#pg-pane-question.is-editor-expanded #pg-editor-section .CodeMirror-scroll {
  height: 100%;
  max-height: none;
}

@media (max-width: 480px) {
  .pg-shrink-btn span:last-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #pg-pane-question #pg-editor-section .CodeMirror {
    transition: none;
  }
}

/* Execution pipeline "Full view" (js/visualizer/full-view.js): the visualizer panel covers the window */
/* Same height as the Step Through button beside it (stretches to the row), square-ish width */
.full-view-btn {
  align-self: stretch;
  width: 34px;
  padding: 0 !important;
  justify-content: center;
}

.full-view-btn .full-view-icon-collapse,
.full-view-btn[aria-pressed="true"] .full-view-icon-expand {
  display: none;
}

.full-view-btn[aria-pressed="true"] .full-view-icon-collapse {
  display: block;
}

.playground-right.is-full-view {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex !important;
  width: auto;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  overflow: hidden;
  background: var(--bg-page);
}

.playground-right.is-full-view .visualizer-container {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}

body.has-full-view {
  overflow: hidden;
}

/* The page fade-in keeps a transform on .route-view, which would pin the fixed panel to the page
   instead of the window */
body.has-full-view .route-view {
  animation: none;
}

/* ==========================================================================
   SQL Sandbox (/sandbox, js/sandbox.js)
   ========================================================================== */

.sandbox-page {
  width: 100%;
  min-width: 0;
}

.sandbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  flex-wrap: wrap;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border-main);
  background: var(--bg-surface);
}

.sandbox-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.sandbox-tagline {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1279px) {
  .sandbox-tagline {
    display: none;
  }
}

.sandbox-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

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

.sbx-dialect {
  font-family: var(--font-mono);
  font-size: 12px;
}

.sbx-samples {
  position: relative;
}

.sbx-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 220px;
  padding: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 10px;
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.35);
}

.sbx-menu[hidden] {
  display: none;
}

.sbx-menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.sbx-menu button:hover,
.sbx-menu button:focus-visible {
  background: var(--bg-surface-elevated);
}

.sandbox-grid {
  display: grid;
  /* --sbx-left-width is set by dragging the splitter (js/sandbox.js) */
  grid-template-columns: minmax(340px, var(--sbx-left-width, 40%)) 12px minmax(0, 1fr);
  min-height: 560px;
  /* Closes off the workspace above the "How it works" section (the right pane shares its background) */
  border-bottom: 1px solid var(--border-main);
}

@media (min-width: 1024px) {
  /* --sbx-header-h is measured by js/sandbox.js; the fallback fits the one-line header */
  .sandbox-grid {
    height: calc(100vh - 64px - var(--sbx-header-h, 55px));
  }

  .sandbox-grid > section {
    min-height: 0;
  }

  /* Steps on top; a failed query's error is pinned below, each scrolling on its own */
  .sandbox-right {
    overflow: hidden;
  }

  .sandbox-right .visualizer-container {
    flex: 1 1 0;
    min-height: 160px;
    padding: 16px 20px;
    gap: 12px;
  }

  /* A step card shrinks to the visible area and scrolls inside, so its last rows are never
     hidden behind a second scrollbar */
  .sandbox-right .visualizer-container > .table-stage-card {
    flex: 0 1 auto;
    min-height: 0;
  }

  .sandbox-right .visualizer-container > .table-stage-card > .table-scroll-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  /* The editor fills the left column */
  .sandbox-left-scroll {
    display: flex;
    flex-direction: column;
  }

  .sandbox-left-scroll > .sbx-editor-section {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .sbx-editor-section .CodeMirror {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
  }

  .sbx-editor-section .CodeMirror-scroll {
    height: 100%;
    min-height: 0;
    max-height: none;
  }

  /* Each tab panel takes the space under the tab bar and scrolls on its own */
  .sbx-tabpanel {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
  }

  .sbx-table-panel .sbx-table-view {
    flex: 0 1 auto;
    min-height: 0;
    max-height: none;
  }

  .sbx-result {
    flex: 0 1 auto;
    max-height: 46%;
    overflow-y: auto;
    border-top: 1px solid var(--border-main);
    background: var(--bg-surface);
    box-shadow: 0 -6px 12px -8px rgba(0, 0, 0, 0.2);
  }
}

@media (max-width: 1023px) {
  .sandbox-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .sandbox-left {
    max-height: 85vh;
  }
}

.sandbox-left {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-surface);
}

.sandbox-left-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sbx-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.sbx-section-head .sbx-run-status {
  margin-left: auto;
}

.sbx-run-btn {
  gap: 6px;
}

.sbx-section-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.sbx-muted {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.sbx-table-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.sbx-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.sbx-danger {
  color: var(--danger) !important;
}

.sbx-table-wrap {
  overflow: auto;
  max-height: 320px;
  border: 1px solid var(--border-main);
  border-radius: 8px;
}

.sbx-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
}

.sbx-table th {
  position: sticky;
  top: 0;
  text-align: left;
  padding: 6px 10px;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-main);
  white-space: nowrap;
}

.sbx-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border-subtle, var(--border-main));
  color: var(--text-primary);
  white-space: nowrap;
}

.sbx-null {
  color: var(--text-muted) !important;
  font-style: italic;
}

.sbx-editor-section {
  border-bottom: 0;
}

/* Below desktop the editor grows with the query: 8 lines minimum, then scrolls after about 18 lines */
@media (max-width: 1023px) {
  .sbx-editor-section .CodeMirror {
    height: auto;
    max-height: none;
  }

  .sbx-editor-section .CodeMirror-scroll {
    min-height: 176px;
    max-height: 400px;
  }
}

/* Tabs above the right panel: Result, one per table, and + to add a table */
.sbx-tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
  padding: 8px 16px 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-main);
}

/* Touch screens swipe the tabs sideways; no scrollbar strip under them */
@media (max-width: 1023px) {
  .sbx-tabs {
    scrollbar-width: none;
  }

  .sbx-tabs::-webkit-scrollbar {
    display: none;
  }
}

.sbx-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  margin-bottom: -1px;
  background: none;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.sbx-tab code {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.sbx-tab:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
}

.sbx-tab[aria-selected="true"] {
  color: var(--accent-primary);
  background: var(--bg-page);
  border-color: var(--border-main);
}

.sbx-tab:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

.sbx-tab-count {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.sbx-tab-add {
  min-width: 32px;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.sbx-tabpanel[hidden] {
  display: none !important;
}

/* A table tab: name, size and actions, then the data with clickable column headers */
.sbx-table-panel {
  padding: 14px 20px 16px;
  gap: 10px;
}

.sbx-table-view-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sbx-table-view {
  max-height: 70vh;
  overflow: auto;
  border: 1px solid var(--border-main);
  border-radius: 10px;
  background: var(--bg-surface);
}

.sbx-table-view .sbx-table th {
  z-index: 1;
  padding: 0;
}

.sbx-col-insert {
  display: block;
  width: 100%;
  padding: 7px 12px;
  border: 0;
  background: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.sbx-col-insert span {
  margin-left: 4px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
}

.sbx-col-insert:hover,
.sbx-col-insert:focus-visible {
  color: var(--accent-primary);
}

.sbx-table-view .sbx-table td {
  padding: 6px 12px;
}

.sbx-table-view-note {
  margin: 0;
}

/* Pipeline bar: steps + row count on the left, tools on the right */
.sbx-pipeline-main,
.sbx-pipeline-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.sbx-pipeline-tools {
  gap: 8px;
}

.sandbox-right .pipeline-bar {
  padding: 10px 20px;
  row-gap: 8px;
}

/* Narrow pipeline bar: drop the "Pipeline" label so the steps stay on one row */
.sandbox-right .pipeline-bar {
  container-type: inline-size;
}

@container (max-width: 560px) {
  .sbx-pipeline-label {
    display: none;
  }
}

.sbx-rows-badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--success-bg, rgba(16, 185, 129, 0.12));
  color: var(--success);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.sbx-rows-badge[hidden] {
  display: none;
}

.sbx-pipeline-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sbx-visualizer-empty {
  padding: 24px;
}

.sbx-result {
  padding: 0 24px 20px;
}

.sbx-result:focus {
  outline: none;
}

.sbx-result:empty {
  display: none;
}

.sbx-result-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 0;
  background: var(--bg-surface);
}

.sbx-result-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.sbx-error {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
}

.sbx-error p {
  margin: 6px 0 0;
  color: var(--text-primary);
}

.sbx-error pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

/* Add / edit table dialog */
.sbx-dialog-card {
  max-width: 820px;
}

.sbx-dialog-title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
}

.sbx-field {
  display: block;
  margin-bottom: 12px;
}

.sbx-field > span {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.sbx-field input,
.sbx-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border-main);
  border-radius: 8px;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.sbx-field textarea {
  resize: vertical;
  line-height: 1.5;
}

.sbx-field input:focus,
.sbx-field textarea:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
}

.sbx-field input:disabled {
  opacity: 0.6;
}

.sbx-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.sbx-field-head label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.sbx-field textarea.is-dragover {
  outline: 2px dashed var(--accent-primary);
  outline-offset: 2px;
  background: var(--bg-surface-elevated);
}

.sbx-drop-hint {
  margin: 4px 0 0;
}

.sbx-detect {
  font-size: 13px;
}

.sbx-detect code {
  font-family: var(--font-mono);
  font-size: 12px;
}

.sbx-detect-table {
  margin-bottom: 14px;
}

.sbx-detect-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.sbx-detect-cols {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.sbx-type-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 8px;
  border: 1px solid var(--border-main);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.sbx-type-pick select {
  border: 0;
  border-radius: 6px;
  padding: 2px 4px;
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.sbx-preview {
  font-size: 11.5px;
}

.sbx-warnings {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--warning);
}

.sbx-error-inline {
  margin: 0;
  color: var(--danger);
  font-weight: 600;
}

.sbx-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* SEO / help content below the app */
.sandbox-about {
  max-width: 820px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.sandbox-about h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 12px;
  color: var(--text-primary);
}

.sandbox-about ol,
.sandbox-about p {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.sandbox-about ol {
  padding-left: 20px;
  margin: 0 0 14px;
}

.sandbox-about p {
  margin: 0 0 32px;
}

.sandbox-about a {
  color: var(--accent-primary);
  font-weight: 600;
  text-decoration: none;
}

@media (max-width: 640px) {
  .sandbox-header {
    padding: 12px 16px;
  }

  .sandbox-left .panel-section,
  .sandbox-right .pipeline-bar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .sbx-result {
    padding: 0 16px 20px;
  }
}
