@font-face {
  font-family: 'KaTeX_Main_Minus';
  src: url('https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/fonts/KaTeX_Main-Regular.woff2') format('woff2'),
       url('https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/fonts/KaTeX_Main-Regular.woff') format('woff'),
       url('https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/fonts/KaTeX_Main-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  unicode-range: U+2212;
}

@font-face {
  font-family: 'KaTeX_Math_X';
  src: url('https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/fonts/KaTeX_Math-Italic.woff2') format('woff2'),
       url('https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/fonts/KaTeX_Math-Italic.woff') format('woff'),
       url('https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/fonts/KaTeX_Math-Italic.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  unicode-range: U+0078, U+0058;
}

:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --success-color: #10B981;
    --error-color: #EF4444;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --bg-card: rgba(255, 255, 255, 0.75);
    --border-card: rgba(255, 255, 255, 0.4);
}

.exercise-wrapper {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f0fdf4 0%, #e0e7ff 100%);
    position: relative;
    border-radius: 12px;
    padding: 15px 20px;
    overflow: hidden;
}

/* Background decorations */
.background-mesh {
    position: absolute;
    top: -20%;
    left: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.3) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    z-index: -1;
}
.background-mesh::after {
    content: '';
    position: absolute;
    bottom: -50%;
    right: -50%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(52, 211, 153, 0.2) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
}

.app-container {
    width: 100%;
    max-width: 700px;
    padding: 0px 20px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.app-header {
    text-align: center;
}

.app-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(90deg, #312E81, #4F46E5);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.app-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Glassmorphism Card */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-card);
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Exercise Display */
.exercise-section {
    background: white;
    padding: 10px;
    border-radius: 12px;
    text-align: center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    border: 1px solid #E5E7EB;
    overflow-x: auto;
    overflow-y: hidden;
}

.math-display {
    font-size: 1.8rem;
    color: var(--text-main);
}

/* Input Section */
.input-section {
    display: flex;
    gap: 10px;
}

#answer-input {
    flex: 1;
    padding: 14px 20px;
    font-size: 1.1rem;
    font-family: 'KaTeX_Math_X', 'KaTeX_Main_Minus', 'Inter', sans-serif;
    letter-spacing: 1px;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    outline: none;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.9);
}

#answer-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.btn {
    padding: 8px 16px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(79, 70, 229, 0.25);
}

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

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

.secondary-btn {
    background: #F3F4F6;
    color: var(--text-main);
    width: 100%;
}

.secondary-btn:hover {
    background: #E5E7EB;
}

/* Feedback Section */
.feedback {
    padding: 16px 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
    
    position: fixed;
    top: 20px;
    left: 0;
    right: 0;
    margin: auto;
    width: max-content;
    max-width: 90%;
    z-index: 9999;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.feedback.success {
    background: rgba(16, 185, 129, 0.95);
    color: #ffffff;
    border: 1px solid rgba(16, 185, 129, 1);
}

.feedback.error {
    background: rgba(239, 68, 68, 0.95);
    color: #ffffff;
    border: 1px solid rgba(239, 68, 68, 1);
}

.hidden {
    display: none !important;
}

footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.shake {
    animation: shake 0.3s ease-in-out;
}

/* Virtual Keyboard */
.virtual-keyboard {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid #E5E7EB;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.vk-btn {
    padding: 8px 0;
    font-size: 1.1rem;
    font-weight: 600;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    background: #F9FAFB;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.1s ease;
    font-family: 'KaTeX_Main_Minus', 'Inter', sans-serif;
}

.vk-btn:active {
    background: #E5E7EB;
    transform: scale(0.95);
}

.vk-op { color: var(--primary-color); }
.vk-var { color: #10B981; font-family: 'KaTeX_Math', 'Times New Roman', serif; font-style: italic; font-size: 1.3rem; }
.vk-square { color: var(--primary-color); }
.vk-del { color: #EF4444; }

/* Responsive Adjustments */
@media (max-width: 640px) {
    .exercise-wrapper {
        padding: 10px 4px;
        border-radius: 8px;
    }

    .app-container {
        padding: 0px 2px 5px 2px;
    }

    .glass-card {
        padding: 15px 8px;
    }
    
    .exercise-section {
        padding: 10px 4px;
    }
    
    .math-display {
        font-size: 1.2rem;
    }
    
    #answer-input {
        font-size: 0.9rem;
    }
    
    .input-section {
        flex-direction: column;
        align-items: center;
    }
    #answer-input {
        width: 100%;
    }
}

.blue-btn {
    background-color: #3B82F6 !important;
    color: white !important;
    width: fit-content !important;
    margin: 0 auto !important;
    display: block;
    padding: 0.5rem 1rem !important;
}

.blue-btn:hover {
    background-color: #2563EB !important;
}
.vk-var { display: none !important; }


/* Fraction Input Styles */
.fraction-input-container { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.fraction-line { width: 80px; height: 3px; background-color: var(--text-main); border-radius: 2px; }
.fraction-input { width: 80px; padding: 8px; font-size: 1.5rem; font-family: 'Inter', sans-serif; font-weight: bold; text-align: center; border: 2px solid #E5E7EB; border-radius: 8px; outline: none; transition: all 0.2s ease; background: rgba(255,255,255,0.9); }
.fraction-input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1); }
