:root {
  --bg: #0f1115;
  --panel: #171a21;
  --accent: #4f8cff;
  --accent-hover: #3a75e6;
  --text: #e8eaed;
  --muted: #8a8f98;
  --border: #2a2e38;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 14px;
}
.back-link:hover { color: var(--text); }
h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 20px;
  text-align: center;
}
.upload-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}
button {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  background: #33384a;
  color: var(--muted);
  cursor: not-allowed;
}
.btn-secondary {
  background: #23272f;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #2b303b; }

/* side (front/back) tabs */
.side-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.side-tab {
  flex: 1;
  background: #23272f;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
}
.side-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* stage = product photo, stays a stable background */
.stage-wrap {
  position: relative;
}
.stage {
  position: relative;
  width: 100%;
  line-height: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #05060a;
}
.stage img#bgImage {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
}

/* print area: independent overlay container on top of the background photo */
.print-area {
  position: absolute;
  overflow: hidden;
  border: 2px dashed rgba(255, 255, 255, .55);
  background: rgba(79, 140, 255, .12);
  touch-action: none;
}

/* one image layer - each next one added lays on top of the previous */
.image-layer {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  cursor: grab;
  touch-action: none;
}
.image-layer.dragging { cursor: grabbing; }
.image-layer img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}
.image-layer .layer-delete {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #23272f;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.print-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
}
.print-empty .file-picker-button {
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  padding: 10px 14px;
}

.zoom-row {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.zoom-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #23272f;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.zoom-btn:hover { background: #2b303b; }
.zoom-btn:disabled { opacity: .4; cursor: not-allowed; }

/* "+ Текст" button, mirrors zoom-row but on the left */
.text-row {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
}
.text-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 16px;
  border-radius: 21px;
  background: #23272f;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.text-add-btn:hover { background: #2b303b; }
.text-add-btn:disabled { opacity: .4; cursor: not-allowed; }

/* draggable text layer placed on top of the user photo */
.text-overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  white-space: pre-wrap;
  text-align: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  padding: 6px;
  display: none;
  width: 92%;
  box-sizing: border-box;
}
.text-overlay.dragging { cursor: grabbing; }
.text-overlay .text-delete {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #23272f;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.text-modal[hidden] { display: none; }
.text-modal {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: start center;
  padding: 24px 16px 16px;
}
.text-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
}
.text-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 390px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
}
.text-dialog h2 { margin: 0 0 8px; }
.text-dialog label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.text-dialog textarea,
.text-dialog select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f1115;
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.text-dialog input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f1115;
}
.text-shadow-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--text) !important;
  font-size: 14px !important;
  cursor: pointer;
  margin-top: 4px;
}
.text-shadow-label input { width: auto; }
.text-dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.text-dialog-actions .btn-primary,
.text-dialog-actions .btn-secondary { flex: 1; }
.text-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
}

.change-file-button {
  margin-top: 12px;
  background: #23272f;
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.status {
  text-align: center;
  font-size: 14px;
  min-height: 18px;
  margin-top: 12px;
}
.status.ok { color: #5fd18a; }
.status.err { color: #ff6b6b; }

.order-modal[hidden] { display: none; }
.order-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: start center;
  padding: 24px 16px 16px;
}
.order-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
}
.order-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 390px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
}
.order-dialog h2 { margin: 0 0 8px; }
.order-dialog label { color: var(--muted); font-size: 13px; }
.order-dialog input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f1115;
  color: var(--text);
  font: inherit;
  margin-bottom: 6px;
}
.order-close {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
}
