/* ========== v3 Brand Variables ========== */
:root {
    --sidebar-width: 280px;
    --sidebar-bg: #132C47;
    --sidebar-text: #8BA3C4;
    --sidebar-active: #C89B3C;
    --sidebar-hover: #1A3A5C;
    --content-bg: #F5F6F8;
    --content-text: #2D3748;
    --heading-color: #132C47;
    --border-color: #E2E8F0;
    --accent-color: #C89B3C;
    --accent-light: #FFF8E7;
    --tag-bg: #EDF2F7;
    --tag-text: #4A5568;
    --tag-entry: #38A169;
    --tag-advanced: #C89B3C;
    --tag-expert: #E53E3E;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 6px;
    --radius-lg: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--content-bg);
    color: var(--content-text);
    line-height: 1.7;
    overflow-x: hidden;
}

/* ========== Layout ========== */
#app { display: flex; min-height: 100vh; }

/* ========== Sidebar ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.site-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.4;
    letter-spacing: 0.5px;
}

.site-subtitle {
    font-size: 0.75rem;
    color: var(--sidebar-text);
    margin-top: 4px;
    opacity: 0.7;
}

/* Search */
.search-box { padding: 16px 16px 8px; position: relative; }

#search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.05);
    color: #fff;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s;
}

#search-input::placeholder { color: rgba(255,255,255,0.35); }
#search-input:focus {
    border-color: var(--sidebar-active);
    background: rgba(255,255,255,0.08);
}

.search-results {
    position: absolute;
    top: calc(100% - 4px);
    left: 16px; right: 16px;
    background: #1A3A5C;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    max-height: 360px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}

.search-results.active { display: block; }

.search-result-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.15s;
}

.search-result-item:hover { background: rgba(255,255,255,0.05); }
.search-result-item:last-child { border-bottom: none; }

.search-result-title {
    font-size: 0.82rem;
    color: #e2e8f0;
    font-weight: 500;
}

.search-result-section {
    font-size: 0.72rem;
    color: var(--sidebar-text);
    margin-top: 2px;
}

.search-result-summary {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
    margin-top: 4px;
    line-height: 1.4;
}

.search-tag {
    display: inline-block;
    padding: 1px 6px;
    background: rgba(200,155,60,0.2);
    color: var(--sidebar-active);
    font-size: 0.65rem;
    border-radius: 3px;
    margin-left: 4px;
}

mark {
    background: rgba(200,155,60,0.3);
    color: #fff;
    padding: 0 2px;
    border-radius: 2px;
}

/* Nav Tree */
.nav-tree { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-section { margin-bottom: 4px; }

.nav-section-title {
    padding: 10px 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    letter-spacing: 0.3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color 0.2s;
}

.nav-section-title em {
    font-style: normal;
    font-size: 0.7rem;
    opacity: 0.6;
}

.nav-section-title:hover { color: rgba(255,255,255,0.8); }

.nav-toggle-icon {
    font-size: 0.65rem;
    transition: transform 0.2s;
}

.nav-section.collapsed .nav-toggle-icon { transform: rotate(-90deg); }
.nav-section.collapsed .nav-articles { max-height: 0 !important; }

.nav-articles {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-subsection-title {
    padding: 6px 20px 4px 28px;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(200,155,60,0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-item {
    padding: 8px 20px 8px 32px;
    font-size: 0.85rem;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all 0.15s;
    line-height: 1.5;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
}

.nav-item.active {
    background: rgba(200,155,60,0.1);
    color: var(--sidebar-active);
    border-left-color: var(--sidebar-active);
}

.nav-placeholder {
    font-size: 0.75rem;
    font-style: italic;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.72rem;
    color: rgba(255,255,255,0.35);
    text-align: center;
}

/* ========== Main Content ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--content-bg);
}

.content-wrapper {
    max-width: 860px;
    margin: 0 auto;
    padding: 40px 48px;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: #718096;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--accent-color);
    text-decoration: none;
    cursor: pointer;
}

.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-separator { color: #CBD5E0; }

/* Article Header */
.article-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
}

#article-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--heading-color);
    line-height: 1.3;
    margin-bottom: 12px;
}

.article-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.article-tag {
    display: inline-block;
    padding: 3px 10px;
    background: var(--tag-bg);
    color: var(--tag-text);
    font-size: 0.75rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.article-tag.tag-entry { background: #F0FFF4; color: var(--tag-entry); border-color: #C6F6D5; }
.article-tag.tag-advanced { background: #FFFFF0; color: #B7791F; border-color: #FEFCBF; }
.article-tag.tag-expert { background: #FFF5F5; color: var(--tag-expert); border-color: #FED7D7; }

.article-week {
    display: inline-block;
    padding: 3px 10px;
    background: var(--accent-light);
    color: #B7791F;
    font-size: 0.75rem;
    border-radius: 20px;
    font-weight: 600;
}

.article-source {
    font-size: 0.75rem;
    color: #718096;
    font-style: italic;
}

.article-date {
    font-size: 0.78rem;
    color: #A0AEC0;
}

/* Article Body */
.article-body {
    font-size: 0.95rem;
    line-height: 1.85;
    color: var(--content-text);
}

.article-body h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--heading-color);
    margin: 40px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.article-body h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--heading-color);
    margin: 28px 0 12px;
}

.article-body h4 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--heading-color);
    margin: 20px 0 10px;
}

.article-body p { margin-bottom: 16px; }
.article-body ul, .article-body ol { margin: 12px 0 16px 24px; }
.article-body li { margin-bottom: 6px; }

.article-body blockquote {
    margin: 20px 0;
    padding: 12px 20px;
    border-left: 4px solid var(--accent-color);
    background: var(--accent-light);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
    color: #744210;
}

.article-body strong { color: var(--heading-color); font-weight: 600; }

.article-body code {
    background: #EDF2F7;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
    font-size: 0.88em;
    color: #2D3748;
}

.article-body pre {
    background: #132C47;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 16px 0;
    font-size: 0.85rem;
    line-height: 1.6;
}

.article-body pre code { background: transparent; padding: 0; color: inherit; }

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.88rem;
}

.article-body th, .article-body td {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.article-body th {
    background: var(--accent-light);
    font-weight: 600;
    color: var(--heading-color);
}

.article-body tr:nth-child(even) { background: #FAFAFA; }

/* Article Nav */
.article-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 2px solid var(--border-color);
    gap: 16px;
}

.nav-prev, .nav-next {
    flex: 1;
    padding: 16px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
}

.nav-prev:hover, .nav-next:hover {
    border-color: var(--accent-color);
    box-shadow: var(--shadow);
}

.nav-next { text-align: right; }

.nav-label {
    font-size: 0.75rem;
    color: #718096;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.nav-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--heading-color);
}

/* Mobile Menu */
.menu-toggle {
    display: none;
    position: fixed;
    top: 16px; left: 16px;
    z-index: 110;
    width: 40px; height: 40px;
    background: var(--sidebar-bg);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 8px;
}

.menu-toggle span {
    display: block;
    width: 20px; height: 2px;
    background: #fff;
    border-radius: 1px;
    transition: all 0.3s;
}

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

/* ========== Welcome Page ========== */
.welcome-content {
    text-align: center;
    padding: 40px 20px;
}

.welcome-content h2 {
    font-size: 1.6rem;
    color: var(--heading-color);
    margin-bottom: 12px;
}

.welcome-content > p {
    font-size: 0.95rem;
    color: #718096;
    max-width: 560px;
    margin: 0 auto 36px;
    line-height: 1.8;
}

.welcome-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    max-width: 720px;
    margin: 0 auto 36px;
}

.welcome-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all 0.2s;
    text-align: left;
}

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

.welcome-card-pending {
    opacity: 0.5;
    border-style: dashed;
}

.welcome-card-pending:hover {
    transform: none;
    box-shadow: none;
    cursor: default;
}

.welcome-card-icon {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.welcome-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--heading-color);
    margin-bottom: 6px;
}

.welcome-card p {
    font-size: 0.8rem;
    color: #718096;
    margin: 0;
}

.welcome-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 24px 0;
    border-top: 1px solid var(--border-color);
}

.stat-item {
    text-align: center;
}

.stat-item strong {
    display: block;
    font-size: 1.8rem;
    color: var(--accent-color);
    font-weight: 700;
}

.stat-item span {
    font-size: 0.8rem;
    color: #718096;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .menu-toggle { display: flex; }
    
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
    }
    
    .sidebar.open { transform: translateX(0); }
    .overlay.active { display: block; }
    .main-content { margin-left: 0; }
    .content-wrapper { padding: 60px 20px 32px; }
    #article-title { font-size: 1.4rem; }
    .article-nav { flex-direction: column; }
    .welcome-cards { grid-template-columns: 1fr 1fr; }
    .welcome-stats { gap: 24px; }
}

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

/* ========== Scrollbar ========== */
.sidebar::-webkit-scrollbar,
.search-results::-webkit-scrollbar { width: 4px; }

.sidebar::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

/* ========== Print ========== */
@media print {
    .sidebar, .menu-toggle, .overlay, .article-nav { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-wrapper { max-width: 100%; padding: 20px; }
}

/* ========== P2: Progress Overview ========== */
.progress-overview {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 24px 0;
    box-shadow: var(--shadow);
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: var(--tag-bg);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #D4AF37);
    transition: width 0.5s ease;
    border-radius: 6px;
}

/* ========== P2: Timeline ========== */
.timeline-section {
    margin-top: 40px;
}

.timeline-section h3 {
    font-size: 1.3rem;
    color: var(--heading-color);
    margin-bottom: 24px;
    text-align: center;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.timeline-phase {
    border-left: 4px solid var(--phase-color, var(--accent-color));
    padding-left: 20px;
}

.phase-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.phase-header h4 {
    font-size: 1.1rem;
    color: var(--phase-color, var(--heading-color));
    margin: 0;
}

.phase-weeks {
    font-size: 0.85rem;
    color: #718096;
    background: var(--tag-bg);
    padding: 4px 12px;
    border-radius: 12px;
}

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

.timeline-week {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.timeline-week:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.timeline-week.week-complete {
    border-left: 3px solid #38A169;
}

.week-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.week-number {
    font-weight: 700;
    color: var(--phase-color, var(--accent-color));
    font-size: 0.9rem;
}

.week-title {
    font-size: 0.9rem;
    color: var(--content-text);
    flex: 1;
}

.week-progress {
    width: 100%;
    height: 6px;
    background: var(--tag-bg);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.week-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #38A169, #48BB78);
    transition: width 0.5s ease;
}

.week-articles {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-article {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 0.85rem;
}

.timeline-article:hover {
    background: var(--tag-bg);
}

.timeline-article.article-complete {
    background: rgba(56, 161, 105, 0.08);
}

.article-check {
    font-size: 1rem;
    color: #A0AEC0;
    flex-shrink: 0;
}

.timeline-article.article-complete .article-check {
    color: #38A169;
}

.article-name {
    color: var(--content-text);
    flex: 1;
    line-height: 1.4;
}

/* ========== P2: Check-in Button ========== */
.article-checkin-section {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 2px solid var(--border-color);
    text-align: center;
}

.checkin-btn {
    background: white;
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
    padding: 12px 32px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.checkin-btn:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.checkin-btn.completed {
    background: #38A169;
    color: white;
    border-color: #38A169;
}

.checkin-btn.completed:hover {
    background: #2F855A;
    border-color: #2F855A;
}

/* ========== P2: Sidebar Progress Indicators ========== */
.nav-item.nav-item-completed {
    position: relative;
}

.nav-item.nav-item-completed::before {
    content: '✓';
    position: absolute;
    right: 8px;
    color: #38A169;
    font-weight: 700;
    font-size: 0.9rem;
}

/* ========== P2: Mobile Optimizations ========== */
@media (max-width: 768px) {
    /* Timeline responsive */
    .phase-weeks-grid {
        grid-template-columns: 1fr;
    }
    
    .timeline-phase {
        padding-left: 12px;
    }
    
    .phase-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .timeline-week {
        padding: 12px;
    }
    
    .week-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    /* Progress overview responsive */
    .progress-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .progress-overview {
        padding: 16px;
    }
    
    /* Check-in button responsive */
    .checkin-btn {
        width: 100%;
        padding: 14px 24px;
    }
    
    /* Better touch targets */
    .nav-item {
        padding: 10px 12px;
        min-height: 44px;
    }
    
    .nav-section-title {
        padding: 12px;
        min-height: 48px;
    }
    
    /* Article body responsive */
    .article-body {
        font-size: 1rem;
        line-height: 1.8;
    }
    
    .article-body table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* Welcome cards responsive */
    .welcome-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .welcome-card {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    .progress-stats {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .stat-item strong {
        font-size: 1.3rem;
    }
    
    .timeline-section h3 {
        font-size: 1.1rem;
    }
    
    .week-title {
        font-size: 0.85rem;
    }
    
    .article-name {
        font-size: 0.8rem;
    }
}
