:root {
  color-scheme: light;
  /* Labaih brand system: white first, black type, one nautical-blue accent. */
  --bg: #f6f6f4;
  --panel: #ffffff;
  --panel-soft: #fafafa;
  --panel-mid: #f0f0ee;
  --ink: #000000;
  --muted: #6f736f;
  --line: rgba(0, 0, 0, 0.1);
  --line-strong: rgba(0, 0, 0, 0.22);
  --brand-blue: #01004a; /* nautical blue — the ONLY accent (thin rules, numbers, small buttons) */
  --green: #01004a; /* deprecated: no greens — mapped to the brand accent */
  --blue: #01004a; /* deprecated: no extra blues — mapped to the brand accent */
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.07);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --font-display: "Lora", Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.35;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 88px minmax(0, 1fr);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto minmax(360px, 1fr);
  align-items: center;
  gap: 22px;
  padding: 18px 28px;
  background: var(--bg);
}

.topbar-left,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-actions {
  justify-content: flex-end;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
}

.brand img {
  display: block;
  width: auto;
  max-width: 156px;
  height: 34px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.exit-button,
.icon-button,
.save-button,
.primary-button,
.outline-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 2px;
  padding: 0 20px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.exit-button,
.icon-button,
.outline-button {
  border: 1px solid var(--line-strong);
  background: #fff;
}

.exit-button {
  min-width: 110px;
}

.icon-button {
  width: 44px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  font-size: 22px;
}

.icon-button.muted {
  color: #8d918e;
}

.save-button {
  border: 1px solid transparent;
  background: #fff;
  box-shadow: var(--shadow);
}

.save-mark {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: linear-gradient(135deg, #000 0 50%, var(--brand-blue) 50% 100%);
}

.primary-button {
  border: 1px solid #000;
  background: #000;
  color: #fff;
}

.outline-button {
  border: 2px solid #000;
}

.exit-button:hover,
.outline-button:hover,
.save-button:hover {
  background: #f8f8f7;
}

.primary-button:hover,
.save-button:hover {
  transform: translateY(-1px);
}

.full-width {
  width: 100%;
}

/* Vertical rhythm for stacked action buttons inside drawer panels */
.drawer-panel .full-width {
  margin-top: 14px;
}

.drawer-panel .full-width + .full-width {
  margin-top: 10px;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 110px minmax(340px, 460px) minmax(520px, 1fr) 286px;
  transition: grid-template-columns 220ms ease;
}

/* Collapsed: drawer column shrinks to 0 and the stage expands. */
.workspace.drawer-collapsed {
  grid-template-columns: 110px 0 minmax(520px, 1fr) 286px;
}

.workspace.drawer-collapsed .control-drawer {
  opacity: 0;
  pointer-events: none;
}

/* Colors panel, groups-only stage: until a group is clicked (which adds
   .show-palette), the drawer hugs the groups column instead of reserving the
   full palette width — otherwise the empty palette track shows as a white panel.
   :where() keeps specificity at (0,1,0) so the per-breakpoint .workspace rules
   below still cascade by source order, and .drawer-collapsed still wins. */
.workspace:has(:where(.colors-panel:not([hidden]):not(.show-palette))) {
  grid-template-columns: 110px 201px minmax(520px, 1fr) 286px;
}

.rail {
  align-self: start;
  justify-self: center;
  width: 88px;
  margin-top: 42px;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-radius: 8px;
  background: #000;
  color: #fff;
  z-index: 5;
}

.rail-item {
  min-height: 72px;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 12px 4px;
  color: #8e9290;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.03em;
  text-align: center;
  text-transform: uppercase;
}

.rail-item.active,
.rail-item:hover {
  color: #fff;
}

.rail-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: currentColor;
}

.rail-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.rail-reset {
  min-height: 44px;
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.control-drawer {
  min-width: 0;
  align-self: start;
  justify-self: start;
  width: 100%;
  margin: 14px 0 20px;
  max-height: calc(100vh - 122px);
  overflow: hidden auto;
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
}

/* Desktop: the Designs (placements) and Additional panels are sparse, so shrink
   the white card to fit instead of stretching it across the full drawer column. */
@media (min-width: 861px) {
  .control-drawer[data-active="design"],
  .control-drawer[data-active="features"] {
    width: 300px;
    max-width: 100%;
  }
}

.drawer-panel {
  height: auto;
}

.drawer-head {
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.drawer-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #4d504e;
  font-size: 26px;
  line-height: 1;
}

.drawer-back {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #4d504e;
  font-size: 30px;
  line-height: 1;
}

.drawer-back:hover,
.drawer-close:hover {
  color: #000;
}

.tool-list {
  display: flex;
  flex-direction: column;
}

.tool-item {
  min-height: 64px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  color: #2c2f2d;
  text-align: left;
}

.tool-item:hover { color: #000; }

.tool-item .tool-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 900;
}

.tool-item strong {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.color-layout {
  min-height: 0;
  display: flex;
  align-items: stretch;
}

.group-column,
.palette-column {
  padding: 8px 18px 20px;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.group-column {
  flex: 0 0 200px;
  border-right: 1px solid var(--line);
}

.palette-column {
  flex: 1 1 248px;
  min-width: 0; /* fill the space left by the groups column; never force overflow */
  display: none; /* hidden until a group is clicked (Reform cascade) */
}

.colors-panel.show-palette .palette-column {
  display: flex;
}

.column-head {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 -18px 4px;
  border-bottom: 1px solid var(--line);
}

.column-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: transparent;
  color: #4d504e;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border: 0;
}

.column-close:hover { color: #000; }

/* Mobile-only "back to groups" chevron in the palette header. */
.palette-back { display: none; }
.m-strip-arrow { display: none; } /* group-strip arrows: mobile only (shown in the @860 block) */
@media (max-width: 860px) {
  .colors-panel .column-head { justify-content: space-between; }
  .palette-back {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    color: #4d504e;
    font-size: 28px;
    line-height: 1;
  }
}

.panel-title {
  min-height: 34px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 3px;
  background: var(--panel-mid);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Rib Colour 1 (base) / Colour 2 (stripe) sub-selector — shown only for the Rib group. */
.rib-targets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 14px;
}
.rib-targets[hidden] { display: none; } /* the hidden attr must win over display:grid */
.rib-target {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  color: #6c706d;
}
.rib-target.active {
  background: #000;
  color: #fff;
  border-color: #000;
}

.group-list,
.placement-list,
.feature-stack {
  display: grid;
  gap: 8px;
}

.group-button {
  min-height: 88px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  text-align: left;
}

.group-button.active,
.group-button:hover {
  color: #000;
}

.group-thumb {
  width: 54px;
  height: 66px;
  position: relative;
  margin: 0 auto;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.group-thumb-canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* Fallback CSS-drawn thumbs only show if the mask thumbnails haven't loaded. */
.group-button:not(.has-thumb-image) .group-thumb::before,
.group-button:not(.has-thumb-image) .group-thumb::after {
  content: "";
  position: absolute;
  background: var(--thumb-main, #111);
}

.group-button:not(.has-thumb-image) .group-thumb::before {
  left: 14px;
  top: 12px;
  width: 26px;
  height: 42px;
  border-radius: 8px 8px 4px 4px;
}

.group-button:not(.has-thumb-image) .group-thumb::after {
  left: 5px;
  top: 18px;
  width: 44px;
  height: 36px;
  border-radius: 20px 20px 14px 14px;
  background:
    linear-gradient(90deg, var(--thumb-sleeves, #111) 0 20%, transparent 20% 80%, var(--thumb-sleeves, #111) 80%),
    transparent;
}

.group-button strong {
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.assistant-button {
  width: 100%;
  min-height: 43px;
  border-radius: 4px;
  background: #000;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.selected-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 12px;
  font-size: 13px;
}

.selected-swatch {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: #111;
}

.selected-row strong {
  flex: 1;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.favorite-button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #676b68;
  font-size: 20px;
}

.favorite-button.active {
  color: var(--brand-blue);
}

.search-box {
  position: relative;
  display: block;
}

.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 36px 0 12px;
  border: 0;
  background: var(--panel-mid);
  color: var(--ink);
}

.search-box span {
  position: absolute;
  right: 12px;
  top: 50%;
  color: #565a57;
  transform: translateY(-50%);
}

.section-label {
  margin: 16px 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.swatch-row,
.palette-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.swatch,
.palette-swatch {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(0, 0, 0, 0.32);
  border-radius: 50%;
  background: var(--swatch, #fff);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
  transition: transform 130ms ease, box-shadow 130ms ease;
}

.palette-grid {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line-strong);
}

.swatch:hover,
.palette-swatch:hover {
  transform: scale(1.08);
}

.palette-swatch.active {
  box-shadow: 0 0 0 3px #000, inset 0 0 0 2px #fff;
}

.palette-swatch.hidden {
  display: none;
}

.custom-color {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input[type="color"] {
  width: 48px;
  height: 34px;
  border: 1px solid var(--line-strong);
  background: transparent;
  padding: 2px;
}

.drawer-panel:not(.colors-panel) {
  padding: 0 26px 28px;
}

.drawer-panel:not(.colors-panel) .drawer-head {
  margin: 0 -26px 24px;
}

.placement-button {
  min-height: 64px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: #5f625f;
  text-align: left;
}

.placement-button.active,
.placement-button:hover {
  color: #000;
}

.placement-plus {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #dededd;
  color: #747875;
  font-size: 24px;
}

.placement-button strong {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.field-label,
.split-fields span {
  display: block;
  margin: 16px 0 7px;
  color: #606461;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.segmented-control button {
  min-height: 38px;
  border-radius: 2px;
  color: #6c706d;
  font-size: 12px;
  font-weight: 900;
}

.segmented-control button.active {
  background: #000;
  color: #fff;
}

select,
input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: #fff;
  color: #000;
}

.split-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 14px;
  align-items: end;
}

/* Design editor: 3-tab type switch (Text / Number / Logo) reusing the
   segmented-control look, then a 50/50 Content | Font row above Size | Color. */
.design-tabs {
  margin: 4px 0 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr; /* desktop: stacked (drawer is narrow); mobile goes 50/50 */
  gap: 12px;
  align-items: start;
  margin-bottom: 4px;
}

.field-col {
  display: block;
  min-width: 0;
}

.field-row .field-label {
  margin-top: 0;
}

input[type="range"] {
  width: 100%;
  accent-color: #000;
}

.upload-box {
  min-height: 118px;
  margin-bottom: 6px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  background: var(--panel-soft);
  text-align: center;
  cursor: pointer;
}

.upload-box input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-box strong {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.upload-box span {
  color: var(--muted);
  font-size: 12px;
}

.toggle-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  font-weight: 800;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: #000;
}

.stage {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 84px;
  grid-template-rows: minmax(0, 1fr) 42px;
  align-items: center;
  background:
    radial-gradient(circle at 50% 46%, #ffffff 0 46%, #f7f7f5 100%),
    #f7f7f5;
  overflow: hidden;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 90%, rgba(0, 0, 0, 0.05) 0, rgba(0, 0, 0, 0) 44%);
  pointer-events: none;
}

.canvas-area {
  position: relative;
  z-index: 1;
  grid-column: 2;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
}

#designerCanvas {
  display: block;
  width: min(112%, 1100px);
  height: auto;
  max-height: calc(100vh - 164px);
  aspect-ratio: 4 / 3;
  touch-action: none;
  cursor: default;
}

#designerCanvas.dragging {
  cursor: grabbing;
}

.view-label {
  position: absolute;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #555956;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.view-arrow {
  position: relative;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  justify-self: center;
  border: 2px solid #000;
  border-radius: 50%;
  background: #fff;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}

.view-dots {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.view-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  padding: 0; /* these are <button>s — UA padding would otherwise make them 12px ovals */
  box-sizing: border-box;
  border-radius: 50%;
  background: #c9ccca;
}

.view-dot.active {
  background: #000;
}

.order-panel {
  min-width: 0;
  padding: 42px 24px 24px 0;
  overflow-y: auto;
}

.order-card,
.meta-card,
.support-card {
  overflow: hidden;
  border-radius: 4px;
  background: #eee;
}

.order-card h3 {
  margin: 0;
  padding: 18px 18px;
  border-bottom: 1px solid #fff;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: center;
}

.fabric-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-bottom: 1px solid #fff;
  text-transform: uppercase;
}

.fabric-row .recycle {
  color: var(--brand-blue);
  font-size: 27px;
}

.fabric-row em {
  margin-left: 10px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f7f7f7;
  color: #777;
  font-family: Georgia, serif;
  font-style: italic;
}

.price-row {
  padding: 17px 16px;
  display: grid;
  place-items: center;
  gap: 4px;
  border-bottom: 1px solid #fff;
}

.price-row span {
  color: #8b8f8c;
  font-size: 23px;
  text-decoration: line-through;
}

.price-row strong {
  font-size: 22px;
  font-weight: 700;
}

.price-row small {
  color: var(--brand-blue);
  font-size: 12px;
}

.quantity-row {
  display: grid;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid #fff;
}

.quantity-row label {
  color: #737876;
  font-weight: 800;
  text-align: center;
}

.qty-control {
  display: grid;
  grid-template-columns: 44px 66px 44px;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.qty-control button {
  height: 42px;
  font-size: 27px;
}

.qty-control input {
  height: 42px;
  border: 1.5px solid var(--brand-blue);
  background: #fff;
  font-size: 17px;
  font-weight: 900;
  text-align: center;
}

.quantity-row p {
  margin: 0;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  font-size: 12px;
  line-height: 1.12;
}
.quantity-row p[hidden] { display: none; } /* the hidden attr must win over display:grid */

.ok-dot,
.info-dot {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.ok-dot {
  background: var(--brand-blue);
}

.info-dot {
  background: var(--blue);
  font-family: Georgia, serif;
  font-style: italic;
}

.total-row {
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 18px;
}

.total-row strong {
  font-size: 21px;
}

.total-row span {
  font-size: 12px;
}

.meta-card {
  margin-top: 14px;
}

.meta-card div {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #fff;
}

.meta-card div:last-child {
  border-bottom: 0;
}

.meta-card span {
  font-weight: 800;
  line-height: 1;
}

.meta-card small {
  display: block;
  font-weight: 600;
}

.meta-card strong {
  font-size: 24px;
}

.support-card {
  margin-top: 12px;
  padding: 16px;
  text-align: center;
}

.support-card span {
  display: block;
  color: #777b78;
  font-size: 12px;
}

.support-card strong {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  text-transform: uppercase;
}

@media (max-width: 1500px) {
  .workspace {
    grid-template-columns: 92px minmax(300px, 420px) minmax(500px, 1fr);
  }

  .workspace:has(:where(.colors-panel:not([hidden]):not(.show-palette))) {
    grid-template-columns: 92px 201px minmax(500px, 1fr);
  }

  .color-layout {
    grid-template-columns: 142px minmax(0, 1fr);
  }

  .order-panel {
    display: none;
  }
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 1fr auto 1fr;
  }

  .topbar-left {
    display: none;
  }

  .workspace {
    grid-template-columns: 86px minmax(290px, 360px) minmax(430px, 1fr);
  }

  .workspace:has(:where(.colors-panel:not([hidden]):not(.show-palette))) {
    grid-template-columns: 86px 201px minmax(430px, 1fr);
  }
}

/* ============================================================
   MOBILE — app-style layout (built per ui-ux-pro-max rules):
   compact sticky top bar, a fixed bottom tab bar, and panels as
   bottom sheets. Uses svh + env(safe-area-inset-*) so the fixed
   bars are never hidden behind mobile browser chrome / gesture bar.
   ============================================================ */
@media (max-width: 860px) {
  :root {
    --rail-h: 60px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
  }

  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  /* svh/dvh instead of 100vh so the bottom bar stays on-screen (skill: viewport-units). */
  .app-shell {
    height: auto;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    grid-template-rows: none;
  }

  /* Shrink-to-fit guards so nothing widens the shell past the viewport. */
  .app-shell,
  .topbar,
  .topbar-left,
  .topbar-actions,
  .workspace,
  .stage,
  .control-drawer,
  .order-panel {
    min-width: 0;
    max-width: 100%;
  }

  /* ---- Sticky compact top bar (safe-area aware) ---- */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 12px;
    padding-top: calc(6px + var(--safe-t));
    background: var(--bg);
  }
  .brand { display: none; }
  .topbar-left { display: flex; gap: 6px; }
  .topbar-actions { display: flex; gap: 6px; }
  .m-hide { display: none; } /* drop secondary words from button labels on mobile */
  .exit-button,
  .icon-button,
  .save-button,
  .primary-button,
  .outline-button {
    min-height: 44px; /* skill: touch target >= 44px */
    white-space: nowrap;
  }
  .icon-button { width: 40px; padding: 0; font-size: 17px; }
  .exit-button { width: 40px; min-width: 40px; padding: 0; gap: 0; } /* icon-only back button */
  .save-button,
  .primary-button,
  .outline-button {
    padding: 0 11px;
    font-size: 11px;
    gap: 5px;
  }

  /* ---- Workspace fills; reserve space for the fixed bottom bar (skill: fixed-element-offset) ---- */
  .workspace {
    flex: 1;
    display: block;
    position: relative;
    min-height: 0;
    padding-bottom: calc(var(--rail-h) + var(--safe-b));
  }

  .stage {
    height: 100%;
    min-height: calc(100svh - 56px - var(--rail-h) - var(--safe-b) - var(--safe-t));
    grid-template-columns: minmax(0, 1fr); /* canvas uses the full width; arrows overlay */
    grid-template-rows: minmax(0, 1fr);
  }
  .canvas-area { grid-column: 1; width: 100%; }
  /* View arrows overlay the canvas edges, vertically centered on the jacket
     (which itself centers in the space above any open sheet). */
  .view-arrow {
    position: absolute;
    top: calc((100% - var(--sheet-pad, 0px)) / 2);
    transform: translateY(-50%);
    z-index: 4;
  }
  .view-arrow.prev { left: 4px; }
  .view-arrow.next { right: 6px; }

  /* ---- Bottom tab bar — fixed, safe-area aware (skill: safe-area-compliance, bottom-nav) ---- */
  .rail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0;
    padding-bottom: var(--safe-b);
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-self: auto;
    justify-self: auto;
    border-radius: 0;
    z-index: 40;
  }
  .rail-item {
    min-height: var(--rail-h);
    height: var(--rail-h);
    gap: 3px;
    padding: 6px 4px;
    border: 0;
    font-size: 10px;
  }
  .rail-icon {
    width: 24px;
    height: 24px;
  }
  .rail-reset {
    display: none; /* not part of the mobile tab bar */
  }

  /* ---- Drawer + order: bottom sheets sitting above the tab bar ---- */
  .control-drawer,
  .order-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--rail-h) + var(--safe-b));
    width: 100%;
    align-self: auto;
    margin: 0;
    max-height: 52svh;
    background: #fff;
    border: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -16px 36px rgba(8, 9, 9, 0.2);
    overflow: hidden auto;
    transform: translateY(110%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 35;
  }
  .workspace:not(.drawer-collapsed) .control-drawer {
    transform: translateY(0);
    pointer-events: auto;
  }
  .workspace.drawer-collapsed .control-drawer {
    transform: translateY(110%);
    pointer-events: none;
  }
  .order-panel {
    display: block;
    max-height: 66svh; /* the pricing sheet is a deliberate modal — can be taller */
    padding: 10px 12px 16px;
    z-index: 36;
  }
  body.show-order .order-panel {
    transform: translateY(0);
  }

  /* Colors: groups become a horizontal strip, palette sits below it. */
  .color-layout {
    min-height: 0;
    flex-direction: column;
  }
  .group-column,
  .palette-column {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    border: 0;
  }
  .group-list {
    grid-auto-flow: column;
    grid-auto-columns: 104px;
    grid-template-columns: none;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none; /* no scrollbar — the ‹ › arrows hint at swipe */
    scroll-behavior: smooth;
    padding: 2px 2px 4px;
  }
  .group-list::-webkit-scrollbar {
    display: none;
  }
  .group-button {
    min-height: 0;
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 4px;
    padding: 8px 6px;
  }
  .group-button > span:last-child {
    display: none; /* chevron */
  }

  /* One view at a time: tapping a group swaps groups → palette (no stacked sections). */
  .colors-panel .panel-title {
    display: none;
  }
  .colors-panel.show-palette .group-column {
    display: none;
  }

  /* Mobile colour sheet — stripped to the essentials so it's ~half the height:
     no search box, no On-garment / Favorites, palette as a tight 12 × 2 grid. */
  .palette-column { padding: 10px 14px 14px; }
  .colors-panel .selected-row { margin: 0 0 10px; }
  .colors-panel .search-box,
  .swatch-cols { display: none; }
  .palette-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 6px;
    margin-top: 6px;
    padding-top: 0;
    border-top: 0;
  }
  .palette-grid .palette-swatch {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }
  .custom-color { margin-top: 10px; }

  /* Designs placements: a centered row of square tiles with the title under each
     (was a tall vertical list of full-width rows — ~60% shorter now). */
  .placement-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 4px 0;
  }
  .placement-button {
    flex: 0 0 76px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 6px 2px;
    border-bottom: 0;
    text-align: center;
  }
  .placement-plus {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    font-size: 26px;
  }
  .placement-button strong {
    font-size: 10px;
    line-height: 1.2;
    white-space: normal;
  }
  .placement-button > span:last-child { display: none; } /* hide the row chevron */

  /* Center the jacket in the space ABOVE whatever sheet is open. mobile.js sets
     --sheet-h to the live height of the open sheet (0 when none), so the jacket
     always sits in the middle of its available room and never collides. */
  .stage {
    align-items: center;
    padding: 6px 0 var(--sheet-pad, 0px);
    transition: padding 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }
  /* Canvas + view label + dots become one centered stack, so the dots always
     sit right under the jacket (not pinned to the bottom). */
  .canvas-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  .view-label { position: static; bottom: auto; left: auto; transform: none; }
  .view-dots { position: static; bottom: auto; transform: none; }
  #designerCanvas {
    width: min(99%, 460px);
    max-height: calc(100svh - 56px - var(--rail-h) - var(--sheet-h, 0px) - 64px);
    transition: max-height 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }

  /* Left/right swipe-hint arrows for the groups strip (added by mobile.js). */
  .m-strip {
    position: relative;
  }
  .m-strip-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    z-index: 2;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
    color: #000;
    font-size: 18px;
    line-height: 1;
  }
  .m-strip-arrow.prev { left: 2px; }
  .m-strip-arrow.next { right: 2px; }

  /* ==========================================================================
     Mobile space sweep — compact every sheet so the jacket keeps maximum room.
     Audit-driven; space-only (padding/margins/font), every touch target >=44px.
     ========================================================================== */

  /* Shared drawer header: 66px -> 50px row, 24px -> 12px gap, smaller title.
     Back/close stay 34px glyphs centered in a 50px row => tap area >=44px. */
  .drawer-head { height: 50px; }
  .drawer-head h2 { font-size: 12px; }
  .drawer-panel:not(.colors-panel) .drawer-head { margin: 0 -18px 12px; }
  /* Shared sheet padding: drop the 28px bottom whitespace; 26px -> 18px sides. */
  .drawer-panel:not(.colors-panel) { padding: 0 18px 14px; }

  /* Features = a single toggle the bottom-nav tab already labels AND toggles
     (re-tap the Features tab to close), so the header bar is redundant. */
  .drawer-panel[data-panel="features"] .drawer-head { display: none; }
  .drawer-panel[data-panel="features"] { padding: 14px 18px; }
  .drawer-panel[data-panel="features"] .toggle-row { min-height: 44px; padding: 8px 12px; }

  /* Text + Logo form labels: trim the repeated 16px lead-in; tighter split row. */
  .field-label,
  .split-fields span { margin: 9px 0 5px; }
  .split-fields { gap: 10px; }
  /* Editor: Content | Font share one 50/50 row to reclaim the dead space. */
  .field-row { grid-template-columns: 1fr 1fr; }

  /* Mobile design editor as a drill-down: pick Text / Number / Logo first
     (picking), then only that form shows — frees space to see the jacket. */
  .drawer-panel[data-panel="text"].picking .design-body { display: none; }
  .drawer-panel[data-panel="text"]:not(.picking) .design-tabs { display: none; }
  .drawer-panel[data-panel="text"].picking .design-tabs { margin: 8px 0 6px; }
  .drawer-panel[data-panel="text"].picking .design-tab { min-height: 54px; font-size: 13px; }

  /* Logo: shrink the oversized 118px dropzone, tighten the stacked buttons. */
  .upload-box { min-height: 84px; padding: 12px; gap: 2px; }
  #logoBody .full-width { margin-top: 10px; }
  #logoBody .full-width + .full-width { margin-top: 8px; }

  /* Colors: drop the palette header's fixed 44px box + divider. */
  .colors-panel .palette-column .column-head {
    height: auto;
    min-height: 34px;
    margin: 0 0 2px;
    border-bottom: 0;
  }

  /* Order / pricing sheet: trim desktop-scale padding on every card band so the
     modal is shorter — no price / qty / total info is hidden. */
  .order-card h3 { padding: 11px 14px; font-size: 16px; }
  .fabric-row { min-height: 0; padding: 9px 14px; }
  .fabric-row .recycle { font-size: 22px; }
  .price-row { padding: 11px 16px; }
  .price-row strong { font-size: 20px; }
  .quantity-row { gap: 8px; padding: 12px 16px; }
  .quantity-row label { font-size: 12px; }
  .quantity-row p { font-size: 11px; line-height: 1.1; }
  .total-row { padding: 11px 16px; }
  .meta-card { margin-top: 8px; }
  .meta-card div { min-height: 0; padding: 9px 14px; }
  .meta-card strong { font-size: 19px; }
  .support-card { margin-top: 8px; padding: 10px 14px; }
}

@media (max-width: 520px) {
  .save-button,
  .primary-button,
  .outline-button {
    padding: 0 10px;
    font-size: 10px;
  }

  #designerCanvas {
    width: min(99%, 440px);
  }

  .view-arrow {
    width: 30px;
    height: 30px;
  }
}
