@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.85);
    --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, #dcfce7 0%, #bbf7d0 100%);
    position: relative;
    border-radius: 16px;
    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: 680px;
    padding: 0px 20px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    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: 15px;
    min-width: 0;
}

.exercise-section {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    border: 1px solid #E5E7EB;
    text-align: center;
}

.math-display {
    font-size: 1.6rem;
    color: #111827;
    margin: 8px 0;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Input Section */
.input-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.equation-input-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.5rem;
    font-family: 'KaTeX_Math_X', 'Inter', sans-serif;
    color: #1F2937;
}

.equation-input {
    width: 160px;
    height: 52px;
    padding: 6px 12px;
    font-size: 1.4rem;
    text-align: center;
    font-family: 'KaTeX_Math_X', 'KaTeX_Main_Minus', 'Inter', sans-serif;
    border: 2px solid #CBD5E1;
    border-radius: 10px;
    outline: none;
    transition: all 0.2s ease;
    background: #FFFFFF;
}

.equation-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.live-preview {
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #4F46E5;
}

.btn {
    padding: 8px 20px;
    font-size: 1.05rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    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);
}

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

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

/* Virtual Keyboard */
.virtual-keyboard {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    width: 100%;
    max-width: 360px;
    margin: 4px auto 0 auto;
    background: #F3F4F6;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid #E5E7EB;
}

.vk-btn {
    background: white;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    padding: 8px 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: #1F2937;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    user-select: none;
    font-family: 'KaTeX_Math_X', 'KaTeX_Main_Minus', 'Inter', sans-serif;
    transition: all 0.1s;
}

.vk-btn:hover {
    background: #F9FAFB;
    border-color: #9CA3AF;
}

.vk-btn:active {
    transform: translateY(1px);
    background: #E5E7EB;
}

.vk-del {
    color: #DC2626;
    font-family: 'Inter', sans-serif;
    font-weight: bold;
}

/* Feedback */
.feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}

.feedback.success {
    background: #DEF7EC;
    color: #03543F;
}

.feedback.error {
    background: #FDE8E8;
    color: #9B1C1C;
}

.feedback.warning {
    background: #FEF3C7;
    color: #92400E;
}

/* Detailed Solution */
#detailed-solution {
    background: #F9FAFB;
    padding: 16px;
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
    text-align: left;
    margin-top: 10px;
}

.correction-step {
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 6px;
    background: white;
    border: 1px solid #E5E7EB;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .equation-input {
        width: 140px;
        height: 48px;
        font-size: 1.25rem;
    }
    .virtual-keyboard {
        max-width: 100%;
        gap: 4px;
        padding: 6px;
    }
    .vk-btn {
        padding: 6px 0;
        font-size: 1.05rem;
    }
}
