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

body {
    font-family: 'Segoe UI', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1em;
    opacity: 0.95;
}

.tabs {
    display: flex;
    background: #f5f5f5;
    border-bottom: 2px solid #e0e0e0;
    flex-wrap: wrap;
}

.tab-btn {
    flex: 1;
    min-width: 150px;
    padding: 20px;
    background: none;
    border: none;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    color: #666;
}

.tab-btn:hover {
    background: #e8e8e8;
}

.tab-btn.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
}

.tab-content {
    display: none;
    padding: 30px;
    min-height: 500px;
}

.tab-content.active {
    display: block;
}

/* 개념 학습 스타일 */
.chapter-nav {
    width: 300px;
    float: left;
    margin-right: 30px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    max-height: 600px;
    overflow-y: auto;
}

.chapter-nav h2 {
    margin-bottom: 20px;
    color: #667eea;
    font-size: 1.3em;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chapter-item {
    padding: 15px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.chapter-item:hover {
    border-color: #667eea;
    transform: translateX(5px);
}

.chapter-item.active {
    border-color: #667eea;
    background: #f0f4ff;
}

.chapter-item h3 {
    font-size: 1.1em;
    margin-bottom: 5px;
    color: #333;
}

.chapter-item p {
    font-size: 0.9em;
    color: #666;
}

.concept-viewer {
    margin-left: 330px;
    background: white;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.welcome-message h2 {
    font-size: 2em;
    margin-bottom: 20px;
    color: #667eea;
}

.concept-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.concept-header h2 {
    font-size: 1.8em;
    color: #333;
}

.concept-nav {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-nav {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.btn-nav:hover:not(:disabled) {
    background: #5568d3;
}

.btn-nav:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.concept-counter {
    font-weight: 600;
    color: #666;
}

.concept-content {
    font-size: 1.1em;
    line-height: 1.8;
    color: #444;
}

.concept-content h3 {
    color: #667eea;
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.concept-content h4 {
    color: #764ba2;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.concept-content ul, .concept-content ol {
    margin: 15px 0;
    padding-left: 30px;
}

.concept-content li {
    margin: 8px 0;
}

.formula-box {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 20px;
    margin: 20px 0;
    border-radius: 8px;
    overflow-x: auto;
}

.formula-box p {
    margin: 10px 0;
}

/* MathJax 스타일 개선 */
.MathJax {
    font-size: 1.1em !important;
}

.MathJax_Display {
    margin: 20px 0 !important;
    text-align: center;
}

/* 질문하기 스타일 */
.question-section {
    max-width: 900px;
    margin: 0 auto;
}

.question-input-area {
    margin-bottom: 30px;
}

.question-input-area textarea {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 15px;
}

.question-input-area textarea:focus {
    outline: none;
    border-color: #667eea;
}

.question-answer {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}

.question-display, .answer-display {
    margin-bottom: 25px;
}

.question-display h3, .answer-display h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.answer-content {
    font-size: 1.1em;
    line-height: 1.8;
    color: #444;
}

/* 문제 풀기 스타일 */
.problem-controls {
    margin-bottom: 30px;
}

.problem-settings {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.problem-settings label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.problem-settings select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
}

.problem-container {
    max-width: 900px;
    margin: 0 auto;
    background: #f8f9fa;
    padding: 30px;
    border-radius: 12px;
}

.problem-header {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.difficulty-badge, .topic-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
}

.difficulty-badge.easy {
    background: #d4edda;
    color: #155724;
}

.difficulty-badge.medium {
    background: #fff3cd;
    color: #856404;
}

.difficulty-badge.hard {
    background: #f8d7da;
    color: #721c24;
}

.topic-badge {
    background: #d1ecf1;
    color: #0c5460;
}

.problem-statement {
    background: white;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid #e0e0e0;
}

.problem-statement h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.problem-text {
    font-size: 1.2em;
    line-height: 1.8;
}

.problem-answer-area {
    background: white;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.problem-answer-area label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
}

.problem-answer-area textarea {
    width: 100%;
    min-height: 100px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: 'Courier New', monospace;
    resize: vertical;
    margin-bottom: 15px;
}

.problem-answer-area textarea:focus {
    outline: none;
    border-color: #667eea;
}

.problem-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.problem-feedback {
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.feedback-correct {
    background: #d4edda;
    color: #155724;
    border: 2px solid #28a745;
}

.feedback-incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #dc3545;
}

.problem-solution {
    background: #e8f4f8;
    padding: 25px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    margin-top: 20px;
}

.problem-solution h4 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
}

/* 복습 노트 스타일 */
.review-section {
    max-width: 1000px;
    margin: 0 auto;
}

.review-notes {
    margin-bottom: 20px;
}

.review-note-item {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
}

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

.note-header h3 {
    flex: 1;
    color: #856404;
    font-size: 1.2em;
}

.note-date {
    color: #666;
    font-size: 0.9em;
}

.btn-delete {
    padding: 6px 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s;
}

.btn-delete:hover {
    background: #c82333;
}

.note-content {
    color: #444;
    line-height: 1.8;
}

/* 버튼 스타일 */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 1em;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1em;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.btn-secondary:hover {
    background: #5a6268;
}

.concept-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.hidden {
    display: none !important;
}

.empty-message {
    text-align: center;
    color: #999;
    padding: 40px;
    font-size: 1.1em;
}

/* 반응형 디자인 */
@media (max-width: 1024px) {
    .chapter-nav {
        width: 100%;
        float: none;
        margin-right: 0;
        margin-bottom: 20px;
    }
    
    .concept-viewer {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        min-width: 100%;
    }
    
    .problem-settings {
        flex-direction: column;
        align-items: stretch;
    }
    
    .problem-settings label {
        flex-direction: column;
        align-items: stretch;
    }
    
    .problem-settings select {
        width: 100%;
    }
    
    .note-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* 수학 기호 선명도 향상 */
.MathJax {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.MathJax_SVG, .MathJax_SVG_Display {
    max-width: 100% !important;
}

/* 인쇄 스타일 */
@media print {
    body {
        background: white;
    }
    
    .container {
        box-shadow: none;
    }
    
    .tabs, .btn-primary, .btn-secondary, .btn-nav {
        display: none;
    }
}
