:root {
  --bg: #fff;
  --panel: #fff;
  --text: #282828;
  --muted: #777;
  --soft: #aaa;
  --line: #e1e1e1;
  --line-light: #eeeeee;
  --accent: #dc9814;
  --button: #282828;
  --ok: #16803c;
  --mobile-gap-tight: 8px;
  --mobile-gap: 12px;
  --mobile-panel-pad: 14px;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 2;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 0;
  background: var(--button);
  color: white;
  padding: 14px 18px;
  cursor: pointer;
  font-weight: normal;
  line-height: 16px;
  transition: opacity 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

button.is-unavailable {
  background: #9c9c9c;
  border-color: #9c9c9c;
  color: #fff;
  cursor: not-allowed;
  opacity: 1;
}

button.is-unavailable:hover {
  opacity: 1;
}

button.ghost.is-unavailable {
  background: #f3f3f3;
  border-color: var(--line);
  color: #aaa;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--soft);
}

button:hover {
  opacity: 0.82;
}

button.ghost:hover {
  opacity: 1;
  border-color: var(--text);
}

button.danger,
button.ghost.danger {
  border-color: #d84a35;
  background: #d84a35;
  color: #fff;
}

button.danger:hover,
button.ghost.danger:hover {
  opacity: 1;
  border-color: #b93624;
  background: #b93624;
  color: #fff;
}

body.preview-mobile {
  background: #fff;
  font-size: 13px;
  line-height: 1.65;
  overflow-x: hidden;
}

body.preview-mobile .app-header,
body.preview-mobile .shell,
body.preview-mobile .app-footer {
  width: 100%;
  max-width: none;
  background: transparent;
}

body.preview-mobile .app-header {
  padding: 20px 14px 18px;
}

body.preview-mobile .app-header h1 {
  font-size: 23px;
  line-height: 1.25;
}

body.preview-mobile .header-note {
  max-width: none;
  font-size: 13px;
  line-height: 1.5;
}

body.preview-mobile .shell {
  margin-bottom: 36px;
  padding: 14px 12px 0;
}

body.preview-mobile .panel {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 18px;
  column-gap: 0;
  padding: 22px 0;
}

body.preview-mobile .panel > :not(.section-title) {
  grid-column: 1;
  min-width: 0;
}

body.preview-mobile .section-title {
  gap: 10px;
}

body.preview-mobile .section-title h2 {
  font-size: 22px;
  line-height: 1.25;
}

body.preview-mobile .section-title p,
body.preview-mobile label {
  font-size: 13px;
  line-height: 1.5;
}

body.preview-mobile .form-grid,
body.preview-mobile .custom-item-list,
body.preview-mobile .custom-item-actions,
body.preview-mobile .queue-toolbar,
body.preview-mobile .submit-row,
body.preview-mobile .video-controls,
body.preview-mobile .lightbox-workspace,
body.preview-mobile .text-grid {
  grid-template-columns: 1fr;
}

body.preview-mobile .submit-actions {
  justify-content: center;
  flex-wrap: wrap;
}

body.preview-mobile .submit-actions button {
  width: auto;
  flex: 0 1 auto;
  min-width: 0;
  min-height: 38px;
  padding: 8px 12px;
  font-size: 13px;
}

body.preview-mobile .submit-card button + button {
  margin-top: 0;
}

body.preview-mobile button {
  min-height: 46px;
  padding: 13px 14px;
  width: 100%;
}

body.preview-mobile #mobilePlayToggle,
body.preview-mobile .submit-actions button {
  width: auto;
}

body.preview-mobile .icon-button {
  width: 44px;
  min-height: 44px;
  padding: 0;
}

body.preview-mobile .custom-item-card {
  min-height: 0;
  padding: 13px;
}

/* Mobile: actions and tool panels placed after active card (not inside it) */
body.preview-mobile .custom-item-list > .custom-item-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 0 12px;
  margin-bottom: 8px;
  border: 0;
  background: transparent;
}

body.preview-mobile .custom-item-list > .custom-item-actions button {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  font-size: 13px;
}

body.preview-mobile .custom-item-list > .custom-item-tool-panel {
  padding: 0 0 12px;
  margin-bottom: 8px;
  border: 0;
  background: transparent;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}

body.preview-mobile .custom-item-list > .custom-work-panel {
  border: 0;
  box-shadow: none;
  padding: 0 0 12px;
  margin-bottom: 10px;
  background: transparent;
}

body.preview-mobile .custom-item-list > .custom-item-tool-panel label {
  font-size: 13px;
  max-width: 100%;
}

body.preview-mobile .custom-item-list > .custom-item-tool-panel .inline-note {
  display: block;
  white-space: normal;
  margin-top: 2px;
}

/* Mobile: hide divider line on thumbnails, reduce card clutter */
body.preview-mobile .image-preview::after {
  display: none;
}

/* Mobile: crop editor inline (not modal) */
body.preview-mobile #cropDialog {
  display: none;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] {
  display: block;
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  margin: 10px 0 12px;
  width: 100%;
  max-width: 100%;
  border: 0;
  box-shadow: none;
  background: none;
  padding: 0;
  max-height: none;
  overflow: visible;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-dialog {
  width: 100%;
  max-width: 100%;
  height: min(78dvh, 780px);
  max-height: min(78dvh, 780px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgb(40 40 40 / 0.12);
  box-shadow: 0 14px 28px rgb(0 0 0 / 0.12);
  background: #fff;
}

body.preview-mobile #cropDialog[open] .crop-editor-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

body.preview-mobile #cropDialog[open] .dialog-head {
  padding: 12px 14px 0;
  background: #fff;
  border-bottom: 1px solid rgb(40 40 40 / 0.08);
}

body.preview-mobile #cropDialog[open] .dialog-head h2 {
  font-size: 18px;
}

body.preview-mobile #cropDialog[open] .crop-preview-panel {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border-bottom: 1px solid rgb(40 40 40 / 0.08);
}

body.preview-mobile #cropDialog[open] .crop-body {
  max-height: none;
  overflow: visible;
}

body.preview-mobile #cropDialog[open] .crop-stage {
  height: auto;
  aspect-ratio: 1163 / 945;
  min-height: 0;
  margin-top: 0;
  background: #8f8f8f;
}

body.preview-mobile #cropDialog[open] .crop-sidebar {
  display: flex;
  touch-action: pan-y;
  flex-direction: column;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 0;
  min-height: 0;
  max-height: none;
  padding: 14px 14px 24px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

body.preview-mobile #cropDialog[open] .crop-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: stretch;
  margin: 0;
}

body.preview-mobile #cropDialog[open] .crop-actions button {
  flex: 1;
  min-width: 0;
}

body.preview-mobile #cropDialog[open] .crop-actions label {
  flex: 1 0 100%;
}

body.preview-mobile .crop-inline-anchor {
  display: block;
  grid-column: 1 / -1;
  position: sticky;
  top: 8px;
  z-index: 30;
  width: 100%;
}

.queue-jump-buttons[hidden] {
  display: none !important;
}

.queue-jump-buttons {
  position: fixed;
  right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  z-index: 2147482400;
  display: grid;
  gap: 8px;
  margin: 0;
}

.queue-jump-button {
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid rgb(40 40 40 / 0.14);
  background: rgb(255 255 255 / 0.96);
  color: var(--text);
  box-shadow: 0 10px 22px rgb(0 0 0 / 0.12);
  font-size: 20px;
  line-height: 1;
}

.queue-jump-button:hover {
  transform: translateY(-1px);
}

body.preview-mobile .drop-zone,
body.preview-mobile .dropzone {
  min-height: 108px;
  padding: 12px 12px;
  gap: var(--mobile-gap-tight);
}

body.preview-mobile .drop-zone strong,
body.preview-mobile .dropzone strong {
  font-size: 16px;
  line-height: 1.2;
}

body.preview-mobile .drop-zone small,
body.preview-mobile .dropzone small {
  line-height: 1.25;
}

body.preview-mobile #uploadWorkspace {
  padding-bottom: 4px;
  margin-bottom: 0;
}

body.preview-mobile #uploadWorkspace + #queueWorkspace {
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  row-gap: 0;
}

body.preview-mobile #uploadWorkspace + #queueWorkspace .queue-toolbar {
  padding-bottom: 0;
}

body.preview-mobile #uploadWorkspace + #queueWorkspace #queueStatus {
  margin: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-light);
}

body.preview-mobile #uploadWorkspace + #queueWorkspace .image-queue:empty {
  display: none;
  margin-top: 0;
}

body.preview-mobile .image-queue {
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}

body.preview-mobile .queue-toolbar {
  padding-bottom: 2px;
  gap: var(--mobile-gap-tight);
}

body.preview-mobile .queue-actions {
  gap: var(--mobile-gap-tight);
}

body.preview-mobile .image-actions,
body.preview-mobile .tool-buttons,
body.preview-mobile .lightbox-align-buttons,
body.preview-mobile .lightbox-text-align,
body.preview-mobile .text-color-buttons {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.preview-mobile .custom-items-wrap > .panel {
  border-top: 0;
  padding-top: 0;
}

body.preview-mobile .lightbox-stage {
  min-width: 0;
  min-height: 210px;
  padding: 8px;
}

body.preview-mobile:not(.lightbox-focus-mode) #lightboxDesigner .lightbox-workspace {
  gap: 12px;
}

body.preview-mobile:not(.lightbox-focus-mode) #lightboxDesigner .lightbox-stage {
  min-height: 0;
  padding: 0;
}

body.preview-mobile .lightbox-tools {
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
}

body.preview-mobile .lightbox-tool-save {
  grid-column: 1;
  width: 100%;
  min-height: 48px;
}

body.preview-mobile #lightboxImageTools:not([hidden]),
body.preview-mobile #lightboxTextTools:not([hidden]) {
  grid-template-columns: 1fr;
}

body.preview-mobile .lightbox-slider {
  width: 100%;
}

body.preview-mobile #lightboxTextTools:not([hidden]) .text-grid {
  grid-template-columns: minmax(0, 1fr) minmax(118px, 0.72fr);
  gap: 10px 8px;
  align-items: end;
}

body.preview-mobile #lightboxTextTools:not([hidden]) .text-grid > label {
  min-width: 0;
}

body.preview-mobile #lightboxTextTools:not([hidden]) .text-grid > label:nth-child(3) {
  grid-column: 1 / -1;
}

body.preview-mobile #lightboxTextTools:not([hidden]) .lightbox-color-palette {
  min-width: 0;
}

body.preview-mobile .lightbox-content-card,
body.preview-mobile .video-tools {
  border: 0;
  box-shadow: none;
  padding: 0;
  background: transparent;
}

body.preview-mobile .video-preview-card {
  min-height: 0;
  margin-top: 10px;
}

body.preview-mobile .video-layout {
  display: grid;
  gap: 12px;
}

body.preview-mobile .video-drop {
  min-height: 128px;
}

body.preview-mobile .video-tools {
  margin-top: 0;
  gap: 12px;
}

body.preview-mobile #sourceVideo {
  max-height: none;
}


body.preview-mobile #lightboxImageTools:not([hidden]) .tool-group,
body.preview-mobile #lightboxImageTools:not([hidden]) .lightbox-slider,
body.preview-mobile #lightboxTextTools:not([hidden]) {
  grid-column: 1;
}

body.preview-mobile .app-footer {
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 18px 24px;
}

body.preview-mobile .submit-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

body.preview-mobile .upload-progress,
body.preview-mobile .upload-progress-track {
  width: 100%;
}

body.preview-mobile .submit-card .upload-progress {
  align-self: stretch;
}

.mobile-playback {
  margin-top: 12px;
  scroll-margin-top: calc(var(--customizer-safe-top, 0px) + 12px);
}

.mobile-playback .flip-holder {
  margin: 0 auto;
}

.mobile-playback .playback-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #222;
  color: #ccc;
  font-size: 13px;
  margin-top: 8px;
}

.mobile-playback .playback-bar label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #999;
  margin-left: auto;
  font-size: 12px;
  white-space: nowrap;
}

.mobile-playback .playback-bar select {
  width: auto;
  padding: 4px 8px;
  height: auto;
  font-size: 12px;
  background: #333;
  color: #ccc;
  border: 1px solid #555;
}

#mobilePlayToggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--button);
  color: #fff;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
  flex: 0 0 auto;
  user-select: none;
  line-height: 1;
}

#mobilePlayLabel {
  font-variant-numeric: tabular-nums;
  color: #ccc;
  white-space: nowrap;
}

#mobilePlayClose {
  cursor: pointer;
  color: #999;
  font-size: 15px;
  padding: 2px 6px;
  user-select: none;
  flex: 0 0 auto;
}

#mobilePlayClose:hover {
  color: #fff;
}

#mobilePlayClose {
  cursor: pointer;
  color: #999;
  font-size: 15px;
  padding: 2px 6px;
  user-select: none;
  flex: 0 0 auto;
}

#mobilePlayClose:hover {
  color: #fff;
}

/* ── Mobile inline crop panel ── */

.mobile-crop-panel {
  margin-top: 20px;
}

.mobile-crop-panel .crop-stage {
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  overflow: hidden;
}

.mobile-crop-panel .crop-stage canvas {
  max-width: 100%;
  max-height: 40vh;
}

.mobile-crop-tools {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.mobile-crop-tools .align-buttons {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.mobile-crop-tools .align-buttons button {
  min-height: 32px;
  padding: 4px 2px;
  font-size: 11px;
  width: 100%;
}

.mobile-crop-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.mobile-crop-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  min-width: 80px;
}

.mobile-crop-row input[type=range] {
  flex: 1;
  height: 28px;
  padding: 0;
}

.mobile-crop-row button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

#mobileCropSaveBtn {
  background: var(--button);
  color: #fff;
}

#mobileCropCloseBtn {
  background: transparent;
  border: 1px solid var(--soft);
}

.app-header {
  display: block;
  max-width: 1280px;
  margin: 0 auto;
  padding: 46px 30px 34px;
  border-bottom: 1px solid var(--line-light);
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.4;
  font-weight: normal;
  letter-spacing: 0;
}

.header-note {
  max-width: 520px;
  margin: 8px auto 0;
  color: var(--muted);
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-link {
  color: var(--muted);
  font-weight: normal;
  text-decoration: none;
  transition: color 0.2s ease;
}

.admin-link:hover {
  color: var(--text);
}

.shell {
  max-width: 1280px;
  margin: 0 auto 64px;
  padding: 42px 30px 0;
}

.panel {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  column-gap: 54px;
  align-items: start;
  background: var(--panel);
  border-top: 1px solid var(--line-light);
  border-radius: 0;
  padding: 42px 0;
  margin-top: 0;
}

.panel:first-child {
  border-top: 0;
  padding-top: 0;
}

.section-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 0;
}

.section-title span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  font-size: 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.4;
  font-weight: normal;
  color: var(--text);
}

.section-title p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.panel > :not(.section-title) {
  grid-column: 2;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 28px;
  row-gap: 24px;
  align-items: start;
}

.local-product-test-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.local-product-test-controls[hidden] {
  display: none !important;
}

.local-product-test-controls button {
  min-height: 44px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: normal;
  line-height: 1.35;
}

input,
select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: white;
  color: var(--text);
  padding: 0 14px;
  line-height: 44px;
  outline: 0;
  box-shadow: none;
  transition: border-color 0.4s ease;
}

input[readonly],
input.is-readonly,
select:disabled,
select.is-readonly {
  background: #f7f7f7;
  color: #666;
  border-color: var(--line-light);
  cursor: default;
}

input[readonly]:focus,
input.is-readonly:focus {
  border-color: var(--line-light);
}

select {
  appearance: none;
  padding-right: 44px;
}

.internal-product-field {
  display: grid;
}

.select-wrap {
  position: relative;
  display: block;
}

.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 17px;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  pointer-events: none;
  transform: translateY(-62%) rotate(45deg);
}

.select-wrap:focus-within::after {
  border-color: var(--text);
}

.product-select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.product-select-row button {
  height: 44px;
  white-space: nowrap;
}

.field-note {
  color: var(--accent);
  font-size: 12px;
  line-height: 1.45;
  min-height: 18px;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 18px;
}

.inline-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
}

.custom-items-wrap {
  display: grid;
  gap: 18px;
}

.custom-items-panel {
  padding-bottom: 18px;
}

.custom-item-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.custom-item-card {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 210px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.custom-item-select {
  display: grid;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.custom-item-card.active {
  border-color: var(--text);
  box-shadow: inset 0 0 0 2px var(--text);
}

.custom-item-card.is-collapsed {
  border-color: #7d55c7;
  border-style: solid;
  box-shadow: inset 0 0 0 2px #7d55c7;
}

.custom-item-card strong {
  font-size: 14px;
  font-weight: normal;
}

.custom-item-card small {
  color: var(--muted);
  line-height: 1.45;
}

.custom-item-card .item-progress {
  color: var(--accent);
}

.item-state-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.item-state-pill {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid var(--line-light);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.item-state-pill i {
  display: inline-block;
  width: 9px;
  height: 9px;
  background: currentColor;
}

.item-state-pill.is-unsaved {
  border-color: rgb(220 152 20 / 0.35);
  color: var(--accent);
}

.item-state-pill.is-saved {
  border-color: rgb(36 114 60 / 0.35);
  color: #24723c;
}

.item-state-pill.is-collapsed {
  border-color: rgb(125 85 199 / 0.35);
  color: #7d55c7;
}

.custom-item-card .item-message {
  color: var(--muted);
  font-style: italic;
}

.custom-item-card .item-save-state {
  color: var(--muted);
}

.custom-item-card .item-save-state.saved {
  color: #24723c;
}

.custom-item-card .item-save-state.unsaved {
  color: var(--accent);
}

.custom-item-card .item-collapse-state {
  color: #7d55c7;
}

.custom-item-actions {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 10px;
  align-items: stretch;
}

.custom-item-actions button {
  flex: 0 1 auto;
  min-height: 48px;
  min-width: 0;
  padding: 11px 14px;
  overflow-wrap: anywhere;
  white-space: nowrap;
}

.custom-item-tool-panel {
  padding: 18px 20px;
  border: 1px solid var(--line-light);
  background: #fff;
}

.custom-message-panel {
  max-width: 760px;
}

.custom-item-status {
  margin: 0;
  color: var(--muted);
}

.custom-work-panel[hidden],
.custom-item-tool-panel[hidden] {
  display: none !important;
}

.custom-work-panel {
  border-top: 0;
  padding-top: 0;
  padding-bottom: 24px;
}

.custom-work-panel > .section-title {
  display: none;
}


.inline-note-accent {
  color: var(--accent);
}

input:focus,
select:focus {
  border-color: var(--text);
}

.upload-tabs {
  width: 100%;
  max-width: none;
}

.tab-list {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.tab-button {
  position: relative;
  min-width: 128px;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0 0 13px;
  text-align: left;
  font-size: 16px;
  line-height: 1.6;
}

.tab-button + .tab-button {
  margin-left: 34px;
}

.tab-button:hover {
  color: var(--text);
  opacity: 1;
}

.tab-button.active {
  color: var(--text);
}

.tab-button.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--text);
}

.tab-panel {
  max-width: none;
}

.upload-tabs > .tab-list[hidden],
.lightbox-method-tabs[hidden] {
  display: none !important;
}

.tab-panel[hidden] {
  display: none;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 154px;
  border: 1px dashed #c7b9a9;
  border-radius: 0;
  background: #fff;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.drop-zone.compact {
  min-height: 132px;
  padding: 18px;
}

.drop-zone:hover {
  border-color: var(--text);
}

.drop-zone input {
  display: none;
}

.drop-zone strong {
  color: var(--text);
  font-size: 17px;
  font-weight: normal;
  line-height: 1.25;
}

.drop-zone small {
  max-width: 440px;
  color: var(--muted);
  line-height: 1.35;
}

.drop-zone small.is-warning {
  color: var(--accent);
  font-weight: normal;
}

.video-layout {
  display: block;
}

#videoPanel.has-video .video-layout {
  display: block;
}

.video-drop {
  min-height: 168px;
}

.video-tools {
  display: grid;
  gap: 12px;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line-light);
  background: #fff;
}

.video-tools[hidden] {
  display: none;
}

.video-preview-card {
  display: grid;
  place-items: center;
  min-height: 280px;
  border: 1px solid var(--line);
  background: #111;
}

.video-preview-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #111;
}

.video-zoom-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  transition: transform 0.15s ease;
}

.video-crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.video-crop-overlay.active {
  pointer-events: none;
}

.video-crop-drag-target {
  position: absolute;
  z-index: 3;
  display: block;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}

.video-crop-drag-target[hidden] {
  display: none;
}

.video-crop-drag-target.dragging {
  cursor: grabbing;
}

.crop-mode-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  align-self: end;
}

.crop-mode-toggle button {
  flex: 1;
  padding: 14px 18px;
  border: 0;
  background: #f5f5f5;
  color: #555;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.crop-mode-toggle button:first-child {
  border-right: 1px solid var(--line);
}

.crop-mode-toggle button.active {
  background: var(--accent, #2271b1);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
}

.crop-mode-toggle button:not(.active):hover {
  background: #e5e5e5;
}

#sourceVideo {
  display: block;
  width: 100%;
  max-height: 420px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #111;
  border-radius: 0;
}

.video-controls {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(180px, max-content) minmax(160px, 220px) minmax(240px, max-content);
  align-items: end;
  justify-content: start;
  gap: 10px;
}

.video-time-row,
.video-action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  gap: 10px;
}

.video-action-row .button-with-help {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.video-action-row > button,
.video-action-row .button-with-help > button:not(.help-icon) {
  width: 100%;
}

.video-crop-size-control {
  display: grid;
  gap: 6px;
  min-width: 160px;
  line-height: 1.25;
}

.video-crop-size-control input[type="range"] {
  width: 100%;
  height: 34px;
}

.video-tools button:not(.help-icon),
.video-tools .crop-mode-toggle {
  border-radius: 0;
}

.lightbox-designer {
  display: grid;
  gap: 24px;
  max-width: none;
}

.lightbox-spec-card {
  background: #fff;
  border: 1px solid var(--line-light);
  box-shadow: 0 12px 28px rgb(0 0 0 / 0.04);
}

.lightbox-spec-card {
  display: grid;
  gap: 4px;
  padding: 28px 34px;
}

.lightbox-spec-card span {
  color: var(--text);
  font-size: 20px;
  line-height: 1.45;
}

.lightbox-spec-card strong {
  color: var(--muted);
  font-size: 17px;
  font-weight: normal;
  line-height: 1.45;
}

.lightbox-method-tabs {
  margin-bottom: 0;
}

.lightbox-content-card {
  display: grid;
  gap: 20px;
  padding: 0;
}

.lightbox-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-light);
}

.lightbox-card-head h3 {
  margin: 0;
  font-size: 22px;
  font-weight: normal;
  line-height: 1.4;
}

.lightbox-card-head span {
  color: #6d77cf;
  font-size: 18px;
}

.lightbox-workspace {
  display: grid;
  gap: 24px;
}

.lightbox-stage {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 0;
  background: #fff;
  position: relative;
}

#lightboxCanvas {
  display: block;
  width: 100%;
  max-height: 440px;
  aspect-ratio: 2055 / 579;
  background: #fff;
  border: 1px solid #dedede;
  box-shadow: none;
  cursor: grab;
}

#lightboxCanvas.is-empty {
  cursor: pointer;
}

#lightboxCanvas:active {
  cursor: grabbing;
}

.lightbox-canvas-upload {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  cursor: pointer;
}

.lightbox-canvas-upload.is-active {
  display: block;
}

.lightbox-tools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: stretch;
}

.lightbox-tool-panel {
  display: grid;
  gap: 16px;
}

#lightboxImageTools:not([hidden]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 142px);
  grid-column: 1;
  align-items: end;
}

#lightboxImageTools:not([hidden]) .tool-group {
  grid-column: 1 / -1;
}

#lightboxImageTools:not([hidden]) .lightbox-slider {
  grid-column: 1;
}

#lightboxTextTools:not([hidden]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 142px);
  grid-column: 1;
  align-items: end;
}

.visually-hidden-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.tool-buttons.lightbox-align-buttons {
  display: grid;
  grid-template-columns: repeat(6, minmax(76px, 1fr));
  gap: 8px;
}

.tool-buttons.lightbox-align-buttons button {
  width: auto;
  min-width: 0;
  min-height: 34px;
  padding: 7px 12px;
  font-size: 14px;
}

.lightbox-slider {
  display: grid;
  gap: 8px;
  margin-top: 2px;
  width: 100%;
  max-width: none;
}

.lightbox-slider input {
  width: 100%;
}

.lightbox-tool-save {
  grid-column: 2;
  align-self: end;
  width: 100%;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  padding-inline: 16px;
  font-size: 16px;
}

.lightbox-text-align {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.lightbox-text-align button {
  width: 100%;
  height: 44px;
  min-height: 44px;
}

.lightbox-text-input {
  width: 100%;
}

.lightbox-color-palette {
  display: grid;
  gap: 6px;
}

.lightbox-scroll-tools {
  display: grid;
  gap: 16px;
  min-height: 0;
}

#lightboxTextTools:not([hidden]) .text-grid,
#lightboxTextTools:not([hidden]) .lightbox-color-palette,
#lightboxTextTools:not([hidden]) .lightbox-scroll-tools {
  grid-column: 1 / -1;
}

#lightboxTextTools:not([hidden]) .text-grid {
  grid-template-columns: minmax(160px, 220px) minmax(160px, 220px) minmax(320px, 1fr);
  align-items: end;
}

.lightbox-tool-panel .text-color-buttons {
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
}

.lightbox-tool-panel .text-color {
  min-height: 30px;
  padding: 5px 7px 5px 22px;
  font-size: 12px;
}

.lightbox-tool-panel .text-color::before {
  left: 7px;
  width: 9px;
  height: 9px;
}

.lightbox-close-btn {
  display: none;
}

body.preview-mobile.lightbox-focus-mode {
  overflow: hidden;
}

body.lightbox-editing-mobile {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  overflow: hidden !important;
}

body.preview-mobile.lightbox-focus-mode #lightboxDesigner {
  position: fixed;
  top: var(--customizer-safe-top, 0px);
  right: 0;
  bottom: var(--customizer-safe-bottom, 0px);
  left: 0;
  z-index: 2147482450;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  height: calc(100dvh - var(--customizer-safe-top, 0px) - var(--customizer-safe-bottom, 0px));
  max-height: calc(100dvh - var(--customizer-safe-top, 0px) - var(--customizer-safe-bottom, 0px));
  margin: 0;
  padding: 8px;
  overflow: hidden;
  background: #fff;
  border: 0;
  box-shadow: none;
  transform: none;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

body.preview-mobile.lightbox-focus-mode #lightboxDesigner[hidden] {
  display: none !important;
}

body.preview-mobile.lightbox-focus-mode #lightboxDesigner > .section-title {
  display: flex;
  align-items: center;
  margin: 0 0 12px;
}

body.preview-mobile.lightbox-focus-mode #lightboxDesigner > .section-title > div {
  min-width: 0;
}

body.preview-mobile.lightbox-focus-mode .lightbox-close-btn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  margin-left: auto;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

body.preview-mobile.lightbox-focus-mode #lightboxDesigner > .section-title p {
  display: none;
}

body.preview-mobile.lightbox-focus-mode .lightbox-designer,
body.preview-mobile.lightbox-focus-mode .lightbox-content-card,
body.preview-mobile.lightbox-focus-mode .lightbox-workspace {
  min-height: 0;
  height: 100%;
}

body.preview-mobile.lightbox-focus-mode .lightbox-designer,
body.preview-mobile.lightbox-focus-mode .lightbox-content-card {
  overflow: visible;
}

body.preview-mobile.lightbox-focus-mode .lightbox-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  overflow: hidden;
}

body.preview-mobile.lightbox-focus-mode .lightbox-designer {
  width: min(calc(100vw - 28px), 820px);
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
}

body.preview-mobile.lightbox-focus-mode .lightbox-stage {
  min-height: 0;
  padding: 0;
  background: #fff;
}

body.preview-mobile.lightbox-focus-mode #lightboxCanvas {
  max-height: min(34dvh, 360px);
}

body.preview-mobile.lightbox-focus-mode .lightbox-tools {
  min-height: 0;
  overflow: visible;
  padding: 12px;
  border: 1px solid var(--line-light);
  background: #fff;
}

body.preview-mobile.lightbox-focus-mode .lightbox-tools.is-text-mode {
  display: block;
  overflow: hidden;
  padding: 12px 12px 0;
}

body.preview-mobile.lightbox-focus-mode #lightboxTextTools:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body.preview-mobile.lightbox-focus-mode #lightboxTextTools:not([hidden]) .text-grid {
  flex: 0 0 auto;
}

body.preview-mobile.lightbox-focus-mode #lightboxTextTools:not([hidden]) .lightbox-scroll-tools {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 0 14px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
  body.preview-mobile.lightbox-focus-mode #lightboxDesigner {
    top: var(--customizer-safe-top, 0px);
    bottom: var(--customizer-safe-bottom, 0px);
    width: 100%;
    height: calc(100dvh - var(--customizer-safe-top, 0px) - var(--customizer-safe-bottom, 0px));
    max-height: calc(100dvh - var(--customizer-safe-top, 0px) - var(--customizer-safe-bottom, 0px));
    padding: 8px;
  }

  body.preview-mobile.lightbox-focus-mode #lightboxCanvas {
    max-height: min(30dvh, 260px);
  }
}

#lightboxStatus.is-warning {
  color: var(--accent);
}

#lightboxStatus.is-error {
  color: #c43b2f;
}

#lightboxStatus.is-success {
  color: var(--ok);
}

.button-with-help {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.help-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
}

.help-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 10;
  width: min(320px, 78vw);
  padding: 12px 14px;
  background: #282828;
  color: #fff;
  font-size: 12px;
  line-height: 1.55;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.help-icon:hover::after,
.help-icon:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.queue-toolbar,
.submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.queue-toolbar {
  padding-bottom: 10px;
}

.queue-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 160px;
}

.queue-actions button {
  width: auto;
  min-width: 132px;
}

.queue-actions button,
.playback-bar [role="button"],
#playbackToggleBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.button-state-icon {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  color: currentColor;
  flex: 0 0 auto;
}

.button-state-icon--play {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid currentColor;
}

.button-state-icon--stop {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: currentColor;
}

.button-state-icon--sort::before,
.button-state-icon--sort::after,
.button-state-icon--check::before {
  content: "";
  position: absolute;
  display: block;
}

.button-state-icon--sort::before {
  inset: 2px 1px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.button-state-icon--sort::after {
  left: 3px;
  right: 3px;
  top: 6px;
  height: 2px;
  background: currentColor;
}

.button-state-icon--check::before {
  left: 2px;
  top: 1px;
  width: 8px;
  height: 12px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(42deg);
}

.queue-actions button.active {
  background: var(--text);
  border-color: var(--text);
  color: white;
}

#queueStatus,
#submitStatus {
  color: var(--muted);
  margin: 0;
  line-height: 1.35;
}

.status-message {
  color: var(--muted);
}

.status-message.is-warning {
  color: var(--accent);
}

.status-message.is-error {
  color: #c43b2f;
}

.status-message.is-success {
  color: var(--ok);
}

#queueStatus.status-message.is-warning,
#submitStatus.status-message.is-warning {
  color: var(--accent);
}

#queueStatus.status-message.is-error,
#submitStatus.status-message.is-error {
  color: #c43b2f;
}

#queueStatus.status-message.is-success,
#submitStatus.status-message.is-success {
  color: var(--ok);
}

.image-queue {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.image-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 0;
  overflow: hidden;
  cursor: grab;
}

.image-card:active {
  cursor: grabbing;
}

body.preview-mobile .image-card {
  cursor: default;
}

body.preview-mobile .image-card:active {
  cursor: default;
}

.image-queue.is-sorting .image-card {
  cursor: grab;
}

.image-queue.is-sorting .image-card:active {
  cursor: grabbing;
}

.image-card--empty {
  border: 2px dashed var(--line);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-height: 140px;
}

.image-card--empty:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.image-empty-slot {
  width: 100%;
  height: 100%;
  min-height: 140px;
  background: none;
  border: 0;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.4;
  padding: 20px;
}

.image-empty-slot:hover {
  color: var(--accent);
}

.image-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  aspect-ratio: 1163 / 951;
  background: #fff;
  border: 0;
  overflow: hidden;
  cursor: zoom-in;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.image-preview::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08);
  transform: translateY(-50%);
}

.image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
}

body.preview-mobile .image-preview {
  pointer-events: none;
  cursor: default;
}

body.preview-mobile .image-preview:active,
body.preview-mobile .image-preview:focus {
  background: transparent;
  opacity: 1;
  outline: 0;
}

.image-meta {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.image-meta strong {
  font-size: 13px;
  font-weight: normal;
  color: var(--text);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.image-actions {
  display: flex;
  gap: 6px;
}

.image-actions button {
  flex: 1;
  min-width: 0;
  padding: 7px 6px;
  font-size: 11px;
  white-space: nowrap;
}

.image-actions button.danger {
  background: #c43b2f;
  border-color: #c43b2f;
  color: white;
}

.sortable-ghost {
  opacity: 0.45;
}

.preview-stack {
  display: grid;
  gap: 22px;
  align-items: start;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 14px;
  align-items: start;
}

.empty-preview {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  border: 1px dashed #c7b9a9;
  padding: 34px;
  text-align: center;
}

.preview-thumb {
  display: grid;
  gap: 8px;
  align-content: start;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 0;
  text-align: left;
}

.preview-thumb:hover {
  opacity: 1;
  color: var(--text);
}

.preview-thumb img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  padding: 3px;
}

.preview-thumb span {
  display: block;
  width: 100px;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.submit-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  gap: 22px;
  align-items: start;
}

.submit-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.submit-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
}

.submit-actions button {
  width: auto;
  flex: 0 0 auto;
  min-width: 140px;
  box-sizing: border-box;
}

.submit-actions #submitBtn {
  border: 1px solid transparent;
}

#submitStatus {
  grid-column: 1 / -1;
  margin-top: -6px;
}

.upload-progress {
  grid-column: 1 / -1;
  margin-top: -4px;
  width: 100%;
}

.upload-progress-track {
  height: 8px;
  background: #ececec;
  border: 1px solid var(--line-light);
  overflow: hidden;
}

.upload-progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  min-width: 0;
  background: var(--accent);
  transition: width 0.18s ease;
}

.upload-progress p {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

dialog {
  position: absolute;
  top: var(--dialog-top, 50%);
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(1440px, calc(100vw - 24px));
  max-height: var(--dialog-max-height, calc(100dvh - 36px));
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  overflow: visible;
}

body.standalone-customizer-page dialog {
  --dialog-safe-top: var(--customizer-safe-top, 0px);
  --dialog-safe-bottom: var(--customizer-safe-bottom, 0px);
  top: max(var(--dialog-safe-top), var(--dialog-top, 50%));
  max-height: calc(100dvh - var(--dialog-safe-top) - var(--dialog-safe-bottom) - 24px);
}

dialog::backdrop,
#cropDialog::backdrop,
#previewDialog::backdrop {
  background: transparent !important;
  backdrop-filter: none !important;
}

dialog[open] {
  background: transparent;
}

#playbackDialog {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(92vw, 900px);
  max-height: calc(100dvh - 36px);
  transform: translate(-50%, -50%);
  overflow: visible;
}

body.standalone-customizer-page #playbackDialog {
  top: calc(var(--customizer-safe-top, 0px) + (100dvh - var(--customizer-safe-top, 0px) - var(--customizer-safe-bottom, 0px)) / 2);
  max-height: calc(100dvh - var(--customizer-safe-top, 0px) - var(--customizer-safe-bottom, 0px) - 24px);
}

#playbackDialog[open] {
  display: grid;
  place-items: center;
}

#previewDialog {
  width: auto;
  max-width: calc(100vw - 24px);
  background: transparent;
  justify-items: center;
}

#previewDialog[open] {
  display: grid;
}

.crop-dialog {
  margin: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: var(--dialog-max-height, calc(100dvh - 36px));
  padding: 18px 18px 22px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 18px 60px rgb(0 0 0 / 0.24);
}

body.standalone-customizer-page .crop-dialog {
  max-height: calc(100dvh - var(--customizer-safe-top, 0px) - var(--customizer-safe-bottom, 0px) - 24px);
}

body.standalone-customizer-page:not(.preview-mobile) #cropDialog[open] {
  position: fixed;
  top: calc(var(--customizer-safe-top, 0px) + 12px);
  bottom: calc(var(--customizer-safe-bottom, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: min(1440px, calc(100vw - 24px));
  max-height: none;
}

body.standalone-customizer-page:not(.preview-mobile) #cropDialog[open] .crop-dialog {
  height: 100%;
  max-height: none;
}

body.standalone-customizer-page:not(.preview-mobile) #cropDialog[open] .crop-preview-panel,
body.standalone-customizer-page:not(.preview-mobile) #cropDialog[open] .crop-sidebar {
  max-height: 100%;
}

.preview-dialog {
  margin: 0 auto;
  width: min(760px, calc(100vw - 36px));
  padding: 16px;
  background: #fff;
  box-shadow: 0 18px 60px rgb(0 0 0 / 0.24);
}

.preview-dialog img {
  display: block;
  width: 100%;
  max-height: min(calc(var(--dialog-max-height, 760px) - 150px), 620px);
  object-fit: contain;
  margin: 14px auto;
  border: 1px solid var(--line);
  background: #fff;
}

.preview-nav {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.preview-nav button {
  min-height: 38px;
  min-width: 118px;
  padding: 9px 18px;
  font-size: 14px;
}

.dialog-head,
.crop-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: normal;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  background: #282828;
}

.mobile-save-crop-btn {
  display: none;
}

.crop-editor-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(340px, 430px);
  gap: 22px;
  min-height: 0;
  height: 100%;
  align-items: start;
  overflow: hidden;
}

.crop-preview-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  min-width: 0;
  position: sticky;
  top: 0;
  align-self: start;
  z-index: 2;
  max-height: calc(100dvh - 122px);
}

.crop-stage {
  position: relative;
  height: min(100%, clamp(360px, calc(100dvh - 150px), 730px));
  margin: 16px 0 0;
  background: #202020;
  overflow: hidden;
  border-radius: 0;
  touch-action: none;
}

#cropCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.crop-frame {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.45);
  pointer-events: none;
  box-sizing: border-box;
}

.crop-frame::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: #fff;
  transform: translateY(-50%);
}

.crop-sidebar {
  display: grid;
  align-content: start;
  gap: 10px;
  max-height: calc(100dvh - 122px);
  margin-top: 16px;
  padding-right: 4px;
  overflow: auto;
  overscroll-behavior: contain;
}

.tool-group {
  display: grid;
  gap: 6px;
}

.tool-group > span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.tool-buttons {
  display: grid;
  gap: 6px;
}

.align-buttons {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.tool-buttons button {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.3;
}

.icon-tool-button {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.background-sections {
  display: grid;
  gap: 0;
}

.background-buttons {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.swatch-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  min-width: 0;
  padding-inline: 6px;
}

.swatch-button.active {
  border-color: var(--text);
}

.swatch {
  width: 12px;
  height: 12px;
  display: inline-block;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.swatch-white {
  background: #fff;
}

.swatch-cream {
  background: #fbf4df;
}

.swatch-warm {
  background: #f6efe3;
}

.swatch-gray {
  background: #ededed;
}

.swatch-sage {
  background: #dfe9df;
}

.swatch-sky {
  background: #dcebf7;
}

.swatch-blush {
  background: #f6dede;
}

.swatch-linen {
  background:
    repeating-linear-gradient(0deg, rgb(122 99 62 / 0.16) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(90deg, rgb(122 99 62 / 0.12) 0 1px, transparent 1px 7px),
    #f7f4ec;
}

.swatch-paper {
  background:
    linear-gradient(rgb(255 255 255 / 0.68), rgb(255 255 255 / 0.68)),
    repeating-linear-gradient(0deg, rgb(80 120 170 / 0.22) 0 1px, transparent 1px 9px),
    #faf7ed;
}

.swatch-grid {
  background:
    repeating-linear-gradient(0deg, rgb(40 40 40 / 0.12) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(90deg, rgb(40 40 40 / 0.12) 0 1px, transparent 1px 6px),
    #f9f8ef;
}

.swatch-dots {
  background:
    radial-gradient(circle, rgb(40 40 40 / 0.22) 1px, transparent 1px),
    #f7f2e9;
  background-size: 7px 7px;
}

.swatch-stripe {
  background:
    repeating-linear-gradient(45deg, rgb(220 152 20 / 0.28) 0 5px, transparent 5px 12px),
    #fff7e8;
}

.swatch-wood {
  background:
    repeating-linear-gradient(0deg, rgb(88 52 22 / 0.16) 0 2px, transparent 2px 9px),
    #d8b482;
}

.swatch-marble {
  background:
    linear-gradient(135deg, rgb(80 80 80 / 0.16), transparent 32%),
    linear-gradient(35deg, transparent 45%, rgb(80 80 80 / 0.12) 46% 48%, transparent 50%),
    #f4f2ed;
}

.swatch-stars {
  background:
    radial-gradient(circle, #fff 1px, transparent 1px),
    #273142;
  background-size: 9px 9px;
}

.swatch-dark {
  background: #222;
}

.text-tool-group input,
.text-tool-group select {
  padding: 9px 10px;
}

.text-tool-group select {
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 50% / 7px 7px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 13px) 50% / 7px 7px no-repeat,
    #fff;
  padding-right: 36px;
  line-height: 1.2;
  text-align: left;
}

.text-tool-group select:focus {
  background:
    linear-gradient(45deg, transparent 50%, var(--text) 50%) calc(100% - 18px) 50% / 7px 7px no-repeat,
    linear-gradient(135deg, var(--text) 50%, transparent 50%) calc(100% - 13px) 50% / 7px 7px no-repeat,
    #fff;
}

.text-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}

.text-color-buttons,
.text-position-buttons,
.symbol-buttons {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.symbol-buttons {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.symbol-buttons button {
  min-height: 30px;
  padding: 4px;
  font-size: 13px;
}

.text-color {
  position: relative;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  padding-left: 21px;
}

.text-color::before {
  content: "";
  position: absolute;
  left: 6px;
  width: 10px;
  height: 10px;
  border: 1px solid var(--line);
  background: var(--text-color);
}

.text-color.active,
.text-position-buttons button.active {
  border-color: var(--text);
}

.color-picker-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  min-height: 34px;
  gap: 8px;
}

.color-picker-row input[type="color"] {
  width: 100%;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.custom-color-icon {
  display: grid;
  place-items: center;
  height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
}

.app-footer {
  display: flex;
  justify-content: center;
  gap: 14px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 30px 30px;
  color: #aaa;
  font-size: 12px;
  line-height: 1.4;
}

.crop-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px 74px;
  align-items: end;
  align-self: end;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-light);
}

.crop-actions label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.crop-actions button {
  min-height: 44px;
  padding: 10px 12px;
}

#rotateCropBtn {
  font-size: 13px;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .image-queue {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .crop-dialog {
    max-height: calc(100dvh - 24px);
  }

  .crop-editor-layout {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  }

  .crop-stage {
    height: min(58vh, 520px);
  }

  .crop-sidebar {
    max-height: calc(100dvh - 138px);
    overflow: auto;
  }
}

@media (max-width: 820px) {
  .preview-dialog {
    width: calc(100vw - 24px);
    padding: 14px;
  }

  .preview-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .preview-nav button {
    min-width: 0;
  }

  .image-queue {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .image-actions {
    gap: 5px;
  }

  .image-actions button {
    padding-inline: 5px;
  }

  .app-header {
    padding: 30px 18px 24px;
  }

  .shell {
    padding: 28px 18px 0;
  }

  .panel {
    display: block;
    padding: 32px 0;
  }

  .section-title {
    margin-bottom: 22px;
  }

  .form-grid,
  .video-tools,
  .submit-card,
  .tab-button {
    min-width: 0;
    flex: 1;
  }

  .tab-button + .tab-button {
    margin-left: 22px;
  }

  .queue-toolbar,
  .submit-row,
  .video-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .crop-stage {
    height: min(52vh, 420px);
  }

  .align-buttons,
  .background-buttons,
  .text-color-buttons,
  .text-position-buttons,
  .symbol-buttons,
  .lightbox-text-align {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tool-buttons.lightbox-align-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .lightbox-stage {
    min-height: 240px;
    padding: 10px;
  }

  .lightbox-tools {
    grid-template-columns: 1fr;
  }

  .lightbox-tool-save {
    grid-column: 1;
    width: 100%;
  }

  #lightboxImageTools:not([hidden]) {
    display: grid;
    grid-template-columns: 1fr;
  }

  #lightboxTextTools:not([hidden]) {
    grid-template-columns: 1fr;
  }

  #lightboxImageTools:not([hidden]) .tool-group,
  #lightboxImageTools:not([hidden]) .lightbox-slider,
  #lightboxTextTools:not([hidden]) {
    grid-column: 1;
  }

  .lightbox-designer {
    max-width: none;
  }

  .lightbox-spec-card,
  .lightbox-content-card {
    padding: 22px 18px;
  }
}

@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  body {
    font-size: 13px;
    line-height: 1.65;
  }

  button {
    width: 100%;
    min-height: 46px;
    padding: 13px 14px;
  }

  .icon-button {
    width: 44px;
    min-height: 44px;
    padding: 0;
  }

  .help-icon {
    width: 30px;
    min-height: 30px;
    padding: 0;
  }

  .app-header {
    display: block;
    padding: 22px 18px 20px;
  }

  .app-header h1 {
    font-size: 25px;
    line-height: 1.25;
  }

  .header-note {
    max-width: none;
    font-size: 13px;
    line-height: 1.5;
  }

  .admin-link {
    display: inline-block;
    margin-top: 12px;
  }

  .shell {
    width: 100%;
    max-width: none;
    margin-bottom: 36px;
    padding: 20px 18px 0;
  }

  .panel {
    display: grid;
    grid-template-columns: 1fr;
    row-gap: 18px;
    column-gap: 0;
    padding: 28px 0;
  }

  .panel > :not(.section-title) {
    grid-column: 1;
    min-width: 0;
  }

  .section-title {
    gap: 10px;
    margin-bottom: 0;
  }

  .section-title h2 {
    font-size: 22px;
    line-height: 1.25;
  }

  .section-title p {
    font-size: 13px;
    line-height: 1.5;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .product-select-row {
    grid-template-columns: 1fr;
  }

  label {
    min-width: 0;
    font-size: 13px;
  }

  .field-label-row {
    display: grid;
    gap: 4px;
    min-height: 0;
  }

  .inline-note {
    white-space: normal;
    line-height: 1.35;
  }

  input,
  select {
    width: 100%;
    min-width: 0;
    height: 50px;
    line-height: 50px;
  }

  .custom-item-list {
    grid-template-columns: 1fr;
  }

  .custom-item-card {
    min-height: 0;
  }

  .custom-item-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .tab-list {
    overflow-x: auto;
    margin-bottom: 18px;
  }

  .tab-button {
    width: auto;
    min-width: max-content;
    font-size: 15px;
  }

  .drop-zone,
  .dropzone {
    min-height: 118px;
    padding: 14px 12px;
  }

  .queue-toolbar,
  .submit-row,
  .video-controls {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: var(--mobile-gap);
  }

  .submit-row > *,
  .queue-toolbar > * {
    width: 100%;
    min-width: 0;
  }

  .queue-actions {
    min-width: 0;
  }

  .submit-actions {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
  }

  .submit-actions button {
    width: auto;
    flex: 0 0 auto;
  }

  .submit-row button {
    width: 100%;
  }

  .image-queue {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .image-actions {
    grid-template-columns: 1fr 1fr;
  }

  .lightbox-workspace,
  .text-grid {
    grid-template-columns: 1fr;
  }

  .lightbox-stage {
    min-width: 0;
    min-height: 210px;
    padding: 8px;
  }

  .lightbox-tools {
    grid-template-columns: 1fr;
  }

  #lightboxImageTools:not([hidden]),
  #lightboxTextTools:not([hidden]) {
    grid-template-columns: 1fr;
  }

  .tool-buttons,
  .lightbox-align-buttons,
  .lightbox-text-align,
  .text-color-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .crop-dialog,
  .preview-dialog {
    width: calc(100vw - 28px);
    max-width: calc(100vw - 28px);
    padding: 18px;
  }

  .crop-editor-layout,
  .crop-body {
    grid-template-columns: 1fr;
    max-height: calc(100vh - 120px);
    overflow: auto;
  }

  .crop-dialog {
    overflow: auto;
  }

  .crop-preview-panel {
    position: sticky;
    top: 0;
  }

  .crop-sidebar {
    max-height: none;
    overflow: visible;
  }

  .crop-stage {
    height: min(52vh, 420px);
  }

  .preview-dialog img {
    max-height: 56vh;
  }

  .preview-nav {
    grid-template-columns: 1fr 1fr;
  }

  .app-footer {
    justify-content: center;
    flex-wrap: wrap;
    padding: 0 18px 24px;
  }
}

@media (max-width: 420px) {
  .shell {
    padding-right: 14px;
    padding-left: 14px;
  }

  .app-header h1 {
    font-size: 23px;
  }

  .image-queue {
    grid-template-columns: 1fr;
  }

  .custom-item-card {
    padding: 13px;
  }
}

/* ── Split-flap playback dialog ── */

.playback-dialog {
  width: min(92vw, 900px);
  max-height: calc(100dvh - 36px);
  border: 0;
  padding: 0;
  background: #111;
  margin: 0;
  overflow: auto;
}

body.standalone-customizer-page .playback-dialog {
  max-height: calc(100dvh - var(--customizer-safe-top, 0px) - var(--customizer-safe-bottom, 0px) - 24px);
}

.playback-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  max-height: 70vh;
  padding: 20px;
}

.flip-holder {
  position: relative;
  max-width: 100%;
  max-height: 65vh;
  overflow: hidden;
}

.flip-top-next,
.flip-bot,
.flip-top,
.flip-bot-next {
  position: absolute;
  left: 0;
  right: 0;
  height: 50%;
  backface-visibility: hidden;
  background-size: cover;
  background-repeat: no-repeat;
}

.flip-top-next,
.flip-top {
  top: 0;
  background-position: center top;
}

.flip-bot,
.flip-bot-next {
  bottom: 0;
  background-position: center bottom;
}

.flip-top-next,
.flip-bot {
  z-index: 1;
}

.flip-top {
  z-index: 3;
  transform-origin: bottom center;
}

.flip-bot-next {
  z-index: 2;
  transform-origin: top center;
}

.playback-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: #222;
  color: #ccc;
  font-size: 14px;
}

.playback-bar label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #999;
  font-size: 13px;
  margin-left: auto;
}

.playback-bar select {
  width: auto;
  padding: 4px 8px;
  height: auto;
  font-size: 13px;
  background: #333;
  color: #ccc;
  border: 1px solid #555;
}

#playbackToggleBtn {
  background: var(--button);
  color: #fff;
  border: 0;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  min-width: 102px;
}

#playbackLabel {
  font-variant-numeric: tabular-nums;
  color: #ccc;
}

body.crop-editing-mobile {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  overflow: hidden !important;
}

/* Final mobile crop editor contract: a self-contained edit page. The preview
   stays fixed, and only the tools panel can scroll between hard limits. */
body.preview-mobile .crop-inline-anchor {
  display: block !important;
  grid-column: 1 / -1 !important;
  position: relative !important;
  top: auto !important;
  z-index: 1 !important;
  width: 100% !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] {
  display: block !important;
  position: fixed !important;
  top: var(--customizer-safe-top, 0px) !important;
  right: 0 !important;
  bottom: var(--customizer-safe-bottom, 0px) !important;
  left: 0 !important;
  transform: none !important;
  width: 100% !important;
  max-width: 100% !important;
  height: calc(100dvh - var(--customizer-safe-top, 0px) - var(--customizer-safe-bottom, 0px)) !important;
  max-height: calc(100dvh - var(--customizer-safe-top, 0px) - var(--customizer-safe-bottom, 0px)) !important;
  margin: 0 !important;
  padding: calc(var(--mobile-crop-fixed-height, 0px) + 14px) 0 0 !important;
  overflow: hidden !important;
  background: #fff !important;
  border: 0 !important;
  box-shadow: none !important;
  z-index: 2147482400 !important;
  touch-action: auto !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-dialog {
  width: min(calc(100vw - 28px), 820px) !important;
  max-width: min(calc(100vw - 28px), 820px) !important;
  height: auto !important;
  max-height: none !important;
  display: block !important;
  position: fixed !important;
  top: calc(var(--customizer-safe-top, 0px) + 8px) !important;
  left: 50% !important;
  z-index: 2147482410 !important;
  transform: translateX(-50%) !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: #fff !important;
  border: 1px solid rgb(40 40 40 / 0.12) !important;
  box-shadow: 0 14px 28px rgb(0 0 0 / 0.12) !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-editor-layout {
  display: block !important;
  grid-template-columns: 1fr !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .dialog-head,
body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-preview-panel {
  flex: 0 0 auto !important;
  position: relative !important;
  top: auto !important;
  background: #fff !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .dialog-head {
  min-height: 42px !important;
  padding: 8px 10px 6px !important;
  border-bottom: 1px solid rgb(40 40 40 / 0.08) !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 92px 34px !important;
  align-items: center !important;
  gap: 8px !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .dialog-head h2 {
  font-size: 17px !important;
  line-height: 1.2 !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .dialog-head .icon-button {
  width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  font-size: 16px !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .mobile-save-crop-btn {
  display: block !important;
  width: 92px !important;
  min-height: 34px !important;
  padding: 6px 12px !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-preview-panel {
  display: grid !important;
  gap: 8px !important;
  padding: 9px 12px 10px !important;
  border-bottom: 1px solid rgb(40 40 40 / 0.08) !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-stage {
  height: clamp(190px, 31dvh, 300px) !important;
  aspect-ratio: auto !important;
  min-height: 0 !important;
  margin-top: 0 !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-actions {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 8px !important;
  order: 2 !important;
  align-self: stretch !important;
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 8px 0 10px !important;
  border-top: 0 !important;
  border-bottom: 1px solid rgb(40 40 40 / 0.08) !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-actions label {
  display: grid !important;
  grid-template-rows: auto 34px !important;
  grid-column: 1 / span 3 !important;
  align-items: end !important;
  font-size: 13px !important;
  line-height: 1.2 !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-actions input[type="range"] {
  display: block !important;
  width: 100% !important;
  inline-size: 100% !important;
  max-width: none !important;
  height: 28px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-sizing: border-box !important;
  accent-color: #007aff !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-actions button {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 42px !important;
  padding: 10px 12px !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] #rotateCropBtn {
  grid-column: 4 !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] #saveCropBtn {
  display: none !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-sidebar {
  display: flex !important;
  flex-direction: column !important;
  position: fixed !important;
  top: calc(var(--customizer-safe-top, 0px) + var(--mobile-crop-fixed-height, 0px) + 18px) !important;
  left: 50% !important;
  bottom: var(--customizer-safe-bottom, 0px) !important;
  z-index: 2147482405 !important;
  transform: translateX(-50%) !important;
  width: min(calc(100vw - 28px), 820px) !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  margin-top: 0 !important;
  padding: 12px 14px calc(24px + env(safe-area-inset-bottom)) !important;
  background: #fff !important;
  border: 1px solid rgb(40 40 40 / 0.1) !important;
  border-radius: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-align-group {
  order: 1 !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .crop-background-group {
  order: 3 !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .text-tool-group {
  order: 4 !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .align-buttons,
body.preview-mobile #cropDialog.is-mobile-inline[open] .background-buttons,
body.preview-mobile #cropDialog.is-mobile-inline[open] .text-color-buttons,
body.preview-mobile #cropDialog.is-mobile-inline[open] .symbol-buttons {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .text-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 8px !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .text-tool-group {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 6px 8px !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .text-tool-group > span,
body.preview-mobile #cropDialog.is-mobile-inline[open] #textOverlayInput,
body.preview-mobile #cropDialog.is-mobile-inline[open] .text-grid,
body.preview-mobile #cropDialog.is-mobile-inline[open] .text-color-buttons,
body.preview-mobile #cropDialog.is-mobile-inline[open] .symbol-buttons {
  grid-column: 1 / -1 !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .color-picker-row {
  display: inline-grid !important;
  grid-template-columns: 1fr !important;
  grid-column: 1 !important;
  width: 100% !important;
  min-height: 42px !important;
  margin: 0 !important;
  gap: 0 !important;
  position: relative !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .custom-color-icon {
  width: 100% !important;
  height: 42px !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
  font-size: 22px !important;
  line-height: 1 !important;
  background: #fff !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .custom-color-icon::after {
  content: none !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .color-picker-row input[type="color"] {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  opacity: 0 !important;
  cursor: pointer !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open] .text-position-buttons {
  grid-column: 2 / -1 !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  margin-top: 0 !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open].has-detached-sidebar .crop-editor-layout {
  display: block !important;
}

body.preview-mobile #cropDialog.is-mobile-inline[open].has-detached-sidebar > .crop-sidebar {
  display: flex !important;
}

body.preview-mobile .queue-actions {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: var(--mobile-gap-tight) !important;
  min-width: 0 !important;
  width: 100% !important;
}

body.preview-mobile .queue-actions button {
  width: 100% !important;
  min-width: 0 !important;
}

body.preview-mobile #queueStatus,
body.preview-mobile #submitStatus {
  line-height: 1.25 !important;
}

body.preview-mobile .video-tools {
  gap: var(--mobile-gap-tight) !important;
  margin-top: var(--mobile-gap-tight) !important;
  padding: var(--mobile-panel-pad) !important;
}

body.preview-mobile .video-controls {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: var(--mobile-gap-tight) !important;
}

body.preview-mobile .video-time-row,
body.preview-mobile .video-action-row {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: var(--mobile-gap-tight) !important;
}

body.preview-mobile .video-crop-size-control {
  min-width: 0 !important;
  gap: 4px !important;
}

body.preview-mobile .video-action-row .button-with-help {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 36px !important;
  gap: 6px !important;
}

body.preview-mobile .video-action-row button,
body.preview-mobile .video-time-row input {
  width: 100% !important;
}

body.preview-mobile .video-preview-card {
  min-height: 190px !important;
}

/* Submission confirmation uses the same panel and action styling as the tool. */
.tracking-success { background: var(--panel); scroll-margin-block: 24px; }
.submission-record-content { min-width: 0; }
.submission-record-content > p { margin: 0; color: var(--muted); line-height: 1.6; }
.submission-record-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.submission-record-actions a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 14px 18px; background: var(--button); color: #fff; text-decoration: none; line-height: 16px; }
.submission-record-actions a:hover { opacity: .82; }
.submission-record-actions button { min-height: 44px; }
.submission-record-actions :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#submissionLinkStatus:not(:empty) { margin-top: 14px; }
.tracking-success input { width: 100%; margin-top: 12px; }
.app-header > a { color: var(--text); text-underline-offset: 4px; }
@media(max-width:600px) {
  .submission-record-actions { align-items: stretch; flex-direction: column; }
  .submission-record-actions > * { width: 100%; }
}
body.preview-mobile .submission-record-actions { align-items: stretch; flex-direction: column; }
body.preview-mobile .submission-record-actions > * { width: 100%; }

/* Product actions share the heading row on desktop and mobile. */
.product-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; color: var(--muted); font-size: 13px; }
.product-heading-row { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.product-heading-row label { flex: 1 0 auto; white-space: nowrap; }
.product-add-button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 0 6px 12px; border: 0; background: transparent; color: var(--text); font-size: 13px; }
.product-add-button[hidden] { display: none; }
.product-add-button > span:first-child { font-size: 20px; }
.custom-item-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.custom-item-heading strong { margin: 0; }
.custom-item-heading .custom-item-remove { min-height: 32px; padding: 4px 0 4px 10px; border: 0; background: transparent; color: var(--muted); font-size: 12px; line-height: 1.4; }
.custom-item-heading .custom-item-remove.danger { color: #a83232; }

/* Compact product cards: consistent inset and quiet destructive actions. */
.custom-item-card { align-content: start; gap: 10px; }
.custom-item-card.active { box-shadow: none; }
.custom-item-card .custom-item-select { padding: 0; min-height: 0; width: 100%; }
.custom-item-heading .custom-item-remove,
.custom-item-heading .custom-item-remove.danger {
  border: 0;
  background: transparent;
  opacity: 1;
  min-width: 48px;
  padding: 4px 8px;
  margin-right: -8px;
  transition: color 150ms ease, background-color 150ms ease;
}
.custom-item-heading .custom-item-remove.danger { color: #a83232; }
@media (hover: hover) {
  .custom-item-heading .custom-item-remove:hover,
  .custom-item-heading .custom-item-remove.danger:hover {
    color: #a83232;
    background: #fff1ee;
    text-decoration: underline;
    text-underline-offset: 3px;
    opacity: 1;
  }
}
.custom-item-heading .custom-item-remove:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
  color: #a83232;
  background: #fff1ee;
}
.custom-item-heading .custom-item-remove:active { color: #a83232; background: #fce5e0; }

/* Submission actions use three equal columns at every viewport size. */
#submitPanel .submit-card { grid-template-columns: minmax(0, 1fr); min-width: 0; }
#submitPanel .submit-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; gap: 10px; align-items: stretch; }
#submitPanel .submit-actions > button { width: 100%; min-width: 0; margin: 0; padding: 12px 8px; white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }

/* Keep the custom text colour within the palette instead of a separate row. */
#cropDialog .text-color-buttons > .color-picker-row {
  grid-column: span 2;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 6px;
  min-width: 0;
  margin: 0;
}
#cropDialog .text-color-buttons .custom-color-icon { border: 0; font-size: 18px; }
#cropDialog .text-color-buttons .color-picker-row:focus-within { outline: 1px solid var(--text); outline-offset: 2px; }
#cropDialog .zoom-label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#cropZoomValue, #textSizeValue { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
body.preview-mobile #cropDialog.is-mobile-inline[open] .text-color-buttons > .color-picker-row { grid-column: span 2 !important; }
body.preview-mobile #cropDialog.is-mobile-inline[open] .text-position-buttons { grid-column: 1 / -1 !important; }

#customTextField:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 14px; align-items: end; }
#customTextField > label { min-width: 0; }
#customTextField .message-page-field { margin: 0; max-width: none; }
@media(max-width:600px) {
  #customTextField:not([hidden]) { grid-template-columns: minmax(0, 1fr) 105px; gap: 8px; }
}
body.preview-mobile #customTextField:not([hidden]) { grid-template-columns: minmax(0, 1fr) 105px; gap: 8px; }
