/* ============ Tokens ============ */
:root {
  --bg: #0a0d12;
  --surface: #12161d;
  --surface-2: #171c25;
  --border: #232a36;
  --text: #e6e9ee;
  --muted: #8b93a3;
  --muted-2: #5c6577;
  --accent: #4f8cff;
  --accent-2: #33d6b0;
  --accent-soft: rgba(79, 140, 255, 0.12);
  --code-bg: #0d1117;
  --danger: #ef5b5b;
  --radius: 8px;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

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

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

/* ============ App shell ============ */
#app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.overlay {
  display: none;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding-bottom: 24px;
}

.main-col {
  min-width: 0;
}

.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
}

.menu-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 36px;
  height: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.menu-toggle span {
  width: 16px;
  height: 2px;
  background: var(--text);
  display: block;
}

.topbar-title {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

.content {
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 32px 96px;
}

/* ============ Sidebar ============ */
.sidebar-header {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-mark {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-mark-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -0.01em;
}

.brand-course {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.sidebar-progress {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.sidebar-progress-label .mono { color: var(--accent-2); font-weight: 600; }

.progress-track {
  height: 5px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.sidebar-setup-link {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 20px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12.5px;
  background: var(--surface-2);
}
.sidebar-setup-link:hover { border-color: var(--accent); text-decoration: none; }

.ai-callout {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.ai-callout p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.ai-callout-link {
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--accent-2);
  color: var(--accent-2);
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
}
.ai-callout-link:hover { background: var(--accent-soft); text-decoration: none; }
.sidebar-setup-icon {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 3px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.sidebar-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 16px 20px 8px;
  border-top: 1px solid var(--border);
}
.sidebar-footer a {
  color: var(--muted);
  font-size: 12px;
}
.sidebar-footer a:hover { color: var(--text); }

.nav-modules { padding: 8px 0; }

.nav-module { border-bottom: 1px solid transparent; }

.nav-module-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: var(--text);
  padding: 10px 20px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
}
.nav-module-toggle:hover { background: var(--surface-2); }

.nav-module-index {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-2);
}

.nav-module-title { flex: 1; }

.nav-module-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}

.nav-module-items {
  display: none;
  flex-direction: column;
  padding: 2px 0 6px;
}
.nav-module.open .nav-module-items { display: flex; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 20px 7px 40px;
  color: var(--muted);
  font-size: 13px;
  border-left: 2px solid transparent;
}
.nav-item:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.nav-item.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
.nav-item-mark {
  width: 12px;
  color: var(--accent-2);
  font-size: 11px;
  flex-shrink: 0;
}
.nav-item-project .nav-item-title::before {
  content: "";
}
.nav-item-project { font-style: normal; }

/* ============ Dashboard ============ */
.dashboard-head h1 {
  font-size: 30px;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.dashboard-tagline {
  color: var(--muted);
  font-size: 15px;
  margin: 0 0 32px;
  max-width: 60ch;
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 10px;
}
.stat-value-small {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  min-height: 20px;
}

.continue-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}
.continue-btn:hover { background: #3f7bef; text-decoration: none; }

.section-heading {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 16px;
}

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

.module-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.module-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}
.module-card-top {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}
.module-card h3 { margin: 0 0 6px; font-size: 16px; }
.module-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ============ Lesson / Project content ============ */
.crumb {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 14px;
}
.crumb a { color: var(--muted); }
.crumb span { margin: 0 4px; }

.project-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-2);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.lesson-title {
  font-size: 26px;
  margin: 0 0 28px;
  letter-spacing: -0.01em;
}

.lesson-section { margin-bottom: 28px; }
.lesson-section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-2);
  margin: 0 0 10px;
}
.lesson-section p { margin: 0 0 4px; color: var(--text); }

.plain-list, .checklist {
  margin: 0;
  padding-left: 20px;
}
.plain-list li, .checklist li {
  margin-bottom: 6px;
  color: var(--text);
}
.checklist { list-style: none; padding-left: 0; }
.checklist li label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.checklist input { margin-top: 4px; }

/* ============ Code blocks ============ */
.code-group { display: flex; flex-direction: column; gap: 12px; }


.code-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code-bg);
}
.code-block-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.code-lang {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 4px;
}
.copy-btn:hover { color: var(--text); border-color: var(--muted); }

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
}
.code-block code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: #d5dae3;
  white-space: pre;
}

.run-note {
  border-left: 3px solid var(--accent-2);
  background: var(--surface);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
  border-radius: 0 6px 6px 0;
}
.run-note strong { color: var(--accent-2); font-weight: 600; }

/* ============ Python setup banner + page ============ */
.setup-banner {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.setup-banner p { margin: 0; font-size: 13.5px; color: var(--text); }
.setup-banner-actions { display: flex; gap: 10px; flex-shrink: 0; }
.setup-banner-link {
  background: var(--accent);
  color: #fff;
  padding: 7px 13px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
}
.setup-banner-link:hover { background: #3f7bef; text-decoration: none; }
.setup-banner-dismiss {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 13px;
  border-radius: 6px;
  font-size: 12.5px;
}
.setup-banner-dismiss:hover { color: var(--text); }

.env-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 16px 0 8px;
}
.env-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
}
.env-card h3 { margin: 0 0 8px; font-size: 14px; }
.env-card p { margin: 0; color: var(--muted); font-size: 13px; }

/* ============ Practice ============ */
.practice-box {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--surface);
}
.practice-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 8px;
}
.practice-task { margin: 0 0 14px; }
.practice-actions { display: flex; gap: 10px; margin-bottom: 4px; }

.reveal-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12.5px;
  padding: 7px 12px;
  border-radius: 6px;
}
.reveal-btn:hover { border-color: var(--accent); }

.reveal-panel { margin-top: 14px; }
.reveal-panel.hidden { display: none; }
.reveal-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

/* ============ Lesson footer / nav ============ */
.lesson-footer {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.complete-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 20px;
}
.complete-btn:hover { background: #3f7bef; }
.complete-btn.done {
  background: var(--surface-2);
  color: var(--accent-2);
  border: 1px solid var(--accent-2);
}

.prev-next {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
}
.pn-link {
  color: var(--muted);
  max-width: 48%;
}
.pn-next { text-align: right; margin-left: auto; }

/* ============ Static pages (about / contact / terms / privacy) ============ */
.static-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.static-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.static-brand:hover { text-decoration: none; }
.static-brand img { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; }
.static-brand span { font-weight: 700; font-size: 14.5px; }
.static-back { font-size: 13px; color: var(--muted); }

.static-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 32px 96px;
}
.static-wrap h1 { font-size: 26px; margin: 0 0 24px; letter-spacing: -0.01em; }
.static-wrap h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-2);
  margin: 32px 0 10px;
}
.static-wrap p { margin: 0 0 12px; color: var(--text); }
.static-wrap ul { margin: 0 0 12px; padding-left: 20px; color: var(--text); }
.static-wrap li { margin-bottom: 6px; }
.static-wrap a { color: var(--accent); }

.contact-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.contact-list li {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--surface);
}
.contact-label { color: var(--muted); font-size: 12.5px; }
.contact-list a { font-size: 13.5px; font-weight: 600; }

.static-footer {
  border-top: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}
.static-footer a { color: var(--muted); }
.static-footer a:hover { color: var(--text); }
.static-footer-links { display: flex; gap: 14px; flex-wrap: wrap; }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .dashboard-stats { grid-template-columns: 1fr; }
  .module-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  #app { grid-template-columns: 1fr; }
  .topbar { display: flex; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  #app.sidebar-open .sidebar { transform: translateX(0); }

  .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 30;
  }
  #app.sidebar-open .overlay { display: block; }

  .content { padding: 28px 18px 72px; }
  .module-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .lesson-title { font-size: 22px; }
  .prev-next { flex-direction: column; }
  .pn-next { text-align: left; }
}
/* ============ Course access gate ============ */
.auth-gate {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 32px;
}
.auth-gate-message {
  color: var(--muted);
  font-size: 14px;
  max-width: 360px;
  margin: 0;
}
.auth-retry-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.auth-retry-btn:hover { background: #3f7bef; }

.auth-gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
}
.auth-gate-brand {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}
.auth-gate-title {
  font-size: 22px;
  margin: 0 0 12px;
}
.auth-gate-card .auth-gate-message {
  margin: 0 0 20px;
}
.auth-gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.auth-gate-input {
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--font-mono);
}
.auth-gate-input:focus {
  outline: none;
  border-color: var(--accent);
}
.auth-gate-unlock-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.auth-gate-unlock-btn:hover { background: #3f7bef; }
.auth-gate-unlock-btn:disabled { opacity: 0.6; cursor: default; }
.auth-gate-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
}
.auth-gate-error.hidden { display: none; }
.auth-gate-pay-link {
  display: inline-block;
  margin-top: 20px;
  color: var(--muted);
  font-size: 12.5px;
}
.auth-gate-pay-link:hover { color: var(--text); }

