html, body { overflow-x: hidden; height: 100%; }
body { display: flex; flex-direction: column; }

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  gap: 16px;
  flex-shrink: 0;
}

.brand {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.5px;
  text-transform: lowercase;
}

.step-indicator {
  display: flex;
  gap: 24px;
  font-size: 13px;
  color: var(--text-muted);
}

.step-indicator .step {
  position: relative;
  padding-bottom: 4px;
  transition: color 0.2s;
}

.step-indicator .step.active {
  color: var(--text);
  font-weight: 500;
}

.step-indicator .step.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

.step-indicator .step.done {
  color: var(--success);
}

.app-main {
  flex: 1;
  padding: 16px 20px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.step-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.step-panel.active {
  display: flex;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-panel h1 {
  font-weight: 500;
  font-size: 20px;
  margin-bottom: 2px;
}

.step-panel .hint {
  color: var(--text-muted);
  margin-bottom: 12px;
  font-size: 13px;
}

/* Orientation chooser ===== */

.orientation-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 600px;
}

.orientation-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  color: inherit;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.orientation-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.orientation-card.selected {
  border-color: var(--accent);
  border-width: 2px;
}

.orientation-preview {
  background: #f0f0f0;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
}

.orientation-preview.portrait {
  width: 84px;
  height: 119px;
}

.orientation-preview.landscape {
  width: 119px;
  height: 84px;
}

.orientation-label {
  font-weight: 500;
  font-size: 16px;
}

.orientation-size {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Editor stage (canvas placeholder) ===== */

.editor-stage,
.preview-stage {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 80px 20px;
  text-align: center;
  margin-bottom: 24px;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder-text {
  color: var(--text-muted);
  font-size: 14px;
}

/* Editor layout (canvas + side panel) ===== */

.editor-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  margin-bottom: 12px;
  align-items: flex-start;
  flex: 1;
  min-height: 0;
}

.canvas-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  align-self: stretch; /* растягивает по высоте grid */
}

.canvas-area canvas,
.canvas-area .canvas-container {
  display: block;
  border: 1px solid #ddd;
  max-width: 100%;
  max-height: 100%;
}

.canvas-side {
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.upload-zone {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: #f9f9f9;
}

.upload-zone .upload-icon {
  font-size: 36px;
  font-weight: 200;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1;
}

.upload-zone p {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.upload-zone .upload-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.photo-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.photo-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.photo-info-row .label {
  color: var(--text-muted);
}

.photo-info-row .value {
  font-variant-numeric: tabular-nums;
}

.quality-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
}

.quality-status.quality-good {
  background: #e8f5ee;
  color: var(--success);
}

.quality-status.quality-medium {
  background: #fdf6e3;
  color: var(--warning);
}

.quality-status.quality-bad {
  background: #fdecea;
  color: var(--error);
}

.quality-icon {
  font-weight: 700;
  flex-shrink: 0;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-align: left;
  align-self: flex-start;
}

.btn-link:hover {
  color: var(--text);
}

/* Text controls (step 3) ===== */

.text-controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.label-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.label-field textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  min-height: 100px;
  background: var(--surface);
}

.label-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.char-counter {
  font-size: 11px;
  color: var(--text-muted);
  align-self: flex-end;
  font-variant-numeric: tabular-nums;
}

.font-select {
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.font-select:focus {
  outline: none;
  border-color: var(--accent);
}

.size-choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.size-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s;
}

.size-card:hover { border-color: var(--accent); }

.size-card.selected {
  border-color: var(--accent);
  border-width: 2px;
  padding: 9px;
  background: var(--accent);
  color: white;
}

/* Responsive ===== */

@media (max-width: 768px) {
  .app-header {
    padding: 12px 16px;
    gap: 8px;
  }
  .brand {
    font-size: 12px;
  }
  .step-indicator {
    gap: 10px;
    font-size: 11px;
  }
  .app-main {
    padding: 24px 16px;
  }
  .editor-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .canvas-area {
    display: block;
    text-align: center;
    padding: 12px;
    width: 100%;
  }
  .canvas-area .canvas-container {
    max-width: 100% !important;
    margin: 0 auto;
  }
  .canvas-area canvas {
    max-width: 100%;
    height: auto;
  }
  .canvas-side {
    min-width: 0;
  }
}

@media (max-width: 420px) {
  .step-indicator { gap: 6px; font-size: 10px; }
  .step-panel h1 { font-size: 20px; }
}

/* Actions row ===== */

.actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-shrink: 0;
}

/* Footer ===== */

.app-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 20px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Step 4 — превью обеих сторон ===== */

.preview-sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
  justify-items: center;
}

.preview-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.preview-side img {
  max-width: 100%;
  max-height: 60vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: white;
}

.preview-side figcaption {
  font-size: 13px;
  color: var(--text-muted);
}

.save-status {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}

.save-status.saving { background: #fdf6e3; color: var(--warning); }
.save-status.success { background: #e8f5ee; color: var(--success); }
.save-status.error { background: #fdecea; color: var(--error); }

@media (max-width: 600px) {
  .preview-sides {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Responsive ===== */

@media (max-width: 600px) {
  .step-indicator { gap: 12px; font-size: 11px; }
  .app-main { padding: 24px 16px; }
  .step-panel h1 { font-size: 22px; }
  .orientation-choices { grid-template-columns: 1fr; }
}
