.cert-panel .auth-label {
  margin-bottom: 4px;
}

.cert-tpl {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.55);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: 0.15s ease;
}

.cert-tpl:hover {
  border-color: rgba(251, 191, 36, 0.45);
}

.cert-tpl.active {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25);
}

.cert-tpl-name {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: #fcd34d;
}

.cert-tpl-hint {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: #94a3b8;
}

.cert-platform-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}
.cert-platform {
  text-align: right;
  padding: 0.55rem 0.65rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.55);
  color: #e2e8f0;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.cert-platform:hover {
  border-color: rgba(252, 211, 77, 0.45);
}
.cert-platform.active {
  border-color: rgba(252, 211, 77, 0.75);
  background: rgba(252, 211, 77, 0.12);
}
.cert-platform-name {
  display: block;
  font-weight: 700;
  font-size: 0.82rem;
}
.cert-platform-hint {
  display: block;
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 0.15rem;
}
.cert-size-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.cert-size-chip {
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.45);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.72rem;
  cursor: pointer;
}
.cert-size-chip.active {
  border-color: rgba(252, 211, 77, 0.7);
  color: #fde68a;
  background: rgba(252, 211, 77, 0.12);
}

.export-platform-panel {
  max-width: min(560px, 96vw);
}
.export-section {
  margin-top: 0.85rem;
}
.export-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fde68a;
  margin-bottom: 0.4rem;
}
.export-fit-row,
.export-format-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}
.export-preview-wrap {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem;
  border-radius: 0.75rem;
  background: rgba(2, 6, 23, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.2);
}
#export-preview-canvas {
  max-width: 100%;
  height: auto;
  border-radius: 0.4rem;
  background: #fff;
}
.export-dims-label {
  font-size: 0.72rem;
  color: #94a3b8;
  margin: 0;
}

.cert-dropzone {
  border: 1px dashed rgba(251, 191, 36, 0.4);
  border-radius: 12px;
  min-height: 118px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: rgba(15, 23, 42, 0.45);
  cursor: pointer;
  text-align: center;
}

.cert-dropzone:hover {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.06);
}

.cert-dropzone-title {
  font-size: 12px;
  color: #fcd34d;
  font-weight: 700;
}

.cert-dropzone-sub {
  font-size: 10px;
  color: #94a3b8;
}

.cert-thumb {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.14);
  margin-top: 4px;
}

.cert-sex-btn {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.5);
  color: #cbd5e1;
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 700;
}

.cert-sex-btn.active {
  border-color: #38bdf8;
  color: #e0f2fe;
  background: rgba(56, 189, 248, 0.15);
}

.cert-canvas-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px;
  background: rgba(2, 6, 23, 0.55);
}

#cert-canvas {
  width: 100% !important;
  max-width: 100%;
  height: auto !important;
  display: block;
  vertical-align: top;
  touch-action: none;
  cursor: default;
}

#cert-canvas.is-dragging {
  cursor: grabbing !important;
}

.cert-drag-hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
}

.cert-dropzone-logo {
  margin-top: 6px;
  min-height: 72px;
}

.cert-dropzone-hero {
  min-height: 140px;
  border-style: solid;
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(14, 165, 233, 0.08);
}

.cert-thumb-lg {
  width: 120px;
  height: 90px;
}

.cert-crop-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.5);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  touch-action: manipulation;
}

.cert-crop-btn.active {
  border-color: #38bdf8;
  color: #e0f2fe;
  background: rgba(56, 189, 248, 0.18);
}

.cert-crop-stage {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  background: #020617;
  max-width: 100%;
}

#crop-canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  cursor: crosshair;
  touch-action: manipulation;
}

.cert-ai-status {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(245, 158, 11, 0.12);
  color: #fde68a;
}

.cert-ai-status.is-loading {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(14, 165, 233, 0.14);
  color: #bae6fd;
}

.cert-ai-status.is-ok {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(16, 185, 129, 0.14);
  color: #a7f3d0;
}

.cert-ai-status.is-err {
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
}

.cert-ai-thumbs {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
}

.cert-ai-thumb {
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 6px;
  background: rgba(2, 6, 23, 0.55);
}

.cert-ai-thumb img {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: #0f172a;
  margin: 0 auto;
  display: block;
}

.cert-ai-thumb span {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: #94a3b8;
  font-weight: 700;
}

.cert-ai-thumb-hero img {
  width: 96px;
  height: 96px;
  border-width: 3px;
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.cert-tf-panel {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(2, 6, 23, 0.45);
}

.cert-tf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.cert-tf-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: #fde68a;
}

.cert-tf-grid {
  display: grid;
  gap: 8px;
}

.cert-tf-row {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: #cbd5e1;
}

.cert-tf-row em {
  font-style: normal;
  color: #fbbf24;
  font-weight: 700;
  margin-inline-start: 4px;
}

.cert-tf-row input[type="range"] {
  width: 100%;
  accent-color: #f59e0b;
}

.cert-tf-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.cert-tf-btns .btn-irpa {
  min-width: 36px;
  padding: 6px 8px;
}

.cert-tf-eye {
  margin-top: 10px;
  font-size: 11px;
  color: #94a3b8;
}

.cert-tf-eye summary {
  cursor: pointer;
  color: #fde68a;
  margin-bottom: 8px;
  user-select: none;
  font-weight: 700;
}

.cert-tf-eye .cert-tf-row {
  margin-bottom: 8px;
}

.cert-tf-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.cert-color-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.cert-color-row input[type="color"],
.cert-color-input {
  width: 44px;
  height: 38px;
  padding: 2px;
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.55);
  cursor: pointer;
}
.cert-color-row .auth-field {
  flex: 1;
  min-width: 0;
}
.cert-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}
.cert-swatch {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  padding: 0;
}
.cert-swatch:hover {
  transform: scale(1.08);
}
.cert-style-panel .cert-tf-row {
  margin: 0;
}

.cert-tf-mode {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: #cbd5e1;
  font-size: 11px;
}

.cert-tf-mode label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.cert-tf-grid.hidden {
  display: none !important;
}

.eye-cropper-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
}

.eye-cropper-modal.hidden {
  display: none !important;
}

.eye-cropper-panel {
  width: min(760px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  border-radius: 16px;
  border: 1px solid rgba(251, 191, 36, 0.28);
  background: #0b1220;
  padding: 14px 14px 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.eye-cropper-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.eye-cropper-head h3 {
  margin: 0;
  color: #fde68a;
  font-size: 16px;
  font-weight: 800;
}

.eye-cropper-x {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.7);
  color: #e2e8f0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.eye-cropper-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: #94a3b8;
}

.eye-cropper-stage {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #020617;
}

#eye-cropper-canvas {
  width: 100%;
  height: auto;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.eye-cropper-zoom {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 700;
}

.eye-cropper-zoom input {
  width: 100%;
}

.eye-cropper-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

#eye-cropper-preview {
  width: 88px;
  height: 88px;
  border-radius: 999px;
  object-fit: cover;
  border: 3px solid #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  background: #0f172a;
}

.eye-cropper-actions {
  display: flex;
  gap: 8px;
  margin-inline-start: auto;
}

.cert-page-wrap {
  max-width: 100%;
  min-width: 0;
  /* avoid overflow-x:clip — it breaks position:sticky for the card preview */
  overflow-x: visible;
}

.cert-export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
}

.cert-draft-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(252, 211, 77, 0.35);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.88));
  color: #e2e8f0;
}
.cert-draft-banner.hidden { display: none; }
.cert-draft-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1;
}
.cert-draft-banner-text strong {
  color: #fde68a;
  font-size: 0.9rem;
}
.cert-draft-banner-text span {
  font-size: 0.78rem;
  color: #94a3b8;
}
.cert-draft-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.cert-preview-panel {
  min-width: 0;
  max-width: 100%;
}

/* Keep card + live dock visible while scrolling controls */
@media (min-width: 1024px) {
  .cert-layout {
    align-items: start;
  }

  .cert-preview-panel {
    position: sticky;
    top: 72px;
    z-index: 20;
    max-height: calc(100vh - 88px);
    overflow: auto;
    align-self: start;
  }

  .cert-preview-panel .cert-canvas-wrap {
    max-height: calc(100vh - 170px);
    background: #ffffff;
  }

  .cert-preview-panel #cert-canvas {
    max-height: calc(100vh - 190px);
    width: auto;
    max-width: 100%;
    height: auto;
    margin-inline: auto;
    display: block;
  }
}

.cert-live-dock {
  position: sticky;
  top: 64px;
  z-index: 25;
  margin: -0.25rem -0.25rem 0.75rem;
  padding: 0.55rem 0.6rem 0.65rem;
  border-radius: 12px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(8, 15, 28, 0.96);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

.cert-live-dock-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 0.4rem;
}

.cert-live-dock-head strong {
  color: #fcd34d;
  font-size: 12px;
}

.cert-live-dock-head span {
  color: #94a3b8;
  font-size: 10px;
}

#cert-live-mini {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #020617;
}

.orbit-bird-preview {
  width: 100%;
  height: auto;
  margin-top: 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, 0.25);
  display: block;
  background: #0f172a;
}

/* ─── Mobile usability ─── */
@media (max-width: 767px) {
  .cert-page-wrap {
    padding-bottom: 5.5rem;
  }

  .cert-panel {
    padding: 1rem !important;
  }

  .cert-fields-row {
    grid-template-columns: 1fr !important;
  }

  .cert-dropzone {
    min-height: 96px;
    padding: 12px 8px;
  }

  .cert-dropzone-hero {
    min-height: 112px;
  }

  .cert-crop-btn,
  .cert-sex-btn,
  .cert-tpl {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 13px;
  }

  .cert-tpl-hint {
    font-size: 11px;
  }

  .cert-canvas-wrap {
    padding: 6px;
    border-radius: 10px;
  }

  .cert-export-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.4rem;
    padding: 0.55rem 0.65rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
    background: rgba(8, 15, 28, 0.96);
    border-top: 1px solid rgba(251, 191, 36, 0.22);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .cert-export-bar .btn-irpa,
  .cert-export-bar .btn-irpa-solid {
    width: 100%;
    min-height: 44px;
    justify-content: center;
    font-size: 11px !important;
    padding: 8px 4px !important;
    white-space: nowrap;
  }

  .cert-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
}

.cert-bird-pick {
  position: relative;
}

.cert-bird-pick-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.cert-bird-pick-row .auth-field {
  flex: 1;
  min-width: 0;
}

.cert-bird-results {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% - 2px);
  max-height: 220px;
  overflow: auto;
  margin-top: 2px;
  border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, 0.28);
  background: rgba(8, 15, 28, 0.98);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.cert-bird-opt {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  text-align: right;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: transparent;
  color: #e2e8f0;
  cursor: pointer;
  font-size: 12px;
}

.cert-bird-opt:hover,
.cert-bird-opt:focus {
  background: rgba(245, 158, 11, 0.12);
  outline: none;
}

.cert-bird-opt-ring {
  font-family: ui-monospace, monospace;
  color: #fcd34d;
  font-weight: 700;
  direction: ltr;
}

.cert-bird-opt-meta {
  color: #94a3b8;
  font-size: 11px;
}

.cert-bird-picked {
  margin-top: 0.4rem;
  font-size: 11px;
  color: #86efac;
}

.cert-advanced {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: rgba(15, 23, 42, 0.35);
}

.cert-advanced > summary {
  font-weight: 600;
}

.cutout-eraser-panel {
  width: min(900px, 100%);
}

.cutout-eraser-stage {
  background:
    linear-gradient(45deg, #1e293b 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #1e293b 25%, transparent 25%) 0 8px / 16px 16px,
    linear-gradient(45deg, transparent 75%, #1e293b 75%) 8px -8px / 16px 16px,
    linear-gradient(-45deg, transparent 75%, #1e293b 75%) -8px 0 / 16px 16px,
    #0f172a;
}

#cutout-eraser-canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  cursor: crosshair;
  touch-action: none;
}

.cutout-eraser-tools .btn-irpa-solid {
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.35);
}

.body-orbit-box {
  margin-top: 0.55rem;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, 0.22);
  background: rgba(15, 23, 42, 0.45);
}

.body-orbit-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 0.45rem;
}

.body-orbit-head strong {
  color: #fcd34d;
  font-size: 12px;
}

.body-orbit-head span {
  color: #94a3b8;
  font-size: 10px;
}

.body-orbit-row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

#body-orbit-sphere {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: #020617;
  flex-shrink: 0;
  touch-action: none;
}

.body-orbit-sliders {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
