/* ============================================
   Q&A 交流学习系统 - 现代风格 v3.0 (圆桌优化版)
   ============================================ */

:root {
    --primary: #6366F1;
    --primary-light: #E0E7FF;
    --primary-dark: #4F46E5;
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --info: #06B6D4;
    --pink: #EC4899;
    --orange: #F97316;
    --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;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
    --shadow-glow: 0 0 40px rgba(99,102,241,0.15);
    --text-primary: #E8EAED;
    --text-secondary: #B0B3B8;
    --text-tertiary: #8A8D91;
    --text-muted: #6B6E73;
    --bg-surface: rgba(30,41,59,0.5);
    --bg-border: rgba(255,255,255,0.08);
    --card-bg: rgba(30,41,59,0.5);
    --border-color: rgba(255,255,255,0.08);
    --touch-min: 44px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--text-primary);
    background: #0B1120;
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    background-attachment: fixed;
    padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--primary); text-decoration: none; transition: all 0.15s; }
a:hover { color: #818CF8; }

/* ========== Header ========== */
.header {
    background: rgba(11,17,32,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.logo {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-900);
}
.logo a { color: #F1F5F9; text-decoration: none; }
.logo-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--pink));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 16px; font-weight: 700;
}
.nav { display: flex; align-items: center; gap: 2px; }
.nav a {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
}
.nav a:hover { background: rgba(255,255,255,0.05); color: white; text-decoration: none; }
.nav a.active { background: rgba(99,102,241,0.15); color: #A5B4FC; }
.nav .btn-logout { color: #FCA5A5; min-height: var(--touch-min); }
.nav .btn-logout:hover { background: rgba(239,68,68,0.1); }
.nav .user-name {
    color: var(--text-secondary); font-weight: 500; margin-right: 6px;
    font-size: 13px; padding: 6px 12px; background: rgba(255,255,255,0.05);
    border-radius: 20px; min-height: var(--touch-min); display: flex; align-items: center;
}

/* ========== Bottom Tab Navigation (P0: Mobile) ========== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(11,17,32,0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.06);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-items {
    display: flex;
    max-width: 500px;
    margin: 0 auto;
    justify-content: space-around;
    align-items: center;
    height: 56px;
}
.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-tertiary);
    font-size: 11px;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    padding: 4px 8px;
    border-radius: 10px;
    transition: all 0.15s;
}
.bottom-nav-item.active { color: #818CF8; }
.bottom-nav-item .bn-icon { font-size: 20px; }

/* Show bottom nav on mobile, add padding to body */
@media (max-width: 768px) {
    .bottom-nav { display: block; }
    body { padding-bottom: 60px; }
    .container { padding-bottom: 72px; }
}

/* ========== Container ========== */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 20px; }

/* ========== Page Hero ========== */
.page-hero {
    text-align: center;
    padding: 40px 0 32px;
}
.page-hero h1 {
    font-size: 28px;
    font-weight: 700;
    color: #F1F5F9;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}
.page-hero .hero-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
}

/* ========== Cards ========== */
.card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--bg-border);
    backdrop-filter: blur(12px);
    transition: all 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 600; color: #F1F5F9; }

/* ========== Track selector ========== */
.track-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 32px;
}
.track-card {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    padding: 40px 28px;
    text-align: center;
    border: 1px solid var(--bg-border);
    backdrop-filter: blur(12px);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    color: #E2E8F0;
    position: relative;
    overflow: hidden;
    min-height: var(--touch-min);
}
.track-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 4px;
    opacity: 0;
    transition: opacity 0.3s;
}
.track-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    text-decoration: none;
}
.track-card:hover::before { opacity: 1; }
.track-card:active { transform: translateY(-1px) scale(0.98); }
.track-card .track-icon {
    width: 72px; height: 72px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
    transition: transform 0.3s;
}
.track-card:hover .track-icon { transform: scale(1.1); }
.track-card .track-name { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.track-card .track-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

.track-card.track-weight_loss::before { background: linear-gradient(90deg, var(--success), #34D399); opacity: 1; }
.track-card.track-weight_loss .track-icon { background: linear-gradient(135deg, #D1FAE5, #A7F3D0); }
.track-card.track-weight_loss:hover { border-color: var(--success); }

.track-card.track-ai_agent::before { background: linear-gradient(90deg, var(--primary), var(--pink)); opacity: 1; }
.track-card.track-ai_agent .track-icon { background: linear-gradient(135deg, var(--primary-light), #C7D2FE); }
.track-card.track-ai_agent:hover { border-color: var(--primary); }

/* New tracks auto-style (orange gradient for e-commerce etc) */
.track-card::before { background: linear-gradient(90deg, var(--primary), var(--pink)); }
.track-card .track-icon { background: linear-gradient(135deg, var(--primary-light), #C7D2FE); }
.track-card:hover { border-color: var(--primary); }
.track-card.track-ai_ecommerce::before { background: linear-gradient(90deg, var(--orange), #FB923C); opacity: 1; }
.track-card.track-ai_ecommerce .track-icon { background: linear-gradient(135deg, #FED7AA, #FDBA74); }
.track-card.track-ai_ecommerce:hover { border-color: var(--orange); }

/* ========== Section header ========== */
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.section-title {
    font-size: 18px; font-weight: 700; color: #F1F5F9;
    display: flex; align-items: center; gap: 8px;
    letter-spacing: -0.3px;
}
.section-title-icon {
    width: 8px; height: 24px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--primary), var(--pink));
}
.section-tabs {
    display: flex; gap: 4px;
    background: rgba(255,255,255,0.05);
    padding: 3px;
    border-radius: var(--radius-sm);
}
.section-tabs a {
    padding: 8px 16px; border-radius: 6px; font-size: 13px;
    color: var(--text-secondary); text-decoration: none; font-weight: 500;
    transition: all 0.15s;
    min-height: var(--touch-min);
    display: flex; align-items: center; justify-content: center;
}
.section-tabs a.active {
    background: rgba(255,255,255,0.1); color: white; font-weight: 600;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.section-tabs a:hover { color: rgba(255,255,255,0.9); text-decoration: none; }
.section-tabs a:active { transform: scale(0.95); }

/* ========== Continue Learning (P0: Homepage shortcut) ========== */
.continue-learning {
    margin-bottom: 24px;
}
.continue-learning h3 {
    font-size: 15px; font-weight: 600; color: var(--text-secondary);
    margin-bottom: 12px; padding: 0 4px;
}
.continue-scroll {
    display: flex; gap: 12px; overflow-x: auto; overflow-y: hidden; padding: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}
.continue-scroll::-webkit-scrollbar { display: none; }
.continue-card {
    flex-shrink: 0; width: 200px;
    background: var(--bg-surface); border: 1px solid var(--bg-border);
    border-radius: var(--radius-md); padding: 14px; text-decoration: none;
    transition: all 0.2s; min-height: var(--touch-min);
}
.continue-card:hover { border-color: rgba(99,102,241,0.3); transform: translateY(-2px); }
.continue-card:active { transform: scale(0.97); }
.continue-card .cc-title { font-size: 13px; color: var(--text-primary); font-weight: 500; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-card .cc-meta { font-size: 11px; color: var(--text-tertiary); display: flex; gap: 8px; align-items: center; }
.continue-card .cc-progress { height: 3px; background: rgba(255,255,255,0.06); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.continue-card .cc-progress-bar { height: 100%; background: var(--primary); border-radius: 2px; }

/* ========== Stats grid ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px; margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-surface); border: 1px solid var(--bg-border);
    border-radius: var(--radius-md); padding: 16px; text-align: center;
    min-height: var(--touch-min);
}
.stat-value { font-size: 24px; font-weight: 700; color: #818CF8; }
.stat-label { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }

/* ========== Question list ========== */
.question-item {
    padding: 18px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex; gap: 14px;
    transition: background 0.15s;
    margin: 0 -16px; padding-left: 16px; padding-right: 16px;
    min-height: var(--touch-min);
}
.question-item:last-child { border-bottom: none; }
.question-item:hover { background: rgba(255,255,255,0.03); border-radius: var(--radius-sm); }
.question-item:active { background: rgba(255,255,255,0.06); }
.question-item .q-status {
    flex-shrink: 0;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
    margin-top: 1px;
}
.q-status.answered { background: rgba(16,185,129,0.15); color: #34D399; }
.q-status.pending { background: rgba(245,158,11,0.15); color: #FBBF24; }
.q-status.closed { background: rgba(255,255,255,0.05); color: var(--text-tertiary); }
.question-item .q-content { flex: 1; min-width: 0; }
.question-item .q-title {
    font-size: 15px; font-weight: 600;
    color: #F1F5F9; margin-bottom: 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.question-item .q-title a { color: #F1F5F9; text-decoration: none; }
.question-item .q-title a:hover { color: var(--primary); }
.question-item .q-meta {
    font-size: 13px; color: var(--text-tertiary);
    display: flex; gap: 16px; align-items: center;
}

/* ========== Course grid ========== */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
    gap: 20px;
}
.course-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--bg-border);
    backdrop-filter: blur(12px);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none; color: #E2E8F0;
    min-height: var(--touch-min);
}
.course-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    text-decoration: none;
}
.course-card:active { transform: translateY(-1px) scale(0.98); }
.course-card .course-cover {
    width: 100%; height: 150px;
    background: linear-gradient(135deg, #1E293B, #334155);
    display: flex; align-items: center; justify-content: center;
    font-size: 48px; position: relative;
    overflow: hidden;
}
.course-card .course-cover img { width: 100%; height: 100%; object-fit: cover; }
.course-card .course-duration {
    position: absolute; bottom: 10px; right: 10px;
    background: rgba(0,0,0,0.7); color: white;
    font-size: 12px; padding: 3px 8px; border-radius: 6px;
    font-weight: 500;
}
.course-card .course-body { padding: 16px; }
.course-card .course-title {
    font-size: 15px; font-weight: 600; color: #F1F5F9; margin-bottom: 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.course-card .course-meta {
    font-size: 13px; color: var(--text-tertiary);
    display: flex; gap: 12px; align-items: center;
}
.course-card .course-progress {
    height: 4px; background: rgba(255,255,255,0.06); border-radius: 2px;
    margin-top: 8px; overflow: hidden;
}
.course-card .course-progress .bar {
    height: 100%; background: linear-gradient(90deg, var(--primary), var(--pink));
    border-radius: 2px; transition: width 0.3s;
}
.course-card .tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; }
.course-card .tag-success { background: rgba(16,185,129,0.15); color: #34D399; }
.course-card .tag-info { background: rgba(99,102,241,0.15); color: #A5B4FC; }

/* ========== Buttons ========== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; border: none; cursor: pointer;
    transition: all 0.15s; text-decoration: none;
    min-height: var(--touch-min);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border: 1px solid var(--bg-border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: #818CF8; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 6px 14px; font-size: 12px; min-height: 36px; }
.btn-block { width: 100%; }

/* ========== Form ========== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 12px 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 14px; outline: none;
    transition: border-color 0.15s; font-family: inherit;
    min-height: var(--touch-min);
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); }
.form-input::placeholder { color: var(--text-muted); }

/* ========== Tags ========== */
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; display: inline-block; }
.tag-success { background: rgba(16,185,129,0.15); color: #34D399; }
.tag-info { background: rgba(99,102,241,0.15); color: #A5B4FC; }
.tag-warning { background: rgba(245,158,11,0.15); color: #FBBF24; }
.tag-danger { background: rgba(239,68,68,0.15); color: #FCA5A5; }

.track-badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: rgba(99,102,241,0.15); color: #A5B4FC; }
.track-badge.weight_loss { background: rgba(16,185,129,0.15); color: #34D399; }

/* ========== Empty state ========== */
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-icon { font-size: 40px; display: block; margin-bottom: 12px; opacity: 0.5; }

/* ========== Pagination ========== */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px;
    text-decoration: none; color: var(--text-secondary);
    min-height: var(--touch-min); display: flex; align-items: center; justify-content: center;
    min-width: var(--touch-min);
}
.pagination a:hover { background: rgba(255,255,255,0.05); text-decoration: none; }
.pagination span.active { background: var(--primary); color: white; font-weight: 600; }

/* ========== Login ========== */
.login-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-box {
    background: var(--bg-surface); border: 1px solid var(--bg-border);
    border-radius: var(--radius-xl); padding: 40px 32px; width: 100%; max-width: 400px;
    backdrop-filter: blur(20px);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand-icon {
    width: 56px; height: 56px; border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--pink));
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 28px; font-weight: 700; margin: 0 auto 16px;
}
.login-brand h1 { font-size: 22px; color: #F1F5F9; margin-bottom: 6px; }
.login-brand .subtitle { font-size: 14px; color: var(--text-tertiary); }
.login-divider { height: 1px; background: var(--bg-border); margin: 24px 0; }
.form-hint { font-size: 12px; color: var(--text-muted); line-height: 1.6; text-align: center; }
.login-footer { text-align: center; margin-top: 24px; }
.login-footer a { font-size: 13px; color: var(--text-tertiary); }

/* ========== Toast ========== */
.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-100px);
    background: rgba(30,41,59,0.98); border: 1px solid var(--bg-border);
    color: var(--text-primary); padding: 12px 24px; border-radius: var(--radius-sm);
    font-size: 14px; z-index: 9999; transition: transform 0.3s; pointer-events: none;
    box-shadow: var(--shadow-lg);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast-error { border-color: rgba(239,68,68,0.3); }
.toast-success { border-color: rgba(16,185,129,0.3); }

/* ========== Modal ========== */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    z-index: 1000; display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: rgba(30,41,59,0.95); border-radius: var(--radius-xl);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 0; width: 90%; max-width: 500px; max-height: 85vh;
    overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal h3 { font-size: 18px; margin-bottom: 16px; color: #F1F5F9; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .track-selector { grid-template-columns: 1fr; }
    .course-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .header-inner { padding: 0 12px; flex-wrap: wrap; height: auto; padding-bottom: 0; }
    .nav {
        display: flex; flex-wrap: wrap; gap: 1px; align-items: center;
        width: 100%; justify-content: flex-start; padding: 4px 0;
    }
    .nav a { padding: 8px 10px; font-size: 12px; white-space: nowrap; min-height: 36px; }
    .nav .user-name { font-size: 11px; padding: 4px 8px; margin-right: 2px; min-height: 36px; }
    .nav .btn-logout { padding: 6px 8px; font-size: 12px; min-height: 36px; }
    .logo { font-size: 15px; }
    .logo a { font-size: 15px; }
    .section-tabs {
        justify-content: center; flex-wrap: wrap; gap: 2px; padding: 3px;
        margin-bottom: 16px; overflow-x: auto; scrollbar-width: none;
    }
    .section-tabs a { padding: 8px 12px; font-size: 12px; min-height: 36px; }
    .login-box { padding: 32px 24px; }
    .container { padding: 16px 12px; padding-bottom: 72px; }
    .question-item { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
    .section-header { flex-wrap: wrap; gap: 8px; }
    .section-title { font-size: 18px; }
    .pinned-area { padding: 0 2px; }
    .pinned-card { padding: 14px 16px; }
    .course-cover { height: 160px; }
    .btn { padding: 12px 18px; min-height: var(--touch-min); }
    .form-input, .form-select { min-height: var(--touch-min); }
}

@media (max-width: 480px) {
    .nav a { padding: 6px 7px; font-size: 11px; min-height: 32px; }
    .nav .user-name { display: none; }
    .section-tabs a { padding: 6px 10px; font-size: 12px; min-height: 32px; }
    .container { padding: 12px 10px; padding-bottom: 72px; }
    .track-card { padding: 28px 20px; }
    .stat-value { font-size: 20px; }
}

/* Markdown answer content */
.answer-content-md h1, .answer-content-md h2, .answer-content-md h3 { color: #fff; margin: 12px 0 6px; }
.answer-content-md h1 { font-size: 18px; }
.answer-content-md h2 { font-size: 16px; }
.answer-content-md h3 { font-size: 15px; }
.answer-content-md p { margin: 8px 0; }
.answer-content-md ul, .answer-content-md ol { margin: 8px 0; padding-left: 20px; }
.answer-content-md li { margin: 4px 0; }
.answer-content-md strong { color: #FBBF24; font-weight: 700; }
.answer-content-md em { color: #60A5FA; }
.answer-content-md code { background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.answer-content-md pre { background: rgba(0,0,0,0.3); padding: 12px; border-radius: 8px; overflow-x: auto; margin: 8px 0; }
.answer-content-md blockquote { border-left: 3px solid rgba(255,255,255,0.2); padding-left: 12px; margin: 8px 0; color: var(--text-secondary); }
.answer-content-md table { border-collapse: collapse; margin: 8px 0; width: 100%; }
.answer-content-md th, .answer-content-md td { border: 1px solid rgba(255,255,255,0.1); padding: 6px 10px; }
.answer-content-md th { background: rgba(255,255,255,0.05); }

/* ============================================
   Course pages - Modern v4
   ============================================ */

/* --- Common course page layout --- */
.course-page { padding-top: 8px; padding-bottom: 96px; }
.course-page .container { max-width: 900px; }

/* Back link strip */
.back-strip {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--text-secondary);
    text-decoration: none; margin-bottom: 16px;
    min-height: var(--touch-min); padding: 0 4px;
}
.back-strip:hover { color: var(--primary); }
.back-strip .back-arrow { font-size: 16px; }

/* --- Course Hero (detail page) --- */
.course-hero {
    position: relative;
    border-radius: var(--radius-xl);
    overflow: hidden;
    margin-bottom: 28px;
    background: linear-gradient(135deg, rgba(99,102,241,0.18) 0%, rgba(236,72,153,0.10) 50%, rgba(15,23,42,0.6) 100%);
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(16px);
}
.course-hero::before {
    content: '';
    position: absolute; top: -40%; right: -10%;
    width: 240px; height: 240px;
    background: radial-gradient(circle, rgba(99,102,241,0.25), transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}
.course-hero-inner { position: relative; padding: 28px 24px; }
.course-hero .track-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 12px; border-radius: 20px;
    font-size: 12px; font-weight: 600;
    background: rgba(255,255,255,0.08); color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 12px;
}
.course-hero .track-badge.weight_loss { background: rgba(16,185,129,0.15); color: #6EE7B7; border-color: rgba(16,185,129,0.2); }
.course-hero .track-badge.ai_agent { background: rgba(99,102,241,0.15); color: #A5B4FC; border-color: rgba(99,102,241,0.2); }
.course-hero .track-badge.ai_ecommerce { background: rgba(249,115,22,0.15); color: #FDBA74; border-color: rgba(249,115,22,0.2); }
.course-hero .cd-title {
    font-size: 24px; font-weight: 700; color: #F1F5F9;
    line-height: 1.35; margin-bottom: 10px;
}
.course-hero .cd-desc {
    color: var(--text-secondary); font-size: 14px; line-height: 1.75;
    margin-bottom: 18px; max-width: 680px;
}
.course-hero .cd-stats {
    display: flex; flex-wrap: wrap; gap: 16px;
    font-size: 13px; color: var(--text-tertiary);
    margin-bottom: 18px;
}
.course-hero .cd-stats span { display: inline-flex; align-items: center; gap: 5px; }
.course-hero .cd-progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.course-hero .cd-progress-bar {
    flex: 1; height: 6px; background: rgba(255,255,255,0.06);
    border-radius: 3px; overflow: hidden;
}
.course-hero .cd-progress-bar .bar {
    height: 100%; background: linear-gradient(90deg, var(--primary), var(--pink));
    border-radius: 3px; transition: width 0.4s;
}
.course-hero .cd-progress-text { font-size: 13px; color: var(--text-secondary); font-weight: 600; flex-shrink: 0; }
.course-hero .cd-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.course-hero .cd-actions .btn { min-height: 44px; padding: 12px 24px; }

/* --- Chapter timeline --- */
.chapter-timeline { position: relative; }
.chapter-timeline::before {
    content: '';
    position: absolute; left: 19px; top: 8px; bottom: 8px;
    width: 2px; background: rgba(255,255,255,0.06);
}
.chapter-timeline-item {
    position: relative;
    display: flex; gap: 16px;
    margin-bottom: 14px;
}
.chapter-timeline-item:last-child { margin-bottom: 0; }
.chapter-node {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(30,41,59,0.8); border: 2px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; color: var(--text-secondary);
    flex-shrink: 0; z-index: 1;
}
.chapter-node.done { background: rgba(16,185,129,0.15); border-color: rgba(16,185,129,0.3); color: #34D399; }
.chapter-card {
    flex: 1; min-width: 0;
    background: rgba(30,41,59,0.5); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg); padding: 16px 18px;
    text-decoration: none; color: inherit;
    transition: all 0.2s; display: block;
}
.chapter-card:hover {
    border-color: rgba(99,102,241,0.25);
    transform: translateY(-2px);
    text-decoration: none;
}
.chapter-card:active { transform: translateY(0); }
.chapter-card .cc-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    margin-bottom: 6px;
}
.chapter-card .cc-title { font-size: 15px; font-weight: 600; color: #F1F5F9; margin: 0; }
.chapter-card .cc-arrow { color: var(--text-muted); font-size: 13px; flex-shrink: 0; margin-top: 3px; }
.chapter-card .cc-desc {
    font-size: 13px; color: var(--text-tertiary); line-height: 1.6;
    margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.chapter-card .cc-meta {
    display: flex; align-items: center; gap: 12px;
    font-size: 12px; color: var(--text-muted);
}
.chapter-card .cc-status {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 600;
}
.cc-status.completed { background: rgba(16,185,129,0.12); color: #34D399; }
.cc-status.inprogress { background: rgba(99,102,241,0.12); color: #A5B4FC; }
.cc-status.pending { background: rgba(255,255,255,0.05); color: var(--text-tertiary); }

/* --- Chapter page --- */
.chapter-hero {
    background: rgba(30,41,59,0.5); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-xl); padding: 24px; margin-bottom: 24px;
}
.chapter-hero .cp-title { font-size: 22px; font-weight: 700; color: #F1F5F9; margin-bottom: 8px; }
.chapter-hero .cp-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 14px; }
.chapter-hero .cp-meta { font-size: 13px; color: var(--text-tertiary); display: flex; gap: 16px; flex-wrap: wrap; }
.chapter-hero .cp-meta span { display: inline-flex; align-items: center; gap: 5px; }

/* Section accordion */
.section-accordion {
    background: rgba(30,41,59,0.4); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg); margin-bottom: 12px; overflow: hidden;
}
.section-accordion .section-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; cursor: pointer; user-select: none;
    margin-bottom: 0; transition: background 0.15s;
}
.section-accordion .section-header:hover { background: rgba(255,255,255,0.03); }
.section-accordion .section-header-left {
    display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.section-accordion .section-toggle-icon {
    width: 24px; height: 24px; border-radius: 6px;
    background: rgba(255,255,255,0.05); color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; transition: transform 0.2s; flex-shrink: 0;
}
.section-accordion.open .section-toggle-icon { transform: rotate(180deg); }
.section-accordion .section-title {
    font-size: 15px; font-weight: 600; color: #F1F5F9; margin: 0;
}
.section-accordion .section-count {
    font-size: 12px; color: var(--text-muted); font-weight: 500; flex-shrink: 0;
}
.section-accordion .section-body {
    max-height: 0; overflow: hidden; transition: max-height 0.25s ease-out;
    padding: 0 18px;
}
.section-accordion.open .section-body {
    max-height: 2000px; transition: max-height 0.35s ease-in;
    padding-bottom: 16px;
}
.section-accordion .section-empty { padding: 16px 0; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Lesson list inside sections */
.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.lesson-row {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 14px; border-radius: var(--radius-md);
    background: rgba(255,255,255,0.03); border: 1px solid transparent;
    text-decoration: none; color: inherit; transition: all 0.15s;
    min-height: 56px;
}
.lesson-row:hover { background: rgba(255,255,255,0.06); border-color: rgba(99,102,241,0.15); text-decoration: none; }
.lesson-row:active { transform: scale(0.99); }
.lesson-row .lr-icon {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600; flex-shrink: 0;
}
.lesson-row .lr-icon.video { background: rgba(239,68,68,0.12); color: #FCA5A5; }
.lesson-row .lr-icon.pdf { background: rgba(245,158,11,0.12); color: #FCD34D; }
.lesson-row .lr-icon.doc { background: rgba(6,182,212,0.12); color: #67E8F9; }
.lesson-row .lr-icon.text { background: rgba(99,102,241,0.12); color: #A5B4FC; }
.lesson-row .lr-info { flex: 1; min-width: 0; }
.lesson-row .lr-title { font-size: 14px; font-weight: 500; color: var(--text-primary); margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-row .lr-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 10px; }
.lesson-row .lr-status { flex-shrink: 0; font-size: 18px; }
.lesson-row .lr-status.done { color: #34D399; }
.lesson-row .lr-status.lock { color: var(--text-muted); }

/* --- Lesson detail page --- */
.lesson-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(11,17,32,0.92); backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 14px 0; margin-bottom: 16px;
}
.lesson-header-inner {
    max-width: 900px; margin: 0 auto; padding: 0 20px;
    display: flex; align-items: center; gap: 12px;
}
.lesson-header .lh-back { font-size: 20px; color: var(--text-secondary); text-decoration: none; min-height: 44px; display: flex; align-items: center; }
.lesson-header .lh-title { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; color: #F1F5F9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-header .lh-meta { font-size: 12px; color: var(--text-tertiary); display: flex; gap: 10px; flex-shrink: 0; }
.lesson-container { max-width: 900px; margin: 0 auto; padding: 0 20px 96px; }
.lesson-hero {
    background: rgba(30,41,59,0.5); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-xl); padding: 24px; margin-bottom: 20px;
}
.lesson-hero .ld-title { font-size: 22px; font-weight: 700; color: #F1F5F9; margin-bottom: 10px; }
.lesson-hero .ld-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--text-tertiary); }
.lesson-type-badge {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600;
}
.lesson-type-badge.type-video { background: rgba(239,68,68,0.12); color: #FCA5A5; }
.lesson-type-badge.type-pdf { background: rgba(245,158,11,0.12); color: #FCD34D; }
.lesson-type-badge.type-doc { background: rgba(6,182,212,0.12); color: #67E8F9; }
.lesson-type-badge.type-text { background: rgba(99,102,241,0.12); color: #A5B4FC; }

/* Video player */
.video-player-wrap {
    position: relative; background: #000;
    border-radius: var(--radius-lg); overflow: hidden;
    margin-bottom: 20px; box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.video-player { width: 100%; display: block; max-height: 520px; }
.video-player-wrap .seek-warning {
    display: none; position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
    background: rgba(239,68,68,0.95); color: #fff; padding: 8px 20px; border-radius: 20px;
    font-size: 13px; z-index: 10; white-space: nowrap; pointer-events: none;
}

/* Document viewer */
.pdf-viewer-wrap, .doc-viewer-wrap {
    background: rgba(30,41,59,0.5); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 20px;
}
.pdf-iframe { width: 100%; height: 70vh; min-height: 400px; border: 0; display: block; background: #fff; }
.pdf-download { padding: 14px; text-align: center; margin: 0; border-top: 1px solid rgba(255,255,255,0.06); }
.pdf-download a { color: var(--primary); font-size: 13px; }
.pdf-download a:hover { color: #818CF8; }

/* Text content */
.text-content {
    background: rgba(30,41,59,0.5); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg); padding: 24px;
    font-size: 15px; line-height: 1.85; color: var(--text-primary);
    white-space: pre-wrap; word-break: break-word;
}
.text-content p { margin-bottom: 12px; }

/* Lesson nav */
.lesson-nav {
    display: flex; justify-content: space-between; gap: 12px;
    margin-top: 28px; flex-wrap: wrap;
}
.lesson-nav a {
    flex: 1; min-width: 140px; padding: 14px 18px;
    background: rgba(30,41,59,0.5); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-md); color: var(--text-secondary);
    text-decoration: none; font-size: 14px; font-weight: 500;
    transition: all 0.15s; min-height: 54px; display: flex; align-items: center; gap: 8px;
}
.lesson-nav a:hover { border-color: rgba(99,102,241,0.25); color: #818CF8; }
.lesson-nav a.ln-next { justify-content: flex-end; }
.lesson-nav a.disabled { opacity: 0.4; pointer-events: none; }

/* Course list page tabs */
.category-tabs {
    display: flex; gap: 8px; overflow-x: auto; padding: 4px;
    margin-bottom: 24px; scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }
.category-tabs a {
    flex-shrink: 0; padding: 8px 16px; border-radius: 20px;
    font-size: 13px; font-weight: 500; color: var(--text-secondary);
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
    text-decoration: none; transition: all 0.15s; min-height: 36px; display: flex; align-items: center;
}
.category-tabs a:hover { color: var(--text-primary); background: rgba(255,255,255,0.08); }
.category-tabs a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Empty state */
.empty-state {
    text-align: center; padding: 48px 24px; color: var(--text-muted);
    background: rgba(30,41,59,0.3); border-radius: var(--radius-lg);
    border: 1px dashed rgba(255,255,255,0.08);
}
.empty-state p { font-size: 14px; }

/* Section heading */
.section-heading {
    font-size: 16px; font-weight: 600; color: #F1F5F9;
    margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.section-heading::before {
    content: ''; width: 4px; height: 18px; border-radius: 2px;
    background: linear-gradient(180deg, var(--primary), var(--pink));
}

/* Responsive course */
@media (max-width: 768px) {
    .course-page .container { padding: 12px 16px 80px; }
    .course-hero-inner { padding: 22px 18px; }
    .course-hero .cd-title { font-size: 20px; }
    .course-hero .cd-desc { font-size: 13px; }
    .chapter-timeline::before { left: 15px; }
    .chapter-node { width: 32px; height: 32px; font-size: 12px; }
    .chapter-card { padding: 14px; }
    .chapter-card .cc-title { font-size: 14px; }
    .lesson-header-inner { padding: 0 16px; }
    .lesson-container { padding: 0 16px 80px; }
    .lesson-hero { padding: 18px; }
    .lesson-hero .ld-title { font-size: 18px; }
    .pdf-iframe { height: 60vh; min-height: 320px; }
    .lesson-nav a { min-width: 120px; font-size: 13px; }
}

/* ========== PWA Install Prompt ========== */
.qa-pwa-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    background: transparent;
    transition: opacity 0.25s, transform 0.25s;
}
.qa-pwa-prompt-inner {
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.35);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    max-width: 520px;
    margin: 0 auto;
}
.qa-pwa-prompt-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 14px;
    box-shadow: 0 4px 16px rgba(99,102,241,0.3);
}
.qa-pwa-prompt-body h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.qa-pwa-prompt-body p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 16px;
}
.qa-pwa-prompt-body p strong { color: var(--text-primary); font-weight: 500; }
.qa-pwa-prompt-actions {
    display: flex;
    gap: 12px;
}
.qa-pwa-btn {
    flex: 1;
    min-height: var(--touch-min);
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.15s;
}
.qa-pwa-btn:active { transform: scale(0.98); }
.qa-pwa-btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
}
.qa-pwa-btn-secondary {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
}
.qa-pwa-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}
@media (max-width: 400px) {
    .qa-pwa-prompt { padding: 12px; }
    .qa-pwa-prompt-inner { padding: 16px; }
    .qa-pwa-prompt-icon { width: 46px; height: 46px; font-size: 20px; }
}

/* PWA Toast */
.qa-pwa-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: rgba(15, 23, 42, 0.96);
    color: var(--text-primary);
    padding: 14px 22px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.5;
    max-width: 280px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.08);
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}
.qa-pwa-toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}


/* ===== 桌面适配 (≥768px) ===== */
@media (min-width: 768px) {
    /* 底部导航——桌面端显示 */
    .bottom-nav {
        display: flex;
    }
    .bottom-nav-items {
        max-width: 680px;
    }
    
    /* 桌面端 body 留出底部导航空间（70px足够容纳56px高的导航栏） */
    body {
        font-size: 16px;
        padding-bottom: 70px;
    }

    /* 聊天室页面 */
    .chat-messages {
        max-width: 780px;
        margin: 0 auto;
    }
    .chat-input-area {
        max-width: 780px;
        margin: 0 auto;
    }
    .chat-header {
        max-width: 780px;
        margin: 0 auto;
    }

    /* 课程卡片增大 */
    .course-card {
        max-width: 680px;
        margin: 0 auto 16px;
    }

    /* 赛道页面内容区 */
    .tab-content, .learn-tab, .showcase-tab, .products-tab {
        max-width: 780px;
        margin: 0 auto;
    }
    .pinned-area {
        max-width: 780px !important;
    }

    /* 私信界面 */
    .chat-area {
        max-width: 780px;
        margin: 0 auto;
    }

    /* 我的页面 */
    .my-container, .profile-container {
        max-width: 680px;
        margin: 0 auto;
    }

    /* 登录/注册卡片 */
    .login-card, .register-card {
        max-width: 440px;
    }

    /* 弹窗面板增大 */
    .profile-panel {
        max-width: 420px !important;
    }

    /* 消息气泡图片增大 */
    .msg-bubble.media-bubble img {
        max-width: 360px !important;
        max-height: 400px !important;
    }
    .msg-bubble.media-bubble video {
        max-width: 400px !important;
        max-height: 420px !important;
    }
}

/* ===== 大屏 (≥1024px) ===== */
@media (min-width: 1024px) {
    .bottom-nav-items {
        max-width: 780px;
    }
    .chat-messages, .chat-input-area, .chat-header,
    .tab-content, .learn-tab, .showcase-tab, .products-tab,
    .pinned-area, .chat-area {
        max-width: 880px;
    }
    .my-container, .profile-container {
        max-width: 780px;
    }
}
