/* ===== CSS Variables / Theming ===== */
:root {
    /* Light theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-code: #f1f3f5;
    --bg-card: #ffffff;
    --bg-nav: rgba(255, 255, 255, 0.95);
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #868e96;
    --border-color: #dee2e6;
    --accent: #228be6;
    --accent-light: #e7f5ff;
    --accent-dark: #1971c2;
    --success: #2f9e44;
    --success-light: #ebfbee;
    --danger: #e03131;
    --danger-light: #fff5f5;
    --warning: #f08c00;
    --warning-light: #fff9db;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --terminal-bg: #1a1b26;
    --terminal-text: #a9b1d6;
    --terminal-prompt: #9ece6a;
    --terminal-path: #7aa2f7;
    --terminal-host: #bb9af7;
    --terminal-user: #9ece6a;
    --eng-bg: #fff3bf;
    --eng-border: #fcc419;
    --eng-text: #664d03;
    --file-bg: #f8f9fa;
    --file-border: #adb5bd;
    --file-header: #343a40;
    --quiz-correct: #2f9e44;
    --quiz-wrong: #e03131;
    --transition-speed: 0.3s;
}

[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-code: #1c2128;
    --bg-card: #161b22;
    --bg-nav: rgba(13, 17, 23, 0.95);
    --text-primary: #e6edf3;
    --text-secondary: #b1bac4;
    --text-muted: #768390;
    --border-color: #30363d;
    --accent: #58a6ff;
    --accent-light: #0d2240;
    --accent-dark: #79c0ff;
    --success: #3fb950;
    --success-light: #0a2611;
    --danger: #f85149;
    --danger-light: #3d1214;
    --warning: #d29922;
    --warning-light: #2e1f02;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
    --terminal-bg: #0d1117;
    --terminal-text: #b1bac4;
    --eng-bg: #2e1f02;
    --eng-border: #9e6a03;
    --eng-text: #d29922;
    --file-bg: #161b22;
    --file-border: #30363d;
    --file-header: #21262d;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    transition: background var(--transition-speed), color var(--transition-speed);
    overflow-x: hidden;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ===== Top Navigation ===== */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-nav);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    transition: all var(--transition-speed);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 60px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    text-decoration: none;
}

.brand-icon {
    font-size: 1.5rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

.nav-link:hover, .nav-link.active {
    color: var(--accent);
    background: var(--accent-light);
}

/* Dropdown */
.nav-dropdown {
    position: relative;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 300px;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    z-index: 100;
}

.nav-dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.8rem;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    transition: all 0.2s;
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.dropdown-item .item-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* Theme Toggle */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle {
    position: relative;
    width: 42px;
    height: 42px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.theme-toggle:hover {
    background: var(--accent-light);
    transform: scale(1.1);
}

.theme-icon {
    position: absolute;
    transition: opacity 0.3s, transform 0.3s;
}

[data-theme="light"] .dark-icon { opacity: 0; transform: rotate(180deg); }
[data-theme="light"] .light-icon { opacity: 1; transform: rotate(0); }
[data-theme="dark"] .light-icon { opacity: 0; transform: rotate(-180deg); }
[data-theme="dark"] .dark-icon { opacity: 1; transform: rotate(0); }

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s;
}

/* Mobile Sidebar */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1001;
}

.mobile-overlay.active {
    display: block;
}

.mobile-sidebar {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    background: var(--bg-card);
    z-index: 1002;
    transition: right 0.3s ease;
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
}

.mobile-sidebar.active {
    right: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 1.1rem;
}

.close-sidebar {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.25rem;
}

.sidebar-content {
    padding: 0.5rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-item:hover, .sidebar-item.active {
    background: var(--accent-light);
    color: var(--accent);
}

.sidebar-item .item-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* Progress Bar */
.progress-bar-container {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--bg-tertiary);
    z-index: 999;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-dark));
    width: 0%;
    transition: width 0.3s;
}

/* ===== Main Content ===== */
.main-content {
    margin-top: 63px;
    min-height: calc(100vh - 63px);
}

/* ===== Hero Section ===== */
.hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 1.5rem;
}

.hero-title {
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1.25rem;
}

.highlight {
    background: linear-gradient(135deg, var(--accent), #845ef7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.8;
}

.hero-features {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.feature {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
}

.feature-icon {
    font-size: 1.2rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-lg {
    padding: 0.85rem 2rem;
    font-size: 1.05rem;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--accent);
    color: var(--accent);
}

.btn-outline:hover {
    background: var(--accent);
    color: #fff;
}

/* Terminal Preview */
.terminal-preview {
    background: var(--terminal-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255,255,255,0.1);
}

.terminal-header-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.05);
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }

.terminal-title-preview {
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    margin-left: auto;
    margin-right: auto;
    font-family: 'Fira Code', monospace;
}

.terminal-body-preview {
    padding: 1.5rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    color: var(--terminal-text);
    min-height: 250px;
}

.typing-line {
    white-space: pre-wrap;
    line-height: 1.8;
}

.typing-cursor {
    display: inline-block;
    width: 8px;
    height: 1.1em;
    background: var(--terminal-prompt);
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* Lessons Grid */
.lessons-grid {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.section-heading {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.05rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.lesson-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.lesson-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.lesson-card .card-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.lesson-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.lesson-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Info Cards */
.info-cards {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem 4rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.75rem;
}

.info-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.info-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}

/* ===== Lesson Layout with TOC ===== */
.lesson-layout {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

/* ===== Chapter TOC (Table of Contents) ===== */
.chapter-toc {
    position: sticky;
    top: 80px;
    align-self: flex-start;
    width: 240px;
    min-width: 240px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 1rem 0 1rem 1rem;
    margin-right: 0;
    border-right: 2px solid var(--border-color);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.chapter-toc::-webkit-scrollbar {
    width: 4px;
}
.chapter-toc::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chapter-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-right: 0.75rem;
}

.chapter-toc-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chapter-toc-toggle {
    display: none; /* only visible on mobile */
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.1rem 0.4rem;
    line-height: 1;
}

.chapter-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-toc-list li {
    margin: 0;
}

.chapter-toc-list li a {
    display: block;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-left: 2px solid transparent;
    border-radius: 0 4px 4px 0;
    transition: all 0.15s ease;
    line-height: 1.35;
    word-break: break-word;
}

.chapter-toc-list li a:hover {
    color: var(--accent);
    background: var(--bg-secondary);
    border-left-color: var(--accent);
}

.chapter-toc-list li a.toc-active {
    color: var(--accent);
    background: var(--bg-secondary);
    border-left-color: var(--accent);
    font-weight: 600;
}

.chapter-toc-list li.toc-h3 a {
    padding-left: 1.5rem;
    font-size: 0.76rem;
}

/* ===== Lesson Pages ===== */
.lesson-container {
    max-width: 820px;
    flex: 1;
    min-width: 0;
    padding: 2.5rem 1.5rem 4rem;
}

.lesson-container h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.lesson-intro {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.8;
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
}

.lesson-container h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 2.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.lesson-container h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 2rem 0 0.75rem;
    color: var(--accent);
}

.lesson-container p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

.lesson-container ul, .lesson-container ol {
    margin: 0.75rem 0 1.25rem 1.5rem;
}

.lesson-container li {
    margin-bottom: 0.5rem;
    line-height: 1.7;
}

/* Inline Code */
.lesson-container code {
    font-family: 'Fira Code', monospace;
    background: var(--bg-code);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.88em;
    color: var(--accent-dark);
    border: 1px solid var(--border-color);
}

/* Code blocks */
.code-block {
    background: var(--terminal-bg);
    color: var(--terminal-text);
    border-radius: var(--radius-md);
    margin: 1.25rem 0;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 0.8rem;
    color: rgba(255,255,255,0.4);
}

.code-block-header .try-btn {
    padding: 0.25rem 0.75rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.code-block-header .try-btn:hover {
    opacity: 0.85;
}

.code-block pre {
    padding: 1rem 1.25rem;
    overflow-x: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.88rem;
    line-height: 1.7;
}

.code-block code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* Syntax highlighting in code blocks */
.code-block .prompt { color: var(--terminal-prompt); }
.code-block .command { color: #7dcfff; }
.code-block .argument { color: #e0af68; }
.code-block .output { color: #9aa5ce; }
.code-block .comment { color: #565f89; font-style: italic; }
.code-block .path { color: var(--terminal-path); }
.code-block .string { color: #9ece6a; }

/* ===== English Meaning Box ===== */
.eng-box {
    background: var(--eng-bg);
    border: 1px solid var(--eng-border);
    border-left: 4px solid var(--eng-border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    font-size: 0.95rem;
}

.eng-box .eng-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: var(--eng-text);
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.eng-box .eng-content {
    color: var(--eng-text);
    line-height: 1.7;
}

.eng-box .eng-word {
    font-weight: 700;
    font-family: 'Fira Code', monospace;
    font-size: 1rem;
}

.eng-box .eng-meaning {
    font-style: italic;
}

/* ===== File Content Display ===== */
.file-display {
    background: var(--file-bg);
    border: 1px solid var(--file-border);
    border-radius: var(--radius-md);
    margin: 1.25rem 0;
    overflow: hidden;
}

.file-display-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--file-header);
    color: #fff;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
}

.file-display-header .file-icon {
    font-size: 1rem;
}

.file-display pre {
    padding: 1rem 1.25rem;
    overflow-x: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.file-display .line-numbers {
    color: var(--text-muted);
    user-select: none;
    padding-right: 1rem;
    margin-right: 1rem;
    border-right: 1px solid var(--border-color);
}

/* ===== Concept / Tip / Warning Boxes ===== */
.info-box {
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    border-left: 4px solid;
}

.info-box.tip {
    background: var(--success-light);
    border-color: var(--success);
}

.info-box.warning {
    background: var(--warning-light);
    border-color: var(--warning);
}

.info-box.danger {
    background: var(--danger-light);
    border-color: var(--danger);
}

.info-box.note {
    background: var(--accent-light);
    border-color: var(--accent);
}

.info-box-title {
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

.info-box.tip .info-box-title { color: var(--success); }
.info-box.warning .info-box-title { color: var(--warning); }
.info-box.danger .info-box-title { color: var(--danger); }
.info-box.note .info-box-title { color: var(--accent); }

/* ===== Command Syntax Box ===== */
.syntax-box {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin: 1.25rem 0;
    font-family: 'Fira Code', monospace;
}

.syntax-box .syntax-title {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.syntax-box code {
    font-size: 0.95rem;
    background: none;
    border: none;
    padding: 0;
    color: var(--text-primary);
}

/* ===== Quiz Section ===== */
.quiz-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin: 3rem 0;
}

.quiz-section h2 {
    border: none !important;
    margin-top: 0 !important;
    padding-bottom: 0 !important;
}

.quiz-question {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.quiz-question .q-text {
    font-weight: 600;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    display: flex;
    gap: 0.5rem;
}

.quiz-question .q-num {
    color: var(--accent);
    font-weight: 700;
    flex-shrink: 0;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.quiz-option:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.quiz-option.selected {
    border-color: var(--accent);
    background: var(--accent-light);
}

.quiz-option.correct {
    border-color: var(--quiz-correct);
    background: var(--success-light);
}

.quiz-option.wrong {
    border-color: var(--quiz-wrong);
    background: var(--danger-light);
}

.quiz-option .option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.quiz-feedback {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: none;
}

.quiz-feedback.show {
    display: block;
}

.quiz-feedback.correct {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid var(--success);
}

.quiz-feedback.wrong {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.quiz-score {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
    display: none;
}

.quiz-score.show {
    display: block;
}

.quiz-score .score-text {
    font-size: 1.5rem;
    font-weight: 700;
}

.quiz-check-btn {
    margin-top: 1rem;
    width: 100%;
}

/* ===== Lesson Navigation ===== */
.lesson-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    gap: 1rem;
}

.lesson-nav .nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.lesson-nav .nav-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.lesson-nav .nav-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ===== Floating Terminal ===== */
.terminal-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 998;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: all 0.2s;
}

.terminal-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(34,139,230,0.4);
}

.terminal-fab.hidden {
    display: none;
}

.floating-terminal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 320px;
    background: var(--terminal-bg);
    z-index: 999;
    transform: translateY(100%);
    transition: transform 0.3s ease, height 0.3s ease;
    display: flex;
    flex-direction: column;
    border-top: 2px solid var(--accent);
}

.floating-terminal.open {
    transform: translateY(0);
}

.floating-terminal.expanded {
    height: 70vh;
}

.terminal-header {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    cursor: grab;
    user-select: none;
}

.terminal-dots {
    display: flex;
    gap: 6px;
    margin-right: 1rem;
}

.terminal-title {
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    font-family: 'Fira Code', monospace;
    flex: 1;
}

.terminal-controls {
    display: flex;
    gap: 0.25rem;
}

.terminal-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.terminal-btn:hover {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
}

.terminal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.terminal-output {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--terminal-text);
    white-space: pre-wrap;
    word-break: break-word;
}

.terminal-welcome {
    color: #565f89;
}

.cmd-highlight {
    color: #7dcfff;
    font-weight: 600;
}

.terminal-input-line {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
}

.terminal-prompt {
    color: var(--terminal-text);
    white-space: nowrap;
    margin-right: 0.5rem;
}

.prompt-user { color: var(--terminal-user); }
.prompt-host { color: var(--terminal-host); }
.prompt-path { color: var(--terminal-path); }

.terminal-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #c0caf5;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    caret-color: var(--terminal-prompt);
}

/* Terminal output colors */
.term-error { color: #f7768e; }
.term-success { color: var(--terminal-prompt); }
.term-info { color: var(--terminal-path); }
.term-dir { color: var(--terminal-path); font-weight: 600; }
.term-file { color: var(--terminal-text); }
.term-exec { color: var(--terminal-prompt); }
.term-link { color: #bb9af7; }
.term-prompt-echo { color: var(--terminal-prompt); }

/* ===== Back to Top ===== */
.back-to-top {
    position: fixed;
    bottom: 5.5rem;
    right: 1.5rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 997;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ===== Footer ===== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    text-align: center;
}

.footer-content p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.footer-note {
    color: var(--text-muted);
    font-size: 0.8rem !important;
}

.footer-contribute {
    margin: 1.25rem auto;
    padding: 1rem 1.5rem;
    max-width: 600px;
    background: var(--bg-tertiary);
    border: 1px dashed var(--accent);
    border-radius: 10px;
}

.footer-contribute-title {
    font-weight: 700;
    font-size: 1rem !important;
    margin-bottom: 0.4rem !important;
}

.footer-contribute-text {
    color: var(--text-muted);
    font-size: 0.82rem !important;
    margin-bottom: 0.7rem !important;
}

.footer-contribute-links {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.footer-contribute-links a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    transition: background var(--transition-speed);
}

.footer-contribute-links a:hover {
    background: var(--accent-light);
    text-decoration: none;
}

.footer-sep {
    color: var(--text-muted);
    opacity: 0.4;
}

.footer-links a {
    color: var(--accent);
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* ===== Person Cards (History Section) ===== */
.person-card {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1.5rem 0;
    transition: border-color var(--transition-speed);
}

.person-card:hover {
    border-color: var(--accent);
}

.person-img {
    width: 120px;
    min-width: 120px;
    height: 150px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.person-img-wide {
    width: 180px;
    min-width: 180px;
    height: 120px;
}

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

.person-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.person-role {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.person-caption {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

@media (max-width: 600px) {
    .person-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .person-img, .person-img-wide {
        width: 160px;
        min-width: auto;
        height: auto;
        max-height: 180px;
    }
}

/* ===== Table ===== */
.lesson-container table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
    font-size: 0.9rem;
}

.lesson-container th,
.lesson-container td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border: 1px solid var(--border-color);
}

.lesson-container th {
    background: var(--bg-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.lesson-container tr:nth-child(even) {
    background: var(--bg-secondary);
}

/* ===== Cheat Sheet ===== */
.cheat-group {
    margin-bottom: 2rem;
}

.cheat-group h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--accent);
    border: none;
}

.cheat-item {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    align-items: baseline;
}

.cheat-item:last-child {
    border-bottom: none;
}

.cheat-cmd {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-dark);
    min-width: 200px;
    flex-shrink: 0;
}

.cheat-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* ===== Responsive ===== */

/* TOC becomes collapsible top bar on smaller screens */
@media (max-width: 1100px) {
    .lesson-layout {
        flex-direction: column;
    }

    .chapter-toc {
        position: relative;
        top: auto;
        width: 100%;
        min-width: unset;
        max-height: none;
        overflow: visible;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 0.75rem 1.5rem;
        margin: 0;
    }

    .chapter-toc-header {
        margin-bottom: 0;
        cursor: pointer;
    }

    .chapter-toc-toggle {
        display: inline-block;
    }

    .chapter-toc-list {
        display: none;
        padding-top: 0.5rem;
        columns: 2;
        column-gap: 1rem;
    }

    .chapter-toc-list.toc-expanded {
        display: block;
    }

    .chapter-toc-list li a {
        border-left: none;
        padding: 0.25rem 0.5rem;
        break-inside: avoid;
    }

    .chapter-toc-list li a.toc-active {
        border-left: none;
        border-radius: 4px;
    }
}

@media (max-width: 600px) {
    .chapter-toc-list {
        columns: 1;
    }

    .chapter-toc {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 900px) {
    .hero {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 2.5rem 1.5rem;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-visual {
        order: -1;
    }

    .nav-links {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .grid {
        grid-template-columns: 1fr 1fr;
    }

    .info-cards {
        grid-template-columns: 1fr;
    }

    .lesson-container {
        padding: 2rem 1rem 3rem;
    }

    .lesson-container h1 {
        font-size: 1.6rem;
    }

    .lesson-nav {
        flex-direction: column;
    }

    .lesson-nav .nav-btn {
        width: 100%;
        justify-content: center;
    }

    .cheat-item {
        flex-direction: column;
        gap: 0.25rem;
    }

    .cheat-cmd {
        min-width: unset;
    }
}

@media (max-width: 600px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .hero-title {
        font-size: 1.6rem;
    }

    .hero-features {
        flex-direction: column;
    }

    .quiz-section {
        padding: 1.25rem;
    }

    .terminal-body-preview {
        min-height: 180px;
        font-size: 0.8rem;
    }

    .floating-terminal {
        height: 280px;
    }

    .floating-terminal.expanded {
        height: 85vh;
    }
}

/* ===== Print ===== */
@media print {
    .top-nav, .progress-bar-container, .floating-terminal, .terminal-fab, .back-to-top, .mobile-sidebar, .mobile-overlay, .chapter-toc {
        display: none !important;
    }
    .main-content {
        margin-top: 0;
    }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInUp 0.5s ease forwards;
}

.section {
    animation: fadeInUp 0.3s ease;
}

/* ===== Additional App Styles ===== */

/* Nav scrolled state */
.top-nav.scrolled {
    box-shadow: 0 2px 20px rgba(0,0,0,0.15);
}

/* Lesson card badge */
.lesson-card-badge {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--success);
    font-weight: 600;
}

.lesson-card.completed {
    border-color: var(--success);
    position: relative;
}

/* Lesson subtitle inline */
.lesson-subtitle-inline {
    font-size: 0.55em;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Quiz feedback text style */
.feedback-correct {
    color: var(--success);
    font-weight: 500;
}

.feedback-wrong {
    color: var(--danger);
    font-weight: 500;
}

.quiz-result {
    display: none;
    margin-top: 1.5rem;
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 2px solid var(--accent);
    border-radius: var(--radius-md);
    font-size: 1.2rem;
    font-weight: 700;
}

/* Typing demo styles */
.demo-prompt {
    color: var(--success);
}

.demo-cmd {
    color: #fff;
    font-weight: 600;
}

.demo-output {
    color: #adb5bd;
    font-size: 0.9em;
    padding-left: 0;
    line-height: 1.5;
}

/* Cheat table */
.cheat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.cheat-table th,
.cheat-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border: 1px solid var(--border-color);
}

.cheat-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.cheat-table td:first-child {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent-dark);
    white-space: nowrap;
}

.cheat-table tr:nth-child(even) {
    background: var(--bg-secondary);
}

/* Cheat group title override for better spacing */
.cheat-group-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--accent);
    border: none;
}

/* ===== Screenshot Gallery ===== */
.screenshot-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.screenshot-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
    transition: transform 0.2s, box-shadow 0.2s;
}

.screenshot-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.screenshot-card img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    border-bottom: 1px solid var(--border-color);
    background: #1a1a2e;
}

.screenshot-card .screenshot-label {
    padding: 0.6rem 0.9rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.screenshot-card .screenshot-label small {
    display: block;
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* Full-width historic photo */
.historic-photo {
    margin: 1.5rem 0;
    text-align: center;
}

.historic-photo img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
}

.historic-photo figcaption {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-style: italic;
}

@media (max-width: 600px) {
    .screenshot-gallery {
        grid-template-columns: 1fr;
    }
    .screenshot-card img {
        height: auto;
    }
}
