:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 12px rgba(15, 23, 42, .05);
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Header */
.header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 0; }
.header .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; font-weight: 700; color: var(--primary); }
.privacy-badge { font-size: .78rem; color: var(--text-muted); max-width: 380px; text-align: right; }

/* Steps */
.main { padding: 24px 0 48px; }
.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.step.hidden { display: none; }
.step-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.step-number {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; flex: none;
}
.step-title { font-size: 1.15rem; font-weight: 600; }
.btn-back { margin-left: auto; }
.step-hint { margin-top: 12px; font-size: .82rem; color: var(--text-muted); text-align: center; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 20px; font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--primary-dark); }
.btn-secondary { background: #eef2ff; color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-next { width: 100%; margin-top: 18px; }

/* Spec cards */
.spec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.spec-card { position: relative; display: block; border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.spec-card:hover { border-color: #b6c6f5; }
.spec-card input { position: absolute; opacity: 0; pointer-events: none; }
.spec-card:has(input:checked),
.spec-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.spec-card input:focus-visible ~ .spec-info { outline: 2px solid var(--primary); outline-offset: 2px; }
.spec-icon { color: var(--primary); margin-bottom: 10px; }
.spec-info h3 { font-size: 1rem; margin-bottom: 2px; }
.spec-info p { font-size: .8rem; color: var(--text-muted); }
.spec-tag { display: inline-block; margin-top: 8px; font-size: .72rem; color: var(--primary); background: #eef2ff; padding: 2px 8px; border-radius: 99px; }

/* Upload */
.upload-area {
  border: 2px dashed #b6c6f5; border-radius: var(--radius);
  padding: 44px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-area:hover, .upload-area.dragover { border-color: var(--primary); background: #eef2ff; }
.upload-icon { color: var(--primary); margin-bottom: 10px; }
.upload-text { font-weight: 600; }
.upload-hint { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.image-preview { margin-top: 16px; text-align: center; }
.image-preview.hidden { display: none; }
#preview-canvas { max-width: 100%; max-height: 320px; border-radius: 8px; border: 1px solid var(--border); }
#btn-change-photo { margin-top: 10px; }

/* Editor */
.editor-container { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 720px) { .editor-container { grid-template-columns: minmax(0, 1fr) 250px; } }
.canvas-wrapper { position: relative; background: #f1f5f9; border-radius: 8px; overflow: hidden; min-height: 260px; display: flex; align-items: center; justify-content: center; }
#edit-canvas { max-width: 100%; display: block; touch-action: none; }
.face-frame { position: absolute; border: 2px solid rgba(37, 99, 235, .9); box-shadow: 0 0 0 9999px rgba(15, 23, 42, .35); cursor: move; touch-action: none; }
.face-frame.hidden { display: none; }
.frame-handle { position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid var(--primary); border-radius: 50%; }
.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; }
.handle-t { top: -8px; left: 50%; margin-left: -8px; cursor: ns-resize; }
.handle-b { bottom: -8px; left: 50%; margin-left: -8px; cursor: ns-resize; }
.handle-l { left: -8px; top: 50%; margin-top: -8px; cursor: ew-resize; }
.handle-r { right: -8px; top: 50%; margin-top: -8px; cursor: ew-resize; }
.detection-status { position: absolute; top: 10px; left: 10px; background: rgba(15, 23, 42, .75); color: #fff; font-size: .75rem; padding: 4px 10px; border-radius: 99px; }

.editor-sidebar { display: flex; flex-direction: column; gap: 16px; }
.control-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 8px; }
.color-options { display: flex; gap: 10px; }
.color-option { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .75rem; cursor: pointer; position: relative; }
.color-option input { position: absolute; opacity: 0; }
.color-option input:checked + .color-swatch { outline: 3px solid var(--primary); outline-offset: 2px; }
.color-swatch { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); display: block; }
input[type="range"] { width: 100%; accent-color: var(--primary); }
.range-value { font-size: .78rem; color: var(--text-muted); }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 400 !important; cursor: pointer; }
.checkbox-label input { accent-color: var(--primary); width: 16px; height: 16px; }
.beta-notice { display: flex; gap: 8px; align-items: flex-start; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: .75rem; padding: 10px 12px; border-radius: 8px; }
.beta-notice svg { flex: none; margin-top: 1px; }

/* Preview */
.preview-container { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 720px) { .preview-container { grid-template-columns: minmax(0, 1fr) 220px; } }
.preview-main { text-align: center; }
#final-canvas { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.preview-info { margin-top: 10px; font-size: .82rem; color: var(--text-muted); }
.preview-actions { display: flex; flex-direction: column; gap: 10px; justify-content: center; }

/* Footer */
.footer { border-top: 1px solid var(--border); background: var(--surface); padding: 18px 0; text-align: center; color: var(--text-muted); font-size: .8rem; }
.footer-links { margin-top: 6px; display: flex; justify-content: center; gap: 8px; }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--primary); }

@media (max-width: 560px) {
  .step { padding: 16px; }
  .privacy-badge { text-align: left; max-width: none; }
  .header .container { justify-content: center; }
}

/* live preview canvas in editor sidebar */
#edit-preview {
  display: block;
  width: 100%;
  max-width: 222px;
  margin: 0 auto;
  border: 1px solid var(--border, #e2e2e2);
  border-radius: 8px;
  background: #fff;
}

/* Site navigation (pure CSS dropdowns: hover + keyboard focus-within) */
.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav-brand { font-weight: 700; color: var(--primary); text-decoration: none; margin-right: 8px; white-space: nowrap; }
.nav-item { position: relative; }
.nav-label {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: 0; font: inherit;
  font-size: .9rem; font-weight: 600; color: var(--text);
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.nav-item:hover .nav-label,
.nav-item:focus-within .nav-label { background: var(--bg); color: var(--primary); }
.nav-menu {
  position: absolute; top: 100%; left: 0; z-index: 30;
  min-width: 215px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px;
  display: none;
}
.nav-item:hover .nav-menu,
.nav-item:focus-within .nav-menu { display: block; }
.nav-menu a {
  display: block; padding: 7px 10px; border-radius: 6px;
  font-size: .88rem; color: var(--text); text-decoration: none; white-space: nowrap;
}
.nav-menu a:hover { background: #eef2ff; color: var(--primary); }
.nav-cols { columns: 2; min-width: 360px; }
.nav-cols a { break-inside: avoid; }
@media (max-width: 720px) {
  .nav { width: 100%; justify-content: space-between; gap: 6px; }
  .nav-item { flex: 1; }
  .nav-label { width: 100%; justify-content: center; padding: 8px 4px; }
  .nav-menu { position: static; width: 100%; min-width: 0; }
  .nav-cols { columns: 2; min-width: 0; }
}
