/* Layout trial (app/layout.html): the studio's own page and modules, arranged with the menus on the left, a larger render in the centre and
   the 2D drawings on the right. Loaded after instrument.css; only arrangement and what is shown change. */
main.lay{display:grid;grid-template-columns:minmax(280px,320px) minmax(0,1fr) minmax(260px,300px);grid-template-areas:"menu render draw";min-height:0;flex:1}
main.lay aside{grid-area:menu;width:auto;border-left:0;border-right:1px solid var(--line);order:0}
main.lay #stage{grid-area:render;display:flex;position:relative;min-width:0;min-height:0}
main.lay #draw{grid-area:draw;display:flex;flex-direction:column;min-width:0;min-height:0;border-left:1px solid var(--line);background:var(--panel);overflow:auto}
/* a view (the render, the plan, the section) is one box: on the stage it fills the centre, on the right it takes its own height */
.dv{display:flex;flex-direction:column;min-width:0;min-height:0}
.dv svg{width:100%;touch-action:none;user-select:none;background:#fbfbf9}
main.lay #stage>.dv{flex:1}
main.lay #stage>.dv svg{flex:1 1 0;min-height:0}
main.lay #stage>.dv[data-view=render]>.dhead{display:none}
main.lay #stage>.dv[data-view=render] #gl{position:absolute;inset:0;border-right:0}
main.lay #draw>.dv{flex:none;border-bottom:1px solid var(--line)}
main.lay #draw>.dv svg{height:auto;aspect-ratio:70/82}
main.lay #draw>.dv svg#section{aspect-ratio:71/27}   /* taller than its frame, so the wrist's note under the case is inside the drawing */
main.lay #draw>.dv[data-view=render] #gl{position:relative;aspect-ratio:4/3;width:100%;border-right:0}
main.lay #draw>.dv[data-view=render] #glbar{display:none}
main.lay .dhead{display:flex;align-items:baseline;gap:6px;padding:6px 12px 4px;font-weight:600;font-size:12px;color:var(--ink)}
main.lay .dhead small{font-weight:400;color:var(--mute);flex:1;min-width:0}
main.lay #draw .dhead small{display:none}
.toStage,#toRender{margin-left:auto;border:0;background:transparent;color:var(--mute);font:inherit;font-size:12px;font-weight:400;padding:0;text-decoration:underline;text-underline-offset:2px;cursor:pointer}
.toStage:hover,#toRender:hover{color:var(--ink)}
#toRender{position:absolute;right:12px;bottom:10px;z-index:2;background:rgba(255,255,255,.8);padding:3px 9px;border-radius:5px;text-decoration:none;color:var(--ink)}
#toRender[hidden],.toStage[hidden]{display:none}
main.lay #readout{grid-column:auto;border-top:0;padding:8px 12px}

/* the way through: open, change, measure, keep. Plain words in the header; a small number, no badge */
#path{position:relative;display:flex;min-width:0;flex:0 1 auto}
#pathSteps{display:flex;align-items:center;gap:2px;min-width:0}
#pathSteps button{display:flex;align-items:baseline;gap:6px;border:0;background:transparent;font:inherit;font-size:12px;color:var(--mute);padding:5px 10px 5px 4px;white-space:nowrap;cursor:pointer;border-radius:3px}
#pathSteps button:hover{color:var(--ink);background:rgba(0,0,0,.05)}
#pathSteps button i{font-style:normal;font-size:10px;font-variant-numeric:tabular-nums;color:var(--mute);opacity:.7}
#pathSteps button[data-done]{color:var(--ink)}
#pathSteps button[data-bad]{color:#a02c2c}
#pathSteps button[data-busy] span{opacity:.6}
#pathSteps button+button::before{content:"";width:14px;height:1px;background:var(--line);align-self:center;margin-right:6px}
#keepBox{position:absolute;left:0;top:calc(100% + 8px);z-index:30;width:340px;max-width:calc(100vw - 20px);display:grid;grid-template-columns:1fr auto auto;gap:8px;align-items:center;padding:12px;background:var(--paper);border:1px solid var(--ink);box-shadow:0 8px 24px rgba(0,0,0,.14);font-size:12px}
#keepBox[hidden]{display:none}
#keepBox label,#keepBox small{grid-column:1/-1;color:var(--mute)}
#keepBox input{font:inherit;padding:5px 8px;border:1px solid var(--line);border-radius:3px;min-width:0}
#keepBox button{font:inherit;font-size:12px;padding:5px 10px;border:1px solid var(--ink);border-radius:3px;background:transparent}
#keepBox button.primary{background:var(--ink);color:var(--paper)}
/* keeping is the fourth place on the way; the header's own save button would be a second one */
header #save{display:none}
header label select{max-width:210px}
table.readback.stale{opacity:.45}
#preview{padding:8px 12px;border-top:1px solid var(--line);background:#fffbe8;font-size:12px;line-height:1.5}
#preview b{font-weight:600}
#preview .was{color:var(--mute);text-decoration:line-through;margin-right:4px}

/* a lug chosen on the model: its shape as typed values */
.lugShape{display:grid;gap:6px;margin:6px 0 10px;padding:8px 10px;border:1px solid var(--line);border-radius:6px;background:#fff}
.lugShape label{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:13px}

/* the header: what a first-time user needs (the watch, undo, start over, save); the rest behind More */
#more{position:relative}#more>summary{list-style:none;cursor:pointer;border:1px solid var(--ink);padding:5px 10px;font-size:12px;border-radius:3px}#more>summary::-webkit-details-marker{display:none}
#more[open]>summary{background:var(--ink);color:var(--paper)}
#moreMenu{position:absolute;right:0;top:calc(100% + 6px);z-index:20;width:340px;max-width:calc(100vw - 20px);background:var(--paper);border:1px solid var(--ink);box-shadow:0 8px 24px rgba(0,0,0,.14);display:flex;flex-direction:column;gap:10px;padding:12px}
#moreMenu label{display:flex;flex-wrap:wrap;align-items:center;gap:6px;color:var(--mute);flex:none!important;min-width:0!important}#moreMenu label select{flex:1 1 160px!important;min-width:0;max-width:none!important}
#moreMenu>button{align-self:flex-start;border:1px solid var(--ink);background:transparent;font-size:12px}#moreMenu>button[hidden]{display:none}
#moreMenu a{font-size:12px}

/* the pick message: what was picked, or that nothing was. It sits at the foot of the menu column, never over the watch */
#pickBar{position:fixed;left:12px;bottom:12px;max-width:256px;z-index:50;padding:10px 14px;border-radius:8px;background:#1b1c1e;color:#fff;font-size:14px;box-shadow:0 6px 18px rgba(0,0,0,.25)}
#pickBar button{margin-left:8px;background:#fff;color:#1b1c1e;border:0;border-radius:4px;padding:4px 10px;font:inherit}

/* reality readback */
#readbackBox{padding:8px 12px;border-top:1px solid var(--line)}
#readbackBox button{font:inherit;padding:4px 10px}
#stillBox{padding:8px 12px;border-top:1px solid var(--line)}
#stillBox button{font:inherit;padding:4px 10px}
#stillBox img.still{display:block;width:100%;height:auto;margin-top:8px;border-radius:4px}
table.readback{border-collapse:collapse;margin-top:6px;font-size:13px;font-variant-numeric:tabular-nums}table.readback td,table.readback th{padding:2px 10px 2px 0;text-align:left}
table.readback tr.off td{color:#a02c2c;font-weight:600}

#phoneTabs{display:none}

/* one way into the exact CAD: the drawings pane's "Measure it in exact CAD" */
#outs [data-out=check]{display:none!important}

/* no status badges or ledger counts in front of the user */
main.lay #stFaults,main.lay #stOut,main.lay #steps,main.lay #critCount,main.lay #cadNote,main.lay #rulesHead,main.lay #rules{display:none!important}

/* every slider can also take a typed value */
.chips.carried>label::after{content:' (set on this watch)';color:var(--mute);font-weight:400}
.num + output{display:none}
.num{width:62px;margin-left:6px;font:inherit;font-variant-numeric:tabular-nums;padding:1px 4px;border:1px solid var(--line);border-radius:4px;background:#fff}

/* handles this page adds on the section drawing (layout.mjs): a diamond for a design value */
svg .h.extra{fill:#b5622c;stroke:#fff}

@media (max-width:820px){
  /* the header's menus in one row that scrolls sideways, so the watch is on screen at once */
  header{flex-wrap:nowrap!important;overflow-x:auto;gap:8px;padding:6px 10px}
  header>*,header label{flex:0 0 auto!important;min-width:max-content}
  header label select{flex:none!important;max-width:220px}
  header .brand span{display:none}
  /* Undo and Start over first in the row, where a thumb finds them; the row scrolls sideways for the rest */
  header #undo{order:-2}header #over{order:-1}
  header{mask-image:linear-gradient(90deg,#000 88%,transparent);-webkit-mask-image:linear-gradient(90deg,#000 88%,transparent)}
  #overMenu,#moreMenu{position:fixed;right:8px;top:56px}
  /* on a phone the watch is the sticky top half; the message sits across the foot of the screen, over the menus */
  #pickBar{left:8px;right:8px;max-width:none}
  /* the view buttons in one row that scrolls sideways (they were cut off at the right edge) */
  #glbar{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none}#glbar>*{flex:none}
  #statebar{top:46svh}
  main.lay{display:flex;flex-direction:column;overflow:visible}
  main.lay #stage{order:1;position:sticky;top:0;z-index:5;height:46svh;flex:none}
  main.lay #draw{order:2;border-left:0;overflow:visible}
  main.lay #draw>.dv svg{flex:none;height:auto;aspect-ratio:70/72;min-height:0}
  main.lay #draw>.dv svg#section{aspect-ratio:58/22}
  main.lay #draw .dhead small{display:inline}
  .toStage,#toRender{display:none}
  /* the line above already names the watch and its changes; the phone shows the two places that follow */
  #statebar #pathSteps button[data-step=open],#statebar #pathSteps button[data-step=change]{display:none}#statebar #pathSteps button[data-step=measure]::before{display:none}
  #statebar #path{margin-top:6px}#statebar #pathSteps{flex-wrap:wrap}#statebar #pathSteps button{padding-left:0}
  #statebar #keepBox{position:static;margin-top:8px;width:auto;box-shadow:none}#statebar #path{flex-direction:column}
  /* a vertical swipe on a drawing scrolls the page; only a handle or a figure takes the touch (it used to be the whole drawing) */
  main.lay #draw svg{touch-action:pan-y}
  main.lay #draw svg .h,main.lay #draw svg .edit{touch-action:none}
  /* Controls or Drawings under the render, so the menus are not below both drawings */
  #phoneTabs{display:flex;position:sticky;top:46svh;z-index:6;background:var(--paper);border-bottom:1px solid var(--line);order:1}
  #phoneTabs button{flex:1;padding:10px 0;border:0;background:transparent;font:inherit;font-size:14px;color:var(--mute);border-bottom:2px solid transparent}
  #phoneTabs button[aria-selected=true]{color:var(--ink);border-bottom-color:var(--ink);font-weight:600}
  main.lay[data-tab=controls] #draw{display:none}
  main.lay[data-tab=drawings] aside{display:none}
  main.lay #draw{order:2}main.lay aside{order:2}
  /* handles big enough for a finger */
  main.lay #draw svg circle.h{r:1px}
  main.lay #draw svg rect.h{stroke-width:.25}
  main.lay aside{order:3;border-right:0;overflow:visible}
}

/* stock parts: a quiet line beside a governed value, and the three counts opening to the list. The page's own ink and mute; no badges */
#stockBox{font-size:12px;color:var(--mute);margin:-2px 0 10px}
#stockBox[hidden]{display:none}
#stockBox>summary{cursor:pointer;list-style:none;padding:2px 0}
#stockBox>summary::-webkit-details-marker{display:none}
#stockBox>summary b{font-weight:500;color:var(--ink);font-variant-numeric:tabular-nums}
#stockBox[open]>summary{color:var(--ink)}
.stockList{margin:6px 0 4px;font-size:11px}
.stockList td{padding:3px 6px 3px 0;vertical-align:top;border-top:1px solid var(--line)}
.stockList td:nth-child(2){text-align:right;white-space:nowrap;color:var(--ink)}
.stockList td:last-child{padding-right:0;overflow-wrap:anywhere;text-align:left}
.stockList a{color:inherit;text-underline-offset:2px}
.stockList tr.shown{opacity:.7}
.stockList small.caveat{display:block;color:var(--mute)}
.stockMark{display:block;width:100%;font-size:11px;color:var(--mute);line-height:1.35}
.stockMark span{color:var(--ink)}
.stockMark .linkish,.stockList .linkish{font-size:11px;color:var(--ink)}
#dims tr.stockRow td{padding-top:0;border-top:0}
