.mb-study{position:fixed;inset:0;z-index:2500;display:grid;place-items:center;background:#182f35a8;backdrop-filter:blur(4px);font-family:MBNanum,sans-serif;color:#44382c;padding:18px;box-sizing:border-box}
.mb-study[hidden]{display:none}.mb-study *{box-sizing:border-box}.mb-study-sheet{width:min(1380px,96vw);height:min(920px,94dvh);background:#fbf5e6;border:3px solid #805636;border-radius:25px;box-shadow:0 18px 70px #081e2755;display:flex;flex-direction:column;overflow:hidden}
.mb-study header{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:18px 28px;border-bottom:1px solid #dbc6a0;background:#eee1c7;flex-shrink:0}.mb-study h2{font:28px MBJua,sans-serif;margin:0 0 4px}.mb-study h3{font:23px MBJua,sans-serif;margin:8px 0 12px}.mb-study p{line-height:1.65;white-space:pre-line;margin:10px 0}.mb-study header p{font-size:14px;margin:0;color:#746552}.mb-study small{font-size:14px;line-height:1.6;color:#746552}
.mb-study-body{padding:22px 28px;overflow:auto;flex:1;min-height:0;font-size:17px}.mb-study button{font:18px MBJua,sans-serif;border:2px solid #c07937;border-radius:12px;padding:10px 16px;background:#ed933e;color:#fffdf6;cursor:pointer;min-height:44px;white-space:normal}.mb-study button.secondary{background:#fff9e9;color:#67492e;border-color:#d7bd8b}.mb-study button.selected{background:#6b4427;border-color:#6b4427;color:white}.mb-study button:disabled{opacity:.5;cursor:default}.mb-study button:focus-visible,.mb-study input:focus-visible,.mb-study textarea:focus-visible{outline:3px solid #e8913f;outline-offset:3px}.mb-study button:hover:enabled{filter:brightness(1.04)}
.mb-study-tools{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin:12px 0}.mb-home-cards{display:grid;grid-template-columns:1fr 1fr;gap:18px;margin:24px 0}.mb-home-cards button{min-height:100px;font-size:24px}.mb-npc-line{background:#f4e8cc;border-left:5px solid #c99a5e;border-radius:12px;padding:16px 22px;font-size:20px}.mb-lesson-list{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin:18px 0}.mb-lesson-card{background:#fffaf0;border:1px solid #d9c7a7;border-radius:16px;padding:20px}.mb-lesson-card p{font-size:16px}.mb-lesson-card button{font-size:16px;padding:9px 12px}.mb-study details{padding:16px;border:1px solid #d7bd8b;border-radius:12px;margin:12px 0}.mb-study summary{cursor:pointer;font-family:MBJua;font-size:20px}
.mb-question-tabs{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:14px}.mb-question-tabs button{border-radius:50%;padding:5px;min-width:44px;font-size:16px}.mb-question-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(300px,400px);gap:20px;min-height:420px}.mb-question-left{display:flex;flex-direction:column;min-width:0}.mb-question-card{border:1px solid #d9c7a7;border-radius:17px;padding:24px;background:#fffdf6;flex:1;min-height:275px}.mb-question-prompt{font-size:clamp(21px,2vw,28px);line-height:1.7;white-space:pre-line;overflow-wrap:anywhere;margin:18px 0 26px}.mb-study label{display:block;font-size:15px;line-height:1.6}.mb-study input:not([type=checkbox]),.mb-study textarea{display:block;width:100%;font:22px MBNanum,sans-serif;padding:13px 15px;border:2px solid #baaa88;border-radius:10px;background:#fff;color:#3c4039;margin-top:7px}.mb-study input:disabled,.mb-study textarea:disabled{background:#eeeadd;color:#555c50;opacity:1}.mb-study textarea{min-height:110px;resize:vertical}.mb-study fieldset{border:0;padding:12px 0;margin-top:12px}.mb-study fieldset label{padding:7px 0;font-size:17px}.mb-study input[type=checkbox]{width:20px;height:20px;accent-color:#8a5530;vertical-align:middle;margin-right:10px}.mb-choices{display:grid;gap:12px}.mb-choices button{text-align:left}.mb-question-feedback{min-height:28px;color:#8a5530;font-size:16px}.mb-question-left>.mb-study-tools{margin-bottom:0}.mb-memo{background:#fffdf6;border:1px solid #d9c7a7;border-radius:17px;padding:18px;display:flex;flex-direction:column;min-width:0}.mb-memo h3{margin:0 0 5px}.mb-memo button{font-size:15px;padding:7px 10px}.mb-memo canvas{width:100%;height:300px;min-height:220px;flex:1;touch-action:none;background:repeating-linear-gradient(#fffdf6 0 27px,#d5d1bd55 28px);border:1px solid #e5dac1;border-radius:6px}.mb-number-keys{display:grid;grid-template-columns:repeat(3,1fr);gap:5px;margin-top:12px}.mb-number-keys button{min-height:36px;padding:5px}.mb-study-error{background:#ffe7d5;color:#843e26;padding:12px 28px!important;margin:0!important;flex-shrink:0;font-size:15px}.mb-study-error[hidden]{display:none}
.mb-study-hud{position:fixed;z-index:41;bottom:22px;left:50%;transform:translateX(-50%);display:flex;gap:9px}.mb-study-hud[hidden]{display:none}.mb-study-hud button{border:1px solid #bd9f71;border-radius:16px;background:#f8f0dded;padding:10px 16px;color:#644a33;font:17px MBJua,sans-serif;cursor:pointer}
.mb-study-head-actions{display:flex;gap:10px;flex-shrink:0}.mb-study-head-actions button{white-space:nowrap}
.mb-backup-layout{display:grid;grid-template-columns:1fr 1.05fr;gap:24px;margin:0 0 20px}.mb-backup-card{border:1px solid #d6c19a;border-radius:18px;padding:24px;background:#fffbf1}.mb-backup-card h3{font:25px MBJua,sans-serif;margin:0 0 16px}.mb-backup-card p{font-size:17px;line-height:1.8;margin:10px 0 18px}.mb-backup-card button{margin:8px 8px 0 0}.mb-backup-card input[type=file]{font-size:16px}.mb-backup-card h4{font:22px MBJua,sans-serif;margin:24px 0 12px}.mb-backup-card [role=status]{color:#8a5530;font-size:16px}
@media(max-width:900px){.mb-backup-layout{grid-template-columns:1fr;gap:16px}.mb-backup-card{padding:18px}.mb-study-head-actions{gap:6px}.mb-study-head-actions button{font-size:15px;padding:9px 12px}}
@media(max-width:560px){.mb-study header{flex-wrap:wrap}.mb-study-head-actions{width:100%;justify-content:flex-end}.mb-study-head-actions button{max-width:none!important;min-height:44px}.mb-backup-card h3{font-size:23px}.mb-backup-card p{font-size:16px}}
.mb-study-sheet.is-question .mb-study-body{display:flex;flex-direction:column}.mb-study-sheet.is-question .mb-question-tabs{flex-shrink:0}.mb-study-sheet.is-question .mb-question-grid{flex:1;min-height:0}.mb-study-sheet.is-question .mb-question-card{min-height:180px;overflow:auto}.mb-study-sheet.is-question .mb-memo{min-height:0}.mb-study-sheet.is-question .mb-memo canvas{height:0;min-height:120px}.mb-study .mb-keypad-box{padding:8px 0 0;margin:8px 0 0;border:0}.mb-keypad-box summary{font-size:16px}.mb-keypad-box .mb-number-keys{grid-template-columns:repeat(6,1fr)}
body.mb-study-open .pause-screen,body.mb-study-open .mb-check{display:none!important}
body.mb-study-open #ui-root,body.mb-study-open .mb-tools,body.mb-study-open .mb-learning-panel,body.mb-study-open .mb-learning-open,body.mb-study-open .mb-status,body.mb-study-open .mb-study-hud,body.mb-study-open .mb-ward-label{visibility:hidden!important}
@media(max-width:850px){.mb-study{padding:8px}.mb-study-sheet{width:100%;height:97dvh;border-radius:16px}.mb-study header{padding:12px 16px;gap:10px}.mb-study h2{font-size:23px}.mb-study-body{padding:15px}.mb-lesson-list{grid-template-columns:1fr}.mb-question-grid{grid-template-columns:minmax(0,1.2fr) minmax(240px,.8fr);gap:12px}.mb-question-card{padding:17px}.mb-question-prompt{font-size:21px}.mb-memo{padding:12px}.mb-study button{font-size:16px}.mb-study-hud{bottom:10px}}
@media(max-width:600px){.mb-question-grid{grid-template-columns:1fr}.mb-memo canvas{height:280px;flex:none}.mb-memo{min-height:340px}.mb-home-cards{grid-template-columns:1fr}.mb-study header button{max-width:100px;font-size:15px}.mb-study-hud button{font-size:14px;padding:9px}.mb-study-hud{gap:6px}.mb-number-keys{grid-template-columns:repeat(6,1fr)}}
@media(max-width:600px){.mb-study-sheet.is-question .mb-question-grid{flex:none;min-height:650px}.mb-study-sheet.is-question .mb-memo canvas{height:260px;min-height:260px}.mb-study-sheet.is-question .mb-question-card{overflow:visible}}
/* Port of Claude's approved journal.css / Journal.uss / LessonJournal.uss.
   Keep the existing question/400px memo proportions; memo ink is temporary. */
.mb-study{background:rgba(26,34,26,.62)}
.mb-study-sheet{position:relative;border:14px solid #7b4a2e;border-bottom-width:18px;border-radius:28px;background:#fbf4e3;box-shadow:0 10px 0 #5c351f,0 28px 65px #101a145c;overflow:visible}
.mb-study-sheet:after{content:'';position:absolute;inset:-8px;border:2px dashed #e9c98eaa;border-radius:21px;pointer-events:none;z-index:2}
.mb-study header{background:transparent;border-bottom:1px solid #e3d3b1;border-radius:12px 12px 0 0;padding:12px 24px}
.mb-study header h2{color:#3a2c22;font-weight:400}.mb-study header p{color:#7a6650}
.mb-study button{border-radius:16px;border:2px solid #e3d3b1;border-bottom-width:4px;background:#fffdf6;color:#3a2c22;box-shadow:0 2px 0 #d8c7a3}
.mb-study button:active:enabled{transform:translateY(2px);box-shadow:none}.mb-study button:focus-visible{outline:3px solid #8a5530;outline-offset:3px}
.mb-study button.selected{background:#8a5530;border-color:#8a5530;border-bottom-color:#4f301b;color:white}
.mb-study button:disabled{opacity:.6;cursor:default;box-shadow:none}
.mb-study .mb-study-body{min-height:0;border-radius:0 0 12px 12px}
.mb-study-sheet.is-question .mb-study-body{padding:16px 22px 20px}
.mb-question-tabs button{background:#f4e9d0;color:#7a6650;border:2px solid #d8c7a3;box-shadow:none;border-radius:50%}
.mb-question-tabs button.selected{background:#ee8a3c;border-color:#b9612a;color:white}
.mb-question-grid{gap:28px}.mb-question-left{position:relative;padding-right:4px}
.mb-question-left:after{content:'';position:absolute;top:-4px;bottom:0;right:-16px;width:4px;background:#d9c49b;box-shadow:-7px 0 12px #cdb68b44,7px 0 12px #cdb68b33;pointer-events:none}
.mb-question-card{position:relative;background:#fffdf8;border:0;border-bottom:5px solid #e2d2ad;box-shadow:0 0 0 1px #f1e5cc;padding:22px;border-radius:15px}
.mb-question-card:before{content:'';position:absolute;top:0;right:16px;width:65px;height:13px;background:#ffe58a99;transform:rotate(5deg);pointer-events:none}
.mb-question-prompt{font-size:24px;line-height:1.6}.mb-study input:focus,.mb-study textarea:focus{outline:0;border-color:#8a5530}
.mb-question-left>.mb-study-tools>button:last-child:not(.secondary){background:#ee8a3c;color:#fff;border-color:#ee8a3c;border-bottom-color:#b9612a;box-shadow:0 2px 0 #b9612a;min-width:140px;font-size:21px}
.mb-memo{background:linear-gradient(90deg,#efe1c344,#fbf4e3 12%);border:0;padding:0 0 0 6px;border-radius:0}
.mb-memo canvas{background-color:#fffefa;background-image:linear-gradient(#e4eef2 1px,transparent 1px),linear-gradient(90deg,#e4eef2 1px,transparent 1px);background-size:26px 26px;border:2px solid #e3d3b1;border-radius:12px}
.mb-memo .mb-study-tools{margin:10px 0 14px}.mb-keypad-box .mb-number-keys button{background:#f7ecd2;border-color:#d7c193}
.mb-study-sheet.is-journal .mb-study-body{padding:0;overflow:hidden;display:flex}
.mb-journal-spread{display:grid;grid-template-columns:1.12fr 1fr;flex:1;min-height:0;min-width:0}
.mb-journal-left,.mb-journal-right{min-width:0;min-height:0;padding:20px 26px;display:flex;flex-direction:column}
.mb-journal-left{background:linear-gradient(90deg,#fbf4e3 88%,#efe1c3);border-right:4px solid #d9c49b}
.mb-journal-right{background:linear-gradient(270deg,#fbf4e3 90%,#efe1c3);overflow:auto}
.mb-journal-heading{display:flex;align-items:center;gap:15px;flex-shrink:0}.mb-journal-heading h3{font-size:25px;margin:0}
.mb-journal-stamp{border:3px dashed #8a5530;border-radius:50%;width:52px;height:52px;display:grid;place-items:center;color:#8a5530;font:19px MBJua;transform:rotate(-10deg)}
.mb-journal-left>.mb-study-tools{gap:6px;flex-shrink:0}.mb-journal-left>.mb-study-tools button{font-size:15px;padding:7px 12px;min-height:38px}
.mb-journal-list{flex:1;min-height:0;overflow:auto;padding:3px 6px 5px 0;scrollbar-width:thin}
.mb-study .mb-journal-row{display:flex;align-items:center;width:100%;text-align:left;padding:12px 8px;gap:12px;margin:0 0 3px;min-height:77px;background:transparent;border:0;border-bottom:2px solid #e3d3b1;border-radius:12px;box-shadow:none}
.mb-study .mb-journal-row.selected{background:#ffe58a99;color:#3a2c22;border-color:transparent}.mb-journal-num{flex-shrink:0;width:38px;height:38px;display:grid;place-items:center;border-radius:50%;background:#f4e9d0;border:2px solid #e3d3b1;color:#7a6650;font:17px MBJua}
.mb-journal-row.selected .mb-journal-num{background:#8a5530;color:white;border-color:#8a5530}.mb-journal-row-text{flex:1}.mb-journal-row strong{display:block;font:21px MBJua;font-weight:400;line-height:1.35}.mb-journal-row small{display:block;font-size:13px;margin-top:4px}.mb-journal-mark{border:2px solid #ad9569;border-radius:50%;width:50px;height:50px;display:grid;place-items:center;flex-shrink:0;font:13px MBJua;color:#8b724b;transform:rotate(-9deg)}
.mb-journal-foot{margin:10px 0 0!important}.mb-journal-photo{position:relative;margin:0 0 12px;padding:8px 8px 5px;background:white;border-bottom:5px solid #e2d2ad;border-radius:5px;transform:rotate(.6deg);flex-shrink:0}
.mb-journal-photo:before,.mb-journal-photo:after{content:'';position:absolute;width:65px;height:18px;background:#ffe58ac4;top:-5px;transform:rotate(-9deg);left:-10px}.mb-journal-photo:after{left:auto;right:-10px;transform:rotate(8deg)}
.mb-journal-photo img{width:100%;height:clamp(95px,17dvh,160px);object-fit:cover;display:block;border-radius:3px}.mb-journal-photo figcaption{text-align:center;font-size:12px;color:#7a6650;padding-top:4px}
.mb-journal-say{display:flex;align-items:center;gap:10px;flex-shrink:0}.mb-journal-face{border:3px solid white;border-radius:50%;background:#c9774f;color:white;display:grid;place-items:center;width:48px;height:48px;font:14px MBJua;flex-shrink:0}.mb-journal-say p{background:white;border:2px solid #e3d3b1;border-radius:16px;padding:8px 12px;font-size:15px;line-height:1.5;margin:0}
.mb-journal-detail{flex:1;min-height:65px;overflow:auto;margin:10px 0}.mb-journal-detail h3{font-size:24px;margin:0 0 6px}.mb-journal-detail ul{padding:0;list-style:none;margin:0}.mb-journal-detail li{padding-left:22px;position:relative;line-height:1.6;font-size:16px}.mb-journal-detail li:before{content:'□';position:absolute;left:0;color:#7a6650}
.mb-journal-actions{flex-shrink:0;display:grid;gap:8px}.mb-study .mb-journal-main{background:#ee8a3c;color:white;border-color:#ee8a3c;border-bottom-color:#b9612a;box-shadow:0 2px 0 #b9612a;font-size:23px;min-height:48px}
.mb-journal-extras{display:grid;grid-template-columns:repeat(3,1fr);gap:7px}.mb-journal-extras button,.mb-study .mb-journal-special{font-size:15px;padding:6px;min-height:38px}.mb-journal-extras button:disabled{background:#fff6c9;color:#8a7440;border-color:#e6d791}.mb-journal-actions>small{font-size:12px}
@media(max-height:760px){.mb-journal-left,.mb-journal-right{padding:14px 20px}.mb-journal-heading h3{font-size:22px}.mb-journal-stamp{width:42px;height:42px}.mb-journal-photo img{height:94px}.mb-journal-photo{margin-bottom:8px}.mb-journal-detail{margin:6px 0;min-height:52px}.mb-journal-detail h3{font-size:21px}.mb-journal-detail li{font-size:14px}.mb-journal-actions{gap:6px}.mb-journal-say p{font-size:14px}.mb-journal-row strong{font-size:19px}}
@media(max-width:850px){.mb-study-sheet{border-width:10px;border-bottom-width:14px}.mb-study-sheet:after{inset:-6px}.mb-study header{padding:10px 15px}.mb-study-sheet.is-question .mb-study-body{padding:12px}.mb-journal-left,.mb-journal-right{padding:14px}.mb-journal-row{gap:7px!important}.mb-journal-mark{display:none}.mb-journal-heading h3{font-size:20px}.mb-journal-extras{grid-template-columns:1fr}.mb-journal-right{overflow:auto}.mb-journal-detail{flex:none;min-height:85px}.mb-journal-say{align-items:flex-start}}
@media(max-width:600px){.mb-study-sheet.is-journal .mb-study-body{overflow:auto;display:block}.mb-journal-spread{display:block}.mb-journal-left{border-right:0;border-bottom:4px solid #d9c49b}.mb-journal-list{max-height:260px;flex:none}.mb-journal-extras{grid-template-columns:repeat(3,1fr)}.mb-journal-photo img{height:150px}.mb-journal-right{overflow:visible}.mb-question-left:after{display:none}.mb-question-grid{gap:20px}.mb-question-prompt{font-size:21px}.mb-memo{padding:0}.mb-study header h2{font-size:21px}}

.mb-question-figure{display:block;width:100%;height:auto;object-fit:contain;margin:16px auto;background:#fff;border-radius:12px;padding:8px;box-sizing:border-box;max-height:300px;}

.mb-journal-face.is-long{font-size:11px;white-space:nowrap;}
.teacher-region-dialog{max-width:min(620px,94vw);max-height:90dvh;overflow:auto;background:#fbf4e3;color:#3a2c22;border:3px solid #6b3f24;border-radius:18px;padding:24px;font:18px/1.5 Nanum,sans-serif}.teacher-region-dialog::backdrop{background:#17251dcc}.teacher-region-dialog label{display:flex;gap:12px;margin:12px 0}.teacher-region-dialog input{width:24px;height:24px}.teacher-region-dialog button{padding:12px 18px;margin:8px;font:18px Jua;min-height:48px}
.math-lab{margin:18px 0;padding:14px;background:#f4eddc;border:2px solid #d9c6a2;border-radius:14px}.math-lab summary{cursor:pointer;font:20px MBJua}.math-lab p{font-size:16px;line-height:1.6}.math-lab button{margin:4px!important;min-height:44px;font-size:16px!important}.math-shape-grid{display:grid;grid-template-columns:repeat(7,1fr);width:min(280px,100%);aspect-ratio:1;margin:14px auto}.math-shape-grid span{border:1px solid #ab9e86;display:grid;place-items:center;background:#fffcf3;color:#483c28}.math-shape-grid .filled{background:#e0a865}.math-bar-plot{display:flex;justify-content:space-around;gap:10px;margin:16px 0}.math-bar-plot>div{flex:1;text-align:center}.math-bar-plot output,.math-bar-plot span{display:block;font-size:15px}.math-bar-control{height:180px;position:relative;touch-action:none;border:1px solid #9d937d;background:repeating-linear-gradient(to top,#c2b9a7 0 1px,transparent 1px 6.6667%);cursor:ns-resize}.math-bar-control>div{position:absolute;bottom:0;left:15%;right:15%;background:#a0714a;pointer-events:none}.math-bar-control:focus-visible{outline:3px solid #f08a3a;outline-offset:2px}

/* Fable A4/C3: keep actions in view, let the question scroll on its own. */
@media(min-width:601px){
 .mb-study-sheet.is-question .mb-study-body{overflow:hidden}
 .mb-study-sheet.is-question .mb-question-grid{overflow:hidden}
 .mb-study-sheet.is-question .mb-question-left{min-height:0;overflow:hidden}
 .mb-study-sheet.is-question .mb-question-card{flex:1 1 0;min-height:0;overflow:auto;padding:14px 18px}
 .mb-study-sheet.is-question .mb-question-prompt{margin:8px 0 12px;font-size:22px;line-height:1.5}
 .mb-study-sheet.is-question .mb-choices{gap:7px}
 .mb-study-sheet.is-question .mb-choices button{padding:8px 12px;min-height:44px;font-size:18px}
 .mb-study-sheet.is-question .mb-question-feedback{flex:none;max-height:64px;overflow:auto;margin:8px 0;min-height:24px}
 .mb-study-sheet.is-question .mb-question-actions{flex:none;margin:3px 0 0;background:#fbf4e3}
 .mb-study-sheet.is-question .mb-memo{overflow:auto}
 .mb-study-sheet.is-question .mb-fraction-figure{margin:6px 0}
 .mb-study-sheet.is-question .mb-fraction-figure svg{max-height:150px}
 .mb-study-sheet.is-question .mb-memo canvas{flex:1;min-height:90px}
}
.mb-journal-detail{flex:none;min-height:0;overflow:visible}
.mb-journal-right{overflow:auto}

.mb-reward-stamp{flex:none;margin:3px 0;color:#6e7b3c;border:2px dashed #a19157;border-radius:10px;padding:7px 10px;font:17px MBJua;max-height:65px;overflow:auto;animation:learning-stamp .22s ease-out}@keyframes learning-stamp{from{transform:scale(1.04);opacity:.3}to{transform:none;opacity:1}}@media(prefers-reduced-motion:reduce){.mb-reward-stamp{animation:none}}

body.mb-study-open :is(.qa-recovery,.market-qa){display:none}

.mb-study-sheet.is-question .mb-geometry-figure svg{max-height:250px;min-height:200px;max-width:650px}.mb-geometry-figure svg{width:100%;height:auto;display:block}.sea-scene .mb-geometry-figure svg{max-height:230px}

/* A single paper-and-leather reading surface, also on narrow student screens. */
.mb-study header>div:first-child{min-width:0}.mb-study header h2{overflow-wrap:anywhere}
.mb-study-body,.mb-question-card,.mb-journal-list{overscroll-behavior:contain}
.mb-journal-row-text{min-width:0}.mb-journal-row strong{overflow-wrap:anywhere}
.mb-question-feedback{line-height:1.6}
@media(max-width:600px){
 .mb-study-sheet.is-question .mb-study-body{overflow:auto}
 .mb-study-sheet.is-question .mb-question-grid{display:flex;flex-direction:column;min-height:0;overflow:visible;flex:none}
 .mb-study-sheet.is-question .mb-question-left,.mb-study-sheet.is-question .mb-question-card{flex:none;overflow:visible}
 .mb-study-sheet.is-question .mb-memo{min-height:320px;flex:none}
 .mb-study-sheet.is-question .mb-question-tabs{flex-wrap:nowrap;overflow-x:auto;min-height:50px}
 .mb-study-sheet.is-question .mb-question-tabs button{flex-shrink:0}
}
