/* NOISE lab · access editor, part 2 (proposed, Package 11): the desk (map plate, resize seam, inspector), the three
   inspector panels and the nodes editor.js generates in them, dialogs, and the phone, short-landscape and enlarged-text
   arrangements. Desktop and laptop are the base here; tokens, header, stage and plate are in access.css. */

/* ---------- desk: the map takes the room, the inspector sits beside it at the width the seam sets ---------- */
.ax > .ax-desk{
  display:grid;min-width:0;min-height:0;
  grid-template-columns:minmax(0,1fr) auto clamp(15rem,var(--editor-panel,22rem),50%);
  grid-template-rows:minmax(0,1fr);
  grid-template-areas:"stage seam panel";
}
.ax-stage{grid-area:stage}
#editorResize{grid-area:seam}
.ax-inspector{grid-area:panel}
.ax.panel-closed > .ax-desk{grid-template-columns:minmax(0,1fr);grid-template-areas:"stage"}
.ax.panel-closed :is(#editorResize,.ax-inspector){display:none}
@media (min-width:100rem){.ax > .ax-desk{grid-template-columns:minmax(0,1fr) auto clamp(15rem,var(--editor-panel,24rem),50%)}}

/* The seam: a paper gutter with a grip; its hit area reaches a little into both neighbours. */
#editorResize{position:relative;z-index:4;width:.5rem;min-height:0;background:var(--paper);border-inline:1px solid var(--rule);cursor:col-resize;touch-action:none}
#editorResize::before{
  content:"";position:absolute;top:50%;inset-inline-start:50%;width:3px;height:2.5rem;margin:-1.25rem 0 0 -1.5px;border-radius:2px;
  background:var(--ink-3);opacity:.55;transition:transform 180ms var(--ease-out),opacity 140ms ease,background-color 140ms ease;
}
#editorResize::after{content:"";position:absolute;inset-block:0;inset-inline:-.375rem}
#editorResize:is(:focus-visible,:active)::before{opacity:1;background:var(--signal-ink);transform:scaleY(1.6)}
#editorResize:focus-visible{outline-offset:-2px}
@media (hover:hover) and (pointer:fine){#editorResize:hover::before{opacity:1;background:var(--signal-ink);transform:scaleY(1.6)}}

/* ---------- inspector ---------- */
.ax-inspector{
  container:inspector/inline-size;
  display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);
  min-width:0;min-height:0;background:var(--plate);
}

/* Tabs: icon and full label; the selected one is underlined in ink and its icon takes the signal. */
.ax-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));background:var(--plate);border-bottom:1px solid var(--rule-2)}
.ax-tabs > button{
  position:relative;gap:.4375rem;min-width:0;min-height:3rem;padding:.5rem .375rem;
  border:0;border-radius:0;background:transparent;color:var(--ink-3);
  font-size:.875rem;font-weight:600;line-height:1.2;
}
.ax-tabs > button > span{min-width:0;overflow-wrap:break-word;text-wrap:balance}
.ax-tabs > button::after{
  content:"";position:absolute;inset-inline:.75rem;bottom:-1px;height:3px;border-radius:2px 2px 0 0;
  background:var(--ink);transform:scaleX(0);transition:transform 220ms var(--ease-out);
}
.ax-tabs > :is([aria-selected=true],.active){color:var(--ink)}
.ax-tabs > :is([aria-selected=true],.active) svg{color:var(--signal-ink)}
.ax-tabs > :is([aria-selected=true],.active)::after{transform:scaleX(1)}
.ax-tabs > button:focus-visible{outline-offset:-3px}
@media (hover:hover) and (pointer:fine){.ax-tabs > button:hover{background:var(--plate-2);color:var(--ink)}}
@container inspector (max-width:23.5rem){
  .ax-tabs > button{flex-direction:column;gap:.25rem;min-height:3.5rem;padding:.5rem .25rem .625rem;font-size:.8125rem}
}

.ax-panel{
  position:relative;display:flex;flex-direction:column;gap:1rem;min-width:0;min-height:0;
  padding:1rem 1rem 1.5rem;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;
}
.ax-panel > *{flex:none;min-width:0}
.ax-head{display:flex;align-items:baseline;justify-content:space-between;gap:.75rem}
.ax-panel h2{font:600 1rem/1.3 var(--f-display);letter-spacing:.01em}
.ax-count{padding:.1875rem .4375rem;border:1px solid var(--rule-2);border-radius:999px;font:600 .8125rem/1 var(--f-num);font-variant-numeric:tabular-nums;color:var(--ink-2)}
.ax-count:empty{display:none}
/* The tab already names these two panels; their headings stay for assistive technology only. */
:is(#axPanelNav,#axPanelVersions) > .ax-head{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

.ax-row{display:grid;gap:.3125rem;min-width:0}
.ax-row > span{font-size:.8125rem;font-weight:600;line-height:1.3;color:var(--ink-2);overflow-wrap:break-word}
.ax-row > :is(input,select,textarea){width:100%}
.ax-panel > .ax-check,.ax-pair > .ax-check,.ax-more > .ax-check{display:flex}
.ax .button-row{display:flex;flex-wrap:wrap;gap:.375rem}

/* ---------- areas panel ---------- */
/* Overlap rule, layer order and "clear all", generated by the controller above the list. */
.layer-controls{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;min-width:0}
.layer-controls label{display:grid;gap:.3125rem;flex:1 1 100%;min-width:0}
.layer-controls label > span{font-size:.8125rem;font-weight:600;line-height:1.3;color:var(--ink-2)}
.layer-controls select{width:100%}
.layer-controls > .button-row{flex-wrap:nowrap;gap:.25rem}
#layerUp svg{transform:rotate(-90deg)}
#layerDown svg{transform:rotate(90deg)}
.ax .layer-controls .danger-action{margin-inline-start:auto;padding:0 .625rem;border-color:transparent;background:transparent;color:var(--ink-2);font-size:.875rem}
.ax .layer-controls .danger-action svg{color:var(--alert)}
.ax .layer-controls .danger-action:focus-visible{color:var(--alert)}
@media (hover:hover) and (pointer:fine){
  .ax .layer-controls .danger-action:hover:not(:disabled){color:var(--alert);background:color-mix(in oklab,var(--alert) 9%,transparent)}
}

/* The list is a sample tray: each row carries its state swatch, and the layer the next stroke writes to carries the
   signal bar and the presenter's target chip. Custom names wrap in full; chips never break, and in a narrow inspector
   the chips and row actions move under the name as a group. */
.area-list{
  display:grid;grid-template-columns:minmax(0,1fr);gap:.125rem;min-width:0;
  max-height:min(24rem,46svh);overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;
  padding:.25rem;border:1px solid var(--rule-2);border-radius:var(--r);background:var(--field);
}
.area-list:not(:has(.area-row,.pending-layer)){padding:1rem .875rem;border-style:dashed;background:transparent;color:var(--ink-3);font-size:.875rem;text-align:center}
.area-list > :is(h3,h4,p){padding:.5rem .5rem .125rem;font-size:.75rem;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--ink-3)}
.area-row{
  position:relative;display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:0 .125rem;min-width:0;
  min-height:calc(var(--hit) + .25rem);padding-inline-end:.125rem;border-radius:calc(var(--r) - 1px);transition:background-color 140ms ease;
}
.area-row > button:first-child{
  flex:1 1 8rem;justify-content:flex-start;gap:.625rem;min-width:0;padding:.375rem .5rem;
  border-color:transparent;background:transparent;color:var(--ink);font-weight:550;text-align:start;
}
.area-row > button:first-child::before{content:"";flex:none;width:.75rem;height:.75rem;border-radius:2px;background:var(--area-color,var(--ink-3));box-shadow:inset 0 0 0 1px rgb(0 0 0/.18)}
.area-row > button:first-child > span{min-width:0;overflow-wrap:anywhere}
.area-row > :not(:first-child){order:2}
.area-row > .mini{flex:none;width:var(--hit);min-width:var(--hit);padding:0;border-color:transparent;background:transparent;color:var(--ink-3)}
.area-row > small{order:1;flex:none;padding:.125rem .375rem;border:1px solid color-mix(in oklab,var(--warn) 55%,transparent);border-radius:2px;color:var(--warn);font-size:.75rem;font-weight:600;line-height:1.2;white-space:nowrap}
.area-row:is(.selected,.active,[aria-selected=true],[aria-current=true],:has(> button:first-child:is([aria-pressed=true],[aria-current=true],.active))){background:var(--plate-2);box-shadow:inset 0 0 0 1px var(--ink-3)}
.area-row[data-ax-target]{background:color-mix(in oklab,var(--signal) 12%,var(--field));box-shadow:inset 3px 0 0 var(--signal-ink)}
.area-row[data-ax-target]:is(.selected,.active,[aria-selected=true],[aria-current=true],:has(> button:first-child:is([aria-pressed=true],[aria-current=true],.active))){box-shadow:inset 3px 0 0 var(--signal-ink),inset 0 0 0 1px var(--ink-3)}
.area-row[data-ax-target]::after{
  content:attr(data-ax-target);order:1;flex:none;margin-inline:.25rem .125rem;padding:.1875rem .4375rem;border-radius:2px;
  background:var(--signal);color:var(--on-signal);font-size:.75rem;font-weight:650;line-height:1.2;white-space:nowrap;
}
.pending-layer{
  display:flex;align-items:center;gap:.625rem;min-height:var(--hit);padding:.375rem .625rem;
  border:1px dashed var(--rule-2);border-radius:calc(var(--r) - 1px);color:var(--ink-2);font-size:.875rem;overflow-wrap:anywhere;
}
.pending-layer::before{content:"";flex:none;width:.75rem;height:.75rem;border:1.5px dashed var(--area-color,var(--ink-3));border-radius:2px}
@media (hover:hover) and (pointer:fine){
  .area-row:hover{background:var(--plate-2)}
  .area-row > .mini:hover:not(:disabled){background:color-mix(in oklab,var(--ink) 8%,transparent);color:var(--ink)}
}

/* Selected area: it leads the panel as a ruled section, not a nested card. State and opacity share a line where the
   inspector has room, so the name, state and switches stay together at the top. */
.ax-props{display:grid;grid-template-columns:minmax(0,1fr);gap:.875rem .75rem;padding-bottom:1.125rem;border-bottom:1px solid var(--rule-2)}
@container inspector (min-width:20rem){
  .ax-props{grid-template-columns:repeat(2,minmax(0,1fr))}
  .ax-props > :not(.ax-half){grid-column:1/-1}
}
.ax-pair{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,9.5rem),1fr));gap:.5rem}
.ax .ax-apply{flex-wrap:nowrap}
.ax-apply > #applyArea{flex:1 1 auto}
@media (hover:hover) and (pointer:fine){#deleteArea:hover:not(:disabled){background:color-mix(in oklab,var(--alert) 10%,var(--plate))}}
.ax-source{font-size:.8125rem;line-height:1.4;color:var(--ink-3);overflow-wrap:anywhere}
.ax-source:empty{display:none}
.ax .ax-import{gap:.5rem}

/* Disclosures: a ruled line with a turning chevron. */
.ax-more{border-top:1px solid var(--rule)}
.ax-more > summary{
  display:flex;align-items:center;justify-content:space-between;gap:.75rem;min-height:var(--hit);padding-block:.25rem;
  list-style:none;cursor:pointer;font-size:.9375rem;font-weight:600;color:var(--ink-2);
}
.ax-more > summary::-webkit-details-marker{display:none}
.ax-more > summary::after{
  content:"";flex:none;width:.4375rem;height:.4375rem;margin-inline-end:.375rem;
  border-inline-end:1.5px solid currentColor;border-bottom:1.5px solid currentColor;
  transform:translateY(-.125rem) rotate(45deg);transition:transform 200ms var(--ease-out);
}
.ax-more[open] > summary{color:var(--ink)}
.ax-more[open] > summary::after{transform:translateY(.125rem) rotate(-135deg)}
.ax-more > :not(summary){margin-top:.75rem}
.ax-more[open]{padding-bottom:.25rem}
@media (hover:hover) and (pointer:fine){.ax-more > summary:hover{color:var(--ink)}}

/* ---------- navigation panel ---------- */
.ax-note{padding-inline-start:.75rem;border-inline-start:2px solid var(--rule-2);font-size:.875rem;line-height:1.5;color:var(--ink-2)}
.ax-grid2{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,9rem),1fr));gap:.875rem .75rem;align-items:end}
.ax-wide{width:100%}
.ax-issues{display:grid;gap:.375rem;font-size:.875rem;line-height:1.45;color:var(--ink-2);overflow-wrap:anywhere}
.ax-issues:empty{display:none}
.ax-issues :is(ul,ol){display:grid;gap:.375rem;margin:0;padding:0;list-style:none}
.ax-issues > :not(ul,ol),.ax-issues li{
  padding:.5rem .625rem;border-inline-start:3px solid var(--warn);border-radius:0 var(--r) var(--r) 0;
  background:color-mix(in oklab,var(--warn) 8%,var(--field));color:var(--ink);
}
.ax-issues :is(.error,.blocking,[data-level=error]){border-inline-start-color:var(--alert);background:color-mix(in oklab,var(--alert) 8%,var(--field))}
.ax-issues :is(.ok,.valid,.success){border-inline-start-color:var(--ok);background:color-mix(in oklab,var(--ok) 8%,var(--field))}
.ax-out{
  display:flex;align-items:center;justify-content:space-between;gap:.75rem;min-height:var(--hit);padding:.5rem .75rem .5rem 1rem;
  border:1px solid var(--rule-2);border-radius:var(--r);background:var(--field);font-weight:600;text-decoration:none;
  transition:border-color 140ms ease,background-color 140ms ease;
}
.ax-out > svg{transition:transform 160ms var(--ease-out)}
.ax-out[aria-disabled=true]{opacity:.5}
@media (hover:hover) and (pointer:fine){
  .ax-out:hover{border-color:var(--ink-3);background:var(--plate-2)}
  .ax-out:hover > svg{transform:translateX(2px)}
}

/* ---------- versions panel ---------- */
.ax-versions{display:grid;min-width:0}
.ax-versions:not(:has(> *)):not(:empty){padding:1rem .875rem;border:1px dashed var(--rule-2);border-radius:var(--r);color:var(--ink-3);font-size:.875rem;text-align:center}
.ax-versions > *{display:flex;flex-wrap:wrap;align-items:center;gap:.25rem .75rem;min-width:0;padding:.75rem .125rem;border-bottom:1px solid var(--rule);overflow-wrap:anywhere}
.ax-versions > * > :first-child{flex:1 1 10rem;min-width:0}
.ax-versions :is(small,time){font-size:.8125rem;color:var(--ink-3)}
.ax-export{display:grid;gap:.625rem;padding-top:1rem;border-top:1px solid var(--rule-2)}
.ax-export h3{font:600 .9375rem/1.3 var(--f-display)}
.ax-export-row{display:flex;flex-wrap:wrap;gap:.375rem}
.ax-export-row > select{flex:1 1 8rem}

/* ---------- dialogs (including the controller's #newLayerDialog) ---------- */
.ax dialog{
  width:min(30rem,calc(100vw - 2rem));max-width:none;max-height:calc(100dvh - 2rem);margin:auto;padding:0;
  overflow:auto;overscroll-behavior:contain;
  border:1px solid var(--rule-2);border-radius:8px;background:var(--plate);color:var(--ink);
  box-shadow:inset 0 3px 0 var(--signal),var(--shadow);
}
.ax dialog[open]{animation:ax-rise 220ms var(--ease-out)}
.ax dialog::backdrop{background:rgb(13 14 13/.45);animation:ax-fade 200ms ease-out}
.ax dialog > form{display:grid;gap:.875rem;padding:1.375rem 1.25rem 1.125rem}
.ax dialog :is(h2,h3){font:600 1.125rem/1.3 var(--f-display)}
.ax dialog label:not(.ax-check){display:grid;gap:.3125rem;min-width:0}
.ax dialog label:not(.ax-check) > span{font-size:.8125rem;font-weight:600;line-height:1.3;color:var(--ink-2)}
.ax dialog :is(select,textarea),.ax dialog input:not([type=checkbox],[type=radio],[type=range],[type=file]){width:100%}
.ax dialog p[role=alert]{font-size:.875rem;font-weight:600;color:var(--alert)}
.ax dialog p[role=alert]:empty{display:none}
.ax dialog .button-row{justify-content:flex-end;gap:.5rem;margin-top:.25rem;padding-top:.875rem;border-top:1px solid var(--rule)}
.ax dialog .button-row > button{min-width:6.5rem}

/* ---------- phone and narrow tablet: one scrolling column; the document actions dock at the bottom ---------- */
@media (max-width:47.5rem),(max-width:55.9375rem) and (min-height:35.0625rem){
  .ax{
    --ax-dock:calc(var(--hit) + 1rem + 1px);
    display:block;height:auto;min-height:100dvh;padding-bottom:calc(var(--ax-dock) + env(safe-area-inset-bottom));
  }
  :root:not([data-lab-host]) .ax-bar,:root[data-lab-host] .ax-bar{
    grid-template-columns:auto minmax(0,1fr) auto auto;
    grid-template-areas:"home title prefs panel" "context context context context" "flow flow flow flow";
    gap:.5rem;padding:max(.5rem,env(safe-area-inset-top)) max(.75rem,env(safe-area-inset-right)) .5rem max(.75rem,env(safe-area-inset-left));
  }
  .ax-context{display:grid;grid-template-columns:minmax(0,1fr);gap:.5rem}
  .ax-pick{max-width:none}
  .ax .ax-bar > .workspace-flow{padding-top:.5rem;border-top:1px solid var(--rule)}
  .ax-classic{width:var(--hit);padding:0}
  .ax-classic > span{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
  .ax-doc{
    position:fixed;inset-inline:0;bottom:0;z-index:30;grid-area:auto;justify-self:auto;justify-content:flex-end;
    padding:.5rem max(.75rem,env(safe-area-inset-right)) calc(.5rem + env(safe-area-inset-bottom)) max(.75rem,env(safe-area-inset-left));
    background:var(--plate);border-top:1px solid var(--rule-2);box-shadow:0 -.5rem 1.5rem rgb(18 20 18/.07);
  }
  .ax-save{flex:1 1 auto;max-width:none}
  #editorPublish{flex:none}

  .ax > .ax-desk{display:block}
  #editorResize{display:none}
  .ax-stage{grid-template-columns:minmax(0,1fr);grid-template-rows:none;grid-template-areas:"plate" "rail" "paint" "brush" "probe"}
  .ax-strip{display:contents}

  /* Plate head in two lines: the write head, then the way back and the view. "Dim areas" keeps its name for
     assistive technology and as a tooltip. */
  .ax-plate{grid-template-rows:auto clamp(16rem,56svh,34rem)}
  .ax-plate-head{padding-inline:max(.5rem,env(safe-area-inset-left)) max(.375rem,env(safe-area-inset-right))}
  .ax-readout{flex-basis:100%}
  .ax-view{flex:1 0 auto}
  .ax-zoom{margin-inline-start:auto}
  #axFaint{width:var(--hit);padding:0}
  #axFaint > span{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

  /* The rail becomes a tool bar under the map; the signal tick moves to the bottom edge. */
  .ax-rail{
    flex-direction:row;justify-content:center;gap:0;overflow:visible;
    padding:.25rem max(.375rem,env(safe-area-inset-right)) .25rem max(.375rem,env(safe-area-inset-left));
    border-inline-end:0;border-bottom:1px solid var(--rule-2);
  }
  .ax-rail > button{flex:1 1 0;width:auto;max-width:3.5rem}
  .ax-rail > button::before{inset-block:auto 3px;inset-inline:.625rem;width:auto;height:3px;transform:scaleX(0)}
  .ax-rail > button.active::before{transform:scaleX(1)}
  .ax-rail > hr{width:1px;height:1.5rem;margin:0 .1875rem}

  .ax-paint,.ax-brush{padding:.625rem max(.75rem,env(safe-area-inset-right)) 0 max(.75rem,env(safe-area-inset-left))}
  .ax-paint{flex-wrap:wrap;gap:.375rem .625rem}
  .ax-states{flex:1 1 17rem}
  .ax-states > button{flex:1 1 0;min-width:0;padding:0 .5rem;font-size:.875rem}

  .ax-probe{margin-top:.75rem;padding:.625rem max(.75rem,env(safe-area-inset-right)) .75rem max(.75rem,env(safe-area-inset-left));border-block:1px solid var(--rule)}
  .ax-ends{flex:1 1 15rem}
  .ax-ends > button{flex:1 1 0}

  .ax-inspector{display:block;margin-top:.75rem;border-top:1px solid var(--rule-2)}
  .ax-tabs{position:sticky;top:0;z-index:3}
  .ax-panel{overflow:visible;padding-inline:max(1rem,env(safe-area-inset-left)) max(1rem,env(safe-area-inset-right))}
  .area-list{max-height:none;overflow:visible}

  .ax-status{position:sticky;bottom:calc(var(--ax-dock) + env(safe-area-inset-bottom));z-index:25;min-height:1.5rem;padding-bottom:.25rem}
}
@media (min-width:36rem) and (max-width:55.9375rem) and (min-height:35.0625rem){
  .ax-context{grid-template-columns:repeat(2,minmax(0,1fr))}
}
/* Phone: the base map and access project fold into one row naming both; the toggle opens the full pickers. */
@media (max-width:35.9375rem){
  .ax .ax-ctx{display:flex}
  .ax-context:not([data-ax-open]) > .ax-pick{display:none}
  .ax-context[data-ax-open] > .ax-pick{animation:ax-rise 200ms var(--ease-out)}

  /* The presenter measures this document's controls, not the surrounding host a second time. */
  :root:not([data-ax-large-text]) .ax-plate{position:relative;grid-template-rows:clamp(16rem,var(--ax-phone-map-h,56svh),34rem) auto}
  :root:not([data-ax-large-text]) #editorViewport{grid-row:1}
  :root:not([data-ax-large-text]) .ax-plate-head{grid-row:2}
  :root:not([data-ax-large-text]) .ax-readout{
    position:absolute;inset-block-start:.5rem;inset-inline-start:max(.5rem,env(safe-area-inset-left));z-index:2;
    max-inline-size:min(100% - 1rem,24rem);padding:.25rem .75rem .25rem .25rem;border-radius:calc(var(--r) + .25rem);
    background:color-mix(in oklab,var(--slab) 92%,transparent);box-shadow:0 .25rem .75rem rgb(18 20 18/.18);pointer-events:none;
  }
  :root:not([data-ax-large-text]) .ax-pulse{inset-inline-start:.25rem}
  :root:not([data-ax-large-text]) .ax-glyph,:root:not([data-ax-large-text]) #activeTool{flex:none;white-space:nowrap}
  :root:not([data-ax-large-text]) #activeLayer{position:relative;display:block;flex:1 1 auto;padding-inline-start:1.1875rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  :root:not([data-ax-large-text]) #activeLayer::before{position:absolute;inset-inline-start:0;top:50%;transform:translateY(-50%)}
}

/* ---------- short screens: what a stroke writes stands in a column beside the map ----------
   On a wide screen under 50rem tall, and in short landscape, a band above the map costs the map too much height. The
   paint state and the brush move into a column at the map's right that scrolls on its own, and the write head runs
   across both, so the map takes the height the band held. */
@media (min-width:75rem) and (min-height:35.0625rem) and (max-height:50rem),(orientation:landscape) and (max-height:35rem) and (min-width:47.5625rem){
  .ax-stage{
    grid-template-columns:auto minmax(0,1fr) minmax(12.5rem,14.5rem);grid-template-rows:auto minmax(0,1fr) auto;
    grid-template-areas:"rail head head" "rail map strip" "rail probe probe";
  }
  .ax-plate{display:contents}
  .ax-plate-head{grid-area:head}
  #editorViewport{grid-area:map}
  .ax-strip{
    flex-direction:column;flex-wrap:nowrap;align-items:stretch;gap:0;min-height:0;padding:0;
    overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;border-bottom:0;border-inline-start:1px solid var(--rule);
  }
  .ax-paint{flex-direction:column;align-items:stretch;gap:.25rem;padding:.5rem .625rem .625rem}
  .ax-states{flex-direction:column}
  .ax-states > button{justify-content:flex-start}
  .ax-brush{display:grid;grid-template-columns:minmax(0,1fr);gap:.375rem;padding:.625rem .625rem .75rem;border-top:1px solid var(--rule)}
  .ax-num{justify-content:space-between}
  #brushShape{width:100%}
  .ax-brush > .ax-check{display:flex}
}

/* ---------- short landscape: the header scrolls away, after which the stage fills the screen exactly ----------
   Nothing scrolls past the stage, so the write head, the tool rail and the route check stay in view together. The
   inspector is a drawer bounded to the stage with a solid edge, scrolling on its own. The panel toggle floats at the
   top-right; the header, the plate head and the drawer tabs leave its corner free. */
@media (orientation:landscape) and (max-height:35rem) and (min-width:47.5625rem){
  .ax{display:block;height:auto;min-height:100dvh;--ax-desk-h:calc(100svh - 1.75rem - env(safe-area-inset-bottom,0px));--ax-drawer:min(22rem,50vw)}
  .ax .ax-bar{
    gap:.25rem .625rem;
    padding:max(.25rem,env(safe-area-inset-top)) calc(var(--hit) + .5rem + max(.5rem,env(safe-area-inset-right))) .375rem max(.75rem,env(safe-area-inset-left));
  }
  .ax-cap{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
  .ax-save{max-width:8rem}
  #panelToggle{position:fixed;top:max(.25rem,env(safe-area-inset-top));inset-inline-end:max(.5rem,env(safe-area-inset-right));z-index:1;box-shadow:0 .25rem .75rem rgb(18 20 18/.16)}

  .ax > .ax-desk{display:block;position:relative;height:var(--ax-desk-h)}
  #editorResize{display:none}
  .ax-stage{height:100%;padding-inline:env(safe-area-inset-left,0px) env(safe-area-inset-right,0px)}
  .ax-plate-head{flex-wrap:nowrap;padding-inline-end:calc(var(--hit) + 1rem)}
  .ax-readout{flex:1 1 auto}
  #axFaint{width:var(--hit);padding:0}
  #axFaint > span{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

  /* Left: the modes in pairs. */
  .ax-rail{display:grid;grid-template-columns:repeat(2,var(--hit));align-content:start;justify-content:center;gap:.25rem;padding:.375rem}
  .ax-rail > hr{display:none}

  .ax-inspector{
    position:absolute;inset-block:0;inset-inline-end:env(safe-area-inset-right,0px);z-index:15;width:var(--ax-drawer);
    border-inline-start:2px solid var(--ink-3);box-shadow:var(--shadow);
    transition:opacity 200ms var(--ease-out),translate 260ms var(--ease-out);
    transition:opacity 200ms var(--ease-out),translate 260ms var(--ease-out),display 260ms allow-discrete;
  }
  .ax.panel-closed .ax-inspector{opacity:0;translate:1.5rem 0}
  @starting-style{.ax:not(.panel-closed) .ax-inspector{opacity:0;translate:1.5rem 0}}
  .ax-tabs{padding-inline-end:calc(var(--hit) + .75rem)}

  /* Drawer open: the stage keeps only the width left of the drawer and scrolls on its own. The write head wraps whole
     controls onto a second line; what a stroke writes and the route check follow the map as wrapping rows; the modes
     stay pinned beside whatever is in view. */
  .ax:not(.panel-closed) .ax-stage{
    margin-inline-end:calc(var(--ax-drawer) + env(safe-area-inset-right,0px));padding-inline-end:0;
    grid-template-columns:auto minmax(0,1fr);grid-template-rows:auto minmax(min(14rem,55svh),1fr) auto auto;
    grid-template-areas:"rail head" "rail map" "rail strip" "rail probe";
    overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;
  }
  .ax:not(.panel-closed) .ax-rail{position:sticky;top:0;align-self:start;min-height:var(--ax-desk-h)}
  .ax:not(.panel-closed) .ax-plate-head{flex-wrap:wrap;padding-inline-end:.375rem}
  .ax:not(.panel-closed) .ax-readout{flex-basis:100%}
  .ax:not(.panel-closed) .ax-strip{
    flex-direction:row;flex-wrap:wrap;align-items:center;gap:.5rem 1.25rem;padding:.5rem .75rem;
    overflow:visible;border-inline-start:0;border-top:1px solid var(--rule);
  }
  .ax:not(.panel-closed) .ax-paint{flex-direction:row;flex-wrap:wrap;align-items:center;gap:.375rem .625rem;padding:0}
  .ax:not(.panel-closed) .ax-states{flex-direction:row;flex-wrap:wrap}
  .ax:not(.panel-closed) .ax-brush{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;padding:0;border-top:0}
  .ax:not(.panel-closed) #brushShape{width:auto}
  .ax:not(.panel-closed) .ax-ends{flex-wrap:wrap;max-width:100%}

  .ax-status{position:sticky;bottom:0;z-index:16}
}

/* ---------- enlarged text (root above 20px): natural document flow, one column, nothing fixed ---------- */
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax){display:block;height:auto;min-height:100dvh;padding-bottom:0}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-bar{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:flex-end;padding-inline-end:max(1rem,env(safe-area-inset-right))}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-context{flex:1 1 100%;display:grid;grid-template-columns:minmax(0,1fr)}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-pick{max-width:none}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-cap{position:static;width:auto;height:auto;overflow:visible;clip-path:none;white-space:normal}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-doc{position:static;flex:1 1 auto;flex-wrap:wrap;padding:0;border:0;background:none;box-shadow:none}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-save{max-width:none}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-prefs{flex-wrap:wrap;min-width:0;max-width:100%}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-bar > .workspace-flow{flex:1 1 100%;order:1}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) #panelToggle{position:static;box-shadow:none}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) > .ax-desk{display:block;height:auto}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) #editorResize{display:none}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-stage{
  height:auto;grid-template-columns:minmax(0,1fr);grid-template-rows:none;grid-template-areas:"plate" "rail" "paint" "brush" "probe";padding-inline:0;
  margin-inline-end:0;overflow:visible;
}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-strip{display:contents}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-plate{display:grid;height:auto;grid-template-rows:auto min(70svh,40rem)}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-plate-head{grid-area:auto;flex-wrap:wrap;padding-inline-end:.375rem}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-readout{flex:1 1 100%}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-view{flex:1 1 auto;min-width:0;max-width:100%}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) #editorViewport{grid-area:auto}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) #axFaint{width:auto;padding:0 .75rem 0 .625rem}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) #axFaint > span{position:static;width:auto;height:auto;overflow:visible;clip-path:none}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-rail{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;gap:.25rem;padding:.375rem 1rem;border-inline-end:0;border-bottom:1px solid var(--rule);position:static;align-self:auto;min-height:0}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-rail > button{flex:none;width:var(--hit);max-width:none}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-rail > button::before{inset-block:auto 3px;inset-inline:.625rem;width:auto;height:3px;transform:scaleX(0)}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-rail > button.active::before{transform:scaleX(1)}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-rail > hr{display:block;width:1px;height:1.5rem;margin:0 .25rem;align-self:center}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) :is(.ax-paint,.ax-brush){
  display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;gap:.5rem;margin:0;padding:.625rem 1rem 0;border:0;background:none;
}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-paint > .ax-k{min-height:0;padding:0}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-states{flex-direction:row;flex-wrap:wrap}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-probe{margin-top:.75rem;padding-inline:1rem}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-ends{flex-wrap:wrap;min-width:0;max-width:100%}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-ends > button{flex:1 1 auto}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-inspector{position:static;display:block;width:auto;height:auto;margin-top:.75rem;border-inline-start:0;border-top:1px solid var(--rule-2);box-shadow:none}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-tabs{position:sticky;top:0;z-index:3;padding-inline-end:0}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-panel{overflow:visible}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .area-list{max-height:none;overflow:visible}
:is(.ax[data-ax-large-text],[data-ax-large-text] .ax) .ax-status{position:static}

/* ---------- reduced motion: keep fades and state changes, drop travel and scaling ---------- */
@media (prefers-reduced-motion:reduce){
  .ax[data-ax] .ax-pulse{animation:none}
  .ax-veil > i::before,.ax-veil > i::after{animation:ax-breathe 1.2s ease-in-out infinite alternate;transform:scale(.72)}
  .ax-veil > i::after{animation-delay:-.6s;transform:scale(1)}
  .ax-save[data-ax=saving]::before{animation:ax-breathe 700ms ease-in-out infinite alternate}
  .ax-save[data-ax=saving]::after{animation:none}
  .selection-menu,#suggestionControls,.ax dialog[open],.ax .ax-cmds > #finishPolygon{animation-name:ax-fade}
  .ax-rail > button::before,.ax-tabs > button::after{transform:none!important;opacity:0;transition:opacity 150ms ease}
  .ax-rail > button.active::before,.ax-tabs > :is([aria-selected=true],.active)::after{opacity:1}
  .ax-states > button.active .ax-key{transform:none}
  .ax-more > summary::after,.ax-ctx::after{transition:none}
  .ax-context[data-ax-open] > .ax-pick{animation-name:ax-fade}
  .ax :is(.ax-btn,.ax-ib,.icon-only,.ax-rail > button,.ax-states > button,.ax-ends > button):active{transform:none}
  #editorResize::before{transform:none!important}
  .ax-out > svg{transform:none!important}
  .ax .ax-inspector{translate:none!important}
}
:where(:root[data-motion=reduced]) .ax[data-ax] .ax-pulse{animation:none}
:where(:root[data-motion=reduced]) .ax-veil > i::before,:where(:root[data-motion=reduced]) .ax-veil > i::after{animation:ax-breathe 1.2s ease-in-out infinite alternate;transform:scale(.72)}
:where(:root[data-motion=reduced]) .ax-veil > i::after{animation-delay:-.6s;transform:scale(1)}
:where(:root[data-motion=reduced]) .ax-save[data-ax=saving]::before{animation:ax-breathe 700ms ease-in-out infinite alternate}
:where(:root[data-motion=reduced]) .ax-save[data-ax=saving]::after{animation:none}
:where(:root[data-motion=reduced]) :is(.selection-menu,#suggestionControls){animation-name:ax-fade}
:where(:root[data-motion=reduced]) .ax dialog[open],:where(:root[data-motion=reduced]) .ax .ax-cmds > #finishPolygon{animation-name:ax-fade}
:where(:root[data-motion=reduced]) .ax-rail > button::before,:where(:root[data-motion=reduced]) .ax-tabs > button::after{transform:none!important;opacity:0;transition:opacity 150ms ease}
:where(:root[data-motion=reduced]) .ax-rail > button.active::before,:where(:root[data-motion=reduced]) .ax-tabs > :is([aria-selected=true],.active)::after{opacity:1}
:where(:root[data-motion=reduced]) .ax-states > button.active .ax-key{transform:none}
:where(:root[data-motion=reduced]) .ax-more > summary::after,:where(:root[data-motion=reduced]) .ax-ctx::after{transition:none}
:where(:root[data-motion=reduced]) .ax-context[data-ax-open] > .ax-pick{animation-name:ax-fade}
:where(:root[data-motion=reduced]) .ax :is(.ax-btn,.ax-ib,.icon-only,.ax-rail > button,.ax-states > button,.ax-ends > button):active{transform:none}
:where(:root[data-motion=reduced]) #editorResize::before,:where(:root[data-motion=reduced]) .ax-out > svg{transform:none!important}
:where(:root[data-motion=reduced]) .ax .ax-inspector{translate:none!important}

/* A hidden page holds its looping indicators. */
[data-ax-hidden] .ax-veil > i::before,[data-ax-hidden] .ax-veil > i::after,
[data-ax-hidden] .ax-save::before,[data-ax-hidden] .ax-save::after,
[data-ax-hidden] #routePreviewResult::before{animation-play-state:paused}

/* ---------- forced colours: selection is outlined, swatches keep their state colours ---------- */
@media (forced-colors:active){
  .ax-rail > button.active,.ax-ends > button.active,.ax-states > button.active,.ax-tabs > :is([aria-selected=true],.active),
  .ax-toggle[aria-pressed=true],#panelToggle[aria-expanded=true],.area-row[data-ax-target]{outline:2px solid Highlight;outline-offset:-2px}
  .ax-key,#activeLayer::before,.area-row > button:first-child::before,.selection-menu > [data-fill-state]::before{forced-color-adjust:none}
  .ax-tabs > button::after,#editorResize::before{background:CanvasText}
}
