/* Copyright (c) 2026 Eleftherios Notas and The XIOM Authors
   SPDX-License-Identifier: MIT OR Apache-2.0 */
/* ================================================================
   XIOM Playground Theme -- v0.49.9
   Design system derived from XIOM landing page mockup.
   Palette: indigo accent, layered dark panels, ambient particles.
   ================================================================ */

:root {
  --void: #08090b;
  --panel: #111217;
  --panel-2: #16181d;
  --panel-3: #1c1e24;
  --border: #25272e;
  --border-soft: #1a1c22;
  --border-hover: #3a3d47;
  --hi: #f2f3f6;
  --mid: #9497a3;
  --low: #5c5f6b;
  --indigo: #5c6bff;
  --indigo-soft: rgba(92,107,255,0.14);
  --indigo-glow: rgba(92,107,255,0.45);
  --green: #34d399;
  --green-soft: rgba(52,211,153,0.12);
  --amber: #f0b445;
  --error: #ff5c7a;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 16px;
  --transition: 200ms ease-out;
}

/* Light mode overrides */
html.light-mode {
  --void: #ffffff;
  --panel: #f6f8fa;
  --panel-2: #eaeef2;
  --panel-3: #dde3e8;
  --border: #d0d7de;
  --border-soft: #d8dee4;
  --border-hover: #b8c0c9;
  --hi: #1f2328;
  --mid: #656d76;
  --low: #8b949e;
  --indigo: #4c5ce6;
  --indigo-soft: rgba(76,92,230,0.10);
  --indigo-glow: rgba(76,92,230,0.25);
  --green: #1a7f37;
  --green-soft: rgba(26,127,55,0.10);
  --amber: #9a6700;
  --error: #cf222e;
}

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

body {
  background: var(--void);
  color: var(--hi);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
}

html { background: var(--void); }

::selection { background: var(--indigo-soft); color: var(--hi); }

/* ================================================================
   LANDING PAGE
   ================================================================ */
.landing-screen {
  /* A constrained height (not min-height) makes this element the scroll
     container. With only min-height it grows to its content and iOS Safari
     clips the excess because body has overflow: hidden, so the page cannot
     be scrolled at all. 100dvh avoids the iOS toolbar clipping. */
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  background: var(--void);
}

/* Ambient stars background */
.landing-screen::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 22%, rgba(255,255,255,0.35), transparent),
    radial-gradient(1px 1px at 78% 15%, rgba(255,255,255,0.25), transparent),
    radial-gradient(1px 1px at 45% 68%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 88% 78%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 25% 85%, rgba(255,255,255,0.22), transparent),
    radial-gradient(1px 1px at 60% 40%, rgba(255,255,255,0.18), transparent);
  opacity: 0.5;
}

html.light-mode .landing-screen::before {
  opacity: 0;
}

html.light-mode .header {
  background: rgba(255,255,255,0.80);
}

html.light-mode .nav-btn:hover {
  background: var(--panel-2);
}

html.light-mode .shortcut-modal {
  background: rgba(255,255,255,0.7);
}

html.light-mode .loading-overlay {
  background: rgba(255,255,255,0.75);
}

html.light-mode .output-content {
  background: #f6f8fa;
}

/* All landing content above stars */
.landing-screen > * { position: relative; z-index: 1; }

.landing-hero {
  text-align: center;
  max-width: 700px;
  margin-bottom: 60px;
  padding-top: 34px;
  animation: fadeInUp 0.8s ease-out;
}

/* ================================================================
   PAGE BANNER
   Copied from xiom-website/style.css ("Page banners"); the wordmark colors
   are intentionally fixed because the artwork is always dark. Keep this in
   sync with the website.
   ================================================================ */
.page-banner {
  position: relative;
  overflow: hidden;
  background: #05080f;
  border-bottom: 1px solid var(--border);
}

.page-banner img {
  display: block;
  width: 100%;
  height: auto;
}

.xiom-banner-text {
  position: absolute;
  left: 7%;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  white-space: nowrap;
}

.xiom-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 0;
}

.xiom-brand {
  font-family: var(--sans);
  font-size: clamp(28px, 2.8vw, 52px);
  font-weight: 300;
  line-height: 1;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #f3f7ff;
  text-shadow:
    0 0 8px rgba(255, 255, 255, 0.08),
    0 0 24px rgba(70, 120, 255, 0.08);
}

.xiom-section {
  margin-top: 13px;
  font-size: clamp(9px, 0.72vw, 14px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: #69b8ff;
  text-shadow:
    0 0 8px rgba(80, 150, 255, 0.3),
    0 0 18px rgba(50, 110, 255, 0.15);
}

.xiom-accent {
  width: 42px;
  height: 2px;
  margin-top: 17px;
  background: linear-gradient(90deg, #66fff1 0%, #4cc8ff 70%, rgba(76, 200, 255, 0) 100%);
  box-shadow:
    0 0 7px rgba(76, 220, 255, 0.55),
    0 0 16px rgba(76, 180, 255, 0.2);
}

/* Full-bleed inside the padded landing scroller. flex-shrink: 0 keeps the
   artwork at its aspect ratio in the fixed-height flex column. */
.landing-screen > .page-banner {
  width: calc(100% + 40px);
  margin: -60px -20px 0;
  flex-shrink: 0;
}

/* Centered hero content inside the banner: headline and primary actions on a
   soft scrim so they stay readable over the artwork. The wordmark keeps the
   left side to itself. */
.banner-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 26px 46px 30px;
  border-radius: 22px;
  background: radial-gradient(ellipse at center,
    rgba(5, 8, 15, 0.72) 0%,
    rgba(5, 8, 15, 0.42) 58%,
    rgba(5, 8, 15, 0) 100%);
  pointer-events: none;
}
.banner-center > * { pointer-events: auto; }
.banner-center .hero-title { margin: 0; }
.banner-center .hero-cta { margin: 18px 0 0; }
.page-banner .btn-primary {
  box-shadow: 0 6px 24px rgba(92, 107, 255, 0.45);
}
.page-banner .btn-secondary {
  background: rgba(243, 247, 255, 0.06);
  border-color: rgba(243, 247, 255, 0.35);
  color: #f3f7ff;
}
.page-banner .btn-secondary:hover {
  background: rgba(105, 184, 255, 0.12);
  border-color: #69b8ff;
  color: #ffffff;
}

.hero-title {
  font-size: 46px;
  margin: 20px 0;
  line-height: 1.1;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.gradient-text {
  background: linear-gradient(120deg, var(--indigo), #9aa4ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--mid);
  max-width: 520px;
  margin: 0 auto 30px;
  line-height: 1.55;
}

.hero-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 4px 0 26px;
}

/* ---- Buttons ---- */
.btn-primary {
  background: var(--indigo);
  color: #fff;
  border: none;
  padding: 13px 26px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.2s ease;
  box-shadow: 0 8px 24px rgba(92,107,255,0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(92,107,255,0.45);
}

.btn-secondary {
  background: var(--panel);
  color: var(--hi);
  border: 1px solid var(--border);
  padding: 13px 26px;
  border-radius: 12px;
  font-size: 14.5px;
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  background: var(--panel-2);
}

/* ---- Continue Learning ---- */
.continue-section {
  margin-top: 24px;
  padding: 16px 24px;
  background: var(--panel);
  border: 1px solid var(--indigo-soft);
  border-radius: var(--radius-lg);
  text-align: center;
  animation: fadeInUp 0.6s ease-out;
  max-width: 500px;
  width: 100%;
}

.continue-prompt {
  font-size: 13px;
  color: var(--mid);
  margin-bottom: 12px;
}

.continue-prompt strong {
  color: var(--hi);
  font-weight: 700;
}

.continue-btn {
  font-size: 13.5px;
  padding: 10px 22px;
}

/* ---- Landing Footer ---- */
.landing-footer {
  margin-top: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--mid);
  animation: fadeInUp 1.4s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.landing-footer a {
  color: var(--indigo);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}
.landing-footer a:hover { color: #9aa4ff; }
.landing-footer-sep { color: var(--border); }
.landing-footer-legal {
  margin-top: 10px;
  font-size: 11.5px;
  flex-wrap: wrap;
  animation: none;
}
.landing-footer-links {
  margin-top: 10px;
  font-size: 11.5px;
  flex-wrap: wrap;
  animation: none;
}

/* Social row copied from xiom-website (.footer-social); color tokens mapped
   to the playground palette. Keep the link order and wording in sync with the
   website (Discord, X, Mastodon, Bluesky, Reddit, Hacker News, LinkedIn,
   Facebook). */
.footer-social {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.footer-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--mid);
  transition: color var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.footer-social a:hover {
  color: var(--hi);
  border-color: var(--indigo);
  box-shadow: 0 0 0 1px rgba(92, 107, 255, 0.25);
}
.footer-social a:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}
.footer-social svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
.stats-source {
  margin-top: 14px;
  text-align: center;
  font-size: 11px;
  color: var(--low);
}
.hero-transparency {
  max-width: 520px;
  margin: 18px auto 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--low);
}
.ai-strip {
  margin-top: 22px;
  text-align: center;
  font-size: 12.5px;
  color: var(--mid);
}
.ai-strip a {
  color: var(--indigo);
  font-weight: 600;
  text-decoration: none;
}
.ai-strip a:hover { text-decoration: underline; }

/* ---- Landing sections ---- */
.landing-section {
  width: 100%;
  max-width: 1100px;
  margin-bottom: 60px;
  animation: fadeInUp 1s ease-out;
}

.landing-section-title {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--hi);
  text-align: center;
  margin-bottom: 8px;
}

.landing-section-sub {
  font-size: 13.5px;
  color: var(--mid);
  text-align: center;
  margin-bottom: 28px;
}

/* ---- Feature Grid ---- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
  width: 100%;
}

.feature-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.feature-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  background: var(--panel-2);
}

.feature-icon {
  font-size: 28px;
  margin-bottom: 12px;
}

.feature-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--hi);
}

.feature-card p {
  font-size: 13px;
  color: var(--mid);
  line-height: 1.5;
}

.feature-card code {
  background: var(--panel-3);
  color: var(--indigo);
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 3px;
}

/* ---- Stats Bar ---- */
.stats-bar {
  display: flex;
  gap: 32px;
  justify-content: center;
  padding: 18px 32px;
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  animation: fadeInUp 1.2s ease-out;
}

.stat {
  font-size: 13px;
  color: var(--mid);
}

.stat strong {
  color: var(--hi);
  font-weight: 700;
}

/* ---- Animations ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.animate-in { animation: fadeIn var(--transition) ease-out; }

/* ================================================================
   HEADER / NAV BAR
   ================================================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(8,9,11,0.72);
  border-bottom: 1px solid var(--border-soft);
  padding: 10px 20px;
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  position: relative;
  z-index: 50;
}

.back-btn {
  background: none;
  border: none;
  color: var(--mid);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--sans);
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease;
}

.back-btn:hover { color: var(--hi); }

.header-site-link {
  font-size: 11.5px;
  color: var(--indigo);
  text-decoration: none;
  font-family: var(--mono);
  font-weight: 600;
  transition: color 0.2s ease;
  padding: 3px 8px;
  border-radius: 4px;
  margin-right: 8px;
  border: 1px solid rgba(92,107,255,0.25);
}
.header-site-link:hover { color: #9aa4ff; background: var(--indigo-soft); }

.lesson-header-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--mid);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.example-select {
  background: var(--panel);
  color: var(--mid);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-family: var(--sans);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.example-select:focus { border-color: var(--indigo); }

.example-select option {
  background: var(--panel);
  color: var(--hi);
}

.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.nav-btn {
  background: transparent;
  color: var(--mid);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  font-weight: 500;
}

.nav-btn:hover {
  color: var(--hi);
  background: var(--panel);
}

/* Desktop-only */
.desktop-only { display: inline-flex; }
@media (max-width: 768px) { .desktop-only { display: none; } }

/* Run button -- primary action */
.btn-run {
  background: var(--indigo);
  color: #fff;
  border: none;
  padding: 7px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--sans);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(92,107,255,0.3);
  white-space: nowrap;
}
.btn-run:hover {
  box-shadow: 0 4px 16px rgba(92,107,255,0.5);
  transform: translateY(-1px);
}
.btn-run.running {
  pointer-events: none;
  opacity: 0.8;
  background: var(--indigo-soft);
  color: var(--indigo);
  border: 1px solid rgba(92,107,255,0.35);
  box-shadow: none;
}
.btn-run.running::after {
  content: '';
  display: inline-block;
  width: 12px; height: 12px;
  margin-left: 6px;
  border: 2px solid var(--indigo);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

/* Dropdown */
.header-dropdown { position: relative; display: inline-flex; z-index: 50; }
.header-dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px; z-index: 200;
  min-width: 200px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  flex-direction: column;
}
.header-dropdown.open .header-dropdown-menu { display: flex; }
.header-dropdown-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 14px; border: none; background: none;
  color: var(--hi); font-size: 13px; font-family: var(--sans);
  cursor: pointer; border-radius: 6px; text-align: left;
  transition: background 0.15s;
}
.header-dropdown-menu button:hover { background: var(--indigo-soft); }

/* Theme toggle button */
.theme-toggle { font-size: 16px; padding: 4px 8px; line-height: 1; }
.shortcut-btn { min-width: 30px; padding: 6px 10px; font-weight: 700; }

/* Close dropdown on outside click */
@media (min-width: 769px) {
  .header-dropdown-menu { display: none !important; }
  .header-dropdown.open .header-dropdown-menu { display: flex !important; }
}

.shortcut-btn {
  min-width: 30px;
  padding: 6px 10px;
  font-weight: 700;
}

.theme-toggle {
  min-width: 30px;
  padding: 6px 8px;
  font-size: 15px;
}

.run-btn {
  background: var(--indigo-soft);
  color: var(--hi);
  border: 1px solid rgba(92,107,255,0.35);
  font-weight: 600;
  border-radius: 8px;
}

.run-btn:hover {
  background: rgba(92,107,255,0.22);
  box-shadow: 0 0 16px rgba(92,107,255,0.15);
}

.hamburger-btn { display: none; }
@media (max-width: 768px) {
  .hamburger-btn { display: inline-flex; }
  .header-actions { display: none; position: absolute; top: 100%; right: 8px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 6px; flex-direction: column;
    z-index: 150; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
  .header-actions.open { display: flex; }
  .header-actions .nav-btn { width: 100%; justify-content: flex-start; padding: 10px 14px; }
  .header { position: relative; }
}

/* ================================================================
   LESSON SIDEBAR
   ================================================================ */
.sidebar {
  width: 280px;
  background: var(--panel);
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
  transition: width var(--transition);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 12px;
  color: var(--low);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--mono);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}

.progress-summary {
  font-size: 11px;
  color: var(--low);
  text-transform: none;
  letter-spacing: 0;
}

.sidebar-progress { display: flex; align-items: center; gap: 8px; }
.sidebar-progress-bar {
  width: 60px; height: 4px; background: var(--border);
  border-radius: 2px; overflow: hidden;
}
.sidebar-progress-fill {
  height: 100%; background: var(--indigo);
  border-radius: 2px; transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.lesson-list { padding: 8px; }

.lesson-search {
  display: block;
  width: calc(100% - 16px);
  margin: 8px 8px 0 8px;
  padding: 8px 12px;
  background: var(--void);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--hi);
  font-family: var(--sans);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s ease;
}
.lesson-search:focus { border-color: var(--indigo); }
.lesson-search::placeholder { color: var(--low); }

.lesson-level-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 6px 12px;
  color: var(--low);
}

.lesson-level-header:first-child { padding-top: 6px; }

.level-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.level-name {
  flex: 1;
  font-weight: 600;
  font-size: 11px;
  color: var(--mid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--mono);
}

.level-progress {
  font-size: 11px;
  color: var(--low);
  flex-shrink: 0;
}

.level-progress.all-done { color: var(--green); }

.lesson-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--mid);
  transition: all 0.2s ease;
}

.lesson-item:hover {
  background: var(--panel-2);
  color: var(--hi);
}

.lesson-item.active {
  background: var(--indigo-soft);
  color: var(--indigo);
  border: 1px solid rgba(92,107,255,0.2);
}

.lesson-check {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--low);
  border: 1px solid var(--border);
  border-radius: 50%;
}

.lesson-check.completed {
  color: var(--green);
  border-color: rgba(52,211,153,0.4);
  background: var(--green-soft);
}

.lesson-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-duration {
  font-size: 11px;
  color: var(--low);
  flex-shrink: 0;
}

.lesson-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.lesson-badge.limited {
  color: var(--error);
  border: 1px solid rgba(255, 92, 122, 0.35);
  background: rgba(255, 92, 122, 0.08);
}

.lesson-limit-notice {
  margin: 0 0 10px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 92, 122, 0.3);
  background: rgba(255, 92, 122, 0.07);
  color: var(--error);
  font-size: 12px;
  border-radius: 8px;
}

.btn-run:disabled,
.btn-run[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.btn-run:disabled:hover,
.btn-run[disabled]:hover {
  background: var(--indigo);
}

/* ================================================================
   NARRATIVE PANEL
   Dimensions controlled by layout.css; this file handles visuals only.
   ================================================================ */
.narrative-panel {
  background: var(--panel);
  overflow-y: auto;
}

.narrative-toggle { display: none; }
@media (max-width: 768px) {
  .narrative-toggle { display: block; position: absolute; top: 8px; right: 8px;
    background: none; border: none; color: var(--mid); font-size: 14px;
    cursor: pointer; z-index: 5; padding: 4px 8px; border-radius: var(--radius-sm); }
  .narrative-toggle:hover { color: var(--hi); background: var(--panel-2); }
  .narrative-panel.collapsed .narrative-content { display: none; }
  .narrative-panel.collapsed { max-height: 40px !important; min-height: 40px; overflow: hidden; }
  .narrative-panel { position: relative; }
}

.narrative-panel.hidden { display: none; }

.narrative-content { padding: 20px 24px; }

.welcome-message {
  text-align: center;
  padding: 60px 20px;
}

.welcome-message h2 {
  font-size: 24px;
  margin-bottom: 12px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.welcome-message p {
  color: var(--mid);
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.6;
}

.narrative-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.narrative-title {
  flex: 1;
  margin: 0;
}

.narrative-duration {
  font-size: 12px;
  color: var(--mid);
  flex-shrink: 0;
}

.narrative-concepts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.concept-tag {
  padding: 4px 10px;
  border-radius: 100px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  background: var(--panel-2);
  color: var(--indigo);
  border: 1px solid rgba(92,107,255,0.35);
}

.narrative-body {
  color: var(--hi);
  font-size: 14px;
  line-height: 1.7;
}

.narrative-body h3 {
  color: var(--hi);
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 8px 0;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 4px;
}

.narrative-body h4 {
  color: var(--mid);
  font-size: 14px;
  font-weight: 600;
  margin: 16px 0 6px 0;
}

.narrative-body p { margin: 8px 0; }

.narrative-body pre {
  background: var(--void);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
  overflow-x: auto;
}

.narrative-body code {
  background: var(--panel-2);
  color: var(--indigo);
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 4px;
  border-radius: 3px;
}

.narrative-body pre code {
  padding: 0;
  background: none;
}

.narrative-body li { margin: 4px 0 4px 20px; }

.narrative-body table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  width: 100%;
}

.narrative-body th {
  background: var(--panel-2);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  border: 1px solid var(--border);
}

.narrative-body td {
  padding: 8px 12px;
  border: 1px solid var(--border);
}

.narrative-tips {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(240,180,69,0.06);
  border: 1px solid rgba(240,180,69,0.2);
}

.narrative-tips h3 {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: var(--amber);
  border-bottom: none;
  padding-bottom: 0;
}

.narrative-tips ul { margin: 0; }

.narrative-tips li {
  color: var(--mid);
  font-size: 13px;
}

/* ---- Story & Analogy Callouts ---- */
.narrative-story {
  margin: 16px 0;
  padding: 14px 18px;
  background: rgba(240,180,69,0.08);
  border: 1px solid rgba(240,180,69,0.2);
  border-radius: var(--radius-sm);
}
.narrative-story-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--mono);
  margin-bottom: 6px;
}
.narrative-story p {
  margin: 0;
  font-size: 13px;
  color: var(--mid);
  font-style: italic;
  line-height: 1.6;
}

.narrative-analogy {
  margin: 16px 0;
  padding: 14px 18px;
  background: var(--indigo-soft);
  border: 1px solid rgba(92,107,255,0.25);
  border-radius: var(--radius-sm);
}
.narrative-analogy-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--indigo);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--mono);
  margin-bottom: 6px;
}
.narrative-analogy p {
  margin: 0;
  font-size: 13px;
  color: var(--hi);
  line-height: 1.6;
}

.narrative-why {
  margin: 16px 0;
  padding: 14px 18px;
  background: rgba(52,211,153,0.08);
  border: 1px solid rgba(52,211,153,0.2);
  border-radius: var(--radius-sm);
}
.narrative-why-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--mono);
  margin-bottom: 6px;
}
.narrative-why p {
  margin: 0;
  font-size: 13px;
  color: var(--hi);
  line-height: 1.6;
}

.narrative-tryit {
  margin: 20px 0 12px;
  padding: 14px 18px;
  background: rgba(92,107,255,0.06);
  border: 1px dashed rgba(92,107,255,0.3);
  border-radius: var(--radius-sm);
}
.narrative-tryit-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--indigo);
  margin-bottom: 6px;
}
.narrative-tryit p {
  margin: 0;
  font-size: 13px;
  color: var(--mid);
  line-height: 1.6;
}

.narrative-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.btn-complete {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  background: var(--indigo);
  color: #fff;
  transition: all 0.2s ease;
}

.btn-complete:hover {
  box-shadow: 0 0 20px rgba(92,107,255,0.3);
}

.btn-complete.done {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(52,211,153,0.35);
  cursor: default;
}

/* ================================================================
   LINE/COLUMN BAR
   ================================================================ */
.ln-col-bar {
  padding: 2px 12px;
  font-size: 10px;
  color: var(--low);
  font-family: var(--mono);
  background: var(--panel);
  border-top: 1px solid var(--border-soft);
  user-select: none;
}

/* ================================================================
   OUTPUT PANEL
   ================================================================ */
.output-panel {
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
}

.output-tabs {
  display: flex;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border-soft);
}

.output-tabs .tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--low);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  transition: all 0.2s ease;
  font-weight: 500;
}

.output-tabs .tab:hover { color: var(--mid); }

.output-tabs .tab.active {
  color: var(--indigo);
  border-bottom: 2px solid var(--indigo);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 5px;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--mono);
  background: var(--indigo);
  color: #fff;
  vertical-align: middle;
}

.output-content {
  background: var(--void);
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.output-content pre {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  margin: 0;
  color: var(--mid);
}

/* Expected-output comparison shown above the Output tab result. */
.output-match {
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--mid);
  font-size: 12px;
  line-height: 1.45;
}
.output-match.ok {
  border-color: rgba(52, 211, 153, 0.35);
  background: var(--green-soft);
  color: var(--green);
}
.output-match.warn {
  border-color: rgba(240, 180, 69, 0.4);
  background: rgba(240, 180, 69, 0.08);
  color: var(--amber);
}
.output-match.note {
  color: var(--low);
}
.output-match .output-match-title {
  font-weight: 600;
  margin-bottom: 6px;
}
.output-match .output-match-expected {
  margin: 0;
  padding: 8px 10px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  background: var(--void);
  color: var(--hi);
  font-size: 11px;
}

/* ================================================================
   FLOATING COMPLETE BUTTON
   ================================================================ */
.floating-complete {
  position: absolute; bottom: 16px; right: 20px;
  display: flex; align-items: center; gap: 10px;
  z-index: 50; animation: fadeInUp 0.3s ease-out;
}
.floating-complete .btn-primary {
  padding: 10px 20px; font-size: 13px;
  box-shadow: 0 4px 16px rgba(92,107,255,0.35);
}
.floating-complete .btn-next {
  padding: 10px 16px; font-size: 13px;
  background: var(--panel); color: var(--hi);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; font-family: var(--sans); font-weight: 600;
  transition: all 0.2s ease;
}
.floating-complete .btn-next:hover { border-color: var(--border-hover); background: var(--panel-2); }

/* ================================================================
   SYNTAX / CONCEPTS PANEL (slide-in from right)
   ================================================================ */
.syntax-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 520px;
  background: var(--panel);
  border-left: 1px solid var(--border-soft);
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
}

.syntax-panel.hidden { transform: translateX(100%); }

.syntax-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}

.syntax-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.syntax-header button {
  background: none;
  border: none;
  color: var(--mid);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.syntax-header button:hover {
  color: var(--hi);
  background: var(--panel-2);
}

.syntax-content { padding: 12px 16px 24px; }

/* ---- Concept Search ---- */
.concept-search {
  width: 100%;
  padding: 10px 14px;
  background: var(--void);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--hi);
  font-family: var(--sans);
  font-size: 13px;
  margin-bottom: 18px;
  outline: none;
}

.concept-search:focus { border-color: var(--indigo); }

/* ---- Concept Grid ---- */
.concept-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.concept-section-title {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 600;
  color: var(--indigo);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--mono);
  padding: 14px 0 4px 0;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
}

.concept-section-title:first-child { padding-top: 0; }

.section-icon { margin-right: 6px; font-size: 14px; }

/* ---- Concept Card ---- */
.concept-card {
  background: var(--void);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.concept-card:hover { border-color: rgba(92,107,255,0.3); }

.concept-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  user-select: none;
}

.concept-card-icon {
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 1px;
}

.concept-card-text { flex: 1; min-width: 0; }

.concept-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--hi);
  margin-bottom: 3px;
}

.concept-card-metaphor-short {
  font-size: 11px;
  color: var(--mid);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Expanded Concept Card ---- */
.concept-card-body {
  display: none;
  padding: 0 12px 12px;
  border-top: 1px solid var(--border-soft);
  margin: 0 12px;
}

.concept-card.expanded .concept-card-body {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

.concept-card.expanded .concept-card-metaphor-short {
  -webkit-line-clamp: unset;
}

.concept-card.expanded {
  grid-column: 1 / -1;
  border-color: rgba(92,107,255,0.4);
}

.concept-card-metaphor-full {
  font-size: 12px;
  color: var(--mid);
  line-height: 1.6;
  margin: 10px 0;
}

.concept-card-code {
  background: #050510;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-x: auto;
  margin: 10px 0;
  max-height: 220px;
  overflow-y: auto;
  color: var(--hi);
}

.concept-card-code .code-keyword { color: #ff8fb3; font-weight: 600; }
.concept-card-code .code-string  { color: #e8c37a; }
.concept-card-code .code-comment { color: var(--low); }
.concept-card-code .code-number  { color: #e8c37a; }
.concept-card-code .code-operator { color: #ffb86c; }

.concept-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0;
}

.concept-card-tags .concept-tag {
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 10px;
  background: var(--indigo-soft);
  color: var(--indigo);
  border: 1px solid rgba(92,107,255,0.25);
}

.concept-card-try {
  display: inline-block;
  margin-top: 6px;
  padding: 7px 18px;
  background: var(--indigo);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.concept-card-try:hover {
  box-shadow: 0 4px 16px rgba(92,107,255,0.3);
}

/* ================================================================
   STATUS BAR
   ================================================================ */
.status-bar {
  padding: 6px 20px;
  background: var(--panel);
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  color: var(--low);
}

.status-bar.ok   { color: var(--green); }
.status-bar.err  { color: var(--error); }
.status-bar.busy { color: var(--amber); }

/* ================================================================
   DIAGNOSTICS
   ================================================================ */
.diag-item {
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--mono);
}

.diag-error {
  background: rgba(255,92,122,0.1);
  border-left: 3px solid var(--error);
  color: #ff8a98;
}

.diag-warn {
  background: rgba(240,180,69,0.1);
  border-left: 3px solid var(--amber);
}

/* ================================================================
   MOBILE READ-ONLY CODE VIEW
   ================================================================ */
.mobile-code-view { display: none; }

.mobile-code-mode .mobile-code-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--void);
}

.mobile-code-mode .editor-container > .monaco-editor { display: none; }
.mobile-code-mode .ln-col-bar { display: none; }
.mobile-code-mode .stdlib-fn-row .stdlib-copy { display: none; }

.mobile-code-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--panel);
}

.mobile-code-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mid);
}

.mobile-code-hint {
  font-size: 11px;
  color: var(--low);
}

.mobile-copy-btn {
  margin-left: auto;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--hi);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.mobile-copy-btn:hover { border-color: var(--indigo); color: var(--indigo); }
.mobile-copy-btn:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.mobile-copy-btn.copied { border-color: var(--green); color: var(--green); background: var(--green-soft); }

.mobile-run-btn {
  border-color: var(--indigo);
  background: var(--indigo);
  color: #fff;
}
.mobile-run-btn:hover { color: #fff; border-color: var(--indigo); opacity: 0.92; }

.mobile-code-input {
  flex: 1;
  width: 100%;
  margin: 0;
  padding: 14px 16px;
  border: 0;
  resize: none;
  overflow: auto;
  font-family: var(--mono);
  /* 16px avoids the iOS focus zoom; the browser only loads Monaco on
     wider screens, so this is the only editor on a phone. */
  font-size: 16px;
  line-height: 1.5;
  color: var(--hi);
  background: var(--void);
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}
.mobile-code-input:focus { outline: none; }
.mobile-code-input:focus-visible { outline: 2px solid var(--indigo); outline-offset: -2px; }

/* ================================================================
   PROGRESS: RINGS, HISTORY, BACKUP
   ================================================================ */
.level-ring { flex-shrink: 0; transform: rotate(-90deg); }
.level-ring-track { fill: none; stroke: var(--border); stroke-width: 2; }
.level-ring-fill { fill: none; stroke: var(--indigo); stroke-width: 2; stroke-linecap: round; }
.level-ring.complete .level-ring-fill { stroke: var(--green); }

.history-block {
  margin: 18px 0 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

.history-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.history-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--low);
}

.history-clear {
  margin-left: auto;
  background: none;
  border: none;
  padding: 2px 6px;
  color: var(--low);
  font-size: 11px;
  cursor: pointer;
  border-radius: 4px;
  font-family: var(--sans);
}
.history-clear:hover { color: var(--error); }
.history-clear:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; }

.history-empty { font-size: 12px; color: var(--low); }

.history-hint {
  margin: 0 0 8px;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--low);
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--mid);
  font-family: var(--mono);
}

.history-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--low);
  flex-shrink: 0;
}
.history-item.ok .history-dot { background: var(--green); }
.history-item.fail .history-dot { background: var(--error); }

.history-status { color: var(--hi); min-width: 44px; }
.history-time { color: var(--low); }
.history-ms { color: var(--low); }
.history-preview {
  color: var(--low);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.continue-hint { margin-top: 10px; font-size: 12px; color: var(--low); }
.continue-hint.hidden { display: none; }

.progress-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-top: 18px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--mid);
  padding: 7px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn-ghost:hover { color: var(--hi); border-color: var(--border-hover); background: var(--panel-2); }
.btn-ghost:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }

.file-btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

.progress-notice { width: 100%; font-size: 12px; color: var(--low); }
.progress-notice.ok { color: var(--green); }
.progress-notice:empty { display: none; }

.progress-actions-hint { margin-top: 8px; font-size: 11.5px; color: var(--low); }

/* Signed-in account chip in the header */
.auth-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.auth-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

/* ================================================================
   FOCUS STATES
   ================================================================ */
a:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.back-btn:focus-visible,
.nav-btn:focus-visible,
.header-site-link:focus-visible,
.tab:focus-visible,
.stdlib-chip:focus-visible,
.stdlib-copy:focus-visible,
.continue-btn:focus-visible,
.syntax-header-button:focus-visible,
.floating-complete button:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}

.lesson-item:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: -2px;
}

.lesson-search:focus-visible,
.concept-search:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 1px;
  border-color: var(--indigo);
}

/* ================================================================
   EMPTY STATES
   ================================================================ */
.lesson-empty,
.stdlib-empty {
  padding: 18px 16px;
  color: var(--low);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
}

.stdlib-empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin: 12px 0;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    max-height: 160px;
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }

  .narrative-panel {
    width: 100%;
    max-height: 35%;
  }

  .resize-handle {
    display: none;
  }

  .editor-section {
    min-height: 300px;
  }

  .header {
    padding: 8px 12px;
    flex-wrap: wrap;
  }

  .header-site-link {
    display: none;
  }

  .hero-title { font-size: 32px; }
  .feature-grid { grid-template-columns: 1fr; }
  .stats-bar { flex-wrap: wrap; gap: 16px; }

  .onboarding-content { padding: 28px 22px; }
  .onboarding-hero { font-size: 38px; margin-bottom: 8px; }
  .onboarding-content p { margin-bottom: 18px; }

  /* Banner: the overlay becomes a dark strip under the artwork so the
     wordmark stays readable on a phone. The banner is identity only; the
     primary actions live in the hero below it. */
  .page-banner { padding-bottom: 18px; }
  .xiom-banner-text {
    position: static;
    transform: none;
    padding: 14px 20px 0;
    white-space: normal;
  }
  .xiom-brand { font-size: 26px; letter-spacing: 0.24em; }
  .xiom-section { margin-top: 9px; }
  .xiom-accent { margin-top: 12px; }

  /* The centered hero block flows under the artwork on phones. */
  .banner-center {
    position: static;
    transform: none;
    background: none;
    width: 100%;
    padding: 18px 20px 0;
  }
  .banner-center .hero-title { font-size: 30px; }
  .banner-center .hero-cta { margin-top: 16px; width: 100%; }
  .landing-hero { padding-top: 20px; }
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  .hero-title {
    font-size: 28px;
  }

  .hero-subtitle {
    font-size: 14px;
    padding: 0 8px;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .stats-bar {
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
  }

  .hero-cta {
    flex-direction: column;
    padding: 0 16px;
  }

  .header-actions {
    gap: 2px;
  }

  .nav-btn {
    padding: 6px 8px;
    font-size: 13px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-btn.run-btn {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
  }

  .nav-btn[data-mobile-label] {
    font-size: 0;
    padding: 6px 8px;
  }

  .nav-btn[data-mobile-label]::before {
    content: attr(data-mobile-label);
    font-size: 17px;
    line-height: 1;
  }

  .lesson-header-title {
    display: none;
  }

  .output-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .output-tabs .tab { flex: none; white-space: nowrap; font-size: 10px; padding: 8px 10px; }

  .syntax-panel {
    width: 100vw;
  }

  .concept-grid {
    grid-template-columns: 1fr;
  }

  .concept-card.expanded {
    grid-column: 1;
  }

  .shortcut-modal-content {
    min-width: auto;
    max-width: 95vw;
    padding: 18px 16px;
  }

  .shortcut-row {
    font-size: 12px;
  }

  .shortcut-row kbd {
    min-width: 80px;
    padding: 3px 6px;
    font-size: 10px;
  }

  .narrative-content {
    padding: 14px 12px;
  }

  .output-content pre {
    font-size: 11px;
  }
}

/* ================================================================
   COMPILER REFERENCE
   ================================================================ */
.compiler-ref-section {
  margin-bottom: 20px;
}
.compiler-ref-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--indigo);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.compiler-ref-entry {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--void);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.compiler-ref-entry code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--hi);
  white-space: nowrap;
}
.compiler-ref-entry span {
  font-size: 12px; color: var(--mid); text-align: right; max-width: 55%;
}

/* ================================================================
   STDLIB REFERENCE PANEL (redesigned)
   ================================================================ */
.stdlib-panel-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border-soft);
}
.stdlib-panel-header h3 { font-size: 14px; font-weight: 700; color: var(--indigo); margin: 0; flex: 1; }
.stdlib-panel-header button { background: none; border: none; color: var(--mid); cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.stdlib-panel-header button:hover { color: var(--hi); background: var(--panel-2); }

.stdlib-panel-content { flex: 1; overflow-y: auto; }

/* Hero section */
.stdlib-hero { padding: 14px 14px 8px; border-bottom: 1px solid var(--border-soft); }
.stdlib-quick-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.stdlib-chip { display: inline-block; padding: 4px 10px; background: var(--indigo-soft); color: var(--indigo); border: 1px solid rgba(92,107,255,0.25); border-radius: 100px; font-size: 11px; font-family: var(--mono); cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.stdlib-chip:hover { background: rgba(92,107,255,0.22); border-color: var(--indigo); }

/* Module cards */
.stdlib-modules { padding: 6px 8px 8px; }
.stdlib-mod-card { margin-bottom: 4px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); overflow: hidden; background: var(--void); }
.stdlib-mod-card-header { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; cursor: pointer; user-select: none; transition: background 0.15s; }
.stdlib-mod-card-header:hover { background: var(--panel-2); }
.stdlib-mod-card-left { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.stdlib-mod-card-arrow { font-size: 8px; color: var(--low); transition: transform 0.15s; }
.stdlib-mod-card.open .stdlib-mod-card-arrow { transform: rotate(90deg); }
.stdlib-mod-card-name { font-weight: 700; font-size: 12px; color: var(--indigo); font-family: var(--mono); }
.stdlib-mod-card-badge { font-size: 9px; color: var(--low); background: var(--panel-2); padding: 1px 6px; border-radius: 8px; font-family: var(--mono); }
.stdlib-mod-card-desc { font-size: 10px; color: var(--mid); flex: 1; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 8px; }
.stdlib-mod-card-body { display: none; padding: 0 12px 8px; }
.stdlib-mod-card.open .stdlib-mod-card-body { display: block; }
.stdlib-fn-row { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border-soft); font-size: 10px; }
.stdlib-fn-row:last-child { border-bottom: none; }
.stdlib-fn-row code { font-family: var(--mono); font-size: 10px; color: var(--hi); flex-shrink: 0; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stdlib-fn-row span { color: var(--mid); font-size: 10px; flex: 1; }

/* Footer */
.stdlib-footer { padding: 10px 14px; border-top: 1px solid var(--border-soft); font-size: 10px; color: var(--low); text-align: center; font-family: var(--mono); }
.stdlib-loading { padding: 24px 14px; color: var(--low); font-size: 12px; text-align: center; font-family: var(--mono); }

.stdlib-tier-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.stdlib-tier-toggle {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--hi);
  font-size: 11px;
  font-family: var(--mono);
  cursor: pointer;
}
.stdlib-tier-toggle:hover { border-color: var(--indigo); color: var(--indigo); }
.stdlib-tier-hint { font-size: 10px; color: var(--low); }

.stdlib-modules .tier-hidden { display: none; }
.stdlib-modules.show-all .tier-hidden,
.stdlib-modules.searching .tier-hidden { display: block; }

.tier-badge {
  padding: 0 5px;
  border-radius: 999px;
  font-size: 9px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.tier-docs { color: var(--indigo); border: 1px solid rgba(92, 107, 255, 0.35); background: var(--indigo-soft); }
.tier-local { color: var(--low); border: 1px solid var(--border); background: var(--panel-2); }

.stdlib-docs-link {
  margin-left: 8px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--indigo);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  flex-shrink: 0;
}
.stdlib-docs-link:hover { color: var(--hi); }

.stdlib-copy {
  margin-left: auto;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--low);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.stdlib-copy:hover { color: var(--indigo); border-color: var(--indigo); background: var(--indigo-soft); }
.stdlib-fn-row { display: flex; align-items: center; gap: 10px; }
.stdlib-fn-row .stdlib-copy { margin-left: auto; }

/* On mobile the persistent panels become full-screen overlays; the override
   lives in layout.css, which loads after this file. */

/* ================================================================
   REGISTRY PACKAGE PANEL (C1, read-only)
   ================================================================ */
.registry-note {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--low);
  font-size: 11px;
  line-height: 1.45;
}

.registry-results { padding: 10px 10px 14px; }

.registry-status {
  padding: 16px 4px;
  color: var(--low);
  font-size: 12px;
}

.registry-error {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--mid);
  font-size: 12px;
}

.registry-empty {
  padding: 18px 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--low);
  font-size: 12.5px;
  text-align: center;
}

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

.registry-card {
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--void);
}

.registry-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.registry-name {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--indigo);
  word-break: break-all;
}

.registry-latest {
  padding: 1px 7px;
  border-radius: 100px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 10px;
  font-family: var(--mono);
}

.registry-versions { margin-left: auto; color: var(--low); font-size: 11px; }

.registry-desc {
  margin: 6px 0 0;
  color: var(--mid);
  font-size: 12px;
  line-height: 1.45;
}

.registry-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.registry-action {
  padding: 4px 10px;
  font-size: 11px;
  text-decoration: none;
}

.registry-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

.registry-version-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 5px 0;
  font-family: var(--mono);
  font-size: 11px;
}

.registry-version { font-weight: 700; color: var(--hi); }
.registry-published { color: var(--low); }
.registry-size { color: var(--low); }

.registry-yanked {
  padding: 1px 6px;
  border-radius: 100px;
  background: rgba(240, 180, 69, 0.12);
  color: var(--amber);
  font-size: 10px;
}

.registry-digest {
  color: var(--low);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 6px;
}

.registry-copy { padding: 3px 8px; font-size: 10.5px; }

.registry-deps {
  padding: 2px 0 6px;
  color: var(--low);
  font-family: var(--mono);
  font-size: 10.5px;
}

/* ================================================================
   ONBOARDING MODAL
   ================================================================ */
.onboarding-modal {
  position: fixed; inset: 0; background: rgba(8,9,11,0.85);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  /* Short phones: the dialog must be scrollable, otherwise the buttons are
     clipped with no way to reach them. margin:auto on the content keeps the
     centering while still allowing overflow to scroll. */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 16px;
  z-index: 500; animation: fadeIn 0.3s ease-out;
}
.onboarding-content {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px; text-align: center;
  max-width: 460px; width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  margin: auto;
}
.onboarding-hero {
  font-size: 48px; font-weight: 700; color: var(--indigo);
  font-family: var(--mono); letter-spacing: -0.03em; margin-bottom: 12px;
}
.onboarding-content h2 { font-size: 20px; margin-bottom: 10px; }
.onboarding-content p { color: var(--mid); font-size: 14px; line-height: 1.6; margin-bottom: 24px; }
.onboarding-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.onboarding-footer { margin-top: 18px; font-size: 11px; color: var(--low); }

/* ================================================================
   UTILITY
   ================================================================ */
.hidden { display: none !important; }

/* ================================================================
   RESIZE HANDLE
   ================================================================ */
.resize-handle {
  width: 5px;
  cursor: col-resize;
  background: var(--border-soft);
  flex-shrink: 0;
  transition: background 0.15s ease;
  position: relative;
  z-index: 10;
}
.resize-handle:hover,
.resize-handle.active {
  background: var(--indigo);
  box-shadow: 0 0 8px rgba(92,107,255,0.4);
}
.resize-handle::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: -3px; right: -3px;
}

/* ================================================================
   LOADING OVERLAY
   ================================================================ */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8,9,11,0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  gap: 16px;
}
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-size: 13px;
  color: var(--mid);
  font-family: var(--mono);
}
.loading-note {
  max-width: 320px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--low);
  text-align: center;
}

/* ================================================================
   SHORTCUT MODAL
   ================================================================ */
.shortcut-modal {
  position: fixed;
  inset: 0;
  background: rgba(8,9,11,0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.shortcut-modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  min-width: 380px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: modalIn 0.2s ease-out;
}
@keyframes modalIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.shortcut-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.shortcut-modal-header h3 { font-size: 15px; font-weight: 600; }
.shortcut-modal-header button {
  background: none; border: none; color: var(--mid);
  cursor: pointer; font-size: 18px; padding: 2px 6px; border-radius: var(--radius-sm);
}
.shortcut-modal-header button:hover { color: var(--hi); background: var(--panel-2); }
.shortcut-grid { display: flex; flex-direction: column; gap: 10px; }
.shortcut-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; font-size: 13px;
}
.shortcut-row kbd {
  background: var(--void); border: 1px solid var(--border);
  border-radius: 5px; padding: 3px 8px; font-family: var(--mono);
  font-size: 11px; color: var(--hi); min-width: 100px; text-align: center;
}
.shortcut-row span { color: var(--mid); }
