/* Formula controls share the workspace surface; only keys and fields need edges. */
.kyy-math-tools,.question-choice-editor,.question-layout{
  margin:.7rem 0;padding:.24rem 0 .48rem;background:transparent;
  border:0;border-bottom:1px solid var(--line);border-radius:0;
}
.kyy-math-tools summary,.question-layout summary{
  cursor:pointer;padding:.34rem 0;color:var(--soft);font-size:.84rem;font-weight:550;
}
.kyy-math-tools :is(summary:hover,summary:focus-visible),.question-layout :is(summary:hover,summary:focus-visible){
  color:var(--green-dark);
}
.kyy-math-body{padding:.3rem 0 .15rem}
.kyy-math-head,.kyy-math-actions{display:flex;flex-wrap:wrap;align-items:center;gap:.4rem}
.kyy-math-head :is(select,button),.kyy-math-actions button{
  max-width:100%;min-height:40px;font-size:.8rem;font-weight:550;
}
.kyy-math-palette{
  display:grid;grid-template-columns:repeat(auto-fit,minmax(2.55rem,1fr));
  gap:.3rem;margin:.55rem 0;
}
.kyy-math-palette button{
  min-width:0;min-height:40px;padding:.18rem .32rem;border:1px solid var(--line);
  border-radius:.3rem;background:var(--paper);color:var(--ink);
  font:550 1rem/1.2 system-ui,"PingFang SC",sans-serif;
}
.kyy-math-palette button:hover:not(:disabled){
  background:var(--light);border-color:var(--green);color:var(--green-dark);
}
.kyy-keyboard{padding:0;margin:.8rem 0;background:transparent;border:0}
.kyy-edit-keys{display:flex;flex-wrap:wrap;gap:.32rem;margin:0 0 .72rem}
.kyy-edit-keys button{
  min-width:3.4rem;min-height:40px;padding:.22rem .58rem;border:1px solid var(--line);
  border-radius:.3rem;background:var(--paper);color:var(--ink);font-size:.82rem;font-weight:550;
}
.kyy-edit-keys button:hover:not(:disabled){background:var(--light);border-color:var(--green);color:var(--green-dark)}
.kyy-key-row>span,.kyy-math-convert>label{
  display:block;font-weight:550;font-size:.82rem;color:var(--soft);
}
.kyy-key-row + .kyy-key-row{margin:.65rem 0 0}
.kyy-key-row .kyy-math-palette{margin:.28rem 0 0}
.kyy-math-tools .kyy-math-convert{
  margin:.55rem 0 0;padding:.25rem 0 0;border:0;border-top:1px solid var(--line);
}
.kyy-math-convert>summary{font-size:.82rem}
.kyy-math-convert>label{margin:.25rem 0 .3rem}
.kyy-math-convert>input{display:block;width:100%;min-height:42px}
.kyy-math-actions{margin-top:.6rem}
.kyy-math-live,.kyy-math-preview{
  font-size:.85rem;color:var(--soft);margin:.4rem 0 0;white-space:normal;overflow-wrap:anywhere;
}
.kyy-math-live:empty,.kyy-math-preview:empty{margin:0}
.kyy-math-visual:not(:empty){
  margin:.55rem 0 .2rem;padding:.6rem .7rem;max-width:100%;overflow-x:auto;
  border:0;border-radius:4px;background:var(--sheet);color:var(--ink);
}
.kyy-math-visual math{width:max-content;min-width:100%;margin:0;font-size:1.12rem}
.question-choice-editor legend{padding:0 .3rem;font-size:.88rem;font-weight:550}
.question-choice-editor .question-choice-toggle{display:flex;align-items:center;gap:.45rem;margin:.15rem 0;font-size:.84rem}
.question-choice-toggle input{width:auto;margin:0}
.question-option-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.42rem .75rem}
.question-option-fields>p{grid-column:1/-1;margin:.3rem 0;font-size:.8rem}
.question-option-fields label{display:grid;grid-template-columns:1.35rem minmax(0,1fr);align-items:center;gap:.2rem;margin:0}
.question-option-fields textarea{min-width:0;min-height:40px;margin:0;resize:none}
.question-layout-preview{
  padding:.65rem 0;margin:.55rem 0;min-width:0;border:0;border-bottom:1px solid var(--line);
  background:transparent;
}
.question-layout-preview .question-text,.question-option>.question-text{display:block;white-space:pre-wrap;overflow-wrap:anywhere}
.question-layout-preview p{margin:.25rem 0}

#mathModule .math-editor>label{display:block;margin:0 0 .35rem;font-size:.88rem;color:var(--soft);font-weight:550}
#mathModule #mathWorkspaceInput{min-height:44px;border:1px solid var(--line);border-radius:4px;background:var(--sheet)}
#mathModule .math-examples{gap:.2rem .3rem}
#mathModule .math-examples button{min-height:36px;padding:.3rem .4rem;border:0;background:transparent;color:var(--soft)}
#mathModule .math-examples button:hover:not(:disabled){background:var(--light);color:var(--green-dark)}
#mathModule .math-workspace-preview h3{color:var(--ink);font-weight:600}
#mathModule .math-preview-actions{gap:.7rem}
#mathModule .math-transfer{padding-top:.65rem;margin-top:0}
#mathModule :is(button,select,input):focus-visible,.kyy-math-tools :focus-visible,.question-layout :focus-visible{
  outline:2px solid var(--green);outline-offset:2px;
}
@media(max-width:820px){
  #mathModule .math-workspace-preview{padding:.85rem 0 0;border-inline-start:0;border-top:1px solid var(--line)}
}
@media(max-width:540px){
  .question-option-fields{grid-template-columns:minmax(0,1fr)}
  .kyy-math-palette button,.kyy-edit-keys button{min-height:44px}
}
