/* ==========================================================================
   DESIGN SYSTEM & THEME TOKENS
   ========================================================================== */
:root {
    --header-height: 64px;
    --sidebar-width: 300px;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

/* 1. Cyberpunk Obsidian (Default) */
body.theme-obsidian {
    --bg-main: #0a0d14;
    --bg-sub: #111622;
    --bg-card: rgba(22, 28, 44, 0.65);
    --bg-hover: rgba(35, 45, 70, 0.8);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --accent: #00f2fe;
    --accent-glow: rgba(0, 242, 254, 0.25);
    --accent-grad: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    --border: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(0, 242, 254, 0.4);
    --glass-bg: rgba(10, 13, 20, 0.82);
    --terminal-bg: #07090e;
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
}

/* 2. Warm Parchment (Sepia Reading) */
body.theme-parchment {
    --bg-main: #f9f3e5;
    --bg-sub: #efe6d1;
    --bg-card: rgba(240, 229, 205, 0.85);
    --bg-hover: rgba(230, 215, 185, 0.95);
    --text-main: #2c241b;
    --text-muted: #736353;
    --accent: #c05c1f;
    --accent-glow: rgba(192, 92, 31, 0.2);
    --accent-grad: linear-gradient(135deg, #d35400 0%, #e67e22 100%);
    --border: rgba(115, 99, 83, 0.18);
    --border-highlight: rgba(192, 92, 31, 0.5);
    --glass-bg: rgba(249, 243, 229, 0.88);
    --terminal-bg: #221c16;
    --shadow: 0 10px 25px -5px rgba(115, 99, 83, 0.15);
}

/* 3. Crisp Paper Light */
body.theme-paper {
    --bg-main: #ffffff;
    --bg-sub: #f8fafc;
    --bg-card: #f1f5f9;
    --bg-hover: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --accent: #2563eb;
    --accent-glow: rgba(37, 99, 235, 0.18);
    --accent-grad: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    --border: #e2e8f0;
    --border-highlight: #3b82f6;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --terminal-bg: #0f172a;
    --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
}

/* 4. Nord Cyber */
body.theme-nord {
    --bg-main: #2e3440;
    --bg-sub: #3b4252;
    --bg-card: rgba(67, 76, 94, 0.7);
    --bg-hover: rgba(76, 86, 106, 0.9);
    --text-main: #eceff4;
    --text-muted: #d8dee9;
    --accent: #88c0d0;
    --accent-glow: rgba(136, 192, 208, 0.25);
    --accent-grad: linear-gradient(135deg, #88c0d0 0%, #81a1c1 100%);
    --border: rgba(236, 239, 244, 0.1);
    --border-highlight: #88c0d0;
    --glass-bg: rgba(46, 52, 64, 0.85);
    --terminal-bg: #242933;
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* Typography Classes */
body.font-inter {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body.font-outfit {
    font-family: 'Outfit', 'Inter', sans-serif;
}

body.font-lora {
    font-family: 'Lora', Georgia, serif;
}

body.font-mono {
    font-family: 'Fira Code', monospace;
}

/* Font Size Scaling */
.font-size-sm {
    --base-font: 14.5px;
    --h1-size: 26px;
    --h2-size: 20px;
    --h3-size: 17px;
}

.font-size-md {
    --base-font: 16.5px;
    --h1-size: 30px;
    --h2-size: 23px;
    --h3-size: 19px;
}

.font-size-lg {
    --base-font: 19px;
    --h1-size: 35px;
    --h2-size: 27px;
    --h3-size: 22px;
}

.font-size-xl {
    --base-font: 22px;
    --h1-size: 40px;
    --h2-size: 31px;
    --h3-size: 25px;
}

/* ==========================================================================
   GLOBAL RESET & BASE STYLES
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-size: var(--base-font);
    line-height: 1.75;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
    overflow-x: hidden;
}

/* Custom Cyberpunk Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==========================================================================
   TOP READING PROGRESS BAR
   ========================================================================== */
.progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 10000;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-grad);
    box-shadow: 0 0 10px var(--accent);
    transition: width 0.1s linear;
}

/* ==========================================================================
   TOP STICKY NAVBAR
   ========================================================================== */
.top-header {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-toggle-btn:hover {
    background: var(--bg-card);
    border-color: var(--accent);
    color: var(--accent);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.5px;
}

.brand-icon {
    font-size: 22px;
    filter: drop-shadow(0 0 8px var(--accent));
}

.badge-pro {
    font-size: 10px;
    font-weight: 800;
    background: var(--accent-grad);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 1px;
}

/* Search Input */
.header-center {
    flex: 1;
    max-width: 520px;
    margin: 0 24px;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

#search-input {
    width: 100%;
    height: 40px;
    background: var(--bg-sub);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0 50px 0 42px;
    color: var(--text-main);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition-fast);
}

#search-input.has-controls {
    padding-right: 155px;
}

#search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
    background: var(--bg-main);
}

#search-input::placeholder {
    color: var(--text-muted);
}

.search-shortcut {
    position: absolute;
    right: 14px;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    pointer-events: none;
}

/* Chrome-like Search Controls Overlay */
.search-controls {
    position: absolute;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2px 6px;
    height: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.search-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 38px;
    text-align: center;
    font-family: 'Fira Code', monospace;
}

.search-count.has-matches {
    color: var(--text-main);
}

.search-count.no-matches {
    color: #ef4444;
}

.search-divider {
    width: 1px;
    height: 14px;
    background: var(--border);
    margin: 0 2px;
}

.search-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.search-nav-btn:hover:not(:disabled) {
    background: var(--bg-sub);
    color: var(--text-main);
}

.search-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.search-nav-btn.close-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Chrome-like Highlighting */
mark.search-hl {
    background-color: #fef08a;
    color: #1c1917;
    border-radius: 2px;
    padding: 1px 2px;
    box-shadow: 0 0 0 1px rgba(254, 240, 138, 0.5);
    transition: background-color 0.15s ease, color 0.15s ease;
}

mark.search-hl.active {
    background-color: #f97316;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 0 0 2px #ea580c, 0 0 12px rgba(249, 115, 22, 0.6);
}

body.theme-parchment mark.search-hl,
body.theme-paper mark.search-hl {
    background-color: #fde047;
    color: #000000;
}

body.theme-parchment mark.search-hl.active,
body.theme-paper mark.search-hl.active {
    background-color: #ea580c;
    color: #ffffff;
}

/* Controls */
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ctrl-group {
    display: flex;
    align-items: center;
    background: var(--bg-sub);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 2px;
}

.ctrl-btn,
.theme-option {
    background: transparent;
    border: none;
    color: var(--text-muted);
    height: 32px;
    padding: 0 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ctrl-btn:hover,
.theme-option:hover {
    color: var(--text-main);
    background: var(--bg-card);
}

.theme-option.active {
    background: var(--accent-grad);
    color: #000;
    box-shadow: 0 0 10px var(--accent-glow);
}

.font-family-btn {
    min-width: 55px;
    color: var(--accent);
}

/* Bookmark Nav Button */
.bookmark-nav {
    background: var(--bg-sub);
    border: 1px solid var(--border);
    color: var(--text-main);
    height: 38px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.bookmark-nav:hover {
    border-color: var(--accent);
    background: var(--bg-card);
    transform: translateY(-1px);
}

.count-badge {
    background: var(--accent-grad);
    color: #000;
    font-size: 11px;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 10px;
}

/* ==========================================================================
   MAIN LAYOUT & SIDEBAR
   ========================================================================== */
.main-layout {
    display: flex;
    min-height: calc(100vh - var(--header-height));
    position: relative;
}

/* Sidebar */
.sidebar-aside {
    width: var(--sidebar-width);
    background: var(--bg-sub);
    border-right: 1px solid var(--border);
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-smooth), transform var(--transition-smooth);
    z-index: 100;
    flex-shrink: 0;
}

.sidebar-aside.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-top {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-top h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

.sidebar-top span {
    font-size: 12px;
    color: var(--text-muted);
}

.toc-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toc-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
}

.toc-link:hover {
    color: var(--text-main);
    background: var(--bg-card);
    transform: translateX(3px);
}

.toc-link.active {
    color: var(--accent);
    background: var(--bg-card);
    border-left-color: var(--accent);
    font-weight: 600;
    box-shadow: inset 0 0 15px rgba(0, 242, 254, 0.05);
}

.toc-icon {
    font-size: 16px;
}

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

.sidebar-card {
    background: var(--bg-main);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-card strong {
    color: var(--text-main);
    display: block;
    margin-bottom: 2px;
}

/* Main Content Area */
.content-main {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: center;
    padding: 40px 24px 120px;
}

.ebook-document {
    width: 100%;
    max-width: 820px;
    display: flex;
    flex-direction: column;
    gap: 80px;
}

/* ==========================================================================
   CHAPTER ARTICLES & TYPOGRAPHY
   ========================================================================== */
.chapter-section {
    scroll-margin-top: calc(var(--header-height) + 30px);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Hero Cover Chapter */
.hero-cover {
    background: linear-gradient(145deg, var(--bg-sub) 0%, var(--bg-card) 100%);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.hero-cover::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0.6;
}

.hero-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--accent);
    background: var(--bg-main);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-highlight);
    margin-bottom: 24px;
}

.hero-title {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(32px, 5vw, 48px);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -1px;
    background: linear-gradient(180deg, var(--text-main) 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.hero-subtitle {
    font-size: clamp(18px, 3vw, 24px);
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 8px;
}

.hero-company {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.hero-meta {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

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

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: var(--radius-md);
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--accent-grad);
    color: #000;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent);
}

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    background: var(--bg-card);
}

/* Chapter Banner */
.chapter-banner {
    padding: 40px 0 24px;
    border-bottom: 2px solid var(--border-highlight);
    margin-bottom: 16px;
}

.chapter-badge {
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 2px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 6px;
}

.chapter-main-title {
    font-family: 'Outfit', sans-serif;
    font-size: var(--h1-size);
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.25;
    letter-spacing: -0.5px;
}

.cheat-sheet-banner {
    border-bottom-color: #f59e0b;
}

.cheat-sheet-banner .chapter-badge {
    color: #f59e0b;
}

/* Headings inside chapters */
.section-title {
    font-family: 'Outfit', sans-serif;
    font-size: var(--h2-size);
    font-weight: 700;
    color: var(--text-main);
    margin-top: 36px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.sub-heading {
    font-family: 'Outfit', sans-serif;
    font-size: var(--h3-size);
    font-weight: 600;
    color: var(--accent);
    margin-top: 24px;
    margin-bottom: 6px;
}

.minor-heading {
    font-size: calc(var(--base-font) * 1.05);
    font-weight: 600;
    color: var(--text-main);
    margin-top: 16px;
}

.body-text {
    color: var(--text-main);
    line-height: 1.8;
}

/* Sleek Flow Diagrams */
.flow-card {
    background: linear-gradient(135deg, var(--bg-sub) 0%, var(--bg-card) 100%);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
    padding: 18px 22px;
    margin: 12px 0;
    box-shadow: var(--shadow);
}

.flow-diagram {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.flow-node {
    background: var(--bg-main);
    border: 1.5px solid var(--accent);
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 14.5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.flow-arrow {
    color: var(--accent);
    font-size: 16px;
    font-weight: 800;
}

/* Label Blocks */
.label-block {
    margin-top: 14px;
    margin-bottom: -4px;
}

.inline-label {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.5px;
}

/* Lists */
.modern-list {
    margin: 12px 0 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modern-list li {
    color: var(--text-main);
    padding-left: 6px;
}

/* Callouts / Alerts */
.callout {
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin: 20px 0;
    border-left: 4px solid var(--accent);
    background: var(--bg-card);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.callout-warning {
    border-left-color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}

.callout-tip {
    border-left-color: var(--accent);
    background: var(--accent-glow);
}

.callout-inner {
    font-weight: 500;
    color: var(--text-main);
}

/* ==========================================================================
   TERMINAL / CODE BLOCKS
   ========================================================================== */
.terminal-container {
    background: var(--terminal-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin: 24px 0;
    box-shadow: var(--shadow);
}

.terminal-bar {
    background: var(--bg-sub);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.mac-dots {
    display: flex;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red {
    background: #ff5f56;
}

.dot.yellow {
    background: #ffbd2e;
}

.dot.green {
    background: #27c93f;
}

.terminal-title {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.copy-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.copy-btn:hover {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.copy-btn.copied {
    background: #10b981;
    color: #fff;
    border-color: #10b981;
}

.terminal-code {
    padding: 18px 20px;
    overflow-x: auto;
    font-family: 'Fira Code', monospace;
    font-size: 13.5px;
    line-height: 1.6;
    color: #38bdf8;
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin: 24px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-sub);
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 15px;
}

.modern-table td,
.modern-table th {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.modern-table tr:last-child td {
    border-bottom: none;
}

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

.modern-table tr:hover {
    background: var(--bg-hover);
}

/* ==========================================================================
   INTERACTIVE BAB 7 FLASHCARDS & Q&A
   ========================================================================== */
.qa-toolbar {
    background: var(--bg-card);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.qa-toolbar-info {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
}

.qa-toolbar-btns {
    display: flex;
    gap: 8px;
}

.btn-sm {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-sm:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

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

.btn-outline:hover {
    background: var(--accent-glow);
}

/* Flashcard Box */
.qa-card {
    background: var(--bg-sub);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    overflow: hidden;
    transition: all var(--transition-fast);
}

.qa-card:hover {
    border-color: var(--border-highlight);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.qa-card-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    user-select: none;
    background: var(--bg-sub);
    transition: background var(--transition-fast);
}

.qa-card-header:hover {
    background: var(--bg-card);
}

.qa-number {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 13px;
    color: #000;
    background: var(--accent-grad);
    padding: 4px 10px;
    border-radius: 6px;
}

.qa-question-text {
    flex: 1;
    font-family: 'Outfit', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.qa-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: transform 0.2s;
}

.btn-icon:hover {
    transform: scale(1.2);
}

.btn-icon.bookmarked {
    filter: drop-shadow(0 0 6px #f59e0b);
}

.chevron {
    color: var(--text-muted);
    font-size: 12px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.qa-card.open .chevron {
    transform: rotate(180deg);
}

.qa-card-body {
    max-height: 0;
    overflow: hidden;
    padding: 0 20px;
    background: var(--bg-main);
    border-top: 1px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
}

.qa-card.open .qa-card-body {
    max-height: 2000px;
    padding: 20px;
    border-top-color: var(--border);
    opacity: 1;
}

/* ==========================================================================
   BOOKMARKS MODAL OVERLAY
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 24px;
}

.modal-dialog {
    background: var(--bg-sub);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-top {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-top h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    color: var(--text-main);
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.btn-close-modal:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-bookmarks {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    line-height: 1.8;
}

.bookmark-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.bookmark-item:hover {
    border-color: var(--accent);
    transform: translateX(4px);
}

.bookmark-item-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-main);
}

.remove-bookmark {
    background: rgba(239, 68, 68, 0.1);
    border: none;
    color: #ef4444;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

.remove-bookmark:hover {
    background: #ef4444;
    color: #fff;
}

.modal-bottom {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    text-align: right;
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE & TABLET)
   ========================================================================== */
@media (max-width: 900px) {
    :root {
        --sidebar-width: 280px;
    }

    .sidebar-aside {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.7);
    }

    .sidebar-aside.collapsed {
        transform: translateX(-100%);
        margin-left: 0;
    }

    .header-center {
        max-width: 200px;
        margin: 0 12px;
    }
}

@media (max-width: 600px) {
    .top-header {
        padding: 0 14px;
    }

    .brand-name {
        display: none;
    }

    .header-center {
        margin: 0 8px;
    }

    #search-input {
        font-size: 13px;
        padding: 0 14px 0 34px;
    }

    .search-icon {
        left: 10px;
    }

    .search-shortcut {
        display: none;
    }

    .ctrl-group.font-ctrl {
        display: none;
    }

    .content-main {
        padding: 24px 16px 80px;
    }

    .hero-cover {
        padding: 40px 20px;
    }
}