@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-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: 18px;
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    border: 1px solid #E5E7EB;
    text-align: left;
}

.problem-statement {
    font-size: 1.15rem;
    line-height: 1.6;
    color: #1F2937;
    margin-bottom: 12px;
}

.problem-question {
    font-size: 1.15rem;
    font-weight: 700;
    color: #3730A3;
}

.math-display {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.35rem;
    color: var(--text-main);
    margin: 8px 0;
    user-select: none;
    min-height: 48px;
}

.input-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.equation-input-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 600;
    color: #374151;
}

.equation-input {
    width: 140px;
    height: 48px;
    border: 2px solid #D1D5DB;
    border-radius: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    color: #1F2937;
    background: white;
    outline: none;
    transition: all 0.2s ease;
}

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

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

.btn {
    appearance: none;
    border: none;
    outline: none;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    padding: 12px 24px;
    font-size: 1.1rem;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

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

.secondary-btn {
    background: #E5E7EB;
    color: #374151;
    padding: 10px 20px;
    font-size: 1rem;
}

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

/* Clavier Virtuel */
.virtual-keyboard {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    background: #F3F4F6;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid #E5E7EB;
    margin-top: 5px;
}

.vk-btn {
    background: white;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1F2937;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.1s ease;
    user-select: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

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

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

.vk-del {
    background: #FEE2E2;
    color: #DC2626;
    border-color: #FCA5A5;
}

.vk-del:hover {
    background: #FECACA;
}

/* Solution détaillée */
#detailed-solution {
    background: #F8FAFC;
    border: 1px solid #CBD5E1;
    border-radius: 12px;
    padding: 16px;
    margin-top: 15px;
    text-align: left;
}

.solution-step {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #E2E8F0;
}

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

.step-title {
    font-weight: 700;
    color: #1E293B;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.step-detail {
    color: #475569;
    padding-left: 14px;
}

/* Feedback message */
.feedback-box {
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    font-size: 1.05rem;
    animation: fadeIn 0.2s ease;
}

.feedback-success {
    background: #DCFCE7;
    color: #166534;
    border: 1px solid #86EFAC;
}

.feedback-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
