:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-light: #f8f9fa;
    --text-main: #333;
    --text-muted: #666;
    --border-light: #e0e0e0;
    --white: #ffffff;
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Segoe UI', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    padding: 40px 20px;
    color: var(--text-main);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Header Section */
header {
    background: var(--bg-gradient);
    color: var(--white);
    padding: 60px 40px;
    text-align: center;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 400;
}

/* Tabs Navigation */
.tabs {
    display: flex;
    background: #f5f5f5;
    border-bottom: 2px solid var(--border-light);
    flex-wrap: wrap;
}

.tab-btn {
    flex: 1;
    min-width: 150px;
    padding: 24px;
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn:hover {
    background: #e8e8e8;
    color: var(--primary);
}

.tab-btn.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: inset 0 -4px 0 var(--primary);
}

/* Tab Content Areas */
.tab-content {
    display: none;
    padding: 40px;
    background: var(--white);
    min-height: 700px;
}

.tab-content.active {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 40px;
}

/* Chapter Sidebar (Concept Tab only) */
.chapter-nav {
    background: var(--bg-light);
    padding: 25px;
    border-radius: var(--radius-md);
    max-height: calc(100vh - 400px);
    overflow-y: auto;
    border: 1px solid var(--border-light);
}

.chapter-nav h2 {
    margin-bottom: 20px;
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chapter-item {
    padding: 18px;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chapter-item:hover {
    border-color: var(--primary);
    transform: translateX(5px);
    box-shadow: var(--shadow-sm);
}

.chapter-item.active {
    background: #f0f4ff;
    border-color: var(--primary);
    border-left: 4px solid var(--primary);
}

.chapter-item h3 {
    font-size: 1.05rem;
    margin-bottom: 4px;
    color: var(--text-main);
}

.chapter-item p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Concept Viewer */
.concept-viewer {
    background: var(--white);
    border-radius: var(--radius-md);
}

.welcome-message {
    text-align: center;
    padding: 100px 40px;
}

.welcome-message h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: var(--primary);
}

/* Content Components */
.concept-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-light);
}

.concept-content h3 {
    color: var(--primary);
    margin-top: 40px;
    margin-bottom: 20px;
    font-size: 1.8rem;
    border-left: 5px solid var(--secondary);
    padding-left: 15px;
}

.math-block {
    background: #f8fafc;
    border-left: 4px solid var(--primary);
    padding: 30px;
    margin: 30px 0;
    border-radius: var(--radius-sm);
    font-size: 1.6rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
    overflow-x: auto;
    text-align: center;
    color: var(--primary-dark);
}

.katex {
    font-size: 1.2em !important;
}

.option-btn .katex {
    font-size: 1.1em !important;
}

/* Problem Cards */
.problem-card {
    background: var(--white);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 30px;
    margin-bottom: 25px;
    transition: all 0.3s ease;
}

.problem-card:hover {
    border-color: var(--primary);
}

.difficulty-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 15px;
}

.diff-1 {
    background: #dcfce7;
    color: #166534;
}

.diff-2 {
    background: #fef9c3;
    color: #854d0e;
}

.diff-3 {
    background: #ffedd5;
    color: #9a3412;
}

.diff-4 {
    background: #fee2e2;
    color: #991b1b;
}

/* Buttons */
.btn-primary {
    background: var(--bg-gradient);
    color: var(--white);
    border: none;
    padding: 14px 28px;
    font-size: 1.05rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Hidden Utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 1000px) {
    .tab-content.active {
        grid-template-columns: 1fr;
    }

    .chapter-nav {
        max-height: none;
    }
}