/* PR31 — genuine operation-first maths editor.
 * The notebook now displays MathML equations, mathematical buttons and
 * an automatically calculated preview, instead of an editable answer line. */
.notebook-math-editor{
  min-width:0;display:grid;gap:7px;padding:10px 11px;border:1px solid #ae956a;
  border-radius:11px;background:linear-gradient(170deg,#f9f1da,#eadbb8);
  box-shadow:inset 0 1px 0 #fff9e8aa
}
.notebook-math-editor>label{
  font-size:.78rem;line-height:1.4;color:#3d4c42;letter-spacing:0
}
.notebook-operator-palette{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
.notebook-operator-palette button,.notebook-maths-keypad button{
  min-width:0;min-height:36px;border:1px solid #ad9871;border-radius:7px;
  background:#fff9e8;color:#273d34;
  box-shadow:inset 0 1px 0 #fff,0 2px 3px #453b2c19;
  font:500 1.12rem "Cambria Math","STIX Two Math",Georgia,serif;
  cursor:pointer;transition:background .12s,box-shadow .12s
}
.notebook-operator-palette button:hover,.notebook-maths-keypad button:hover{
  background:#f2dfb5;border-color:#746143
}
.notebook-operator-palette button[aria-pressed="true"]{
  background:#2d574c;color:#fff0cc;border-color:#325e51;
  box-shadow:0 0 0 2px #2b635d42
}
.notebook-operator-palette button:focus-visible,.notebook-maths-keypad button:focus-visible{
  outline:3px solid #325b62;outline-offset:1px
}
.notebook-math-editor .notebook-input-row{gap:7px;margin:0}
.notebook-math-field{position:relative;flex:1 1 auto;min-width:0}
.notebook-math-field input{
  width:100%;min-width:0;min-height:42px;padding:7px 95px 7px 11px;
  color:#213831;background:#fffdf5;border:2px solid #958360;
  border-radius:8px;font:500 1.0rem "Cambria Math",Georgia,serif;
  font-variant-numeric:lining-nums;letter-spacing:.05em
}
.notebook-math-field input[aria-invalid="true"]{border-color:#9a4443}
.notebook-math-field input:focus-visible{outline:3px solid #3a7278;outline-offset:2px}
.notebook-operation-typeset{
  display:grid;place-items:center;position:absolute;right:6px;top:50%;
  transform:translateY(-50%);max-width:86px;min-width:50px;
  height:30px;padding:2px 8px;border:1px solid #cfb98a;
  border-radius:6px;background:#f5e6ca;color:#284b41;
  font:1.14rem "Cambria Math","STIX Two Math",serif;pointer-events:none;white-space:nowrap
}
.notebook-math-editor #notebook-apply{
  flex:0 0 auto;min-height:42px;padding:7px 11px;font-size:.76rem;
  white-space:nowrap
}
.notebook-math-editor #notebook-apply:disabled{opacity:.53;cursor:not-allowed}
.notebook-maths-keypad{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:3px}
.notebook-maths-keypad button{min-height:30px;padding:2px 0;font-size:.86rem}
.notebook-maths-keypad button[data-notebook-key="x"]{font-style:italic;font-weight:700}
.notebook-maths-keypad button[data-notebook-key="backspace"]{font:600 .88rem sans-serif}
/* PR47: expanding ONE sealed expression is a local identity rewrite.
   It is an option, never a preselected algebraic first step. */
.notebook-expand-choices{display:flex;gap:6px;flex-wrap:wrap}
.notebook-expand-choices button{
  flex:1 1 135px;min-height:34px;padding:6px 10px;
  border:1px solid #987a4d;border-radius:7px;
  color:#2b4c40;background:#e7ddc3;
  font-weight:700;font-size:.76rem;cursor:pointer
}
.notebook-expand-choices button:hover:not(:disabled){background:#d6c5a4}
.notebook-expand-choices button:focus-visible{outline:3px solid #396d73;outline-offset:2px}
.notebook-expand-choices button[hidden]{display:none!important}
.notebook-expand-choices:has(button[hidden]:first-child):has(button[hidden]:last-child){display:none}
.notebook-operation-typeset:has(mtext){font-size:.74rem}
@media(min-width:900px) and (max-height:649px){
  .app-shell .notebook-expand-choices button{min-height:24px;padding:3px 7px}
}
.notebook-operation-tip{font-size:.68rem;line-height:1.3;color:#766344;margin:0}
.notebook-operation-preview{
  display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);
  gap:6px;align-items:center;border-top:1px solid #c5b38a;
  padding:8px 0 2px;min-width:0
}
.notebook-operation-preview>div{min-width:0}
.notebook-operation-preview small{
  display:block;font-size:.64rem;color:#79684a;margin-bottom:4px;
  font-weight:700;letter-spacing:.02em
}
.notebook-math-output{
  display:block;min-height:37px;max-width:100%;overflow:auto;
  padding:7px 8px;border-radius:6px;background:#fffaf1;
  color:#263a36;font:normal 1.13rem "Cambria Math","STIX Two Math",Georgia,serif;
  line-height:1.12;white-space:nowrap
}
.notebook-math-output math,.notebook-line-equation math,
.notebook-operation-typeset math{
  font-family:"Cambria Math","STIX Two Math","Latin Modern Math",serif;
  font-size:1.0em
}
.notebook-preview-arrow{
  display:grid;gap:3px;justify-items:center;text-align:center;
  color:#46594b;max-width:100px
}
.notebook-preview-arrow span:first-child{font-size:1.35rem;line-height:1}
.notebook-preview-arrow span:last-child{font-size:.66rem;line-height:1.2;overflow-wrap:anywhere}
.notebook-preview-next .notebook-math-output[data-state="error"]{
  color:#85312a;background:#f8e1d7;white-space:normal;font:normal .7rem/1.3 sans-serif
}
.notebook-preview-next .notebook-math-output[data-state="incomplete"]{
  color:#746449;background:#f4e9d1;white-space:normal;font:normal .72rem/1.3 sans-serif
}
.notebook-paper .notebook-line-equation{
  display:inline-block;font:normal 1.18rem "Cambria Math","STIX Two Math",Georgia,serif
}
.notebook-paper .notebook-lines li small{font-size:.69rem}
.notebook-paper .notebook-form{margin-top:5px;min-height:0}
.notebook-paper .notebook-help{margin-top:10px}
.notebook-paper .notebook-feedback{margin:6px 0 4px;min-height:26px}
@media (min-width:900px) and (min-height:500px){
  .app-shell .notebook-paper{overflow:hidden}
  .app-shell .notebook-form{flex:0 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain}
  .app-shell .notebook-paper .notebook-lines{flex:1 1 42px;min-height:38px}
  .app-shell .notebook-math-editor{gap:5px;padding:7px 8px}
  .app-shell .notebook-operator-palette button{min-height:29px}
  .app-shell .notebook-maths-keypad button{min-height:25px}
  .app-shell .notebook-math-field input,.app-shell .notebook-math-editor #notebook-apply{min-height:35px}
  .app-shell .notebook-math-output{min-height:29px;padding:5px 6px}
  .app-shell .notebook-operation-preview{padding:5px 0 0}
  .app-shell .notebook-paper .notebook-feedback{flex:none;min-height:21px}
  .app-shell .notebook-paper .notebook-actions{flex:none}
  .app-shell .notebook-paper .notebook-help{font-size:.6rem;line-height:1.25}
}
@media (min-width:900px) and (min-height:500px) and (max-height:649px){
  .app-shell .notebook-math-editor{padding:5px 7px;gap:3px}
  .app-shell .notebook-math-editor>label{font-size:.69rem}
  .app-shell .notebook-operator-palette button{min-height:26px;font-size:.96rem}
  .app-shell .notebook-maths-keypad button{min-height:23px}
  .app-shell .notebook-operation-tip{font-size:.60rem;line-height:1.1}
  .app-shell .notebook-operation-preview small{font-size:.55rem;margin-bottom:2px}
  .app-shell .notebook-math-output{min-height:26px;font-size:.96rem;padding:3px 5px}
  .app-shell .notebook-paper .notebook-help{display:none}
}
@media(max-width:680px){
  .notebook-operation-preview{grid-template-columns:1fr;gap:4px}
  .notebook-preview-arrow{max-width:none;display:flex;align-items:center;justify-content:center}
  .notebook-preview-arrow span:first-child{font-size:1rem}
  .notebook-maths-keypad{grid-template-columns:repeat(6,minmax(0,1fr))}
  .notebook-maths-keypad button{min-height:40px}
  .notebook-math-editor #notebook-apply{white-space:normal}
}
@media(max-width:540px){
  .notebook-math-editor .notebook-input-row{flex-direction:column;align-items:stretch}
  .notebook-math-editor #notebook-apply{min-height:44px}
  .notebook-operator-palette button{min-height:44px}
  .notebook-maths-keypad button{min-height:44px}
  .notebook-operation-preview{gap:5px}
  .notebook-math-output{font-size:1.1rem}
}
