/* The house style on the lab's markup.
   Linked by index.html and glitchcut/index.html so the two pages cannot
   drift: the mode bar already taught that lesson. The system is
   /Users/jm/dev/house-style/DESIGN.md, vendored beside this as house.css;
   everything here maps the lab's own classes onto those tokens. */

/* Selection and touch behavior, for both pages.
   Safari still needs the -webkit- prefix on user-select, and it starts a text
   selection from any mouse drag that the page does not claim: a slider drag,
   a double click on a label, a click on a tab. The whole page is chrome, so it
   is switched off once, here, and the few things worth copying are switched
   back on below. The callout and the tap flash are the touch equivalents: the
   long-press menu on a button and the gray box iOS paints on a tap. */
html{
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
/* Stays selectable: text fields ( the slider number, the paste field ), the
   error readout, and the body text of the "about" group ( its header is a
   button and stays chrome ). Inputs that are not text ( range, checkbox,
   radio, color, file, button ) stay out of the list, so nothing here can
   interfere with a drag on them. Safari also needs the explicit "text" on an
   input, because it will not type into a field under user-select: none. */
input:not([type="range"], [type="checkbox"], [type="radio"], [type="color"], [type="file"], [type="button"], [type="submit"]),
textarea, [contenteditable]:not([contenteditable="false"]),
#err, #about .gbody, #about .gbody *{
  -webkit-user-select: text; user-select: text;
  -webkit-touch-callout: default;
}

/* Panel chrome */
/* Near black, so the canvas is the only thing with color in it */
/* Much darker, still translucent: the canvas shows through as a shadow of
   itself, not as color. */
:root{ --panel: rgba(2,2,2,.90); }
#panel{ border-radius: var(--h-r-xl); border-left: 1px solid var(--h-line-ink); }

/* The toolbar reads as rows of wide keys, not a grid of squares. Glitchcut
   and textlab still draw theirs as this two-column grid; the lab's own row
   ( slice 5, below ) overrides it under body.lab. */
.presets{ gap: 4px; margin-bottom: 4px; grid-template-columns: repeat(2, 1fr); }
.presets button, .morekeys button{
  height: 44px; padding: 0 14px; border-radius: var(--h-r-full);
  background: #0F0F0F; color: var(--h-on-ink);
  justify-content: center; gap: 8px;
}
.presets button:hover, .morekeys button:hover{ background: #1A1A1A; }
.presets button:disabled, .morekeys button:disabled{ background: #0A0A0A; color: var(--h-on-ink-2); opacity: 1; }

button{
  font: 400 var(--h-t-sm)/1 var(--h-mono); letter-spacing: var(--h-mono-track);
  color: var(--h-on-ink); background: #0F0F0F;
  border: 1px solid transparent; border-radius: var(--h-r-full);
  height: 44px; padding: 0 14px;
}
button:hover{ background: #1A1A1A; }
button:disabled:hover{ background: #0A0A0A; }
#hidePanel{ width: 40px; height: 40px; border-radius: var(--h-r-md); }

.shaderrow select{ font: 400 var(--h-t-nav)/var(--h-lh-1) var(--h-mono); letter-spacing: var(--h-mono-track); color: var(--h-on-ink); }
#pasterow input{
  height: 48px; padding: 0 16px;
  background: #0D0D0D; border: 1px solid transparent;
  border-radius: var(--h-r-lg);
  font: 400 var(--h-t-sm) var(--h-mono); letter-spacing: var(--h-mono-track);
  color: var(--h-on-ink);
}
#pasterow input:hover{ background: #161616; }
#pasterow input:focus{ border-color: var(--h-blue); }

/* Section heads read as disclosure rows, each section keeping one bright */
/* Twelve sections, seven hues: the set cycles and a section keeps its own. */
.group{ --sec: var(--h-blue); }
.group:nth-of-type(7n+1){ --sec: var(--h-blue); }
.group:nth-of-type(7n+2){ --sec: var(--h-orange); }
.group:nth-of-type(7n+3){ --sec: var(--h-yellow); }
.group:nth-of-type(7n+4){ --sec: var(--h-green); }
.group:nth-of-type(7n+5){ --sec: var(--h-cyan); }
.group:nth-of-type(7n+6){ --sec: var(--h-violet); }
.group:nth-of-type(7n+7){ --sec: var(--h-pink); }
.ghead .gtoggle{
  /* Two steps under the house row title, at the small size. At step 1 in a
     56px bar the section names read loud. They now sit a hair under the
     parameter labels inside them; the chip, the weight and the tile carry the
     rank instead of the size. 44px matches the toolbar keys above. */
  height: 44px; gap: 12px;
  font: 500 var(--h-t-sm)/1 var(--h-sans);
  color: var(--h-on-ink); border-bottom: 1px solid var(--h-line-ink);
}
.group.open .gtoggle{ font-weight: 500; border-bottom-color: transparent; }
.ghead .gtoggle > span:first-child::before{
  content: ""; display: inline-block; vertical-align: 0;
  width: 12px; height: 12px; margin-right: 12px;
  border-radius: 4px; background: var(--sec);
}
.ghead .chev .ic{ stroke: var(--h-on-ink-2); }

/* The one filled action on the toolbar is blue, the house action color.
   The lab's clock is a plain key in More since slice 5, so these hold only
   where body is not .lab. */
body:not(.lab) #freeze, body:not(.lab) #freeze.on{ background: var(--h-blue); color: var(--h-ink); border-color: var(--h-blue); font-weight: 400; border-radius: var(--h-r-full); }
body:not(.lab) #freeze .ic, body:not(.lab) #freeze.on .ic{ stroke: var(--h-ink); }
body:not(.lab) #freeze:hover, body:not(.lab) #freeze.on:hover{ background: var(--h-blue); color: var(--h-ink); filter: brightness(.94); }
#savevid.on{ background: var(--h-danger); border-color: var(--h-danger); color: #FFFFFF; }
body:not(.lab) #saveimg, body:not(.lab) #savevid, body:not(.lab) #copylink, body:not(.lab) #copy{ color: var(--h-on-ink-2); }
body:not(.lab) #saveimg:hover, body:not(.lab) #savevid:hover, body:not(.lab) #copylink:hover, body:not(.lab) #copy:hover{ color: var(--h-on-ink); }


/* ══ House style layer ═══════════════════════════════════════════════
   /Users/jm/dev/house-style/DESIGN.md, vendored as house.css next to this
   file. The canvas stays full bleed; the panel becomes an ink tile of packed
   mono controls, and every slider is a filled channel with its label and
   number inside it. */
:root{
  --panel: rgba(32,32,32,.94);
  --line: var(--h-line-ink);
  --line-strong: #6C6C6C;
  --ink: var(--h-on-ink);
  --dim: var(--h-on-ink-2);
  --mono: var(--h-mono);
  --r-out: var(--h-r-xl);
  --r-box: var(--h-r-md);
  --pad: 12px;
}
body{ font-family: var(--h-sans); font-size: var(--h-t-sm); }

/* Sliders: the label and the number sit inside the channel
   The row is the channel: 44px tall, filled to the value, the label on its
   left and the number on its right. The handle is a 2px line standing on the
   value, held 10px inside either end, and the fill runs 10px past it. Dots
   mark the tenths. The label and the handle stay gray until the row is under
   the pointer or being dragged; the number stays white.
   paint() sets --p, the value as a fraction of its range, and the fill, the
   handle and the dots are all drawn from it. */
.ctl{
  --edge: 10px;
  --x: clamp(var(--edge), var(--p, 0) * 100%, 100% - var(--edge));
  display: flex; align-items: center;
  height: 44px; margin-bottom: 4px;
}
.rows{ padding-bottom: 0; }   /* the last row's 4px margin stands in for it */
.ctl .track{
  inset: 0; height: auto;
  border-radius: var(--h-r-md); background: #0D0D0D; overflow: hidden;
}
.ctl:hover .track{ background: #0D0D0D; }   /* the label and the handle carry the hover */
/* Twice the handle's offset until it reaches 10px past the handle, then the
   offset plus 10px. An empty slider shows no fill, and the fill grows from
   there without a jump. */
.ctl .fill{
  top: 0; bottom: 0; height: auto; min-width: 0;
  width: min(var(--p, 0) * 200%, var(--p, 0) * 100% + var(--edge));
  background: #242424; border-radius: var(--h-r-md);
}
.ctl .lab{
  position: static; transform: none; margin-left: 2px;
  flex: 0 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font: 400 var(--h-t-sm)/var(--h-lh--1) var(--h-sans); color: var(--h-on-ink-2);
  transition: color var(--h-dur-snap) var(--h-ease);
}
/* The lab's number is an input in the row; glitchcut's sits in .vu with its
   unit. Either way it is the last thing on the line. */
.ctl .val, .ctl .vu{ position: static; transform: none; flex: none; }
.ctl .vu, .ctl > .val{ margin-right: 2px; }
.ctl .val{ font: 400 var(--h-t-sm) var(--h-mono); letter-spacing: var(--h-mono-track); color: var(--h-on-ink); }
.ctl .val:focus{ color: var(--h-on-ink); background: rgba(0,0,0,.55); box-shadow: 0 0 0 3px rgba(0,0,0,.55); }

/* Lanes: the open stretches of the channel, one before the label, one
   between the label and the number, one after the number. The handle and the
   dots are laid out against the whole row and each lane shows only its own
   stretch, so neither is ever drawn over the text. */
.ctl .lane{
  align-self: stretch; flex: 1 1 0; min-width: 0; margin: 0 8px;
  z-index: 1; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6px, #000 calc(100% - 6px), transparent);
          mask-image: linear-gradient(90deg, transparent, #000 6px, #000 calc(100% - 6px), transparent);
}
/* 14px plus the 2px margin puts the text 16px in. The handle parked at 10px
   sits clear of the 3px fade and is gone before it reaches the text. */
.ctl .lead, .ctl .tail{ flex: 0 0 14px; margin: 0; }
.ctl .lead{
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 3px), transparent);
          mask-image: linear-gradient(90deg, #000 calc(100% - 3px), transparent);
}
.ctl .tail{
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 3px);
          mask-image: linear-gradient(90deg, transparent, #000 3px);
}
.ctl .lane::after{
  content: ""; position: absolute; top: 50%; left: var(--x);
  width: 2px; height: 18px; margin: -9px 0 0 -1px; border-radius: 1px;
  background: var(--h-on-ink-2); opacity: .5;
  transition: background-color var(--h-dur-snap) var(--h-ease), opacity var(--h-dur-snap) var(--h-ease);
}
.ctl:hover .lab, .ctl.dragging .lab{ color: var(--h-on-ink); }
.ctl:hover .lane::after, .ctl.dragging .lane::after{ background: var(--h-on-ink); opacity: 1; }
/* The dots, with a hole where the handle stands. The fades are wider than a
   dot, so a dot caught at an edge shows whole and fainter. */
.ctl .gap::before{
  content: ""; position: absolute; inset: 0; opacity: .5;
  background-image:
    radial-gradient(circle 1.5px at 10% 50%, var(--h-on-ink-2) 99%, transparent),
    radial-gradient(circle 1.5px at 20% 50%, var(--h-on-ink-2) 99%, transparent),
    radial-gradient(circle 1.5px at 30% 50%, var(--h-on-ink-2) 99%, transparent),
    radial-gradient(circle 1.5px at 40% 50%, var(--h-on-ink-2) 99%, transparent),
    radial-gradient(circle 1.5px at 50% 50%, var(--h-on-ink-2) 99%, transparent),
    radial-gradient(circle 1.5px at 60% 50%, var(--h-on-ink-2) 99%, transparent),
    radial-gradient(circle 1.5px at 70% 50%, var(--h-on-ink-2) 99%, transparent),
    radial-gradient(circle 1.5px at 80% 50%, var(--h-on-ink-2) 99%, transparent),
    radial-gradient(circle 1.5px at 90% 50%, var(--h-on-ink-2) 99%, transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 calc(var(--x) - 12px), transparent calc(var(--x) - 4px), transparent calc(var(--x) + 4px), #000 calc(var(--x) + 12px));
          mask-image: linear-gradient(90deg, #000 calc(var(--x) - 12px), transparent calc(var(--x) - 4px), transparent calc(var(--x) + 4px), #000 calc(var(--x) + 12px));
}


/* ── Look gallery ──────────────────────────────────────────────────
   A modal of thumbnails grouped by engine. The pictures are rendered by
   bin/thumbs.mjs into thumbs/ and are what you actually pick from. */
.gal{
  position:fixed; inset:0; z-index:90;
  display:flex; align-items:center; justify-content:center; padding:8px;
  background:rgba(0,0,0,.55); -webkit-backdrop-filter:blur(10px); backdrop-filter:blur(10px);
}
.gal[hidden]{display:none}
.gal-panel{
  width:min(1100px, 100%); max-height:92vh; display:flex; flex-direction:column;
  background:rgba(4,4,4,.97); border:1px solid #232323;
  border-radius:var(--h-r-xl); overflow:hidden;
}
.gal-head{
  display:flex; align-items:center; justify-content:space-between;
  height:56px; padding:0 16px; flex:none;
}
.gal-count{ font:400 var(--h-t-sm) var(--h-mono); letter-spacing:var(--h-mono-track); color:var(--h-on-ink-2); }
.gal-close{
  width:40px; height:40px; padding:0; border-radius:var(--h-r-md);
  background:#0F0F0F; color:var(--h-on-ink); border:0; font-size:14px;
}
.gal-body{ overflow-y:auto; padding:0 16px 16px; }
.gal-group{ margin-bottom:16px; }
.gal-group h3{
  margin:0 0 8px; display:flex; align-items:center; gap:12px;
  font:500 var(--h-t-row)/1 var(--h-sans); color:var(--h-on-ink);
}
.gal-group h3::before{
  content:""; width:12px; height:12px; border-radius:4px; background:var(--sec, var(--h-blue));
}
.gal-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:8px; }
.gal-tile{
  padding:0; border:0; background:none; cursor:pointer; text-align:left;
  display:flex; flex-direction:column; gap:6px; height:auto;
}
.gal-tile img{
  width:100%; aspect-ratio:8/5; object-fit:cover; display:block;
  border-radius:var(--h-r-lg); background:#000;
  outline:2px solid transparent; outline-offset:-2px;
}
.gal-tile span{
  font:400 var(--h-t-micro) var(--h-mono); letter-spacing:var(--h-mono-track);
  color:var(--h-on-ink-2); padding-left:2px;
}
.gal-tile:hover img{ outline-color:var(--h-on-ink-2); }
.gal-tile.on img{ outline-color:var(--h-blue); }
.gal-tile.on span{ color:var(--h-on-ink); }
.gal-foot{
  display:flex; justify-content:space-between; flex:none;
  height:48px; padding:0 16px; align-items:center;
  border-top:1px solid var(--h-line-ink);
  font:400 var(--h-t-micro) var(--h-mono); letter-spacing:var(--h-mono-track); color:var(--h-on-ink-2);
}
@media (max-width:520px){
  .gal-grid{ grid-template-columns:repeat(auto-fill, minmax(120px, 1fr)); }
  .gal-panel{ max-height:96vh; }
}


/* ── The panel ────────────────────────────────────────────────────────
   One name and one width for both pages: it is the panel everywhere, never
   the rail. It floats with a 10px margin off the top, right and bottom at
   every breakpoint, so the canvas runs behind it on all four sides. On a
   phone it is most of the screen, because the controls are what the hand is
   on and the canvas keeps rendering underneath. */
:root{
  --panel-w: 400px;
  --panel-w-phone: min(80vw, 460px);
  --panel-gap: 10px;
}
#panel{
  width: var(--panel-w);
  top: var(--panel-gap); right: var(--panel-gap); bottom: var(--panel-gap);
  border-radius: var(--h-r-xl);
}
body.panel-hidden #panel{ transform: translateX(calc(100% + var(--panel-gap) * 2)); }
@media (max-width: 900px){
  #panel{
    width: var(--panel-w-phone); max-width: none;
    transform: translateX(calc(100% + var(--panel-gap) * 2));
  }
  body.panel-open #panel{ transform: none; }
  body.scrubbing #panel{ transform: translateX(calc(100% + var(--panel-gap) * 2)) !important; }
}


/* ── Glitchcut's transport ────────────────────────────────────────────
   Only this page has it: the play key, the timecode, the ruler and the
   legend along the bottom of the canvas. Same parts as the panel, so it
   takes the same treatment. */
#bar{ background: rgba(2,2,2,.90); border-top: 1px solid var(--h-line-ink); }
#barPlay{
  width: 48px; height: 48px; margin: 0 8px;
  border-radius: var(--h-r-md);
  background: var(--h-blue); color: var(--h-ink); border: 0;
}
#barPlay:hover{ background: var(--h-blue); filter: brightness(.94); }
#clock{
  font: 400 var(--h-t-sm)/var(--h-lh--1) var(--h-mono);
  letter-spacing: var(--h-mono-track); color: var(--h-on-ink);
  font-variant-numeric: tabular-nums;
}
#clock span{ color: var(--h-on-ink-2); }
#legend{
  font: 400 var(--h-t-micro) var(--h-mono);
  letter-spacing: var(--h-mono-track); color: var(--h-on-ink-2);
}

/* ── Section heads stay put ───────────────────────────────────────────
   Scrolling a long panel used to leave you inside an unlabelled list of
   sliders. Each section head sticks to the top of the scroller while its
   own body is on screen and gets pushed off by the next one, so the name
   of what you are adjusting is always there. */
.group > .ghead{
  position: sticky; top: 0; z-index: 8;
  /* The head is dark, one step up from the tile, so a pinned head still
     reads as a header while the rows slide under it. The section's color
     lives in the chip at the front of the name and nowhere else: twelve
     tinted bands turned the panel into a color chart and buried the one
     thing the color is for, telling the sections apart. A solid fill, not a
     blur: twelve blurred sticky heads cost a composite every frame. No
     negative margins either: a head that reaches past the scroller's padding
     also reaches past the panel, where it swallowed taps meant for the
     canvas. */
  background: #121212;
  border-radius: var(--h-r-lg) var(--h-r-lg) 0 0;
}
.group:not(.open) > .ghead{ border-radius: var(--h-r-lg); }

/* ── Upload and media rows ────────────────────────────────────────────
   Both pages carry these: drop a file in, then say what to do with it.
   They were a stack of tall cards with a label above each; now they are
   house rows, 4 apart, with the formats and the control on the right. */
.gbody .sublab{
  font: 400 var(--h-t-micro) var(--h-mono);
  letter-spacing: var(--h-mono-track); color: var(--h-on-ink-2);
  margin: 0 0 4px; padding-left: 2px;
}
.gbody .sublab + .mlist:empty{ display: none; }
.addbtn{
  display: flex; align-items: center; gap: 12px;
  width: 100%; height: 56px; padding: 0 16px; margin-bottom: 4px;
  background: #131313; border: 1px solid transparent; border-radius: var(--h-r-lg);
  text-align: left;
}
.addbtn:hover{ background: #1A1A1A; border-color: var(--h-line-ink); }
.addbtn .addlab{
  font: 400 var(--h-t-sm)/var(--h-lh--1) var(--h-sans);
  color: var(--h-on-ink);
}
/* The formats sit under the action, left, and wrap like a sentence: on a
   phone panel six formats in the micro step do not fit one line, and a
   right-aligned list that wraps reads as two scraps. The row grows to hold
   them rather than letting the second line hit the edge. */
.gbody .addbtn{ height: auto; min-height: 56px; padding: 12px 16px; column-gap: 12px; row-gap: 4px; }
.addbtn .addfmt{
  margin-left: 0; text-align: left;
  font: 400 var(--h-t-micro) var(--h-mono);
  letter-spacing: var(--h-mono-track); color: var(--h-on-ink-2);
}
.selrow{ display: flex; align-items: center; gap: 8px; min-height: 48px; margin-bottom: 4px; }
.selrow .slab{
  flex: 0 0 88px;
  font: 400 var(--h-t-sm)/var(--h-lh--1) var(--h-sans);
  color: var(--h-on-ink-2);
}
.selrow select, .filerow select{
  height: 40px; padding: 0 32px 0 12px; border-radius: var(--h-r-md);
  background-color: #131313; border: 1px solid transparent;
  font: 400 var(--h-t-sm) var(--h-mono); letter-spacing: var(--h-mono-track);
  color: var(--h-on-ink);
}
.selrow select:hover, .filerow select:hover{ background-color: #1A1A1A; }
.filerow{ margin-bottom: 4px; }
.filerow select{ width: 100%; }

/* ── A section is one tile ────────────────────────────────────────────
   Open or closed, the group is a single dark container at radius 16 with
   its title inside it and 4px to the next one. The body used to be a
   lighter tray floating under a separate head, which read as two objects
   for one section. Contrast comes from the rows inside instead. */
.group{
  background: #050505;
  border-radius: var(--h-r-lg);
  margin-bottom: 4px;
  padding: 0;                 /* the head's wash reaches the tile edges */
}
.group > .ghead{
  /* Dark, a step up from the tile so a pinned head separates from the rows
     sliding under it. The color is carried by the chip in the name. */
  background: #121212;
  border-bottom: none;
  border-radius: var(--h-r-lg) var(--h-r-lg) 0 0;
  padding: 0 12px;
}
.group:not(.open) > .ghead{ border-radius: var(--h-r-lg); }
.group.open > .ghead{ border-bottom: none; }
.group.open .gbody{
  background: transparent;
  border-radius: 0;
  margin: 0;
  padding: 0 12px 8px;
}

/* No rule between sections: the 4px gap and the tile edge already separate
   them, and a hairline on top of that reads as a seam. */
.ghead .gtoggle{ border-bottom: none; }
.accordion, .accordion:first-child{ border-top: none; border-bottom: none; }

/* No scrollbar. It took 8px off the panel whenever it appeared, so the
   controls shifted as a section opened. The panel scrolls by drag and
   wheel; nothing needs the track. */
#panelscroll{ scrollbar-width: none; -ms-overflow-style: none; }
#panelscroll::-webkit-scrollbar{ width: 0; height: 0; display: none; }

/* The foot hide button is a key like the toolbar's: same pill, same fill,
   same height. It was the one square, lighter block on the panel. */
#hidePanelFoot{
  height: 44px; padding: 0 14px; border-radius: var(--h-r-full);
  background: #0F0F0F; color: var(--h-on-ink); border: 0;
}
#hidePanelFoot:hover{ background: #1A1A1A; }

/* The look picker is one button: tiles icon, the look's name, a caret. It
   opens the gallery, where every look is a picture. */
body:not(.lab) #randomLook{
  flex: none; width: 48px; height: 48px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--h-r-lg); background: #0F0F0F;
}
body:not(.lab) #randomLook:hover{ background: #1A1A1A; }
.shaderrow{ gap: 4px; }
#galleryBtn.selfield{
  flex: 1; min-width: 0; width: auto; height: 48px;
  display: flex; align-items: center; gap: 10px; padding: 0 14px 0 14px;
  background: #0D0D0D; border: 1px solid #262626; border-radius: var(--h-r-lg);
  color: var(--h-on-ink); text-align: left; cursor: pointer;
  font: 400 var(--h-t-sm)/1 var(--h-mono); letter-spacing: var(--h-mono-track);
}
#galleryBtn.selfield:hover{ background: #121212; border-color: #3A3A3A; }
#galleryBtn.selfield > svg:first-child{ flex: none; color: var(--h-on-ink-2); }
#lookLabel{ flex: 1; min-width: 0; display: flex; white-space: nowrap; }
#lookName{ min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#lookEdit{ flex: none; white-space: pre; color: var(--h-on-ink-2); }
#galleryBtn .selcaret{ flex: none; color: var(--h-on-ink-2); }

/* ── Polish, from the 14 Nov UI audit ─────────────────────────────────
   /Users/jamiemcniel/dev/shader-lab/tasks/ui-audit-2026-11-14.md, slice 1. */

/* Tap targets: 44px, the house minimum, on every key the hand reaches for. */
#panelToggle{ width: 44px; height: 44px; }
#hidePanel{ width: 44px; height: 44px; }
.gal-close{ width: 44px; height: 44px; }
.selrow select, .filerow select{ height: 44px; }
.cset > summary{ min-height: 44px; }
/* The lock and the die fill the head's height and sit side by side, 44 square
   each. They keep that size in a narrow panel too. Glitchcut and the lab
   both carry the pair. */
.ghead .gdice, .ghead .glock{
  top: 0; transform: none; width: 44px; height: 44px; border-radius: var(--h-r-md);
}
.ghead .gdice{ right: 24px; }
.ghead .glock{ right: 68px; }
/* Swatches: 44 tall, never narrower than 44. A row of eight wraps to a second
   row instead of shrinking each one to 28px. */
.swatches{ display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 6px; }
.sw .swbtn, .sw input[type=color]{ height: 44px; }
.sw span{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Rows that wrap split evenly, so a row of eight is four and four rather
   than seven and one. Six and seven only wrap on a phone-width panel. */
.swatches:has(> .sw:nth-child(8):last-child){ grid-template-columns: repeat(4, 1fr); }
@container (max-width: 360px){
  .swatches:has(> .sw:nth-child(6):last-child){ grid-template-columns: repeat(3, 1fr); }
  .swatches:has(> .sw:nth-child(7):last-child){ grid-template-columns: repeat(4, 1fr); }
}

/* The closed summary ends 4px short of the lock's box and is clipped there, so a
   long row of chips can no longer run back over the section name. It is one
   16px line that wraps into a hidden second one: whatever does not fit whole
   drops out of sight, so a chip is never cut in half at the edge. */
.ghead .gsum{
  padding: 0; margin-right: 78px; overflow: hidden;
  justify-content: flex-start; flex-wrap: wrap; align-content: flex-start;
  height: 16px; line-height: 16px; row-gap: 16px;
}
.ghead .gsum > *{ align-self: center; }
.ghead .gsum > :first-child{ margin-left: auto; }

/* The scroller's 12px top padding sat above a pinned head, and the rows
   scrolling under it showed through that slit. The head now pins to the
   scroller's edge. */
.group > .ghead{ top: calc(-1 * var(--pad)); }

/* 12px is the smallest text on the panel. */
.ghead .gsum, .sw span, #stats, .note, .fstate, .ctl .tip, .selrow .tip,
.cpop, .cset > summary, .ccustom, .ctl .val{ font-size: 12px; }
.ctl .val{ font-size: var(--h-t-sm); }
@container (max-width: 250px){ .ctl .val{ font-size: 12px; } }

/* "click a look" and "esc to close" are desktop words; a phone has neither. */
@media (max-width: 900px){ .gal-foot{ display: none; } }

/* ── Stage state, slice 3 of the 14 Nov UI audit ──────────────────────
   The dot after a stage's name: filled blue while the stage changes the
   picture, a gray ring while it does nothing. Shape and color both say it. */
.ghead .gon{
  flex: none; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%;
  box-sizing: border-box; border: 1.5px solid var(--h-on-ink-2); opacity: .7;
}
.ghead .gon.on{ background: var(--h-blue); border-color: var(--h-blue); opacity: 1; }
/* The dot stays beside the name when the section is open and its summary is
   gone; while the summary is there it takes the room and this margin is 0. */
.ghead .gon{ margin-right: auto; }
/* A head with no lock and die ( Ground ) gives its summary that room too. */
.ghead:not(:has(.glock)) .gsum{ margin-right: 0; }

/* ── Chrome, slice 5 of the 14 Nov UI audit ───────────────────────────
   One row of five keys: undo, redo, Randomize, Share, More. Randomize is the
   one filled key, blue, the house action color. More opens a tray in place
   under the row with the tool switch, the language, the clock, the exports,
   Any look, New palette and paste. */
body.lab .presets{ display: flex; gap: 4px; margin: 0 0 8px; }
body.lab .presets button{ flex: none; min-width: 44px; padding: 0 16px; }
.presets .key-icon{ width: 44px; padding: 0; }
.presets .key-rand{ flex: 1 1 auto; min-width: 0; background: var(--h-blue); color: var(--h-ink); border-color: var(--h-blue); }
.presets .key-rand .ic{ stroke: var(--h-ink); opacity: 1; }
.presets .key-rand:hover{ background: var(--h-blue); filter: brightness(.94); }
body.lab .presets button span{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#moreBtn.on{ background: #2A2A2A; }
/* A phone-width panel: Share drops its word and Randomize its die, so the
   five keys still fit one row at 44px. */
@container (max-width: 330px){
  .presets .key-share{ width: 44px; padding: 0; }
  .presets .key-share span{ display: none; }
  .presets .key-rand{ padding: 0 10px; }
  .presets .key-rand .ic{ display: none; }
}
#more{ background: #0A0A0A; border-radius: var(--h-r-lg); padding: 8px; margin: 0 0 8px; }
#more[hidden]{ display: none; }
#more .modebar{ height: auto; margin: 0 0 4px; }
.morekeys{ display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; margin: 0 0 4px; }
.morekeys button{ display: flex; align-items: center; justify-content: flex-start; gap: 6px; min-width: 0; padding: 0 10px 0 12px; }
.morekeys button span{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#more #pasterow{ margin: 0; }

/* ── Phone: a top bar and a bottom sheet, slice 6 of the 14 Nov audit ──
   Under 900px the look picker and the five keys float over the top of the
   canvas, and the panel is a sheet anchored to the bottom edge at one of
   three heights ( --sheet-h, set by setSheet() ): peek 96px, half 45% of
   the screen, full 90%. Only the grabber resizes it, so a swipe inside is
   always a scroll. Safe-area insets pad the bar under the notch and the
   sheet over the home indicator. The rules hang off body.phone, which only
   the lab's placeChrome() sets: glitchcut's page links this file too and
   keeps its own drawer. */
#labbar, #grabber{ display: none; }
body.phone #labbar{
  display: flex; align-items: center; gap: 4px;
  position: fixed; z-index: 36;
  top: calc(8px + env(safe-area-inset-top));
  left: calc(8px + env(safe-area-inset-left));
  right: calc(8px + env(safe-area-inset-right));
  transition: transform .28s cubic-bezier(.32,.72,0,1), opacity .2s;
}
body.phone #labbar .shaderrow{ flex: 1 1 auto; min-width: 0; margin: 0; }
body.phone #labbar #galleryBtn.selfield{ height: 44px; background: rgba(13,13,13,.92); }
body.phone #labbar #hidePanel{ display: none; }
body.phone #labbar .presets{ flex: none; margin: 0; }
body.phone #labbar .presets button{ background: rgba(15,15,15,.92); }
body.phone #labbar .presets #redo{ display: none; }
body.phone #labbar .presets .key-rand, body.phone #labbar .presets .key-share{ flex: none; width: 44px; padding: 0; background: var(--h-blue); }
body.phone #labbar .presets .key-share{ background: rgba(15,15,15,.92); }
body.phone #labbar .presets .key-rand span, body.phone #labbar .presets .key-share span{ display: none; }
body.phone #labbar .presets .key-rand .ic{ display: block; }
body.phone #labbar .presets #moreBtn.on{ background: #2A2A2A; }
/* More drops down under the bar as its own tile, over the canvas */
body.phone #labbar #more{
  position: absolute; top: 52px; left: 0; right: 0; margin: 0;
  max-height: calc(100dvh - 140px); overflow-y: auto; overscroll-behavior: contain;
  background: rgba(10,10,10,.97); border: 1px solid var(--h-line-ink);
}
body.phone #labbar #more .modebar{ height: 48px; }

body.phone #panel{
  top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-width: none;
  height: var(--sheet-h, 45vh);
  border-radius: var(--h-r-xl) var(--h-r-xl) 0 0;
  border-left: 0; border-top: 1px solid var(--h-line-ink);
  padding-bottom: env(safe-area-inset-bottom);
  transform: none;
  transition: height .4s cubic-bezier(.32,.72,0,1), transform .28s cubic-bezier(.32,.72,0,1), opacity .2s;
}
body.phone #panel.sheet-drag{ transition: none; }
body.phone #grabber{
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 100%; height: 44px; padding: 0; margin: 0;
  background: none; border: 0; border-radius: 0; cursor: grab;
  touch-action: none;
}
body.phone #grabber:hover{ background: none; }
body.phone #grabber i{ display: block; width: 40px; height: 5px; border-radius: var(--h-r-full); background: var(--h-on-ink-2); opacity: .7; }
body.phone #grabber:focus-visible{ outline: 2px solid var(--h-blue); outline-offset: -4px; }
body.phone #panelscroll{ padding-top: 0; }
body.phone .phone-only{ display: flex; }

/* put away: a double tap on the canvas, or the hide key at the foot */
body.phone #panelToggle{ display: none !important; }
body.phone.panel-hidden #panelToggle{ display: flex !important; top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); }
body.phone.panel-hidden #panel{ transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none; }
body.phone.panel-hidden #labbar{ transform: translateY(calc(-100% - 24px)); opacity: 0; pointer-events: none; }

/* a slider drag clears the whole screen: the sheet drops, the bar lifts, and
   the readout at the bottom left says what is moving */
body.phone.scrubbing #panel{ transform: translateY(100%) !important; opacity: 0; transition: transform .16s ease, opacity .12s; }
body.phone.scrubbing #labbar{ opacity: 0; pointer-events: none; transition: opacity .12s; }
body.phone.scrubbing #panelToggle{ display: none !important; }
body.phone #hud{ font-size: 17px; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); }
body:not(.phone) .phone-only{ display: none !important; }
/* the scroller has no top padding in the sheet, so a pinned head sits at 0 */
body.phone .group > .ghead{ top: 0; }
/* the stats line is desktop furniture: in the sheet its 37px go to the rows,
   and the readout a phone needs is the one over the canvas while dragging */
body.phone #foot{ display: none; }

/* ── Entry, slice 8 of the 14 Nov UI audit ────────────────────────────
   Typing a value on a phone, hints on a long press, seeds as a reroll key,
   and mesh's ramp as one gradient bar. */

/* A long press opens the hint and it stays until the next touch. */
.tipopen > .tip{ opacity: 1 !important; transition-delay: 0s !important; }
.rampbar .tip{ font-size: 12px; }

/* While the number has focus the row shows the range it takes, where the
   dots were. */
.ctl .rng{ display: none; }
.ctl.editing .gap{ display: none; }
.ctl.editing .rng{
  display: block; flex: 1 1 0; min-width: 0; margin: 0 8px; z-index: 1;
  text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font: 400 12px var(--h-mono); color: var(--h-on-ink-2); pointer-events: none;
}
/* On a phone the number takes no touch until it has focus: a tap or a hold on
   it lands on the row, which opens the keypad or the hint. Left as a field,
   a hold made iOS select the digits and start editing. */
body.phone .ctl:not(.editing) .val{
  pointer-events: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* The keypad bar: pinned to the bottom of the visual viewport while a number
   is typed on a phone ( placeTypeBar() sets top from it ). On iOS 26 that
   edge is the top of Safari's address pill and its up, down and Done row,
   which float over the page between the bar and the keys. The bar is opaque,
   and its skirt fills the page behind those two rows down past the keyboard,
   so no row of the panel shows through anywhere under the bar. */
#typebar{
  position: fixed; left: 0; right: 0; top: 0; z-index: 320;
  display: flex; align-items: center; gap: 8px; box-sizing: border-box;
  height: 52px; padding: 4px 8px 4px 16px;
  background: #0A0A0A; border-top: 1px solid var(--h-line-ink);
  font: 400 13px var(--h-mono); color: var(--h-on-ink);
}
#typebar::after{
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 480px;
  background: #0A0A0A; pointer-events: none;
}
#typebar[hidden]{ display: none; }
#typebar .tb-lab{ flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--h-sans); }
#typebar .tb-rng{ flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--h-on-ink-2); font-size: 12px; text-align: right; }
#typebar .tb-val{ flex: none; min-width: 44px; padding: 0 8px; line-height: 36px; border-radius: var(--h-r-md); background: #242424; text-align: right; font-size: 17px; }
#typebar .sign{
  flex: none; width: 44px; height: 44px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--h-r-md); background: #3A3A3A; font: 400 13px var(--h-mono);
}
#typebar .sign[hidden]{ display: none; }

/* A seed: the number in a field the size of a dropdown, and a 44px reroll key. */
.seedrow .seedval{
  flex: 1 1 auto; min-width: 0; height: 44px; box-sizing: border-box; margin: 0;
  padding: 0 10px; border: 0; border-radius: var(--h-r-md); outline: none;
  background: rgba(255,255,255,.12); color: var(--h-on-ink);
  font: 400 13px var(--h-mono); letter-spacing: var(--h-mono-track);
}
.seedrow .seedval:focus{ box-shadow: inset 0 0 0 1px var(--h-on-ink-2); }
.seedrow .reroll{
  flex: none; width: 44px; height: 44px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--h-r-md); background: rgba(255,255,255,.12);
}
.seedrow .reroll:hover{ background: rgba(255,255,255,.2); }
.seedrow .reroll .ic{ width: 18px; height: 18px; }
@container (max-width: 250px){
  .seedrow .seedval{ flex: 1 1 0; width: auto; }
  .seedrow .reroll{ flex: none; width: 44px; }
}

/* mesh's ramp: the gradient the eight stops make, 32px, with a handle under
   it for each stop. The bar is 64px tall and a handle answers 24px either side
   of its center, so every stop is a 48x64 target however small it draws. */
.rampbar{ position: relative; height: 64px; margin: 0 0 4px; touch-action: pan-y; cursor: pointer; }
.rampbar .rampgrad{
  position: absolute; left: 0; right: 0; top: 0; height: 32px;
  border-radius: var(--h-r-md); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.rampbar .ramptrack{ position: absolute; left: 12px; right: 12px; top: 0; bottom: 0; }
.ramptrack .rstop{
  position: absolute; top: 36px; left: calc(var(--p, 0) * 100%);
  width: 20px; height: 26px; margin: 0 0 0 -10px; padding: 0;
  border: 2px solid #050505; border-radius: 6px; background: var(--c, #000);
  box-shadow: 0 0 0 1px rgba(255,255,255,.35); pointer-events: none;
}
.ramptrack .rstop::before{
  content: ""; position: absolute; left: 50%; top: -8px; width: 2px; height: 6px; margin-left: -1px;
  background: rgba(255,255,255,.55);
}
.ramptrack .rstop.on{ box-shadow: 0 0 0 2px var(--h-on-ink); z-index: 2; }
.ramptrack .rstop.on::before{ background: var(--h-on-ink); }
.ramptrack .rstop:focus-visible{ outline: 2px solid var(--h-blue); outline-offset: 3px; }
.ramptrack input[type=color]{
  position: absolute; left: 0; top: 36px; width: 1px; height: 1px; margin: 0; padding: 0; border: 0;
  opacity: 0; pointer-events: none;
}
.ramp > .rows{ padding: 0; }

/* iOS Safari's floating address bar sits over the bottom of the page, and
   the sheet runs under it: the last rows need room to scroll clear of it */
body.phone #panelscroll{ padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

/* ── Tabs and essentials, slice 7 of the 14 Nov audit ─────────────────
   Form, Camera, Color, Finish as one segmented control: a dark track, 44px
   segments, the active one raised. Advanced ( n ) closes each of the first
   three tabs and opens the rows the tab keeps back. */
.labtabs{
  display: flex; gap: 4px; padding: 4px; margin: 0 0 8px;
  background: #0A0A0A; border-radius: var(--h-r-full);
}
.labtabs .labtab{
  flex: 1 1 0; min-width: 0; height: 44px; padding: 0 8px;
  border-radius: var(--h-r-full); background: none; border-color: transparent;
  font: 400 var(--h-t-sm)/1 var(--h-sans); color: var(--h-on-ink-2);
  transition: background-color var(--h-dur-snap) var(--h-ease), color var(--h-dur-snap) var(--h-ease);
}
.labtabs .labtab:hover{ background: #161616; color: var(--h-on-ink); }
.labtabs .labtab.on{ background: #2A2A2A; color: var(--h-on-ink); font-weight: 500; }
.labtabs .labtab:focus-visible{ outline: 2px solid var(--h-blue); outline-offset: 2px; }
.tabpane[hidden]{ display: none; }
.tabpane:not(.adv-open) .adv{ display: none !important; }
/* Each tab opens on a head: Essentials or All as a two-way switch, then the
   die for the tab's sections. The chosen half is filled light with dark type,
   so the state reads from across a room; the other half is dim type on the
   dark track. Finish lists every stage, so a caption stands in for the switch. */
body.lab .tabhead{ display: flex; gap: 4px; margin: 0 0 8px; }
body.lab .rowswitch{
  flex: 1 1 auto; min-width: 0; display: flex; height: 44px; padding: 0;
  background: #0A0A0A; border-radius: var(--h-r-full);
}
body.lab .rowswitch .rowseg{
  flex: 1 1 0; min-width: 0; height: 44px; padding: 0 12px;
  border-radius: var(--h-r-full); background: none; border-color: transparent;
  font: 400 var(--h-t-sm)/1 var(--h-sans); color: var(--h-on-ink-2);
  transition: background-color var(--h-dur-snap) var(--h-ease), color var(--h-dur-snap) var(--h-ease);
}
body.lab .rowswitch .rowseg span{ display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.lab .rowswitch .rowseg:hover{ background: #161616; color: var(--h-on-ink); }
body.lab .rowswitch .rowseg.on{ background: var(--h-on-ink); color: var(--h-ink); font-weight: 500; }
body.lab .rowswitch .rowseg:focus-visible{ outline: 2px solid var(--h-blue); outline-offset: 2px; }
body.lab .tabdice{
  flex: none; width: 44px; height: 44px; padding: 0; margin-left: auto;
  display: flex; align-items: center; justify-content: center;
}
body.lab .tabdice .ic{ width: 16px; height: 16px; }
body.lab .tabcap{ flex: 1 1 auto; min-width: 0; margin: 0; padding: 0 16px; align-self: center; font: 400 12px/1.3 var(--h-sans); color: var(--h-on-ink-2); }
body.lab .tabdice:disabled{ opacity: .32; cursor: default; }
/* the tabs are the top of the sheet: a peek shows the grabber and them */
body.phone .labtabs{ position: sticky; top: 0; z-index: 9; margin: 0 0 8px; box-shadow: 0 -8px 0 0 #202020; }
body.phone .tabpane > .group > .ghead{ top: 60px; }

/* ── Visual pass, 14 Nov: three proposals ─────────────────────────────
   All three hang off body.lab: glitchcut and textlab link this file and
   keep their own rows and their own color cycle. */

/* The fill stops at the handle with a square end, so it reads as a level
   and the handle is the only edge. It grows from 0 to the handle's parked
   spot at 10px, follows the handle, and past the far parking spot runs on
   to the end, so a full slider is full. The track's radius rounds the left. */
body.lab .ctl .fill{
  width: max(min(var(--p, 0) * 200%, var(--x)), 100% - (1 - var(--p, 0)) * 200%);
  border-radius: var(--h-r-md) 0 0 var(--h-r-md);
}

/* One text edge. A select row is the same 44px channel as a slider: the
   label 16px in, the value right in mono, the caret at the end. The select
   keeps 60% of the row, so the label stays free for the long-press hint.
   The label carries the hover, as it does on a slider. */
body.lab .selrow{
  min-height: 44px; margin-bottom: 4px; padding-left: 16px; gap: 8px;
  background: #0D0D0D; border-radius: var(--h-r-md);
}
body.lab .selrow .slab{
  flex: 1 1 auto; min-width: 0; width: auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color var(--h-dur-snap) var(--h-ease);
}
body.lab .selrow:hover .slab{ color: var(--h-on-ink); }
body.lab .selrow select{
  flex: 0 1 60%; min-width: 0; height: 44px;
  background-color: transparent; border: 0;
  text-align: right; text-align-last: right;
  padding: 0 36px 0 8px; background-position: right 14px center;
}
body.lab .selrow select:hover{ background-color: transparent; }
/* A seed's number and reroll key sit inside the channel, at its right. */
body.lab .seedrow{ padding-right: 0; }
body.lab .seedrow .seedval{ flex: 0 1 40%; text-align: right; }
/* The image row's load and clear keys carry 8px of their own, so "clear"
   ends 16px in, where a slider's number does. */
body.lab .filerow{ padding-right: 8px; }
/* State lines and notes start on the same 16px edge, with room under the head. */
body.lab .gbody .gstate{ margin: 0; padding: 8px 16px 12px; color: var(--h-on-ink-2); }
body.lab .gbody .fstate{ padding: 0 16px; }
body.lab .gbody .note{ padding-left: 14px; padding-right: 16px; }   /* 2px rule + 14 */
body.lab .gbody .note.lede{ padding-left: 16px; }

/* Blue is for pressing and for on. The section chips cycle through six
   hues and skip it, so a section's chip never reads as a second Randomize
   key, and the blue on dot beside a section's name always shows. */
body.lab .group:nth-of-type(6n+1){ --sec: var(--h-orange); }
body.lab .group:nth-of-type(6n+2){ --sec: var(--h-yellow); }
body.lab .group:nth-of-type(6n+3){ --sec: var(--h-green); }
body.lab .group:nth-of-type(6n+4){ --sec: var(--h-cyan); }
body.lab .group:nth-of-type(6n+5){ --sec: var(--h-violet); }
body.lab .group:nth-of-type(6n+6){ --sec: var(--h-pink); }
