:root{
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --border: rgba(15,23,42,.10);
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
  --radius: 14px;
}

/* ==========================================
   FULL SIZE / FLEXBOX 100x100 FIX
   - If parent has height:100% (like a 100x100 flex container),
     this will stretch fully.
   - Also gives a nice full screen default with min-height:100vh.
   ========================================== */

.my3dapp-shell{
  display:grid;
  grid-template-columns: 280px 1fr 340px;
  gap: 14px;
  background: var(--bg);
  padding: 14px;
  border-radius: calc(var(--radius) + 4px);

  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100vh;
  box-sizing: border-box;
}

.my3dapp-left,
.my3dapp-right,
.my3dapp-center{
  min-height: 0; /* IMPORTANT: allow stretching inside flex parents */
}

.my3dapp-canvas-wrap{
  position: relative;

  height: 100%;
  min-height: 0; /* IMPORTANT: don't force 560px if parent is controlling height */

  background: radial-gradient(1200px 600px at 50% 0%, #ffffff 0%, #f1f5f9 60%, #eef2ff 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}

#my3dapp-canvas{
  width: 100%;
  height: 100%;
  display:block;
}

.my3dapp-left, .my3dapp-right{
  /* was: min-height:560px; removed for full-stretch layouts */
}

.my3dapp-panel{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  gap: 10px;
}

.my3dapp-panel + .my3dapp-panel{ margin-top: 14px; }

.my3dapp-panel-title{
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 10px;
}

.my3dapp-center{
  /* was: min-height:560px; removed for full-stretch layouts */
}

.my3dapp-status{
  position:absolute;
  left: 12px;
  bottom: 12px;
  padding: 8px 10px;
  background: rgba(255,255,255,.85);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  box-shadow: 0 8px 24px rgba(15,23,42,.08);
}

.my3dapp-btn{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
  transition: transform .06s ease, filter .15s ease;
  user-select:none;
}

.my3dapp-search{
  margin-bottom: 10px;
}

.my3dapp-btn:active{ transform: translateY(1px); }

.my3dapp-btn-primary{
  background: var(--accent);
  color: white;
  border-color: rgba(79,70,229,.35);
  margin-bottom: 10px;
}
.my3dapp-btn-secondary{
  background: #eef2ff;
  color: #1e1b4b;
}
.my3dapp-btn-ghost{
  background: transparent;
  color: var(--text);
}

.my3dapp-hint{
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.my3dapp-product-title{
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
  margin: 6px 0 6px;
}

.my3dapp-price{
  font-size: 14px;
  color: var(--text);
  margin-bottom: 10px;
}

.my3dapp-desc{
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 12px;
}

.my3dapp-row{ display:flex; gap:10px; align-items:center; margin: 10px 0; }

.my3dapp-qty{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap:10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.my3dapp-qty span{ font-size: 12px; color: var(--muted); }
.my3dapp-qty input{
  width: 90px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
}

.my3dapp-actions{
  display:grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* Library */
.my3dapp-library{ display:flex; flex-direction:column; gap:10px; }
.my3dapp-library-item{
  display:flex;
  gap:10px;
  width:100%;
  text-align:left;
  padding:10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background:#fff;
  cursor:pointer;
}
.my3dapp-thumb{
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  background:#f8fafc;
}
.my3dapp-thumb img{ width:100%; height:100%; object-fit:cover; }
.my3dapp-thumb-fallback{ font-weight:800; font-size:12px; color: var(--muted); }
.my3dapp-lib-name{ font-weight:800; font-size:13px; color: var(--text); }
.my3dapp-lib-sub{ font-size:12px; color: var(--muted); }

/* Overlay + modal */
.my3dapp-overlay{
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .40);
  display:none;
  align-items:center;
  justify-content:center;
  padding: 18px;
  z-index: 9999;
}
.my3dapp-overlay.is-open{ display:flex; }

.my3dapp-modal{
  width: min(1100px, 100%);
  background: var(--panel);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
  border: 1px solid var(--border);
  overflow:hidden;
  transform: translateY(6px);
  animation: my3dappPop .14s ease-out forwards;
}
@keyframes my3dappPop{
  to { transform: translateY(0); }
}
.my3dapp-modal-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.my3dapp-modal-title{
  font-weight: 850;
  color: var(--text);
}
.my3dapp-icon-btn{
  border: 1px solid var(--border);
  background:#fff;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  cursor:pointer;
  font-size: 16px;
}

.my3dapp-modal-body{ padding: 12px; }

.my3dapp-editor-toolbar{
  display:flex;
  gap: 10px;
  align-items:center;
  margin-bottom: 10px;
}
.my3dapp-file input{ display:none; }
.my3dapp-tool-group{
  display:flex;
  gap: 8px;
  align-items:center;
}
.my3dapp-tool-group .my3dapp-btn{
  width:auto;
  padding: 10px 12px;
}
.my3dapp-spacer{ flex: 1; }
#my3dapp-apply{ width: auto; padding: 10px 16px; }

.my3dapp-editor-stage{
  position: relative;
  height: 560px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow:hidden;
  background: #f8fafc;
}

.my3dapp-blueprint{
  position:absolute;
  inset: 0;
  padding: 12px;
}

.my3dapp-art-layer{
  position:absolute;
  inset: auto;
  display:none;
  border: 2px dashed rgba(79,70,229,.55);
  border-radius: 10px;
  transform-origin: center;
  cursor: move;
}
.my3dapp-art-layer img{
  width:100%;
  height:100%;
  object-fit: contain;
  display:block;
  pointer-events: none;
  user-select:none;
}
.my3dapp-handle{
  position:absolute;
  width: 14px;
  height: 14px;
  border-radius: 6px;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 10px 20px rgba(0,0,0,.15);
}
.my3dapp-handle-br{ right: -8px; bottom: -8px; cursor: nwse-resize; }

.my3dapp-editor-foot{
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 1100px){
  .my3dapp-shell{ grid-template-columns: 260px 1fr; }
  .my3dapp-right{ grid-column: 1 / -1; }
}
@media (max-width: 720px){
  .my3dapp-shell{ grid-template-columns: 1fr; min-height: 100vh; }
  .my3dapp-left, .my3dapp-right{ min-height: auto; }
  .my3dapp-editor-stage{ height: 420px; }
}

/* ===============================
   SVG FIT FIX (ONLY ADDITION)
   =============================== */
.my3dapp-blueprint svg{
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
  preserveAspectRatio: xMidYMid meet;
}

/* =========================
   LIBRARY UI FIX (ONLY)
   ========================= */

/* Simple one-piece search input */
.my3dapp-search-simple{
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  margin-bottom: 10px;
}

/* Icon inside input (simple gray) */
.my3dapp-search-simple .my3dapp-search-ico{
  width: 18px;
  height: 18px;
  margin-right: 10px;
  opacity: .65;
  background: currentColor;
  color: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M10 18a8 8 0 1 1 0-16a8 8 0 0 1 0 16m11 3l-6-6'/%3E%3C/svg%3E") no-repeat center / contain;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M10 18a8 8 0 1 1 0-16a8 8 0 0 1 0 16m11 3l-6-6'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* Make the real input clean */
.my3dapp-search-simple .my3dapp-search{
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
  color: var(--text);
  margin: 0 !important;
  padding: 0;
  width: 100%;
}

/* Focus ring */
.my3dapp-search-simple:focus-within{
  border-color: rgba(15,23,42,.18);
  box-shadow: 0 10px 26px rgba(15,23,42,.08);
}

/* Library item: align name with thumbnail */
.my3dapp-library-item{
  align-items: center;
  border-color: var(--border);
}

.my3dapp-lib-meta{
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.my3dapp-lib-name{
  margin: 0;
  line-height: 1.2;
}

/* Load more full width + spacing */
.my3dapp-loadmore{
  width: 100%;
  margin-top: 10px;
}

.my3dapp-library-item.is-active{
  border-color: rgba(15,23,42,.18);
  box-shadow: 0 10px 26px rgba(15,23,42,.08);
}

/* =========================
   SIMPLE PRICE UNDER QTY
   ========================= */

.my3dapp-product-price-simple{
  margin: 8px 0 12px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}
