main { max-width: 1080px; }
.level-picker { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; background: white; padding: 18px; }
.level-picker .choice { text-align: left; justify-content: flex-start; gap: 12px; }
.level-picker p { grid-column: 1/-1; margin: 0; color: var(--muted); font-size: .9rem; }
#formula, #preview, #result { text-align: center; overflow-x: auto; padding: 18px 8px; font-size: 1.25rem; }
#result { border: 2px solid var(--green); border-radius: 12px; background: #edf8ed; }
#expansion { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 20px 0; }
.term { background: white; color: var(--text); border: 2px solid var(--border); min-height: 90px; padding: 14px; }
.term[aria-pressed="true"] { border-color: var(--ocean); background: #d9edf1; box-shadow: 0 0 0 3px #abd5df; }
.difference { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 14px; align-items: end; max-width: 640px; margin: 24px auto; }
.difference label { min-width: 0; }
.difference label span { display: block; margin-bottom: 8px; font-weight: 650; }
.difference select { width: 100%; padding: 12px; min-height: 50px; font: inherit; color: var(--text); background: white; border: 2px solid var(--border); border-radius: 9px; }
.difference select.validated { border-color: #368844; background: #edf8ed; opacity: 1; }
.minus { font-size: 2rem; padding-bottom: 4px; }
#score, #math-status { color: var(--muted); }
@media(max-width: 620px) {
  .level-picker { grid-template-columns: 1fr; }
  .difference { gap: 8px; }
  .difference label span { font-size: .85rem; }
  .difference select { padding: 9px 4px; font-size: .95rem; }
  .term { padding: 12px 8px; }
}

/* Développement regroupé par valeur de l’indice. */
#expansion { align-items: flex-start; gap: 12px 8px; }
.term-group { display: flex; flex-direction: column; align-items: center; max-width: 100%; overflow-x: auto; }
.term-pair { display: flex; align-items: center; gap: 4px; padding: 4px; }
.term-pair .term { position: relative; min-height: 76px; padding: 12px 7px; font-size: 1rem; border: 1px solid transparent; border-radius: 8px; }
.term-pair .term:hover { border-color: var(--border); }
.term-pair .term.cancelled { color: #72828c; background: #f4f6f7; box-shadow: none; }
.term.cancelled::after { content: ''; position: absolute; top: 50%; left: 6%; width: 88%; height: 2px; background: #677b89; transform: rotate(-28deg); pointer-events: none; }
.parenthesis { font-size: 2.8rem; font-weight: 300; }
.index-caption { color: #88949f; font-size: .85rem; padding: 4px 0; }
.expansion-plus, .ellipsis { padding-top: 30px; }

/* Menus avec rendu mathématique et navigation au clavier. */
.math-field { min-width: 0; }
.field-label { display: block; margin-bottom: 8px; font-weight: 650; }
.math-menu { position: relative; }
.math-toggle { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; min-height: 76px; padding: 12px; background: white; color: var(--text); border: 2px solid var(--border); border-radius: 9px; font-weight: 500; }
.math-toggle > span:first-child { min-width: 0; overflow-x: auto; padding: 3px; }
.math-toggle.validated { border-color: #368844; background: #edf8ed; opacity: 1; }
.math-options { position: absolute; top: calc(100% + 6px); left: 0; width: 100%; z-index: 20; max-height: 330px; overflow-y: auto; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: white; box-shadow: 0 10px 24px #0c355c26; }
.math-option { display: block; width: 100%; min-height: 72px; padding: 12px 4px; background: white; color: var(--text); border: 2px solid transparent; border-radius: 7px; font-weight: 500; overflow-x: auto; }
.math-option[aria-selected="true"] { background: #d9edf1; border-color: var(--ocean); }
.math-option:focus { outline: none; border-color: var(--ocean); background: #edf8fa; }
.math-toggle:hover, .math-option:hover { transform: none; }
@media(max-width: 620px) { .field-label { font-size: .85rem; } .math-toggle { padding: 9px 4px; } }
