/* Inkloom Merch Studio overlay */
.ms-root { position: fixed; inset: 0; z-index: 1200; display: none; }
.ms-root.is-open { display: block; }
body.ms-open { overflow: hidden; }
.ms-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(4px); }

.ms-panel {
  position: absolute; inset: 2.5vh 2.5vw; margin: auto; max-width: 1240px;
  background: #f6f8fb; border-radius: 20px; box-shadow: 0 30px 80px rgba(15, 23, 42, 0.45);
  display: flex; flex-direction: column; overflow: hidden;
  font-family: Inter, "Segoe UI", system-ui, sans-serif; color: #1b1f27;
}

.ms-head { display: flex; align-items: center; gap: 16px; padding: 14px 18px; background: #fff; border-bottom: 1px solid #e6eaf0; }
.ms-head-title { display: flex; flex-direction: column; line-height: 1.15; margin-right: auto; }
.ms-head-title strong { font-size: 1.12rem; }
.ms-head-title span { font-size: 0.78rem; color: #6b7280; }
.ms-tabs { display: flex; gap: 6px; background: #eef1f6; padding: 4px; border-radius: 999px; }
.ms-tab { border: 0; background: transparent; padding: 7px 18px; border-radius: 999px; font-weight: 600; font-size: 0.86rem; cursor: pointer; color: #4b5563; }
.ms-tab.is-active { background: #fff; color: #111827; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12); }
.ms-x { border: 0; background: #eef1f6; width: 38px; height: 38px; border-radius: 12px; cursor: pointer; display: grid; place-items: center; }
.ms-x svg { width: 18px; height: 18px; stroke: #374151; stroke-width: 2; fill: none; }

.ms-body { flex: 1; display: grid; grid-template-columns: 300px 1fr; min-height: 0; }
.ms-side { border-right: 1px solid #e6eaf0; background: #fff; overflow-y: auto; padding: 16px; }
.ms-block { margin-bottom: 18px; }
.ms-block h4 { margin: 0 0 8px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: #8a93a2; }

.ms-products { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ms-prod { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 4px; border: 1.5px solid #e3e8ef; border-radius: 12px; background: #fff; cursor: pointer; font-size: 0.66rem; font-weight: 600; color: #4b5563; text-align: center; }
.ms-prod svg { width: 24px; height: 24px; fill: none; stroke: #4b5563; stroke-width: 1.6; }
.ms-prod:hover { border-color: #c9a655; }
.ms-prod.is-active { border-color: #c9a655; background: #fdf7ea; color: #7a5c12; }
.ms-prod.is-active svg { stroke: #a9812a; }

.ms-swatch-row { display: flex; flex-wrap: wrap; gap: 7px; }
.ms-swatch { width: 26px; height: 26px; border-radius: 8px; border: 2px solid #dfe4ec; cursor: pointer; padding: 0; }
.ms-swatch.is-active { border-color: #111827; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #c9a655; }

.ms-row { display: flex; gap: 8px; }
.ms-input { width: 100%; border: 1.5px solid #dfe4ec; border-radius: 10px; padding: 8px 10px; font-size: 0.86rem; background: #fff; color: #1b1f27; font-family: inherit; }
.ms-qty { max-width: 84px; }
.ms-color { width: 42px; height: 38px; border: 1.5px solid #dfe4ec; border-radius: 10px; padding: 2px; background: #fff; cursor: pointer; }

.ms-tool-row { display: flex; gap: 8px; margin-bottom: 8px; }
.ms-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1.5px solid #dfe4ec; background: #fff; padding: 9px 12px; border-radius: 10px; font-weight: 600; font-size: 0.84rem; cursor: pointer; color: #1b1f27; flex: 1; }
.ms-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.ms-btn:hover { border-color: #c9a655; }
.ms-btn.primary { background: #111827; color: #fff; border-color: #111827; }
.ms-btn.primary:hover { background: #000; }
.ms-btn-wide { width: 100%; flex: none; }
.ms-btn.is-busy { opacity: 0.7; cursor: progress; }
.ms-btn .ms-spin { display: none; width: 15px; height: 15px; border: 2px solid rgba(0,0,0,0.15); border-top-color: #c9a655; border-radius: 50%; animation: ms-spin 0.7s linear infinite; }
.ms-btn.is-busy .ms-spin { display: inline-block; }
@keyframes ms-spin { to { transform: rotate(360deg); } }

.ms-layers { display: flex; flex-direction: column; gap: 6px; }
.ms-layer { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1.5px solid #e3e8ef; border-radius: 10px; cursor: pointer; font-size: 0.82rem; }
.ms-layer svg { width: 16px; height: 16px; fill: none; stroke: #6b7280; stroke-width: 1.6; }
.ms-layer span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-layer.is-active { border-color: #c9a655; background: #fdf7ea; }
.ms-layer-del { border: 0; background: transparent; cursor: pointer; padding: 2px; }
.ms-layer-del svg { width: 14px; height: 14px; stroke: #b0454a; }
.ms-empty { color: #9aa2b1; font-size: 0.82rem; margin: 0; }

.ms-stage { display: flex; flex-direction: column; min-width: 0; padding: 18px; overflow-y: auto; }
.ms-canvas-wrap { position: relative; flex: 1; display: grid; place-items: center; border: 2px dashed transparent; border-radius: 16px; min-height: 300px; }
.ms-canvas-wrap.is-drag { border-color: #c9a655; background: rgba(201, 166, 85, 0.06); }
.ms-canvas { max-width: 100%; max-height: 58vh; border-radius: 12px; background: #fff; box-shadow: 0 12px 40px rgba(15, 23, 42, 0.14); touch-action: none; }
.ms-preview-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ms-preview { max-width: 100%; border-radius: 12px; }
.ms-preview-hint { margin: 0; font-size: 0.82rem; color: #6b7280; }

.ms-drop-cta { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; pointer-events: none; }
.ms-drop-cta strong { font-size: 1rem; }
.ms-drop-cta small, .ms-drop-cta span { font-size: 0.82rem; color: #6b7280; }
.ms-drop-cta .ms-btn { pointer-events: auto; margin-top: 6px; flex: none; }

.ms-sel { margin-top: 14px; background: #fff; border: 1px solid #e6eaf0; border-radius: 14px; padding: 14px; }
.ms-sel[hidden] { display: none; }
.ms-sel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.ms-sel-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ms-chip { border: 1.5px solid #dfe4ec; background: #fff; border-radius: 8px; padding: 5px 10px; font-size: 0.76rem; font-weight: 600; cursor: pointer; color: #374151; }
.ms-chip:hover { border-color: #c9a655; }
.ms-chip.danger { color: #b0454a; border-color: #f0d5d7; }
.ms-sel textarea.ms-input { resize: vertical; margin-bottom: 8px; }
.ms-slider { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; color: #4b5563; margin-top: 10px; }
.ms-slider input { flex: 1; }

.ms-foot { display: flex; align-items: center; gap: 16px; padding: 14px 18px; background: #fff; border-top: 1px solid #e6eaf0; }
.ms-price { font-size: 0.86rem; color: #4b5563; margin-right: auto; }
.ms-use { flex: none; padding: 11px 26px; font-size: 0.92rem; }

.ms-toast { position: absolute; bottom: 84px; left: 50%; transform: translateX(-50%) translateY(12px); background: #111827; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 0.84rem; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 5; }
.ms-toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .ms-panel { inset: 0; border-radius: 0; max-width: none; }
  .ms-body { grid-template-columns: minmax(0, 1fr); }
  .ms-side {
    border-right: 0;
    border-bottom: 1px solid #e6eaf0;
    max-height: 38vh;
    -webkit-overflow-scrolling: touch;
  }
  .ms-stage { padding: 12px; order: -1; }
  .ms-canvas,
  .ms-preview { max-width: 100%; max-height: 46vh; }
  .ms-head { flex-wrap: wrap; gap: 10px; padding: 12px; }
  .ms-tabs { order: 3; width: 100%; justify-content: center; }
  .ms-products { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ms-foot {
    position: sticky;
    bottom: 0;
    z-index: 4;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
  }
  .ms-price { width: 100%; margin-right: 0; }
  .ms-use { width: 100%; }
  .ms-sel { padding: 12px; }
}
