: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 “ONE PAGE” VIEWPORT LAYOUT FIX (NO PAGE SCROLL)
   ========================================================= */

.my3dapp-shell{
  display:grid;
  grid-template-columns: 280px 1fr 340px;
  gap: 14px;
  background: #E6EDFF;
  padding: 14px;
  border-radius: calc(var(--radius) + 4px);
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

@supports (height: 100dvh){
  .my3dapp-shell{
    height: 100dvh;
    max-height: 100dvh;
  }
}

body.admin-bar .my3dapp-shell{
  height: calc(100vh - 32px);
  max-height: calc(100vh - 32px);
}
@supports (height: 100dvh){
  body.admin-bar .my3dapp-shell{
    height: calc(100dvh - 32px);
    max-height: calc(100dvh - 32px);
  }
}

.my3dapp-left,
.my3dapp-right,
.my3dapp-center{
  min-height: 0;
}

.my3dapp-left,
.my3dapp-right{
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.my3dapp-center{
  overflow: hidden;
}

.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;
}

/* Canvas */
.my3dapp-canvas-wrap{
  position: relative;
  height: 100%;
  min-height: 0;
  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-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{
  margin-top:10px;
  display:grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* =========================================================
   Library
   (ONLY this section uses !important to beat theme CSS)
   ========================================================= */

.my3dapp-library{
  display:flex !important;
  flex-direction:column !important;
  gap:10px !important;
}

.my3dapp-library-item{
  display:flex !important;
  flex-direction:row !important;
  gap:10px !important;
  width:100% !important;
  text-align:left !important;
  padding:10px !important;
  border-radius: 12px !important;
  border: 1px solid var(--border) !important;
  background:#fff !important;
  cursor:pointer !important;
  align-items:center !important;
  justify-content:flex-start !important;
}

.my3dapp-thumb{
  width: 44px !important;
  height: 44px !important;
  flex: 0 0 44px !important;
  border-radius: 12px !important;
  border: 1px solid var(--border) !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  overflow:hidden !important;
  background:#f8fafc !important;
}

.my3dapp-thumb img{
  width:100% !important;
  height:100% !important;
  object-fit:cover !important;
  display:block !important;
}

.my3dapp-thumb-fallback{
  font-weight:800 !important;
  font-size:12px !important;
  color: var(--muted) !important;
}

.my3dapp-lib-meta{
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
  text-align:left !important;
  align-items:flex-start !important;
}

.my3dapp-lib-name{
  font-weight:800 !important;
  font-size:13px !important;
  color: var(--text) !important;
  margin: 0 !important;
  line-height: 1.2 !important;
  text-align:left !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.my3dapp-lib-sub{
  font-size:12px !important;
  color: var(--muted) !important;
  text-align:left !important;
  margin-top: 2px !important;
}

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

.my3dapp-loadmore{
  width: 100% !important;
  margin-top: 10px !important;
}

/* =========================================================
   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 solid rgba(79,70,229,.55); /* was dashed */
  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;
}

/* (Removed old .my3dapp-handle + .my3dapp-handle-br because it conflicts with new pro handles) */

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

@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; }
  .my3dapp-editor-stage{ height: 420px; }
}

/* SVG FIT FIX */
.my3dapp-blueprint svg{
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
  /* NOTE: preserveAspectRatio is an SVG attribute, not a CSS property */
}

/* LIBRARY UI FIX (search bar) */
.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;
}

.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;
}

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

.my3dapp-search-simple:focus-within{
  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);
}

/* --- UV editor: pro guides + mask + handles --- */

.my3dapp-guide {
  position: absolute;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 90ms ease, transform 90ms ease;

  /* removed glow/shadow */
  filter: none;
}

/* NEW: kad je upaljen, nek bude jače vidljiv */
.my3dapp-guide.is-on { opacity: 1 !important; }
.my3dapp-guide.is-hit { opacity: 1 !important; }

.my3dapp-guide--v {
  top: 0;
  bottom: 0;
  width: 2px;

  /* pink “dashed” (not dots) */
  background: repeating-linear-gradient(
    to bottom,
    #ff2da1 0px,
    #ff2da1 6px,
    rgba(0, 0, 0, 0) 6px,
    rgba(0, 0, 0, 0) 12px
  );
}

.my3dapp-guide--h {
  left: 0;
  right: 0;
  height: 2px;

  /* pink “dashed” (not dots) */
  background: repeating-linear-gradient(
    to right,
    #ff2da1 0px,
    #ff2da1 6px,
    rgba(0, 0, 0, 0) 6px,
    rgba(0, 0, 0, 0) 12px
  );
}

/* “Hit the limit” state = smart guide (isprekidano) */
.my3dapp-guide--v.is-hit {
  background: repeating-linear-gradient(
    to bottom,
    #ff2da1 0px,
    #ff2da1 6px,
    rgba(0, 0, 0, 0) 6px,
    rgba(0, 0, 0, 0) 12px
  );
  transform: scale(1.03);
}

.my3dapp-guide--h.is-hit {
  background: repeating-linear-gradient(
    to right,
    #ff2da1 0px,
    #ff2da1 6px,
    rgba(0, 0, 0, 0) 6px,
    rgba(0, 0, 0, 0) 12px
  );
  transform: scale(1.03);
}

/* Active area outline */
.my3dapp-panel-outline {
  position: absolute;
  z-index: 9998;
  pointer-events: none;
  opacity: 0;
  transition: opacity 90ms ease;
  border: 2px solid rgba(30, 144, 255, 0.95);
  border-radius: 6px;
}

.my3dapp-panel-outline.is-on { opacity: 1; }

/* Outside mask: darken everything outside the active area */
.my3dapp-panel-mask {
  position: absolute;
  inset: 0;
  z-index: 9997;
  pointer-events: none;
  opacity: 0;
  transition: opacity 90ms ease;
}

.my3dapp-panel-mask.is-on { opacity: 1; }

.my3dapp-panel-mask__shade {
  position: absolute;
  background: rgba(0,0,0,0.18);
}

/* Handles (new system) */
#my3dapp-art-layer { cursor: move; }

#my3dapp-art-layer .my3dapp-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(30, 144, 255, 0.98);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  user-select: none;
}

#my3dapp-art-layer .my3dapp-handle:hover { transform: scale(1.08); }

#my3dapp-art-layer .my3dapp-handle[data-handle="n"],
#my3dapp-art-layer .my3dapp-handle[data-handle="s"] { cursor: ns-resize; }

#my3dapp-art-layer .my3dapp-handle[data-handle="ne"],
#my3dapp-art-layer .my3dapp-handle[data-handle="sw"] { cursor: nesw-resize; }

#my3dapp-art-layer .my3dapp-handle[data-handle="nw"],
#my3dapp-art-layer .my3dapp-handle[data-handle="se"] { cursor: nwse-resize; }

/* Rotate handle */
#my3dapp-art-layer .my3dapp-rotate {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 140, 0, 0.98);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  cursor: grab;
}

#my3dapp-art-layer .my3dapp-rotate:active { cursor: grabbing; }