/* Every band in the sticky header (brand bar, Controls summary, the UI grid
   inside it) is centred on this same width, so their content shares one left
   edge. They previously carried separate values and drifted apart. */
:root{ --shellMax: 1180px; }

* { box-sizing: border-box; }
body { margin:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial; background:#181a1f; color:#f3f4f6; color-scheme:dark; }

/* Sticky header: semi-transparent + blur so circles are visible while scrolling */
.siteHeader{
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(24, 26, 31, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Brand bar: name and description on one line */
.brandBar{
  display: flex;
  align-items: center;
  gap: 18px;
  white-space: nowrap;
  overflow-x: auto;
  max-width: var(--shellMax);
  margin: 0 auto;
  padding: 18px 20px 10px;
}
.brandName{ font-size: 26px; font-weight: 600; letter-spacing: .03em; }
.brandTagline{ font-size: 13px; opacity: .62; white-space: normal; line-height: 1.35; }

.controlsDisclosure { max-width: var(--shellMax); margin: 0 auto; }
.controlsSummary { display:flex; align-items:center; gap:12px; cursor:pointer; list-style:none; padding:7px 20px 12px; font-size:14px; line-height:1.25; font-weight:700; }
.controlsSummary::-webkit-details-marker { display:none; }
.controlsSummary::before { content:'⌄'; color:#9dc6ff; font-size:18px; line-height:1; transition:transform .2s; }
.controlsDisclosure:not([open]) .controlsSummary::before { transform:rotate(-90deg); }
.summaryHint { margin-left:2px; font-size:12px; font-weight:400; opacity:.5; }

/* UI grid */
#ui.uiGrid{
  display: grid;
  gap: 14px;
  padding: 16px 20px 22px;
  margin: 0;
  background: rgba(39,43,51,.48);
  border-top: 1px solid rgba(255,255,255,.07);
}
#ui .row{
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 10px;
  align-items: end;
}
#ui .field{ display: grid; gap: 6px; }
#ui label{ font-size: 13px; opacity: .7; }
#ui select, #ui textarea, #ui button{
  width: 100%;
  box-sizing: border-box;
  min-height: 46px;
  padding: 10px 12px;
  font-size: 16px;
}
#ui button{ cursor:pointer; }

/* Row 1: 4 equal blocks on wide */
#ui .row:nth-child(1) .field:nth-child(1){ grid-column: span 3; }
#ui .row:nth-child(1) .field:nth-child(2){ grid-column: span 3; }
#ui .row:nth-child(1) .field:nth-child(3){ grid-column: span 3; }
#ui .row:nth-child(1) .field:nth-child(4){ grid-column: span 3; }

/* Row 1b: circle size / row spacing sliders */
#ui .rowSliders .field{ grid-column: span 6; }
#ui .rowSliders input[type="range"]{ width: 100%; padding: 0; }
#ui .rowSliders label span{ opacity: 1; font-variant-numeric: tabular-nums; }

/* Row 2: text. The mask toggle sits on the label's row inside the field
   (.fieldHead), not as a grid sibling, so the field spans the full width at
   every breakpoint and needs no per-breakpoint rules. */
#ui .row:nth-child(3) .fieldGrow{ grid-column: span 12; }

/* Label left, icon button right, sharing one line above the textarea. */
#ui .fieldHead{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 20px;
}
#ui .fieldHead label{ margin: 0; }

/* Overrides the full-width #ui button sizing: this one hugs its icon. */
#ui .iconBtn{
  width: auto;
  min-height: 0;
  padding: 4px;
  line-height: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  color: inherit;
  opacity: .7;
}
#ui .iconBtn:hover{ background: #363d49; opacity: 1; }
#ui .iconBtn svg{ width: 20px; height: 20px; display: block; }

/* Only one of the two icons is ever shown; which one depends on the
   pressed state, and the icon names the action the click performs. */
#ui .iconBtn .iconEye{ display: none; }
#ui .iconBtn[aria-pressed="true"] .iconEyeOff{ display: none; }
#ui .iconBtn[aria-pressed="true"] .iconEye{ display: block; }
#ui .iconBtn[aria-pressed="true"]{ opacity: 1; color: #9dc6ff; }

/* Row 3: label ABOVE buttons (always) */
#ui .row:nth-child(4) .exportLabel{
  grid-column: span 12;
  font-size: 12px;
  opacity: .75;
  align-self: center;
}
#ui .row:nth-child(4) #savePng{ grid-column: span 6; }
#ui .row:nth-child(4) #saveSvg{ grid-column: span 6; }

/* Narrow: 2x2 grid for the four dropdowns; sliders stay on one row */
@media (max-width: 700px){
  #ui .row:nth-child(1) .field{ grid-column: span 6; }
}

#wrap { overflow:auto; padding: 28px 20px 40px; }

/* p5 sets the canvas' real drawing dimensions. Never squeeze it with
   max-width:100% — that changes circles into ovals when a long line is wider
   than the preview viewport. The wrapper provides horizontal scrolling. */
canvas { display:block; width:auto !important; height:auto !important; margin: 0 auto 16px auto; }

/* textarea: keep it tidy */
#txt{
  min-height: 44px;
  max-height: 160px;
  resize: vertical;
  line-height: 1.2;
  font-family: inherit;
  white-space: pre-wrap;
}

#ui select, #ui textarea, #ui button {
  color: inherit;
  background: #272b33;
  border: 1px solid #626977;
  border-radius: 10px;
  font-family: inherit;
}
#ui button:hover { background: #363d49; }
#ui :focus-visible { outline: 2px solid #9dc6ff; outline-offset: 3px; }
#ui .field { min-width: 0; }
/* Hidden text is still editable, so this is a cue, not a disabled state. */
#txt.isMasked { color: #bfc5d0; }
@media (max-width: 420px) {
  #ui .row:nth-child(3) .fieldGrow { grid-column: span 12; }
}

@media (max-width: 700px) {
  .brandBar { padding: 16px 16px 8px; gap: 14px; }
  .brandName { font-size: 22px; }
  .controlsSummary { padding-inline: 16px; }
  #ui.uiGrid { padding: 14px 16px 18px; }
  #ui .row { gap: 12px; }
  #ui select, #ui button { min-height: 50px; }
  #wrap { padding: 20px 12px 32px; }
}

/* Developer inspector (?debug=1 only) — not part of the normal UI */
#debugPanel{
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 20;
  max-width: min(480px, calc(100vw - 20px));
  margin: 0;
  padding: 10px 12px;
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  color: #d7dbe3;
  background: rgba(24, 26, 31, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  pointer-events: none;
}
