/* Inkloom Phone Studio */
.ph-root {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  flex-direction: column;
  background: #0b1017;
  color: #eef2f7;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}
.ph-root.is-open { display: flex; }

/* Top bar */
.ph-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(9, 14, 22, 0.9);
}
.ph-brand { display: flex; flex-direction: column; line-height: 1.1; }
.ph-brand strong { font-size: 15px; letter-spacing: 0.02em; }
.ph-brand span { font-size: 12px; color: #9fb0c3; }
.ph-spacer { flex: 1; }

/* Buttons */
.ph-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: #eef2f7;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.ph-btn:hover { background: rgba(255, 255, 255, 0.12); }
.ph-btn:active { transform: translateY(1px); }
.ph-btn.is-primary {
  background: linear-gradient(135deg, #c9a655, #e9c98b);
  border-color: transparent;
  color: #20242b;
}
.ph-btn.is-danger { border-color: rgba(226, 88, 88, 0.5); color: #ff9a9a; }
.ph-icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  color: #eef2f7;
}
.ph-icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* Body layout */
.ph-body {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  min-height: 0;
}
.ph-panel { overflow-y: auto; padding: 16px; background: rgba(12, 18, 27, 0.7); }
.ph-left { border-right: 1px solid rgba(255, 255, 255, 0.08); }
.ph-right { border-left: 1px solid rgba(255, 255, 255, 0.08); }
.ph-section { margin-bottom: 18px; }
.ph-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8fa2b6;
  margin: 0 0 8px;
}
.ph-subtitle { font-size: 11px; color: #7d8ea3; margin: 12px 0 6px; }
.ph-hint { font-size: 12px; color: #8497ac; margin: 6px 0 0; line-height: 1.4; }
.ph-empty {
  font-size: 12px;
  color: #7d8ea3;
  margin: 0;
  padding: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

/* Chips */
.ph-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.ph-chip {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: #dbe4ee;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ph-chip:hover { border-color: rgba(233, 201, 139, 0.6); }
.ph-chip.is-active {
  background: linear-gradient(135deg, #c9a655, #e9c98b);
  color: #20242b;
  border-color: transparent;
}

/* Device picker */
.ph-search {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: #eef2f7;
  padding: 8px 10px;
  font-size: 13px;
  margin-bottom: 10px;
}
.ph-search:focus { outline: none; border-color: #e9c98b; }
/* Brand tabs */
.ph-brand-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.ph-brand-tab {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
  color: #b8c4d2;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ph-brand-tab:hover { border-color: rgba(233, 201, 139, 0.5); color: #eef3f8; }
.ph-brand-tab.is-active {
  background: linear-gradient(135deg, #c9a655, #e9c98b);
  color: #20242b;
  border-color: transparent;
}

/* Device tile grid (clickable phone pictures) */
.ph-devices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 2px 4px 2px 2px;
}
.ph-dev-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.ph-dev-tile:hover { border-color: rgba(233, 201, 139, 0.55); background: rgba(255, 255, 255, 0.06); transform: translateY(-1px); }
.ph-dev-tile.is-active {
  border-color: #e9c98b;
  background: rgba(233, 201, 139, 0.14);
  box-shadow: 0 0 0 1px rgba(233, 201, 139, 0.5) inset;
}
.ph-dev-thumb { width: 44px; height: 62px; display: block; }
.ph-dev-name {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  color: #cdd7e2;
  text-align: center;
}
.ph-dev-tile.is-active .ph-dev-name { color: #f2e6c9; }
.ph-tile-star {
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 9px;
  color: #f2c14e;
}

/* Collage layout picker */
.ph-layouts { display: flex; flex-wrap: wrap; gap: 6px; }
.ph-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 44px;
  padding: 6px 4px 4px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
  color: #cdd7e2;
  border-radius: 10px;
  cursor: pointer;
}
.ph-layout:hover { border-color: rgba(233, 201, 139, 0.55); background: rgba(255, 255, 255, 0.06); }
.ph-layout.is-active { border-color: #e9c98b; background: rgba(233, 201, 139, 0.16); color: #f2e6c9; }
.ph-layout-ic { font-size: 17px; line-height: 1; }
.ph-layout-tx { font-size: 10px; font-weight: 600; }
.ph-layout-clear { justify-content: center; color: #e0b4ab; }
.ph-layout-clear:hover { border-color: #e0736055; color: #ffb4a6; }

/* Ready-made design ideas */
.ph-designs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 8px;
}
.ph-design {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 4px 5px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.ph-design:hover { border-color: rgba(233, 201, 139, 0.55); background: rgba(255, 255, 255, 0.06); transform: translateY(-1px); }
.ph-design.is-active { border-color: #e9c98b; background: rgba(233, 201, 139, 0.16); box-shadow: 0 0 0 1px rgba(233, 201, 139, 0.5) inset; }
.ph-design-thumb {
  width: 46px;
  height: 46px;
  border-radius: 9px;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.ph-design-tx { font-size: 10.5px; font-weight: 600; color: #cdd7e2; }
.ph-design.is-active .ph-design-tx { color: #f2e6c9; }

/* Case types */
.ph-cases { display: flex; flex-direction: column; gap: 7px; }
.ph-case {
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 9px;
  padding: 9px 11px;
  color: #dbe4ee;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ph-case.is-active { border-color: #e9c98b; background: rgba(233, 201, 139, 0.12); }

/* Fields */
.ph-field { display: flex; flex-direction: column; gap: 4px; }
.ph-field label { font-size: 11px; color: #8fa2b6; }
.ph-field input,
.ph-field select {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: #eef2f7;
  padding: 8px 10px;
  font-size: 13px;
}
.ph-field input:focus,
.ph-field select:focus { outline: none; border-color: #e9c98b; }
.ph-range { width: 100%; accent-color: #e9c98b; }
.ph-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: #b9c6d4;
  margin-top: 10px;
  cursor: pointer;
}

/* Swatches + gradients */
.ph-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.ph-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  padding: 0;
}
.ph-swatch.is-active { border-color: #e9c98b; box-shadow: 0 0 0 2px rgba(233, 201, 139, 0.4); }
.ph-gradients { display: flex; flex-wrap: wrap; gap: 7px; }
.ph-grad {
  width: 34px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  padding: 0;
}
.ph-grad.is-active { border-color: #e9c98b; box-shadow: 0 0 0 2px rgba(233, 201, 139, 0.4); }
.ph-bg-wrap.is-clear .ph-subtitle,
.ph-bg-wrap.is-clear .ph-gradients { opacity: 0.55; }

/* Price */
.ph-price {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
}
.ph-price-amount { font-size: 24px; font-weight: 800; color: #f5e6bf; }
.ph-price-unit { font-size: 13px; color: #cdd8e4; margin: 2px 0 6px; }
.ph-price small { font-size: 11px; color: #8497ac; line-height: 1.4; display: block; }

/* Stage */
.ph-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  background: radial-gradient(120% 120% at 50% 0%, #16202e 0%, #0b1017 70%);
  min-height: 0;
}
.ph-canvas-wrap {
  max-width: 100%;
  max-height: 74vh;
  border-radius: 22px;
  overflow: hidden;
}
.ph-canvas-wrap canvas {
  display: block;
  max-height: 72vh;
  width: auto;
  height: auto;
  touch-action: none;
  cursor: crosshair;
}
.ph-stage-hint { font-size: 12.5px; color: #9fb0c3; text-align: center; max-width: 520px; }

/* Add-to-case buttons */
.ph-add-photo { width: 100%; margin-bottom: 8px; }
.ph-add-text-btn { width: 100%; }

/* 2D / 3D view toggle */
.ph-view-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.ph-view {
  border: none;
  background: transparent;
  color: #cdd8e4;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.ph-view.is-active {
  background: linear-gradient(135deg, #c9a655, #e9c98b);
  color: #20242b;
}

/* Drag-and-drop empty state on the case */
.ph-canvas-wrap { position: relative; }
.ph-canvas-wrap.is-dragover::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px dashed #e9c98b;
  border-radius: 22px;
  background: rgba(233, 201, 139, 0.08);
  pointer-events: none;
}
.ph-drop-cta {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 22px;
  border-radius: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.5);
  background: rgba(11, 16, 23, 0.55);
  color: #eef2f7;
  cursor: pointer;
  backdrop-filter: blur(2px);
}
.ph-drop-cta[hidden] { display: none; }
.ph-drop-cta span { font-size: 26px; }
.ph-drop-cta strong { font-size: 14px; }
.ph-drop-cta small { font-size: 11.5px; color: #b9c6d4; }

/* 3D preview */
.ph-3d-wrap {
  position: relative;
  width: min(460px, 60vw);
  height: 72vh;
  max-height: 620px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Soft studio backdrop so the case reads as a premium product shot (and no
     white flash while the WebGL context warms up). */
  background: radial-gradient(120% 90% at 50% 30%, #1a2436 0%, #0c111b 70%);
  border-radius: 20px;
}
.ph-3d-wrap[hidden] { display: none; }
.ph-photo-wrap {
  position: relative;
  width: min(460px, 60vw);
  height: 72vh;
  max-height: 620px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 90% at 50% 30%, #1a2436 0%, #0c111b 70%);
  border-radius: 20px;
}
.ph-photo-wrap[hidden] { display: none; }
.ph-photo-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  filter: drop-shadow(0 26px 40px rgba(0,0,0,0.55));
}
.ph-3d-canvas { width: 100% !important; height: 100% !important; display: block; cursor: grab; }
.ph-3d-canvas:active { cursor: grabbing; }
.ph-3d-loading {
  position: absolute;
  font-size: 13px;
  color: #9fb0c3;
}
.ph-3d-loading[hidden] { display: none; }

/* Layers */
.ph-layers { display: flex; flex-direction: column; gap: 6px; }
.ph-layer {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px 10px;
  color: #dbe4ee;
  font-size: 13px;
  cursor: pointer;
}
.ph-layer.is-active { border-color: #e9c98b; background: rgba(233, 201, 139, 0.12); }
.ph-layer-ic {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 700;
}
.ph-layer-tx { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* Onboarding */
.ph-onboard {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 10, 18, 0.66);
  backdrop-filter: blur(4px);
  padding: 20px;
}
.ph-onboard[hidden] { display: none; }
.ph-onboard-card {
  max-width: 460px;
  background: #131c28;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.ph-onboard-kicker {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #e9c98b;
}
.ph-onboard-card h3 { margin: 8px 0 14px; font-size: 22px; }
.ph-onboard-card ol {
  margin: 0 0 20px;
  padding-left: 20px;
  color: #cdd8e4;
  line-height: 1.6;
  font-size: 14px;
}
.ph-onboard-card ol b { color: #f5e6bf; }

/* Toast */
.ph-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #20242b;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.14);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}
.ph-toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Remove-background popup */
.ph-bg-modal {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 10, 18, 0.7);
  backdrop-filter: blur(4px);
  padding: 22px;
}
.ph-bg-modal[hidden] { display: none; }
.ph-bg-dialog {
  width: min(760px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: #131c28;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.ph-bg-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.ph-bg-head strong { font-size: 18px; display: block; }
.ph-bg-head span { font-size: 12.5px; color: #b9c6d4; }
.ph-bg-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.ph-bg-pane { display: flex; flex-direction: column; gap: 6px; }
.ph-bg-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9fb0c0;
}
.ph-bg-view {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ph-bg-view.is-dragover { border-color: #6fd08c; background: rgba(111, 208, 140, 0.12); }
.ph-bg-checker {
  background-color: #e9edf2;
  background-image:
    linear-gradient(45deg, #cbd3dd 25%, transparent 25%),
    linear-gradient(-45deg, #cbd3dd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #cbd3dd 75%),
    linear-gradient(-45deg, transparent 75%, #cbd3dd 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.ph-bg-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.ph-bg-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  color: #cdd8e4;
  cursor: pointer;
  padding: 16px;
}
.ph-bg-pick span { font-size: 26px; }
.ph-bg-pick strong { font-size: 14px; }
.ph-bg-pick small { font-size: 11.5px; color: #93a3b4; }
.ph-bg-change {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11.5px;
  cursor: pointer;
}
.ph-bg-placeholder { font-size: 12px; color: #6a7f92; padding: 0 14px; text-align: center; }
.ph-bg-working { text-align: center; color: #cdd8e4; padding: 12px; }
.ph-bg-working p { margin: 10px 0 2px; font-size: 13px; font-weight: 600; }
.ph-bg-working small { font-size: 11px; color: #93a3b4; }
.ph-bg-spin {
  display: inline-block;
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: #6fd08c;
  border-radius: 50%;
  animation: ph-bg-spin 0.9s linear infinite;
}
@keyframes ph-bg-spin { to { transform: rotate(360deg); } }
.ph-bg-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.ph-bg-badge.is-working { background: rgba(20, 28, 40, 0.82); color: #cfe0ff; border: 1px solid rgba(255, 255, 255, 0.18); }
.ph-bg-badge.is-hd { background: rgba(21, 128, 61, 0.9); color: #eafff0; border: 1px solid rgba(255, 255, 255, 0.2); }
.ph-bg-spin-sm { width: 12px; height: 12px; border-width: 2px; }

.ph-bg-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}
.ph-bg-foot .ph-spacer { flex: 1; }

@media (max-width: 560px) {
  .ph-bg-main { grid-template-columns: 1fr; }
}

@media (max-width: 1080px) {
  .ph-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    overflow-y: auto;
  }
  .ph-panel { max-height: none; }
  .ph-stage { order: -1; min-height: 52vh; }
  .ph-canvas-wrap canvas { max-height: 56vh; }
}

@media (max-width: 760px) {
  .ph-topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }
  .ph-brand strong { font-size: 14px; }
  .ph-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .ph-left,
  .ph-right {
    border: 0;
    max-height: none;
  }
  .ph-stage {
    order: -1;
    min-height: 48vh;
    padding: 10px;
  }
  .ph-canvas-wrap {
    min-height: 42vh;
  }
  .ph-canvas-wrap canvas {
    max-width: 100%;
    max-height: 48vh;
    width: auto !important;
    height: auto !important;
  }
  .ph-panel {
    padding: 12px;
  }
  .ph-foot,
  .ph-bottom,
  [data-ph-use] {
    position: sticky;
    bottom: 0;
    z-index: 4;
  }
}
