.custom-case-page {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(31, 157, 107, 0.08), transparent 55%),
    radial-gradient(ellipse 70% 45% at 90% 10%, rgba(20, 23, 31, 0.04), transparent 50%),
    var(--bg, #f6f7f9);
}

.custom-case-page .site-header {
  flex: 0 0 auto;
}

.custom-case-designer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 4.25rem);
}

.custom-case-main {
  width: min(1280px, calc(100% - 1.5rem));
  margin: 0.5rem auto;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.custom-case-seo {
  width: min(720px, calc(100% - 1.5rem));
  margin: 0 auto 1.75rem;
}

.custom-case-seo-inner {
  padding: 1.35rem 0 0.25rem;
  border-top: 1px solid var(--line, #e5e7eb);
}

.custom-case-seo h2 {
  margin: 0 0 0.65rem;
  font-size: clamp(1.2rem, 2.4vw, 1.45rem);
  letter-spacing: -0.02em;
}

.custom-case-seo h3 {
  margin: 1.25rem 0 0.45rem;
  font-size: 1.02rem;
}

.custom-case-seo p,
.custom-case-seo li {
  color: var(--text-soft, #5b6470);
  font-size: 0.95rem;
  line-height: 1.65;
}

.custom-case-seo p {
  margin: 0 0 0.85rem;
}

.custom-case-seo ul {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

.custom-case-seo a {
  color: var(--primary-dark, #167a53);
  font-weight: 600;
}

.custom-case-steps {
  margin: 0 0 0.5rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.custom-case-steps li {
  display: grid;
  gap: 0.15rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line-soft, #eceff3);
  background: rgba(255, 255, 255, 0.65);
}

.custom-case-steps strong {
  color: var(--text, #14181f);
  font-size: 0.92rem;
}

.custom-case-faq-group {
  margin: 1.35rem 0 0.55rem;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  color: var(--text, #14181f);
}

.custom-case-faq-list {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.25rem;
}

.custom-case-faq-item {
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.15rem 0.85rem;
}

.custom-case-faq-item summary {
  cursor: pointer;
  font-weight: 650;
  padding: 0.7rem 0;
  color: var(--text, #14181f);
}

.custom-case-faq-item p {
  margin: 0 0 0.85rem;
}

.custom-case-footer {
  margin-top: auto;
}

.custom-case-top {
  flex: 0 0 auto;
}

.custom-case-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.85rem;
}

.custom-case-intro h1 {
  margin: 0;
  font-size: clamp(1.15rem, 2vw, 1.4rem);
  letter-spacing: -0.03em;
}

.custom-case-intro p {
  margin: 0;
  line-height: 1.35;
  font-size: 0.84rem;
}

.custom-case-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(19rem, 22.5rem);
  gap: 0.75rem;
  align-items: start;
}

.custom-case-stage {
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  padding: 0.85rem 0.75rem 0.7rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius-lg, 16px);
  background:
    linear-gradient(180deg, #fbfbfc 0%, #eef1f5 100%);
  overflow: auto;
}

.custom-case-stage > .cc-mockup,
.custom-case-stage > .cc-phone {
  flex: 0 1 auto;
  min-height: 0;
}

.custom-case-canvas-tools {
  width: min(480px, 100%);
  display: grid;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.custom-case-zoom-inline {
  display: grid;
  gap: 0.2rem;
  font-size: 0.76rem;
  font-weight: 650;
}

.custom-case-zoom-inline em {
  font-style: normal;
  font-weight: 700;
  color: var(--primary-dark, #166534);
}

.custom-case-zoom-inline input[type="range"] {
  width: 100%;
}

.custom-case-controls {
  align-self: start;
  width: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.55rem;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0.7rem 0.75rem 0.85rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius-lg, 16px);
  background: var(--surface, #fff);
  box-shadow: var(--shadow-sm, 0 8px 24px rgba(20, 23, 31, 0.06));
}

.custom-case-panel {
  display: grid;
  gap: 0.45rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line, #e5e7eb);
  flex: 0 0 auto;
}

.custom-case-panel:last-of-type,
.custom-case-panel--checkout {
  border-bottom: 0;
  padding-bottom: 0;
}

.custom-case-panel--checkout {
  margin-top: 0.15rem;
}

.custom-case-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.custom-case-grid-colors {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

.custom-case-field {
  display: grid;
  gap: 0.22rem;
  font-size: 0.76rem;
  font-weight: 650;
  min-width: 0;
}

.custom-case-field select,
.custom-case-field input[type="range"] {
  width: 100%;
}

.custom-case-field select {
  min-height: 2.15rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 9px;
  background: #fff;
  font: inherit;
  font-weight: 500;
}

.custom-case-field em {
  font-style: normal;
  font-weight: 700;
  color: var(--primary-dark, #166534);
}

.custom-case-upload input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.custom-case-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.custom-case-upload-row .button {
  min-height: 2.05rem;
  padding-inline: 0.65rem;
  font-size: 0.85rem;
}

.custom-case-file-name {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 500;
  word-break: break-all;
}

.custom-case-inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.custom-case-hint {
  margin: 0;
  padding-top: 0.15rem;
  font-size: 0.72rem;
  line-height: 1.35;
  font-weight: 500;
  flex: 0 0 auto;
}

.custom-case-section-label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted, #6b7280);
}

.custom-case-price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.15rem 0 0;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(31, 157, 107, 0.1);
  border: 1px solid rgba(31, 157, 107, 0.22);
}

.custom-case-price__label {
  font-size: 0.76rem;
  font-weight: 650;
  color: var(--muted, #6b7280);
}

.custom-case-price strong {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--primary-dark, #166534);
}

.custom-case-save-btn {
  width: 100%;
  min-height: 2.6rem;
  margin-top: 0.15rem;
  font-weight: 750;
}

.custom-case-save-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.custom-case-save-status {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.35;
  font-weight: 550;
}

.custom-case-save-status.is-error {
  color: #b42318;
}

.custom-case-save-status.is-ok {
  color: var(--primary-dark, #166534);
}

.custom-case-save-status a {
  color: inherit;
  font-weight: 700;
}

.custom-case-field textarea {
  width: 100%;
  min-height: 2.8rem;
  max-height: 5rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 9px;
  background: #fff;
  font: inherit;
  font-weight: 500;
  resize: vertical;
}

.custom-case-color-row {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  gap: 0.35rem;
  align-items: center;
}

.custom-case-color-row input[type="color"] {
  width: 2.2rem;
  height: 2.05rem;
  padding: 0;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.custom-case-color-row input[type="text"] {
  width: 100%;
  min-width: 0;
  min-height: 2.05rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 8px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.custom-case-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 650;
}

.custom-case-check input {
  width: 1rem;
  height: 1rem;
}

.custom-case-mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.custom-case-mode {
  min-height: 2.1rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
}

.custom-case-mode.is-active {
  border-color: rgba(31, 157, 107, 0.55);
  background: rgba(31, 157, 107, 0.12);
  color: var(--primary-dark, #166534);
}

/* ---- Real PNG case mockup ---- */
.cc-mockup {
  width: min(540px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  user-select: none;
  touch-action: none;
}

.cc-mockup__stage {
  position: relative;
  width: min(100%, 72vh, 540px);
  aspect-ratio: 1;
  container-type: inline-size;
}

/* Faint full-bleed copy of the art (outside the case) */
.cc-mockup__ghost {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

.cc-mockup__ghost img,
.cc-mockup__print > img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  max-width: none;
  /* Fit entire image by longest side; case background fills the rest */
  object-fit: contain;
  transform-origin: center center;
  pointer-events: none;
  will-change: transform;
  z-index: 1;
}

.cc-mockup__cover {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #111827;
}

.cc-mockup__text {
  position: absolute;
  left: 50%;
  top: 52%;
  z-index: 2;
  max-width: 58%;
  padding: 0.35rem 0.55rem;
  text-align: center;
  line-height: 1.15;
  font-weight: 700;
  white-space: pre-wrap;
  word-break: break-word;
  transform: translate(-50%, -50%);
  pointer-events: none;
  user-select: none;
}

.cc-mockup__text.has-plate {
  border-radius: 0.35rem;
}

.cc-mockup__text[hidden] {
  display: none !important;
}

.cc-mockup.is-text-mode .cc-mockup__print {
  cursor: grab;
}

.cc-mockup.is-text-mode .cc-mockup__text {
  outline: 1px dashed rgba(255, 255, 255, 0.35);
}

/* Art clipped to case silhouette via alpha mask */
.cc-mockup__print {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  z-index: 1;
  background: transparent;
  -webkit-mask-image: var(--cc-mask);
  mask-image: var(--cc-mask);
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-mode: alpha;
  mask-mode: alpha;
}

.cc-mockup__print.is-dragging {
  cursor: grabbing;
}

.cc-mockup__placeholder {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(46%, 12.5rem);
  margin: 0;
  padding: 0.5rem 0.65rem;
  transform: translate(-50%, -50%);
  text-align: center;
  color: rgba(255, 255, 255, 0.62);
  font-size: clamp(0.74rem, 3.4cqi, 0.92rem);
  line-height: 1.4;
  font-weight: 650;
  pointer-events: none;
  overflow: visible;
  text-wrap: balance;
}

.cc-mockup__placeholder[hidden] {
  display: none !important;
}

/* Hide any leftover empty-src images (Safari shows a broken-image glyph otherwise) */
.cc-mockup img:not([src]),
.cc-mockup img[src=""],
.cc-phone img:not([src]),
.cc-phone img[src=""] {
  visibility: hidden;
}

.cc-mockup__overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 8px 16px rgba(20, 23, 31, 0.12));
}

.cc-mockup__caption {
  margin: 0;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text, #14171f);
}

/* ---- Phone shell ---- */
.cc-phone {
  --cc-w: 280px;
  --cc-ratio: 19.5 / 9;
  --cc-radius: 2.4rem;
  --cc-bezel: 0.55rem;
  --cc-screen-radius: 1.9rem;
  width: var(--cc-w);
  user-select: none;
  touch-action: none;
}

.cc-phone__bezel {
  position: relative;
  width: 100%;
  aspect-ratio: var(--cc-ratio);
  padding: var(--cc-bezel);
  border-radius: var(--cc-radius);
  background: linear-gradient(160deg, #2a2e36 0%, #14171d 55%, #0d0f13 100%);
  box-shadow:
    0 18px 40px rgba(20, 23, 31, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.cc-phone__screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: var(--cc-screen-radius);
  background: #0b0d11;
  cursor: grab;
}

.cc-phone__screen.is-dragging {
  cursor: grabbing;
}

.cc-phone__canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    linear-gradient(45deg, #1a1d24 25%, transparent 25%),
    linear-gradient(-45deg, #1a1d24 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1d24 75%),
    linear-gradient(-45deg, transparent 75%, #1a1d24 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  background-color: #11141a;
}

.cc-phone__canvas img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  transform-origin: center center;
  pointer-events: none;
  will-change: transform;
}

.cc-phone__placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 1.5rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.9rem;
  line-height: 1.45;
  font-weight: 600;
}

.cc-phone__island {
  position: absolute;
  z-index: 3;
  top: calc(var(--cc-bezel) + 0.55rem);
  left: 50%;
  width: 34%;
  height: 1.15rem;
  border-radius: 999px;
  background: #050607;
  transform: translateX(-50%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.cc-phone__button {
  position: absolute;
  background: #1a1d24;
  border-radius: 2px;
}

.cc-phone__button--power {
  right: -0.14rem;
  top: 22%;
  width: 0.14rem;
  height: 12%;
}

.cc-phone__button--vol-up,
.cc-phone__button--vol-down {
  left: -0.14rem;
  width: 0.14rem;
  height: 7%;
}

.cc-phone__button--vol-up {
  top: 18%;
}

.cc-phone__button--vol-down {
  top: 28%;
}

.cc-phone__caption {
  margin: 0.85rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text, #14171f);
}

/* Samsung-style camera island */
.cc-phone--samsung {
  --cc-ratio: 19.3 / 9;
  --cc-radius: 2.1rem;
  --cc-screen-radius: 1.7rem;
}

.cc-phone--samsung .cc-phone__island {
  top: calc(var(--cc-bezel) + 0.7rem);
  left: 50%;
  width: 28%;
  height: 1.35rem;
  border-radius: 1rem;
  transform: translateX(-50%);
}

.cc-phone--samsung-ultra {
  --cc-ratio: 19.3 / 9;
  --cc-radius: 2rem;
  --cc-screen-radius: 1.55rem;
  --cc-w: 292px;
}

.cc-phone--samsung-ultra .cc-phone__island {
  top: calc(var(--cc-bezel) + 0.55rem);
  left: calc(var(--cc-bezel) + 0.55rem);
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 1.1rem;
  transform: none;
}

.cc-phone--compact {
  --cc-ratio: 19 / 9;
  --cc-w: 260px;
}

@media (max-width: 980px) {
  .custom-case-page {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .custom-case-main {
    margin-bottom: 1.5rem;
  }

  .custom-case-layout {
    grid-template-columns: 1fr;
    flex: none;
    align-items: stretch;
  }

  .custom-case-stage {
    order: -1;
    height: auto;
    min-height: 0;
  }

  .custom-case-controls {
    max-height: none;
    overflow: visible;
  }

  .custom-case-grid-2 {
    grid-template-columns: 1fr;
  }

  .cc-mockup__stage {
    width: min(380px, 86vw);
  }

  .cc-phone {
    --cc-w: min(260px, 72vw);
  }
}
