/* ═══════════════════════════════════════════════════════
   All About VLSI — Main Stylesheet
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Syne:wght@400;600;700;800&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  /* Colors */
  --bg:        #080b10;
  --surface:   #0e1219;
  --panel:     #131820;
  --card:      #181f2e;
  --border:    #1e2738;
  --border2:   #2a3550;
  --accent:    #00d4aa;
  --accent2:   #4f8ef7;
  --accent3:   #f7934f;
  --warn:      #f76f6f;
  --success:   #4fdb8f;
  --text:      #dce6f5;
  --dim:       #8899bb;
  --muted:     #445577;

  /* Level colors */
  --beginner:     #4fdb8f;
  --intermediate: #4f8ef7;
  --advanced:     #f7934f;

  /* Typography */
  --mono:  'JetBrains Mono', monospace;
  --head:  'Syne', sans-serif;
  --body:  'DM Sans', sans-serif;

  /* Layout */
  --nav-h:     54px;
  --sidebar-w: 260px;
  --theory-w:  380px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 14px;
  overflow: hidden;
}

/* ── SCROLLBARS ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── LANDING PAGE ── */
#landing-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg);
}

.landing-nav {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 40px;
  border-bottom: 1px solid var(--border);
  background: rgba(8,11,16,0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-family: var(--head);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--accent);
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-chip {
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  color: var(--bg);
}
.logo em { color: var(--dim); font-style: normal; }

.landing-nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 40px 40px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 800px; height: 400px;
  background: radial-gradient(ellipse at center,
    rgba(0,212,170,0.07) 0%,
    rgba(79,142,247,0.04) 40%,
    transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 4px 14px;
  background: rgba(0,212,170,0.08);
  border: 1px solid rgba(0,212,170,0.2);
  border-radius: 20px;
  color: var(--accent);
  margin-bottom: 24px;
  letter-spacing: 0.05em;
}
.hero-badge::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

.hero-title {
  font-family: var(--head);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.04em;
  margin-bottom: 20px;
  color: var(--text);
}
.hero-title .hl { color: var(--accent); }

.hero-sub {
  font-size: 1.05rem;
  color: var(--dim);
  max-width: 540px;
  line-height: 1.7;
  margin-bottom: 40px;
  font-weight: 300;
}

.hero-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 28px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 10px;
  font-family: var(--head);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: -0.01em;
}
.btn-primary:hover { background: #00ffcc; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0,212,170,0.3); }

.btn-secondary {
  padding: 13px 28px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: 10px;
  font-family: var(--head);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 40px;
  justify-content: center;
  padding: 32px 40px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-top: 60px;
  background: var(--surface);
}
.stat { text-align: center; }
.stat-num {
  font-family: var(--head);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Module cards grid */
.modules-section {
  padding: 60px 40px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.section-title {
  font-family: var(--head);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.03em;
}
.section-sub {
  color: var(--dim);
  font-size: 0.88rem;
  margin-bottom: 32px;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.module-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  opacity: 0;
  transition: opacity 0.2s;
}
.module-card.beginner::before     { background: var(--beginner); }
.module-card.intermediate::before { background: var(--intermediate); }
.module-card.advanced::before     { background: var(--advanced); }
.module-card:hover { border-color: var(--border2); transform: translateY(-2px); box-shadow: 0 12px 32px rgba(0,0,0,0.3); }
.module-card:hover::before { opacity: 1; }

.card-icon { font-size: 1.8rem; margin-bottom: 12px; }
.card-title {
  font-family: var(--head);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.level-pill {
  font-family: var(--mono);
  font-size: 0.6rem;
  padding: 2px 8px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.level-pill.beginner     { background: rgba(79,219,143,0.1);  color: var(--beginner);     border: 1px solid rgba(79,219,143,0.2);  }
.level-pill.intermediate { background: rgba(79,142,247,0.1);  color: var(--intermediate); border: 1px solid rgba(79,142,247,0.2);  }
.level-pill.advanced     { background: rgba(247,147,79,0.1);  color: var(--advanced);     border: 1px solid rgba(247,147,79,0.2);  }

.card-lesson-count {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
}
.card-progress {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.card-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s;
}
.card-start-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 10px;
}

/* ── LESSON PAGE ── */
#lesson-page { display: none; height: 100vh; flex-direction: column; }

/* Lesson Nav */
.lesson-nav {
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 50;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--head);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--dim);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.back-btn:hover { color: var(--text); border-color: var(--border2); }

.lesson-nav-title {
  font-family: var(--head);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.lesson-nav-center {
  flex: 1;
  display: flex;
  justify-content: center;
  gap: 6px;
}

/* progress dots */
.progress-dots { display: flex; gap: 5px; align-items: center; }
.pdot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: all 0.2s;
}
.pdot.done    { background: var(--success); }
.pdot.active  { background: var(--accent); width: 20px; border-radius: 4px; }
.pdot:hover   { background: var(--dim); }

.run-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 18px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-family: var(--head);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.run-btn:hover  { background: #00ffcc; box-shadow: 0 4px 16px rgba(0,212,170,0.25); }
.run-btn:active { transform: scale(0.97); }
.run-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.run-btn svg { width: 9px; height: 9px; fill: var(--bg); flex-shrink: 0; }

.sim-select {
  font-family: var(--mono);
  font-size: 0.65rem;
  background: var(--panel);
  border: 1px solid var(--border2);
  color: var(--dim);
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.nav-prev-next {
  display: flex;
  gap: 6px;
}
.nav-prev-next button {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 5px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--dim);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-prev-next button:hover { color: var(--text); border-color: var(--border2); }
.nav-prev-next button:disabled { opacity: 0.3; cursor: not-allowed; }

/* Lesson body layout */
.lesson-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.lesson-sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-module-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-mod-title {
  font-family: var(--head);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-lessons {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.sidebar-lesson {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.12s;
  font-size: 0.8rem;
  color: var(--dim);
  border-left: 2px solid transparent;
}
.sidebar-lesson:hover { background: var(--panel); color: var(--text); }
.sidebar-lesson.active {
  background: rgba(0,212,170,0.06);
  color: var(--accent);
  border-left-color: var(--accent);
}
.sidebar-lesson.done { color: var(--success); }

.lesson-num {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 600;
  flex-shrink: 0;
  transition: all 0.2s;
}
.sidebar-lesson.active .lesson-num { border-color: var(--accent); color: var(--accent); }
.sidebar-lesson.done   .lesson-num { background: var(--success); border-color: var(--success); color: var(--bg); }

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.sidebar-progress-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  margin-bottom: 5px;
}
.sidebar-prog-track {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.sidebar-prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  transition: width 0.4s;
}

/* ── THEORY PANE ── */
.theory-pane {
  width: var(--theory-w);
  min-width: 280px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-header {
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 10px;
  flex-shrink: 0;
}
.pane-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.theory-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px;
  line-height: 1.7;
  min-height: 0;
}

/* Theory typography */
.theory-content h2 {
  font-family: var(--head);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}
.theory-content h3 {
  font-family: var(--head);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent2);
  margin: 18px 0 8px;
  letter-spacing: -0.01em;
}
.theory-content p {
  color: var(--dim);
  font-size: 0.84rem;
  margin-bottom: 10px;
}
.theory-content ul, .theory-content ol {
  padding-left: 18px;
  margin-bottom: 10px;
}
.theory-content li {
  color: var(--dim);
  font-size: 0.83rem;
  margin-bottom: 4px;
}
.theory-content strong { color: var(--text); font-weight: 600; }
.theory-content code {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}
.theory-content pre.code-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--text);
  overflow-x: auto;
  margin: 10px 0;
  white-space: pre;
}
.theory-content table.truth-table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--mono);
  font-size: 0.75rem;
  margin: 10px 0;
}
.truth-table th {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 6px 10px;
  color: var(--accent2);
  text-align: left;
}
.truth-table td {
  border: 1px solid var(--border);
  padding: 5px 10px;
  color: var(--dim);
}

/* flow diagram */
.flow-diagram {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.flow-step {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.72rem;
  text-align: center;
  color: var(--dim);
  line-height: 1.4;
}
.flow-step small { color: var(--muted); font-family: var(--mono); font-size: 0.62rem; display: block; }
.flow-arrow { color: var(--muted); font-size: 0.9rem; }

/* tasks box */
.tasks-box {
  margin: 14px 0 0;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.tasks-title {
  font-family: var(--head);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--dim);
  padding: 3px 0;
  transition: color 0.2s;
}
.task-item.done { color: var(--success); text-decoration: line-through; opacity: 0.6; }
.task-check {
  width: 15px; height: 15px;
  border-radius: 4px;
  border: 1.5px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.55rem;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.2s;
}
.task-item.done .task-check { background: var(--success); border-color: var(--success); color: var(--bg); }

.hint-toggle {
  width: 100%;
  margin-top: 12px;
  padding: 7px 12px;
  background: rgba(79,142,247,0.08);
  border: 1px solid rgba(79,142,247,0.2);
  color: var(--accent2);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.hint-toggle:hover { background: rgba(79,142,247,0.14); }
.hint-box {
  display: none;
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(79,142,247,0.05);
  border: 1px solid rgba(79,142,247,0.15);
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--dim);
  line-height: 1.6;
}
.hint-box.show { display: block; }
.hint-pre {
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.65;
  color: var(--dim);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.hint-box code {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--accent2);
  background: var(--card);
  border: 1px solid var(--border);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ── EDITOR PANE ── */
.editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--border);
}

.editor-header {
  height: 36px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 4px;
  flex-shrink: 0;
}

.file-tab {
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--muted);
  background: none;
  border: 1px solid transparent;
  transition: all 0.12s;
}
.file-tab.active {
  color: var(--accent);
  background: var(--panel);
  border-color: var(--border);
}
.file-tab:hover:not(.active) { color: var(--dim); }

.editor-wrap {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--bg);
}

.line-nums {
  padding: 12px 0;
  background: var(--surface);
  min-width: 44px;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.73rem;
  line-height: 1.65;
  color: var(--muted);
  user-select: none;
  border-right: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.line-nums span { display: block; padding-right: 10px; }

textarea.code-editor {
  flex: 1;
  background: var(--bg);
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.65;
  padding: 12px 14px;
  resize: none;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  overflow-y: auto;
  caret-color: var(--accent);
}

/* ── OUTPUT + WAVEFORM ── */
.output-pane {
  width: 360px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transition: width 0.3s;
}

.output-pane.expanded { width: 520px; }

.output-header {
  height: 36px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
}

.status-pill {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.58rem;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--border);
  color: var(--muted);
  transition: all 0.2s;
}
.status-pill.ok  { background: rgba(79,219,143,0.12);  color: var(--success); }
.status-pill.err { background: rgba(247,111,111,0.12); color: var(--warn);    }
.status-pill.run { background: rgba(79,142,247,0.12);  color: var(--accent2); }

#console-output {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.7;
  padding: 12px 14px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 0;
}

.o-info  { color: var(--accent2); }
.o-ok    { color: var(--success); }
.o-err   { color: var(--warn);    }
.o-dim   { color: var(--muted);   }

.result-banner {
  margin: 0 12px 10px;
  padding: 9px 14px;
  border-radius: 7px;
  font-family: var(--head);
  font-size: 0.8rem;
  font-weight: 600;
  display: none;
}
.result-banner.pass {
  background: rgba(79,219,143,0.08);
  border: 1px solid rgba(79,219,143,0.2);
  color: var(--success);
  display: block;
}
.result-banner.fail {
  background: rgba(247,111,111,0.08);
  border: 1px solid rgba(247,111,111,0.2);
  color: var(--warn);
  display: block;
}

/* ── WAVEFORM ── */
.wave-pane {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-height: 180px;
  max-height: 400px;
  resize: vertical;
  overflow: hidden;
}

.wave-header {
  height: 36px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
}
.wave-expand-btn {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color 0.15s;
}
.wave-expand-btn:hover { color: var(--text); }

.wave-scroll-area {
  flex: 1;
  overflow: auto;
  position: relative;
}

#wave-canvas {
  display: block;
  background: var(--bg);
  cursor: crosshair;
  min-height: 140px;
}

.wave-timescale {
  display: flex;
  margin-left: 72px;
  height: 16px;
  position: relative;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.wave-time-label {
  position: absolute;
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--muted);
  transform: translateX(-50%);
  pointer-events: none;
}

.wave-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  padding: 20px;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 11px 20px;
  border-radius: 8px;
  font-family: var(--head);
  font-size: 0.82rem;
  font-weight: 700;
  transform: translateY(60px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(.34,1.56,.64,1);
  z-index: 999;
  pointer-events: none;
}
.toast.pass { background: var(--success); color: var(--bg); }
.toast.info { background: var(--accent2); color: white; }
.toast.show { transform: translateY(0); opacity: 1; }

/* ── NEXT LESSON BUTTON ── */
.next-lesson-wrap {
  padding: 10px 12px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}
.next-lesson-btn {
  width: 100%;
  padding: 9px;
  background: rgba(0,212,170,0.08);
  border: 1px solid rgba(0,212,170,0.2);
  color: var(--accent);
  border-radius: 7px;
  font-family: var(--head);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}
.next-lesson-btn:hover { background: rgba(0,212,170,0.15); }
.next-lesson-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── VERILATOR OPTIONS BUTTON ── */
.veri-opts-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 5px 10px;
  background: var(--panel);
  border: 1px solid var(--border2);
  color: var(--dim);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.veri-opts-btn:hover  { color: var(--accent); border-color: var(--accent); }
.veri-opts-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(0,212,170,0.08); }

/* ── VERILATOR OPTIONS PANEL ── */
.veri-panel {
  position: fixed;
  top: var(--nav-h);
  right: 0;
  z-index: 200;
  width: 340px;
  max-height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border2);
  border-top: none;
  border-right: none;
  border-radius: 0 0 0 12px;
  box-shadow: -8px 8px 32px rgba(0,0,0,0.5);
  animation: veri-slide-in 0.18s ease;
}
@keyframes veri-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

#veri-backdrop {
  position: fixed;
  inset: 0;
  z-index: 199;
}

.veri-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
}
.veri-panel-title {
  font-family: var(--head);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}
.veri-ver-badge {
  font-family: var(--mono);
  font-size: 0.58rem;
  padding: 1px 7px;
  border-radius: 3px;
  background: rgba(79,142,247,0.12);
  border: 1px solid rgba(79,142,247,0.25);
  color: var(--accent2);
}
.veri-panel-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 5px;
  border-radius: 4px;
  transition: color 0.15s;
}
.veri-panel-close:hover { color: var(--warn); }

.veri-panel-body {
  padding: 12px 0 8px;
}

/* ── Panel sections ── */
.veri-section {
  padding: 8px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.veri-section:last-child { border-bottom: none; }

.veri-section-title {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Radio options */
.veri-radio-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 2px;
}
.veri-radio-label:hover { background: rgba(255,255,255,0.03); }
.veri-radio-label input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.veri-radio-text strong {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text);
  font-weight: 600;
}
.veri-radio-text em {
  display: block;
  font-style: normal;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 1px;
}

/* Checkbox options */
.veri-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.73rem;
  color: var(--dim);
  transition: background 0.12s, color 0.12s;
  margin-bottom: 1px;
}
.veri-check-label:hover { background: rgba(255,255,255,0.03); color: var(--text); }
.veri-check-label input[type="checkbox"] {
  accent-color: var(--accent);
  flex-shrink: 0;
}
.veri-check-label code {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--accent2);
  background: rgba(79,142,247,0.08);
  padding: 0 4px;
  border-radius: 3px;
}

/* Optimization select */
.veri-select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  color: var(--dim);
}
.veri-select {
  font-family: var(--mono);
  font-size: 0.68rem;
  background: var(--panel);
  border: 1px solid var(--border2);
  color: var(--dim);
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  flex: 1;
  outline: none;
  transition: border-color 0.15s;
}
.veri-select:focus { border-color: var(--accent); color: var(--text); }

/* Extra flags input */
.veri-extra-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.7rem;
  background: var(--panel);
  border: 1px solid var(--border2);
  color: var(--dim);
  border-radius: 5px;
  padding: 5px 8px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, color 0.15s;
}
.veri-extra-input:focus { border-color: var(--accent); color: var(--text); }
.veri-extra-input::placeholder { color: var(--muted); }

/* Active flags preview */
.veri-flags-preview {
  margin: 4px 16px 0;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.6;
  min-height: 28px;
  display: none;
}
.veri-flags-preview.has-flags { display: block; }

/* ── UVM sub-section ── */
.uvm-unavail {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--warn);
  background: rgba(247,111,111,0.07);
  border: 1px solid rgba(247,111,111,0.2);
  border-radius: 5px;
  padding: 5px 10px;
  margin-bottom: 6px;
}
.uvm-subopts {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(79,142,247,0.04);
  border: 1px solid rgba(79,142,247,0.15);
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.uvm-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.uvm-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  width: 72px;
  flex-shrink: 0;
}
.uvm-hint {
  font-size: 0.69rem;
  color: var(--muted);
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: 7px;
  margin-top: 2px;
}
.uvm-hint code {
  font-family: var(--mono);
  font-size: 0.67rem;
  color: var(--accent2);
  background: rgba(79,142,247,0.08);
  padding: 0 4px;
  border-radius: 3px;
}

/* Panel actions */
.veri-panel-actions {
  padding: 8px 16px 6px;
  display: flex;
  justify-content: flex-end;
}
.veri-reset-btn {
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 4px 12px;
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted);
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}
.veri-reset-btn:hover { color: var(--text); border-color: var(--dim); }

/* ── FEEDBACK FAB ── */
.feedback-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  background: var(--panel);
  border: 1px solid var(--border2);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 7px 14px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: all 0.2s;
}
.feedback-fab:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 4px 20px rgba(0,212,170,0.15);
}

/* ── FEEDBACK MODAL ── */
.feedback-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 300;
  backdrop-filter: blur(2px);
}
.feedback-modal {
  display: none;
  position: fixed;
  bottom: 76px;
  right: 24px;
  z-index: 400;
  width: 320px;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 18px 20px 16px;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.feedback-title {
  font-family: var(--head);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}
.feedback-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  transition: color 0.15s;
}
.feedback-close:hover { color: var(--warn); }

.feedback-lesson-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--muted);
  margin-top: -6px;
}

/* Star rating */
.feedback-stars {
  display: flex;
  gap: 6px;
}
.feedback-stars span {
  font-size: 1.6rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s, transform 0.12s;
  line-height: 1;
}
.feedback-stars span:hover,
.feedback-stars span.active {
  color: #f7c94f;
  transform: scale(1.15);
}

.feedback-textarea {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--body);
  font-size: 0.75rem;
  padding: 8px 10px;
  resize: vertical;
  min-height: 72px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.feedback-textarea:focus { border-color: var(--accent); }
.feedback-textarea::placeholder { color: var(--muted); }

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.feedback-btn-cancel {
  background: none;
  border: 1px solid var(--border2);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.feedback-btn-cancel:hover { border-color: var(--dim); }
.feedback-btn-send {
  background: rgba(0,212,170,0.12);
  border: 1px solid rgba(0,212,170,0.35);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 5px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.feedback-btn-send:hover {
  background: rgba(0,212,170,0.22);
  border-color: var(--accent);
}

/* ── RESPONSIVE (desktop) ── */
@media (max-width: 1100px) {
  :root { --theory-w: 300px; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; --theory-w: 260px; }
  .output-pane { width: 300px; }
}

/* ── MOBILE TAB BAR (hidden on desktop) ── */
.mob-tab-bar {
  display: none;
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 52px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
}
.mob-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--body);
  font-size: 0.62rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  padding: 6px 4px;
}
.mob-tab:hover  { color: var(--dim); }
.mob-tab.active { color: var(--accent); background: rgba(0,212,170,0.06); }
.mob-tab-icon   { font-size: 1.2rem; line-height: 1; }
.mob-code-shortcut { display: none; }

/* ── MOBILE (≤768px) ── */
@media (max-width: 768px) {
  /* Landing */
  .landing-nav { padding: 0 16px; }
  .hero { padding: 40px 20px 24px; }
  .hero-title { font-size: clamp(1.8rem, 8vw, 2.5rem); }
  .hero-sub   { font-size: 0.88rem; margin-bottom: 24px; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .btn-primary, .btn-secondary { justify-content: center; }
  .stats-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 0;
    margin-top: 32px;
  }
  .stat {
    padding: 14px 12px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }
  .stat:nth-child(2n) { border-right: none; }
  .stat:nth-child(3), .stat:nth-child(4) { border-bottom: none; }
  .modules-section { padding: 28px 16px; }
  .modules-grid { grid-template-columns: 1fr; }

  /* Lesson nav — keep sim-select and veri-opts visible but compact */
  .lesson-nav { padding: 0 8px; gap: 5px; overflow: hidden; }
  .lesson-nav-center { display: none; }
  .nav-prev-next { display: none; }
  .lesson-nav-title { max-width: 80px; font-size: 0.72rem; }
  .sim-select { font-size: 0.58rem; padding: 3px 4px; }
  .run-btn { flex-shrink: 0; }
  .veri-opts-btn { font-size: 0.6rem; padding: 3px 6px; }
  .mob-code-shortcut {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    font-family: var(--mono);
    font-size: 0.65rem;
    padding: 4px 10px;
    background: rgba(0,212,170,0.1);
    border: 1px solid rgba(0,212,170,0.3);
    color: var(--accent);
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Lesson body: stack panes, show only active */
  .lesson-body { position: relative; overflow: hidden; }
  .lesson-sidebar,
  .theory-pane,
  .editor-pane,
  .output-pane {
    display: none;
    position: absolute;
    top: 0; left: 0; right: 0;
    bottom: 52px;
    width: 100% !important;
    min-width: 0 !important;
    border-right: none;
  }
  .lesson-sidebar.mob-active,
  .theory-pane.mob-active,
  .editor-pane.mob-active,
  .output-pane.mob-active { display: flex; flex-direction: column; }

  /* Show tab bar */
  .mob-tab-bar { display: flex; }

  /* Verilator panel full-width */
  .veri-panel { width: 100%; border-radius: 0; border-left: none; }

  /* Toast + FAB above tab bar */
  .toast        { bottom: 68px; right: 12px; }
  .feedback-fab { bottom: 68px; right: 12px; }
  .feedback-modal { right: 8px; bottom: 120px; width: calc(100vw - 16px); }
}

/* ═══════════════════════════════════════════════════════
   MASTER COURSE CARD
   ═══════════════════════════════════════════════════════ */

.course-card {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 28px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.course-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--accent3));
}
.course-card:hover {
  border-color: rgba(0,212,170,0.3);
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
}

.course-header {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.course-icon {
  font-size: 2.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.course-info {
  flex: 1;
  min-width: 0;
}

.course-title {
  font-family: var(--head);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.course-desc {
  font-size: 0.88rem;
  color: var(--dim);
  margin-bottom: 10px;
  line-height: 1.5;
}

.course-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.meta-dot { color: var(--border2); }
.meta-progress { color: var(--accent); font-weight: 600; }

.course-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 22px;
}
.course-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  transition: width 0.5s ease;
}

.course-chapters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.chapter-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s;
  position: relative;
  overflow: hidden;
}
.chapter-chip::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  opacity: 0;
  transition: opacity 0.18s;
}
.chapter-chip.beginner::before     { background: var(--beginner); }
.chapter-chip.intermediate::before { background: var(--intermediate); }
.chapter-chip.advanced::before     { background: var(--advanced); }
.chapter-chip:hover {
  border-color: var(--border2);
  background: var(--card);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}
.chapter-chip:hover::before { opacity: 1; }

.chapter-num {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chapter-icon {
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.chapter-name {
  flex: 1;
  font-family: var(--head);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-count {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  flex-shrink: 0;
}

/* ── Section divider between course and standalone modules ── */
.section-divider {
  grid-column: 1 / -1;
  font-family: var(--head);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 16px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ── Sidebar course context ── */
.sidebar-chapter-info {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--accent);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .course-card { padding: 18px; }
  .course-title { font-size: 1.05rem; }
  .course-chapters { grid-template-columns: 1fr 1fr; gap: 8px; }
  .chapter-chip { padding: 9px 10px; gap: 7px; }
  .chapter-name { font-size: 0.7rem; }
}
