* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90e2;
    --secondary-color: #50c878;
    --text-color: #333;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 0;
}

header h1 {
    font-size: 2.5em;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    color: #666;
}

/* Navigation */
.main-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 12px 24px;
    font-size: 1em;
    border: 2px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
}

.nav-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Pages */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Home Page */
.welcome-section {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.subject-card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.subject-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.subject-card h3 {
    color: var(--primary-color);
    font-size: 1.5em;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.subject-card ul {
    list-style: none;
}

.subject-card li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
}

.subject-card li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--secondary-color);
    font-weight: bold;
}

/* Concept Page */
.concept-container {
    display: flex;
    gap: 30px;
    min-height: 600px;
}

.chapter-sidebar {
    width: 280px;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-height: 80vh;
    overflow-y: auto;
    position: sticky;
    top: 20px;
}

.chapter-sidebar h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.3em;
}

.subject-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.subject-tab {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
}

.subject-tab:hover {
    background: var(--primary-color);
    color: white;
}

.subject-tab.active {
    background: var(--primary-color);
    color: white;
}

.chapter-list {
    list-style: none;
}

.chapter-item {
    padding: 12px 15px;
    margin: 8px 0;
    background: #f5f5f5;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 4px solid transparent;
}

.chapter-item:hover {
    background: #e8f4f8;
    border-left-color: var(--primary-color);
    transform: translateX(5px);
}

.chapter-item.active {
    background: #e8f4f8;
    border-left-color: var(--primary-color);
    font-weight: bold;
    color: var(--primary-color);
}

.concept-content {
    flex: 1;
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    min-height: 600px;
}

.concept-welcome {
    text-align: center;
    padding: 60px 20px;
}

.concept-welcome h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 2em;
}

.concept-body {
    font-size: 1.1em;
    line-height: 1.8;
}

.concept-body h3 {
    color: var(--primary-color);
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.5em;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.concept-body h4 {
    color: #555;
    margin-top: 25px;
    margin-bottom: 12px;
    font-size: 1.2em;
}

.concept-body p {
    margin-bottom: 15px;
}

.concept-body ul, .concept-body ol {
    margin-left: 30px;
    margin-bottom: 20px;
}

.concept-body li {
    margin-bottom: 10px;
}

/* Math rendering - KaTeX styling */
.katex {
    font-size: 1.2em !important;
    color: #1a1a1a;
}

.katex-display {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    overflow-x: auto;
}

.katex-display > .katex {
    font-size: 1.3em !important;
    text-align: left;
}

/* Graph containers */
.graph-container {
    margin: 30px 0;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.graph-container canvas {
    max-width: 100%;
    height: auto;
}

.desmos-graph {
    width: 100%;
    height: 400px;
    margin: 20px 0;
    border-radius: 8px;
    overflow: hidden;
}

/* Problem Page */
.problem-container {
    display: flex;
    gap: 30px;
    min-height: 600px;
}

.problem-sidebar {
    width: 280px;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-height: 80vh;
    overflow-y: auto;
    position: sticky;
    top: 20px;
}

.problem-sidebar h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.3em;
}

.filter-group {
    margin-bottom: 20px;
}

.filter-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.filter-select {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1em;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.filter-select:hover {
    border-color: var(--primary-color);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 10px;
}

.btn-primary:hover {
    background: #357abd;
}

.problem-content {
    flex: 1;
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    min-height: 600px;
}

.problem-welcome {
    text-align: center;
    padding: 60px 20px;
}

.problem-welcome h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 2em;
}

.problem-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.problem-info {
    display: inline-block;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
}

.problem-question {
    font-size: 1.2em;
    line-height: 1.8;
    margin-bottom: 30px;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.answer-section {
    margin-bottom: 25px;
}

.answer-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 1.1em;
}

.answer-input {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.1em;
    font-family: 'Courier New', monospace;
    resize: vertical;
    transition: border-color 0.3s;
}

.answer-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.problem-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.btn-secondary {
    padding: 12px 24px;
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
}

.answer-result {
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 1.1em;
    font-weight: bold;
}

.answer-result.correct {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.answer-result.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.solution-box {
    padding: 25px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
    margin-top: 20px;
}

.solution-box h4 {
    color: var(--secondary-color);
    margin-bottom: 15px;
    font-size: 1.3em;
}

/* Responsive Design */
@media (max-width: 968px) {
    .concept-container,
    .problem-container {
        flex-direction: column;
    }

    .chapter-sidebar,
    .problem-sidebar {
        width: 100%;
        position: static;
        max-height: none;
    }

    header h1 {
        font-size: 2em;
    }

    .concept-content,
    .problem-content {
        padding: 25px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.5em;
    }

    .subject-grid {
        grid-template-columns: 1fr;
    }

    .problem-actions {
        flex-direction: column;
    }

    .btn-secondary,
    .btn-primary {
        width: 100%;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #357abd;
}
