:root {
    --bg: #0d1117;
    --bg-card: #161b22;
    --bg-card-hover: #1c2230;
    --bg-inline: #1a2236;
    --border: #21293a;
    --border-accent: #2d4a7a;
    --blue-bright: #79b8ff;
    --blue-mid: #58a6ff;
    --blue-dim: #1f4e8c;
    --blue-glow: rgba(88, 166, 255, 0.12);
    --green: #56d364;
    --green-dim: #1a3d20;
    --green-bright: #a8f0c0;
    --red: #f85149;
    --red-dim: #3d1a1a;
    --red-bright: #ffa198;
    --yellow: #e3b341;
    --yellow-dim: #3d2e0a;
    --yellow-bright: #f0d080;
    --purple: #c084fc;
    --purple-dim: #2a1a4a;
    --orange: #f0883e;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --sidebar-w: 270px;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  }

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

  body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.7;
    display: flex;
    min-height: 100vh;
  }

  /* ── SIDEBAR ── */
  #sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
  }

  .sidebar-header {
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-course-tag {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--blue-mid);
    margin-bottom: 6px;
  }

  .sidebar-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
  }

  .sidebar-progress-wrap {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
  }

  .progress-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
  }

  .progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
  }

  .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue-dim), var(--blue-mid));
    border-radius: 2px;
    width: 0%;
    transition: width .4s ease;
  }

  .sidebar-nav { padding: 10px 0; flex: 1; }

  .nav-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 10px 18px 4px;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 18px;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all .15s;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
  }

  .nav-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
  .nav-item.active { border-left-color: var(--blue-mid); color: var(--blue-bright); background: var(--blue-glow); }
  .nav-item.done { color: var(--green); }
  .nav-item.done .nav-dot { background: var(--green); }

  .nav-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: background .2s;
  }
  .nav-item.active .nav-dot { background: var(--blue-mid); box-shadow: 0 0 6px var(--blue-mid); }

  /* ── MAIN ── */
  #main {
    margin-left: var(--sidebar-w);
    flex: 1;
    max-width: 860px;
    padding: 48px 52px 80px;
  }

  /* ── SECTIONS ── */
  .lesson-section {
    display: none;
    animation: fadeIn .25s ease;
  }
  .lesson-section.active { display: block; }

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

  /* ── LESSON HEADER ── */
  .lesson-eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--blue-mid);
    margin-bottom: 10px;
  }

  h1.lesson-title {
    font-size: 34px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.02em;
    color: var(--text-primary);
    margin-bottom: 14px;
  }

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

  .lesson-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
  }

  .meta-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 4px 12px;
    border-radius: 20px;
  }

  .meta-pill .dot { width: 6px; height: 6px; border-radius: 50%; }

  /* ── SECTION HEADERS ── */
  h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 36px 0 14px;
    letter-spacing: -.01em;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  h2::before {
    content: '';
    display: block;
    width: 3px;
    height: 20px;
    background: var(--blue-mid);
    border-radius: 2px;
  }

  h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--blue-bright);
    margin: 24px 0 10px;
  }

  p { margin-bottom: 14px; color: var(--text-primary); line-height: 1.75; }

  /* ── CODE BLOCKS ── */
  .code-block {
    background: #090d13;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 16px 0 20px;
    overflow: hidden;
  }

  .code-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .code-filename {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
  }

  .code-tag {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 3px;
  }
  .tag-bad { background: var(--red-dim); color: var(--red); }
  .tag-good { background: var(--green-dim); color: var(--green); }
  .tag-example { background: var(--blue-dim); color: var(--blue-bright); }
  .tag-output { background: #1a1a2e; color: #8888cc; }

  pre {
    padding: 18px 20px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13.5px;
    line-height: 1.65;
  }

  /* Syntax highlighting */
  .kw { color: #ff7b72; }         /* keyword: class, public, void, etc */
  .type { color: #79b8ff; }       /* types: String, Integer, T, etc */
  .gen { color: #f0c070; }        /* generic params <T>, <E>, etc */
  .method { color: #d2a8ff; }     /* method names */
  .str { color: #a5d6ff; }        /* strings */
  .num { color: #79c0ff; }        /* numbers */
  .comment { color: #484f58; font-style: italic; }
  .anno { color: #f0883e; }       /* annotations */
  .err { color: #f85149; text-decoration: underline wavy var(--red); } /* error highlight */

  code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg-inline);
    color: var(--blue-bright);
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid var(--border);
  }

  /* ── CALLOUT BOXES ── */
  .callout {
    border-radius: 8px;
    padding: 16px 18px;
    margin: 18px 0;
    border-left: 3px solid;
    font-size: 14px;
    line-height: 1.7;
  }

  .callout-title {
    font-weight: 600;
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 6px;
  }

  .callout.info { background: #0c1929; border-color: var(--blue-mid); }
  .callout.info .callout-title { color: var(--blue-mid); }
  .callout.warning { background: var(--yellow-dim); border-color: var(--yellow); }
  .callout.warning .callout-title { color: var(--yellow); }
  .callout.tip { background: var(--green-dim); border-color: var(--green); }
  .callout.tip .callout-title { color: var(--green); }
  .callout.danger { background: var(--red-dim); border-color: var(--red); }
  .callout.danger .callout-title { color: var(--red); }
  .callout.concept { background: var(--purple-dim); border-color: var(--purple); }
  .callout.concept .callout-title { color: var(--purple); }

  /* ── ANALOGY CARD ── */
  .analogy-card {
    background: linear-gradient(135deg, #0c1929 0%, #12102a 100%);
    border: 1px solid var(--border-accent);
    border-radius: 10px;
    padding: 22px 24px;
    margin: 20px 0;
    position: relative;
    overflow: hidden;
  }

  .analogy-card::before {
    content: '💡';
    position: absolute;
    top: 18px; right: 18px;
    font-size: 22px;
    opacity: .5;
  }

  .analogy-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--purple);
    margin-bottom: 8px;
  }

  .analogy-card p { color: var(--text-secondary); margin-bottom: 0; }
  .analogy-card strong { color: var(--text-primary); }

  /* ── COMPARISON TABLE ── */
  .compare-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0 20px;
    font-size: 13.5px;
  }

  .compare-table th {
    background: var(--bg-card);
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
  }

  .compare-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: top;
  }

  .compare-table tr:last-child td { border-bottom: none; }
  .compare-table tr:hover td { background: var(--bg-card-hover); }

  .td-bad { color: var(--red); }
  .td-good { color: var(--green); }

  /* ── QUIZ ── */
  .quiz-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    margin: 28px 0;
  }

  .quiz-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--yellow);
    margin-bottom: 12px;
  }

  .quiz-q {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.5;
  }

  .quiz-options { display: flex; flex-direction: column; gap: 8px; }

  .quiz-option {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13.5px;
    color: var(--text-secondary);
    transition: all .15s;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-align: left;
  }

  .quiz-option:hover { border-color: var(--blue-dim); color: var(--text-primary); background: var(--bg-inline); }
  .quiz-option.correct { border-color: var(--green); color: var(--green-bright); background: var(--green-dim); }
  .quiz-option.wrong { border-color: var(--red); color: var(--red-bright); background: var(--red-dim); }

  .option-letter {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--border);
    flex-shrink: 0;
    margin-top: 1px;
  }

  .quiz-feedback {
    display: none;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 7px;
    font-size: 13.5px;
    line-height: 1.6;
  }

  .quiz-feedback.show { display: block; }
  .quiz-feedback.correct-fb { background: var(--green-dim); color: var(--green-bright); border: 1px solid var(--green); }
  .quiz-feedback.wrong-fb { background: var(--red-dim); color: var(--red-bright); border: 1px solid var(--red); }

  /* ── CHALLENGE ── */
  .challenge-card {
    background: linear-gradient(135deg, #0f1d12 0%, #0d1117 100%);
    border: 1px solid #2a4a30;
    border-radius: 10px;
    padding: 24px;
    margin: 28px 0;
  }

  .challenge-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--green);
    margin-bottom: 10px;
  }

  .challenge-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
  }

  .challenge-desc { color: var(--text-secondary); font-size: 14px; margin-bottom: 14px; }

  .challenge-task {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 12px 14px;
    font-size: 13.5px;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
  }

  .task-num {
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    margin-top: 2px;
  }

  .reveal-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 5px;
    cursor: pointer;
    transition: all .15s;
    margin-top: 8px;
    font-family: var(--font-sans);
  }

  .reveal-btn:hover { border-color: var(--green); color: var(--green); }

  .reveal-content { display: none; margin-top: 12px; }
  .reveal-content.show { display: block; }

  /* ── CONCEPT MAP ── */
  .concept-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 18px 0;
  }

  .concept-tile {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    transition: border-color .2s;
  }

  .concept-tile:hover { border-color: var(--blue-dim); }
  .concept-tile-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--blue-mid); margin-bottom: 6px; }
  .concept-tile-text { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

  /* ── NAV BUTTONS ── */
  .lesson-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 52px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
  }

  .nav-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font-sans);
    transition: all .15s;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .nav-btn:hover { border-color: var(--blue-mid); color: var(--blue-bright); }
  .nav-btn:disabled { opacity: .3; cursor: not-allowed; }
  .nav-btn.primary { background: var(--blue-dim); border-color: var(--blue-mid); color: var(--blue-bright); font-weight: 500; }
  .nav-btn.primary:hover { background: #1a3d70; }

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

  /* ── TYPE PARAM VISUAL ── */
  .type-param-demo {
    background: #090d13;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 28px 24px;
    margin: 18px 0;
    text-align: center;
    font-family: var(--font-mono);
  }

  .tpd-main { font-size: 26px; color: var(--text-primary); margin-bottom: 12px; }
  .tpd-labels { display: flex; justify-content: center; gap: 40px; font-size: 12px; color: var(--text-secondary); }
  .tpd-label { display: flex; flex-direction: column; align-items: center; gap: 4px; }
  .tpd-arrow { color: var(--text-muted); font-size: 16px; }
  .tpd-label span:last-child { color: var(--blue-bright); font-weight: 600; }

  .highlight-t { color: var(--yellow); }
  .highlight-class { color: #ff7b72; }
  .highlight-name { color: var(--purple); }
  .highlight-bracket { color: var(--text-muted); }

  /* ── STEP LIST ── */
  .step-list { margin: 14px 0; }

  .step-item {
    display: flex;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }
  .step-item:last-child { border-bottom: none; }

  .step-num {
    width: 26px;
    height: 26px;
    background: var(--blue-dim);
    color: var(--blue-bright);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
  }

  .step-content { flex: 1; }
  .step-title { font-weight: 600; color: var(--text-primary); margin-bottom: 3px; font-size: 14px; }
  .step-desc { color: var(--text-secondary); font-size: 13.5px; }

  /* ── WILDCARD SECTION ── */
  .wildcard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 16px 0;
  }

  .wc-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
  }

  .wc-card h4 { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
  .wc-upper h4 { color: var(--blue-bright); }
  .wc-lower h4 { color: var(--orange); }
  .wc-unbound h4 { color: var(--purple); }
  .wc-card p { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
  .wc-syntax { font-family: var(--font-mono); font-size: 13px; background: var(--bg); border: 1px solid var(--border); padding: 6px 10px; border-radius: 5px; color: var(--text-primary); }

  /* progress dots */
  .progress-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
  }

  .pdot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border);
    cursor: pointer;
    transition: background .2s;
  }
  .pdot.active { background: var(--blue-mid); }
  .pdot.done { background: var(--green); }

    .main { 
        width: 100% !important; 
        padding: 15px !important;
    }
    .lesson-nav { 
        flex-direction: column; 
        gap: 10px; 
    }
    button, .nav-btn, .btn { 
        min-height: 44px !important; 
        padding: 12px !important;
    }

/* Mobile Responsive Overrides */
@media (max-width: 768px) {
    .shell, .layout { flex-direction: column !important; }
    .sidebar { width: 100% !important; position: static !important; margin-bottom: 20px; }
    .main { width: 100% !important; padding: 15px !important; }
    .lesson-nav { flex-direction: column; gap: 10px; }
    button, .nav-btn, .btn { min-height: 44px !important; padding: 12px !important; }
    .concept-row, .wildcard-grid { grid-template-columns: 1fr !important; }
}
