:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2430;
  --accent: #4f6ef7;
  --accent-dark: #3c58d6;
  --muted: #7a8194;
  --error: #d64545;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.header {
  text-align: center;
  padding: 40px 16px 8px;
}
.header h1 {
  margin: 0;
  font-size: 2.4rem;
  letter-spacing: 0.04em;
}
.subtitle {
  color: var(--muted);
  margin-top: 8px;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(31, 36, 48, 0.06);
}
.card h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

input[type="text"], input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d8dce6;
  border-radius: 8px;
  font-size: 1rem;
}

.preview-box {
  margin-top: 14px;
  text-align: center;
}
#photoPreview {
  max-width: 100%;
  max-height: 340px;
  border-radius: 10px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.template-grid img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 10px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.template-grid img:hover { transform: scale(1.03); }
.template-grid img.selected { border-color: var(--accent); }

.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

button, .button-link {
  padding: 12px 22px;
  border: none;
  border-radius: 10px;
  background: #e8ebf4;
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.primary, .button-link {
  background: var(--accent);
  color: #fff;
}
button.primary:hover, .button-link:hover { background: var(--accent-dark); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.poster {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 12px auto;
  border-radius: 10px;
}

.hint { color: var(--muted); font-size: 0.92rem; }
.error { color: var(--error); text-align: center; }

.footer {
  text-align: center;
  color: var(--muted);
  padding: 24px 0 40px;
  font-size: 0.9rem;
}

code {
  background: #eef0f6;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}

/* ---------- Wizard v3 ---------- */
.steps {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 16px 8px;
}
.steps .step {
  font-size: 0.82rem;
  color: var(--muted);
  background: #e8ebf4;
  border-radius: 999px;
  padding: 6px 12px;
}
.steps .step.active {
  background: var(--accent);
  color: #fff;
}

.field {
  display: block;
  margin: 14px 0;
  font-size: 0.95rem;
  color: #3b4152;
}
.field input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #d8dce6;
  border-radius: 8px;
  font-size: 1rem;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.template-card {
  margin: 0;
  cursor: pointer;
  text-align: center;
  border-radius: 12px;
  padding: 8px;
  border: 3px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.template-card:hover { transform: translateY(-3px); }
.template-card.selected { border-color: var(--accent); background: #f2f4fd; }
.template-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
}
.template-card figcaption { font-size: 0.85rem; margin-top: 6px; color: #454b5c; }

.tariff-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.tariff-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  text-align: left;
  border: 2px solid #e2e6f0;
  background: #fff;
  padding: 16px;
}
.tariff-card .price { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.tariff-card.selected { border-color: var(--accent); background: #f2f4fd; }

.checkbox {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 12px 0;
  font-size: 0.92rem;
  line-height: 1.35;
  color: #3b4152;
}
.checkbox input { margin-top: 3px; }

.total {
  margin: 16px 0;
  font-size: 1.1rem;
}
.total strong { font-size: 1.4rem; color: var(--accent); }

/* ---------- Фото в кружке: живой редактор ---------- */
.circle-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 14px;
  padding: 14px;
  background: #f7f8fc;
  border: 1px solid #e2e6f0;
  border-radius: 12px;
}
@media (max-width: 720px) {
  .circle-editor { grid-template-columns: 1fr; }
}
.circle-editor__label {
  margin: 0 0 8px;
  font-weight: 600;
  font-size: 0.95rem;
  color: #3b4152;
}
.circle-editor__row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
.bg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #3b4152;
}
.bg-row select {
  padding: 6px 8px;
  border: 1px solid #d8dce6;
  border-radius: 8px;
  font-size: 0.9rem;
}
#photoBgCustom {
  width: 36px;
  height: 32px;
  padding: 2px;
  border: 1px solid #d8dce6;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.ghost-btn {
  padding: 8px 14px;
  border: 1px solid #d8dce6;
  background: #fff;
  color: #3b4152;
  border-radius: 8px;
  font-size: 0.88rem;
  cursor: pointer;
}
.ghost-btn:hover { background: #eef1f8; }

.zoom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #3b4152;
}
.zoom-row input[type="range"] {
  width: 120px;
  accent-color: var(--accent);
}
.zoom-row span {
  min-width: 40px;
  font-variant-numeric: tabular-nums;
}

/* круг-превью */
.circle-stage {
  position: relative;
  width: min(240px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  background: #e8ebf4;
  cursor: grab;
  touch-action: none;
  user-select: none;
  box-shadow: inset 0 0 0 3px rgba(79, 110, 247, 0.25), 0 4px 14px rgba(31, 36, 48, 0.12);
}
.circle-stage:active { cursor: grabbing; }
.circle-stage__fill {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #f0e6d0; /* подставляется из темы/фона */
  z-index: 0;
}
.circle-stage #circlePhoto {
  position: absolute;
  /* left/top/width задаёт paintCircleEditor (геометрия как в Pillow) */
  z-index: 1;
  pointer-events: none;
  max-width: none;
  max-height: none;
  height: auto;
  object-fit: fill;
}
.circle-stage__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 2px rgba(79, 110, 247, 0.35);
  z-index: 2;
  pointer-events: none;
}
.circle-stage__hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 3;
  background: rgba(31, 36, 48, 0.72);
  color: #fff;
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
}
.circle-stage__hint.is-hidden { opacity: 0; }

/* исходник с рамкой кадра */
.source-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: #e8ebf4;
  line-height: 0;
}
.source-stage #photoPreview {
  display: block;
  max-width: 100%;
  max-height: 280px;
  width: auto;
  height: auto;
  pointer-events: none;
}
.source-stage__crop {
  position: absolute;
  border: 2px dashed rgba(79, 110, 247, 0.9);
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(244, 246, 251, 0.45);
  pointer-events: none;
}
#offsetEcho {
  margin: 8px 0 0;
  font-variant-numeric: tabular-nums;
}

