#shatoor-math{--sm-ink:#273d3a;--sm-teal:#25685f;--sm-gold:#e9bd6d;--sm-cream:#f6f4ee;--sm-line:#d8e0dc;--sm-muted:#52645f;--sm-white:#fff;font:16px/1.8 'Noto Sans Arabic',Tahoma,Arial,sans-serif;color:var(--sm-ink);background:var(--sm-cream);direction:rtl;min-height:100vh;overflow-wrap:anywhere}
#shatoor-math *,#shatoor-math *::before,#shatoor-math *::after{box-sizing:border-box}
#shatoor-math h1,#shatoor-math h2,#shatoor-math h3,#shatoor-math p{margin:0 0 .6rem}#shatoor-math h1{font-size:clamp(1.7rem,4vw,2.5rem);line-height:1.5}#shatoor-math h2{font-size:1.25rem}#shatoor-math a{color:var(--sm-teal)}
#shatoor-math main{width:min(1160px,100%);padding:20px 14px;margin:auto}#shatoor-math .sm-header{padding:28px max(18px,calc((100% - 1132px)/2));background:#fff;border-top:5px solid var(--sm-teal);border-bottom:1px solid var(--sm-line);display:flex;align-items:center;gap:26px;flex-wrap:wrap}
#shatoor-math .sm-brand{font-size:24px;color:var(--sm-teal);min-width:150px;border-inline-end:2px solid var(--sm-gold);padding-inline-end:24px}#shatoor-math .sm-brand span{display:block;font:12px/2 Arial;letter-spacing:.4px}#shatoor-math .sm-eyebrow{font-size:13px;color:var(--sm-teal);font-weight:bold}#shatoor-math .sm-header>div:nth-child(2){flex:1;min-width:230px}#shatoor-math .sm-header p{color:var(--sm-muted);font-size:14px}
#shatoor-math .sm-panel{padding:20px;background:#fff;border:1px solid var(--sm-line);border-radius:16px;margin-bottom:20px}#shatoor-math .sm-section-title{display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap;margin-bottom:18px}#shatoor-math .sm-tag{font-size:12px;background:#f9f1df;padding:4px 12px;border-radius:30px}
#shatoor-math button,#shatoor-math select,#shatoor-math input{font:inherit;max-width:100%;min-width:0;min-height:46px;border:1px solid #a5b8b1;border-radius:9px;padding:8px 12px;background:#fff;color:var(--sm-ink)}#shatoor-math button{cursor:pointer;font-size:14px;font-weight:bold}#shatoor-math button:hover{background:#eef4f1}#shatoor-math button:disabled{opacity:.55;cursor:default}#shatoor-math button:focus-visible,#shatoor-math input:focus-visible,#shatoor-math select:focus-visible,#shatoor-math summary:focus-visible,#shatoor-math a:focus-visible{outline:3px solid #a56813;outline-offset:3px}
#shatoor-math .sm-primary,#shatoor-math button[aria-pressed=true]{background:var(--sm-teal);color:#fff;border-color:var(--sm-teal)}#shatoor-math .sm-primary:hover{background:#194f47}#shatoor-math .sm-tracks{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:24px}#shatoor-math .sm-tracks button{text-align:start;display:flex;flex-direction:column;justify-content:center;gap:2px}#shatoor-math .sm-tracks small{font-size:11px;font-weight:normal;opacity:.85}#shatoor-math .sm-controls{display:grid;grid-template-columns:minmax(0,1fr);gap:16px}#shatoor-math label{font-size:13px;font-weight:bold;display:flex;flex-direction:column;gap:6px}#shatoor-math label input,#shatoor-math label select{width:100%;font-size:14px;font-weight:normal}#shatoor-math .sm-help{color:var(--sm-muted);font-size:12px;margin-top:8px}#shatoor-math details{border-top:1px solid var(--sm-line);margin-top:18px;padding-top:14px}#shatoor-math summary{cursor:pointer;font-size:14px;font-weight:bold;padding:8px 0}#shatoor-math .sm-advanced{margin-top:18px}#shatoor-math .sm-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-top:14px}#shatoor-math .sm-actions .sm-help{flex:1;min-width:190px}#shatoor-math .sm-toolbar{background:#f2f6f3;border:1px solid var(--sm-line);border-radius:12px;padding:14px;margin-top:18px;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}#shatoor-math .sm-toolbar .sm-actions{margin:0}#shatoor-math #sm-result,#shatoor-math #sm-notice{font-size:14px;margin-top:12px}#shatoor-math .sm-paper{padding:22px 16px;background:#fff;border:1px solid var(--sm-line);border-radius:12px}
#shatoor-math .sm-sheet-head{border-bottom:2px solid var(--sm-ink);padding-bottom:16px;margin-bottom:20px;break-inside:avoid}#shatoor-math .sm-sheet-top{display:flex;align-items:start;justify-content:space-between;gap:12px}#shatoor-math .sm-sign{color:var(--sm-teal);font-weight:bold;font-size:24px;white-space:nowrap}#shatoor-math .sm-meta{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;font-size:12px;margin-top:16px}#shatoor-math .sm-meta span{border-bottom:1px dotted #aab7b2;padding-bottom:6px}#shatoor-math .sm-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:16px}#shatoor-math .sm-question{border:1px solid var(--sm-line);border-radius:10px;padding:16px;break-inside:avoid;page-break-inside:avoid;position:relative;min-width:0}#shatoor-math .sm-q-head{display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap;font-size:12px;font-weight:bold;border-bottom:1px solid #e6ebe8;padding-bottom:8px;margin-bottom:10px}#shatoor-math .sm-question p{font-size:13px}#shatoor-math .sm-math{direction:ltr;unicode-bidi:isolate;text-align:center;font:600 20px/1.8 'DejaVu Sans',Arial,sans-serif;white-space:pre-line;overflow-wrap:anywhere;background:#f7f9f7;padding:12px 6px;border-radius:6px;margin:12px 0}#shatoor-math .sm-vertical{white-space:pre;font-variant-numeric:tabular-nums;text-align:right;width:max-content;margin:12px auto;max-width:100%}#shatoor-math .sm-answer{direction:ltr;text-align:center;unicode-bidi:isolate;font-family:'DejaVu Sans',Arial,sans-serif}#shatoor-math .sm-answer-label{margin-top:16px}#shatoor-math .sm-answer-label input{font-size:18px;width:100%}#shatoor-math .sm-solution{background:#f4f7f3;border-inline-start:3px solid var(--sm-teal);padding:12px;margin-top:12px;font-size:12px}#shatoor-math .sm-step-eq{direction:ltr;unicode-bidi:isolate;text-align:left;font-family:'DejaVu Sans',Arial;font-size:12px;overflow-wrap:anywhere}#shatoor-math .sm-correct{border:2px solid #2b7250}#shatoor-math .sm-wrong{border:2px solid #a83c3c}#shatoor-math .sm-empty{border:2px dashed #8f6d2b}#shatoor-math .sm-status{font-size:12px;font-weight:bold}#shatoor-math .sm-scratch{height:55px;background:repeating-linear-gradient(to bottom,transparent 0,transparent 25px,#dce2de 26px,transparent 27px);margin-top:16px}#shatoor-math .sm-large .sm-scratch{height:110px}#shatoor-math .sm-watermark{display:block;text-align:left;font-size:12px;opacity:.14;line-height:1;user-select:none;margin-top:12px}#shatoor-math .sm-sheet-footer{margin-top:22px;padding-top:12px;border-top:1px solid var(--sm-line);font-size:12px;display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap}#shatoor-math .sm-bottom{text-align:center;padding:28px;font-size:13px}#shatoor-math #sm-print-root{display:none}#shatoor-math [hidden]{display:none!important}
@media(min-width:600px){#shatoor-math .sm-controls{grid-template-columns:repeat(2,minmax(0,1fr))}#shatoor-math .sm-grid{grid-template-columns:repeat(2,minmax(0,1fr))}#shatoor-math .sm-paper{padding:30px}#shatoor-math .sm-tracks{grid-template-columns:repeat(4,minmax(0,1fr))}#shatoor-math .sm-wide{grid-column:1/-1}}
@media(min-width:1000px){#shatoor-math .sm-controls{grid-template-columns:repeat(3,minmax(0,1fr))}#shatoor-math .sm-meta{grid-template-columns:repeat(4,minmax(0,1fr))}#shatoor-math .sm-panel{padding:26px}#shatoor-math .sm-tracks{grid-template-columns:repeat(7,minmax(0,1fr))}}
@page{size:A4 portrait;margin:12mm}
@media print{
 html,body{margin:0!important;padding:0!important}
 #shatoor-math{background:#fff;color:#182b25;font-size:11pt;line-height:1.45;min-height:0;overflow:visible}
 #shatoor-math>.sm-header,#shatoor-math>main{display:none!important}
 #shatoor-math #sm-print-root{display:block!important}
 #shatoor-math .sm-paper{border:0;border-radius:0;padding:0;margin:0;overflow:visible}
 #shatoor-math .sm-print-page{break-after:page;page-break-after:always}
 #shatoor-math .sm-print-page:last-child{break-after:auto;page-break-after:auto}
 #shatoor-math .sm-print-table{border:0;border-collapse:separate;border-spacing:3mm 0;width:100%;table-layout:fixed;direction:rtl}
 #shatoor-math .sm-print-table thead{display:table-header-group}
 #shatoor-math .sm-print-table tfoot{display:table-footer-group}
 #shatoor-math .sm-print-table tbody{break-inside:auto}
 #shatoor-math .sm-print-table tr{break-inside:avoid;page-break-inside:avoid}
 #shatoor-math .sm-print-table td{border:0;padding:0;vertical-align:top;min-width:0}
 #shatoor-math .sm-sheet-head{padding-bottom:2mm;margin-bottom:3mm;border-bottom-width:.4mm}
 #shatoor-math .sm-sheet-top{gap:3mm}
 #shatoor-math .sm-sheet-head h2{font-size:17pt;line-height:1.3;margin-bottom:1mm}
 #shatoor-math .sm-sheet-head p{font-size:9pt;line-height:1.4;margin:0 0 1mm}
 #shatoor-math .sm-eyebrow{font-size:9pt}
 #shatoor-math .sm-sign{font-size:20pt}
 #shatoor-math .sm-meta{grid-template-columns:repeat(4,minmax(0,1fr));font-size:9pt;gap:2mm;margin-top:2mm}
 #shatoor-math .sm-meta span{padding-bottom:1mm}
 #shatoor-math .sm-question{display:block;width:100%;margin:0 0 3mm;border-color:#9daea7;border-radius:1.5mm;padding:3mm;break-inside:avoid;page-break-inside:avoid}
 #shatoor-math .sm-q-head{font-size:10pt;line-height:1.3;margin-bottom:1.5mm;padding-bottom:1mm}
 #shatoor-math .sm-q-head>span:last-child{display:none}
 #shatoor-math .sm-question p{font-size:11pt;line-height:1.45;margin:0 0 1.5mm}
 #shatoor-math .sm-math{font-size:15pt;line-height:1.5;background:none;padding:1mm 0;margin:1.5mm 0}
 #shatoor-math .sm-basic>p{display:none}
 #shatoor-math .sm-basic .sm-q-head{border:0;line-height:1.2;padding:0;margin:0}
 #shatoor-math .sm-basic .sm-math{font-size:17pt;line-height:1.35;padding:0;margin:1mm 0}
 #shatoor-math .sm-basic .sm-watermark{position:absolute;top:3mm;left:3mm;margin:0}
 #shatoor-math .sm-basic .sm-solution{padding:1mm 1.5mm;margin-top:1mm}
 #shatoor-math .sm-basic .sm-step-eq{font-size:11pt}
 #shatoor-math .sm-question .sm-scratch{height:13mm;margin-top:1mm;background:repeating-linear-gradient(to bottom,transparent 0,transparent 6mm,#dce2de 6.2mm,transparent 6.4mm)}
 #shatoor-math .sm-basic .sm-scratch{height:7mm}
 #shatoor-math .sm-calculus .sm-scratch{height:19mm}
 #shatoor-math .sm-large .sm-question .sm-scratch{height:27mm}
 #shatoor-math .sm-solution{background:none;padding:1.5mm 2mm;margin-top:1.5mm;font-size:10pt;line-height:1.4;border-inline-start-width:.4mm}
 #shatoor-math .sm-solution p{font-size:10pt;line-height:1.4;margin:1mm 0}
 #shatoor-math .sm-step-eq{font-size:10pt;line-height:1.4;white-space:normal;overflow-wrap:anywhere}
 #shatoor-math .sm-watermark{color:#687a70;opacity:.2;margin-top:1mm;font-size:9pt}
 #shatoor-math .sm-sheet-footer{margin:0;padding:1.5mm 0 0;border-top-width:.2mm;font-size:9pt;line-height:1.3;break-inside:avoid}
 #shatoor-math .sm-bank-warning{border:1px solid #856826;padding:2mm}
}

#shatoor-math textarea{font:12px/1.7 monospace;display:block;width:100%;max-width:100%;padding:12px;border:1px solid var(--sm-line);border-radius:8px;resize:vertical;margin-bottom:12px}#shatoor-math textarea:focus-visible{outline:3px solid #a56813;outline-offset:3px}

#shatoor-math .sm-choice-section{margin-top:20px;border-top:1px solid var(--sm-line);padding-top:16px}#shatoor-math .sm-choice-section h3{font-size:15px}#shatoor-math .sm-choices{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}#shatoor-math .sm-choices button{white-space:normal;line-height:1.7;text-align:right;min-height:48px}#shatoor-math .sm-startup{background:#fbf3df;border:1px solid #d1b16b;border-radius:8px;padding:10px;font-size:13px;margin-bottom:16px}@media(min-width:768px){#shatoor-math .sm-choices{grid-template-columns:repeat(3,minmax(0,1fr))}}

/* MathML Core supplies spatial order; text direction never decides operand order. */
#shatoor-math .sm-math-native{direction:ltr;unicode-bidi:isolate;max-width:100%;font-family:'STIX Two Math','Cambria Math','DejaVu Math TeX Gyre','Noto Sans Math',math;font-size:1em;line-height:normal;white-space:normal}
#shatoor-math .sm-math-native :is(mrow,mtable,mtr,mtd,msup,msub,msubsup,mfrac,msqrt){direction:ltr;unicode-bidi:isolate}
#shatoor-math .sm-math-native :is(mn,mi,mo){direction:ltr;unicode-bidi:isolate-override}
#shatoor-math .sm-math-native mtd{text-align:left;padding:.05em .1em}
#shatoor-math .sm-math-vertical{border-bottom:1px solid currentColor}
#shatoor-math .sm-math,#shatoor-math .sm-step-eq{direction:ltr;unicode-bidi:isolate;white-space:normal;overflow-wrap:normal}
@media print{#shatoor-math .sm-math-native{font-size:1em}#shatoor-math .sm-step-eq .sm-math-native{font-size:1em}#shatoor-math .sm-math-native :is(mn,mi,mo){unicode-bidi:isolate-override}}

#shatoor-math input.sm-answer{direction:ltr;unicode-bidi:bidi-override}

/* Compact continuation headers save paper without changing any font size. */
@media print{
 #shatoor-math .sm-compact-head{margin-bottom:2mm;padding-bottom:1.5mm}
 #shatoor-math .sm-page-number{white-space:nowrap;unicode-bidi:isolate}
}

/* Print repair 7: no speculative application page numbers or repeated student fields. */
#shatoor-math{--sm-print-build:shatoor-print-7}
@media print{
 #shatoor-math .sm-first-page-head{display:block;position:static;break-inside:avoid;page-break-inside:avoid;break-after:avoid-page;page-break-after:avoid}
 #shatoor-math .sm-print-caption{display:flex;justify-content:space-between;flex-wrap:wrap;gap:2mm;padding:1.5mm 0;margin-bottom:2mm;border-bottom:.2mm solid #9daea7}
}

/* Final print7 polish: named A4 page margins, no guessed physical page counts.
 * Chromium 131+ supports page margin boxes. Older browsers omit the small
 * continuation label rather than duplicate the first-page header.
 */
#shatoor-math .sm-unit-coefficient>:nth-child(-n+2){display:none}
@media print{
 #shatoor-math .sm-print-student{page:sm-student}
 #shatoor-math .sm-print-key{page:sm-key}
 /* The label now lives in the physical page margin, never in the first body. */
 #shatoor-math .sm-print-table thead{display:none}
 /* Display-style fractions keep numerator/denominator readable at the existing
  * font size. Native MathML supplies their intrinsic height; no fixed clipping. */
 #shatoor-math .sm-step-eq .sm-math-native:has(mfrac){math-style:normal}
}
@page sm-student{
 @top-center{content:"عالم شطور · ورقة الطالب";font:9pt Tahoma,Arial,sans-serif;direction:rtl;color:#273d3a}
}
@page sm-key{
 @top-center{content:"عالم شطور · نموذج الإجابة";font:9pt Tahoma,Arial,sans-serif;direction:rtl;color:#273d3a}
}
@page sm-student:first{@top-center{content:none}}
@page sm-key:first{@top-center{content:none}}

/* Independently measured A4 groups. No fixed row count, font reduction, or
 * imposed height: oversized content always retains native fragmentation. */
@media print{
 #shatoor-math .sm-a4-page{display:block;break-after:page;page-break-after:always}
 #shatoor-math .sm-a4-page:last-child{break-after:auto;page-break-after:auto}
}

/* A4 repair: ordinary block pages; table footer fragmentation is not involved.
 * Keep footer with the final question row, including the native fallback path.
 * Sizes of text, MathML and student scratch areas are unchanged.
 */
body.shmg-frame-body{margin:0}
#shatoor-math.sm-embedded{min-height:0}
@media print{
 #shatoor-math #sm-print-root>.sm-paper{width:186mm;max-width:none}
 #shatoor-math .sm-print-content{display:flow-root}
 #shatoor-math .sm-print-row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));column-gap:3mm;break-inside:avoid;page-break-inside:avoid}
 #shatoor-math .sm-print-cols-1{grid-template-columns:minmax(0,1fr)}
 #shatoor-math .sm-print-cell{display:flow-root;min-width:0}
 #shatoor-math .sm-print-tail{display:flow-root;break-inside:avoid;page-break-inside:avoid}
 #shatoor-math .sm-print-footer{display:flex;position:static;break-before:avoid-page;page-break-before:avoid;break-inside:avoid;page-break-inside:avoid}
 #shatoor-math .sm-a4-page{display:flow-root;break-inside:avoid-page;page-break-inside:avoid}
}

/* rc.2: clean writing space in printBackground=true and false alike.
 * Gradients can rasterize as thick gray bands. Keep every existing height,
 * margin and writing area; remove only the printed background paint.
 */
@media print{
 #shatoor-math .sm-question .sm-scratch{background:none!important}
}
