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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fff;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

canvas {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
}

#photoView {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  pointer-events: none;
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
}

#mainCanvas {
  z-index: 1;
  background: transparent;
}

#cropCanvas {
  z-index: 2;
  pointer-events: none;
}

#toolCanvas {
  z-index: 3;
  pointer-events: auto;
}

#fileInput,
#fileInputToolbar {
  position: fixed;
  left: -10000px;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.toolbar-file-btn {
  position: absolute;
  z-index: 10;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.toolbar-file-btn:disabled {
  pointer-events: none;
  cursor: default;
}

.start-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.92);
  text-align: center;
  padding: 1.5rem;
}

.start-overlay[hidden] {
  display: none;
}

.start-overlay-text {
  margin: 0;
  font-size: 1.1rem;
  color: #222;
}

.choose-photo-control {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 1.75rem);
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  background: #333;
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
}

.choose-photo-control[hidden] {
  display: none !important;
}

.brave-hint {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 5.5rem);
  margin: 0;
  max-width: min(90vw, 320px);
  font-size: 0.8rem;
  line-height: 1.35;
  color: #555;
  text-align: center;
}

.brave-hint[hidden] {
  display: none;
}

.order-progress {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  margin-top: 0.5rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}

.order-progress[hidden] {
  display: none;
}

.message {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  max-width: min(90vw, 360px);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.88);
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
}

.message.error {
  background: rgba(120, 24, 24, 0.95);
}

.message.success {
  background: rgba(24, 80, 40, 0.95);
}

.message.hidden {
  display: none;
}
