/* ============================================
   CSS Variables & Reset
   ============================================ */
   :root {
    --bg-primary:    #0d1117;
    --bg-secondary:  #161b22;
    --bg-tertiary:   #21262d;
    --bg-hover:      #30363d;
    --border:        #30363d;
    --border-muted:  #21262d;
    --text-primary:  #e6edf3;
    --text-secondary:#8b949e;
    --text-muted:    #6e7681;
    --accent-blue:   #58a6ff;
    --accent-blue-hover: #79c0ff;
    --success:       #2ea043;
    --success-light: #3fb950;
    --warning:       #e3b341;
    --error:         #f85149;
    --error-light:   #ff7b72;
    --code-bg:       #161b22;
    --radius-sm:     6px;
    --radius-md:     12px;
    --radius-lg:     16px;
    --shadow:        0 8px 32px rgba(0,0,0,0.4);
    --transition:    0.2s ease;
  }
  
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  
  html { scroll-behavior: smooth; }
  
  body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Segoe UI', 'Apple SD Gothic Neo', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    min-height: 100vh;
  }
  
  /* ============================================
     Global Progress Bar (Fixed Top)
     ============================================ */
  #global-progress-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--bg-tertiary);
    z-index: 1000;
    display: flex;
    align-items: center;
  }
  #global-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--success-light));
    transition: width 0.5s ease;
    width: 0%;
  }
  #global-progress-text {
    position: absolute;
    right: 12px;
    top: 6px;
    font-size: 11px;
    color: var(--text-muted);
  }
  
  /* ============================================
     Header & Navigation
     ============================================ */
  #main-header {
    position: sticky;
    top: 4px;
    z-index: 900;
    background: rgba(13,17,23,0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0;
  }
  .header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .header-meta { display: flex; flex-direction: column; gap: 4px; }
  #course-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
  .header-tags { display: flex; gap: 8px; flex-wrap: wrap; }
  .header-tags span {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
  }
  .header-actions { display: flex; gap: 8px; flex-shrink: 0; }
  
  #step-nav {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #step-nav::-webkit-scrollbar { display: none; }
  
  .step-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    font-size: 12px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  }
  .step-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
  .step-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    background: rgba(88,166,255,0.06);
  }
  .step-tab.completed { color: var(--success-light); }
  .step-tab.completed .step-num { background: var(--success); }
  .step-num {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
    transition: background var(--transition);
  }
  .step-tab.active .step-num { background: var(--accent-blue); color: #fff; }
  .step-label { font-size: 11px; }
  
  /* ============================================
     Main & Step Panels
     ============================================ */
  #app {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px 60px;
  }
  .step-panel { display: none; animation: fadeIn 0.3s ease; }
  .step-panel.active { display: block; }
  
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  
  .step-header {
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
  }
  .step-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
  .step-desc { color: var(--text-secondary); font-size: 14px; }
  
  /* ============================================
     Buttons
     ============================================ */
  .btn-primary {
    background: var(--accent-blue);
    color: #0d1117;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
  }
  .btn-primary:hover { background: var(--accent-blue-hover); transform: translateY(-1px); }
  .btn-primary.btn-lg { padding: 14px 32px; font-size: 16px; border-radius: var(--radius-md); }

  .step-next-bar {
    display: flex;
    justify-content: flex-end;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
  }
  
  .btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
  }
  .btn-ghost:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(88,166,255,0.06);
  }
  
  .btn-success {
    background: var(--success);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
  }
  .btn-success:hover { background: var(--success-light); }
  
  /* ============================================
     Cards & Boxes
     ============================================ */
  .card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
  }
  .tip-box {
    background: rgba(88,166,255,0.08);
    border: 1px solid rgba(88,166,255,0.25);
    border-left: 3px solid var(--accent-blue);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin: 16px 0;
    font-size: 14px;
  }
  .warning-box {
    background: rgba(227,179,65,0.08);
    border: 1px solid rgba(227,179,65,0.25);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin: 16px 0;
    font-size: 14px;
  }
  
  /* ============================================
     Step 1: Assessment
     ============================================ */
  .assessment-q-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    transition: border-color var(--transition);
  }
  .assessment-q-card.correct { border-color: var(--success); }
  .assessment-q-card.wrong   { border-color: var(--error); }
  
  .q-number {
    font-size: 12px;
    color: var(--accent-blue);
    font-weight: 600;
    margin-bottom: 8px;
  }
  .question-text { font-size: 15px; margin-bottom: 14px; font-weight: 500; }
  
  .ox-buttons { display: flex; gap: 12px; }
  .ox-btn {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 20px; font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
  }
  .ox-btn:hover { border-color: var(--accent-blue); background: rgba(88,166,255,0.1); }
  .ox-btn.selected-o { border-color: var(--success); background: rgba(46,160,67,0.15); color: var(--success-light); }
  .ox-btn.selected-x { border-color: var(--error);   background: rgba(248,81,73,0.15); color: var(--error-light); }
  .ox-btn.disabled { cursor: not-allowed; opacity: 0.6; }
  
  .mcq-options { list-style: none; display: flex; flex-direction: column; gap: 8px; }
  .mcq-option-btn {
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex; align-items: center; gap: 10px;
  }
  .mcq-option-btn::before {
    content: attr(data-num);
    min-width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--bg-hover);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
  }
  .mcq-option-btn:hover:not(.disabled) { border-color: var(--accent-blue); background: rgba(88,166,255,0.08); }
  .mcq-option-btn.correct { border-color: var(--success); background: rgba(46,160,67,0.15); color: var(--success-light); }
  .mcq-option-btn.correct::before { background: var(--success); color: #fff; }
  .mcq-option-btn.wrong { border-color: var(--error); background: rgba(248,81,73,0.12); color: var(--error-light); }
  .mcq-option-btn.wrong::before { background: var(--error); color: #fff; }
  .mcq-option-btn.disabled { cursor: not-allowed; }
  
  .assessment-result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 20px;
    text-align: center;
  }
  .assessment-result-card.level-beginner {
    border-color: rgba(88,166,255,0.4);
    background: rgba(88,166,255,0.06);
  }
  .assessment-result-card.level-intermediate {
    border-color: rgba(46,160,67,0.4);
    background: rgba(46,160,67,0.06);
  }
  .assessment-result-card strong { font-size: 18px; display: block; margin-bottom: 8px; }
  
  /* ============================================
     Step 2: Overview (Flowchart)
     ============================================ */
  #overview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 20px 0;
  }
  .flow-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 480px;
  }
  .flow-box {
    width: 100%;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border);
    background: var(--bg-secondary);
    text-align: center;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    user-select: none;
  }
  .flow-box:hover {
    border-color: var(--accent-blue);
    background: rgba(88,166,255,0.08);
    transform: scale(1.02);
  }
  .flow-box.type-start { border-color: var(--success); color: var(--success-light); }
  .flow-box.type-end   { border-color: var(--accent-blue); color: var(--accent-blue); background: rgba(88,166,255,0.08); }
  .flow-box.type-decision {
    border-radius: 4px;
    background: rgba(227,179,65,0.06);
    border-color: var(--warning);
    color: var(--warning);
  }
  .flow-arrow {
    font-size: 20px;
    color: var(--text-muted);
    margin: 4px 0;
    line-height: 1;
  }
  .flow-popup {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-blue);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    text-align: left;
    line-height: 1.6;
    width: 100%;
    display: none;
    animation: fadeIn 0.2s ease;
  }
  .flow-popup.visible { display: block; }
  .flow-node-num {
    position: absolute;
    top: -10px; left: -10px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: #0d1117;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
  }
  
  /* ============================================
     Step 3: Lessons
     ============================================ */
  #lessons-progress-bar {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    height: 8px;
    margin-bottom: 24px;
    position: relative;
    overflow: visible;
  }
  #lessons-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--success-light));
    border-radius: 20px;
    transition: width 0.4s ease;
    width: 0%;
  }
  #lessons-progress-text {
    position: absolute;
    right: 0; top: -20px;
    font-size: 12px;
    color: var(--text-muted);
  }
  
  .lesson-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    transition: border-color var(--transition);
  }
  .lesson-card.understood { border-color: var(--success); }
  .lesson-card h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text-primary);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-muted);
  }
  .lesson-card p { color: var(--text-secondary); font-size: 14px; margin-bottom: 12px; }
  .lesson-card ol, .lesson-card ul {
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
  }
  .lesson-card li { margin-bottom: 4px; }
  .lesson-card a { color: var(--accent-blue); text-decoration: none; }
  .lesson-card a:hover { text-decoration: underline; }
  
  code.term {
    background: rgba(88,166,255,0.12);
    color: var(--accent-blue);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 13px;
    cursor: help;
    border-bottom: 1px dashed var(--accent-blue);
  }
  code:not(.term) {
    background: var(--code-bg);
    color: var(--success-light);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 13px;
  }
  
  .code-block-wrapper {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: 16px 0;
    overflow: hidden;
  }
  .code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
  }
  .code-lang-badge {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'Consolas', monospace;
    text-transform: uppercase;
  }
  .copy-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
  }
  .copy-btn:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
  .copy-btn.copied { border-color: var(--success); color: var(--success-light); }
  pre.code-block {
    padding: 16px;
    overflow-x: auto;
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre;
    margin: 0;
  }
  
  .understand-btn {
    margin-top: 20px;
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
  }
  .understand-btn:hover {
    border-color: var(--success);
    color: var(--success-light);
    background: rgba(46,160,67,0.06);
  }
  .understand-btn.done {
    border-color: var(--success);
    color: var(--success-light);
    background: rgba(46,160,67,0.1);
    border-style: solid;
  }
  
  /* ============================================
     Step 4: Checkpoint
     ============================================ */
  .checkpoint-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
  }
  .checkpoint-title {
    font-size: 16px; font-weight: 700;
    margin-bottom: 20px;
    display: flex; align-items: center; gap: 8px;
  }
  .checkpoint-q {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 14px;
    border-left: 3px solid var(--accent-blue);
  }
  .checkpoint-feedback {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: none;
  }
  .checkpoint-feedback.correct {
    background: rgba(46,160,67,0.12);
    border: 1px solid var(--success);
    color: var(--success-light);
    display: block;
  }
  .checkpoint-feedback.wrong {
    background: rgba(248,81,73,0.10);
    border: 1px solid var(--error);
    color: var(--error-light);
    display: block;
  }
  .checkpoint-link {
    display: inline-block;
    margin-top: 6px;
    color: var(--accent-blue);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
  }
  .checkpoint-pass-banner {
    background: rgba(46,160,67,0.12);
    border: 1px solid var(--success);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--success-light);
    font-weight: 600;
    font-size: 14px;
    margin-top: 12px;
    display: none;
    text-align: center;
  }
  .checkpoint-pass-banner.show { display: block; }
  
  /* ============================================
     Step 5: Practice
     ============================================ */
  #practice-progress {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
  }
  #practice-progress-text { color: var(--accent-blue); font-weight: 700; }
  
  .practice-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
  }
  .practice-title {
    font-size: 16px; font-weight: 700;
    margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
  }
  .checklist-item-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-muted);
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    transition: all var(--transition);
    cursor: pointer;
  }
  .checklist-item-row:hover { border-color: var(--accent-blue); }
  .checklist-item-row.done {
    background: rgba(46,160,67,0.06);
    border-color: var(--success);
    opacity: 0.8;
  }
  .checklist-checkbox {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    margin-top: 2px;
    transition: all var(--transition);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px;
  }
  .checklist-item-row.done .checklist-checkbox {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
  }
  .checklist-text { font-size: 14px; color: var(--text-secondary); }
  .checklist-item-row.done .checklist-text {
    text-decoration: line-through;
    color: var(--text-muted);
  }
  
  .debug-item-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 16px;
  }
  .debug-description { font-size: 14px; margin-bottom: 12px; color: var(--text-secondary); font-weight: 500; }
  .debug-code-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
  }
  .debug-code-label {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 6px;
    text-transform: uppercase;
  }
  .debug-code-label.buggy  { color: var(--error); }
  .debug-code-label.fixed  { color: var(--success-light); }
  .debug-hint-btn {
    background: transparent;
    border: 1px dashed var(--warning);
    color: var(--warning);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    margin-right: 8px;
  }
  .debug-hint-text {
    background: rgba(227,179,65,0.08);
    border: 1px solid rgba(227,179,65,0.2);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    color: var(--warning);
    margin-top: 8px;
    display: none;
  }
  .debug-hint-text.show { display: block; }
  .debug-explain-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
  }
  .debug-explain-text {
    background: rgba(88,166,255,0.06);
    border: 1px solid rgba(88,166,255,0.2);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    display: none;
  }
  .debug-explain-text.show { display: block; }
  
  /* ============================================
     Step 6: Scenarios
     ============================================ */
  .scenario-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
  }
  .scenario-num {
    font-size: 12px;
    color: var(--accent-blue);
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
  }
  .scenario-story {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 18px;
    line-height: 1.7;
  }
  .scenario-choices { display: flex; flex-direction: column; gap: 8px; }
  .scenario-choice-btn {
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
  }
  .scenario-choice-btn:hover:not(.disabled) {
    border-color: var(--accent-blue);
    background: rgba(88,166,255,0.06);
  }
  .scenario-choice-btn.chosen-correct {
    border-color: var(--success);
    background: rgba(46,160,67,0.12);
    color: var(--success-light);
  }
  .scenario-choice-btn.chosen-wrong {
    border-color: var(--error);
    background: rgba(248,81,73,0.10);
    color: var(--error-light);
  }
  .scenario-choice-btn.reveal-correct {
    border-color: var(--success);
    background: rgba(46,160,67,0.06);
    color: var(--success-light);
    opacity: 0.7;
  }
  .scenario-choice-btn.disabled { cursor: not-allowed; }
  .scenario-feedback {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.6;
    display: none;
    animation: fadeIn 0.3s ease;
  }
  .scenario-feedback.correct {
    background: rgba(46,160,67,0.10);
    border: 1px solid var(--success);
    color: var(--success-light);
    display: block;
  }
  .scenario-feedback.wrong {
    background: rgba(248,81,73,0.08);
    border: 1px solid var(--error);
    color: var(--error-light);
    display: block;
  }
  
  /* ============================================
     Step 7: Quiz
     ============================================ */
  #quiz-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
  }
  #quiz-score-display { display: flex; gap: 16px; font-size: 14px; color: var(--text-secondary); }
  #quiz-score-display strong { color: var(--text-primary); }
  #quiz-controls { display: flex; gap: 8px; }
  
  .quiz-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    margin-bottom: 16px;
    transition: border-color var(--transition), box-shadow 0.4s ease;
  }
  .quiz-card.answered-correct { border-color: var(--success); box-shadow: 0 0 18px rgba(46,160,67,0.2); }
  .quiz-card.answered-wrong   { border-color: var(--error); }
  
  .quiz-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
  }
  .quiz-q-num { font-size: 12px; color: var(--text-muted); }
  .difficulty-badge { font-size: 12px; }
  .quiz-type-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border);
  }
  
  .quiz-short-input-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
  }
  .quiz-short-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
    font-family: inherit;
  }
  .quiz-short-input:focus { border-color: var(--accent-blue); }
  .quiz-short-input.correct { border-color: var(--success); }
  .quiz-short-input.wrong   { border-color: var(--error); }
  .quiz-submit-btn {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    background: var(--accent-blue);
    color: #0d1117;
    border: none;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
  }
  .quiz-submit-btn:hover { background: var(--accent-blue-hover); }
  .quiz-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
  
  .quiz-explanation {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.6;
    display: none;
  }
  .quiz-explanation.show { display: block; }
  .quiz-explanation.correct {
    background: rgba(46,160,67,0.10);
    border: 1px solid var(--success);
    color: var(--success-light);
  }
  .quiz-explanation.wrong {
    background: rgba(248,81,73,0.08);
    border: 1px solid var(--error);
    color: var(--error-light);
  }
  
  @keyframes shake {
    0%,100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
  }
  @keyframes bounce {
    0%,100% { transform: scale(1); }
    40%     { transform: scale(1.04); }
    60%     { transform: scale(0.97); }
  }
  .anim-shake  { animation: shake 0.4s ease; }
  .anim-bounce { animation: bounce 0.4s ease; }
  
/* ============================================
   Step 8: Flashcards
   ============================================ */
   .review-schedule-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-wrap: wrap;
  }
  .schedule-item {
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12px;
  }
  .schedule-item.today    { background: rgba(88,166,255,0.15); color: var(--accent-blue); }
  .schedule-item.tomorrow { background: rgba(46,160,67,0.15);  color: var(--success-light); }
  .schedule-item.week     { background: rgba(227,179,65,0.15); color: var(--warning); }
  .schedule-arrow { color: var(--text-muted); }
  
  #flashcard-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
  
  /* wrapper: 높이를 inner에 맡김 */
  .flashcard-wrapper {
    perspective: 1000px;
    cursor: pointer;
  }
  
  /* inner: 앞면·뒷면을 쌓는 컨테이너 */
  .flashcard-inner {
    position: relative;
    width: 100%;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
  }
  
  .flashcard-wrapper.flipped .flashcard-inner {
    transform: rotateY(180deg);
  }
  
  /* ── 앞면: 정상 흐름으로 높이 결정 ── */
  .card-front {
    width: 100%;
    min-height: 160px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border);
    box-sizing: border-box;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    gap: 8px;
    position: relative;
  }
  
  /* ── 뒷면: 앞면과 동일한 크기로 겹침, 항상 숨겨짐 ── */
  .card-back {
    position: absolute;
    inset: 0;                        /* top/right/bottom/left: 0 */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 16px;
    text-align: left;
    border: 1px solid var(--border);
    box-sizing: border-box;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.7;
    word-break: keep-all;
    overflow-wrap: break-word;
    overflow-y: auto;
    transform: rotateY(180deg);      /* 뒤집혀 숨겨짐 — 필수 */
    /* inset:0 + position:absolute → 앞면 크기를 그대로 따라감 */
    /* 뒷면 내용이 앞면보다 길어도 앞면 밖으로 넘치지 않음 */
  }
  
  /* 뒷면 스크롤바 */
  .card-back::-webkit-scrollbar       { width: 3px; }
  .card-back::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  .card-back::-webkit-scrollbar-track { background: transparent; }
  
  .card-term {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    word-break: keep-all;
  }
  
  .card-tag {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(88,166,255,0.15);
    color: var(--accent-blue);
    margin-bottom: 6px;
    font-family: inherit;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
  }
  
  .flip-hint {
    font-size: 10px;
    color: var(--text-muted);
    position: absolute;
    bottom: 8px;
    right: 10px;
    font-weight: 400;
  }
  
  @media (max-width: 640px) {
    #flashcard-container {
      grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
  }

  /* 플래시카드 완료 체크 버튼 */
  .fc-done-btn {
    margin-top: 10px;
    padding: 4px 12px;
    font-size: 11px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    align-self: flex-end;
    flex-shrink: 0;
  }
  .fc-done-btn:hover { background: var(--bg-primary); }

  /* 완료된 카드 앞면 표시 */
  .flashcard-wrapper.fc-done .card-front {
    border-color: var(--success-light);
    opacity: 0.75;
  }
  .flashcard-wrapper.fc-done .card-front::after {
    content: '✅';
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 12px;
  }

  /* 플래시카드 진행률 */
  .flashcard-progress-bar {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
  }


  /* ============================================
     Step 9: Report
     ============================================ */
  .report-hero {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 20px;
    text-align: center;
  }
  .report-score-circle {
    width: 120px; height: 120px;
    border-radius: 50%;
    background: conic-gradient(var(--accent-blue) 0% var(--score-pct, 0%), var(--bg-tertiary) 0%);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    position: relative;
  }
  .report-score-circle::before {
    content: '';
    width: 88px; height: 88px;
    border-radius: 50%;
    background: var(--bg-secondary);
    position: absolute;
  }
  .report-score-inner {
    position: relative;
    z-index: 1;
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
  }
  .report-badge-area { margin-top: 16px; }
  .report-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(88,166,255,0.1);
    border: 1px solid var(--accent-blue);
    border-radius: 30px;
    font-size: 15px; font-weight: 700;
    margin-bottom: 8px;
  }
  .report-badge-msg {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
  }
  
  .report-sections {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
  }
  .report-section-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
  }
  .report-section-name { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
  .report-section-bar-wrap {
    background: var(--bg-tertiary);
    border-radius: 10px;
    height: 6px;
    overflow: hidden;
    margin-bottom: 4px;
  }
  .report-section-bar {
    height: 100%;
    border-radius: 10px;
    background: var(--accent-blue);
    transition: width 0.6s ease;
  }
  .report-section-bar.high   { background: var(--success); }
  .report-section-bar.medium { background: var(--warning); }
  .report-section-bar.low    { background: var(--error); }
  .report-section-pct { font-size: 11px; color: var(--text-muted); }
  
  .report-weak-areas {
    background: var(--bg-secondary);
    border: 1px solid var(--error);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
  }
  .report-weak-title { font-size: 14px; font-weight: 700; color: var(--error-light); margin-bottom: 10px; }
  .report-weak-link {
    display: inline-block;
    margin: 4px 6px 4px 0;
    padding: 4px 12px;
    border-radius: 4px;
    background: rgba(248,81,73,0.1);
    border: 1px solid rgba(248,81,73,0.3);
    color: var(--error-light);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
  }
  
  /* 다음 강좌 추천 */
  .report-next-course {
    margin-top: 24px;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
  }
  .report-next-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 12px;
  }
  .report-next-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }
  .report-next-info strong { font-size: 14px; display: block; margin-bottom: 4px; }
  .report-next-info p { font-size: 12px; color: var(--text-secondary); margin: 0 0 4px; }
  .report-next-info span { font-size: 11px; color: var(--text-muted); }

  /* 단계별 초기화 모달 */
  .reset-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .reset-opt-btn {
    padding: 10px 16px;
    text-align: left;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition);
  }
  .reset-opt-btn:hover { background: var(--bg-tertiary); }
  .reset-opt-btn.danger {
    border-color: rgba(248,81,73,0.4);
    color: var(--error-light);
    margin-top: 4px;
  }
  .reset-opt-btn.danger:hover { background: rgba(248,81,73,0.08); }

  /* ============================================
     Tooltip
     ============================================ */
  .tooltip {
    position: fixed;
    z-index: 9999;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-blue);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 260px;
    line-height: 1.6;
    pointer-events: none;
    animation: fadeIn 0.15s ease;
    box-shadow: var(--shadow);
  }
  
  /* ============================================
     Modal
     ============================================ */
  #modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
  }
  #modal-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 480px;
    width: 100%;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
  }
  #modal-close {
    position: absolute;
    top: 12px; right: 14px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
  }
  #modal-close:hover { color: var(--text-primary); }
  
  /* ============================================
     Utilities & Responsive
     ============================================ */
  .hidden { display: none !important; }
  .mt-8  { margin-top: 8px; }
  .mt-16 { margin-top: 16px; }
  .divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
  }
  .text-success { color: var(--success-light); }
  .text-error   { color: var(--error-light); }
  .text-muted   { color: var(--text-muted); }
  .text-center  { text-align: center; }
  
  @media (max-width: 640px) {
    .header-inner { padding: 10px 14px; }
    #app { padding: 16px 14px 60px; }
    .step-label { display: none; }
    .step-tab { padding: 8px 10px; }
    #quiz-toolbar { flex-direction: column; align-items: flex-start; }
    .debug-code-compare { grid-template-columns: 1fr; }
    #flashcard-container { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    /* 모바일: wrapper 고정 높이 제거 (이미 위에서 제거됨) */
  }

  /* ── 카탈로그 네비게이션 바 ── */
  .course-nav-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: var(--bg-primary, #0f0f10);
    border-bottom: 1px solid var(--border, #2c2c2e);
  }

  .back-to-catalog {
    font-size: 13px;
    color: var(--accent-blue);
    text-decoration: none;
    white-space: nowrap;
    transition: opacity 0.2s;
  }

  .back-to-catalog:hover {
    opacity: 0.75;
  }

  .current-course-title {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

/* ============================================
   Quiz: Fill 타입 (코드 빈칸 채우기)
   ============================================ */
  .fill-code-block {
    display: block;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: var(--text-primary);
    margin-top: 12px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-all;
  }
  .fill-inline-input {
    display: inline-block;
    width: 110px;
    padding: 1px 8px;
    border-radius: 4px;
    border: 1px solid var(--accent-blue);
    background: var(--bg-tertiary);
    color: var(--accent-blue);
    font-family: 'Courier New', monospace;
    font-size: 13px;
    outline: none;
    vertical-align: middle;
    transition: border-color var(--transition);
  }
  .fill-inline-input:focus { border-color: var(--accent-blue-hover); }
  .fill-inline-input.correct { border-color: var(--success); color: var(--success-light); }
  .fill-inline-input.wrong   { border-color: var(--error);   color: var(--error-light); }
  .fill-submit-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
  }

/* ============================================
   Quiz: Order 타입 (순서 배열)
   ============================================ */
  .order-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
  }
  .order-choice-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
  }
  .order-choice-btn:hover:not(.selected):not(.disabled) { border-color: var(--accent-blue); }
  .order-choice-btn.selected {
    border-color: var(--accent-blue);
    background: rgba(88,166,255,0.08);
  }
  .order-choice-btn.correct { border-color: var(--success); background: rgba(46,160,67,0.1); }
  .order-choice-btn.wrong   { border-color: var(--error);   background: rgba(248,81,73,0.08); }
  .order-choice-btn.disabled { cursor: default; }
  .order-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s;
  }
  .order-choice-btn.selected .order-num { opacity: 1; }
  .order-choice-btn.correct .order-num,
  .order-choice-btn.wrong .order-num { opacity: 1; }
  .order-submit-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
  }
