/* Phone authoring and library controls. All colors follow the active theme. */
.lib__head, .dw-cls__head { border:0; background:transparent; cursor:pointer; font:inherit; width:100%; color:var(--mb-ink); text-align:left; }
.lib__head { min-height:48px; padding:10px 12px; gap:8px; }
.lib__name { flex:1; font-size:16px; }
.lib__code { max-width:64px; overflow:hidden; text-overflow:ellipsis; }
.lib__count { flex:none; font-size:9px; white-space:nowrap; }
.lib__chev { display:grid; place-items:center; width:14px; height:18px; flex:none; color:var(--mb-faint); transition:rotate .18s var(--ease); }
.lib__chev svg { width:13px; height:13px; }
[aria-expanded="true"] > .lib__chev { rotate:90deg; }
.lib__tree-note { border-top:1px solid var(--mb-line-soft); border-radius:0; min-height:46px; }
.lib__tree-note .fresh { width:6px; height:6px; box-shadow:none; margin-right:5px; }
.lib__notes > .dw-folder { border-top:1px solid var(--mb-line-soft); border-radius:0; padding-left:12px; }
.lib__notes .dw-folder__children { background:color-mix(in srgb,var(--mb-bg) 35%,transparent); }
.dw-archive__head { width:100%; color:var(--mb-soft); text-align:left; }
.lib__head:active, .dw-cls__head:active { background:var(--mb-mint); }
.lib__head:focus-visible, .dw-cls__head:focus-visible, .dw-folder:focus-visible { outline:2px solid var(--mb-accent); outline-offset:-3px; }
.rule { flex-wrap:wrap; gap:4px 7px; margin-top:14px; }
.rule__count { flex-basis:100%; text-align:right; font-size:9px; }
.library-fold { min-height:32px; padding:4px 6px; background:transparent; color:var(--mb-soft); font:500 11px 'Hanken Grotesk',sans-serif; white-space:nowrap; border:0; border-radius:6px; cursor:pointer; }
.library-fold:active { background:var(--mb-mint); }
.drawer__folds { display:flex; justify-content:space-between; padding:0 14px 3px; flex:none; }
.drawer__foot { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.drawer__foot .btn-dashed { margin:0; min-height:42px; padding:8px; font-size:12px; border-style:solid; }
.hm-body > .btn-flow { min-height:44px; height:44px; border-radius:10px; font-size:14px; box-shadow:none; background:var(--mb-accent); }
.mb-body #note-seg { margin:7px 12px 0; padding:3px; border-radius:10px; }
.mb-body #note-seg .seg__btn { height:34px; border-radius:7px; font-size:13px; }
.mb-body #student-note-tools { gap:4px; padding-top:5px; padding-bottom:5px; border-bottom:0; flex-wrap:nowrap; }
.mb-body #student-note-tools > button { min-width:0; flex:1; justify-content:center; gap:5px; min-height:38px; padding:6px 3px; border:0; border-radius:7px; background:transparent; font:500 12px 'Hanken Grotesk',sans-serif; color:var(--mb-soft); transition:background .15s,color .15s; }
.mb-body #student-note-tools > button:active { background:var(--mb-mint); color:var(--mb-deep); }
.mb-body #student-note-tools > button svg { width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:1.7; flex:none; }
.mb-body .student-save-mobile { border:0; padding-bottom:4px; font-size:10px; }
/* The flex direction must survive removal of [open] during the discrete exit.
   Otherwise the header/body become columns while the backdrop fades out. */
.student-dialog { flex-direction:column; }
.mb-body .writing-dialog, .mb-body .sketch-dialog { border-radius:20px 20px 0 0; background:var(--mb-card-2); }
.mb-body .writing-dialog .student-dialog__head, .mb-body .sketch-dialog .student-dialog__head { align-items:center; padding-top:16px; padding-bottom:14px; gap:12px; }
.mb-body .writing-dialog .student-eyebrow { display:none; }
.mb-body .writing-dialog h2, .mb-body .sketch-dialog h2 { font-size:24px; }
.mb-body .writing-dialog .student-dialog__close, .mb-body .sketch-dialog .student-dialog__close { width:36px; height:36px; border:0; background:var(--mb-mint); border-radius:10px; font-size:23px; line-height:1; }
.mb-body .writing-dialog .student-dialog__close::after, .mb-body .sketch-dialog .student-dialog__close::after { content:''; position:absolute; inset:-4px; }
.mb-body .writing-dialog .student-dialog__close, .mb-body .sketch-dialog .student-dialog__close { position:relative; }
.mb-body .writing-dialog .student-dialog__body { padding-top:4px; padding-bottom:8px; }
.writing-dialog .student-field { margin:14px 0; }
.writing-dialog .student-input { border-radius:10px; padding:10px 12px; }
.writing-dialog textarea.student-input { min-height:120px; height:clamp(120px,26dvh,220px); resize:none; }
.writing-dialog[data-type="code"] textarea { font-family:'IBM Plex Mono',monospace; font-size:16px; tab-size:2; }
.writing-dialog .student-input:focus-visible { outline:2px solid var(--mb-accent); outline-offset:1px; }
.writing-dialog .student-error:empty { display:none; }
.writing-dialog .student-answer { margin-top:12px; padding:12px; }
.writing-dialog[data-type="image"] .student-answer { display:grid; place-items:center; background:var(--mb-bg); padding:8px; }
.writing-dialog .student-answer img { display:block; max-width:100%; max-height:180px; object-fit:contain; border-radius:7px; }
.writing-dialog .student-actions:not(.writing-actions) { margin-top:8px; gap:5px; }
.writing-dialog .student-actions:not(.writing-actions) .student-button { min-height:34px; padding:6px 9px; font-size:11px; }
.writing-actions { display:flex; gap:8px; margin:0; flex:none; padding:12px max(12px,calc(var(--safe-l) + 12px)) calc(12px + var(--safe-b)); border-top:1px solid var(--mb-line); background:var(--mb-card-2); }
.writing-actions .student-button { min-height:42px; padding:10px 12px; font-size:12px; border-radius:9px; }
.writing-actions .student-button--primary { margin-left:auto; }
.writing-dialog.writing-exit { top:var(--writing-exit-top); bottom:auto; height:var(--writing-exit-height); max-height:none; }
.writing-upload { margin:16px 0 10px; }
.writing-upload__choose { position:relative; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:7px; min-height:138px; padding:18px; background:var(--mb-card); border:1px dashed var(--mb-mint-line); border-radius:12px; text-align:center; cursor:pointer; overflow:hidden; }
.writing-upload__choose:focus-within { outline:2px solid var(--mb-accent); outline-offset:2px; }
.writing-upload__input { position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; }
.writing-upload__icon { display:grid; place-items:center; width:34px; height:34px; border-radius:9px; background:var(--mb-mint); color:var(--mb-deep); }
.writing-upload__icon svg { width:21px; height:21px; }
.writing-upload b { max-width:100%; font-size:13px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.writing-upload small { font-size:11px; color:var(--mb-soft); }
.writing-upload__remove { display:block; margin:5px auto 0; min-height:32px; border:0; padding:5px 10px; background:transparent; color:var(--mb-danger); font:500 12px 'Hanken Grotesk',sans-serif; }
.writing-upload.has-image .writing-upload__choose { min-height:76px; padding:10px; }
.writing-upload.has-image .writing-upload__icon, .writing-upload.has-image small { display:none; }
.note-tool-head { display:flex; align-items:center; justify-content:space-between; }
body.mb-body:has(#mobile-note-tools:not([hidden])) #toasts { visibility:hidden; }
.note-tool-head .icon-btn { width:36px; height:36px; font-size:24px; background:var(--mb-mint); border-radius:10px; }
.note-tool-label { margin:18px 0 10px; font-size:11px; color:var(--mb-soft); }
.note-tool-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:7px; }
.note-tool-grid button, .note-tool-actions button { display:flex; align-items:center; gap:8px; min-width:0; min-height:42px; border:1px solid var(--mb-line); border-radius:10px; padding:10px; background:var(--mb-card); color:var(--mb-ink); font:500 12px 'Hanken Grotesk',sans-serif; text-align:left; transition:background .15s,transform .15s; }
.note-tool-grid button { flex-direction:column; justify-content:center; min-height:68px; gap:7px; padding:9px 3px; font-size:11px; }
.note-tool-grid svg, .note-tool-actions svg { width:18px; height:18px; flex:none; color:var(--mb-deep); }
.note-tool-actions { display:grid; grid-template-columns:1fr 1fr; gap:7px; }
.note-tool-actions button:disabled { opacity:.4; }
.note-tool-grid button:active, .note-tool-actions button:active { background:var(--mb-mint); transform:scale(.98); }
.note-tool-actions .note-tool-danger { grid-column:1/-1; justify-content:center; min-height:38px; border:0; background:transparent; color:var(--mb-danger); font-size:11px; }
.note-tool-actions .note-tool-danger svg { color:inherit; }
.note-tool-linked:has(> *) { border-top:1px solid var(--mb-line); margin-top:16px; padding-top:14px; }
.note-tool-sheet .lm-feature-tools { gap:8px; justify-content:space-between; }
.note-tool-sheet .lm-button { margin:0; font-size:12px; min-height:38px; padding:8px 10px; }
.note-focus #view-chat > :is(.ch-top,#note-seg,#student-note-tools,.student-save-mobile,.composer) { display:none; }
.note-focus-exit { position:fixed; top:calc(var(--app-top,0px) + var(--safe-t) + 10px); right:calc(var(--safe-r) + 12px); z-index:30; min-height:36px; border:1px solid var(--mb-line); border-radius:20px; padding:8px 14px; background:var(--mb-card); color:var(--mb-deep); box-shadow:var(--sh-card); font:500 12px 'Hanken Grotesk',sans-serif; }
.sketch-tools { display:flex; flex-wrap:wrap; gap:6px; }
.sketch-tools button { min-height:38px; border:1px solid var(--mb-line); border-radius:8px; padding:7px 12px; background:var(--mb-card); color:var(--mb-soft); font:500 12px 'Hanken Grotesk',sans-serif; }
.sketch-tools button[aria-pressed="true"] { color:var(--mb-deep); background:var(--mb-mint); border-color:var(--mb-mint-line); }
.sketch-pad { display:block; width:min(100%,69dvh); height:auto; margin:auto; border:1px solid var(--mb-line); border-radius:12px; background:var(--mb-card); color:var(--mb-ink); touch-action:none; }
.sketch-hint { font-size:11px; color:var(--mb-soft); }
@media(max-height:440px) {
  .mb-body .writing-dialog .student-dialog__head { padding-top:8px; padding-bottom:8px; }
  .writing-dialog textarea.student-input { height:100px; min-height:70px; }
  .writing-actions { padding-top:7px; padding-bottom:7px; }
  .writing-upload__choose { min-height:90px; padding:10px; }
}
@media(prefers-reduced-motion:reduce) {
  .lib__notes, .dw-folder__children, .dw-cls > div { animation:none !important; }
  .lib__chev, .note-tool-grid button, .note-tool-actions button { transition:none; }
}
