/* Math Working (working.js, 23 Nov 2026): typed lines over the calculator's keys (calc.css draws .cx-pad), the pen pad as
   Write on a finger-or-pen tablet. The card's frame, its bar and its place beside the question are app.css's .working. */
.wk .wk-type,.wk .wk-write{flex:1;min-height:0;display:flex;flex-direction:column}
.wk .wk-type{padding:8px 8px 6px}
.working.wk:not(.open) :is(.wk-toolbar,.wk-tabs,.wk-type,.wk-write,.wk-diagram,.wk-keys,.wk-coach){display:none}
.wk:is([data-view="write"],[data-view="diagram"]) :is(.wk-type,.wk-keys),.wk:not([data-view="write"]) .wk-write,.wk:not([data-view="diagram"]) .wk-diagram{display:none}
.wk .wk-write .pad-tools{display:flex}
.wk .wk-write .padwrap{display:block}

/* Write or Type, on a tablet */
.wk-tabs{display:flex;flex:none;gap:4px;padding:6px;background:var(--sunk);border-bottom:1px solid var(--line)}
.wk-tabs button{flex:1;min-height:40px;border:1px solid var(--line);border-radius:var(--r-md);background:var(--surface);color:var(--ink);font:600 14px var(--display)}
.wk-tabs button[aria-pressed="true"]{background:var(--btn);border-color:var(--btn);color:var(--on-btn)}

/* The typed lines: each a MathQuill field on a ruled line, set in the question's maths size */
.wk-lines{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;border:1px solid var(--line);border-radius:var(--r-md);padding:6px 10px;background:var(--surface);color:var(--ink);cursor:text}
.wk-line{min-height:44px;display:flex;align-items:center;border-bottom:1px solid var(--line)}
.wk-line:last-child{border-bottom:0}
.wk-math{display:block;width:100%;font-size:20px;line-height:1.35}
.wk-math.mq-editable-field,.wk-math.mq-editable-field.mq-focused{border:0;box-shadow:none;outline:0}
.wk-math .mq-root-block{padding:4px 0;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}
.wk-math .mq-root-block::-webkit-scrollbar{display:none}
.wk-math .mq-cursor{border-left:2px solid var(--accent);margin-left:-1px}
.wk-line:first-child .mq-root-block.mq-empty::after{content:"Type a step; ↵ starts the next";font:16px var(--text);color:var(--ink-soft);opacity:.8;visibility:visible}
.wk-line:first-child .mq-focused .mq-root-block.mq-empty::after{content:none}
.wk-loading{margin:4px 0;color:var(--ink-soft);font:15px var(--text)}

/* The maths keypad (calc/keypad.mjs PAD_HTML), the calculator's and Working's: moved here from calc/calc.css on 23 Nov 2026
   so it is styled with the app's first load (Working draws it before the calculator has ever opened). */
/* The maths keypad (keypad.mjs): three blocks as on a phone calculator, digits on the surface, operators and letters
   a step quieter, functions and the cursor on the sunk tone, Enter in the accent. Each key fills its cell (no gaps
   that swallow taps); the space between keys is drawn inside the cell. */
.cx-pad{flex:none;position:relative;padding:4px 3px calc(4px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:var(--sunk);user-select:none;-webkit-user-select:none}
.cx-pad[hidden],.cx-pad [hidden]{display:none!important}
.cx-padmain{display:flex;gap:6px}
.cx-block{display:grid;grid-auto-rows:46px}
.cx-left,.cx-mid{flex:4 1 0;grid-template-columns:repeat(4,minmax(0,1fr))}
.cx-right{flex:2 1 0;grid-template-columns:repeat(2,minmax(0,1fr))}
.cx-pad .cx-key{position:relative;min-width:0;min-height:0;height:100%;margin:0;padding:0;border:0;background:transparent;font:500 19px/1 var(--text);color:var(--ink);display:flex;align-items:center;justify-content:center;-webkit-tap-highlight-color:transparent}
.cx-pad .cx-key::before{content:"";position:absolute;inset:2.5px 2px;border-radius:var(--r-md);background:color-mix(in srgb,var(--surface) 55%,var(--sunk));border:1px solid var(--line);z-index:-1}
.cx-pad .cx-key{z-index:0;isolation:isolate}
.cx-pad .k-num::before{background:var(--surface);border-color:var(--edge)}
.cx-pad .k-num{font-weight:500;font-size:20px;font-variant-numeric:tabular-nums}
/* the maths keys in a serif, letters italic, as Desmos's keypad sets them (the x key a slanted x, never the × of times) */
.cx-pad .cx-left .cx-key:not(.k-mode),.cx-pad .k-num,.cx-pad .k-op{font-family:"Times New Roman",Times,serif;font-weight:400;font-size:21px}
.cx-pad .cx-key sup{font-size:.62em;margin:0 0 .7em 2px;line-height:1;vertical-align:baseline}
.cx-pad .cx-key i+sup{position:relative;top:-.15em}
.cx-pad .k-var{font-size:21px}
.cx-pad .k-op{color:var(--ink);font-weight:500;font-size:20px}
.cx-pad .k-mode{font-size:14.5px;font-weight:500}
.cx-pad .k-mode::before{background:color-mix(in srgb,var(--ink) 9%,var(--sunk))}
.cx-pad .k-enter{color:var(--on-btn)}
.cx-pad .k-enter::before{background:var(--btn);border-color:transparent}
.cx-pad .k-wide{grid-column:span 2}
.cx-pad .cx-key:active::before{filter:brightness(.92)}
.cx-pad .cx-key:focus-visible{outline:none}
.cx-pad .cx-key:focus-visible::before{outline:2px solid var(--accent);outline-offset:1px}
.cx-pad .cx-key[aria-pressed=true]::before{background:var(--surface);border-color:var(--ink)}
.cx-padabc{display:flex;flex-direction:column}
.cx-abcrow{display:flex;height:46px}
.cx-abcrow .cx-key{flex:1 1 0}
.cx-abcrow.r1{padding:0 5%}
.cx-abcrow .k-letter{font-size:19px}
.cx-abcrow .cx-key small{font-size:.62em;margin-left:2px;color:var(--ink-soft)}
.cx-abcrow .cx-key sub{font-size:.62em;position:relative;top:.4em;margin-left:1px}
.cx-abcrow [data-pad="_"]{font-family:"Times New Roman",Times,serif;font-size:21px}
.cx-abcrow .k-mode,.cx-abcrow .k-enter{flex:1.4 1 0}
.cx-funcs{position:absolute;inset:0 0 auto 0;max-height:100%;overflow-y:auto;overscroll-behavior:contain;background:var(--sunk);padding:6px 8px calc(8px + env(safe-area-inset-bottom));z-index:2;box-shadow:0 -1px 0 var(--line)}
.cx-funcshead{display:flex;align-items:center;justify-content:space-between;padding:0 2px 2px}
.cx-funcshead .cx-key{width:72px;height:44px;flex:none}
.cx-funcgroup{display:flex;flex-direction:column;gap:2px;margin-top:4px}
.cx-functitle{font-size:12px;font-weight:500;color:var(--ink-soft);padding:0 2px}
.cx-funcrow{display:flex;flex-wrap:wrap}
.cx-funcrow .cx-key{flex:0 0 auto;min-width:76px;height:44px;padding:0 12px;font-size:15px;font-weight:500}
@media (min-width:600px){.cx-block,.cx-abcrow{grid-auto-rows:50px}.cx-abcrow{height:50px}.cx-padmain{gap:12px}}

/* The keys: the calculator's, a little shorter here so the lines keep their room */
.wk .wk-keys{flex:none;border-radius:0}
.wk .wk-keys .cx-block{grid-auto-rows:42px}
.wk .wk-keys .cx-abcrow{height:42px}
.wk .wk-keys .cx-funcs{max-height:180px;overflow:auto}
.wk.coach-reading .wk-keys{display:none}
/* (a typed answer on a phone: the same keys type into his answer box until he taps a line again) */
.wk.answering .wk-keys :is(.cx-padmain,.cx-padabc,.cx-funcs){display:none!important}
.wk-answer-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:2px 4px 6px;font:600 14px var(--display)}
.wk-answer-head .soft.small{min-height:36px}
.wk-answer-keys .spr-keys{display:grid;max-width:none;margin:0}

/* A phone held upright with Working open: Working's own tools in a row; the coach's reply beside the work; Lock in alone
   underneath, shown once there is an answer to lock in */
.wk-toolbar{position:relative;display:flex;flex:none;gap:2px;padding:0 4px;border-bottom:1px solid var(--line);background:var(--surface)}
.wk-toolbar .qtool{flex:1 1 0;min-width:0;min-height:48px}
.wk-more{position:absolute;z-index:6;top:calc(100% + 4px);right:6px;padding:8px;background:var(--surface);border:1px solid var(--line-strong);border-radius:var(--r-md);box-shadow:0 8px 20px rgb(0 0 0 / .16)}
.wk-more[hidden]{display:none}
.wk-more .soft.small{min-height:44px;gap:6px}
.wk-coach{flex:none;margin:6px 8px 0;border:1px solid var(--line-strong);border-radius:var(--r-md);background:var(--sunk);font:15px/1.45 var(--text)}
.wk-coach summary{display:flex;align-items:center;gap:6px;min-height:36px;padding:0 10px;font:600 14px var(--display);cursor:pointer}
.wk-coach .coach-text{max-height:96px;overflow:auto;padding:0 10px 8px}
.wk-coach .thinking{display:block}
@media (max-width:739px){
  .session.quant.working-open #qcard .spr-keys{display:none}
  .wk-foot:has(.lockin:disabled){display:none}
  .session.quant .working.wk.open{margin-inline:calc(-1 * var(--gutter));border-radius:var(--r-lg) var(--r-lg) 0 0;border-bottom:0}
}

/* A tablet upright (740 px and wider, taller than wide): typing gets the full width under the question; Write keeps the
   pen pad beside it, as before */
@media (min-width:740px) and (min-height:600px) and (orientation:portrait){
  .session.quant .s-body:has(.wk.open:not([data-view="write"])){flex-direction:column}
  .session.quant .s-body:has(.wk.open:not([data-view="write"])) .s-card{flex:0 0 42%;min-height:0}
  .session.quant .s-body:has(.wk.open:not([data-view="write"])) .wk{flex:1 1 0;min-height:0;width:100%}
}

/* His saved working, in review */
.wk-review{border:1px solid var(--line);border-radius:var(--r-md);padding:4px 10px;margin:0 0 10px;cursor:default}
.wk-review .wk-math{font-size:18px}
.wk-review-text{white-space:pre-wrap;font:17px/1.5 var(--text)}

/* The calculator open beside the question on a laptop: its own keys are on screen and a keyboard types Working's lines,
   so Working keeps only its lines and both fit */
@media (pointer:fine){body.calc-open:not(.calc-sheet) .wk .wk-keys{display:none}}

/* A screen on its side, short or narrow (working.js COMPACT; owner, 22 Nov 2026): the question and Working side by side,
   the keys a size smaller, and on a phone the tools and Lock in share one row, so the question, the work, the keys, the
   tools and Lock in are all on the screen at once (667 x 375: test/fits.mjs, test/layout.mjs) */
@media (orientation:landscape) and (max-width:739px),(orientation:landscape) and (max-height:500px){
  .session.quant .s-body{flex-direction:row;gap:8px;padding-bottom:6px}
  .session.quant .s-card{flex:1 1 0;min-width:0;max-height:none!important}
  .session.quant .working.wk.open{flex:1.15 1 0;min-width:0;min-height:0;margin-inline:0;border-radius:var(--r-lg);border-bottom:1px solid var(--line-strong)}
  .wk .wk-type{padding:4px}
  .wk .wk-line{min-height:34px}
  .wk .wk-keys{padding:2px}
  .wk .wk-keys .cx-block{grid-auto-rows:31px}
  .wk .wk-keys .cx-abcrow{height:31px}
  .wk .wk-keys .cx-key{font-size:16px}
  .wk-tabs{padding:4px} .wk-tabs button{min-height:34px}
  .session.quant .s-foot.phone-foot{flex-direction:row;align-items:center;gap:6px;padding-top:3px;padding-bottom:calc(3px + env(safe-area-inset-bottom))}
  .session.quant .phone-foot .tool-row{flex:1 1 auto}
  .session.quant .phone-foot > .lockin{width:auto;flex:0 0 34%;min-height:40px}
  .session.quant .phone-foot .qtool{min-height:40px}   /* (40 px tall, the full width of its share wide: the room goes to the question and pad; owner, 23 Nov 2026) */
  .session.quant .jump.more-below{display:none}   /* (it covered the question's words or a cross-out; the cut-off choice shows there is more) */
}

/* The diagram board (diagram.js): the question's figure, or a blank grid, sized to its stage; his lines and ink over it */
.wk .wk-diagram{flex:1;min-height:0;display:flex;flex-direction:column;padding:6px 8px}
.dg-stage{flex:1;min-height:120px;display:flex;align-items:center;justify-content:center;overflow:hidden}
.dg-board{position:relative;flex:none;background:var(--surface);border:1px solid var(--line);border-radius:var(--r-md);touch-action:none}
.dg-board.blank{background-image:linear-gradient(90deg,var(--grid) 1px,transparent 1px),linear-gradient(var(--grid) 1px,transparent 1px);background-size:24px 24px}
.dg-base,.dg-base svg,.dg-marks,.dg-ink,.dg-labels{position:absolute;inset:0;width:100%;height:100%}
.dg-base svg{max-width:none}
.dg-base.figure{margin:0;overflow:visible}   /* (the app's .figure margin shifted the figure off the marks drawn over it; 23 Nov 2026) */
.dg-marks{overflow:visible;pointer-events:none}
.dg-ink{pointer-events:none;touch-action:none}
.dg-labels{pointer-events:none}
.dg-line{stroke:var(--accent);stroke-width:3;stroke-linecap:round}
.dg-snap{fill:transparent;stroke:var(--accent);stroke-width:1.5;stroke-dasharray:3 3;opacity:.7}
.dg-pending{fill:color-mix(in srgb,var(--accent) 25%,transparent);stroke:var(--accent);stroke-width:2}
.dg-tools{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:4px;flex:none;margin-top:6px}
.dg-tools button{min-width:0;min-height:40px;padding:0 4px;border:1px solid var(--line);border-radius:var(--r-md);background:var(--surface);color:var(--ink);font:500 13.5px var(--display)}
.dg-tools button[aria-pressed="true"]{background:var(--btn);border-color:var(--btn);color:var(--on-btn)}
.wk-review-board .dg-stage{height:min(48vw,260px);margin:0 0 10px}

/* See it solved (worked.js openPage): a question's own page, filling the sheet under Close, with its own controls and colors */
.wk-solved{flex:1;min-height:0;display:flex;flex-direction:column}
.wk-solved[hidden]{display:none}
.wk-solved.sheet{position:fixed;inset:0;z-index:60;background:var(--surface);padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)}
body.solving-open{overflow:hidden}
.wk-solved.sheet.page{background:#fff}   /* (the page's own ground, tools/solved_pages/page.mjs, so Close's row is one with it) */
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]) .wk-solved.sheet.page{background:#0e1411}}
:root[data-theme="dark"] .wk-solved.sheet.page{background:#0e1411}   /* (dark chosen in the app, not only by the phone) */
.wk-solved.sheet.page iframe{visibility:hidden}   /* (shown once the page says it has drawn: no blank flash while it loads) */
.wk-solved.sheet.page[data-ready] iframe{visibility:visible}
.wk-solved-head{display:flex;align-items:center;gap:6px;flex:none;padding:6px 12px;font:600 15px var(--display)}
.wk-solved-head .soft.small{min-height:36px}
.wk-solved-body{flex:1;min-height:0;overflow:hidden;padding:0;display:flex;flex-direction:column}
.wk-solved.page iframe{flex:1;width:100%;border:0}
@media (pointer:coarse){.wk-solved-head .soft.small{min-height:44px;padding:0 14px}}
@media (max-height:500px){.wk-solved-head{padding:2px 10px}}
@media (pointer:coarse) and (min-height:600px){.wk-tabs button,.dg-tools button{min-height:44px}}
