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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

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

header {
    background: #2c3e50;
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.subtitle {
    opacity: 0.8;
    font-size: 1rem;
}

main {
    padding: 30px;
}

/* Controls Section */
.controls {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.topic-selector,
.calc-selector,
.grade-selector {
    flex: 1;
    min-width: 150px;
}

.topic-selector label,
.calc-selector label,
.grade-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.topic-selector select,
.calc-selector select,
.grade-selector select {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.topic-selector select:focus,
.calc-selector select:focus,
.grade-selector select:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd6;
    transform: translateY(-2px);
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #219a52;
    transform: translateY(-2px);
}

/* Question Area */
.question-area {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
}

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

.question-badges {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.topic-badge {
    background: #667eea;
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.calc-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.calc-badge.calculator {
    background: #27ae60;
    color: white;
}

.calc-badge.non-calculator {
    background: #e74c3c;
    color: white;
}

.grade-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
}

.grade-badge.grade-low {
    background: #3498db;
}

.grade-badge.grade-mid {
    background: #f39c12;
}

.grade-badge.grade-high {
    background: #9b59b6;
}

.grade-badge.grade-top {
    background: #e74c3c;
}

.marks {
    color: #7f8c8d;
    font-size: 0.9rem;
    font-weight: 500;
}

.question-text {
    font-size: 1.2rem;
    color: #2c3e50;
    line-height: 1.8;
}

.question-text p {
    margin-bottom: 10px;
}

/* Answer Area */
.answer-area {
    margin-bottom: 25px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.input-group input {
    width: 100%;
    padding: 14px 18px;
    font-size: 1.1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.hint {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #7f8c8d;
    font-style: italic;
}

/* Symbol Toolbar */
.symbol-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.symbol-btn {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Times New Roman', serif;
}

.symbol-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: scale(1.1);
}

.symbol-btn:active {
    transform: scale(0.95);
}

.symbol-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.symbol-btn:disabled:hover {
    background: white;
    color: inherit;
    border-color: #ccc;
    transform: none;
}

/* Result Area */
.result-area {
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    text-align: center;
}

.result-area.correct {
    background: #d4edda;
    border: 2px solid #27ae60;
}

.result-area.incorrect {
    background: #f8d7da;
    border: 2px solid #e74c3c;
}

.result-message {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.result-area.correct .result-message {
    color: #27ae60;
}

.result-area.incorrect .result-message {
    color: #e74c3c;
}

.correct-answer {
    font-size: 1rem;
    color: #555;
}

/* Solution Area */
.solution-area {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
}

.solution-area h3 {
    color: #856404;
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.solution-steps {
    color: #2c3e50;
}

.solution-step {
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 1.05rem;
    line-height: 1.8;
}

.solution-step:last-child {
    border-bottom: none;
}

/* Next Area */
.next-area {
    text-align: center;
    margin-top: 20px;
}

/* Footer */
footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    color: #7f8c8d;
    border-top: 1px solid #e0e0e0;
}

/* Calculator Area */
.calculator-area {
    margin-bottom: 25px;
}

.calculator {
    background: #2c3e50;
    border-radius: 12px;
    padding: 20px;
    max-width: 320px;
}

.calc-display {
    margin-bottom: 15px;
}

.calc-display input {
    width: 100%;
    padding: 15px;
    font-size: 1.5rem;
    text-align: right;
    border: none;
    border-radius: 8px;
    background: #1a252f;
    color: #2ecc71;
    font-family: 'Courier New', monospace;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.calc-btn {
    padding: 15px;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #34495e;
    color: white;
    font-weight: 600;
}

.calc-btn:hover {
    background: #4a6278;
    transform: scale(1.05);
}

.calc-btn:active {
    transform: scale(0.95);
}

.calc-operator {
    background: #667eea;
}

.calc-operator:hover {
    background: #5a6fd6;
}

.calc-equals {
    background: #27ae60;
}

.calc-equals:hover {
    background: #219a52;
}

.calc-clear {
    background: #e74c3c;
}

.calc-clear:hover {
    background: #c0392b;
}

.calc-scientific {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.calc-sci {
    padding: 10px;
    font-size: 0.9rem;
    background: #5d6d7e;
}

.calc-sci:hover {
    background: #6d7d8e;
}

.calc-use {
    width: 100%;
    padding: 12px;
    background: #9b59b6;
    font-size: 1rem;
}

.calc-use:hover {
    background: #8e44ad;
}

/* KaTeX overrides */
.katex {
    font-size: 1.1em;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    main {
        padding: 20px;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        width: 100%;
    }

    .question-text {
        font-size: 1.1rem;
    }
}
