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

:root {
    /* Blue Tech Color Palette */
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-300: #93c5fd;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-800: #1e40af;
    --blue-900: #1e3a8a;
    --blue-950: #172554;

    /* Neutral */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --gray-950: #020617;

    /* UI Tokens */
    --sidebar-width: 280px;
    --sidebar-bg: #ffffff;
    --main-bg: #f0f4fa;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--main-bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

ul, ol {
    list-style-position: inside;
}

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--blue-700);
}

pre {
    font-family: var(--font-mono);
    line-height: 1.6;
}

/* ===========================
   Layout
   =========================== */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--gray-700);
    border-radius: 2px;
    transition: all 0.3s;
}

.mobile-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}

/* ===========================
   Sidebar
   =========================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform 0.3s ease;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--blue-700);
}

.logo svg {
    width: 28px;
    height: 28px;
    color: var(--blue-600);
}

.sidebar-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.nav-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--blue-50);
    color: var(--blue-700);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px -2px rgb(59 130 246 / 0.4);
}

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

.nav-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--blue-600);
    background: var(--blue-100);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-item.active .nav-badge {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.nav-text {
    font-size: 13.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-divider {
    padding: 16px 12px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 49;
}

/* ===========================
   Main Content
   =========================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

/* ===========================
   Hero Section (Index)
   =========================== */
.hero-section {
    position: relative;
    padding: 80px 60px 60px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 50%, #e0e7ff 100%);
    overflow: hidden;
    display: flex;
    gap: 40px;
    align-items: center;
}

.hero-content {
    flex: 1;
    max-width: 600px;
    z-index: 2;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: white;
    border: 1px solid var(--blue-200);
    border-radius: 999px;
    font-size: 13px;
    color: var(--blue-700);
    font-weight: 500;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgb(59 130 246 / 0.1);
}

.hero-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.hero-title {
    font-size: 42px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 20px;
    color: var(--gray-900);
}

.gradient-text {
    background: linear-gradient(135deg, var(--blue-500), var(--indigo-600, #4f46e5));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-desc {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 32px;
}

.hero-actions {
    display: flex;
    gap: 14px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
    color: white;
    box-shadow: 0 4px 14px rgb(59 130 246 / 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgb(59 130 246 / 0.5);
}

.btn-primary svg {
    width: 18px;
    height: 18px;
}

.btn-outline {
    background: white;
    color: var(--blue-700);
    border: 1.5px solid var(--blue-300);
}

.btn-outline:hover {
    background: var(--blue-50);
    border-color: var(--blue-400);
}

.hero-stats {
    display: flex;
    gap: 40px;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-item strong {
    font-size: 28px;
    font-weight: 700;
    color: var(--blue-700);
}

.stat-item span {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Hero Decoration - Floating Cards */
.hero-decoration {
    flex: 1;
    position: relative;
    min-height: 300px;
    max-width: 450px;
}

.floating-card {
    position: absolute;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.card-1 {
    top: 20px;
    left: 20px;
    width: 340px;
    animation: float 6s ease-in-out infinite;
}

.card-2 {
    bottom: 20px;
    right: 0;
    width: 240px;
    animation: float 6s ease-in-out infinite;
    animation-delay: -3s;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.floating-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--border-color);
}

.dot-red, .dot-yellow, .dot-green {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot-red { background: #ef4444; }
.dot-yellow { background: #eab308; }
.dot-green { background: #22c55e; }

.card-title {
    margin-left: 8px;
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.floating-card-body {
    padding: 16px;
}

.floating-card-body pre {
    font-size: 13px;
    color: var(--gray-800);
}

.floating-card .kw {
    color: var(--blue-600);
    font-weight: 600;
}

.floating-card .num {
    color: #f97316;
}

.result-table {
    padding: 12px;
    font-size: 13px;
    font-family: var(--font-mono);
}

.result-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 6px 10px;
    border-bottom: 1px solid var(--gray-100);
}

.result-row.header {
    background: var(--blue-50);
    color: var(--blue-700);
    font-weight: 600;
    border-radius: 6px 6px 0 0;
}

/* ===========================
   Section Headers
   =========================== */
.section-header {
    text-align: center;
    margin-bottom: 40px;
}

.section-header h2 {
    font-size: 30px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

/* ===========================
   Chapters Grid (Index)
   =========================== */
.chapters-section {
    padding: 60px 60px;
}

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

.chapter-card {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.chapter-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-xl);
    border-color: var(--blue-300);
}

.chapter-card-header {
    padding: 24px;
    color: white;
    min-height: 140px;
}

.gradient-1 { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.gradient-2 { background: linear-gradient(135deg, #3b82f6, #1e40af); }
.gradient-3 { background: linear-gradient(135deg, #22d3ee, #0284c7); }
.gradient-4 { background: linear-gradient(135deg, #818cf8, #4338ca); }
.gradient-5 { background: linear-gradient(135deg, #38bdf8, #2563eb); }

.chapter-number {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
    backdrop-filter: blur(4px);
}

.chapter-card-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
}

.chapter-card-header p {
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.5;
}

.chapter-card-footer {
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--blue-600);
    font-weight: 500;
}

.chapter-card-footer svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s;
}

.chapter-card:hover .chapter-card-footer svg {
    transform: translateX(4px);
}

/* ===========================
   Features Section
   =========================== */
.features-section {
    padding: 60px;
    background: white;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    max-width: 1000px;
    margin: 0 auto;
}

.feature-card {
    text-align: center;
    padding: 32px 24px;
    border-radius: var(--radius-lg);
    background: var(--gray-50);
    transition: all 0.3s ease;
}

.feature-card:hover {
    background: var(--blue-50);
    transform: translateY(-4px);
}

.feature-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.feature-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-900);
}

.feature-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ===========================
   Footer
   =========================== */
.site-footer {
    padding: 30px 60px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    background: white;
    border-top: 1px solid var(--border-color);
}

/* ===========================
   Chapter Page
   =========================== */
.chapter-header {
    padding: 50px 40px 40px;
    color: white;
    position: relative;
    overflow: hidden;
}

.chapter-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.chapter-header-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
}

.chapter-tag {
    display: inline-block;
    padding: 5px 14px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 14px;
    backdrop-filter: blur(8px);
}

.chapter-header h1 {
    font-size: 34px;
    font-weight: 700;
    margin-bottom: 10px;
}

.chapter-subtitle {
    font-size: 16px;
    opacity: 0.9;
    margin-bottom: 24px;
}

.chapter-nav {
    display: flex;
    gap: 12px;
}

.chapter-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.chapter-nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chapter-nav-btn svg {
    width: 16px;
    height: 16px;
}

/* ===========================
   Three Cards Layout
   =========================== */
.cards-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    padding: 24px;
}

.content-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 140px);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--gray-50);
    flex-shrink: 0;
}

.card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 10px;
}

.icon-concept { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.icon-demo { background: linear-gradient(135deg, #cffafe, #a5f3fc); }
.icon-exercise { background: linear-gradient(135deg, #ede9fe, #ddd6fe); }

.card-header h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 2px;
}

.card-header p {
    font-size: 13px;
    color: var(--text-muted);
}

.card-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.card-body::-webkit-scrollbar {
    width: 6px;
}

.card-body::-webkit-scrollbar-track {
    background: transparent;
}

.card-body::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.card-body::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ===========================
   Concept Blocks
   =========================== */
.concept-block {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px dashed var(--gray-200);
}

.concept-block:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.concept-block h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--blue-700);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.concept-block h3::before {
    content: '';
    width: 4px;
    height: 18px;
    background: linear-gradient(180deg, var(--blue-400), var(--blue-600));
    border-radius: 2px;
}

.concept-block p {
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.75;
}

.concept-block ul, .concept-block ol {
    margin-bottom: 10px;
    padding-left: 4px;
}

.concept-block li {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.8;
    margin-bottom: 4px;
}

.concept-block li::marker {
    color: var(--blue-500);
}

.concept-block ul li {
    list-style: none;
    position: relative;
    padding-left: 18px;
}

.concept-block ul li::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: var(--blue-500);
    font-weight: bold;
}

.concept-highlight {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-left: 3px solid var(--blue-500);
    padding: 12px 14px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 12px 0;
    font-size: 13.5px;
    color: var(--blue-800);
    line-height: 1.7;
}

.sql-syntax {
    background: var(--gray-900);
    color: #e2e8f0;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.7;
    margin: 10px 0;
    border: 1px solid var(--gray-800);
}

.sql-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
}

.sql-table th, .sql-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.sql-table th {
    background: var(--blue-50);
    color: var(--blue-800);
    font-weight: 600;
    font-size: 12.5px;
}

.sql-table td {
    color: var(--text-secondary);
}

.badge-ddl, .badge-dml, .badge-dql, .badge-dcl {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: white;
}

.badge-ddl { background: #f97316; }
.badge-dml { background: #22c55e; }
.badge-dql { background: #3b82f6; }
.badge-dcl { background: #8b5cf6; }

/* ===========================
   Demo Blocks
   =========================== */
.demo-block {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px dashed var(--gray-200);
}

.demo-block:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.demo-block h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--blue-200);
    display: inline-block;
}

.demo-table-wrapper {
    margin-bottom: 12px;
}

.demo-table-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.demo-table {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

.demo-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.demo-table th {
    background: var(--gray-100);
    color: var(--gray-700);
    font-weight: 600;
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

.demo-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--text-secondary);
    white-space: nowrap;
}

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

.null-val {
    color: var(--text-muted);
    font-style: italic;
    font-size: 11px;
}

/* SQL Code Block */
.sql-code-block {
    margin: 14px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--gray-800);
}

.sql-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
}

.sql-label {
    font-size: 11px;
    font-weight: 700;
    color: #60a5fa;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #334155;
    color: #94a3b8;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: #475569;
    color: #e2e8f0;
}

.copy-btn svg {
    width: 13px;
    height: 13px;
}

.copy-btn.copied {
    background: #166534;
    color: #86efac;
}

.sql-code {
    margin: 0;
    padding: 14px 16px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 13px;
    line-height: 1.7;
    overflow-x: auto;
}

/* SQL Syntax Highlighting (basic) */
.sql-code {
    counter-reset: line;
}

/* Result Block */
.result-block {
    margin: 14px 0;
}

.result-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--green-700, #15803d);
    margin-bottom: 6px;
    user-select: none;
}

.result-title svg {
    width: 14px;
    height: 14px;
    color: #22c55e;
}

/* 可折叠的查询结果标题 */
.result-toggle {
    cursor: pointer;
    transition: opacity 0.2s;
}

.result-toggle:hover {
    opacity: 0.8;
}

.result-toggle .result-arrow {
    width: 12px;
    height: 12px;
    color: var(--green-600);
    transition: transform 0.3s ease;
}

.result-count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 500;
    color: var(--green-600);
    background: #dcfce7;
    padding: 2px 8px;
    border-radius: 10px;
}

.result-content {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.result-table-wrapper {
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
}

.result-table-sql {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    font-family: var(--font-mono);
}

.result-table-sql th {
    background: #dcfce7;
    color: #166534;
    font-weight: 600;
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid #bbf7d0;
    white-space: nowrap;
}

.result-table-sql td {
    padding: 6px 10px;
    border-bottom: 1px solid #dcfce7;
    color: #14532d;
    white-space: nowrap;
}

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

.demo-explanation {
    margin-top: 12px;
    padding: 10px 12px;
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 13px;
    color: #92400e;
    line-height: 1.7;
}

/* ===========================
   Exercise Blocks
   =========================== */
.exercise-block {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
}

.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.table-preview-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    background: #fff;
    border: 1px solid var(--gray-300);
    border-radius: 14px;
    font-size: 12px;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
}
.table-preview-btn:hover {
    background: var(--blue-50);
    border-color: var(--blue-300);
    color: var(--blue-600);
}
.table-preview-btn svg {
    width: 14px;
    height: 14px;
}
.table-preview-btn.active {
    background: var(--blue-100);
    border-color: var(--blue-400);
    color: var(--blue-700);
}

.table-preview-content {
    display: none;
    margin-bottom: 12px;
    padding: 10px;
    background: #fff;
    border: 1px dashed var(--blue-200);
    border-radius: var(--radius-sm);
}
.table-preview-content.show {
    display: block;
    animation: fadeInDown 0.25s ease;
}
.table-preview-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--blue-700);
    margin-bottom: 8px;
}

.small-table th,
.small-table td {
    padding: 6px 10px;
    font-size: 12px;
}

.answer-sql {
    background: var(--dark-bg);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--dark-text);
    overflow-x: auto;
    margin: 0;
    white-space: pre;
}

.answer-result {
    margin-top: 12px;
    border-top: 1px solid var(--green-200);
    padding-top: 12px;
}
.answer-result-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--green-700);
    margin-bottom: 8px;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.exercise-block:hover {
    border-color: var(--blue-300);
    background: #f8fafc;
}

.exercise-number {
    display: inline-block;
    padding: 2px 10px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.exercise-question {
    font-size: 14px;
    color: var(--gray-800);
    line-height: 1.7;
    margin-bottom: 12px;
}

/* SQL 输入区 */
.sql-input-wrapper {
    margin-bottom: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sql-input-wrapper:focus-within {
    border-color: var(--blue-400);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.15);
}

.sql-input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--gray-200);
}

.sql-input-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.run-sql-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.run-sql-btn:hover {
    background: linear-gradient(135deg, var(--blue-600), var(--blue-700));
    transform: translateY(-1px);
}

.run-sql-btn:active {
    transform: translateY(0);
}

.run-sql-btn svg {
    width: 13px;
    height: 13px;
}

.run-sql-btn.running {
    opacity: 0.7;
    pointer-events: none;
}

.sql-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: none;
    outline: none;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--gray-800);
    background: white;
}

.sql-textarea::placeholder {
    color: var(--text-muted);
}

.sql-feedback {
    padding: 10px 12px;
    font-size: 13px;
    border-top: 1px solid var(--gray-200);
    line-height: 1.6;
}

.sql-feedback.success {
    background: #ecfdf5;
    color: #065f46;
    border-top-color: #a7f3d0;
}

.sql-feedback.success::before {
    content: '✅ 回答正确！';
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
    color: #059669;
}

.sql-feedback.error {
    background: #fef2f2;
    color: #991b1b;
    border-top-color: #fecaca;
}

.sql-feedback.error::before {
    content: '❌ 还不对，再试试';
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
    color: #dc2626;
}

.sql-feedback.info {
    background: #eff6ff;
    color: #1e40af;
    border-top-color: #bfdbfe;
}

.sql-feedback pre {
    margin: 6px 0 0;
    background: rgba(0, 0, 0, 0.05);
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
}

.sql-feedback.hint {
    background: #fffbeb;
    color: #92400e;
    border-top-color: #fde68a;
}

.sql-feedback.hint::before {
    content: '💡 小提示';
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
    color: #d97706;
}

.toggle-answer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 14px;
    background: white;
    color: var(--blue-600);
    border: 1px solid var(--blue-300);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-answer-btn:hover {
    background: var(--blue-50);
    border-color: var(--blue-400);
}

.toggle-answer-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.3s;
}

.exercise-block.show-answer .toggle-answer-btn svg {
    transform: rotate(180deg);
}

.answer-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.exercise-block.show-answer .answer-content {
    max-height: 500px;
}

.answer-inner {
    margin-top: 12px;
    padding: 12px;
    background: #ecfdf5;
    border-radius: var(--radius-sm);
    border: 1px solid #a7f3d0;
}

.answer-label {
    font-size: 11px;
    font-weight: 700;
    color: #059669;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.answer-inner pre {
    font-size: 12.5px;
    color: #064e3b;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.7;
    font-family: var(--font-mono);
}

/* ===========================
   Bottom Nav
   =========================== */
.bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 24px;
    margin: 0 24px 24px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.bottom-nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    flex: 1;
    max-width: 280px;
}

.bottom-nav-btn.prev {
    justify-content: flex-start;
    color: var(--text-secondary);
}

.bottom-nav-btn.next {
    justify-content: flex-end;
    color: var(--blue-700);
    background: var(--blue-50);
}

.bottom-nav-btn:hover {
    background: var(--blue-100);
}

.bottom-nav-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.bottom-nav-btn .nav-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.bottom-nav-btn .nav-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.progress-indicator {
    text-align: center;
    flex: 1;
    max-width: 200px;
}

.progress-indicator > span {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue-400), var(--blue-600));
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ===========================
   Error Page
   =========================== */
.error-page {
    text-align: center;
    padding: 120px 40px;
}

.error-code {
    font-size: 120px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--blue-500), var(--indigo-600, #6366f1));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 20px;
}

.error-page h1 {
    font-size: 28px;
    margin-bottom: 10px;
    color: var(--gray-900);
}

.error-page p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 1400px) {
    .cards-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .content-card {
        max-height: none;
    }

    .card-body {
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 1024px) {
    .hero-section {
        padding: 50px 30px;
        flex-direction: column;
    }

    .hero-decoration {
        display: none;
    }

    .hero-title {
        font-size: 32px;
    }

    .chapters-section,
    .features-section {
        padding: 40px 30px;
    }

    .site-footer {
        padding: 24px 30px;
    }
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        top: 56px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding-top: 56px;
    }

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

    .hero-title {
        font-size: 26px;
    }

    .hero-stats {
        gap: 24px;
    }

    .stat-item strong {
        font-size: 22px;
    }

    .chapters-section,
    .features-section {
        padding: 30px 20px;
    }

    .section-header h2 {
        font-size: 24px;
    }

    .chapter-header {
        padding: 30px 20px;
    }

    .chapter-header h1 {
        font-size: 24px;
    }

    .cards-container {
        padding: 16px;
        gap: 12px;
    }

    .card-header,
    .card-body {
        padding: 16px;
    }

    .bottom-nav {
        flex-wrap: wrap;
        margin: 0 16px 16px;
        padding: 14px;
        gap: 12px;
    }

    .bottom-nav-btn {
        max-width: none;
        flex: 1 1 40%;
    }

    .progress-indicator {
        order: 3;
        flex: 1 1 100%;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .hero-actions {
        flex-direction: column;
    }

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

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

    .chapter-nav-btn {
        justify-content: center;
    }
}
