:root {
  color-scheme: light;
  --bg: #f5f2ec;
  --panel: #ffffff;
  --ink: #161616;
  --muted: #626262;
  --line: #ded7cb;
  --green: #ffc529;
  --green-dark: #171717;
  --black: #111111;
  --warning: #9b5a00;
  --danger: #b42318;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 197, 41, 0.2), transparent 28%),
    var(--bg);
  color: var(--ink);
}

body.wizard-open {
  overflow: hidden;
  overscroll-behavior: none;
}

.studio-loading .app-shell {
  filter: blur(8px);
  transform: scale(1.01);
  pointer-events: none;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(500px, 540px) minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.control-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 10px;
  padding: 12px;
  border-right: 1px solid #d8d0c3;
  background: linear-gradient(180deg, #fff 0%, #fbf8f1 100%);
  overflow: hidden;
}

.control-panel > .brand-row,
.control-panel > .project-section,
.control-panel > .submit-section {
  grid-column: 1 / -1;
}

.control-panel > .plate-colours {
  grid-column: 1 / -1;
}

.control-panel > .upload-zone {
  grid-column: 1;
}

.control-panel > .lightbox-settings {
  grid-column: 2;
}

.control-panel > .project-section {
  order: 20;
}

.control-panel > .submit-section {
  order: 30;
}

.brand-row,
.section-heading,
.preview-toolbar,
.preview-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #8a6500;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.25;
}

.status-pill,
output,
.preview-stats span {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #fffdf7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.panel-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 0;
  padding: 10px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 24px rgba(22, 22, 22, 0.04);
}

.upload-zone {
  position: relative;
  display: block;
  min-height: 102px;
  border-style: dashed;
}

.upload-zone.dragging {
  border-color: var(--green);
  background: #fff8dc;
}

.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.toggle-row small {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.upload-button {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  justify-items: start;
  width: 100%;
  min-height: 126px;
  height: 100%;
  padding: 16px;
  cursor: pointer;
  text-align: left;
  font-size: 18px;
  user-select: none;
}

.upload-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.52);
  color: #161616;
  font-size: 28px;
  font-weight: 800;
}

#chooseFileText {
  min-width: 0;
  line-height: 1.12;
}

.primary-button,
.secondary-button {
  min-height: 36px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: var(--green);
  color: #111;
  box-shadow: 0 8px 18px rgba(255, 197, 41, 0.25);
}

.primary-button:hover {
  background: #f5b800;
}

.secondary-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.mini {
  min-width: 38px;
  min-height: 36px;
  padding: 0 10px;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #717971;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.icon-button:hover {
  background: #eef2ef;
  color: var(--ink);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.upload-zone .primary-button {
  width: 100%;
  min-width: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.usage-heading {
  margin-top: 12px;
}

.usage-segmented {
  grid-template-columns: repeat(2, 1fr);
}

.setting-pill {
  justify-self: end;
  margin-top: 8px;
}

.section-heading > .setting-pill {
  margin-top: 0;
}

.lightbox-settings > .setting-pill {
  display: none;
}

.seg {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

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

.seg.active {
  border-color: var(--green);
  background: #fff6d6;
  box-shadow: inset 0 0 0 1px var(--green);
}

.submit-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.submit-section p {
  grid-column: 1 / -1;
  margin: 0;
}

.order-button {
  background: #171717;
  color: #fff;
  box-shadow: 0 8px 18px rgba(23, 23, 23, 0.16);
}

.order-button:hover {
  background: #2b2b2b;
}

.toggle-row,
.range-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
}

.toggle-row input {
  width: 46px;
  height: 26px;
  accent-color: var(--green);
}

.visualizer-light-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.visualizer-light-toggle {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 5;
  display: grid;
  gap: 5px;
  justify-items: center;
}

.light-toggle-label {
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
  text-transform: lowercase;
}

.visualizer-zoom-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  display: grid;
  grid-template-columns: 38px 58px 38px;
  gap: 6px;
  padding: 6px;
  border-radius: 9px;
  background: rgba(18, 20, 20, 0.62);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 12px 26px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(12px);
}

.zoom-button {
  display: grid;
  min-width: 0;
  min-height: 34px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #f4f7f4;
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
}

.zoom-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

#previewZoomReset {
  font-size: 12px;
}

.light-switch {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 54px;
  height: 34px;
  border-radius: 8px;
  background: #232526;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 0 9px 14px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.light-switch svg {
  position: absolute;
  top: 5px;
  left: 8px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #4d5252;
  color: #dfe4df;
  padding: 4px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition:
    transform 220ms ease,
    color 260ms ease,
    background 260ms ease,
    box-shadow 260ms ease;
}

.visualizer-light-toggle input:checked + .light-switch svg {
  transform: translateX(16px);
  background: #fff9dc;
  color: #333b36;
  box-shadow:
    0 0 14px rgba(255, 197, 41, 0.48),
    0 0 0 5px rgba(255, 255, 255, 0.08);
}

.range-row {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.range-row input {
  width: 150px;
  accent-color: var(--green);
}

.swatch-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.swatch {
  display: block;
}

.swatch i {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 50%;
}

.plate-colours {
  display: grid;
  grid-template-columns: 4fr 1fr 1fr;
  gap: 8px;
}

.plate-colours > .section-heading {
  grid-column: 1 / -1;
}

.plate-colours > .plate-card:nth-child(2) {
  grid-column: 1;
}

.plate-colours > .plate-card:nth-child(3) {
  grid-column: 2;
}

.plate-colours > .plate-card:nth-child(4) {
  grid-column: 3;
}

.plate-card {
  display: grid;
  gap: 7px;
  border-radius: 10px;
  padding: 8px;
  background: #f6f3eb;
}

.plate-card p {
  margin-bottom: 0;
  color: #4e5a52;
  font-size: 13px;
  font-weight: 700;
}

.plate-colour-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.plate-dot,
.shell-colour i {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.plate-dot {
  cursor: pointer;
}

.plate-empty {
  color: var(--muted);
  font-size: 13px;
}

.shell-colour {
  display: grid;
  grid-template-columns: 24px;
  align-items: center;
  justify-items: start;
  gap: 10px;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.shell-colour span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.shell-colour strong {
  display: none;
  color: var(--muted);
  font-size: 12px;
}

.diagnostics ul {
  display: grid;
  max-height: 58px;
  overflow: hidden;
  gap: 5px;
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.28;
}

.diagnostics {
  display: none;
}

.diagnostics li.warn {
  color: var(--warning);
}

.diagnostics li.error {
  color: var(--danger);
}

.submit-section {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 8px;
}

.project-section {
  position: relative;
  display: grid;
  gap: 8px;
}

.project-section > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.project-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.project-icon-button {
  display: grid;
  place-items: center;
}

.project-icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
  min-height: 210px;
  max-height: 280px;
  overflow: auto;
  gap: 8px;
}

.project-empty,
.project-section p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.project-item {
  position: relative;
  display: grid;
  aspect-ratio: 1;
  grid-template-columns: 1fr;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #fffdf7;
  cursor: pointer;
}

.project-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #6f756f;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.project-delete:hover {
  background: #fff1ef;
  color: var(--danger);
}

.project-thumb {
  width: 100%;
  height: 100%;
  border-radius: 7px;
  background:
    radial-gradient(circle at 50% 45%, rgba(122, 136, 150, 0.42), transparent 60%),
    #252929;
  object-fit: cover;
}

.project-meta {
  min-width: 0;
}

.project-meta strong,
.project-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-meta strong {
  font-size: 13px;
}

.project-meta span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.project-item-actions {
  display: flex;
  gap: 6px;
  margin-top: 5px;
}

.project-mini {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.project-mini:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.preview-panel {
  display: grid;
  grid-template-rows: minmax(360px, 1fr);
  min-width: 0;
  min-height: 0;
  padding: 0;
  background:
    linear-gradient(180deg, #faf7ef 0%, #f0ebe2 100%);
}

.preview-toolbar {
  padding: 0;
}

.preview-toolbar h2 {
  font-size: 24px;
}

.mobile-studio-title {
  display: none;
}

.stage-ribbon {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 7;
  min-height: 78px;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(18, 20, 20, 0.68), rgba(18, 20, 20, 0));
  color: #fff;
  backdrop-filter: blur(10px);
}

.preview-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.preview-title-row h2 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
}

.preview-title-input {
  width: min(520px, 52vw);
  min-width: 260px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
}

.preview-title-input:focus {
  border-color: var(--green);
  outline: 3px solid rgba(255, 197, 41, 0.24);
}

.title-edit-button {
  display: grid;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  cursor: pointer;
}

.title-edit-button:hover {
  border-color: var(--green);
  background: #fff6d6;
  color: #111;
}

.title-edit-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.preview-stats {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.preview-stats span {
  border-color: rgba(222, 215, 203, 0.78);
  background: transparent;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.42);
}

#sessionEmailStat {
  max-width: min(320px, 34vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-login-button {
  flex: 0 0 auto;
  min-height: 31px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(18, 20, 20, 0.48);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.admin-login-button:hover,
.admin-login-button.active {
  border-color: var(--green);
  background: rgba(255, 197, 41, 0.94);
  color: #111;
}

.stage {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 50% 35%, rgba(72, 75, 73, 0.16), transparent 32%),
    linear-gradient(#303231 0%, #2c2e2d 54%, #202120 62%, #4c4f4c 100%);
  perspective: 1250px;
  user-select: none;
  touch-action: none;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, transparent 0 54%, rgba(0, 0, 0, 0.2) 58%, rgba(255, 255, 255, 0.035) 60%, transparent 66%),
    radial-gradient(ellipse at 50% 108%, rgba(205, 203, 188, 0.18), rgba(105, 108, 104, 0.12) 28%, transparent 56%),
    linear-gradient(to bottom, transparent 0 60%, rgba(255, 255, 255, 0.028) 61%, rgba(0, 0, 0, 0.18) 100%);
  opacity: 1;
}

.stage-note {
  position: absolute;
  left: 18px;
  right: auto;
  bottom: 72px;
  z-index: 6;
  max-width: min(620px, calc(100% - 190px));
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 9px 12px;
  background: rgba(18, 20, 20, 0.66);
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
  backdrop-filter: blur(12px);
}

.stage-note:empty {
  display: none;
}

.preview-alert {
  position: absolute;
  left: 18px;
  right: auto;
  top: 88px;
  z-index: 4;
  display: grid;
  width: 44px;
  height: 44px;
  max-width: none;
  place-items: center;
  border: 1px solid rgba(222, 215, 203, 0.54);
  border-radius: 16px 16px 16px 4px;
  padding: 0;
  background: rgba(18, 20, 20, 0.42);
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
  font-size: 11px;
  line-height: 1.2;
  backdrop-filter: blur(6px);
  transition:
    width 180ms ease,
    height 180ms ease,
    background 260ms ease,
    opacity 260ms ease;
}

.preview-alert.expanded {
  right: 18px;
  width: auto;
  height: auto;
  max-width: 560px;
  justify-items: stretch;
  place-items: stretch;
  border-color: rgba(166, 95, 0, 0.28);
  border-radius: 8px;
  padding: 10px 34px 10px 12px;
  background: rgba(18, 20, 20, 0.58);
}

.preview-alert-trigger {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border: 0;
  background: transparent;
  color: currentColor;
  cursor: pointer;
  font-size: 0;
  line-height: 0;
}

.preview-alert-trigger svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.preview-alert.expanded .preview-alert-trigger {
  display: none;
}

.preview-alert-content,
.preview-alert-close {
  display: none;
}

.preview-alert.expanded .preview-alert-content,
.preview-alert.expanded .preview-alert-close {
  display: block;
}

.app-loading {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 20, 20, 0.38);
  opacity: 1;
  transition:
    opacity 420ms ease,
    visibility 420ms ease;
}

.app-loading.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.app-loading-card {
  width: min(420px, calc(100vw - 48px));
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 22px;
  background: rgba(18, 20, 20, 0.82);
  color: #fff;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(16px);
  animation: modal-card-enter 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.app-loading-card.needs-email {
  width: min(440px, calc(100vw - 48px));
}

.app-loading-card h2 {
  margin: 0 0 16px;
  font-size: 20px;
  line-height: 1.25;
  text-align: center;
}

.loading-dots {
  display: inline-grid;
  grid-template-columns: repeat(3, 0.35em);
  margin-left: 1px;
  vertical-align: baseline;
}

.loading-dots span {
  animation: loading-dot-blink 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.18s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.36s;
}

.loading-logo {
  display: block;
  width: 100px;
  height: 100px;
  object-fit: contain;
  margin: 0 auto 16px;
  border-radius: 50%;
  transform-style: preserve-3d;
  animation: loading-logo-spin 1.15s linear infinite;
  filter: drop-shadow(0 0 18px rgba(255, 197, 41, 0.55));
}

.loading-email-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  text-align: left;
}

.loading-email-form h3 {
  margin: 0;
  color: #fff;
  font-size: 17px;
  line-height: 1.2;
  text-align: center;
}

.loading-email-form .email-gate-field {
  color: rgba(255, 255, 255, 0.88);
}

.loading-email-form .email-gate-error {
  min-height: 16px;
  text-align: center;
}

.loading-start-button {
  min-height: 48px;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    opacity 180ms ease;
}

.loading-start-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.ready-to-start .loading-start-button:not(:disabled) {
  animation: start-button-pulse 840ms ease-in-out infinite;
}

@keyframes loading-logo-spin {
  0% {
    transform: perspective(420px) rotateY(0deg);
  }

  50% {
    transform: perspective(420px) rotateY(180deg);
  }

  100% {
    transform: perspective(420px) rotateY(360deg);
  }
}

@keyframes loading-dot-blink {
  0%,
  20% {
    opacity: 0.18;
    transform: translateY(0);
  }

  45% {
    opacity: 1;
    transform: translateY(-1px);
  }

  80%,
  100% {
    opacity: 0.18;
    transform: translateY(0);
  }
}

@keyframes start-button-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 197, 41, 0.45);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(255, 197, 41, 0);
    transform: scale(1.025);
  }
}

@keyframes modal-backdrop-enter {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes modal-card-enter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes popover-enter {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.preview-alert-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: currentColor;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.preview-alert-close:hover {
  background: rgba(0, 0, 0, 0.08);
}

.preview-alert[hidden] {
  display: none;
}

.preview-alert.error {
  border-color: rgba(255, 166, 151, 0.52);
  background: rgba(18, 20, 20, 0.48);
  color: #fff;
}

.preview-alert.error.expanded {
  border-color: rgba(180, 35, 24, 0.32);
  background: rgba(18, 20, 20, 0.64);
  color: #fff;
}

.preview-alert strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.preview-alert ul {
  display: grid;
  gap: 3px;
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.28;
}

.stage.lights-on {
  background:
    radial-gradient(circle at 50% 35%, rgba(74, 77, 75, 0.2), transparent 33%),
    linear-gradient(#303231 0%, #2d2f2e 54%, #212321 62%, #535653 100%);
}

.stage.lights-off {
  background:
    radial-gradient(circle at 50% 35%, rgba(46, 49, 47, 0.14), transparent 32%),
    linear-gradient(#2c2e2d 0%, #292b2a 54%, #191a19 62%, #3d403e 100%);
}

.stage {
  transition: background 520ms ease;
}

.three-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.stage:active .three-canvas {
  cursor: grabbing;
}

.stage.three-active .scene {
  display: none;
}

.scene {
  width: min(62vw, 680px);
  height: min(62vw, 680px);
  min-width: 310px;
  min-height: 310px;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  visibility: hidden;
  opacity: 0;
}

.stage.preview-ready .scene {
  visibility: visible;
  opacity: 1;
}

.model-stack {
  position: relative;
  width: 62%;
  height: 62%;
  transform-style: preserve-3d;
  transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  transition: transform 120ms ease-out;
}

.model-layer,
.shadow {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.shadow {
  top: 79%;
  left: 2%;
  width: 96%;
  height: 22%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.46);
  filter: blur(18px);
  transform: translate3d(34px, 58px, -170px) rotateX(88deg) scale(1.2);
}

.back-shell,
.side-wall {
  background: var(--side-color, #000);
  clip-path: var(--silhouette, polygon(18% 16%, 82% 16%, 88% 52%, 70% 86%, 30% 86%, 12% 52%));
  box-shadow:
    inset 14px 0 28px rgba(255, 255, 255, 0.08),
    inset -18px 0 30px rgba(0, 0, 0, 0.44),
    inset 0 0 0 2px rgba(255, 255, 255, 0.06),
    0 26px 48px rgba(0, 0, 0, 0.36);
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.12));
}

.back-shell {
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.16), transparent 18% 74%, rgba(0, 0, 0, 0.34)),
    radial-gradient(circle at 52% 42%, rgba(255, 255, 255, 0.08), transparent 44%),
    var(--back-color, #000);
  transform: translateZ(-136px) scale(1.035);
  box-shadow:
    inset 0 0 0 10px rgba(255, 255, 255, 0.04),
    inset 0 0 0 22px rgba(0, 0, 0, 0.3),
    0 34px 52px rgba(0, 0, 0, 0.42);
}

.side-wall {
  opacity: 0.96;
  background:
    linear-gradient(90deg, var(--side-color-light, #1f1f1f), var(--side-color, #000) 38%, var(--side-color-dark, #000)),
    var(--side-color, #000);
  transform: translateZ(-120px) scale(1.032);
}

.offset-1 {
  background: var(--side-color, #000);
  transform: translateZ(-105px) scale(1.028);
}

.offset-2 {
  background: var(--side-color, #000);
  transform: translateZ(-90px) scale(1.024);
}

.offset-3 {
  background: var(--side-color, #000);
  transform: translateZ(-75px) scale(1.02);
}

.offset-4 {
  background: var(--side-color, #000);
  transform: translateZ(-60px) scale(1.016);
}

.offset-5 {
  background: var(--side-color, #000);
  transform: translateZ(-45px) scale(1.012);
}

.offset-6 {
  background: var(--side-color, #000);
  transform: translateZ(-30px) scale(1.008);
}

.offset-7 {
  background: var(--side-color, #000);
  transform: translateZ(-15px) scale(1.004);
}

.offset-8 {
  background: var(--side-color-light, #191919);
  transform: translateZ(0) scale(1);
}

.front-face {
  width: 100%;
  height: 100%;
  overflow: visible;
  backface-visibility: hidden;
  transform: translateZ(18px);
  filter:
    drop-shadow(0 0 14px rgba(210, 226, 255, 0.34))
    drop-shadow(0 10px 16px rgba(0, 0, 0, 0.42));
  transition: filter 520ms ease, opacity 520ms ease;
}

.stage.lights-on .front-face {
  filter:
    brightness(1.035)
    saturate(1.02)
    drop-shadow(0 0 5px rgba(255, 225, 150, 0.2))
    drop-shadow(0 0 12px rgba(255, 197, 41, 0.08))
    drop-shadow(0 10px 16px rgba(0, 0, 0, 0.36));
}

.front-rim {
  filter: drop-shadow(0 10px 8px rgba(0, 0, 0, 0.22));
  transition: filter 520ms ease;
}

.stage.lights-on .front-rim {
  filter:
    drop-shadow(0 0 6px rgba(255, 224, 148, 0.18))
    drop-shadow(0 10px 8px rgba(0, 0, 0, 0.22));
}

.lid-artwork {
  opacity: 0.98;
}

.stage.lights-on .lid-artwork {
  opacity: 1;
  filter: brightness(1.045) saturate(1.02);
}

.diffuser-lid {
  transform-origin: center;
}

.glow {
  pointer-events: none;
  backface-visibility: hidden;
  background:
    radial-gradient(circle at 46% 44%, rgba(255, 241, 178, 0.18), transparent 46%),
    radial-gradient(circle at 68% 58%, rgba(255, 255, 255, 0.11), transparent 42%);
  clip-path: var(--silhouette, polygon(18% 16%, 82% 16%, 88% 52%, 70% 86%, 30% 86%, 12% 52%));
  mix-blend-mode: screen;
  transform: translateZ(24px) scale(1.035);
  opacity: 0.22;
  transition: opacity 520ms ease;
}

.stage.lights-off .glow {
  opacity: 0.04;
}

.hidden {
  display: none !important;
}

.email-gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(22, 22, 22, 0.42);
  backdrop-filter: blur(4px);
  animation: modal-backdrop-enter 260ms ease both;
}

.admin-gate {
  position: fixed;
  inset: 0;
  z-index: 28;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 20, 20, 0.46);
  backdrop-filter: blur(8px);
  animation: modal-backdrop-enter 260ms ease both;
}

.admin-gate-card {
  width: min(360px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  background: #fffdf7;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.26);
  animation: modal-card-enter 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.admin-gate-card h2 {
  margin-bottom: 14px;
  font-size: 22px;
}

.admin-gate-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.email-gate-card {
  display: grid;
  width: min(430px, calc(100vw - 36px));
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 10px;
  padding: 24px;
  background: rgba(255, 253, 247, 0.92);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  animation: modal-card-enter 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.email-gate-card h2 {
  font-size: 24px;
}

.email-gate-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.42;
}

.email-gate-field {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 800;
}

.email-gate-field input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.email-gate-field input:focus {
  border-color: var(--green);
  outline: 3px solid rgba(255, 197, 41, 0.26);
}

.email-gate.invalid .email-gate-field input,
.loading-email-form.invalid .email-gate-field input {
  border-color: var(--danger);
}

.email-gate-error {
  min-height: 18px;
  color: var(--danger) !important;
  font-size: 13px;
  font-weight: 700;
}

.wizard {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.48);
  animation: modal-backdrop-enter 260ms ease both;
}

.wizard-card {
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto;
  width: min(1200px, calc(100vw - 48px));
  height: min(800px, calc(100vh - 48px));
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  animation: modal-card-enter 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.wizard-header,
.wizard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}

.wizard-header h2 {
  font-size: 21px;
}

.wizard-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.wizard-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  min-height: 0;
}

.wizard-main {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #5a5d5b;
}

.artboard {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.checkerboard {
  background-color: #f8f8f8;
  background-image:
    linear-gradient(45deg, #d9d9d9 25%, transparent 25%),
    linear-gradient(-45deg, #d9d9d9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d9d9d9 75%),
    linear-gradient(-45deg, transparent 75%, #d9d9d9 75%);
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

#wizardImage {
  max-width: 82%;
  max-height: 82%;
  object-fit: contain;
  transform: scale(var(--wizard-zoom, 1));
  transform-origin: center;
}

.crop-box {
  position: absolute;
  display: none;
  min-width: 44px;
  min-height: 44px;
  border: 2px solid #fff;
  outline: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.34);
  background: rgba(255, 255, 255, 0.001);
  cursor: move;
  touch-action: none;
  z-index: 3;
}

.crop-box.visible {
  display: block;
}

.crop-box.circle {
  border-radius: 50%;
}

.crop-handle {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1px solid #777;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
  touch-action: none;
}

.crop-nw {
  left: -10px;
  top: -10px;
  cursor: nwse-resize;
}

.crop-ne {
  right: -10px;
  top: -10px;
  cursor: nesw-resize;
}

.crop-sw {
  left: -10px;
  bottom: -10px;
  cursor: nesw-resize;
}

.crop-se {
  right: -10px;
  bottom: -10px;
  cursor: nwse-resize;
}

.preview-tools {
  position: absolute;
  left: 22px;
  bottom: 20px;
  display: flex;
  gap: 8px;
}

.wizard-side {
  overflow: auto;
  border-left: 1px solid var(--line);
  padding: 18px 16px;
  background: #fff;
}

.wizard-side h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.wizard-side p {
  color: #7a817b;
  font-size: 13px;
  line-height: 1.35;
}

.crop-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0 22px;
}

.crop-preset {
  display: grid;
  gap: 6px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 4px;
  background: #fff;
  cursor: pointer;
  color: #37413b;
  font-size: 12px;
}

.crop-preset.active {
  border-color: var(--green);
  background: #eef9f4;
}

.crop-icon {
  width: 28px;
  height: 20px;
  border: 1px solid #8e938f;
  background: #ddd;
}

.crop-icon.ratio-1 {
  width: 24px;
  height: 24px;
}

.crop-icon.ratio-43 {
  width: 30px;
  height: 22px;
}

.crop-icon.ratio-32 {
  width: 32px;
  height: 22px;
}

.crop-icon.ratio-169 {
  width: 34px;
  height: 18px;
}

.crop-icon.circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.switch-row input,
.compact-toggle input {
  accent-color: var(--green);
}

.colour-count-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 10px;
  align-items: center;
  margin: 18px 0;
}

.colour-count-row input {
  width: 100%;
  height: 32px;
  accent-color: var(--green);
  cursor: grab;
  touch-action: pan-y;
}

.colour-count-row input:active {
  cursor: grabbing;
}

.count-badge {
  display: grid;
  min-height: 30px;
  place-items: center;
  border-radius: 8px;
  background: #eceeed;
  font-weight: 700;
}

.mapping-list,
.detail-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.plate-detail-heading {
  margin-top: 20px;
}

.mapping-controls-title {
  margin-top: 18px !important;
}

.mapping-row,
.detail-row {
  display: grid;
  grid-template-columns: 24px 24px 28px 24px 32px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  font-size: 13px;
}

.map-arrow {
  display: block;
  min-width: 18px;
  text-align: center;
  white-space: nowrap;
  line-height: 1;
}

.detail-row {
  grid-template-columns: 28px 1fr auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

button.detail-row {
  width: 100%;
  background: #fff;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.map-dot,
.colour-dot {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 50%;
}

.colour-dot {
  cursor: pointer;
}

.map-number {
  display: grid;
  min-width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 8px;
  background: var(--token-color, #f5f6f5);
  color: var(--token-ink, #111);
  font-weight: 800;
}

.map-number.dark {
  background: var(--token-color, #061f49);
  color: var(--token-ink, #fff);
}

.colour-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 20px;
}

.colour-chip {
  display: grid;
  min-width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--token-color, #fff);
  color: var(--token-ink, #111);
  cursor: pointer;
  font-weight: 800;
}

.colour-add-chip {
  background: #fffdf7;
  color: var(--muted);
}

.colour-chip.active {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(255, 197, 41, 0.35);
}

.colour-detail-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.shell-detail-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.colour-detail-row {
  grid-template-columns: 1fr;
  min-height: 48px;
  place-items: center;
  gap: 2px;
  background: var(--token-color, #fff) !important;
  color: var(--token-ink, #111) !important;
  text-align: center;
}

.colour-detail-row span,
.colour-detail-row strong {
  color: inherit;
  font-weight: 900;
  line-height: 1;
}

.colour-detail-row span {
  font-size: 14px;
}

.colour-detail-row strong {
  font-size: 11px;
}

.reset-button {
  border: 0;
  background: transparent;
  color: #4e5a52;
  cursor: pointer;
  font-size: 13px;
}

.colour-popover {
  position: fixed;
  z-index: 40;
  width: 255px;
  border: 1px solid #d9dedb;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
  padding: 10px 10px 12px;
  transform-origin: top left;
  animation: popover-enter 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.popover-tabs {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.popover-tabs button:not(.icon-button) {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 8px 0;
  cursor: pointer;
}

.popover-tabs button.active {
  border-color: #00a85a;
}

.popover-tabs .icon-button {
  margin-left: auto;
  width: 28px;
  height: 28px;
  font-size: 20px;
}

.colour-current {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  background: #f7f8f7;
}

.colour-current i {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: #001c42;
}

.colour-current input {
  width: 100%;
  border: 0;
  background: transparent;
}

.preset-pane p,
.used-pane p {
  margin-bottom: 8px;
  color: #8a908b;
  font-size: 12px;
}

.preset-grid,
.used-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
}

.preset-grid button,
.used-grid button {
  width: 20px;
  height: 20px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 2px;
  cursor: pointer;
}

.used-empty {
  grid-column: 1 / -1;
  color: #8a908b;
  font-size: 12px;
}

.custom-pane input[type='color'] {
  width: 100%;
  height: 170px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.rgb-row {
  display: grid;
  grid-template-columns: 62px repeat(3, 1fr);
  gap: 0;
  margin-top: 8px;
}

.rgb-row span,
.rgb-row input {
  min-height: 34px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  text-align: center;
}

.rgb-row span {
  border-radius: 6px 0 0 6px;
  background: #f8f8f8;
  font-size: 12px;
}

.rgb-row input:last-child {
  border-radius: 0 6px 6px 0;
}

@media (max-width: 880px) {
  body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .control-panel {
    order: 2;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .control-panel > * {
    grid-column: 1 / -1 !important;
    width: 100%;
  }

  .brand-row {
    display: none;
  }

  .preview-panel {
    order: 1;
    min-height: clamp(340px, 54vh, 460px);
    padding: 0;
  }

  .preview-toolbar {
    align-items: center;
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .stage-ribbon {
    min-height: 104px;
    padding: 14px 16px;
  }

  .mobile-studio-title {
    display: block;
    margin: 0 0 4px;
    color: #fff;
    font-size: clamp(19px, 5.4vw, 24px);
    line-height: 1.05;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.62);
  }

  .preview-title-row h2 {
    font-size: 18px;
    text-align: center;
  }

  .preview-title-row {
    justify-content: center;
    width: 100%;
  }

  .stage {
    min-height: clamp(340px, 54vh, 460px);
  }

  .stage-note {
    right: 18px;
    bottom: 70px;
    max-width: none;
  }

  .preview-stats {
    width: 100%;
    gap: 8px;
    justify-content: center;
  }

  #sessionEmailStat {
    max-width: min(72vw, 360px);
    padding-right: 14px;
    padding-left: 14px;
  }

  .admin-login-button {
    display: none;
  }

  .preview-alert {
    top: 118px;
    right: auto;
    left: 14px;
    display: grid;
    width: 42px;
    height: 42px;
    max-width: none;
    place-items: center;
    border-color: rgba(222, 215, 203, 0.54);
    border-radius: 16px 16px 16px 4px;
    padding: 0;
    background: rgba(18, 20, 20, 0.42);
    color: #fff;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
    font-size: 11px;
    line-height: 1.2;
    backdrop-filter: blur(6px);
  }

  .preview-alert.expanded {
    right: 14px;
    width: auto;
    height: auto;
    justify-items: stretch;
    place-items: stretch;
    border-radius: 8px;
    padding: 8px 32px 8px 10px;
    background: rgba(18, 20, 20, 0.58);
  }

  .preview-alert-trigger {
    position: relative;
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
    border: 0;
    background: transparent;
    color: currentColor;
    cursor: pointer;
    font-size: 0;
    line-height: 0;
  }

  .preview-alert.expanded .preview-alert-trigger {
    display: none;
  }

  .preview-alert-content,
  .preview-alert-close {
    display: none;
  }

  .preview-alert.expanded .preview-alert-content,
  .preview-alert.expanded .preview-alert-close {
    display: block;
  }

  .preview-alert strong {
    margin-bottom: 3px;
    font-size: 11px;
  }

  .preview-alert ul {
    gap: 2px;
    padding-left: 14px;
    font-size: 10px;
    line-height: 1.18;
  }

  .preview-alert-close {
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    font-size: 14px;
  }

  .visualizer-zoom-controls {
    right: 12px;
    bottom: 12px;
    grid-template-columns: 30px 48px 30px;
    gap: 4px;
    padding: 4px;
    border-radius: 8px;
  }

  .zoom-button {
    min-height: 28px;
    border-radius: 6px;
    font-size: 13px;
  }

  #previewZoomReset {
    font-size: 11px;
  }

  .scene {
    width: min(88vw, 520px);
    height: min(88vw, 520px);
  }

  .upload-zone,
  .lightbox-settings,
  .plate-colours,
  .project-section,
  .submit-section {
    width: 100%;
  }

  .upload-zone {
    min-height: 78px;
  }

  .upload-button {
    min-height: 78px;
    padding: 12px 16px;
    justify-items: center;
    text-align: center;
  }

  .segmented {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .usage-segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .seg {
    width: 100%;
    min-height: 54px;
  }

  .setting-pill {
    width: auto;
    display: block;
    justify-self: center;
    margin-top: 12px;
    text-align: center;
  }

  .lightbox-settings > .setting-pill {
    display: none;
  }

  .project-count-pill {
    margin-top: 0;
  }

  .plate-colours {
    grid-template-columns: 2fr 1fr 1fr;
  }

  .plate-colours > .section-heading {
    grid-column: 1 / -1;
  }

  .plate-colours > .plate-card:nth-child(2) {
    grid-column: 1;
  }

  .plate-colours > .plate-card:nth-child(3) {
    grid-column: 2;
  }

  .plate-colours > .plate-card:nth-child(4) {
    grid-column: 3;
  }

  .project-section > .section-heading {
    flex-direction: row;
    align-items: center;
  }

  .plate-card {
    width: 100%;
    min-height: 106px;
  }

  .shell-colour {
    width: auto;
    min-height: 44px;
  }

  .project-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .submit-section {
    grid-template-columns: 1fr;
  }

  .submit-section .primary-button {
    width: 100%;
    min-height: 48px;
  }

  .project-icon-button {
    width: 100%;
    min-height: 44px;
  }

  .project-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: start;
    width: 100%;
    max-height: none;
    min-height: auto;
    gap: 8px;
  }

  .project-empty {
    grid-column: 1 / -1;
  }

  .project-item {
    aspect-ratio: 1;
    grid-template-columns: 1fr;
    gap: 0;
    align-items: stretch;
    overflow: hidden;
    padding: 0;
  }

  .project-thumb {
    width: 100%;
    height: 100%;
    border-radius: 7px;
  }

  .project-meta {
    display: none;
  }

  .project-delete {
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    z-index: 2;
    font-size: 14px;
  }

  .wizard {
    align-items: start;
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
    overflow: hidden;
    overscroll-behavior: contain;
  }

  .wizard-card {
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: calc(100vw - 16px);
    height: calc(var(--app-vh, 100dvh) - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
    max-height: calc(var(--app-vh, 100dvh) - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
    min-height: 0;
  }

  .wizard-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(260px, 52%) minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
  }

  .wizard-main {
    min-height: 0;
  }

  #wizardImage {
    max-width: 70%;
    max-height: 70%;
  }

  .preview-tools {
    left: 14px;
    bottom: 12px;
  }

  .wizard-side {
    max-height: none;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 12px;
  }

  .wizard-footer {
    flex: 0 0 auto;
    min-height: 52px;
  }
}

@media (max-width: 520px) {
  .control-panel,
  .preview-panel {
    padding: 14px;
  }

  .preview-panel {
    padding: 0;
  }

  .brand-row,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .project-section > .section-heading {
    align-items: center;
    flex-direction: row;
  }

  .wizard-header,
  .wizard-footer {
    padding: 0 14px;
  }

  .wizard-header {
    min-height: 50px;
  }

  .wizard-header h2 {
    font-size: 18px;
  }

  .crop-presets {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    margin: 8px 0 12px;
  }

  .crop-preset {
    min-width: 0;
    gap: 4px;
    padding: 6px 2px;
    font-size: 10px;
  }

  .crop-icon {
    transform: scale(0.72);
  }

  .wizard-side p {
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.25;
  }

  .wizard-side h3 {
    margin-bottom: 4px;
    font-size: 14px;
  }

  .colour-count-row {
    grid-template-columns: 1fr 38px;
    gap: 8px;
    margin: 8px 0 10px;
  }

  .count-badge {
    min-height: 28px;
    border-radius: 8px;
  }

  .mapping-list,
  .detail-list {
    gap: 6px;
    margin-top: 6px;
  }

  .mapping-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mapping-row {
    grid-template-columns: 20px 18px 28px 1fr;
    gap: 6px;
    min-height: 26px;
  }

  .mapping-row .colour-dot {
    justify-self: start;
  }

  .map-dot,
  .colour-dot {
    width: 20px;
    height: 20px;
  }

  .map-number {
    min-width: 24px;
    height: 24px;
    border-radius: 7px;
    font-size: 12px;
  }

  .colour-chips {
    gap: 6px;
    margin: 6px 0 10px;
  }

  .colour-chip {
    min-width: 30px;
    height: 30px;
  }

  .colour-add-chip {
    min-width: 30px;
  }

  .detail-row {
    grid-template-columns: 22px 1fr auto;
    min-height: 32px;
    padding: 6px 8px;
  }

  .colour-detail-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .shell-detail-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .colour-detail-row {
    grid-template-columns: 1fr;
    min-height: 44px;
    place-items: center;
    gap: 1px;
    padding: 6px 4px;
    background: var(--token-color, #fff) !important;
    color: var(--token-ink, #111) !important;
    text-align: center;
  }

  .colour-detail-row .colour-dot {
    display: none;
  }

  .colour-detail-row span,
  .colour-detail-row strong {
    color: inherit;
    font-weight: 900;
    line-height: 1;
  }

  .colour-detail-row span {
    font-size: 13px;
  }

  .colour-detail-row strong {
    font-size: 10px;
  }

  .plate-detail-heading {
    margin-top: 10px;
  }

  .reset-button {
    font-size: 12px;
  }

  #wizardImage {
    max-width: 66%;
    max-height: 66%;
  }

  .switch-row {
    min-height: 38px;
  }
}
