﻿:root {
  --card-bg: #fff0f5;
  --card-border: #ffb6c1;
  --card-accent: #ff69b4;
  --card-text: #4a4a4a;
  --font-family: 'M PLUS Rounded 1c', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'M PLUS Rounded 1c', sans-serif;
  background-color: #f4f6f8;
  color: #333;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

header {
  text-align: center;
  margin-bottom: 10px;
}

header h1 {
  font-size: 1.3rem;
  color: #e91e63;
  margin-bottom: 2px;
}

header p {
  font-size: 0.75rem;
  color: #666;
}

.app-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 440px;
}

.controls-bar {
  background: #ffffff;
  padding: 8px 10px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  justify-content: center;
  align-items: center;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: bold;
}

input[type="color"] {
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  background: none;
}

select, .btn-secondary {
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.75rem;
  background: #fff;
  cursor: pointer;
}

.btn-danger {
  background: #fff0f0;
  color: #d9534f;
  border-color: #f5c6cb;
}

.btn-primary {
  background: linear-gradient(135deg, #ff6b81, #ff4757);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 25px;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(255, 71, 87, 0.4);
  width: 100%;
  max-width: 280px;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(255, 71, 87, 0.5);
}

.card-outer-wrapper {
  padding: 4px;
  background: #e0e0e0;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  width: 100%;
  max-width: 420px;
}

.profile-card {
  width: 100%;
  min-height: 580px;
  height: auto;
  background-color: var(--card-bg) !important;
  border: 5px solid var(--card-border) !important;
  border-radius: 10px;
  position: relative;
  font-family: var(--font-family);
  color: var(--card-text);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s, border-color 0.2s;
}

.bg-edit-banner {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 100;
  display: flex;
  align-items: center;
}

.btn-bg-done {
  background: #10b981;
  color: white;
  border: none;
  padding: 5px 14px;
  border-radius: 14px;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.btn-bg-done:hover {
  background: #059669;
}

.bg-transform-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.profile-card.is-editing-bg .bg-transform-layer {
  z-index: 50;
}

.profile-card.is-editing-bg .card-content-layer,
.profile-card.is-editing-bg .stamps-layer {
  opacity: 0.35;
  pointer-events: none !important;
}

.profile-card.is-editing-bg [contenteditable="true"],
.profile-card.is-editing-bg .avatar-wrapper {
  pointer-events: none !important;
}

.card-content-layer {
  position: relative;
  flex: 1;
  width: 100%;
  padding: 8px 10px 18px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: none;
  transition: opacity 0.2s;
}

.card-content-layer [contenteditable="true"],
.card-content-layer .avatar-wrapper,
.card-content-layer .card-header {
  pointer-events: auto;
}

[contenteditable="true"] {
  outline: none;
  border-bottom: 1.5px dashed rgba(0,0,0,0.15);
  padding: 1px 2px;
  border-radius: 3px;
  min-height: 1.1em;
  word-break: break-word;
}

[contenteditable="true"]:empty:before {
  content: attr(data-placeholder);
  color: #b0b0b0;
  pointer-events: none;
}

[contenteditable="true"]:hover {
  background-color: rgba(255, 255, 255, 0.5);
  border-bottom-color: var(--card-accent);
}

[contenteditable="true"]:focus {
  background-color: #ffffff;
  border-bottom: 2px solid var(--card-accent);
}

.card-header {
  text-align: center;
  border-bottom: 2px double var(--card-border);
  padding-bottom: 2px;
}

.card-title {
  font-size: 1.1rem;
  color: var(--card-accent) !important;
  font-weight: 800;
  letter-spacing: 2px;
  display: inline-block;
}

.profile-top {
  display: flex;
  gap: 6px;
  align-items: center;
}

.avatar-wrapper {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.avatar-box {
  width: 100%;
  height: 100%;
  border: 2px solid var(--card-border) !important;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.avatar-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  font-size: 0.4rem;
  color: #aaa;
  text-align: center;
  padding: 1px;
  line-height: 1;
}

.avatar-delete-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: #ff4757;
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  z-index: 30;
}

.top-fields {
  flex-grow: 1;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.75);
  padding: 2px 5px;
  border-radius: 8px;
  border: 1px solid var(--card-border) !important;
}

.field-label {
  font-weight: bold;
  color: var(--card-accent) !important;
  white-space: nowrap;
  font-size: 0.65rem;
}

.field-value {
  flex-grow: 1;
  font-size: 0.68rem;
}

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.q-item {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--card-border) !important;
  border-radius: 5px;
  padding: 2px 5px;
}

.q-item .field-label {
  display: block;
  margin-bottom: 1px;
  font-size: 0.62rem;
}

.q-item .field-value {
  font-size: 0.68rem;
}

.free-space-item {
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid var(--card-border) !important;
  border-radius: 5px;
  padding: 5px 7px 8px;
  flex: 1;
  min-height: 64px;
  display: flex;
  flex-direction: column;
}

.free-space-item .field-label {
  border-bottom: 1px dashed var(--card-border);
  padding-bottom: 2px;
  margin-bottom: 4px;
  font-size: 0.65rem;
}

.free-space-item .field-value {
  flex: 1;
  min-height: 36px;
  font-size: 0.68rem;
  line-height: 1.4;
}

.stamps-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

.stamp-wrapper, .bg-wrapper {
  position: absolute;
  display: inline-block;
  cursor: move;
  user-select: none;
  touch-action: none;
  pointer-events: auto;
  transform-origin: center center;
  padding: 0px;
}

.bg-wrapper img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.stamp-wrapper img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.stamp-wrapper.selected {
  outline: 1.5px dashed #ff4757;
  z-index: 20;
}

.bg-wrapper.selected {
  outline: 2px dashed #3b82f6;
}

.stamp-wrapper .btn-delete,
.stamp-wrapper .handle-rotate,
.stamp-wrapper .handle-tl,
.stamp-wrapper .handle-tr,
.stamp-wrapper .handle-bl,
.stamp-wrapper .handle-br,
.bg-wrapper .btn-delete,
.bg-wrapper .handle-rotate,
.bg-wrapper .handle-tl,
.bg-wrapper .handle-tr,
.bg-wrapper .handle-bl,
.bg-wrapper .handle-br {
  display: none !important;
}

.stamp-wrapper.selected .btn-delete,
.stamp-wrapper.selected .handle-rotate,
.stamp-wrapper.selected .handle-tl,
.stamp-wrapper.selected .handle-tr,
.stamp-wrapper.selected .handle-bl,
.stamp-wrapper.selected .handle-br,
.bg-wrapper.selected .handle-rotate,
.bg-wrapper.selected .handle-tl,
.bg-wrapper.selected .handle-tr,
.bg-wrapper.selected .handle-bl,
.bg-wrapper.selected .handle-br {
  display: flex !important;
}

.btn-delete {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  background: #ff4757;
  color: white;
  border-radius: 50%;
  font-size: 13px;
  font-weight: bold;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
  z-index: 30;
}

.handle-rotate {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 26px;
  background: #ffffff;
  border: 2.5px solid #ff4757;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: grab;
  z-index: 30;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.bg-wrapper.selected .handle-rotate {
  border-color: #3b82f6;
}

.handle-tl, .handle-tr, .handle-bl, .handle-br {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border: 2.5px solid #ff4757;
  border-radius: 50%;
  z-index: 30;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.bg-wrapper.selected .handle-tl,
.bg-wrapper.selected .handle-tr,
.bg-wrapper.selected .handle-bl,
.bg-wrapper.selected .handle-br {
  border-color: #3b82f6;
}

.handle-tl { top: -8px; left: -8px; cursor: nwse-resize; }
.handle-tr { top: -8px; right: -8px; cursor: nesw-resize; }
.handle-bl { bottom: -8px; left: -8px; cursor: nesw-resize; }
.handle-br { bottom: -8px; right: -8px; cursor: nwse-resize; }

input[type="file"] {
  display: none;
}