/* Saraskala Photo Studio — professional layered raster editor
   Client-side only. Nothing is uploaded; all processing happens in the browser.

   Token architecture (primitive -> semantic -> component):
     :root                 primitives (raw palette / space / radius / type scale)
     .pe-app / :root       semantic aliases (surface, ink, accent, focus ring)
     .pe-* component rules component tokens (panel, tool, chip, range, modal)

   Layout: 4-column workspace grid
     [tools 62px] [inspector 250px] [stage 1fr] [layers 232px]
   The collapse toggles are absolutely positioned so they never occupy a
   grid track -- previously they were grid children, which pushed the tool
   rail into the last column and collapsed the inspector to 62px. */

:root {
  /* ---------- Primitives ---------- */
  --skl-p-bg: #070a10;
  --skl-p-panel: #11151f;
  --skl-p-panel-2: #161b28;
  --skl-p-panel-3: #1b2233;
  --skl-p-border: #232a3a;
  --skl-p-border-2: #2e374b;
  --skl-p-text: #e6ebf5;
  --skl-p-muted: #8b95ab;
  --skl-p-accent: #38d9f0;
  --skl-p-accent-2: #5b8cff;
  --skl-p-accent-ink: #061018;
  --skl-p-danger: #ff5c7a;
  --skl-p-warn: #f2b544;
  --skl-p-ok: #3be0a1;
  --skl-p-active-bg: #14303a;
  --skl-p-stage: #0c0f16;
  --skl-p-stage-2: #12151d;
  --skl-p-focus: #2be4ff;

  --skl-p-r-4: 4px;
  --skl-p-r-6: 6px;
  --skl-p-r-7: 7px;
  --skl-p-r-8: 8px;
  --skl-p-r-9: 9px;
  --skl-p-r-10: 10px;
  --skl-p-r-12: 12px;
  --skl-p-r-14: 14px;

  --skl-p-s-1: 4px;
  --skl-p-s-2: 6px;
  --skl-p-s-3: 8px;
  --skl-p-s-4: 10px;
  --skl-p-s-5: 12px;
  --skl-p-s-6: 14px;
  --skl-p-s-7: 18px;
  --skl-p-s-8: 22px;
  --skl-p-s-9: 26px;
  --skl-p-s-10: 32px;

  --skl-p-fs-10: 10px;
  --skl-p-fs-11: 11px;
  --skl-p-fs-12: 12px;
  --skl-p-fs-13: 13px;
  --skl-p-fs-14: 14px;
  --skl-p-fs-15: 15px;
  --skl-p-fs-17: 17px;

  --skl-p-t-fast: .14s;
  --skl-p-t: .18s;

  /* ---------- Semantic ---------- */
  --skl-bg: var(--skl-p-bg);
  --skl-panel: var(--skl-p-panel);
  --skl-panel-2: var(--skl-p-panel-2);
  --skl-border: var(--skl-p-border);
  --skl-text: var(--skl-p-text);
  --skl-muted: var(--skl-p-muted);
  --skl-accent: var(--skl-p-accent);
  --skl-accent-2: var(--skl-p-accent-2);
  --skl-danger: var(--skl-p-danger);
  --skl-warn: var(--skl-p-warn);
  --skl-ok: var(--skl-p-ok);
  --skl-focus: var(--skl-p-focus);
  --skl-radius: var(--skl-p-r-12);
  --skl-toolbar-h: 52px;
  --skl-status-h: 30px;

  /* ---------- Component tokens ---------- */
  --skl-c-tool-size: 44px;
  --skl-c-rail-w: 62px;
  /* The height of the tool strip, now that the rail is a top bar. The
     collapse toggles are placed against it. */
  --skl-c-toolbar-h: 60px;
  --skl-c-inspector-w: 250px;
  --skl-c-layers-w: 232px;
  --skl-c-panel-w-narrow: 216px;
  --skl-c-layers-w-narrow: 200px;
  --skl-c-rail-w-mobile: 56px;
}

* { box-sizing: border-box; }

/* The `hidden` attribute sets display:none in the UA stylesheet, but any
   author `display` rule beats it. Panels here are flex/grid, so state the
   override once, globally, and stop hidden elements from leaking on screen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--skl-bg);
  color: var(--skl-text);
  font-family: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  overflow: hidden;
  /* Stop the browser hijacking pinch-zoom on the canvas; the studio handles
     its own gesture. Everything else stays natively zoomable. */
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--skl-focus);
  outline-offset: 2px;
  border-radius: var(--skl-p-r-4);
}

/* ---------- Maintenance lock (until internal tests pass) ---------- */

.pe-maintenance {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 10, 18, 0.72);
  backdrop-filter: blur(6px);
}
.pe-maintenance__card {
  max-width: 440px;
  padding: 28px 28px 24px;
  border-radius: 16px;
  border: 1px solid rgba(56, 217, 240, 0.28);
  background: linear-gradient(180deg, #101828, #0b1220);
  color: #dbe6ff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.pe-maintenance__kicker {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #38d9f0;
}
.pe-maintenance__card h1 {
  margin: 0 0 10px;
  font-size: 26px;
  letter-spacing: -0.03em;
}
.pe-maintenance__card p {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.55;
  color: #9fb4d8;
}
.pe-maintenance__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.pe-maintenance__btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(122, 100, 190, 0.35);
  color: #efeaff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.pe-maintenance__btn--primary {
  background: #38d9f0;
  border-color: #38d9f0;
  color: #062028;
}
.pe-app[inert] { pointer-events: none; user-select: none; }

/* ---------- App shell ---------- */

.pe-app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- Top bar ---------- */

.pe-topbar {
  display: flex;
  align-items: center;
  gap: var(--skl-p-s-2);
  padding: 0 var(--skl-p-s-4);
  height: var(--skl-toolbar-h);
  background: var(--skl-panel);
  border-bottom: 1px solid var(--skl-border);
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}

.pe-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  margin-right: 6px;
}

.pe-brand__sub {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--skl-accent);
  border: 1px solid rgba(56,217,240,.35);
  border-radius: 999px;
  padding: 2px 7px;
}
.pe-brand__mark {
  width: 26px; height: 26px;
  border-radius: var(--skl-p-r-7);
  background: linear-gradient(135deg, var(--skl-accent), var(--skl-accent-2));
  display: grid; place-items: center;
  color: var(--skl-p-accent-ink); font-size: 13px; font-weight: 700;
}

.pe-back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: var(--skl-p-r-9);
  border: 1px solid var(--skl-border);
  background: var(--skl-panel-2);
  color: var(--skl-text);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  transition: border-color var(--skl-p-t-fast), background var(--skl-p-t-fast);
}
.pe-back:hover { border-color: var(--skl-accent-2); background: var(--skl-p-panel-3); }

.pe-sep { width: 1px; height: 26px; background: var(--skl-border); margin: 0 3px; flex: none; }

.pe-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: var(--skl-p-r-9);
  border: 1px solid var(--skl-border);
  background: var(--skl-panel-2);
  color: var(--skl-text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  min-height: 34px;
  transition: border-color var(--skl-p-t-fast), background var(--skl-p-t-fast), transform .05s;
}
.pe-btn:hover:not(:disabled) { border-color: var(--skl-accent-2); background: var(--skl-p-panel-3); }
/* The compare is a toggle, so it has to LOOK like a toggle. */
.pe-btn.is-active, .pe-btn[aria-pressed="true"] {
  border-color: var(--skl-accent); background: var(--skl-p-active-bg); color: var(--skl-accent);
}
.pe-btn:active:not(:disabled) { transform: translateY(1px); }
.pe-btn:disabled { opacity: .42; cursor: not-allowed; }
.pe-btn--primary {
  background: linear-gradient(135deg, var(--skl-accent), var(--skl-accent-2));
  border-color: transparent; color: var(--skl-p-accent-ink); font-weight: 600;
}
.pe-btn--primary:hover:not(:disabled) { filter: brightness(1.08); background: linear-gradient(135deg, var(--skl-accent), var(--skl-accent-2)); }
.pe-btn--icon { padding: 7px 9px; min-width: 34px; justify-content: center; }
.pe-btn.is-active { border-color: var(--skl-accent); background: var(--skl-p-active-bg); color: var(--skl-accent); }

.pe-spacer { flex: 1 1 auto; min-width: 8px; }

/* ---------- Main workspace ----------
   4 explicit tracks. The collapse toggles are position:absolute (see
   .collapse-toggle below) so they float over the seams instead of
   consuming a track. */

.pe-main {
  display: grid;
  grid-template-columns:
    var(--skl-c-rail-w)
    var(--skl-c-inspector-w)
    minmax(0, 1fr)
    var(--skl-c-layers-w);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ---------- Tool rail ---------- */

.pe-tools {
  grid-column: 1;
  grid-row: 1;
  background: var(--skl-panel);
  border-right: 1px solid var(--skl-border);
  padding: var(--skl-p-s-2) 0;
  display: flex; flex-direction: column; align-items: center; gap: var(--skl-p-s-1);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.pe-tool {
  width: var(--skl-c-tool-size);
  height: var(--skl-c-tool-size);
  flex: none;                       /* never squash the 44px touch target */
  border-radius: var(--skl-p-r-10);
  border: 1px solid transparent;
  background: transparent;
  color: var(--skl-muted);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 15px;
  position: relative;
  transition: background var(--skl-p-t-fast), color var(--skl-p-t-fast), border-color var(--skl-p-t-fast);
}
.pe-tool:hover { background: var(--skl-panel-2); color: var(--skl-text); }
.pe-tool.is-active {
  background: var(--skl-p-active-bg);
  border-color: var(--skl-accent);
  color: var(--skl-accent);
}
.pe-tool__tip {
  position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  background: #05070c; color: var(--skl-text);
  padding: var(--skl-p-s-1) 9px; border-radius: var(--skl-p-r-6); font-size: var(--skl-p-fs-11);
  white-space: nowrap;
  border: 1px solid var(--skl-border); pointer-events: none;
  opacity: 0; transition: opacity var(--skl-p-t-fast); z-index: 60;
}
.pe-tool:hover .pe-tool__tip,
.pe-tool:focus-visible .pe-tool__tip { opacity: 1; }

/* ---------- Left panel (inspector) ---------- */

.pe-panel {
  background: var(--skl-panel);
  border-right: 1px solid var(--skl-border);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--skl-p-s-5);
  min-width: 0;
  scrollbar-width: thin;
}
.pe-panel--left {
  grid-column: 2; grid-row: 1;
  /* A flex column so the active tool's options can be pinned to the top
     and the properties can be navigated, the way a professional editor
     splits the inspector. */
  display: flex; flex-direction: column;
}
/* Without this the flex column would shrink the sections to fit the
   viewport and clip their content. */
.pe-panel--left > * { flex: none; }
/* The pinned head comes first, then the tool-specific panels, then the
   general properties. */
.pe-panel--left > .pe-panel__section { order: 10; }
.pe-panel--left > #brush-section,
.pe-panel--left > #text-section,
.pe-panel--left > #shape-section,
.pe-panel--left > #select-section { order: -1; }
.pe-panel--left > .pe-inspector-head { order: -3; }

/* The sticky head: the section nav plus the tool hint. */
.pe-inspector-head {
  position: sticky; top: 0; z-index: 7;
  background: var(--skl-panel);
  border-bottom: 1px solid var(--skl-border);
  margin: 0 calc(var(--skl-p-s-5) * -1);
  padding: 0 var(--skl-p-s-5);
}
.pe-inspector-head .pe-panel__section--pinned { margin-bottom: 0; }

/* Sticky section nav. */
.pe-inspector-nav {
  display: flex; gap: var(--skl-p-s-1);
  overflow-x: auto; scrollbar-width: none;
  padding: var(--skl-p-s-3) 0;
}
.pe-inspector-nav::-webkit-scrollbar { display: none; }
.pe-navchip {
  flex: none;
  padding: 5px 10px;
  border-radius: var(--skl-p-r-7);
  border: 1px solid var(--skl-border);
  background: var(--skl-panel-2);
  color: var(--skl-muted);
  font: inherit; font-size: var(--skl-p-fs-11);
  cursor: pointer; white-space: nowrap;
  transition: color var(--skl-p-t-fast), border-color var(--skl-p-t-fast), background var(--skl-p-t-fast);
}
.pe-navchip:hover { color: var(--skl-text); border-color: var(--skl-accent-2); }
.pe-navchip.is-active {
  color: var(--skl-accent);
  border-color: var(--skl-accent);
  background: var(--skl-p-active-bg);
}

/* Tool rail grouping. */
.pe-tool-sep {
  width: 24px; height: 1px; flex: none;
  background: var(--skl-border);
  margin: var(--skl-p-s-2) 0;
}
.pe-panel--right {
  grid-column: 4; grid-row: 1;
  border-right: none; border-left: 1px solid var(--skl-border);
}

.pe-panel__title {
  font-size: var(--skl-p-fs-11); text-transform: uppercase; letter-spacing: .09em;
  color: var(--skl-muted); margin: 0 0 var(--skl-p-s-3); font-weight: 600;
}
.pe-panel__title-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--skl-p-s-2); margin-bottom: var(--skl-p-s-3);
}
.pe-panel__title-row .pe-panel__title { margin: 0; }
.pe-panel__section { margin-bottom: var(--skl-p-s-6); }
.pe-panel__section:last-child { margin-bottom: 0; }

/* Section collapse control (used by every inspector section). */
.pe-section-toggle {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--skl-p-r-6);
  border: 1px solid var(--skl-border);
  background: var(--skl-panel-2);
  color: var(--skl-muted);
  cursor: pointer; font-size: 11px;
  transition: color var(--skl-p-t-fast), border-color var(--skl-p-t-fast);
}
.pe-section-toggle:hover { color: var(--skl-accent); border-color: var(--skl-accent-2); }
.pe-panel__section.is-collapsed > *:not(.pe-panel__title-row) { display: none; }
.pe-panel__section.is-collapsed .pe-section-toggle i { transform: rotate(-90deg); }
.pe-section-toggle i { transition: transform var(--skl-p-t-fast); }

/* ---------- Controls ---------- */

.pe-field { margin-bottom: var(--skl-p-s-4); }
.pe-field:last-child { margin-bottom: 0; }

.pe-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--skl-p-fs-12); color: var(--skl-muted); margin-bottom: var(--skl-p-s-2);
}
.pe-label__val { color: var(--skl-text); font-family: "JetBrains Mono", monospace; font-size: var(--skl-p-fs-11); }

.pe-range-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pe-range-row .pe-range { flex: 1; min-width: 0; width: auto; }
.pe-step {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--skl-border);
  border-radius: var(--skl-p-r-4);
  background: var(--skl-panel-3);
  color: var(--skl-text);
  font-size: 15px;
  line-height: 20px;
  cursor: pointer;
  user-select: none;
}
.pe-step:hover { border-color: var(--skl-accent); color: var(--skl-accent); }
.pe-step:active { background: var(--skl-active-bg, #14303a); }

.pe-range {
  width: 100%; height: 4px; -webkit-appearance: none; appearance: none;
  background: #222a3a; border-radius: 3px; outline: none; cursor: pointer;
}
.pe-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--skl-accent); cursor: pointer; border: 2px solid var(--skl-p-bg);
}
.pe-range::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--skl-accent); cursor: pointer; border: 2px solid var(--skl-p-bg);
}

/* The row wraps. A rail this narrow clipped "Fit to weight range"
   to "Fit to weight r", which read as a broken control.

   Wrapping the row is not enough on its own: the buttons are flex items
   with a 0 basis, so they shrink to fit and the nowrap label is cut off at
   the panel edge. They get an automatic basis and are allowed to wrap
   their own text, so the label is always readable. */
.pe-row { display: flex; gap: var(--skl-p-s-2); flex-wrap: wrap; }
.pe-row > * { flex: 1 1 auto; }
.pe-row > .pe-btn { white-space: normal; text-align: center; justify-content: center; }

/* A narrow rail stacks its buttons, full width, one per line. Two buttons
   side by side do not fit in 225px, and shrinking them to fit meant the
   labels wrapped to three lines inside a half-width button. */
.pe-row--stack { flex-direction: column; align-items: stretch; }
.pe-row--stack > * { flex: none; width: 100%; }
.pe-row > * { flex: 1; min-width: 0; }

.pe-input, .pe-select {
  width: 100%; padding: 7px 9px;
  background: var(--skl-panel-2);
  border: 1px solid var(--skl-border);
  border-radius: var(--skl-p-r-8); color: var(--skl-text);
  font-size: var(--skl-p-fs-12); font-family: inherit;
  min-height: 34px;
}
.pe-input:focus, .pe-select:focus { outline: none; border-color: var(--skl-accent-2); }
.pe-input:focus-visible, .pe-select:focus-visible {
  outline: 2px solid var(--skl-focus); outline-offset: 1px;
}
.pe-textarea { resize: vertical; min-height: 68px; line-height: 1.5; }

.pe-checks { display: grid; grid-template-columns: 1fr 1fr; gap: var(--skl-p-s-2); }
.pe-check {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--skl-p-fs-11); color: var(--skl-muted); cursor: pointer;
  padding: 5px 7px; border-radius: var(--skl-p-r-7); border: 1px solid transparent;
  min-height: 30px;
}
.pe-check:hover { background: var(--skl-panel-2); }
.pe-check input { accent-color: var(--skl-accent); cursor: pointer; }

.pe-chip-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--skl-p-s-2); }
.pe-chip-grid--3 { grid-template-columns: repeat(3, 1fr); }
.pe-chip-grid--4 { grid-template-columns: repeat(4, 1fr); }
.pe-chip-grid--2 { grid-template-columns: repeat(2, 1fr); }
.pe-chip {
  padding: 7px 4px; border-radius: var(--skl-p-r-8);
  border: 1px solid var(--skl-border); background: var(--skl-panel-2);
  color: var(--skl-muted); font-size: var(--skl-p-fs-11); cursor: pointer;
  text-align: center; min-height: 32px;
  transition: color var(--skl-p-t-fast), border-color var(--skl-p-t-fast), background var(--skl-p-t-fast);
}
.pe-chip:hover { border-color: var(--skl-accent-2); color: var(--skl-text); }
.pe-chip.is-active { background: var(--skl-p-active-bg); border-color: var(--skl-accent); color: var(--skl-accent); }

/* Colour swatches for background sampling. */
.pe-swatches {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--skl-p-s-2);
  min-height: 30px;
}
.pe-swatches .pe-swatch {
  aspect-ratio: 1 / 1; border-radius: var(--skl-p-r-6);
  border: 1px solid var(--skl-border-2); cursor: pointer; padding: 0;
}
.pe-swatches .pe-swatch:hover { border-color: var(--skl-accent); }
.pe-empty-note { color: var(--skl-muted); font-size: var(--skl-p-fs-11); grid-column: 1 / -1; }

.pe-hint { font-size: var(--skl-p-fs-11); color: var(--skl-muted); line-height: 1.5; margin: var(--skl-p-s-2) 0 0; }
.pe-hint--link a { color: var(--skl-accent); text-decoration: none; }
.pe-hint--link a:hover { text-decoration: underline; }

/* Export verification readout. */
.pe-verify {
  margin-top: var(--skl-p-s-3);
  border: 1px solid var(--skl-border);
  border-radius: var(--skl-p-r-8);
  background: var(--skl-panel-2);
  padding: var(--skl-p-s-3);
  display: grid; gap: var(--skl-p-s-2);
}
.pe-verify__row {
  display: flex; justify-content: space-between; gap: var(--skl-p-s-3);
  font-size: var(--skl-p-fs-11); color: var(--skl-muted);
  font-family: "JetBrains Mono", monospace;
}
.pe-verify__row span:last-child { color: var(--skl-text); }

/* ---------- Compliance certificate ----------
   The proof, not the file. Every value in here was read back out of the
   exported bytes, so the panel can be shown to a portal or a clerk. */
.pe-cert {
  /* The inspector rail is narrow, so the table's layout is chosen by the
     width of the certificate, not of the window. */
  container-type: inline-size;
  margin-top: var(--skl-p-s-3);
  border: 1px solid var(--skl-border);
  border-radius: var(--skl-p-r-8);
  background: var(--skl-panel-2);
  padding: var(--skl-p-s-3);
  display: grid; gap: var(--skl-p-s-3);
}
.pe-cert__head { display: flex; gap: var(--skl-p-s-3); align-items: flex-start; }
.pe-cert__headings { display: grid; gap: 2px; min-width: 0; }
.pe-cert__title { font-size: var(--skl-p-fs-12); line-height: 1.35; }
.pe-cert__sub { font-size: var(--skl-p-fs-11); color: var(--skl-muted); line-height: 1.45; }
.pe-cert__verdict {
  flex: none;
  font-family: "JetBrains Mono", monospace;
  font-size: var(--skl-p-fs-11);
  font-weight: 700;
  letter-spacing: .06em;
  padding: 4px 8px;
  border-radius: var(--skl-p-r-6);
  border: 1px solid currentColor;
}
.pe-cert__verdict.is-ok { color: var(--skl-ok); background: rgba(59,224,161,.12); }
.pe-cert__verdict.is-bad { color: var(--skl-danger); background: rgba(255,92,122,.12); }
.pe-cert__verdict.is-muted { color: var(--skl-muted); }

.pe-cert__facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px var(--skl-p-s-3);
  margin: 0;
  font-size: var(--skl-p-fs-11);
}
.pe-cert__facts dt { color: var(--skl-muted); }
.pe-cert__facts dd {
  margin: 0;
  color: var(--skl-text);
  font-family: "JetBrains Mono", monospace;
  overflow-wrap: anywhere;
}

.pe-cert__digest {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--skl-p-s-3);
  font-size: var(--skl-p-fs-11);
  color: var(--skl-muted);
  align-items: baseline;
}
.pe-cert__digest code {
  font-family: "JetBrains Mono", monospace;
  color: var(--skl-text);
  overflow-wrap: anywhere;
  font-size: 10px;
  line-height: 1.4;
}

.pe-cert__rules {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--skl-p-fs-11);
}
.pe-cert__rules caption {
  text-align: left;
  color: var(--skl-muted);
  padding-bottom: var(--skl-p-s-2);
  font-size: var(--skl-p-fs-11);
}
.pe-cert__rules th, .pe-cert__rules td {
  text-align: left;
  vertical-align: top;
  padding: 5px 6px 5px 0;
  border-bottom: 1px solid var(--skl-border);
  overflow-wrap: anywhere;
}
.pe-cert__rules th { color: var(--skl-muted); font-weight: 500; }
.pe-cert__rules td:last-child, .pe-cert__rules th:last-child { white-space: nowrap; font-weight: 700; }
.pe-cert__rules tr.is-pass td:last-child { color: var(--skl-ok); }
.pe-cert__rules tr.is-fail td:last-child { color: var(--skl-danger); }

.pe-cert__prov { display: grid; gap: 4px; font-size: var(--skl-p-fs-11); color: var(--skl-muted); }
.pe-cert__prov p { margin: 0; line-height: 1.5; overflow-wrap: anywhere; }
.pe-cert__src a { color: var(--skl-accent); }
.pe-cert__caveat { color: var(--skl-warn); }

.pe-cert__actions { display: flex; flex-wrap: wrap; gap: var(--skl-p-s-2); }

/* A narrow rail cannot hold four columns, so each rule becomes a
   stacked block: the rule name, then required, then actual, then the
   result. The DOM is unchanged; only the layout differs. */
@container (max-width: 430px) {
  .pe-cert__rules thead { display: none; }
  .pe-cert__rules tr { display: block; border-bottom: 1px solid var(--skl-border); padding: 8px 0; }
  .pe-cert__rules td { display: block; border: 0; padding: 1px 0; }
  .pe-cert__rules td::before {
    content: attr(data-label) "  ";
    color: var(--skl-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  }
  .pe-cert__rules td:last-child { white-space: normal; padding-top: 3px; }
  .pe-cert__rules td:first-child { font-weight: 600; }
}

/* Printing the certificate is a real use: it is the thing a user shows a
   clerk at an appointment. Only the certificate is printed. */
@media print {
  body * { visibility: hidden !important; }
  #export-certificate, #export-certificate * { visibility: visible !important; }
  #export-certificate {
    position: absolute;
    left: 0; top: 0; width: 100%;
    background: #fff;
    color: #000;
    border: 1px solid #000;
  }
  .pe-cert__actions { display: none !important; }
}


/* ---------- Projects ----------
   The restore bar sits under the top bar. It is the only thing on the page
   that appears without the user asking, so it has to read as an offer and
   not as an error. */
.pe-autosave {
  /* An overlay across the top of the stage. It appears by itself, so it
     must not reflow the workspace when it does. */
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: var(--skl-p-s-3);
  flex-wrap: wrap;
  padding: 8px 14px;
  background: var(--skl-p-accent-bg, rgba(56,217,240,.10));
  border-bottom: 1px solid var(--skl-border);
  font-size: var(--skl-p-fs-11);
  color: var(--skl-text);
}
.pe-autosave[hidden] { display: none; }
.pe-autosave > i { color: var(--skl-accent); }
.pe-autosave__text { font-weight: 600; }
.pe-autosave__when { color: var(--skl-muted); }
.pe-autosave .pe-btn { min-height: 28px; padding: 3px 10px; font-size: 12px; }


/* ---------- Layer drag-reorder ---------- */
.pe-layer.is-dragging { opacity: .45; }
.pe-layer.is-drop { border-color: var(--skl-accent); background: var(--skl-p-active-bg); }

/* ---------- The first-run guide ----------
   It sits at the bottom of the stage, out of the way of the artwork, and
   it is the only thing on the page that appears without being asked for -
   so it has to read as a hint and not as an error. */
.pe-onboarding {
  position: absolute;
  left: 50%;
  /* At the TOP of the stage: the toasts appear at the bottom, and the two
     were landing on top of each other. The canvas is centred, so the top
     of the stage is usually free. */
  top: 18px;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: var(--skl-p-s-3);
  max-width: min(560px, calc(100% - 32px));
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--skl-panel);
  border: 1px solid var(--skl-border);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  font-size: var(--skl-p-fs-12);
}
.pe-onboarding[hidden] { display: none; }
.pe-onboarding__step {
  flex: none;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--skl-accent);
}
.pe-onboarding__text { color: var(--skl-text); line-height: 1.4; }
.pe-onboarding .pe-btn { min-height: 26px; padding: 2px 12px; font-size: 12px; border-radius: 999px; }


/* ---------- Acceptance checks ----------
   The certificate is about the file; these are about the photo. */
.pe-accept {
  margin-top: var(--skl-p-s-3);
  border: 1px solid var(--skl-border);
  border-radius: var(--skl-p-r-8);
  background: var(--skl-panel-2);
  padding: var(--skl-p-s-3);
  display: grid; gap: var(--skl-p-s-2);
}
.pe-accept__head-row { display: flex; align-items: center; justify-content: space-between; gap: var(--skl-p-s-2); }
.pe-accept__title { font-size: var(--skl-p-fs-12); }
.pe-accept__list { display: grid; gap: var(--skl-p-s-2); }
.pe-accept__row { display: flex; gap: var(--skl-p-s-2); align-items: flex-start; }
.pe-accept__mark { flex: none; width: 16px; line-height: 1.4; text-align: center; }
.pe-accept__row.is-ok .pe-accept__mark { color: var(--skl-ok); }
.pe-accept__row.is-bad .pe-accept__mark { color: var(--skl-warn); }
.pe-accept__row.is-unknown .pe-accept__mark { color: var(--skl-muted); }
.pe-accept__body { min-width: 0; }
.pe-accept__head { display: flex; gap: var(--skl-p-s-2); align-items: baseline; flex-wrap: wrap; }
.pe-accept__head strong { font-size: var(--skl-p-fs-11); }
.pe-accept__value { font-family: "JetBrains Mono", monospace; font-size: 10px; color: var(--skl-muted); }
.pe-accept__note { margin: 2px 0 0; font-size: var(--skl-p-fs-11); color: var(--skl-muted); line-height: 1.45; }
.pe-accept__summary { margin: 0; font-size: var(--skl-p-fs-11); font-weight: 600; }
.pe-accept__summary.is-ok { color: var(--skl-ok); }
.pe-accept__summary.is-bad { color: var(--skl-warn); }
.pe-accept__summary.is-unknown { color: var(--skl-muted); }


/* ---------- Layer groups ----------
   A group is a container, not a Fabric Group, so the pixels do not move.
   The indent is the only thing that says a layer is inside one. */
.pe-layer--group { background: var(--skl-p-panel-3, rgba(255,255,255,.03)); }
.pe-layer--group .pe-layer__name { font-weight: 600; }
.pe-layer__tri {
  flex: none;
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--skl-muted);
  cursor: pointer; padding: 0; font-size: 10px;
}
.pe-layer__tri:hover { color: var(--skl-accent); }
.pe-layer.is-selected { background: var(--skl-p-active-bg); }
.pe-layer.is-indented { padding-left: 20px; }


/* ---------- Tone curve editor ---------- */

.pe-curve { margin-top: var(--skl-p-s-3); }
.pe-curve__canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: var(--skl-p-r-8);
  border: 1px solid var(--skl-border);
  background: #080b11;
  cursor: crosshair;
  touch-action: none;   /* the editor owns the drag gesture */
}
.pe-curve__row { align-items: center; margin-top: var(--skl-p-s-3); }
#curve-channels .pe-chip[data-curve="rgb"].is-active { color: var(--skl-accent); border-color: var(--skl-accent); background: var(--skl-p-active-bg); }
#curve-channels .pe-chip[data-curve="r"].is-active { color: #ff6b81; border-color: #ff6b81; background: rgba(255,107,129,.12); }
#curve-channels .pe-chip[data-curve="g"].is-active { color: #3be0a1; border-color: #3be0a1; background: rgba(59,224,161,.12); }
#curve-channels .pe-chip[data-curve="b"].is-active { color: #5b8cff; border-color: #5b8cff; background: rgba(91,140,255,.12); }
.pe-curve__row .pe-hint { flex: 1 1 auto; text-align: right; margin: 0; }

/* ---------- Selection panel ---------- */

/* ---------- Canvas area ---------- */

.pe-stage {
  grid-column: 3; grid-row: 1;
  position: relative;
  background:
    linear-gradient(45deg, var(--skl-p-stage-2) 25%, transparent 25%),
    linear-gradient(-45deg, var(--skl-p-stage-2) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--skl-p-stage-2) 75%),
    linear-gradient(-45deg, transparent 75%, var(--skl-p-stage-2) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: var(--skl-p-stage);
  overflow: hidden;
  display: grid; place-items: center;
  min-width: 0;
  min-height: 0;
  touch-action: none;   /* the studio owns pan/zoom gestures on the canvas */
}

.pe-canvas-wrap {
  position: relative;
  box-shadow: 0 12px 44px rgba(0,0,0,.6);
  background: #fff;
}
.pe-canvas-wrap .canvas-container { position: relative !important; }

.pe-stage__overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center; padding: var(--skl-p-s-9);
  pointer-events: none; z-index: 5;
}
.pe-stage__overlay.is-hidden { display: none; }
.pe-empty { pointer-events: auto; }
.pe-empty__icon { font-size: 46px; color: #2c3446; margin-bottom: var(--skl-p-s-5); }
.pe-empty h2 { margin: 0 0 var(--skl-p-s-2); font-size: var(--skl-p-fs-17); color: var(--skl-text); font-weight: 600; }
.pe-empty p { margin: 0 0 var(--skl-p-s-5); color: var(--skl-muted); font-size: var(--skl-p-fs-13); max-width: 400px; line-height: 1.6; }
.pe-empty__note { font-size: var(--skl-p-fs-12); }
.pe-empty__note a { color: var(--skl-accent); }
.pe-empty .pe-drop {
  border: 2px dashed #2c3446; border-radius: var(--skl-p-r-14); padding: var(--skl-p-s-9) var(--skl-p-s-10);
  transition: border-color var(--skl-p-t), background var(--skl-p-t);
  max-width: 420px;
}
.pe-empty .pe-drop.is-over { border-color: var(--skl-accent); background: rgba(56,217,240,.05); }

/* ---------- Layers panel ---------- */

.pe-layers { display: flex; flex-direction: column; gap: var(--skl-p-s-1); }

.pe-layer {
  display: flex; align-items: center; gap: var(--skl-p-s-2);
  padding: 7px 9px; border-radius: var(--skl-p-r-9);
  background: var(--skl-panel-2);
  border: 1px solid transparent;
  cursor: pointer; font-size: var(--skl-p-fs-12);
  min-height: 36px;
  transition: border-color var(--skl-p-t-fast), background var(--skl-p-t-fast), opacity var(--skl-p-t-fast);
}
.pe-layer:hover { border-color: var(--skl-p-border-2); }
.pe-layer.is-active { border-color: var(--skl-accent); background: var(--skl-p-active-bg); }
.pe-layer.is-hidden { opacity: .45; }
.pe-layer__vis {
  width: 18px; height: 18px; border-radius: var(--skl-p-r-5); flex: none;
  border: 1px solid var(--skl-border); background: #0e1219;
  color: var(--skl-muted); font-size: 10px; cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.pe-layer__vis:hover { border-color: var(--skl-accent-2); color: var(--skl-accent); }
.pe-layer__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-layer__op { font-size: 10px; color: var(--skl-muted); font-family: "JetBrains Mono", monospace; }

.pe-blend { width: 100%; margin-top: 2px; }

/* ---------- History panel ---------- */

.pe-history {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 200px; overflow-y: auto;
  scrollbar-width: thin;
}
.pe-hist {
  display: block; width: 100%; text-align: left;
  padding: 5px 8px; border-radius: var(--skl-p-r-6);
  border: 1px solid transparent;
  background: transparent; color: var(--skl-muted);
  font: inherit; font-size: var(--skl-p-fs-11);
  cursor: pointer;
  transition: color var(--skl-p-t-fast), background var(--skl-p-t-fast), border-color var(--skl-p-t-fast);
}
.pe-hist:hover { color: var(--skl-text); background: var(--skl-panel-2); }
.pe-hist.is-current { color: var(--skl-accent); background: var(--skl-p-active-bg); border-color: var(--skl-accent); }
.pe-hist.is-future { opacity: .45; }

/* ---------- Status bar ---------- */

.pe-status {
  display: flex; align-items: center; gap: var(--skl-p-s-5);
  height: var(--skl-status-h); padding: 0 var(--skl-p-s-4);
  background: var(--skl-panel);
  border-top: 1px solid var(--skl-border);
  font-size: var(--skl-p-fs-11); color: var(--skl-muted);
  font-family: "JetBrains Mono", monospace;
  overflow-x: auto; white-space: nowrap;
  scrollbar-width: thin;
}
.pe-status__item { display: flex; gap: 5px; align-items: center; }
.pe-status__item b { color: var(--skl-text); font-weight: 500; }

/* ---------- Toasts ---------- */

.pe-toasts {
  position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--skl-p-s-2); z-index: 200; align-items: center;
  pointer-events: none;
}
.pe-toast {
  background: var(--skl-panel-2); color: var(--skl-text);
  border: 1px solid var(--skl-border); border-left: 3px solid var(--skl-accent);
  padding: 9px 15px; border-radius: var(--skl-p-r-9); font-size: 12.5px;
  box-shadow: 0 6px 22px rgba(0,0,0,.5);
  animation: pe-in .22s ease;
  max-width: 460px;
}
.pe-toast--error { border-left-color: var(--skl-danger); }
.pe-toast--warn { border-left-color: var(--skl-warn); }
.pe-toast--ok { border-left-color: var(--skl-ok); }
@keyframes pe-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */

.pe-modal {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(5,7,12,.78);
  display: grid; place-items: center; padding: var(--skl-p-s-6);
}
.pe-modal[hidden] { display: none; }
.pe-modal__card {
  background: var(--skl-panel); border: 1px solid var(--skl-border);
  border-radius: var(--skl-radius); padding: var(--skl-p-s-7);
  width: min(430px, 100%); box-shadow: 0 18px 56px rgba(0,0,0,.65);
  max-height: 88vh; overflow-y: auto;
}
.pe-modal__title { margin: 0 0 var(--skl-p-s-5); font-size: 15px; font-weight: 600; }
.pe-modal__row { display: flex; gap: var(--skl-p-s-2); justify-content: flex-end; margin-top: var(--skl-p-s-6); }
.pe-modal__card--wide { width: min(760px, 100%); }

/* ---------- Keyboard shortcuts sheet ---------- */

.pe-shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--skl-p-s-7);
}
.pe-shortcuts h4 {
  margin: 0 0 var(--skl-p-s-3);
  font-size: var(--skl-p-fs-11); text-transform: uppercase; letter-spacing: .09em;
  color: var(--skl-accent); font-weight: 600;
}
.pe-shortcuts dl {
  margin: 0; display: grid;
  grid-template-columns: auto 1fr; gap: var(--skl-p-s-2) var(--skl-p-s-4);
  align-items: baseline;
}
.pe-shortcuts dt { display: flex; gap: 3px; align-items: center; }
.pe-shortcuts dd { margin: 0; color: var(--skl-muted); font-size: var(--skl-p-fs-12); }
.pe-shortcuts kbd {
  display: inline-block; min-width: 22px; text-align: center;
  padding: 3px 6px; border-radius: var(--skl-p-r-6);
  border: 1px solid var(--skl-border-2);
  border-bottom-width: 2px;
  background: var(--skl-p-panel-3);
  color: var(--skl-text);
  font-family: "JetBrains Mono", monospace; font-size: 11px; line-height: 1.2;
}

/* Zoom readout that sits next to the zoom cluster in the top bar. */
.pe-zoom-readout {
  min-width: 46px; text-align: center;
  font-family: "JetBrains Mono", monospace; font-size: var(--skl-p-fs-11);
  color: var(--skl-muted); flex: none;
}

/* Visually hidden but announced to assistive tech. */
.pe-visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Background sampling mode ----------
   While the background sampler is armed the stage shows a crosshair and
   tints the stage edge so the mode is visible, not just announced. */

.pe-stage.pe-bg-picking { cursor: crosshair; }
.pe-stage.pe-bg-picking::after {
  content: "";
  position: absolute; inset: 0;
  border: 2px solid var(--skl-accent);
  pointer-events: none;
  z-index: 6;
}

/* ---------- Panel collapse toggles ----------
   Absolutely positioned so they float over the panel seams instead of
   becoming grid items. Without this they took grid tracks, which pushed the
   tool rail into the right-hand column and squeezed the inspector. */

.collapse-toggle {
  position: absolute;
  top: 8px;
  z-index: 40;
  width: 28px; height: 28px;
  border: 1px solid var(--skl-border);
  border-radius: var(--skl-p-r-8);
  background: rgba(255,255,255,.04);
  color: var(--skl-text);
  cursor: pointer;
  font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  transition: background var(--skl-p-t-fast), border-color var(--skl-p-t-fast);
}
.collapse-toggle:hover { background: rgba(255,255,255,.08); border-color: rgba(138,92,255,.28); }
.collapse-toggle:focus-visible { outline: 2px solid var(--skl-focus); outline-offset: 2px; }

/* Left seam: sits on the tool-rail / inspector boundary. */
.collapse-toggle--left { left: calc(var(--skl-c-rail-w) - 14px); }
/* Right seam: sits on the inspector / stage boundary. */
.collapse-toggle--right { left: calc(var(--skl-c-rail-w) + var(--skl-c-inspector-w) - 14px); }
/* Layers seam: sits on the stage / layers boundary. */
.pe-toggle--layers { left: calc(100% - var(--skl-c-layers-w) - 14px); }

/* Collapsed state: the panel drops out of the grid and the toggle follows. */
.pe-main[data-tools="collapsed"] { grid-template-columns: 0 var(--skl-c-inspector-w) minmax(0,1fr) var(--skl-c-layers-w); }
.pe-main[data-inspector="collapsed"] { grid-template-columns: var(--skl-c-rail-w) 0 minmax(0,1fr) var(--skl-c-layers-w); }
.pe-main[data-layers="collapsed"] { grid-template-columns: var(--skl-c-rail-w) var(--skl-c-inspector-w) minmax(0,1fr) 0; }
.pe-main[data-tools="collapsed"] .pe-tools,
.pe-main[data-inspector="collapsed"] .pe-panel--left,
.pe-main[data-layers="collapsed"] .pe-panel--right { display: none; }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .pe-main {
    grid-template-columns:
      var(--skl-c-rail-w)
      var(--skl-c-panel-w-narrow)
      minmax(0, 1fr)
      var(--skl-c-layers-w-narrow);
  }
  .collapse-toggle--right { left: calc(var(--skl-c-rail-w) + var(--skl-c-panel-w-narrow) - 14px); }
  .pe-toggle--layers { left: calc(100% - var(--skl-c-layers-w-narrow) - 14px); }
}

@media (max-width: 900px) {
  /* Tablet: the layers panel becomes a bottom sheet, the inspector moves
     under the stage. The rail and stage keep their columns. */
  .pe-main {
    grid-template-columns: var(--skl-c-rail-w-mobile) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .pe-tools { grid-column: 1; grid-row: 1; }
  .pe-stage { grid-column: 2; grid-row: 1; }
  .pe-panel--left {
    grid-column: 2; grid-row: 2;
    border-right: none; border-top: 1px solid var(--skl-border);
    max-height: 210px;
  }
  .pe-panel--right { display: none; }
  .collapse-toggle--left { left: calc(var(--skl-c-rail-w-mobile) - 14px); }
  .collapse-toggle--right { left: calc(var(--skl-c-rail-w-mobile) + 50% - 14px); }
  .pe-toggle--layers { display: none; }
}

@media (max-width: 620px) {
  .pe-brand span.pe-brand__text { display: none; }
  .pe-btn span.pe-btn__text { display: none; }
  .pe-btn { padding: 7px 9px; }
  .pe-main { grid-template-columns: var(--skl-c-rail-w-mobile) minmax(0, 1fr); }
  .pe-panel--left { max-height: 170px; padding: var(--skl-p-s-4); }
  .pe-status { gap: var(--skl-p-s-4); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   The tool rail is a secondary TOP bar
   ============================================================
   The rail was a 62px column on the left of the workspace. It is now a
   full-width strip under the top bar, which is how a horizontal toolbar
   is arranged in Photoshop and GIMP.

   What it buys: the canvas gets 62px more WIDTH, and the left column
   holds only the inspector. What it costs: about 60px of height. For a
   photo editor the width is the scarcer resource - the canvas is
   landscape far more often than portrait - so the trade is the right
   way round.

   The DOM order is unchanged: the rail is still the first child of
   .pe-main, so the visual order and the keyboard order agree. */

.pe-main {
  position: relative;
  grid-template-columns:
    var(--skl-c-inspector-w)
    minmax(0, 1fr)
    var(--skl-c-layers-w);
  grid-template-rows: auto minmax(0, 1fr);
}

.pe-tools {
  grid-column: 1 / -1;
  grid-row: 1;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  border-right: none;
  border-bottom: 1px solid var(--skl-border);
  padding: var(--skl-p-s-2) var(--skl-p-s-3);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.pe-panel--left { grid-column: 1; grid-row: 2; }
.pe-stage { grid-column: 2; grid-row: 2; }
.pe-panel--right { grid-column: 3; grid-row: 2; }

/* The tooltip now hangs BELOW the button, because the rail is a row. */
.pe-tool__tip {
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
}

/* The group separators stand up rather than lie down. */
.pe-tool-sep {
  width: 1px;
  height: 24px;
  margin: 0 var(--skl-p-s-2);
}

/* The collapse toggles follow the new seams. The rail's own toggle moves
   to the right end of the top bar, and the inspector's toggle moves to the
   inspector's right edge - which is now the canvas's left edge. */
.collapse-toggle--left {
  left: auto;
  right: 8px;
  top: 8px;
}
.collapse-toggle--right {
  left: calc(var(--skl-c-inspector-w) - 14px);
  top: calc(var(--skl-c-toolbar-h) + 8px);
}
.pe-toggle--layers {
  left: calc(100% - var(--skl-c-layers-w) - 14px);
  top: calc(var(--skl-c-toolbar-h) + 8px);
}

.pe-main[data-tools="collapsed"] {
  grid-template-columns: var(--skl-c-inspector-w) minmax(0, 1fr) var(--skl-c-layers-w);
}
.pe-main[data-inspector="collapsed"] {
  grid-template-columns: 0 minmax(0, 1fr) var(--skl-c-layers-w);
}
.pe-main[data-layers="collapsed"] {
  grid-template-columns: var(--skl-c-inspector-w) minmax(0, 1fr) 0;
}

/* ---- narrower screens ----
   The rail is a row everywhere, so at a narrow width it scrolls sideways
   rather than squeezing. The workspace below it keeps the three columns
   until the tablet layout, where the inspector becomes a bottom sheet. */
@media (max-width: 1180px) {
  .pe-main {
    grid-template-columns:
      var(--skl-c-panel-w-narrow)
      minmax(0, 1fr)
      var(--skl-c-layers-w-narrow);
  }
  .collapse-toggle--right { left: calc(var(--skl-c-panel-w-narrow) - 14px); }
  .pe-toggle--layers { left: calc(100% - var(--skl-c-layers-w-narrow) - 14px); }
}

@media (max-width: 900px) {
  /* Tablet: the top bar of tools, the stage, and the inspector as a
     bottom sheet. The layers panel is dropped. */
  .pe-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .pe-tools { grid-column: 1; grid-row: 1; }
  .pe-stage { grid-column: 1; grid-row: 2; }
  .pe-panel--left {
    grid-column: 1; grid-row: 3;
    border-right: none; border-top: 1px solid var(--skl-border);
    max-height: 210px;
  }
  .pe-panel--right { display: none; }
  .collapse-toggle--left { left: auto; right: 8px; top: 8px; }
  .collapse-toggle--right { left: calc(50% - 14px); top: calc(var(--skl-c-toolbar-h) + 8px); }
  .pe-toggle--layers { display: none; }
}

@media (max-width: 620px) {
  .pe-main { grid-template-columns: minmax(0, 1fr); }
  .pe-panel--left { max-height: 170px; padding: var(--skl-p-s-4); }
}

/* ============================================================
   The inspector is a top ribbon; the rail is back on the left
   ============================================================
   The rail was 62px of width spent on a column of icons, and the
   INSPECTOR - the secondary column beside it - was a 250px strip
   holding thirteen sections with every control squeezed. The
   inspector is now a full-width ribbon under the top bar, so every
   control gets the whole window, and the rail is back at the far
   left where it started.

   The ribbon is TABBED. One section at a time, chosen from the
   strip that was already there as a row of chips, and its fields are
   laid out across the width in a grid that wraps. A ribbon showing
   all thirteen sections at once would be taller than the canvas it
   serves. */

.pe-main {
  grid-template-columns:
    var(--skl-c-rail-w)
    minmax(0, 1fr)
    var(--skl-c-layers-w);
  grid-template-rows: auto minmax(0, 1fr);
}

/* The ribbon spans the whole workspace and sits on top of it. */
.pe-panel--left {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  border-right: none;
  border-bottom: 1px solid var(--skl-border);
  padding: var(--skl-p-s-2) var(--skl-p-s-3);
  overflow: hidden;
}

/* The rail is a column again. */
.pe-tools {
  grid-column: 1;
  grid-row: 2;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border-right: 1px solid var(--skl-border);
  border-bottom: none;
  padding: var(--skl-p-s-2) 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.pe-stage { grid-column: 2; grid-row: 2; }
.pe-panel--right { grid-column: 3; grid-row: 2; }

/* ---- the ribbon's own head ---- */
.pe-inspector-head {
  position: static;
  margin: 0 0 var(--skl-p-s-2);
  padding: 0;
  border-bottom: none;
  background: none;
}
.pe-inspector-nav { margin-bottom: var(--skl-p-s-2); }

/* The chips are tabs now. */
.pe-navchip.is-active {
  background: var(--skl-p-active-bg);
  border-color: var(--skl-accent);
  color: var(--skl-accent);
}

/* Only the chosen section is shown, and its fields run across the width. */
.pe-panel--left > .pe-panel__section { display: none; }
.pe-panel--left > .pe-panel__section.is-ribbon-active {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: var(--skl-p-s-2) var(--skl-p-s-3);
  align-items: end;
}
.pe-panel__section--tool:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: var(--skl-p-s-2) var(--skl-p-s-3);
  align-items: end;
  order: -1;
}
.pe-panel--left > .pe-panel__section > .pe-panel__title {
  grid-column: 1 / -1;
  margin: 0;
  font-size: var(--skl-p-fs-11);
}

/* Only the controls take clicks back. */
.pe-panel--left > .pe-panel__section.is-ribbon-active button,
.pe-panel--left > .pe-panel__section.is-ribbon-active input,
.pe-panel--left > .pe-panel__section.is-ribbon-active select,
.pe-panel--left > .pe-panel__section.is-ribbon-active textarea,
.pe-panel--left > .pe-panel__section.is-ribbon-active label,
.pe-panel--left > .pe-panel__section.is-ribbon-active canvas,
.pe-panel--left > .pe-panel__section.is-ribbon-active .pe-chip { pointer-events: auto; }
/* A field that should span the ribbon rather than sit in one column. */
.pe-panel--left > .pe-panel__section .pe-field--wide { grid-column: 1 / -1; }
.pe-panel--left > .pe-panel__section .pe-checks,
.pe-panel--left > .pe-panel__section .pe-hint,
.pe-panel--left > .pe-panel__section .pe-row { grid-column: 1 / -1; }

/* The curve editor needs room, so its tab gets a taller ribbon. */
.pe-main[data-ribbon="curves-section"] { grid-template-rows: 340px minmax(0, 1fr); }
.pe-main[data-ribbon="curves-section"] .pe-curve { max-width: 320px; }

/* The section chevrons are hidden: the tab strip does that job now,
   and they were landing on top of the section titles. */
.pe-panel--left .pe-section-toggle { display: none; }

/* The ribbon is a FIXED height, not just a capped one. A ribbon that
   resized with its content would resize the stage, which re-fits the canvas
   and changes the zoom - so the canvas lurched every time a tab was
   switched, and anything positioned by pixel (a background sample) landed
   in the wrong place. It is an options bar, not a panel: 300px took a
   third of a 900px viewport. */
.pe-panel--left { height: 220px; max-height: 220px; }
.pe-panel--left > .pe-panel__section.is-ribbon-active,
.pe-panel__section--tool:not([hidden]) {
  overflow-y: auto;
  padding-right: var(--skl-p-s-2);
}

/* ---- the rail's own details ---- */
.pe-tool__tip {
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
}
.pe-tool-sep {
  width: 24px;
  height: 1px;
  margin: var(--skl-p-s-2) 0;
}

/* ---- the collapse toggles ---- */
/* The rail's own toggle lives INSIDE the rail, in a padding row of
   its own. It used to be positioned against the whole workspace, from
   the top of the bar: when the bar collapsed that measurement went to
   zero and the toggle jumped up into the top bar and covered it, and it
   sat three pixels over the rail's first tool. */
.pe-tools { position: relative; padding-top: 30px; }
.collapse-toggle--left {
  left: calc(100% - 14px);
  top: 4px;
  right: auto;
}
.collapse-toggle--right {
  left: auto;
  right: 8px;
  top: 8px;
}
.pe-toggle--layers {
  left: calc(100% - var(--skl-c-layers-w) - 14px);
  top: calc(var(--skl-c-toolbar-h) + 8px);
}

/* ---- narrower screens ---- */
@media (max-width: 1180px) {
  .pe-main {
    grid-template-columns:
      var(--skl-c-rail-w)
      minmax(0, 1fr)
      var(--skl-c-layers-w-narrow);
  }
  .pe-toggle--layers { left: calc(100% - var(--skl-c-layers-w-narrow) - 14px); }
}

@media (max-width: 900px) {
  /* Tablet: the ribbon on top, the rail and the stage below, and the
     inspector's own columns collapse into the ribbon. */
  .pe-main {
    grid-template-columns: var(--skl-c-rail-w-mobile) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .pe-panel--left { grid-column: 1 / -1; grid-row: 1; }
  .pe-tools { grid-column: 1; grid-row: 2; }
  .pe-stage { grid-column: 2; grid-row: 2; }
  .pe-panel--right { display: none; }
  .collapse-toggle--left { left: calc(var(--skl-c-rail-w-mobile) - 14px); top: 8px; }
  .collapse-toggle--right { left: auto; right: 8px; top: 8px; }
  .pe-toggle--layers { display: none; }
}

@media (max-width: 620px) {
  .pe-main { grid-template-columns: var(--skl-c-rail-w-mobile) minmax(0, 1fr); }
  /* The ribbon is bounded on a phone. Unbounded it ate the whole viewport
     and left the stage with NO height at all. */
  .pe-panel--left { max-height: 38vh; }
  .pe-main[data-ribbon="curves-section"] { grid-template-rows: 38vh minmax(0, 1fr); }
}

/* ============================================================
   The ribbon is a BAR plus an overlay PANEL
   ============================================================
   The bar is one row of tabs, with the tool's own options under it,
   and it is content-driven - nothing is clipped and nothing is a fixed
   height. The panel for the chosen section drops OVER the canvas, so
   opening or closing it never resizes the canvas and the page never
   scrolls. */

.pe-main { position: relative; }

/* The stage NEVER changes size because of a tab. The old rules gave the
   curves tab a 340px grid row and re-fitted the canvas, which is the
   lurch this model exists to remove. */
.pe-main[data-ribbon] { grid-template-rows: auto minmax(0, 1fr); }

/* The bar. */
.pe-panel--left {
  /* The bar stops at the layers panel. It used to span it, so the tool's
     own options ran underneath the studio's properties column and were
     painted over by it. */
  grid-column: 1 / 3;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  /* No gap. The gap only applied when the bar had TWO children - the
     head, and the tool-options row - so the bar was 8px taller with a
     tool that has controls than with one that does not, and the rail
     and the canvas moved every time a tool was picked. The two rows are
     mutually exclusive, so the gap bought nothing. */
  gap: 0;
  border-right: none;
  border-bottom: 1px solid var(--skl-border);
  background: var(--skl-panel);
  padding: var(--skl-p-s-2) var(--skl-p-s-3);
  height: auto;
  max-height: none;
  overflow: visible;
}

.pe-inspector-head {
  position: static;
  margin: 0;
  padding: 0;
  border-bottom: none;
  background: none;
}

/* The tab strip WRAPS. Forcing ten chips into one row and clipping the
   overflow was the old behaviour, and it hid tabs on a narrow screen. */
.pe-inspector-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--skl-p-s-1);
  margin: 0;
  overflow: visible;
}

/* The panel is a WINDOW over the canvas, not a band under the top
   bar. It is what Photoshop's Levels and Curves dialogs are: something
   the user opened, with a title bar and a close button, that can be
   dragged out of the way. Drawn as a full-width band it read as more
   bar and it covered the top of the image. */
.pe-stage { position: relative; }

/* The panels that moved into the stage are hidden unless one of them is
   the chosen section. The rule that hid them was keyed on the bar they
   left, so they all piled up in the stage at once. */
.pe-stage > .pe-panel__section { display: none; }

.pe-panel--left > .pe-panel__section.is-ribbon-active,
.pe-stage > .pe-panel__section.is-ribbon-active {
  display: grid;
  position: absolute;
  /* A small window in the middle of the canvas, the way Photoshop opens
     its Levels and Curves dialogs. NOT a band under the top bar: a band
     read as more bar and covered the top of the image - half the screen
     from the top - and there was no way to work under it. */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: min(92%, 380px);
  max-height: 72vh;
  overflow-y: auto;
  z-index: 30;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--skl-p-s-2);
  align-items: stretch;
  padding: var(--skl-p-s-3);
  background: var(--skl-panel);
  border: 1px solid var(--skl-border);
  border-radius: var(--skl-p-r-8);
  box-shadow: 0 24px 64px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.4);
}

/* The title row becomes the window's title bar. A section's title
   sits in a row, and the row's chevron - a control for a scrolling
   column, meaningless in a window - landed on top of the close button. */
.pe-stage > .pe-panel__section.is-ribbon-active > .pe-panel__title-row,
.pe-stage > .pe-panel__section.is-ribbon-active > .pe-panel__title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--skl-p-s-2);
  margin: calc(var(--skl-p-s-3) * -1) calc(var(--skl-p-s-3) * -1) var(--skl-p-s-2);
  padding: var(--skl-p-s-2) var(--skl-p-s-3);
  font-size: var(--skl-p-fs-11);
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--skl-muted);
  background: var(--skl-panel-2, rgba(255,255,255,.03));
  border-bottom: 1px solid var(--skl-border);
  cursor: grab;
  user-select: none;
}
.pe-stage > .pe-panel__section.is-ribbon-active > .pe-panel__title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--skl-p-s-2);
  margin: calc(var(--skl-p-s-3) * -1) calc(var(--skl-p-s-3) * -1) var(--skl-p-s-2);
  padding: var(--skl-p-s-2) var(--skl-p-s-3);
  font-size: var(--skl-p-fs-11);
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--skl-muted);
  background: var(--skl-panel-2, rgba(255,255,255,.03));
  border-bottom: 1px solid var(--skl-border);
  cursor: grab;
  user-select: none;
}
.pe-stage > .pe-panel__section.is-ribbon-active > .pe-panel__title:active { cursor: grabbing; }

/* The close button. */
.pe-stage > .pe-panel__section.is-ribbon-active .pe-panel__close {
  margin-left: auto;
  flex: none;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--skl-border);
  border-radius: var(--skl-p-r-8);
  background: none;
  color: var(--skl-muted);
  cursor: pointer;
  font-size: 10px;
}
.pe-stage > .pe-panel__section.is-ribbon-active .pe-panel__close:hover {
  color: var(--skl-text);
  border-color: var(--skl-accent);
}
.pe-stage > .pe-panel__section.is-ribbon-active .pe-panel__close:focus-visible {
  outline: 2px solid var(--skl-focus);
  outline-offset: 2px;
}

/* The chevron is for a scrolling column. In a window it means
   nothing, and it sat on the close button. */
.pe-stage > .pe-panel__section.is-ribbon-active .pe-section-toggle { display: none; }

/* A field that should span the window rather than sit in one column. */
.pe-stage > .pe-panel__section.is-ribbon-active .pe-field--wide,
.pe-stage > .pe-panel__section.is-ribbon-active .pe-checks,
.pe-stage > .pe-panel__section.is-ribbon-active .pe-hint,
.pe-stage > .pe-panel__section.is-ribbon-active .pe-row { grid-column: 1 / -1; }

/* The curve editor fits a narrow dialog. */
.pe-stage > .pe-panel__section.is-ribbon-active .pe-curve { max-width: 100%; }

/* The tool's own options stay in the bar - they are contextual and
   belong where the tool is chosen - and the row is a FIXED height that
   scrolls sideways. Its height used to follow its content, so picking a
   different tool moved the tool rail and the canvas. */
.pe-panel__section--tool:not([hidden]) {
  display: grid;
  /* Above the autosave banner, which is an overlay in the same bar and
     used to cover the gradient's controls. */
  position: relative;
  z-index: 3;
  grid-auto-flow: column;
  /* The columns are sized to their CONTENT. A fixed width was the
     cause of a row overflowing its column and painting over the control
     in the next one - the font dropdown was covered by a row beside
     it, and could not be opened. */
  /* BOUNDED. The columns were sized to their content, which made a tool
     with many controls - the text tool has ten - run past the end of the
     bar and under the layers panel, where they were painted over and
     could not be reached. */
  grid-auto-columns: minmax(140px, 200px);
  gap: var(--skl-p-s-2) var(--skl-p-s-3);
  align-items: end;
  /* The height is CLAMPED, minimum and maximum. A flex item's automatic
     minimum size is its content's, so a plain height was silently
     overridden and the row grew with its controls - which moved the
     tool rail and the canvas every time a tool was picked. */
  /* 60px is what the tallest control in the row needs: a label and a
     34px select. */
  height: 60px;
  min-height: 60px;
  max-height: 60px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  /* No margin. A section carries a 20px bottom margin for a scrolling
     column, and here it made the bar 20px taller with a tool that has
     controls than with one that does not - so the rail and the canvas
     moved every time a tool was picked. */
  margin: 0;
}
.pe-panel__section--tool:not([hidden])::-webkit-scrollbar { height: 4px; }
.pe-panel__section--tool:not([hidden])::-webkit-scrollbar-thumb {
  background: var(--skl-border);
  border-radius: 2px;
}

/* Collapsed: the bar keeps its TAB STRIP and loses everything else.
   The control that collapses a thing is never inside the thing it
   collapses: the chevron lives in the strip, so there is always a way
   back. The canvas takes the tool-options row back - 65px. */
.pe-main[data-ribbon-collapsed="1"] .pe-panel--left > .pe-panel__section,
.pe-main[data-ribbon-collapsed="1"] .pe-panel--left > .pe-inspector-head > .pe-panel__section--pinned {
  display: none;
}
.pe-main[data-ribbon-collapsed="1"] .pe-panel--left {
  padding-top: 0;
  padding-bottom: 0;
}
.pe-main[data-ribbon-collapsed="1"] .pe-inspector-nav {
  padding: 0;
  margin: 0;
}

/* The pinned hint is ONE row: the title beside the text, and the text
   truncated rather than wrapped. Wrapping made the bar taller every time
   the hint was a sentence.

   It is also the SAME height as the tool-options row. The bar was 74px
   with the move tool and 96px with the brush, because these two rows had
   different heights, so the tool rail and the canvas moved every time a
   tool was picked. The bar's height must not depend on what is in it. */
.pe-panel--left .pe-panel__section--pinned {
  height: 60px;
  min-height: 60px;
  max-height: 60px;
  align-items: center;
  overflow: hidden;
  margin: 0;
}
.pe-panel--left .pe-panel__section--pinned {
  display: flex;
  align-items: baseline;
  gap: var(--skl-p-s-2);
  margin: 0;
}
.pe-panel--left .pe-panel__section--pinned .pe-panel__title {
  flex: none;
  margin: 0;
  font-size: var(--skl-p-fs-11);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
.pe-panel--left .pe-panel__section--pinned {
  /* The pinned row is the OPTIONS ROW: the hint and the current tool's
     controls sit side by side in it. It is one row of a FIXED height, so
     the bar is the same height whatever the tool - which is what stops
     the tool rail and the canvas moving when a tool is picked. */
  height: 60px;
  min-height: 60px;
  max-height: 60px;
  flex-direction: row;
  align-items: center;
  gap: var(--skl-p-s-3);
  overflow: hidden;
  margin: 0;
}
.pe-panel--left .pe-panel__section--pinned > .pe-panel__title { flex: none; margin: 0; }
.pe-panel--left .pe-panel__section--pinned > .pe-hint {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A tool with its own controls does not also need the hint. */
.pe-panel--left[data-tool-controls="1"] .pe-panel__section--pinned { display: none; }

/* The collapse toggle sits at the end of the tab strip. */
/* A row of controls inside the tool row: its CHILDREN are the grid's
   items, so each control gets its own column. As one flex row it was a
   single column of a fixed width, so it overflowed and painted over the
   control in the next column - the font dropdown was covered and could
   not be opened. */
.pe-panel__section--tool:not([hidden]) .pe-row {
  display: contents;
}

/* A field, and the control inside it, are bounded by their column. A
   control wider than its field painted over the control in the next
   column: the font dropdown and the content field were covered. */
.pe-panel__section--tool:not([hidden]) > * { flex: 0 0 auto; }
.pe-panel__section--tool:not([hidden]) .pe-row > * { flex: 0 0 auto; }
.pe-panel__section--tool:not([hidden]) .pe-field { min-width: 0; }

/* A wide field spans EVERY column in a column-flow grid, which is how
   it came to be laid over the controls beside it - the font dropdown,
   the content field and the size field were all covered by it. In this
   grid a field is one column and does not span. */
.pe-panel__section--tool:not([hidden]) .pe-field--wide,
.pe-panel__section--tool:not([hidden]) .pe-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--skl-p-s-2);
}
.pe-panel__section--tool:not([hidden]) .pe-row > * { flex: 0 0 auto; }
.pe-panel__section--tool:not([hidden]) .pe-field > * { max-width: 100%; }
.pe-panel__section--tool:not([hidden]) .pe-field input,
.pe-panel__section--tool:not([hidden]) {
  /* A FLEX row, not a grid. Flex items do not overlap, overflow works,
     and a wide field's grid-column is ignored - so nothing can be laid
     over a control beside it. A grid with a column flow put a wide field
     across every column, and display:contents on a row destroyed that
     row's overflow - so the controls that did not fit spilled out of
     the bar, under the layers panel, and were painted over. */
  display: flex;
  flex-wrap: nowrap;
  gap: var(--skl-p-s-2) var(--skl-p-s-3);
  align-items: end;
  /* The height is CLAMPED, minimum and maximum. A flex item's automatic
     minimum size is its content's, so a plain height was silently
     overridden and the row grew with its controls - which moved the
     tool rail and the canvas every time a tool was picked. 60px is what
     the tallest control in the row needs: a label and a 34px select. */
  height: 60px;
  min-height: 60px;
  max-height: 60px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  /* No margin. A section carries a 20px bottom margin for a scrolling
     column, and here it made the bar 20px taller with a tool that has
     controls than with one that does not - so the rail and the canvas
     moved every time a tool was picked. */
  margin: 0;
  /* Above the autosave banner, which is an overlay in the same bar and
     used to cover the gradient's controls. */
  position: relative;
  z-index: 3;
}

.pe-ribbon-toggle {
  flex: none;
  align-self: center;
  margin-left: auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--skl-border);
  border-radius: var(--skl-p-r-8);
  color: var(--skl-muted);
  cursor: pointer;
  font-size: 11px;
}
.pe-ribbon-toggle:hover { color: var(--skl-text); border-color: var(--skl-accent); }
.pe-ribbon-toggle:focus-visible { outline: 2px solid var(--skl-focus); outline-offset: 2px; }

@media (max-width: 620px) {
  /* The bar is content-driven, so it is already short; it is still
     bounded so it cannot swallow a phone. */
  .pe-panel--left { max-height: 40vh; }
  .pe-panel--left > .pe-panel__section.is-ribbon-active { max-height: 52vh; }
}

/* ============================================================
   The tool-options row holds one line of controls
   ============================================================
   A chip grid in the options row is a LINE of chips. A grid in an
   indefinite width stacks its chips in one column, so the six shape
   chips were six rows tall - taller than the row, so they overflowed
   upwards over the tab strip and were painted over, and the shape
   chips stopped working. */
.pe-panel__section--tool:not([hidden]) .pe-chip-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--skl-p-s-2);
  align-items: center;
}

/* The text field is one line high in the options row. It is a
   three-row textarea, which is taller than the row. */
.pe-panel__section--tool:not([hidden]) .pe-textarea {
  height: 34px;
  min-height: 34px;
  resize: none;
}

/* A swatch is one line high. The gradient controls were taller than the
   options row, so they overflowed upwards into the tab strip, were
   painted over by it, and could not be reached. */
.pe-panel__section--tool:not([hidden]) [id^="gradient-"],
.pe-panel__section--tool:not([hidden]) [class*="gradient"] {
  max-height: 32px;
  min-height: 0;
}

/* The autosave banner is an overlay in the property bar, and it was
   painted over the tool's own controls - the gradient's colour control
   could not be reached. The options row sits above it. */
.pe-panel--left .pe-autosave { z-index: 1; }

/* The gradient colours and its shapes are a ROW, like every other set of
   controls in the bar. As a plain div it was one tall flex item, and it
   overflowed the options row over the canvas. */
.pe-panel__section--tool:not([hidden]) #gradient-colours-field {
  display: flex;
  align-items: end;
  gap: var(--skl-p-s-2) var(--skl-p-s-3);
}
.pe-panel__section--tool:not([hidden]) {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--skl-p-s-2) var(--skl-p-s-3);
  height: 60px;
  min-height: 60px;
  max-height: 60px;
  flex: 0 0 auto;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0;
  order: 0;
}

.pe-stage > .pe-panel__section.is-ribbon-active > .pe-panel__title .pe-panel__close {
  margin-left: auto;
  flex: none;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--skl-border);
  border-radius: var(--skl-p-r-8);
  background: none;
  color: var(--skl-muted);
  cursor: pointer;
  font-size: 10px;
}
.pe-stage > .pe-panel__section.is-ribbon-active .pe-panel__close:hover {
  color: var(--skl-text);
  border-color: var(--skl-accent);
}
.pe-stage > .pe-panel__section.is-ribbon-active .pe-panel__close:focus-visible {
  outline: 2px solid var(--skl-focus);
  outline-offset: 2px;
}
