/* DAVINCI V2 pen (magic-sketch.js): the quill button, the ink layer over the whole screen and one slim glass bar at the bottom.
   Eddy 2026-10-05: the bar keeps its layout - messages never go into it (a small line above it), the note keeps a fixed width, narrow screens wrap into two clean rows.
   Surfaces use the shared template tokens (theme.css); the ink dots are the pen's own colours. */
#magicSketchPen{position:fixed;right:20px;bottom:24px;z-index:160;width:46px;height:46px;display:grid;place-items:center;padding:0;border-radius:50%;color:var(--text);background:var(--v2-panel);border:1px solid var(--pane-edge);box-shadow:0 10px 28px var(--shd);cursor:pointer}
#magicSketchPen>.gx{width:22px;height:22px}
#magicSketch[hidden],#magicSketchPen[hidden]{display:none}
#magicSketch{position:fixed;inset:0;z-index:170;background:transparent;font:400 var(--v2-label,12px)/1.4 var(--v2-font);color:var(--text)}
#magicSketch canvas{position:absolute;inset:0;width:100%;height:100%;background:transparent;touch-action:none;cursor:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24' fill='none' stroke='%23f3d58c' stroke-width='0.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19.8 3.2C13.2 4.6 8.8 10.2 6.6 17.4'/%3E%3Cpath d='M19.8 3.2C19.4 9.2 15 13.2 8.6 14M17.2 5.4L13.4 8.4M15.6 8.6L11.4 10.8'/%3E%3Cpath d='M6.6 17.4L5.4 20.4'/%3E%3C/svg%3E") 7 27,crosshair}

/* the dock: the message line sits above the bar, the bar never changes size for it */
#magicSketch .mDock{position:absolute;left:50%;bottom:18px;transform:translateX(-50%);box-sizing:border-box;width:max-content;max-width:calc(100% - 32px);display:flex;flex-direction:column;align-items:center;gap:6px;pointer-events:none}
#magicSketch .mDock>*{pointer-events:auto}
#magicSketch .mSay{box-sizing:border-box;max-width:min(520px,100%);margin:0;padding:4px 12px;border-radius:99px;background:var(--v2-panel);border:1px solid var(--pane-edge);-webkit-backdrop-filter:blur(var(--v2-blur));backdrop-filter:blur(var(--v2-blur));color:var(--soft);font-size:11.5px;text-align:center;overflow-wrap:anywhere}
#magicSketch .mSay:empty{display:none}

/* the bar: glass, round ink dots, glyph buttons */
#magicSketch .magicBar{box-sizing:border-box;max-width:100%;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:8px 10px;padding:7px 10px;border-radius:99px;background:var(--v2-panel);border:1px solid var(--pane-edge);-webkit-backdrop-filter:blur(var(--v2-blur)) saturate(1.2);backdrop-filter:blur(var(--v2-blur)) saturate(1.2);box-shadow:0 12px 40px var(--shd),inset 0 1px 0 var(--pane-hi)}
#magicSketch .mTools,#magicSketch .mWrite,#magicSketch .mInks,#magicSketch .mSizes{flex:none;display:flex;align-items:center;gap:6px}
#magicSketch .mTools{gap:8px}
#magicSketch button{margin:0;padding:0;border:0;background:transparent;color:inherit;font:inherit;cursor:pointer}
#magicSketch .mInk{width:16px;height:16px;border-radius:50%;background:var(--c);border:1px solid var(--pane-hi);transition:transform .2s var(--ease)}
#magicSketch .mInk.on{transform:scale(1.25);box-shadow:0 0 0 2px var(--ink),0 0 0 3px var(--hd)}
#magicSketch .mSize{width:22px;height:22px;display:grid;place-items:center;border-radius:50%}
#magicSketch .mSize i{display:block;border-radius:50%;background:var(--hd);opacity:.45}#magicSketch .mSize.on i{opacity:1}
#magicSketch .mSep{width:1px;height:18px;background:var(--line)}
#magicSketch .mIco{flex:none;width:28px;height:28px;display:grid;place-items:center;border-radius:50%}
#magicSketch .mIco:hover{background:var(--hover)}
#magicSketch .mIco svg,#magicSketch .magicSend svg{width:16px;height:16px;color:var(--hd)}
#magicSketch .mIco svg *,#magicSketch .magicSend svg *{stroke-width:1.1px!important;vector-effect:non-scaling-stroke}
/* every pen icon is a live DAVINCI glyph (.hv host): Leonardo's frame keeps its own fine line as it sketches in; a tool that is on shows it */
#magicSketch .gx .fr>*,#magicSketchPen .gx .fr>*{stroke-width:.45!important;vector-effect:none}
#magicSketch .mIco.on{background:var(--hover);box-shadow:inset 0 0 0 1px var(--hd)}
#magicSketch .magicInstruction{box-sizing:border-box;flex:0 0 260px;width:260px;min-width:0;margin:0;padding:5px 4px;border:0;border-bottom:1px solid var(--line);border-radius:0;background:transparent;color:var(--text);font:inherit;font-size:12.5px;outline:none}
#magicSketch .magicInstruction:focus{border-bottom-color:var(--hd)}
#magicSketch .magicInstruction::placeholder{color:var(--muted)}
#magicSketch .magicSend{flex:none;width:34px;height:34px;display:grid;place-items:center;border-radius:50%;background:var(--hd)}
#magicSketch .magicSend svg{color:var(--ink)}
#magicSketch .magicSend:disabled{opacity:.55;cursor:progress}

/* narrow screens: tools and close on the first row, the note and send on the second, full width */
@media(max-width:720px){
 #magicSketch .mDock{bottom:12px;width:calc(100% - 24px);max-width:none}
 #magicSketch .magicBar{width:100%;justify-content:space-between;border-radius:var(--v2-card-radius,18px);padding:8px 10px}
 #magicSketch .mWrite{order:3;flex:1 1 100%;gap:8px}
 #magicSketch .magicInstruction{flex:1 1 auto;width:auto}
 #magicSketchPen{right:12px;bottom:16px}
}

/* Eddy 2026-10-05: DaVinci minimized sits bottom-right, so the pen moves to the bottom-left */
/* over the model (Eddy 2026-10-14): the pen lies under the page's own controls, so menus and the top bar stay usable while sketching; one pointer draws, two move the view.
   The ink is only painted by #magicSketch canvas (no pointer events); the .mCatch layer below the page UI takes the pointer. */
#magicSketch.mPass,#magicSketch.mPass canvas{pointer-events:none}
#magicSketch.mPass textarea{pointer-events:auto}
/* a note on the sketch (QA #621): its editor, with the sweep that removes it */
#magicSketch .mNote{position:fixed;z-index:2147483100;display:flex;align-items:flex-start;gap:4px;pointer-events:auto}
#magicSketch .mNote .mNoteDel{background:var(--v2-panel);border:1px solid var(--pane-edge)}
.mCatch{position:fixed;inset:0;z-index:1;touch-action:none;background:transparent;cursor:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24' fill='none' stroke='%23f3d58c' stroke-width='0.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19.8 3.2C13.2 4.6 8.8 10.2 6.6 17.4'/%3E%3Cpath d='M19.8 3.2C19.4 9.2 15 13.2 8.6 14M17.2 5.4L13.4 8.4M15.6 8.6L11.4 10.8'/%3E%3Cpath d='M6.6 17.4L5.4 20.4'/%3E%3C/svg%3E") 7 27,crosshair}

/* QA #658: saved sketches - the Save box and the list sit above the bar, in the pen's own glass */
#magicSketch .mPop{box-sizing:border-box;width:min(360px,calc(100vw - 32px));max-height:min(46vh,380px);overflow:auto;display:grid;gap:8px;padding:12px 14px;border-radius:22px;background:var(--v2-panel);border:1px solid var(--pane-edge);-webkit-backdrop-filter:blur(var(--v2-blur)) saturate(1.2);backdrop-filter:blur(var(--v2-blur)) saturate(1.2);box-shadow:0 12px 40px var(--shd);color:var(--text)}
#magicSketch .mPop label{font:600 10px/1 var(--v2-font,Inter);letter-spacing:.16em;text-transform:uppercase;color:var(--hd,#f3d58c)}
#magicSketch .mPop input{box-sizing:border-box;width:100%;padding:7px 12px;border-radius:99px;border:1px solid var(--line);background:var(--field);color:inherit;font:inherit;outline:none}
#magicSketch .mPop span{display:flex;gap:8px}
#magicSketch .mPop button{padding:6px 14px;border-radius:99px;background:var(--faint);font-size:12px}#magicSketch .mPop button:hover{background:var(--hover)}#magicSketch .mPop .mPri{background:linear-gradient(135deg,#f3d88f,#c99a3d);color:#1d1b17}
#magicSketch .mList{display:grid;gap:6px}#magicSketch .mNone{margin:0;color:var(--muted)}
#magicSketch .mRow{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:6px;border-radius:16px;background:var(--faint)}
#magicSketch .mRow img,#magicSketch .mRow i{flex:none;width:64px;height:40px;border-radius:10px;object-fit:cover;background:var(--field)}
#magicSketch .mRow .mOpen{flex:1;min-width:0;display:grid;text-align:left;background:none;padding:2px 4px}#magicSketch .mRow .mOpen b{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#magicSketch .mRow small{color:var(--muted);font-size:10.5px}
#magicSketch .mRow .mVers{flex:1 1 100%;flex-wrap:wrap;gap:4px}#magicSketch .mRow .mVers button{padding:3px 9px;font-size:11px}

/* QA #659: schematic mode - the bar says so, notes are numbered instructions */
#magicSketch .mIco.on{box-shadow:inset 0 0 0 1.5px var(--hd,#f3d58c)}
#magicSketch.mSchem .magicBar{border-color:var(--hd,#f3d58c)}
