@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: 100 900;
  font-style: normal;
  unicode-range: U+2212;
}

:root {
    --primary-color: #2563EB;
    --primary-hover: #1D4ED8;
    --success-color: #10B981;
    --error-color: #EF4444;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --bg-card: rgba(255, 255, 255, 0.92);
    --border-card: rgba(255, 255, 255, 0.6);
}

.exercise-wrapper {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    border-radius: 16px;
    padding: 15px 20px;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 720px;
    padding: 0px 10px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
}

.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.06), inset 0 1px 0 rgba(255, 255, 255, 0.7);
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
}

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

.math-display {
    font-size: 1.25rem;
    color: var(--text-main);
    margin: 8px 0;
    line-height: 1.6;
}

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

.input-container-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 600;
    color: #1F2937;
    width: 100%;
}

#answer-input {
    width: 100%;
    max-width: 240px;
    padding: 10px 16px;
    border: 2px solid #CBD5E1;
    border-radius: 10px;
    text-align: center;
    font-size: 1.4rem;
    font-family: 'KaTeX_Main', 'KaTeX_Main_Minus', 'Inter', serif;
    outline: none;
    transition: all 0.2s ease;
    background: white;
    touch-action: manipulation;
}

#answer-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.btn {
    border-radius: 9999px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    border: none;
    text-align: center;
}

.primary-btn {
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

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

/* Virtual Keyboard */
.virtual-keyboard {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    width: 100%;
    max-width: 480px;
    margin: 4px auto 0 auto;
}

.vk-btn {
    padding: 10px 0;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    background: white;
    color: #1E293B;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    transition: all 0.15s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.vk-btn:hover {
    background: #F1F5F9;
    border-color: #CBD5E1;
}

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

.vk-minus, .vk-del {
    background: #F8FAFC;
    color: #475569;
}

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

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

/* Feedback & Solution Styles */
.feedback-box {
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: fadeIn 0.3s ease-out;
}

.feedback-success {
    background: #ECFDF5;
    border: 1.5px solid #A7F3D0;
    color: #065F46;
}

.feedback-error {
    background: #FEF2F2;
    border: 1.5px solid #FECACA;
    color: #991B1B;
}

.detailed-solution {
    background: white;
    border-radius: 14px;
    padding: 18px;
    border: 1.5px solid #E5E7EB;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    text-align: left;
    margin-top: 10px;
}

.detailed-solution h4 {
    font-size: 1.15rem;
    color: #1E3A8A;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tables de statistiques */
.stat-table {
    border-collapse: collapse;
    margin: 12px auto;
    background: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    border-radius: 8px;
    overflow: hidden;
}

.stat-table th, .stat-table td {
    border: 1px solid #D1D5DB;
    padding: 8px 14px;
    text-align: center;
    font-size: 1rem;
}

.stat-table th {
    background: #F8FAFC;
    font-weight: 700;
    color: #1E293B;
}

.stat-table tr:hover {
    background-color: #F8FAFC;
}

.stat-table .ecc-row {
    background: #EFF6FF;
    color: #1D4ED8;
    font-weight: 600;
}

/* Boxplot Diagram SVG */
.boxplot-container {
    width: 100%;
    max-width: 560px;
    margin: 10px auto;
    background: white;
    border-radius: 12px;
    padding: 12px;
    border: 1px solid #E2E8F0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    overflow-x: auto;
}

.boxplot-svg {
    width: 100%;
    min-width: 320px;
    height: auto;
    display: block;
}

/* Mini Calculator Tool */
.calc-toggle-btn {
    background: #F1F5F9;
    border: 1px solid #CBD5E1;
    color: #334155;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.2s;
}

.calc-toggle-btn:hover {
    background: #E2E8F0;
}

.mini-calculator {
    position: absolute;
    top: 60px;
    right: 20px;
    width: 250px;
    background: #0F172A;
    border-radius: 14px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    padding: 12px;
    z-index: 50;
    border: 1px solid #334155;
    animation: slideDown 0.2s ease-out;
}

.calc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #1E293B;
}

.calc-screen {
    background: #020617;
    border: 1px solid #1E293B;
    border-radius: 8px;
    padding: 8px 10px;
    text-align: right;
    margin-bottom: 10px;
}

.calc-expression {
    font-size: 0.75rem;
    color: #94A3B8;
    min-height: 16px;
    word-break: break-all;
}

.calc-value {
    font-size: 1.4rem;
    color: #38BDF8;
    font-weight: 700;
    font-family: monospace;
    overflow-x: auto;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.c-btn {
    background: #1E293B;
    color: #F8FAFC;
    border: none;
    border-radius: 6px;
    padding: 8px 0;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.15s;
}

.c-btn:hover {
    background: #334155;
}

.c-op {
    background: #3B82F6;
    color: white;
}

.c-op:hover {
    background: #2563EB;
}

.c-equal {
    background: #10B981;
    color: white;
}

.c-equal:hover {
    background: #059669;
}

.c-clear {
    background: #EF4444;
    color: white;
}

.c-clear:hover {
    background: #DC2626;
}

.calc-copy-btn {
    width: 100%;
    margin-top: 8px;
    background: #334155;
    color: #38BDF8;
    border: 1px solid #475569;
    border-radius: 6px;
    padding: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.2s;
}

.calc-copy-btn:hover {
    background: #475569;
    color: white;
}

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

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

@media (max-width: 640px) {
    .virtual-keyboard {
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
    }
    .vk-btn {
        padding: 8px 0;
        font-size: 1.05rem;
    }
    .mini-calculator {
        width: calc(100% - 24px);
        left: 12px;
        right: 12px;
        top: 50px;
    }
}
