/* ═══════════════════════════════════════════════════════════
   CHABAD BACKGROUND GENERATOR — style.css
   Matches the chabadlogo.com design system
═══════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Ideal Sans';
  src: url('IdealSans-Book-Pro.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Entrance animations — copied from chabadlogo.com ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes tabFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeUp 0.4s ease-out both; }
.tab-fade { animation: tabFade 0.25s ease-out both; }
html { font-size: 16px; }
body {
  font-family: 'Ideal Sans', 'DM Sans', sans-serif;
  background: #ffffff;
  color: #1a1a1a;
  min-height: 100vh;
}
button { cursor: pointer; font-family: inherit; }
.hidden { display: none !important; }

:root {
  --c-primary:    #871a39;
  --c-secondary:  #f27730;
  --c-dark:       #1a1a1a;
  --c-bg:         #ffffff;
  --c-panel:      #F2F2F2;
  --c-border:     #e0e0e0;
  --c-input-bg:   #ffffff;
  --c-muted:      #888;
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 2px 16px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 40px rgba(0,0,0,0.14);
  --c-glow:       rgba(242,119,48,0.35);
  --transition:   0.2s ease;
  --panel-w:      400px;
}

/* ══════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════ */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
@media (min-width: 960px) {
  .app-layout { flex-direction: row; align-items: stretch; height: 100vh; }
}

/* ══════════════════════════════════════════
   LEFT PANEL — Controls
══════════════════════════════════════════ */
.controls-panel {
  width: 100%;
  background: var(--c-panel);
  padding: 0 32px 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
@media (min-width: 960px) {
  .controls-panel {
    width: var(--panel-w);
    min-width: var(--panel-w);
    max-width: var(--panel-w);
    height: 100vh;
    border-right: 1px solid var(--c-border);
  }
}

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 26px 0 18px;
  border-bottom: 1px solid var(--c-border);
}
.brand-mark { width: 38px; height: 38px; flex-shrink: 0; }
.app-header-text h1 {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--c-dark);
  line-height: 1.2;
}
.app-header-text p {
  font-size: 0.74rem;
  color: var(--c-muted);
  margin-top: 3px;
  line-height: 1.4;
}

/* ─── Accordions ─── */
.accordion { border-bottom: 1px solid var(--c-border); }
.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 18px 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--c-dark);
  font-family: inherit;
}
.accordion-chevron {
  width: 18px; height: 18px;
  color: var(--c-muted);
  transition: transform var(--transition);
}
.accordion.open .accordion-chevron { transform: rotate(180deg); }
.accordion-body {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 2px 0 20px;
}
.accordion.open .accordion-body { display: flex; }

.ctrl-group { display: flex; flex-direction: column; gap: 16px; }
.ctrl-row-2 { flex-direction: row; gap: 10px; }
.ctrl-row-2 .form-field { flex: 1; }

.ctrl-subheading {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 6px;
}
.ctrl-subheading:first-child { margin-top: 0; }

.ctrl-hint {
  font-size: 0.78rem;
  color: var(--c-muted);
  line-height: 1.5;
}
.ctrl-hint.no-mt { margin-top: 0; }

/* ─── Suite pill tabs — copied from chabadlogo.com ─── */
.suite-tabs-outer {
  position: relative;
  flex-shrink: 0;
  margin: 12px -32px 4px;
}
.suite-tabs-outer::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, #F2F2F2);
  pointer-events: none;
  z-index: 1;
}
.suite-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 48px 8px 32px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.suite-tabs::-webkit-scrollbar { display: none; }
.pill-tab {
  background: #fff;
  border: none;
  border-radius: 20px;
  padding: 9px 18px;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--c-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pill-tab:hover {
  color: var(--c-dark);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.pill-tab.active {
  background: var(--c-primary);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.pill-ext { width: 11px; height: 11px; opacity: 0.55; }

/* ─── Random pattern button ─── */
.btn-random {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 12px 16px;
  background: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--c-dark);
  box-shadow: 0 1px 5px rgba(0,0,0,0.1);
  transition: box-shadow var(--transition), transform var(--transition);
}
.btn-random:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); transform: translateY(-1px); }
.btn-random svg { width: 17px; height: 17px; color: var(--c-secondary); }

/* ─── Look stepper ─── */
.stepper-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.step-btn {
  width: 28px; height: 28px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: var(--c-dark);
  font-size: 1rem;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.step-btn:hover { color: var(--c-primary); }
.step-val {
  min-width: 64px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ─── Color drag handle ─── */
.drag-handle {
  width: 12px;
  height: 18px;
  margin-right: 8px;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
  background-image: radial-gradient(circle, #bdbdbd 1.2px, transparent 1.4px);
  background-size: 6px 6px;
  background-position: 0 1px;
}
.color-row.dragging { background: rgba(135,26,57,0.05); border-radius: 6px; }
.color-row .color-label { flex: 1; }

/* ─── Pattern thumbnail tiles ─── */
.pattern-tiles { display: flex; gap: 10px; }
.pattern-tile {
  flex: 1;
  background: #fff;
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 6px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.pattern-tile:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.12); }
.pattern-tile.active { border-color: var(--c-primary); }
.pattern-tile .tile-art { width: 100%; }
.pattern-tile .tile-art svg,
.pattern-tile .tile-art img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 8 / 5;
  object-fit: cover;
  border-radius: 6px;
  /* grayscale: the tiles show the pattern's shape, not its colors */
  filter: grayscale(1);
}
.tile-label { font-size: 0.78rem; font-weight: 500; color: #555; }
.pattern-tile.active .tile-label { color: var(--c-primary); }

/* ─── Sliders — one line: name · track · value (Paper-style) ─── */
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-name {
  width: 92px;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--c-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slider-track-wrap { flex: 1; display: flex; align-items: center; min-width: 0; }
.slider-val {
  width: 46px;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.74rem;
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #d8d8d8;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--c-secondary);
  border: none;
  box-shadow: 0 1px 5px rgba(0,0,0,0.18);
  cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--c-secondary);
  border: none;
  box-shadow: 0 1px 5px rgba(0,0,0,0.18);
  cursor: grab;
}
input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; }

.btn-inline-reset {
  align-self: flex-start;
  background: none;
  border: none;
  padding: 2px 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--c-secondary);
  transition: opacity var(--transition);
}
.btn-inline-reset:hover { opacity: 0.7; }

/* ─── Inputs & selects ─── */
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 0.78rem; color: var(--c-dark); }
.ctrl-input {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--c-input-bg);
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--c-dark);
  outline: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: box-shadow var(--transition);
}
.ctrl-input:focus {
  box-shadow: 0 0 0 3px rgba(135,26,57,0.12), 0 2px 8px rgba(0,0,0,0.1);
}
.select-row { display: flex; align-items: center; gap: 10px; }
.select-row .form-label { width: 92px; flex-shrink: 0; }
.select-row .ctrl-select { flex: 1; }
.ctrl-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' fill='%23888'%3E%3Cpath d='M0.979 0.01L5 4.024 9.021 0.01 10 0.989 5 5.989 0 0.989z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 10px;
  padding-right: 34px;
  cursor: pointer;
}

/* ─── Toggle switch ─── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px; height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 24px;
  transition: background var(--transition);
  cursor: pointer;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-track { background: var(--c-secondary); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(20px); }

/* ─── Color rows ─── */
.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1px 0;
}
.color-label { font-size: 0.82rem; }
.color-swatch-wrap { display: flex; align-items: center; gap: 8px; }
input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 32px; height: 32px;
  border: 2px solid var(--c-border);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: none;
  overflow: hidden;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 50%; }
.color-hex-input {
  font-size: 0.78rem;
  font-family: 'DM Sans', monospace;
  color: var(--c-muted);
  width: 72px;
  padding: 5px 6px;
  border: none;
  border-radius: 4px;
  background: var(--c-input-bg);
  outline: none;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.color-hex-input:focus {
  color: var(--c-dark);
  box-shadow: 0 0 0 3px rgba(135,26,57,0.12), 0 2px 8px rgba(0,0,0,0.1);
}

.color-list { display: flex; flex-direction: column; gap: 2px; }
.color-list .color-row { justify-content: flex-start; gap: 8px; padding: 2px 0; }
.color-list input[type="color"] {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--c-border);
}
.color-list input[type="color"]::-webkit-color-swatch { border-radius: 5px; }
.color-list input[type="color"]::-moz-color-swatch { border-radius: 5px; }
.color-list .color-hex-input { width: 84px; text-align: left; padding: 7px 9px; }
.color-spacer { flex: 1; }
.color-remove {
  border: none;
  background: none;
  color: #b0b0b0;
  font-size: 1.45rem;
  line-height: 1;
  padding: 2px 8px;
  cursor: pointer;
}
.color-remove:hover { color: #b03030; }
.color-add-row { display: flex; justify-content: space-between; margin-bottom: -6px; }
.color-add svg { width: 13px; height: 13px; }
.color-add {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: #fff;
  color: var(--c-muted);
  font-size: 1.05rem;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  cursor: pointer;
}
.color-add:hover { color: var(--c-primary); }

/* ─── Preset gradient carousel — bleeds to the panel edges ─── */
.preset-carousel {
  display: flex;
  gap: 14px;
  margin: 0 -32px;
  padding: 7px 32px 7px;
  overflow-x: auto;
  scrollbar-width: none;
}
.preset-carousel::-webkit-scrollbar { display: none; }
.preset-circle-wrap {
  background: none;
  border: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.preset-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.1);
  transition: transform var(--transition);
}
.preset-circle-wrap:hover .preset-circle { transform: scale(1.07); }
.preset-circle.active { outline: 2.5px solid var(--c-primary); outline-offset: 2px; }
.preset-label { font-size: 0.7rem; color: var(--c-muted); }
.preset-circle.active + .preset-label,
.preset-circle-wrap:has(.active) .preset-label { color: var(--c-primary); font-weight: 500; }

/* ─── Export split button ─── */
.ctrl-section { padding: 22px 0; }
.ctrl-export { border-bottom: none; }
.split-btn-wrap {
  position: relative;
  display: flex;
  border-radius: 24px;
  overflow: visible;
  box-shadow: 0 4px 18px var(--c-glow);
  background: var(--c-primary);
}
.split-btn-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: none;
  border: none;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 13px 18px;
  border-radius: 24px 0 0 24px;
  transition: background var(--transition);
}
.split-btn-main:hover:not(:disabled) { background: rgba(255,255,255,0.08); }
.split-btn-main:disabled { opacity: 0.65; cursor: wait; }
.split-btn-icon { width: 18px; height: 18px; }
.split-btn-divider { width: 1px; background: rgba(255,255,255,0.25); margin: 8px 0; }
.split-btn-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 18px 0 14px;
  color: #fff;
  border-radius: 0 24px 24px 0;
}
.split-btn-face { font-size: 0.82rem; pointer-events: none; }
.split-btn-caret { width: 10px; height: 6px; pointer-events: none; }
.split-btn-select {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}
.export-duration {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}
.export-note {
  font-size: 0.74rem;
  color: var(--c-muted);
  text-align: center;
  margin-top: 12px;
  line-height: 1.5;
}

/* ─── Bottom link ─── */
.panel-back-link {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--c-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.panel-back-link:hover { color: var(--c-dark); }
.form-bottom-link { margin-top: auto; padding: 24px 0 12px; }
.panel-links { display: flex; justify-content: space-between; align-items: center; }

/* ══════════════════════════════════════════
   RIGHT COLUMN — Preview
══════════════════════════════════════════ */
.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 60vh;
  background: #ffffff;
}
@media (min-width: 960px) {
  .preview-panel { height: 100vh; min-height: 0; }
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 24px 0;
}
.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}
.dim-note {
  font-size: 0.74rem;
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Compact format controls living in the toolbar */
.toolbar-format {
  display: flex;
  align-items: center;
  gap: 8px;
}
.toolbar-format .pill-mini {
  background: #e2e2e2;
  border-radius: 16px;
  padding: 3px;
  gap: 2px;
}
.toolbar-format .pill-mini .pill-tab {
  flex: 0 0 auto;
  padding: 5px 10px;
  font-size: 0.72rem;
  border-radius: 13px;
}
.toolbar-size { display: flex; align-items: center; gap: 5px; }
.toolbar-x { font-size: 0.72rem; color: var(--c-muted); }
.toolbar-num {
  width: 64px;
  padding: 6px 8px;
  font-size: 0.75rem;
  text-align: center;
}
.toolbar-select {
  width: auto;
  padding: 6px 26px 6px 12px;
  font-size: 0.75rem;
  background-position: right 10px center;
}
.toolbar-actions { display: flex; gap: 8px; }
.btn-toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: none;
  border-radius: 18px;
  padding: 8px 15px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--c-dark);
  box-shadow: 0 1px 5px rgba(0,0,0,0.1);
  transition: box-shadow var(--transition), transform var(--transition);
}
.btn-toolbar:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.15); transform: translateY(-1px); }
.btn-toolbar svg { width: 15px; height: 15px; }

.preview-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 16px;
}
.canvas-frame {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #ddd;
}
.canvas-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.btn-toolbar.active {
  background: var(--c-dark);
  color: #fff;
}

.record-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 500;
  backdrop-filter: blur(2px);
}
.record-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #ff4d4d;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

.gl-error {
  padding: 40px;
  text-align: center;
  color: var(--c-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-dark);
  color: #fff;
  font-size: 0.82rem;
  padding: 10px 18px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ══════════════════════════════════════════
   MOBILE SHELL — iOS-editor layout (light)
══════════════════════════════════════════ */
#m-root { display: none; }

@media (max-width: 959px) {
  /* pin the shell to the visual viewport — on iOS Chrome 100vh includes
     the browser chrome, making the page scroll past the top bar */
  html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .app-layout { display: none; }
  #m-root {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    background: var(--c-panel);
    overflow: hidden;
  }

  .suite-tabs-outer.m-suite { margin: 0; }
  .suite-tabs-outer.m-suite .suite-tabs { padding: 10px 40px 4px 14px; }
  .m-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px 8px;
  }
  .m-top-btn {
    width: 38px; height: 38px;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: var(--c-dark);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .m-top-btn svg { width: 17px; height: 17px; }
  .m-pill {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    flex: 0 0 auto;
    border: none;
    border-radius: 20px;
    padding: 10px 22px;
    font-size: 0.85rem;
    font-weight: 500;
    background: #fff;
    color: var(--c-dark);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  }
  .m-pill svg { width: 16px; height: 16px; color: var(--c-secondary); }
  .m-pill-primary { background: var(--c-secondary); color: #fff; box-shadow: 0 3px 12px var(--c-glow); }
  .m-pill-primary svg { color: #fff; }

  .m-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 6px;
  }
  .m-format-chip {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: none;
    border-radius: 20px;
    padding: 11px 10px;
    background: #fff;
    color: var(--c-dark);
    font-size: 0.8rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  }
  .m-format-chip svg { width: 10px; height: 6px; color: var(--c-muted); flex-shrink: 0; }
  .m-format-chip span { overflow: hidden; text-overflow: ellipsis; }

  .m-sheet {
    background: #fff;
    border-top: 1px solid var(--c-border);
    padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  }
  .m-context { display: flex; flex-direction: column; }

  .m-choice {
    display: flex;
    gap: 14px;
    padding: 7px 16px 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .m-choice::-webkit-scrollbar { display: none; }
  /* center rows whose content fits; left-align only once they scroll */
  .m-choice > :first-child, .m-chips > :first-child { margin-left: auto; }
  .m-choice > :last-child, .m-chips > :last-child { margin-right: auto; }
  .m-circle-wrap {
    background: none; border: none; padding: 0;
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    flex-shrink: 0;
  }
  .m-circle {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: var(--c-panel);
    color: var(--c-dark);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.72rem;
    font-weight: 500;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
  }
  .m-circle img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1); }
  .m-circle.active { outline: 2.5px solid var(--c-primary); outline-offset: 2px; }
  .m-circle-label { font-size: 0.66rem; color: var(--c-muted); }
  .m-circle svg { width: 20px; height: 20px; }
  .m-swatches { padding-top: 0; align-items: center; }
  .m-swatch {
    width: 34px; height: 34px;
    border: none; padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
    touch-action: none;
  }
  .m-swatch-input {
    position: absolute;
    width: 0; height: 0;
    opacity: 0;
    pointer-events: none;
  }
  .m-qty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    margin-left: 4px;
    flex-shrink: 0;
  }
  .m-qty-btn {
    border: none;
    background: none;
    color: #777;
    font-size: 0.62rem;
    padding: 1px 8px;
    line-height: 1;
  }
  .m-qty-n { font-size: 0.72rem; font-weight: 500; color: var(--c-dark); line-height: 1; }

  .m-stepper-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    margin-top: 5px;   /* centers on the 46px circles, ignoring their labels */
    margin-left: 6px;
    flex-shrink: 0;
  }
  .m-step-btn {
    width: 36px; height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--c-panel);
    color: #444;
    font-size: 1.1rem;
    line-height: 1;
  }
  .m-step-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--c-dark);
    min-width: 62px;
    text-align: center;
    font-variant-numeric: tabular-nums;
  }

  .m-random-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: calc(100% - 32px);
    margin: 2px 16px 10px;
    padding: 12px;
    border: none;
    border-radius: 14px;
    background: var(--c-primary);
    color: #fff;
    font-size: 0.86rem;
    font-weight: 500;
    box-shadow: 0 3px 10px var(--c-glow);
  }
  .m-random-bar svg { width: 16px; height: 16px; }

  .m-chips {
    display: flex;
    gap: 8px;
    padding: 4px 16px 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .m-chips::-webkit-scrollbar { display: none; }

  .m-scrub {
    position: relative;
    height: 48px;
    margin: 0 16px 6px;
    overflow: hidden;
    touch-action: none;
    cursor: ew-resize;
  }
  .m-scrub-strip {
    position: absolute;
    left: 50%;
    top: 0; bottom: 0;
    display: flex;
    align-items: center;
  }
  .m-tick {
    width: 2px;
    height: 15px;
    margin-right: 7px;
    border-radius: 1px;
    background: #c4c4c4;
    flex-shrink: 0;
    transition: transform 0.25s ease;
    transform-origin: center;
  }
  .m-tick.major { height: 24px; background: #9a9a9a; }
  .m-scrub-marker {
    position: absolute;
    left: 50%; top: 4px; bottom: 4px;
    width: 3px;
    margin-left: -1.5px;
    border-radius: 2px;
    background: var(--c-secondary);
    pointer-events: none;
  }

  .m-cats {
    display: flex;
    justify-content: space-around;
    padding: 6px 8px 2px;
    border-top: 1px solid var(--c-border);
  }
  .m-cat {
    background: none; border: none;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 4px 6px;
    color: var(--c-muted);
  }
  .m-cat-icon {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--c-panel);
    display: flex; align-items: center; justify-content: center;
  }
  .m-cat-icon svg { width: 18px; height: 18px; }
  .m-cat-label { font-size: 0.62rem; }
  .m-cat.active { color: var(--c-primary); }
  .m-cat.active .m-cat-icon { background: var(--c-primary); color: #fff; }

}

/* ══════════════════════════════════════════
   FORMAT PANEL — shared sheet/dialog (both shells)
══════════════════════════════════════════ */
.m-export {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.m-export-card {
  position: relative;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 38px 16px max(16px, env(safe-area-inset-bottom));
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.m-export-lengths { display: flex; gap: 8px; justify-content: center; }
.m-export-close {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--c-panel);
  color: #777;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.m-export-close:hover { color: var(--c-dark); }
.m-export-close svg { width: 11px; height: 11px; }
@media (min-width: 960px) {
  /* desktop: anchored dropdown under the format chip, no dim */
  .m-export { background: transparent; }
  .m-export-card {
    position: absolute;
    width: 440px;
    border-radius: 14px;
    padding: 38px 20px 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--c-border);
  }
}

.m-chip {
  border: none;
  border-radius: 16px;
  padding: 8px 11px;
  font-size: 0.8rem;
  background: none;
  color: #9a9a9a;
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.m-chip.active { color: var(--c-primary); font-weight: 600; }

.m-seg-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.m-seg {
  display: flex;
  background: #ececec;
  border-radius: 17px;
  padding: 3px;
  gap: 2px;
}
.m-seg-btn {
  border: none;
  background: none;
  padding: 8px 16px;
  border-radius: 14px;
  font-size: 0.8rem;
  color: #555;
  cursor: pointer;
}
.m-seg-btn.active {
  background: #fff;
  color: var(--c-primary);
  font-weight: 500;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.m-shape-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.m-shape-row::-webkit-scrollbar { display: none; }
.m-shape {
  border: none;
  background: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  cursor: pointer;
}
.m-shape-art {
  width: 46px; height: 42px;
  color: #9a9a9a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.m-shape-art svg { width: 30px; height: 30px; }
.m-shape.active .m-shape-art { color: var(--c-primary); }
.m-shape-label { font-size: 0.66rem; color: var(--c-muted); }
.m-shape.active .m-shape-label { color: var(--c-primary); font-weight: 500; }

/* freeform resize grip — both shells */
.m-resize-handle {
  display: none;
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 12px 0 10px 0;
  background: rgba(255,255,255,0.92);
  color: var(--c-primary);
  box-shadow: 0 1px 6px rgba(0,0,0,0.18);
  touch-action: none;
  cursor: nwse-resize;
  z-index: 5;
}
.m-resize-handle:not(.hidden) { display: flex; }
.m-resize-handle svg { width: 16px; height: 16px; }

/* desktop toolbar: format chip + primary download */
.d-format-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 18px;
  padding: 9px 16px;
  background: #fff;
  color: var(--c-dark);
  font-size: 0.8rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 5px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: box-shadow var(--transition);
}
.d-format-chip:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.15); }
.d-format-chip svg { width: 10px; height: 6px; color: var(--c-muted); flex-shrink: 0; }

.btn-toolbar-primary {
  background: var(--c-secondary);
  color: #fff;
  box-shadow: 0 3px 12px var(--c-glow);
}
.btn-toolbar-primary:hover { box-shadow: 0 5px 16px var(--c-glow); }
