:root{
  --rail: 520px;
}
html,body{height:100%}
.app{display:flex;height:100vh;height:100dvh;overflow:hidden}

.rail{
  width:var(--rail);flex:0 0 var(--rail);
  background:var(--card);border-right:1px solid var(--rule);
  display:flex;flex-direction:column;overflow-y:auto;
}
.brand{padding:34px 26px 26px;border-bottom:1px solid var(--rule)}
.brand h1{
  margin:0;font-weight:300;font-size:20px;line-height:1;
  letter-spacing:.3em;text-transform:uppercase;color:var(--ink);
}
.brand p{margin:14px 0 0;color:var(--muted);font-size:12.5px;line-height:1.55;white-space:nowrap;font-weight:300}

.block{padding:24px 26px;border-bottom:1px solid var(--rule)}

.grow{flex:1 1 auto;display:flex;flex-direction:column}

.foot{margin-top:auto}      /* download always sits at the bottom of the rail */
/* the privacy link under the credit. Unlike the credit it stays on the stacked layout,
   so every tool links its notice on a phone too */
.legal{margin:8px 0 0;text-align:center;font-size:10px;letter-spacing:.14em;font-weight:300}
.legal a{color:var(--muted);text-decoration:none;border-bottom:1px solid var(--rule)}
.legal a:hover{color:var(--accent);border-bottom-color:var(--accent)}
.legal a:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* drawer chrome — inert on desktop: the grab bar is hidden and the wrappers are
   display:contents, so the rail lays out exactly as if they weren't there */
.grab{display:none;width:100%;border:0;background:var(--card);padding:14px 0;cursor:pointer;touch-action:none}
.grabpill{display:block;width:44px;height:4px;margin:0 auto;background:var(--rule);border-radius:2px;transition:background .18s}
.grab:hover .grabpill{background:var(--accent)}
.grab:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.drawerbody,.drawerinner{display:contents}

.stage{flex:1;position:relative;min-width:0;background:var(--bg);overflow:hidden}
.empty{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;text-align:center;padding:24px}
.empty[hidden]{display:none}
.empty p{
  font-size:11px;letter-spacing:.34em;text-transform:uppercase;
  color:var(--muted);margin:0;font-weight:300;
}

/* an overlay: a full-screen working view on top of the tool — Pattern Maker's cropper,
   Chart Maker's forms. A white header bar holds the label, any chips and the actions;
   a white caption bar at the foot reports the result */
.overlay{position:fixed;inset:0;z-index:20;background:var(--bg);display:flex;flex-direction:column}
.overlay[hidden]{display:none}
.overlayhead{
  display:flex;align-items:center;gap:26px;flex-wrap:wrap;
  padding:20px 26px;border-bottom:1px solid var(--rule);background:var(--card);
}
.overlayfoot{
  margin:0;padding:16px 26px;border-top:1px solid var(--rule);background:var(--card);
  font-size:10px;letter-spacing:.18em;text-transform:uppercase;color:var(--muted);font-weight:300;
}

@media (max-width:820px) and (min-height:500px){
  .app{flex-direction:column-reverse}
  /* the rail takes exactly the height its content needs... */
  .rail{width:100%;flex:0 0 auto;border-right:0;border-top:0}
  /* ...and the preview takes everything that is left, so nothing scrolls */
  .stage{flex:1 1 auto;min-height:110px}
  /* the rail is a pull-up drawer: the grab bar, or a tap anywhere on the preview,
     toggles it. 1fr→0fr animates to natural height with no measuring;
     shared/tool.js gates its toggling on this same media query — change them together */
  .grab{display:block}
  .drawerbody{display:grid;grid-template-rows:1fr;transition:grid-template-rows .2s ease}
  .drawerinner{display:block;overflow:hidden;min-height:0}
  .app.closed .drawerbody{grid-template-rows:0fr}
  /* content stays visible while the drawer shrinks, vanishes (and leaves the tab
     order) once it lands; reopening shows it immediately. The delay tracks the
     duration above, and shared/tool.js's settle() fallback timer has to outlast both */
  .app.closed .drawerinner{visibility:hidden;transition:visibility 0s .2s}
  /* while a finger is on the grab bar the drawer tracks it: no transition to fight the
     drag, and the content stays visible even when the pull starts from closed */
  .app.dragging .drawerbody{transition:none}
  .app.dragging .drawerinner{visibility:visible;transition:none}
  /* the stacked layout is fighting for height, so trim chrome that earns nothing here.
     No section rules at all: the eyebrows already say where each group starts, and the
     preview's colour marks the drawer's edge far better than a hairline. The picker
     announces itself, so it loses its label too. Every pixel saved goes to the preview.
     Control borders — the drop zone, the mode and count buttons — are boxes, not rules,
     and stay. */
  .brand,.block{border-bottom:0}
  .brand{padding:18px 20px 14px}
  .credit{display:none}          /* the maker's credit is desktop-only — no room here */
  .brand p{margin-top:9px;font-size:min(12.5px,3.3vw)}   /* keeps the one-liner on narrow phones */
  .block{padding:14px 20px}
  .grow{display:block}
  .btn{padding:13px}
  .eyebrow{margin-bottom:10px}
}

/* shorter handsets — trim the rail so the preview keeps a usable share */
@media (max-width:820px) and (min-height:500px) and (max-height:780px){
  .brand{padding:14px 18px 12px}
  .brand p{margin-top:7px}
  .block{padding:11px 18px}
  .btn{padding:12px}
}

@media (max-width:820px) and (min-height:500px) and (max-height:700px){
  .block{padding:10px 18px}
}
/* short desktop windows — the padding is the first thing to go */
@media (min-width:821px) and (max-height:790px){
  .brand{padding:24px 26px 20px}
  .block{padding:18px 26px}
}

/* laptop windows shorter still — trim the padding everywhere */
@media (min-width:821px) and (max-height:660px){
  .brand{padding:16px 26px 14px}
  .block{padding:12px 26px}
  .eyebrow{margin-bottom:8px}
  .btn{padding:12px}
  .credit{margin-top:10px}
}
