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

:root {
  --bg: #0a0e1a;           /* Void Black */
  --bg-surface: #141824;   /* Console Surface */
  --bg-elevated: #1e2536;  /* Wire Grey (elevated) */
  --border: #1e2536;       /* Wire Grey */
  --text: #e2e8f0;         /* Signal White */
  --text-muted: #8892a8;   /* Exhaust Grey */
  --accent: #f7df1e;       /* Reactor Teal */
  --accent-dim: #14b8a6;
  --accent-glow: rgba(247, 223, 30, 0.08); /* Reactor Glow */
  --green: #34d399;
  --red: #f87171;
  --orange: #fbbf24;
  --radius: 8px;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', system-ui, sans-serif;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar h1 {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #fde68a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.topbar .progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.progress-bar {
  width: 200px;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #fde68a);
  border-radius: 4px;
  transition: width 0.4s ease;
}
.progress-pct {
  font-weight: 600;
  color: var(--accent);
  min-width: 36px;
  text-align: right;
}

/* ---------- Layout ---------- */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 260px;
  min-width: 260px;
  border-right: 1px solid var(--border);
  background: var(--bg-surface);
  padding: 12px 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.search-wrap {
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.search-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.8125rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.2s;
}
.search-input::placeholder { color: #475569; }
.search-input:focus { border-color: var(--accent); }
.sidebar-lessons { flex: 1; overflow-y: auto; }
.sidebar-group-label {
  padding: 8px 16px 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 8px;
  border-bottom: 1px solid var(--border);
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-muted);
  transition: all 0.2s;
  border-left: 3px solid transparent;
  border-top: none;
  border-right: none;
  border-bottom: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
}
.sidebar-item:hover {
  background: var(--accent-glow);
  color: var(--text);
}
.sidebar-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-glow);
  font-weight: 600;
}
.sidebar-item.done { color: var(--green); }
.sidebar-item.done .sidebar-icon { color: var(--green); }
.sidebar-icon {
  min-width: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}
.sidebar-item.active .dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.sidebar-num {
  color: #475569;
  font-size: 0.75rem;
  min-width: 16px;
}

/* ---------- Main content ---------- */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  max-width: 960px;
}
.lesson-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.lesson-num {
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.es-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: 1px solid rgba(247, 223, 30, 0.2);
}
.lesson-desc {
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 24px;
  font-size: 0.9375rem;
}
.lesson-desc code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--accent);
  border: 1px solid var(--border);
}
.lesson-desc strong { color: var(--text); font-weight: 600; }
.lesson-desc em { color: var(--text-muted); }
.lesson-desc a {
  color: var(--accent-dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.lesson-desc a:hover { border-bottom-color: var(--accent-dim); }
.lesson-desc ul, .lesson-desc ol {
  margin: 8px 0;
  padding-left: 20px;
}
.lesson-desc li { margin: 4px 0; }
.lesson-desc pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  margin: 12px 0;
}
.lesson-desc pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text);
}

/* ---------- Editor ---------- */
.editor-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-muted);
}
#editor-container { height: 340px; }
.btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.btn {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-sans);
}
.btn-run {
  background: var(--accent);
  color: #0a0e1a;
}
.btn-run:hover { filter: brightness(1.15); }
.btn-run:disabled { opacity: 0.5; cursor: wait; }
.btn-reset {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-reset:hover { color: var(--text); }
.btn-solution {
  background: transparent;
  color: var(--orange);
  border: 1px solid var(--orange);
  margin-left: auto;
}
.btn-solution:hover { background: rgba(251, 191, 36, 0.1); }

/* ---------- Output ---------- */
.output-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}
.output-header {
  padding: 8px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}
.output-status-ok { color: var(--green); }
.output-status-err { color: var(--red); }
#output {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  min-height: 80px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg);
  color: var(--green);
  white-space: pre-wrap;
  word-break: break-word;
}
#output.has-error { color: var(--red); }
.output-empty { color: var(--text-muted); font-style: italic; }

/* ---------- Exercise ---------- */
.exercise {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.exercise h3 {
  font-size: 0.875rem;
  color: var(--orange);
  margin-bottom: 8px;
}
.exercise p {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}
.exercise code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8em;
  color: var(--accent);
}
.hint-toggle {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.8125rem;
  padding: 4px 0;
  margin-top: 8px;
}
.hint-text {
  display: none;
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.hint-text.show { display: block; }

/* Exercise validation result */
.exercise-result {
  min-height: 0;
  transition: all 0.3s ease;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  margin: 8px 0 4px;
}
.exercise-result:empty { display: none; }
.result-pass-wrap {
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.3);
  padding: 8px 12px;
}
.result-pass { color: #3fb950; }
.result-fail-wrap {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  padding: 8px 12px;
}
.result-fail { color: #f85149; }
.result-neutral {
  background: rgba(247, 223, 30, 0.06);
  border: 1px solid rgba(247, 223, 30, 0.15);
  padding: 8px 12px;
}
.result-info { color: var(--accent); }

/* ---------- Navigation ---------- */
.nav-bottom {
  display: flex;
  justify-content: space-between;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--bg);
  z-index: 10;
}
.nav-btn {
  padding: 10px 24px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.nav-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0e1a;
  font-weight: 600;
}

/* ---------- Landing page (DESIGN.md: deep-space cockpit) ---------- */
.landing {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  overflow: hidden;
  transition: opacity 0.5s, transform 0.5s;
  display: flex;
  flex-direction: column;
}
.landing.hidden {
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
}

/* Main content fills available space, footer sticks to bottom */
.landing-inner {
  flex: 1;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2.5vh;
  padding: 0 32px;
  box-sizing: border-box;
}

/* Zone 1: Header */
.landing-header {
  text-align: center;
}
.landing-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid rgba(247, 223, 30, 0.2);
  margin-bottom: 12px;
}
.landing-title {
  font-size: clamp(1.5rem, 2.8vw, 2.2rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 6px;
  color: var(--text);
}
.gradient-text {
  background: linear-gradient(135deg, var(--accent), #fde68a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.landing-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.45;
}

/* Install banner */
.install-banner {
  display: inline-block;
  padding: 10px 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}

/* Zone 2: Feature grid - compact version cards */
.feature-grid {
  width: 100%;
  max-width: 820px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.feature-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(247, 223, 30, 0.08);
}
.feature-card-ver {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 2px;
}
.feature-card-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}
.feature-card-preview {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Zone 3: CTA */
.landing-cta-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.landing-cta {
  padding: 12px 36px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #fde68a);
  color: #0a0e1a;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(247, 223, 30, 0.25);
}
.landing-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(247, 223, 30, 0.35);
}
.landing-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Loading overlay ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity 0.5s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ---------- Congratulations overlay ---------- */
.congrats-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s;
}
.congrats-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.congrats-inner {
  text-align: center;
  max-width: 520px;
  padding: 0 24px;
  position: relative;
}
.congrats-glow {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(247, 223, 30, 0.12) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.congrats-title {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #fde68a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  position: relative;
}
.congrats-sub {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.5;
}
.congrats-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-bottom: 32px;
}
.congrats-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.congrats-stat-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}
.congrats-stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.congrats-next {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.congrats-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}
.congrats-btn {
  padding: 12px 28px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  text-decoration: none;
  transition: border-color 0.2s, transform 0.2s;
}
.congrats-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.congrats-btn.primary {
  background: linear-gradient(135deg, var(--accent), #fde68a);
  color: #0a0e1a;
  border: none;
  box-shadow: 0 4px 16px rgba(247, 223, 30, 0.25);
}
.congrats-btn.primary:hover {
  box-shadow: 0 6px 24px rgba(247, 223, 30, 0.35);
}

/* ---------- Mobile sidebar drawer ---------- */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1100;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  transition: border-color 0.2s;
}
.sidebar-toggle:hover { border-color: var(--accent); }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1099;
}
.sidebar-backdrop.open { display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .sidebar-toggle { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }

  .content { padding: 20px 16px; }

  /* Topbar: compact for mobile */
  .topbar {
    padding: 10px 12px 10px 52px;
    gap: 8px;
  }
  .topbar h1 { font-size: 0.95rem; }
  .topbar .progress-wrap { gap: 6px; font-size: 0.7rem; }
  .topbar .progress-wrap #progress-label { display: none; }
  .topbar .progress-bar { width: 80px; height: 6px; }
  .topbar .progress-pct { font-size: 0.7rem; min-width: 28px; }

  /* Landing page: no scroll, compact on mobile */
  .landing-inner {
    justify-content: flex-start;
    padding: 24px 16px 0;
    gap: 12px;
  }

  .landing-badge { margin-bottom: 8px; font-size: 0.65rem; }
  .landing-title { font-size: 1.5rem; margin-bottom: 4px; }
  .landing-subtitle { font-size: 0.8rem; max-width: 100%; }

  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-width: 100%;
  }
  .feature-card { padding: 10px 12px; }
  .feature-card-ver { font-size: 0.85rem; }
  .feature-card-preview { -webkit-line-clamp: 1; }

  .landing-cta { padding: 10px 28px; font-size: 0.9rem; }
  .landing-meta { font-size: 0.7rem; }
}

@media (max-width: 380px) {
  .landing-title { font-size: 1.3rem; }
  .feature-card-preview { display: none; }
  .feature-card { padding: 8px 10px; }
  .feature-grid { gap: 6px; }
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.site-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.site-footer a:hover {
  text-decoration: underline;
}
.site-footer .disclaimer {
  display: block;
  margin-top: 6px;
  font-size: 0.68rem;
  color: #7a8499;
}
