:root {
  --bg: #0d1420;
  --bg-2: #111b2a;
  --panel: #121b2a;
  --panel-alt: #1a2437;
  --panel-border: rgba(148, 163, 184, 0.14);
  --canvas-bg: #f5f7fa;
  --canvas-surface: #ffffff;
  --ink: #e5edf8;
  --muted: #9aa9be;
  --blue: #4e8cff;
  --blue-strong: #7aa8ff;
  --yellow: #f6cf2a;
  --yellow-dark: #e1bb1d;
  --shadow: rgba(2, 6, 23, 0.46);
  --field: rgba(148, 163, 184, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at top, #162334 0%, var(--bg) 40%, #0a1018 100%);
  color: var(--ink);
}

body {
  min-height: 100vh;
  display: grid;
  place-items: stretch;
  padding: 0;
}

button, input {
  font: inherit;
}

.page-shell {
  width: 100vw;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 0;
  padding: 0;
  border-radius: 0;
  background: var(--panel);
  box-shadow: none;
  border: 0;
  overflow: hidden;
}

.controls-panel {
  background: linear-gradient(180deg, #0a0b0b 0%, #0b0c0d 100%);
  border-right: 1px solid var(--panel-border);
  padding: 20px 18px;
  color: var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 8px 6px 18px;
  font-weight: 900;
  font-size: clamp(1.3rem, 1.6vw, 1.8rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}

.brand-1,
.brand-2 {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(246, 207, 42, 0.12);
  border: 1px solid rgba(246, 207, 42, 0.25);
  color: #f7d96a;
  box-shadow: none;
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  padding: 18px 12px;
  border-radius: 16px;
  border: 1px dashed rgba(148, 163, 184, 0.3);
  background: var(--field);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
  text-align: center;
  color: var(--ink);
}

.dropzone.drag-over {
  transform: translateY(-2px);
  border-color: var(--blue-strong);
  background: rgba(78, 140, 255, 0.12);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-label {
  font-size: 1.02rem;
  font-weight: 700;
}

.dropzone-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(17, 43, 82, 0.08);
}

.section-label {
  margin-bottom: 10px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.layer-toggle,
.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.layer-button,
.split-button,
.action-button,
.save-button,
.secondary-button,
.primary-button,
.icon-button {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  font-weight: 700;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.layer-button,
.split-button,
.action-button,
.save-button,
.secondary-button,
.primary-button,
.icon-button {
  padding: 10px 12px;
  background: rgba(148, 163, 184, 0.08);
  color: var(--ink);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.layer-button.active,
.split-button.active {
  background: rgba(78, 140, 255, 0.18);
  color: #dae7ff;
  border-color: rgba(122, 168, 255, 0.5);
  box-shadow: inset 0 0 0 1px rgba(122, 168, 255, 0.18);
}

.layer-button:hover,
.split-button:hover,
.action-button:hover,
.save-button:hover,
.secondary-button:hover,
.primary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.zoom-label {
  display: block;
  margin: 16px 0 8px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.mini-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.action-button {
  background: rgba(246, 207, 42, 0.22);
  border: 1px solid rgba(17, 43, 82, 0.12);
}

.action-button.alt {
  background: rgba(17, 43, 82, 0.08);
}

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

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.save-button,
.primary-button {
  width: 100%;
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--yellow) 0%, var(--yellow-dark) 100%);
  border: 4px solid var(--blue);
  color: var(--ink);
  font-size: 1.04rem;
  box-shadow: 0 10px 0 rgba(31, 61, 120, 0.16);
}

.secondary-button {
  width: 100%;
  padding: 14px 18px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.12);
  color: var(--ink);
}

.project-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 40;
}

.project-modal.hidden {
  display: none;
}

.project-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
}

.project-modal-panel {
  position: relative;
  width: min(620px, calc(100vw - 32px));
  max-height: min(80vh, 640px);
  overflow: auto;
  background: #121b2a;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 18px;
  box-shadow: 0 30px 70px rgba(2, 6, 23, 0.52);
  padding: 20px;
}

.project-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.project-modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--ink);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: rgba(148, 163, 184, 0.08);
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  padding: 0;
}

.project-form {
  margin-bottom: 18px;
}

.project-form label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.project-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

#projectNameInput {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(148, 163, 184, 0.08);
  color: var(--ink);
}

.saved-projects-header {
  margin: 10px 0 8px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.saved-project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.saved-project-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.saved-project-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 88px;
  height: 70px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(19, 23, 32, 0.8);
}

.saved-project-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: rgba(148, 163, 184, 0.1);
}

.saved-project-thumb + .saved-project-thumb {
  border-left: 1px solid rgba(148, 163, 184, 0.16);
}

.saved-project-info {
  min-width: 0;
}

.saved-project-name {
  display: block;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-project-date {
  display: block;
  margin-top: 3px;
  font-size: 0.76rem;
  color: var(--muted);
}

.saved-project-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.saved-project-actions button {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(148, 163, 184, 0.08);
  color: var(--ink);
  cursor: pointer;
}

.saved-project-actions .load-project {
  background: rgba(78, 140, 255, 0.18);
}

.empty-projects {
  border: 1px dashed rgba(148, 163, 184, 0.18);
  border-radius: 12px;
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.preview-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #1e1e1e 0%, #272728 100%);
  padding: 22px;
  min-height: 100vh;
}

.editor-stage {
  position: relative;
  width: min(72vmin, 760px);
  aspect-ratio: 4 / 5;
  background: #ffffff;
  border-radius: 0;
  overflow: hidden;
  box-shadow: 6px 6px 13px #000;
  transform-origin: center center;
  transition: transform 0.12s ease;
}

.preview-wrap {
  display: none;
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.floating-tag {
  position: absolute;
  pointer-events: auto;
  border: 7px solid #0b2252;
  border-radius: 32px;
  background: radial-gradient(circle, rgb(255 230 112) 0%, rgb(255, 226, 101) 52%, rgb(240, 193, 17) 100%);
  color: #0b2252;
  font-family: 'Hamberger Bold', 'Segoe UI', sans-serif;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: clamp(1.7rem, 2.6vw, 3.1rem);
  line-height: 93px;
  height: 90px;
  padding: 0 40px;
  box-shadow: 0 9px 0 #0b2252;
  cursor: grab;
  user-select: none;
  white-space: nowrap;
  transform-origin: center center;
  overflow: visible;
}

.floating-tag.selected {
  box-shadow: 0 9px 0 #0b2252;
}

.logo-layer {
  position: absolute;
  left: 0;
  top: 0;
  display: none;
  pointer-events: auto;
  cursor: grab;
  user-select: none;
  transform-origin: center center;
  z-index: 3;
  overflow: visible;
  position: absolute;
  filter: drop-shadow(0 8px 18px rgba(17, 43, 82, 0.14));
}

.logo-layer img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.logo-layer .tag-handle {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 3px solid var(--blue);
  border-radius: 50%;
  background: #fff;
  color: var(--blue);
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(17, 43, 82, 0.18);
  cursor: pointer;
  pointer-events: auto;
  z-index: 4;
  padding: 0;
}

.logo-layer .tag-handle-rotate {
  right: -14px;
  top: -18px;
}

.logo-layer .tag-handle-resize {
  right: -14px;
  bottom: -18px;
}

.logo-layer .tag-handle[data-type="opacity"] {
  right: 18px;
  top: -18px;
  background: #f5f8ff;
  font-size: 0.95rem;
}

.logo-layer.selected {
  filter: drop-shadow(0 10px 18px rgba(17, 43, 82, 0.18)) drop-shadow(0 0 0 3px rgba(31, 61, 120, 0.12));
}

.logo-layer:active {
  cursor: grabbing;
}

.floating-tag:active {
  cursor: grabbing;
}

.tag-handle {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 3px solid var(--blue);
  border-radius: 50%;
  background: #fff;
  color: var(--blue);
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(17, 43, 82, 0.18);
  cursor: pointer;
  pointer-events: auto;
  z-index: 4;
  padding: 0;
}

.tag-handle:hover {
  background: #f5f8ff;
}

.tag-handle-rotate {
  right: -14px;
  top: -18px;
}

.tag-handle-resize {
  right: -14px;
  bottom: -18px;
}

.before-tag {
  left: 0;
  top: 0;
}

.after-tag {
  left: 0;
  top: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 5;
  object-fit: contain;
  border-radius: 0;
  background: #ffffff;
  cursor: grab;
}

canvas.dragging {
  cursor: grabbing;
}

@media (max-width: 980px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .preview-wrap {
    min-height: 520px;
  }
}
