/* กระดาษทดครูผึ้ง (คู่กับ /assets/scratchpad.js) · สี Brand Kit: น้ำผึ้ง #FFC61F/#E9A400 น้ำตาล #3A2315 */
.cjsp-fab{position:fixed;z-index:9001;right:max(14px,env(safe-area-inset-right,0px));bottom:calc(72px + env(safe-area-inset-bottom,0px));
  display:inline-flex;align-items:center;gap:6px;min-height:48px;padding:8px 18px;border:2px solid #3A2315;border-radius:999px;
  background:#FFC61F;color:#3A2315;font-family:var(--f-display,"Bai Jamjuree",sans-serif);font-weight:700;font-size:1.05rem;
  box-shadow:0 6px 16px rgba(58,35,21,.25);cursor:pointer;-webkit-tap-highlight-color:transparent}
.cjsp-fab:hover{background:#E9A400}
.cjsp-fab:focus-visible,.cjsp button:focus-visible{outline:3px solid #3A2315;outline-offset:2px}
.cjsp-fab[hidden],.cjsp[hidden]{display:none}

.cjsp{position:fixed;z-index:9000;display:flex;flex-direction:column;background:#FFFDF6;border:0 solid #3A2315;
  box-shadow:0 -6px 24px rgba(58,35,21,.18);font-family:var(--f-display,"Bai Jamjuree",sans-serif);color:#3A2315}
.cjsp-bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;padding:8px 10px;background:#FFC61F;border-bottom:2px solid #3A2315}
.cjsp-title{flex:1 1 100%;font-size:.95rem;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cjsp-grp{display:inline-flex;align-items:center;gap:4px}
.cjsp-bar button{min-width:40px;min-height:40px;padding:4px 8px;border:1.5px solid #3A2315;border-radius:10px;background:#FFFDF6;color:#3A2315;
  font:inherit;font-weight:600;font-size:1rem;line-height:1;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
.cjsp-bar button[aria-pressed="true"]{background:#3A2315;color:#FFC61F}
.cjsp-bar button:disabled{opacity:.4;cursor:default}
.cjsp-bar button.arm{background:#D33A2C;border-color:#D33A2C;color:#fff}
.cjsp-bar button i{display:block;width:20px;height:20px;border-radius:50%;margin:auto;border:2px solid #FFFDF6}
.cjsp-bar button[aria-pressed="true"] i{border-color:#FFC61F}
.cjsp-pg{font-size:.85rem;font-weight:600;white-space:nowrap;padding:0 2px}
.cjsp-wrap{position:relative;flex:1;min-height:0;overflow:hidden}
.cjsp-wrap[data-bg="grid"]{background-image:linear-gradient(rgba(233,164,0,.28) 1px,transparent 1px),linear-gradient(90deg,rgba(233,164,0,.28) 1px,transparent 1px);background-size:24px 24px}
.cjsp-wrap[data-bg="lines"]{background-image:linear-gradient(transparent 31px,rgba(233,164,0,.4) 31px);background-size:100% 32px}
.cjsp canvas{display:block;touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;cursor:crosshair}
.cjsp-msg{position:absolute;left:50%;bottom:10px;transform:translateX(-50%);margin:0;max-width:90%;padding:0;border-radius:999px;
  background:#3A2315;color:#FFC61F;font-size:.88rem;font-weight:600;pointer-events:none;text-align:center}
.cjsp-msg:not(:empty){padding:6px 14px}

/* โปร่งใส: เห็นโจทย์ข้างหลังแผ่นทด */
.cjsp.see{background:rgba(255,253,246,.45);box-shadow:none}
.cjsp.see .cjsp-wrap[data-bg="grid"]{background-image:linear-gradient(rgba(233,164,0,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(233,164,0,.18) 1px,transparent 1px)}
.cjsp.see .cjsp-wrap[data-bg="lines"]{background-image:linear-gradient(transparent 31px,rgba(233,164,0,.25) 31px)}

/* จอกว้างแนวนอน (iPad แนวนอน คอม): แผ่นทดครึ่งจอด้านขวา หน้าโจทย์หดไปทางซ้าย */
@media (min-width:768px) and (orientation:landscape){
  .cjsp{top:0;right:0;bottom:0;width:48vw;border-left-width:2px;padding-bottom:env(safe-area-inset-bottom,0px)}
  .cjsp.small{width:34vw}
  body.cjsp-open{margin-right:48vw}
  body.cjsp-open.cjsp-small{margin-right:34vw}
  .cjsp-title{flex-basis:100%}
}
/* จอแนวตั้ง/มือถือ: แผ่นทดด้านล่าง เลื่อนโจทย์ได้ในครึ่งบน */
@media (max-width:767.98px),(orientation:portrait){
  .cjsp{left:0;right:0;bottom:0;height:50vh;height:50dvh;border-top-width:2px;border-radius:16px 16px 0 0;overflow:hidden;padding-bottom:env(safe-area-inset-bottom,0px)}
  .cjsp.small{height:34vh;height:34dvh}
  body.cjsp-open{padding-bottom:50vh}
  body.cjsp-open.cjsp-small{padding-bottom:34vh}
  .cjsp-bar{gap:4px 6px;padding:6px 8px}
  .cjsp-bar button{min-width:38px;min-height:38px;padding:3px 6px}
}
@media (max-width:420px){.cjsp-pg{display:none}}
/* โหมดโปร่งใส: ไม่ต้องดันหน้าโจทย์หลบ ให้โจทย์อยู่ใต้แผ่นทด */
body.cjsp-open:has(.cjsp.see){margin-right:0;padding-bottom:0}

@media print{.cjsp,.cjsp-fab{display:none!important}body.cjsp-open{margin-right:0!important;padding-bottom:0!important}}
