.math-editor { --tool-size:44px; position:relative; min-width:0; width:100%; height:100% }
.entry-editor { display:flex; flex-direction:column; height:auto; gap:8px }
.editor-top { display:flex; align-items:center; gap:8px }
.entry-editor .editor-top { position:relative; flex-wrap:wrap; flex:none }
.editor-modes { display:flex; flex:1; border:1px solid #d5d5d2; padding:3px; background:#efefef; border-radius:8px }
.editor-modes button { flex:1; border:0; min-height:37px; background:transparent; color:#646368; font-weight:650 }
.editor-modes button[aria-pressed=true] { background:white; color:#2a292b; box-shadow:0 1px 4px #2222 }
.editor-sample { font-size:.8rem; white-space:nowrap }
#work-controls .editor-top { flex-wrap:wrap }
#work-controls .editor-modes { flex-basis:100% }
#work-controls .editor-sample { min-height:32px }
.math-editor [data-pane] { position:relative; width:100%; height:100%; min-height:0 }
.board-prompt-viewport { position:absolute; inset:0; overflow:hidden; pointer-events:none }
.board-prompt { position:absolute; top:0; left:0; width:max-content; transform-origin:0 0; color:#202020; overflow-wrap:anywhere }
.board-prompt-heading { margin-bottom:3px; font:bold 14px/17px -apple-system,BlinkMacSystemFont,sans-serif }
.entry-editor [data-pane] { flex:1 }
.entry-editor [data-pane=ink] { display:flex; flex-direction:column; min-height:155px }
.ink-canvas { position:absolute; inset:0; width:100%; height:100%; display:block; background:transparent; touch-action:none; cursor:crosshair }
.ink-canvas[data-tool=pan] { cursor:grab }
.ink-canvas.dragging { cursor:grabbing }
.entry-editor .ink-canvas { position:relative; flex:1; min-height:90px; height:0; background:#fefff1; border:1px solid #d5d3c9; border-radius:8px }
.editor-notice:not(:empty) {
  position:absolute; bottom:120px; left:50%; transform:translateX(-50%); max-width:90%;
  background:white; border:1px solid var(--edge); border-radius:8px; padding:.5rem .75rem; font-size:.82rem;
}
.ink-tools,.ink-zoom,.math-tools { display:flex; align-items:center; justify-content:center }
.ink-tools {
  position:fixed; z-index:3; bottom:max(18px,env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%);
  padding:4px; border:1px solid #ffffff30; border-radius:30px;
  background:var(--graphite); box-shadow:0 5px 20px #20202030; color:white; backdrop-filter:blur(22px);
}
.ink-tools button,.math-tools button {
  display:grid; place-items:center; flex:none; width:var(--tool-size); min-height:var(--tool-size); padding:0;
  border:0; border-radius:50%; background:transparent; color:inherit; line-height:1;
}
.ink-tools button:enabled:hover { background:#ffffff29 }
.ink-tools button[aria-pressed=true]:not([data-color]) { background:var(--violet) }
.ink-tools img { object-fit:contain; width:22px; height:22px; filter:brightness(0) invert(1); pointer-events:none }
.ink-tools button:disabled { opacity:.38 }
.tool-options { display:none; align-items:center; justify-content:center; gap:2px }
.ink-tools.expanded .tool-options,.entry-editor .tool-options { display:flex }
.ink-tools.expanded .toolbar-toggle,.entry-editor .toolbar-toggle { display:none }
.color-control { position:relative }
.color-toggle span,.palette span { display:block; width:26px; height:26px; border:2px solid #ffffffa0; border-radius:50% }
.palette {
  position:absolute; z-index:5; bottom:calc(100% + 10px); left:50%; transform:translateX(-50%);
  display:grid; grid-template-columns:repeat(4,42px); padding:6px; background:#42423f; border-radius:16px; box-shadow:var(--shadow);
}
.palette button { width:42px; min-height:42px }
.palette button[aria-pressed=true] span { outline:2px solid white; outline-offset:2px }
.brush { display:flex; align-items:center; gap:5px; padding:0 7px; font-size:.78rem; font-weight:500 }
.brush input { margin:0; width:65px; min-height:44px; padding:0; accent-color:#a7a6ff }
.brush output { width:2ch }
.ink-zoom {
  position:fixed; z-index:2; right:max(20px,env(safe-area-inset-right)); bottom:max(88px,env(safe-area-inset-bottom));
  min-height:38px; border:1px solid #deddd7; border-radius:8px; padding:2px; background:#fffffff0; color:#27272b; gap:2px;
}
.ink-zoom button { border:none; min-height:38px; min-width:38px; padding:0; background:transparent; font-size:1.1rem }
.ink-zoom output,.ink-zoom [data-command=home] { font-size:.85rem; min-width:4ch; text-align:center; font-variant-numeric:tabular-nums }
.entry-editor .ink-tools {
  position:static; transform:none; justify-content:start; width:100%; border:1px solid #dddcd5; border-radius:9px;
  color:var(--ink); background:#faf9f3; box-shadow:none; backdrop-filter:none;
}
.entry-editor .ink-toolbar { flex:none }
.entry-editor .tool-options { flex-wrap:wrap; justify-content:start }
.entry-editor .ink-tools img { filter:brightness(0) }
.entry-editor .ink-tools button:enabled:hover { background:#ededed }
.entry-editor .ink-tools button[aria-pressed=true]:not([data-color]) { background:#e7e6fb }
.entry-editor .color-toggle span { border-color:#d0ceca }
.entry-editor .ink-zoom { position:absolute; top:8px; right:8px; bottom:auto }
.entry-editor .brush input { accent-color:var(--violet) }
[data-pane=typed] { display:flex; flex-direction:column }
.editor-text-label { display:block; flex:1; min-height:0 }
.editor-text {
  width:100%; height:100%; border:0; resize:none; background:transparent; color:#29292b;
  padding:0; font:clamp(1.25rem,2.3vw,2rem)/1.6 "Cambria Math","STIX Two Text",Georgia,serif;
}
.editor-prompt:not(.ink-description) {
  flex:none; margin:0; padding:10px 0 16px;
  font:clamp(2.4375rem,7.125vw,5.15625rem)/1.2 "Cambria Math","STIX Two Text",Georgia,serif; overflow-wrap:anywhere; white-space:pre-line;
}
.editor-prompt:not(.ink-description) { overflow-x:auto }
.work-sheet:has(.typed-work) { display:flex; flex-direction:column }
.work-sheet:has(.typed-work) #work-title { position:static; margin:var(--work-top) 16px 0 var(--work-left); flex:none }
.work-sheet:has(.typed-work) #solution-editor { flex:1; min-height:0 }
.typed-work { display:flex; flex-direction:column; padding:0 max(16px,4.1667%) 84px var(--work-left); overflow:auto }
.math-editor.typed-work [data-pane=typed] { flex:1; height:auto; min-height:110px }
.entry-editor .editor-text {
  min-height:100px; padding:18px; border:1px solid #d5d3c9; border-radius:8px; background:#fefff1;
  font-size:1.35rem;
}
.math-tools {
  position:fixed; left:50%; bottom:max(18px,env(safe-area-inset-bottom)); z-index:2; transform:translateX(-50%);
  width:max-content; padding:4px; border-radius:26px; background:var(--graphite); color:white; box-shadow:var(--shadow);
}
.math-tools button:enabled:hover { background:#ffffff29 }
.entry-editor .math-tools { position:static; transform:none; margin-top:6px; color:var(--ink); background:#f2f2ee; box-shadow:none }
@media(max-width:700px) {
  .editor-modes { flex-basis:100% }
  .entry-editor .editor-top { gap:2px }
  .entry-editor .editor-sample { min-height:32px }
  .ink-zoom { right:10px; bottom:82px }
  .math-editor { --tool-size:42px }
  .ink-tools.expanded { max-width:calc(100vw - 16px); width:max-content; border-radius:18px }
  .tool-options { flex-wrap:wrap; gap:0 }
  .brush { padding:0 3px }
  .brush input { width:40px }
  .palette { position:fixed; bottom:calc(100% + 4px); left:50% }
  .entry-editor .palette { position:absolute }
  .entry-editor .ink-tools { padding:2px }
}
.work-sheet:has(.ink-description) #work-title { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }

@media(max-width:375px) {
  .math-editor:not(.entry-editor) .ink-toolbar:has(.ink-tools.expanded) .ink-zoom { bottom:134px }
}
