* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f5f5f5;
  font-family: Arial, sans-serif;
}

#photoEditorApp {
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.editor-header {
  height: 50px;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.editor-logo {
  font-size: 25px;
  font-weight: 500;
  color: #ff5f8a;
  text-decoration: none;
}

.editor-project-name {
  font-size: 18px;
  font-weight: 500;
  color: #444;
}

.editor-header-actions {
  display: flex;
  gap: 16px;
}

.header-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #ff8aaa;
  font-size: 13px;
}

.save-header-btn {
  color: #ff5181;
  font-weight: 600;
}

.editor-main {
  height: calc(100vh - 50px);
  display: grid;
  grid-template-columns: 280px 1fr;
}

.left-panel {
  background: #fff;
  border-right: 1px solid #ddd;
  padding: 16px;
  overflow-y: auto;
}

.templates-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
}

.templates-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.template-card {
  height: 120px;
  background: #fafafa;
  border: 2px solid #e5e5e5;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  padding: 12px;
}

.template-card.active {
  border-color: #ff5181;
}

.template-preview {
  margin: 0 auto;
  background: #fff;
  border: 1px solid #ddd;
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
}

.template-preview-photo {
  position: absolute;
  background: #d6d6d6;
}

.template-name {
  margin-top: 8px;
  text-align: center;
  font-size: 13px;
  color: #555;
}

.center-panel {
  overflow: auto;
  padding: 36px;
}

.photo-sheet {
  display: grid;
  grid-template-columns: repeat(5, max-content);
  gap: 24px;
  align-items: start;
}

.photo-frame {
  position: relative;
  background: #fff;
  box-shadow: 0 5px 18px rgba(0,0,0,.08);
  overflow: hidden;
}

.photo-image-slot {
  position: absolute;
  overflow: hidden;
  background: #d8d8d8;
}

.photo-image-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  touch-action: none;
  cursor: grab;
  transform-origin: center center;
}

.add-photo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  cursor: pointer;
  color: #222;
}

.photo-frame.active {
  outline: 2px solid #ff5181;
}

.photo-upload-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 12px;
  z-index: 20;
  pointer-events: none;
}

.text-box {
  position: absolute;
  z-index: 30;
  cursor: move;
  touch-action: none;
  color: #222;
  font-size: 22px;
  font-family: Arial, sans-serif;
  min-width: 40px;
}

.text-box.selected {
  outline: 1px solid #ff5181;
}

.upload-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 240px;
  padding: 14px;
  background: rgba(255,255,255,.92);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  z-index: 999999;
  opacity: 0;
  transform: translateY(30px);
  pointer-events: none;
  transition: all .25s ease;
}

.upload-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.upload-toast-title {
  font-size: 14px;
  font-weight: 600;
  color: #222;
  margin-bottom: 10px;
}

.upload-toast-bar {
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0,0,0,.08);
}

.upload-toast-progress {
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: #ff5181;
  animation: uploadMove 1s infinite linear;
}

@keyframes uploadMove {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(350%);
  }
}