/* Math Worksheet Generator — preview on screen, worksheet / answer key on paper */
.mw-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:10px;}
.mw-row .ub-input-group{margin-bottom:0;}
.mw-opts{display:flex;flex-wrap:wrap;gap:6px 16px;margin:14px 0 4px;}
.mw-check{display:flex;gap:8px;align-items:center;font-size:.85rem;color:var(--text-secondary);cursor:pointer;}
.mw-check input{width:18px;height:18px;}
.mw-msg{font-size:.8rem;line-height:1.45;color:var(--text-secondary);min-height:1.2em;margin-top:8px;}
.mw-seed{display:flex;gap:6px;}
.mw-seed input{flex:1;min-width:0;text-transform:uppercase;}
.mw-seed button{flex:0 0 auto;min-height:44px;padding:0 12px;border-radius:var(--radius-sm);border:1.5px solid var(--text-tertiary);background:transparent;color:var(--text-primary);font-weight:700;cursor:pointer;}
.mw-seed button:hover{border-color:var(--accent);color:var(--accent);}
.mw-preview-wrap{width:100%;max-height:520px;overflow:auto;background:#e9e6df;border-radius:6px;padding:12px;}
#mw-preview .mw-sheet{background:#fff;color:#111;border-radius:4px;box-shadow:0 1px 6px rgba(0,0,0,.25);padding:18px 18px 12px;font-size:13px;}
.mw-sheet{font-family:Georgia,'Times New Roman',serif;color:#111;}
.mw-sheet__head{border-bottom:2px solid #111;padding-bottom:8px;margin-bottom:12px;}
.mw-sheet__title{font-size:1.25em;font-weight:700;}
.mw-sheet__lines{display:flex;flex-wrap:wrap;gap:6px 18px;margin:8px 0 4px;font-size:.92em;}
.mw-sheet__lines i{display:inline-block;width:9em;border-bottom:1px solid #111;height:1em;vertical-align:bottom;}
.mw-sheet__lines i.mw-short{width:3em;}
.mw-sheet__sub{font-size:.82em;color:#444;}
.mw-grid{list-style:none;margin:0;padding:0;display:grid;gap:14px 18px;counter-reset:mwp;}
.mw-cols-2{grid-template-columns:repeat(2,minmax(0,1fr));}
.mw-cols-3{grid-template-columns:repeat(3,minmax(0,1fr));}
.mw-cols-4{grid-template-columns:repeat(4,minmax(0,1fr));}
.mw-p{counter-increment:mwp;position:relative;padding-left:2.1em;min-height:2.2em;font-family:'Courier New',ui-monospace,monospace;font-size:1em;line-height:1.5;break-inside:avoid;page-break-inside:avoid;overflow-wrap:anywhere;}
.mw-p::before{content:counter(mwp) '.';position:absolute;left:0;top:0;font-family:Georgia,serif;font-weight:700;font-size:.9em;}
.mw-p--tall{min-height:3.2em;}
.mw-blank{display:inline-block;width:4.5em;border-bottom:1px solid #111;height:1.1em;vertical-align:bottom;}
.mw-a{color:#b4530a;font-weight:700;}
.mw-fr{display:inline-flex;flex-direction:column;text-align:center;vertical-align:middle;line-height:1.1;font-size:.95em;}
.mw-fr span:first-child{border-bottom:1.5px solid currentColor;padding:0 2px;}
.mw-fr span:last-child{padding:0 2px;}
.mw-vert{display:inline-flex;flex-direction:column;align-items:flex-end;font-size:1.1em;line-height:1.35;}
.mw-vert b{font-weight:400;margin-right:.6em;}
.mw-vert span:nth-child(2){border-bottom:1.5px solid #111;padding-left:.4em;}
.mw-vert__ans{min-height:1.5em;}
.mw-grid--vert{gap:20px 18px;}
.mw-grid--vert .mw-p{min-height:5.2em;}
.mw-sheet__foot{margin-top:16px;padding-top:6px;border-top:1px solid #bbb;font-size:.72em;color:#555;font-family:Georgia,serif;}
.mw-steps{font-size:.78rem;color:var(--text-secondary);margin-top:2px;line-height:1.6;}
.mw-print-btns{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px;}
.mw-print-btns .ub-tool-btn{flex:1 1 140px;}
#mw-print-root{display:none;}
@media (max-width:520px){
    .mw-cols-3,.mw-cols-4{grid-template-columns:repeat(2,minmax(0,1fr));}
    #mw-preview .mw-sheet{padding:12px 10px;font-size:12px;}
}
@media print{
    body.mw-printing > *:not(#mw-print-root){display:none!important;}
    body.mw-printing{background:#fff!important;color:#000!important;margin:0!important;padding:0!important;}
    body.mw-printing #mw-print-root{display:block!important;}
    #mw-print-root .mw-sheet{font-size:12.5pt;padding:0;}
    #mw-print-root .mw-cols-3{grid-template-columns:repeat(3,minmax(0,1fr));}
    #mw-print-root .mw-cols-4{grid-template-columns:repeat(4,minmax(0,1fr));}
    #mw-print-root .mw-a{color:#000;text-decoration:underline;}
    .mw-break{break-before:page;page-break-before:always;height:0;}
    @page{margin:14mm;}
}
